I wonder if there is any way to define a shortcut to maximize / focus on last opened terminal? Ctrl + Shift + T opens a new terminal, and I would like to jump to the last opened instead.
Ubuntu – Key shortcut to invoke last opened terminal
gnome-terminalshortcut-keys
Related Question
- Ubuntu – Terminal shortcut key
- Ubuntu – How to open new tab in existing window using keyboard shortcuts on Ubuntu
- Ubuntu – How to switch between tabs opened in gnome-terminal and also close any particular tab using shortcut key
- Ubuntu – Keyboard shortcut to focus on (idle) terminal
- Ubuntu – How to bring up last terminal window with a shortcut key
- Ubuntu – Maximize active window in terminator
Best Answer
Yes, if you're using Xorg.
Install
xdotool
:To activate the last used gnome-terminal if one is present, add a custom shortcut with the following command:
To activate the last used gnome-terminal or start a new one if none is present, use the following command:
If you wonder why I used a command substitution with a second
xdotool
invocation:From man xdotool:
In your case, you want the last window, but there is no way to reference it using xdotool's notation, so we let it print all window ids and pipe them to tail in order to retrieve only the last window's id.
The second command above works because if there's no gnome-terminal running, the result of the command substitution is an empty string. The resulting command
xdotool windowactivate
exits with a non-zero status (because no window id is given), and leads to execution of the right side of the||
(logical or) operator.