May
9
Printing a file from the right-click context menu in Nautilus
Sun, 05/09/2010 - 19:41
By default, Gnome does not provide a print option in the right-click menu of the file browser. Luckily it is very easy to add more functions to this menu.
Nautilus will look into the ~/.gnome2/nautilus-scripts folder and add the files it finds there to the 'scripts'-entry in the context menu that pops up whenever your right-click a file.
Create a file called 'print.sh' in this folder and paste the following script in it:
#!/bin/bash
#
# print.sh
#
# Print files from the right-click context menu in Nautilus.
# Place this script in ~/.gnome2/nautilus-scripts.
# The printer to use (as shown in the Printer Configuration
# gui or in /etc/cups/printers.conf).
printer=HP-Color-LaserJet-CP1215
echo "$NAUTILUS_SCRIPT_SELECTED_FILE_PATHS" | while read file
do
lpr -P "$printer" "$file"
done
exit 0
Replace "HP-Color-LaserJet-CP1215" with your own printer model. You can find the exact model name in the CUPS printer configuration GUI (Ubuntu: System > Administration > Printing).
Save the file, and make it executable:
$ sudo chmod u+x ~/.gnome2/nautilus-scripts/print.sh
From now on you can easily print multiple files directly from the file manager without having to open them first.
Reference:
Ubuntu: Printing with a mouse right-click - the inspiration for this article.

this doesn't seem to work for me. when i execute the lpr command from the terminal it works fine, but the script appears to do nothing. do you have any idea how i can troubleshoot it? thanks
dan
did you make the script executable?
Hi
Thanks for the tip!
Can this be adapted somehow to enable printing direct to pdf (from rt click context menu)?
Grateful for your advice!
Many thanks
Sure, you can add a virtual PDF printer with Cups-PDF. On Ubuntu you can install it with:
$ sudo apt-get install cups-pdfA new printer named "PDF" will be added. Use this line in the script:
printer=PDFthank you friend it was very useful!!! God bless you
Seems to be a small typo. Initially, the file is called 'print.sh', but in the terminal command below, it's called 'printING.sh', so copy-pasting that command line would fail... Thanks for a great idea though!ondexte
Well spotted :) I'll fix it. Thanks!!
Hi,
Thanks for the idea. Its really working like a charm.
I have one input & one question.
Input: when we use printer=PDF, the file goes to the ~/PDF folder. ( After some googling i found this).
Question: Can i print all the documents into one pdf instaed of individual pdfs ?
oh i love you for that script thaaanks a lot
Really Great, thanks for the contribution!
Brilliant!
Post new comment