I don't like to have dozens of terminals opened. Is there a way to add Open in current Terminal instead of Open in Terminal when using Nautilus?
I don't like to have dozens of terminals opened. Is there a way to add Open in current Terminal instead of Open in Terminal when using Nautilus?
Dirty or not, the solution below worked perfectly in the 30 minutes I tested it frequently. The solution works as long as you can right-click a file (any) inside the directory:
1.
2.
3.
Nautilus script
How to use
The script needs
wmctrl
,xdotool
and xclip:Copy the script into an empty file, save it as
open_in_terminal
(no extension) in~/.local/share/nautilus/scripts
. Create the directory if needed. Make the script executableThat's it. Log out and back in and you'll have the script available as in the image (2).
Explanation
"NAUTILUS_SCRIPT_CURRENT_URI"
.xclip
)gnome-terminal
window and pastes the path, preceded by thecd
command. Since we usedecho
to load the whole line into the clipboard, Return is included.Notes
gnome-terminal
window.More information on nautilus scripts here.
Alternatively, pick your own terminal window if you have multiple
If you want to be able to choose in which terminal window you would open the current (nautilus) directory, use the script below.
How it works in practice
Right- click (any) file inside the directory (in this case my desktop) like below:
Click on (or raise otherwise) the terminal window you'd like to use, and it will cd to the directory:
The script
Setup
Is exactly like the first script.
Explanation
The script has one difference from the first one: instead of automatically raising the first found terminal window, it waits for the first terminal window to have focus. Then it cd's to the directory inside that window.
Simplest way is this:
cd
, space, then Shift + Insert (or INS) to paste the path. Hit Enter.No need for scripts or extra work.
I'm pretty sure there's no way to do this, however I have a workaround for you that might help.
You can always drag and drop a directory from Nautilus into a terminal window and Nautilus will pass that directory and paste it into the command line, so you could do
cd
and then drag the folder onto the terminal and hit enter.In my opinion the only elegant way to solve this without fuding around is to use a terminal multiplexer like tmux and have your file manager
The following shell script achieves just that:
TERMINAL_EMULATOR
holds the desired terminal emulator for new terminal windows (if you don't like the default of whateverx-terminal-emulator
points to) plus a command-line option for the command to execute inside the emulator.You can register the file handler script like any other file type association in your file manager.