I often find myself browsing my filesystem with Nautilus (the GNOME file manager) and wanting a terminal window to manipulate files in the current directory. I decided to take a shot at writing my own Nautilus script to solve the problem. So here's my first Nautilus script. Save it in $HOME/.gnome2/nautilus-scripts. I named it terminal-here on my system.
#!/bin/bash # # Nautilus script - terminal-here # This script will open a GNOME Terminal in the current directory. # Written by Linerd in August, 2009 - https://tuxtweaks.com/ # # Save this script under $HOME/.gnome2/nautilus-scripts/terminal-here. Make sure that # you give this file executable permission. { chmod +x terminal-here } # # This program is free software. It is distributed in the hope # that it will be useful, but WITHOUT ANY WARRANTY; without even # the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR # PURPOSE. See the GNU General Public License for more details. ###################################################################### if [ "$NAUTILUS_SCRIPT_CURRENT_URI" == "x-nautilus-desktop:///" ]; then DIR=$HOME"/Desktop" else DIR=`echo $NAUTILUS_SCRIPT_CURRENT_URI | sed 's/^file:\/\///' | sed 's/%20/ /g'` fi gnome-terminal --working-directory="$DIR" exit 0
Make sure to make the file executable.
You can now launch a terminal by right clicking in Nautilus and selecting Scripts->terminal-here.
Being quite pleased with myself for my accomplishment, I then searched the web for similar solutions. Not only had others written scripts to do this, but some even chose the same name. The winner for being brief and simple was one I found on SourceForge, also called terminal-here.
I also found that there is also a plugin available for Nautilus that does the same thing. You can install it with
You will need to log out and log back in for the plugin to show up in the context menu. It's nice that it's right there on the menu when you right click rather than being buried in a sub-menu under the Scripts menu.
I ended up finding a couple of better solutions than my own hack, but it was a good learning process.
#
Doesn't work for folders with UTF-8 character encoding.
#
#
Thanks, very useful for me. I knew about nautilus-open-terminal but I don't use it because of the lack of support for konsole. Your script with James' patch is just what I need.
#
Although the other script you mentioned is shorter, it doesn't work if you use konsole. I was able to adapt your version for use with konsole so it opens in nautilus' current directory!
Simply replace the gnome-terminal line with:
konsole --workdir "$DIR"
#