I would like to use a keyboard shortcut to launch the file manager in the working directory of the terminal (the reverse equivalent of Keyboard shortcut for "open a terminal here").
How can I achieve this?
I would like to use a keyboard shortcut to launch the file manager in the working directory of the terminal (the reverse equivalent of Keyboard shortcut for "open a terminal here").
How can I achieve this?
A keyboard shortcut like this doesn't exist by default, but you can use the bash built-in bind
to define one.
Just add the following section to your ~/.bashrc
:
# define function that opens default FM in working directory
fmhere(){
xdg-open "$PWD"
}
# bind hotkey to it (<Alt><Shift><F>)
bind -x '"\eF":"fmhere"'
\eF
is the terminal escape sequence of my keyboard shortcut, Alt+Shift+F. Check out @slm's excellent answer over at unix.SE to learn how to determine the correct escape code for your keyboard shortcut of choice.
Another quick way to determine the escape code:
Open your terminal and press Ctrl+V. Now press your favorite keyboard shortcut. The correct escape code should appear. Just make sure to replace ^[
with \e
before adding the shortcut to your .bashrc
, e.g. replace ^[F
with \eF
.
Sources:
https://www.gnu.org/software/bash/manual/bashref.html#Bash-Builtins
https://unix.stackexchange.com/q/89622/29245