Friday, April 19, 2024
 Popular · Latest · Hot · Upcoming
21
rated 0 times [  21] [ 0]  / answers: 1 / hits: 5694  / 3 Years ago, wed, august 25, 2021, 1:56:05

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


More From » nautilus

 Answers
7

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.


[#37512] Thursday, August 26, 2021, 3 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
ormlai

Total Points: 292
Total Questions: 106
Total Answers: 115

Location: Cape Verde
Member since Fri, Sep 16, 2022
2 Years ago
ormlai questions
Wed, Sep 28, 22, 00:17, 2 Years ago
Sun, Aug 7, 22, 22:05, 2 Years ago
Wed, Jun 16, 21, 03:50, 3 Years ago
Sun, Feb 6, 22, 09:11, 2 Years ago
Mon, Jul 12, 21, 10:00, 3 Years ago
;