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:
sudo apt install xdotool
Now create a file (e.g in your home named .custom-terminal-key.sh
) and put these lines in it (Thanks to Jacob Vlijm):
#!/bin/bash
if [[ "$(xprop -id "$(xdotool getactivewindow)" WM_CLASS)" == *"gnome-terminal"* ]]; then
sleep 0.1
xdotool key ctrl+shift+t
elif ! pgrep 'gnome-terminal'; then
gnome-terminal
fi
Every time we run it, if any gnome-terminal
was open, it will simulate a Ctrl+Shift+t key binding, otherwise it runs gnome-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.
gsettings set org.gnome.desktop.default-applications.terminal exec '/home/USER/.custom-terminal-key.sh'
Change USER
with your real username.
Don't forget to give our script the executable bit:
chmod +x ~/.custom-terminal-key.sh
We are done.
Rollback
Whenever you changed your mind just run:
gsettings set org.gnome.desktop.default-applications.terminal exec 'gnome-terminal'
Remove our script rm ~/.custom-terminal-key.sh
and xdotool
: sudo apt remove xdotool
.
Getting active window name
org.gnome.desktop.default-applications.terminal
(unity/16.04) You might want to mention the manual way, using Settings > keyboard. – Jacob Vlijm Apr 27 '17 at 20:58gsettings set org.gnome.desktop.default-applications.terminal exec
it gives mex-terminal-emulator
on 16.04 unity. – Ravexina Apr 28 '17 at 09:41usr/local/bin
and changed steps 4 and 5 accordingly. Unfortunately, couldn't get it to work. :/ – KT12 Apr 28 '17 at 16:11gedit
) instead of our script to see if our key binding are working ... first find which part does not work for you so we can work on it. – Ravexina May 03 '17 at 04:54