Created
April 25, 2020 02:14
-
-
Save rolandcrosby/dfb45bcdd7bda9af84a34463bf198615 to your computer and use it in GitHub Desktop.
switch to gnome-terminal if it's open, otherwise launch a new one
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
read -r win_found <<<$(wmctrl -l -p | awk '{print $1,$3}' | while read -r wins; do ps -o command= -p "${wins/0x* /}" | grep -q gnome-terminal && echo "${wins/ */}" && break; done) | |
if [ -z "$win_found" ]; then | |
gnome-terminal | |
else | |
wmctrl -i -a $win_found | |
fi | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment