Monday, April 29, 2024
10
rated 0 times [  10] [ 0]  / answers: 1 / hits: 16088  / 3 Years ago, tue, october 5, 2021, 7:30:38

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.



Thanks!



Example:




  • Pre-shortcut:



Pre-image shortcut







  • Post-shortcut:



Post-image shortcut


More From » command-line

 Answers
6

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):



#!/bin/bash

if [ $# -ne 1 ];then
echo -e "Usage: `basename $0` PROGRAM_NAME

For example:

'`basename $0` gnome-terminal' for Terminal

'`basename $0` firefox' for Firefox

'`basename $0` chromium-browser' for Chromium
..."
exit 1
fi

pids=" $(pidof $@) "

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

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


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:




[#29414] Wednesday, October 6, 2021, 3 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
unsmmoth

Total Points: 72
Total Questions: 113
Total Answers: 95

Location: Thailand
Member since Tue, Oct 6, 2020
4 Years ago
;