PDA

View Full Version : Add "Terminal Here" to right click menu



RichGags
27th January 2006, 07:00 PM
Is it possible to add a "Terminal Here" to the right click menu so that when I right click a folder, it can get a terminal window already mapped to that folder?

When I was a Windowman, I had installed a little proggie called "doshere.inf", which gave me a "Command Prompt Here" on my right-click menu... It was kinda handy.

TIA!

baschti
27th January 2006, 07:03 PM
in a konqueror window just hit F4 to get a terminal
(i don't know if there is such an option in gnome)

baschti
27th January 2006, 07:07 PM
...you can also right click on a folder and click on actions->open terminal

RichGags
27th January 2006, 07:11 PM
I should have said, Im using Gnome, sorry. But there is not Actions on my right click menu.
:(

Thanks!

dishawjp
27th January 2006, 09:58 PM
Hi RichGags,

I'm at work now and using SUSE 10 and not Fedora with Gnome, but if I right click in a Nautilus directory I get an "Open in Terminal" option. Since I usually do most everything in a terminal anyway and rarely open Nautilus, I'm not sure if the same option exists in FC.

I will check that when I get home though.

Jim

dishawjp
27th January 2006, 10:00 PM
Hi RichGags,

I'm at work now and using SUSE 10 and not Fedora with Gnome, but if I right click in a Nautilus directory I get an "Open in Terminal" option. Since I usually do most everything in a terminal anyway and rarely open Nautilus, I'm not sure if the same option exists in FC.

I will check that when I get home though.

Also, even iif you are running Gnome, you should be able to run Konqueror if you installed KDE. I do use it occasionally, it's a pretty powerful app.

HTH,

Jim

baschti
28th January 2006, 01:31 AM
i just stumbled over 'nautilus-open-terminal'
http://gnomefiles.org/app.php?soft_id=908

jim
28th January 2006, 07:33 PM
simple

add the following to a text file named "Open Terminal Here"


gedit ~/.gnome2/nautilus-scripts/"Open Terminal Here"




#!/usr/bin/perl -w
use strict;

$_ = $ENV{'NAUTILUS_SCRIPT_CURRENT_URI'};
if ($_ and m#^file:///#) {
s/%([0-9A-Fa-f]{2})/chr(hex($1))/eg;
s#^file://##;
exec "gnome-terminal --working-directory='$_'";
}

# Added 2003-12-08 Dexter Ang
if ($_ == "x-nautilus-desktop:///") {
$_ = $ENV{'HOME'};
$_ = $_.'/Desktop';
exec "gnome-terminal --working-directory='$_'";
}

save and close

right click and choose scripts then Open terminal Here

RichGags
29th January 2006, 02:30 PM
fedorajim, thanks for the script, but I did exactly as you asked and when I right click a folder, there is no "scripts" option.
Am I doing something wrong?
Thanks

jim
29th January 2006, 02:53 PM
opps I forgot to have you make ir executable

as root

chmod +x ~/.gnome2/nautilus-scripts/"Open Terminal Here"

RichGags
30th January 2006, 02:07 AM
Ok, Almost there. Although as root, I tried the chmod command you gave me, it didnt change the permissions. I right clicked the file in /.gnome2/nautilas-scripts and set the permissions to 777. Now I have a scripts option on my right click menu, and I have the "Open Terminal Here" in there. When I click "Open Terminal Here", its opens a terminal, however, it opens the terminal at [RichGags@localhost /]$ no matter what folder I right click on.

In other words, its not opening the terminal where I need it.

Is there anything else I can do?

Thanks!

jim
30th January 2006, 02:09 AM
are you doing this on the desktop? by defaukt if you are on the desktop it will revert to your home folder.

open nautilus to some dir other than your home folder then right click in that folder and chose open terminal here

RichGags
30th January 2006, 02:19 AM
Wow this is the wierd part. Before I was in Nautilus, right clicking folders as you suggested, and it was bringing me just to localhost dir. Its still doing just that:

[RichGags@localhost ~]$


However if I right click the desktop, and chose "Scripts","Open Terminal Here" it brings me to


[RichGags@localhost Desktop]$

In other words, it seems the ONLY place its working correctly is on the Desktop. Hmmm.....

RichGags
30th January 2006, 02:20 AM
Discovery! I have to actually enter the folder, then right click on empty space and it works properly.

Well done! Thanks!

jim
30th January 2006, 02:23 AM
localhost is not a dir it is the name of your PC

as for the script that doesn't sound right

open the script in gedit again

gedit ~/.gnome2/nautilus-scripts/"Open Terminal Here"

is there a blank line after the bottom curly bracket --> } ?

if not make sure there is and save the file again

RichGags
30th January 2006, 02:34 AM
Discovery! I have to actually enter the folder, then right click on empty space and it works properly.

Well done! Thanks!

prosen
30th January 2006, 12:35 PM
I thought it was simpler .. I use this one :

!/bin/bash

dir=`pwd`
if test -d "$1" ; then
gnome-terminal --working-directory="$dir/$1"
else
gnome-terminal --working-directory="$dir"
fi
this works inside a directory as well as when u right-click on it ..
also .. if u select any other file and then execute this .. it opens the directory in which the file is ..

mobsta
30th January 2006, 01:07 PM
This works like a treat for me.



#!/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"

RichGags
30th January 2006, 07:11 PM
This works like a treat for me.


Works great too! Thanks!...

Just a note, to future readers, make sure to create this file as a regular user in ~/.gnome2/nautilus-scripts/

paperdiesel
30th January 2006, 09:48 PM
Haha! He said "Discovery!". Seriously -- this made me laugh out loud. I'm going to use this from now on.

jim
30th January 2006, 11:21 PM
The difference is one is in perl and one is in bash

war59312
23rd March 2006, 11:42 PM
Hey,

Does this not work in FC5? Seeing as when I right click ther is no scripts?

Thanks,

Will