HOWTO: Quickly Open a Terminal From Nautilus
This has probably been covered before, but I couldn`t see it anywhere...
Anyway, this is a quick method of dropping to a terminal from nautilus, which automatically changes directory to wherever you were browsing with nautilus. (For any local location - won`t work with ftp or other esoteric locations).
Big thanks to the guys in the Drag and Drop To Run As Root HOWTO thread for showing me how this could be achieved.
HOWTO: Quickly Open a Terminal From Nautilus
- Open a Terminal
- Type:
Code:
cd ~/.gnome2/nautilus-scripts
- Type:
Code:
gedit Open\ Terminal\ Here
- Paste the following code into the file:
Code:
#!/bin/sh
# From Chris Picton
# Replaces a Script by Martin Enlund
# Modified to work with spaces in path by Christophe Combelles
# This script either opens in the current directory,
# or in the selected directory
base="`echo $NAUTILUS_SCRIPT_CURRENT_URI | cut -d'/' -f3- | sed 's/%20/ /g'`"
if [ -z "$NAUTILUS_SCRIPT_SELECTED_FILE_PATHS" ]; then
dir="$base"
else
while [ ! -z "$1" -a ! -d "$base/$1" ]; do shift; done
dir="$base/$1"
fi
gnome-terminal --working-directory="$dir"
- Save the gedit file, and quit.
- Back in the terminal type:
Code:
chmod +x Open\ Terminal\ Here
et voila....
In any nautilus window, you can right click, and from the scripts sub-context-menu, click on Open Terminal Here to open a terminal at the currently viewed directory.
[EDIT] You can now highlight a folder and perform the operation to open a terminal at the location highlighted.
Hope somebody besides me finds this useful - the lack of this option has driven me batty since my foray into linux. :)
Re: HOWTO: Quickly Open a Terminal From Nautilus
Works perfectly. You just got rid of the last advantage KDE has over Gnome.
Re: HOWTO: Quickly Open a Terminal From Nautilus
Re: HOWTO: Quickly Open a Terminal From Nautilus
Quote:
Originally Posted by jonny
Works perfectly. You just got rid of the last advantage KDE has over Gnome.
Yeah, Gnome rulez!
Re: HOWTO: Quickly Open a Terminal From Nautilus
Re: HOWTO: Quickly Open a Terminal From Nautilus
Great how-to. I didn't realize how useful this was until I tried it and now I can't live without it!
Do you know if there is a manual to see what variables are available? For instance, there is $NAUTILUS_SCRIPT_CURRENT_URI and $NAUTILUS_SCRIPT_SELECTED_URIS. Any more? I bet a lot of useful scripts can be made. In fact, I'm going to make a couple right now and do how tos if they work well.
Re: HOWTO: Quickly Open a Terminal From Nautilus
Quote:
Originally Posted by shakin
Great how-to. I didn't realize how useful this was until I tried it and now I can't live without it!
Do you know if there is a manual to see what variables are available? For instance, there is $NAUTILUS_SCRIPT_CURRENT_URI and $NAUTILUS_SCRIPT_SELECTED_URIS. Any more? I bet a lot of useful scripts can be made. In fact, I'm going to make a couple right now and do how tos if they work well.
The quick answer to your question is "Yes".
The long answer is taken from the "About Scripts" dialog:
Quote:
When executed from a local folder, scripts will be passed the selected file names. When executed from a remote folder (e.g. a folder showing web or ftp content), scripts will be passed no parameters.
In all cases, the following environment variables will be set by Nautilus, which the scripts may use:
NAUTILUS_SCRIPT_SELECTED_FILE_PATHS: newline-delimited paths for selected files (only if local)
NAUTILUS_SCRIPT_SELECTED_URIS: newline-delimited URIs for selected files
NAUTILUS_SCRIPT_CURRENT_URI: URI for current location
NAUTILUS_SCRIPT_WINDOW_GEOMETRY: position and size of current window
There's tons of useful things which can be done with this - the terminal launcher is the only one I could think of that was bothering me enough to make me implement something though. :D
I look forward to seeing anything you come up with. :)
Re: HOWTO: Quickly Open a Terminal From Nautilus
Quote:
Originally Posted by shakin
Great how-to. I didn't realize how useful this was until I tried it and now I can't live without it!
Do you know if there is a manual to see what variables are available? For instance, there is $NAUTILUS_SCRIPT_CURRENT_URI and $NAUTILUS_SCRIPT_SELECTED_URIS. Any more? I bet a lot of useful scripts can be made. In fact, I'm going to make a couple right now and do how tos if they work well.
To answer my own question, here are the available variables:
NAUTILUS_SCRIPT_SELECTED_FILE_PATHS:
newline-delimited paths for selected files (only if local)
NAUTILUS_SCRIPT_SELECTED_URIS:
newline-delimited URIs for selected files
NAUTILUS_SCRIPT_CURRENT_URI:
current location
NAUTILUS_SCRIPT_WINDOW_GEOMETRY
position and size of current window
You can also use the gdialog application if your script needs user input.
--
dupe post. I spent too long browsing other scripts :)
Re: HOWTO: Quickly Open a Terminal From Nautilus
After some browsing, I came across a perl version of my script. Lol.
Re: HOWTO: Quickly Open a Terminal From Nautilus