Until recently, one could add custom links to the left pane of Nautilus by dragging a folder. It seems this option no longer works (since Ubuntu 10.10 (Maverick Meerkat) or 11.04 (Natty_Narwhal)). How do I get this to work on a recent version of Ubuntu?
Ubuntu – How to add custom links in the left pane of Nautilus
nautilus
Related Solutions
As aneeshep's answer explains, the key is creating an appropriate .desktop
"launcher". But there's a simpler way than doing it by hand; in many cases, you may not even need to edit the .desktop
file.
Solution: Use Ubuntu Tweak
- Ubuntu Tweak is a utility, which among other things, allows you to associate file types to be opened with a custom command. Behind the scenes, it creates a
.desktop
file which you can edit further for your needs, e.g. if you are using a command-line editor or program to open, etc.
In this how-to, we look at how to set up Nautilus to open .php
files in the free Komodo Edit GUI text editor, which comes with a shell-installer that installs it in your home directory by default; the program/command is then /home/user/Komodo-Edit-7/bin/komodo
1. Install Ubuntu Tweak
Add its PPA, update and install Ubuntu Tweak from the terminal with:
sudo apt-add-repository ppa:tualatrix/ppa sudo apt-get update sudo apt-get install ubuntu-tweak
Update: Check this question for updated instructions for newer Ubuntu releases
2. Find the MIME description for your file extension
- Before using Ubuntu Tweak, we need to find the MIME description for the file extension we're interested in.
Open Nautilus, find one of the files we want (here,
.php
), right-click on it and click on Properties:In the Properties window which comes up, note the text shown just after Type:; that's the MIME description we're looking for (here, "PHP Script"):
3. Add a custom program to open your filetype
Start Ubuntu Tweak from the Dash, and click on the Admins tab on top; then click on the File Type Manager entry on the bottom:
After the File Type Manager opens, click on All in the left sidebar, and uncheck the Only show filetypes... box at the bottom:
Select any filetype on the right side, and begin typing the first few letters of the MIME description from Step 2 to automatically search and select your filetype:
Double-click on your filetype, which is now selected, to edit its associated commands.
- Click on Add, and in the Add Application window, expand the Custom Command option on the bottom
- Type the command/program you want or use the Browse button to navigate to it and select it; here we have selected the Komodo-Edit editor from my home folder:
- Click on Add, so the new command is now the default, and then click Close:
PHP files will now open in Komodo by default, as seen in the Properties below; press the Reset button to go back to the default for that filetype:
Here is a small Nautilus script which gives you a "Use a custom command" dialogue box on Nautilus.
The Script
Save the following script as Open with custom command
in the following directory
~/.local/share/nautilus/scripts/
(Ubuntu 13.04 or above)~/.gnome2/nautilus-scripts/
(Ubuntu 12.10 and below)
#!/bin/bash
var=$(zenity --entry \
--title="Add Application" \
--text="Use a custom command" \
--width="320")
if [ $? -eq 0 ] && [ "$var" ]; then
$var "$1"
else
exit 0
fi
- Give the script execution permission. It is important, otherwise no change will take place. You can use in terminal,
chmod +x ~/.local/share/nautilus/scripts/Open\ with\ custom\ command
Or you can do it from GUI. Right click on the script, then go to Properties >> Permissions and check the box corresponds to Execute to give the script execution permission.
How it looks like
After that when you right click on a file you could see an option Scripts followed by another option under script Open with custom command.
When you select the option Open with custom command, you will get a dialogue box like,
You can write a command in the box to open the file.
Usage
You can open any file by entering corresponding application's command only in the dialogue box.
For example you can open a .txt
file using gedit
or a .pdf
file writing evince
in the dialogue box.
Some Other Usage
Open file as root:
If you want to open a file as root, just use gksudo
before your command. To open a .txt
file as root you can use in the dialogue box,
gksudo gedit
Opening an unknown file:
If you are not sure which application to use to open an unknown file, you can use in the dialogue box,
xdg-open
Opening a file with a Terminal Application:
If you want to open a text file using vi
, you can use in the dialogue box,
gnome-terminal -x vi
Note:
To use gksudo
you need to have gksu
installed. In Ubuntu 13.04 onwards it is not install by default. You can install it using,
sudo apt-get install gksu
Best Answer
Select the folder you want to link, then go to the top menu bar and select Bookmarks -> Add Bookmark.
When inside the folder that you want to bookmark, go to the top menu bar and select Bookmarks -> Bookmark this location -- or Ctrl+D.