"Open in Terminal" in Ubuntu 18.04

12,186

Solution 1

Does the package nautilus-extension-gnome-terminal provide what you want?

Method of determining the new package (in case it's of interest)

I'm still on Xenial, which made some things easier, some harder.

First, try to determine what specific file (i.e. script, linked library or the like) is responsible for the feature on Xenial. The name of the file is likely to contain terminal so search for that:

locate terminal | less

and within less search for nautilus, as a first guess (if I were more confident I'd have just used grep).

/usr/lib/nautilus/extensions-3.0/libterminal-nautilus.so seems the most likely candidate, as it's correctly located (within the nautilus/extensions-3.0 hierarchy) and reasonably named.

Check what package provides it:

dpkg -S /usr/lib/nautilus/extensions-3.0/libterminal-nautilus.so

It seems that it's provided by the package gnome-terminal itself (which matches what I remember — I didn't have to install any special packages).

The online list of files provided by the gnome-terminal package corroborates this:

https://packages.ubuntu.com/xenial/amd64/gnome-terminal/filelist

Unfortunately, /usr/lib/nautilus/extensions-3.0/libterminal-nautilus.so is no longer provided by gnome-terminal in bionic:

https://packages.ubuntu.com/bionic/amd64/gnome-terminal/filelist

If I had access to a machine running bionic (or could be bothered fiddling with the options for apt-file to use an alternative sources.list, I'd have used:

apt-file search /usr/lib/nautilus/extensions-3.0/libterminal-nautilus.so

to find the package providing the file.

As it is, I just used the online interface at packages.ubuntu.com.

To check, nautilus-extension-gnome-terminal does provide the needed file on bionic.

Solution 2

sudo apt install nautilus-admin Adds some administrative actions to the right-click menu:

Open as Administrator.

Edit as Administrator.

Open in terminal.

Hope this help you

Solution 3

For recent versions of Ubuntu (eg. 18)... create/save this script in:

~/.local/share/nautilus/scripts/

Note: you need to also chg the permission of this new file to allow execution

It will add a Scripts right click context menu item (with the name given e.g. 'open-in-terminal.sh') for any file or directory you click in nautilus.

#!/bin/bash
#
# When a directory is selected, go there. Otherwise go to current
# directory. If more than one directory is selected, show error.
if [ -n "$NAUTILUS_SCRIPT_SELECTED_FILE_PATHS" ]; then
    set $NAUTILUS_SCRIPT_SELECTED_FILE_PATHS
    if [ $# -eq 1 ]; then
        destination="$1"
        # Go to file's directory if it's a file
        if [ ! -d "$destination" ]; then
            destination="`dirname "$destination"`"
        fi
    else
        zenity --error --title="ERROR! Open terminal here" \
            --text="Plz only select one directory."
        exit 1
    fi
else
    destination="`echo "$NAUTILUS_SCRIPT_CURRENT_URI" | sed 's/^file:\/\///'`"
fi

# It's only possible to go to local directories
if [ -n "`echo "$destination" | grep '^[a-zA-Z0-9]\+:'`" ]; then
    zenity --error --title="ERROR! Open terminal here" \
        --text="Sorry, only local directories can be used."
    exit 1
fi

gnome-terminal --working-directory="$destination"

Based on this source: https://help.ubuntu.com/community/NautilusScriptsHowto/SampleScripts#Open_terminal_here

Solution 4

For anyone using 19.04, didn't find this mentioned anywhere else.

I initially had to use a Nautilus script to solve this problem, especially when the folder is full of files and there's nowhere to click. But I recently found I can just click on the name of the current folder in the 'address bar', and get the Open in Terminal option, which is good enough for me.

term

Share:
12,186

Related videos on Youtube

RE60K
Author by

RE60K

Updated on September 18, 2022

Comments

  • RE60K
    RE60K almost 2 years

    This option seems to have gone away after upgrading from Ubuntu 16.04. I tried installing nautilus-open-terminal but it is unable to locate the package for 18.04. Also trying to install nautilus-actions gives:

    Package nautilus-actions is not available, but is referred to by another package. This may mean that the package is missing, has been obsoleted, or is only available from another source
    

    enter image description here

    How to fix this?

  • Thomas Ward
    Thomas Ward about 6 years
    How does this solve the question being asked? You should expand to explain how the specified package fixes the problem, rather than just saying "Here run this: <command>"
  • msoftrain
    msoftrain over 4 years
    Something similar also works in Ubuntu 18.04. When clicking on the name of the current folder in the 'address bar', the option to select is: Preferences>Behavior>Executable textfiles - Run them