Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

In Nautilus, I have upon right-clicking a directory, the option to open a Terminal with the prompt in the selected directory. I think this is very handy and I use it a lot.

Now I would like to use Guake instead of the classic terminal. Is there a way to do this?

I'm struggling with nautilus-actions. I can open Guake allright (i.e. it drops down from the top since it's permanently loaded), but the prompt isn't located at the directory of choice. In addition, it's one more mouseclick to open the terminal (if it would work), I would prefer a shorter way.

Anyone any idea how to manage this? (or could this be a possible feature request?)

Ubuntu 12.04, gnome-classic without Unity

share|improve this question

1 Answer 1

up vote 9 down vote accepted
+50

Ok, so I found a shell script that will work and modified it to work with guake. To get it working follow these steps.

  1. Create a new empty document, Right click => Create New Document => Empty Document
  2. Name It Open in Guake or something similar
  3. Open it and paste the code listed below- Source 1 (This is needed because the nautilus returns a specific file path and it needs to be reformatted to work in the terminal.)

    #!/bin/bash
    # From Chris Picton
    # Replaces a Script by Martin Enlund
    # Modified to work with spaces in path by Christophe Combelles
    # Modified to use guake by Matthew Jump
    
    # 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
    
    #there should be an embracing around the $dir
    guake -t --execute-command="cd '$dir'"
    

Noitice the last command is what is used to open the directory in guake -t toggles the apearance of guake, and --execute-command="cd $dir" navigates to the directory. run man guake (in terminal) for a complete list of commands (note that it gets complicated with mixing comands).

4.Save the file and then place it in ~/.gnome2/nautilus-scripts which is a hidden folder in your home folder, to view hidden folders go to => View => Show Hidden Files

5.Now we need to make the file executable, Right click on the file go to > Properties > click Permissions tab > look for "Execute" and check "Allow executing file as program" then close out.

Next We just need to try out the script, right click a folder in Nautilus, then go to =>Scripts => Open in Guake

Now you have a custom "Open in Guake" script on your right click.

Open in new Guake tab and rename tab as path:
I made some changes to the script to open a new tab in Guake and rename the tab after the directory. So if you want to use these changes just replace the last line of the code with this-

guake -n "$dir" -r "$dir" -t

-n "$dir" makes a new tab with the directory as its prompt, so its faster than executing "CD" like I did above. And -r is to rename the tab.

Open in new tab, with short name for current directory:
It now shows either the directory name you are in or the selected directory depending on where you right click, for files and the blank space the folder name of the directory you are in, for selecting a folder it displays the folder name, to use just replace the last line with this code-

guake -n "$dir" -r "`echo ${dir%/} | rev | cut -d'/' -f1 | rev`" -t

the quotes around $dir also fix an issue i had with certain folders that had a lot of spaces.

share|improve this answer
    
Tried it and works. Not only does it open the selected directory, but if a file is selected, it opens the directory the file is in. This is exactly what I needed, thanks a lot +++ –  Tinellus Jun 20 '12 at 4:04
    
I added a bit to make a new tab and rename it –  Mateo Jun 20 '12 at 14:25
    
Also tried that one, and works. Thank you so so very much, I will definitely keep using this. One more remark though: most of my tabs will have uncomfortably long names (/home/Pictures/2011/xxx/ etc...). Would it be possible to keep only the name of the last directory? Nevertheless, the bounty is yours... –  Tinellus Jun 20 '12 at 17:33
    
Just awarded you the bounty. Thanks for all your efforts... Just tried it: works elegantly, exactly what I needen. On top of the service you have given me, you gave me, the completest noob, much insight in coding. Thanks –  Tinellus Jun 21 '12 at 6:54
3  
For Ubuntu 13.04 I had to put the script into /home/$USER/.local/share/nautilus/scripts/ I also had to put the -t onto a new line e.g: guake -n "$dir" -r "`echo ${dir%/} | rev | cut -d'/' -f1 | rev`" guake -t –  thelastshadow Jul 30 '13 at 9:07

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.