Disable printing in rxvt and urxvt

For a while now, I’ve been using urxvt as my terminal of choice in Linux – it’s small, light and fast, as all terminals should be, but still has some decent features. However, I won’t take that discussion any further – the rest of the internet should provide you with plenty of reading material on the topic of terminal choice.

The issue I’ve been having is that I sometimes got a page out of my printer consisting of the contents of the terminal window. urxvt (and its non-Unicode sibling rxvt) have a sometimes-handy feature that pressing Print Screen will print such a page. However, it also seems that there’s another key combination that does the same thing, since I’m not aware of pressing Print Screen but have still been wasting paper and ink on useless printouts. For the sake of my pocket (and the trees – won’t someone please think of the trees!), I decided that this state of affairs could not continue, so I figured out how to disable printing altogether.

It turns out that (u)rxvt has an option to specify what command it runs when it’s asked to print something, so it’s a trivial matter to make it send its output to the black hole that is /dev/null. Simply add one of the following lines to your ~/.Xdefaults file (depending on which terminal you’re using):

rxvt.print-pipe: "cat > /dev/null"
urxvt.print-pipe: "cat > /dev/null"

Restart your terminal, and you’ll never see it printing things again.

Of course, if you can think of a reason why you might want to print the terminal contents, you can always set the destination of the cat command to a file somewhere, so you can grab its contents if you need them. As always, the choice is yours.

May 26, 2011   Tags: linux/ubuntu

8 Responses

  1. EgilHa - June 11, 2011

    Thanks! That was really annoying.

  2. squaregoldfish - June 11, 2011

    No problem. Do you happen to know what key combination was triggering the print? I’d like to know, because disabling the key combo would be better than disabling the whole print mechanism.

  3. 童貞 - August 3, 2011

    Thanks for this. I was on a network where the default printer was some random thing in a different part of the building, so I didn’t even notice this for months…

  4. PLum - August 23, 2012

    damn, today i printed in work 200pages,… thx for the tip!!!

  5. Poing - December 6, 2012

    Thank you *very* much!

  6. Sebastian - August 9, 2013

    FTM, restarting (u)rxvt only pulls the new X resources after an ‘xrdb -merge ~/.Xdefaults’.


  7. Hendrik - January 27, 2014

    Thank you, I’ve been sporadically printing terminal pages for years! (On a common printer in the office’s printing room. Embarassing when your colleagues go through your console stuff with all typos, regexes and so on).

  8. sk - October 10, 2016

    Thank you very much. I was afraid my work pc was compromised.

Leave a Reply