One option that most Linux users find invaluable is being able to open a terminal pointing to the current folder, and while file-managers like Nautilus, Nemo and Caja don’t ship with that by default, it’s easily installed with a plugin or extension: nautilus-open-terminal, nemo-terminal and, in the case of Caja, caja-open-terminal (which also gets installed with the caja-extensions package).
While in Nautilus the only way to access that is via a right-click, in Nemo you can actually add a button for it to the toolbar. I couldn’t find a way to add an Open in Terminal button to Caja’s toolbar, likely because it is provided by an extension, not built into Caja, so I wanted to see if I could create a keyboard shortcut for it. But it seems there is a general issue with Caja extensions being that they cannot set keyboard shortcuts for their menu items, because libcaja-extension doesn’t provide this ability.
But you can get around this with a script, and you don’t even need to have caja-open-terminal installed, as long as caja-actions is installed (run sudo apt-get install caja-actions
if it isn’t). And the best part is you can even assign an accelerator (keyboard shortcut or hotkey) to it. For me, hitting the F4 key is quicker and easier than clicking a toolbar button, so I’ll show you how to create the script and assign a hotkey to it. Note that you can use another function key, or assign a key-combo, as long as it isn’t already being used for another task, but the F4 is a great choice, as it isn’t already used by Caja or the system.
Creating the “Open Terminal Here” Script
When it comes to creating scripts, most guides out there err on the side of caution and instruct you to create file-names all in lower-case, and with dashes replacing spaces, like open-terminal-here, but there is absolutely no reason for this – your scripts will work just fine with names like Open Terminal Here, and will look nicer in the Scripts sub-menu:
Create a text file called Open Terminal Here for the script in ~/.config/caja/scripts/ with:
pluma ~/.config/caja/"Open Terminal Here"
Paste the following code into it:
#!/bin/sh
#
# This script opens a mate-terminal window in the current directory.
#
# Note that you need to have caja-actions installed to use scripts.
cd $CAJA_SCRIPT_CURRENT_URI
exec mate-terminal
If you want to use another terminal, then replace mate-terminal with gnome-terminal (which is my personal preference), xfce-terminal, konsole, or other terminal of your choice. Save the file, then make it executable with:
chmod +x ~/.config/caja/scripts/"Open Terminal Here"
Before continuing, you need to totally quit Caja, as it will keep overwriting the next file you’ll be adding the shortcut key to; and because Caja is always running in the background in MATE, instead of the usual caja -q, you need to run:
pkill -KILL caja
Assigning the Hotkey for the Script
Then to edit Caja’s “accelerators” file, run:
pluma ~/.config/caja/accels
Your new script should have been automatically added to the accels file, so look for the following line (USER will actually be your username in lower-case):
; (gtk_accel_path "<Actions>/ScriptsGroup/script_file:\\s\\s\\shome\\sUSER\\s.config\\scaja\\sscripts\\sOpen%20Terminal%20Here" "")
First, delete the semi-colon and space at the beginning of the line, then add the shortcut key in between the quotes at the end, so it looks like:
(gtk_accel_path "<Actions>/ScriptsGroup/script_file:\\s\\s\\shome\\sUSER\\s.config\\scaja\\sscripts\\sOpen%20Terminal%20Here" "F4")
Save the file and close it, open Caja, and now the F4 key will open a terminal with its path being the current folder.
The Keyboard Shortcut Not Working?
If you found it almost impossible to edit the accels file (like what happened to me) because something keeps trying to write to it, and Pluma keeps wanting to reload the file, it’s because Caja is being obstinate, and is still running in the background. While killing Caja before editing accels works fine for most people, with the hotkey immediately working, you might need to get more aggressive with Caja, so check out the Successfully Editing ACCELS tutorial to see how I got around this annoyance.
☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻☻
The tutorial above is TOTALLY FREE, and I hope you found it useful! But if this information really made your day, because it rescued you from hours of headache, or allowed you to accomplish something you thought was impossible, then please consider making a donation via PayPal, to buy me a donut, beer, or pizza for my time and effort! Many thanks in advance!