17

How can I set a shortcut for open terminal in current directory for nautilus?

I'm using Nautilus 3.16.2 and I already tried this answer but look like it's broken in newer version.

pazel1374
  • 659
  • 6
  • 16

3 Answers3

25

I added a new feature to Nautilus with the precious help of the maintainers.

This new feature allow you to map custom keyboard shortcuts to launch the scripts in the scripts folder ( ~/.local/share/nautilus/scripts ).

So, when you add an executable in that folder it will appear in the right-click context menu, but now if you create a special configuration file ( ~/.config/nautilus/scripts-accels ) you can assign a shortcut to it.

For example make a script called Terminal with the following content:

#! /bin/sh
gnome-terminal

Now create (or edit) the ~/.config/nautilus/scripts-accels file adding the following lines:

F4 Terminal

; Commented lines must have a space after the semicolon
; Examples of other key combinations:
; <Control>F12 Terminal
; <Alt>F12 Terminal
; <Shift>F12 Terminal

Restart Nautilus (nautilus -q) and when you'll press F4 key you'll open a new terminal window in the current directory (feel free to create a new key combination following the commented lines examples).

Note: if you select one or more files, their names will be passed as parameters to the executable. Your script can also have access to many information through environment variables.

Link of the commit: https://git.gnome.org/browse/nautilus/commit/?id=9fe1335

There is also a gui to manage these shortcuts: https://github.com/echo-devim/nautilusaccelsmanager

rofrol
  • 210
  • 2
  • 9
RobotMan
  • 371
  • 2
  • 6
  • I already installed nautilus 3.18.2 but this method not works for me. Is it need to compile the commit source? From which version it pushed to master? – pazel1374 Nov 15 '15 at 16:27
  • The commit is already pushed in the master branch. You should download and compile the latest source code from the official site, because probably this patch will be included in the next release. – RobotMan Nov 16 '15 at 20:19
  • 1
    This method works with 3.28.1. – orschiro Jul 18 '18 at 11:14
  • 2
    Make sure you provide executable permissions to the Terminal script. chmod +x ~/.local/share/nautilus/scripts/Terminal. See here: https://askubuntu.com/a/1062263/775359 – Nagabhushan S N May 30 '19 at 09:01
  • What is the correct way to configure shortcuts for scripts with spaces in their names? – Jollywatt Apr 11 '20 at 12:32
  • 1
    Successfully tested on Ubuntu 20.04 LTS! – Salim B May 08 '20 at 16:14
  • 1
    This isn't working for me on Ubuntu 20.04 LTS. I have a script named "Terminal", executable, that works fine when right-clicking a file. I put "T Terminal" in the scripts-accels file, and the shortcut even says "Alt+T" on the context menu for the script. However, the shortcut keys don't work. Do you HAVE to use F-keys? How do you assign a shortcut using normal keys? – Septem151 Jul 09 '21 at 03:29
  • 1
    I confirm that this solution is working on Ubuntu 22.04 LTS. Configured opening the terminal by Shift + F9. F9 like in Krusader is not working since this key is used to show/hide sidebar of Nautilus. As @NagabhushanSN mentioned chmod +x ~/.local/share/nautilus/scripts/Terminal needs to be added to the answer. – Anton Samokat Jun 03 '22 at 11:05
  • For me, it has been working on Ubuntu 20.04 LTS, but is not working on Ubuntu 22.04 LTS. I followed the description in this answer, and also made the Terminal script executable. In nautlius, I can use the right-clicking solution. However, the keyboard shortcut is not working. – m.g. Jun 05 '23 at 07:02
5

According to News file inside nautilus git repository, since version 3.15.4 accells not loaded any more

Major changes in 3.15.4:
* Stop loading custom accel maps file

Fortunately for nautilus >= 3.20 "RobotMan" answer solved the problem.

pazel1374
  • 659
  • 6
  • 16
  • 1
    Its 2022. I switched to the Thunar and god it's awesome. Packed with nice GUI to easily map any script to any key binding with tons of other cool features and options. Still Nautilus stick to it's shitty search UX, hard way to set shortcut and very bad keyboard focus handling. – pazel1374 Mar 29 '22 at 04:55
2

2020
One option is to use:
Ctrl + F10 then e

Ctrl + F10: Same as right click at the current folder
e: Selects "Open in Terminal"

This is my favorite because you don't have to change any settings


It can change if your OS is in another language.
For example, in portuguese from brasil would be:
Ctrl + F10 then t
Just look at the underlined letter to know the key.


If you are using notebook you may have to use the super key too.
Ctrl + Super + F10 then e