Page 1 of 3 123 LastLast
Results 1 to 10 of 29

Thread: HOWTO: Quickly Open a Terminal From Nautilus

  1. #1
    Join Date
    Feb 2005
    Location
    Watervliet, MI
    Beans
    155

    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.
    Last edited by bobmitch; April 13th, 2005 at 08:25 PM. Reason: Found a better bash script to use...

  2. #2
    Join Date
    Dec 2004
    Beans
    297

    Re: HOWTO: Quickly Open a Terminal From Nautilus

    Works perfectly. You just got rid of the last advantage KDE has over Gnome.

  3. #3
    Join Date
    Apr 2005
    Beans
    11

    Re: HOWTO: Quickly Open a Terminal From Nautilus

    good idea

  4. #4
    Join Date
    Apr 2005
    Beans
    514

    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!

  5. #5
    Join Date
    Apr 2005
    Location
    Wales, UK
    Beans
    113

    Re: HOWTO: Quickly Open a Terminal From Nautilus

    Good stuff

  6. #6
    Join Date
    Nov 2004
    Beans
    489

    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.

  7. #7
    Join Date
    Feb 2005
    Location
    Watervliet, MI
    Beans
    155

    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:

    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.

    I look forward to seeing anything you come up with.

  8. #8
    Join Date
    Nov 2004
    Beans
    489

    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
    Last edited by shakin; April 13th, 2005 at 08:06 PM. Reason: too slow

  9. #9
    Join Date
    Feb 2005
    Location
    Watervliet, MI
    Beans
    155

    Re: HOWTO: Quickly Open a Terminal From Nautilus

    After some browsing, I came across a perl version of my script. Lol.

  10. #10
    Join Date
    Apr 2005
    Location
    Hampshire, UK
    Beans
    25
    Distro
    Ubuntu 10.04 Lucid Lynx

    Re: HOWTO: Quickly Open a Terminal From Nautilus

    Take a look at G-Scripts

    http://g-scripts.sourceforge.net/

Page 1 of 3 123 LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •