10

I would like to add an option to 'open terminal here' from the context menu that results from clicking on a file in the list mode of nautilus. This already exists when nautilus is in tiled mode and you right click on white space, but I find it annoying that I have to switch to this mode and then back every time I want to open a terminal (which is a lot).

I tried to illustrate my point with screenshots, but I can't figure out how to take a screenshot of a context menu. Let me know if this is not a clear question. Thanks.

1 Answers1

13

You are facing an issue in Files (nautilus) that comes with Ubuntu 18.04. Indeed, if the list view is full, there is no empty space where you can right-click to obtain the folder-specific righ-click menu. That is the menu that contains the "Open terminal here" option.

The issue is solved in more recent versions by making the breadcrumb path items, i.e., the buttons of the folders above the file list, more functional. You now can click (or right-click) the folder name in the breadcrumb to obtain the menu, making that context menu available with the mouse anytime.

Still, you can work around in the Nautilus version that comes with 18.04.

Keyboard shortcut in Nautilus

The shortcut key Ctrl+F10 opens the empty-space context menu anytime. Thus, just press Ctrl+F10 then e to open the terminal here.

Using a Nautilus script

If that is not enough and you also want mouse accessibility to the Open Terminal Here command, then there is still a way to implement the function using nautilus scripts.

  • Create a script, Terminal, that contains following code

Script code:

#!/bin/sh
gnome-terminal

(yes, it cannot be more simple than that!).

  • Put the script in the folder .local/share/nautilus/scripts under your home folder. Enable "Show hidden files". Then you will see the hidden .local folder and be able to navigate to scripts.

  • Make the script executable. (Right-click, Properties tab, Permissions: "Allow executing file as program")

  • Restart nautilus (killall nautilus). Now, you will have a new "scripts" menu when right-clicking any file, which contains your "Terminal" command

Optional: assign a hotkey to the script

(Update: unfortunately the following does not anymore work in Ubuntu 20.10).

  • If it does not exist, create a text file ~/.config/nautilus/scripts-accels

  • Add a line:

F12 Terminal

Hitting F12 in nautilus now will immediately open a terminal in the current folder.

vanadium
  • 88,010
  • 1
    If I wanted to do this with xterm instead of gnome-terminal, how would I make xterm open already pointed to the current folder? – Adrian Keister Sep 11 '20 at 21:16
  • In my case, it already opens in the current folder. The script is as simple as the one shown in the post replacing "gnome-terminal" with "xterm". Note that Nauitlus passes the currently selected file name as first argument. You may use that for more fancy scripts. Like for example: if [ -d "$1" ]; then; cd $1 && xterm; else; xterm; fi – lcorag Dec 19 '23 at 08:44