I want to be able to open a terminal using a keyboard shortcut from any directory I am currently in. Software based approaches are not an option as I do not have the ability to install software on this PC. It is an office and I don't have admin rights.

The second answer to this post specifies how to setup a keyboard shortcut to do open a terminal, however it turns out that it always just opens the terminal in the home directory so it is not what I am looking for.

So is there a way to open a terminal from any directory using only a keyboard shortcut?

  • 3
    This is highly dependant on the window manager and file manager used. Can you specify which distro/WM/file manager you are using?
    – mtak
    Commented Aug 23, 2016 at 8:44

2 Answers 2


If you are using the Dolphin file manager, there's a build in shortcut Shift + F4 that does exactly this.

  • This opens a terminal in the directory in which Nautilus is, not where the current terminal is. Commented Aug 23, 2016 at 11:45
  • Isn't that what he's asking?
    – Lubo Kanev
    Commented Aug 24, 2016 at 15:32
  • Quote: from any directory I am currently in. I understood that to be any directory in the terminal, not in Nautilus. Commented Aug 24, 2016 at 15:52


Unlike @LuboKanev, I understood the OP to mean: a shortcut to open a new terminal in the present working directory I find myself in, in the currently active terminal, not in the file manager (BTW, in KDE there is the same trick pointed out in the other answer: in Doplhin, you use Shift+F4; I believe any decent file manager will provide such a key).

The script below is a tad complex for this reason: in the current active window you may have a currently running task (say, you are watching a movie via vlc), so you do not have the prompt available; how do you then retrieve your PWD without waiting for the completion of the task, i.e. without waiting for the movie to finish? The script solves exactly this problem.

The following script first identifies the current active window, then identifies the process running into it (it will be something like konsole, or xterm, or ..., if it is a terminal), then finds the children processes of konsole/xterm/..., and, for every child process which is a bash shell, it locates its current working directory and opens a konsole window in the given current directory. It does so for all bash shells found open, not just the first one.


ACT_WIN=$(xdotool getactivewindow)
MY_PPID=$(xprop -id $ACT_WIN _NET_WM_PID | awk '{print $3}')

for i in $(pgrep -P $MY_PPID); do
      ps -o cmd -p "$i" | grep bash > /dev/null
      if [ $? -eq 0 ]; then
         MYPWD=$(readlink -e /proc/$i/cwd)
         konsole --workdir $MYPWD 2>/dev/null & disown

Careful, there is no error checking in the above....

The good thing about this script is that, if the current active window is not a terminal, hence it has spawn no bash shells, nothing will happen. You may then click with the mouse on your terminal, which becomes the current active directory, and resend the shortcut: you will then get your terminal, and the proper directory.

After making this script executable, you can associate it to a keyboard shortcut; this depends on DM. For KDE, go to System Settings -> Shortcuts and Gestures -> Custom Shortcuts -> Edit (in the lower left corner) -> New -> Global -Shortcut -> Command/URL. Under New Action, choose Comment to explain what you are doing, then the trigger (the command, something like Alt+F10), and then, under action, enter the absolute path to the executable script above.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .