I was wondering whether there is a possibility to assign a keyboard shortcut for creating a new empty file in Ubuntu 18.04 for nautilus. Namely if there is a possibility to assign a keyboard shortcut to the "Empty File" option generated by the right mouse click. The solution provided on this answer does not appear to work for Ubuntu 18.04
Ubuntu – Keyboard shortcut to create a new empty file on Ubuntu 18.04
nautilusshortcut-keys
Related Question
- Ubuntu – How to create keyboard shortcuts for the nautilus scripts
- Nautilus – What Happened to the ‘Create Link’ Feature in Ubuntu 16.10 and Newer
- Nautilus Shortcut Keys – How to Assign Keyboard Shortcuts for Nautilus Scripts
- Ubuntu – Create custom keyboard shortcut in Ubuntu 17.10 / 18.04
- Ubuntu – Keyboard shortcut for open terminal Nautilus in Bionic 18.04
Best Answer
Nautilus unfortunately does not allow the user to assign keyboard shortcuts to functions, as in the old days. Still, there is a workaround to create your own hotkeys through the use of nautilus scripts, which can be assigned a hotkey.
You can create a shortcut key to quickly create an empty file as following.
1) Create a nautilus script that does what you want
a) Create the scripts folder if it does not exist
If the folder
scripts
does not yet exist in the folder.local/share/nautilus/scripts
, then create it first..local
is a hidden folder in your home folder. Press Ctrl+h to toggle the display of hidden files in the file manager.b) Create a new script
Then create a script file in the nautilus scripts folder with the following command.
You can leave
$USER
: it should normally automatically be substituted with your login name.The script could look like:
Also this nautilus script will recognize the variable
$USER
. Alternatively, replace the variable by your own login name.c) Make the script executable
Make the script file executable (Right-click, properties or
chmod +x "/home/$USER/.local/share/nautilus/scripts/New Empty File"
2. Testing the script
Close Files fully and restart it. To make sure it is fully closed, use the command
After restarting, you should have a new entry "New Empty File" in your right-click menu when a file is selected.
Assign a hotkey to your script
Edit 2020-11-17 Unfortunately, this seems broken in Files 3.38.1 that comes with Ubuntu 20.10.
Creating a new file with the right-click menu is easy enough without the script. However, the reason we do this is to be able to assign a hotkey. For that, create a file
scripts-accels
under.config/nautilus
Suppose we want to use Ctrl+Shift+t as the shortcut key. Then, the file should contain at least the last line from the following snippet:
Bonus tip
You can give your new menu entry in the Scripts menu an accelerator, by prepending the script name with
_
. The letter prepended by_
will show up with an underscore. This way, a script named "_New Empty File" can be summoned from the keyboard as (a file must be selected) Shift+F10sn.