In 10.10, when opening a directory in Nautilus, I was wondering how to copy the current path?
My address bar, pictured here, is not copyable:
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It only takes a minute to sign up.
Sign up to join this communityCtrl+L
. Very frustrating to not find an option in the View menu (which should then be clearly labeled Ctrl+L). Had to do a web search.
And then very frustrating to find that Ctrl+L doesn't toggle it back. Another web search... Drum roll... Esc
And then, how to set your preference? Web search... Have to install gconf-editor or dconf-editor or manually use a terminal command:
gsettings set org.gnome.nautilus.preferences always-use-location-entry true
http://ubuntuforums.org/showthread.php?t=1504058
Of course, this would be a little less painful if there were a 'terminal here' option in the context menu. Web search... Install nautilus-open-terminal
How do I open a terminal in the current location?
Sigh. Oversimplified interfaces are so hard to figure out. I appreciate all the helpful answers people have put on the web for us to find.
May I ask why you want the path?
If you want the path because you want to use it and navigate directly from the terminal, then you can simply install nautilus-open-terminal using synaptic.
Or
sudo apt-get install nautilus-open-terminal
After that, simply right click on any folder and use "Open in terminal"
If you simply want the path, then Ctrl + L would do just fine.
Copy the file or folder. When you paste on terminal or text editor, it will paste the path, not the file or folder.
Paste
#!/bin/bash
echo -n "${PWD}" | xclip -selection clipboard
into ~/.local/share/nautilus/scripts/Copy Directory Path
.
(requires that xclip is installed)
You can now right-click on a file, mouse over "Scripts", and choose "Copy Directory Path" to copy the path of the directory that contains the file. Caveat: will not work in an empty directory.
echo -n "${PWD}"
: Echoes the current working directory (Nautilus sets the working directory of the script to the one you had open in the window from which you ran the script) without a trailing newline. Initially I considered pwd | head -c -1
, since pwd includes a trailing newline, but that was two unnecessary calls to external programs compared to echo
.xclip -selection clipboard
: xclip
by default copies to the X11 "primary" clipboard, but most desktop environments use the "clipboard" clipboard for their clipboard. I can't believe I just wrote thatYou can also type into your terminal gconftool-2 --type=Boolean --set apps/nautilus/preferences/always_use_location_entry true
so that you always get a text based location bar.
Additional to the answer of Nonny Moose, you can create, and use a Shortcut for copy to the clipboard the Path to your file/folder. Thus, you select a folder or a file in Nautilus, and then press a shortcut, and you will have you Path to that folder/file in the Clipboard ready to be pasted.
You can do in the following manner:
Install Xclip: $ sudo apt install xclip
Create and save a script in ~/.local/share/nautilus/scripts as follow:
#!/bin/sh
echo -n "${PWD}" | xclip -selection clipboard
Create the following file in /home/user_name/.config/nautilus
F6
is the shortcut you want to assign to run this script, space and then the name of the script you want to run, in this case the file name you just have created in the previous step.
F6 Nautilus-Copy-Path
Restart Nautilus
cd
to the directory Nautilus is in. A quick way to do that would be toright-click
and selectopen in terminal
(as long as your~/.bashrc
doesn't set yourpwd
)