Shortcut to Bring All Open Terminals to the Front

command linegnome-terminalshortcut-keysshortcuts

After I navigate out to a webpage or editor, is there any way to bring all the open terminals back to the front in their original positions? It is a bit of a pain clicking the terminal icon and then bringing each one back individually.



  • Pre-shortcut:

Pre-image shortcut

  • Post-shortcut:

Post-image shortcut

Best Answer

You can press Alt+Tab to switch forward between windows and Alt+Shift+Tab to switch back between windows. This shortcut is made to work in almost all graphical operating systems. Yow can also use Super+W and arrow keys for the same purpose.

After you bring one terminal window in the front, press Alt+~ to bring all other terminal windows in the front one by one:

switch to windows

To automatically bring all open terminals in the front (not one by one as I described before) you will need to add a keyboard shortcut for the following script (script taken from Adobe's answer and improved considering that version of script hasn't worked for me):


if [ $# -ne 1 ];then
  echo -e "Usage: `basename $0` PROGRAM_NAME\n
           For example:\n\t
           '`basename $0` gnome-terminal' for Terminal\n\t
           '`basename $0` firefox' for Firefox\n\t
           '`basename $0` chromium-browser' for Chromium\n\t..."
  exit 1

pids=" $(pidof $@) "

if [ "$pids" = "  " ]; then # the string "  " contain two spaces
    echo "There is no program named '$@' opened at the moment."
    exit 1

wmctrl -lp | while read identity desktop_number PID window_title; do 
    if [ "${pids/ $PID }" != "$pids" ]; then
        wmctrl -ia $identity

Don't forget to make the script executable:

chmod +x /path/to/script/script_name

After you test the script in terminal, you must to see:

Related Question