How to open directory in Guake from Nautilus

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 --show --execute-command="cd '$dir'"
    

    Notice the last command is what is used to open the directory in guake --show 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:

    For 12.04: ~/.gnome2/nautilus-scripts
    For 14.04: ~/.local/share/nautilus/scripts/

    Which are hidden folders 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.