Is there a way to get Ctrl+Alt+T to open a terminal tab, if you already have an open terminal, instead of another terminal window?
I have already changed my preferences to open new terminals in tab.
(I still want the key binding to open a terminal if none are open.)
Best Answer
Here is what I've done and it did the job pretty good.
change
gnome-terminal
preferences to default if you have changed it.so, set the Ctrl+Shift+t as shortcut for opening a new tab.
We need
xdotool
(it's around 30KB) install it via:Now create a file (e.g in your home named
.custom-terminal-key.sh
) and put these lines in it (Thanks to Jacob Vlijm):Every time we run it, if any
gnome-terminal
was open, it will simulate a Ctrl+Shift+t key binding, otherwise it runsgnome-terminal
.Finally we change the default behavior of Ctrl+Alt+t, instead of opening a terminal every time you press these, it will run our script.
Change
USER
with your real username.Don't forget to give our script the executable bit:
We are done.
Rollback
Whenever you changed your mind just run:
Remove our script
rm ~/.custom-terminal-key.sh
andxdotool
:sudo apt remove xdotool
.Getting active window name