Created
March 20, 2015 17:29
-
-
Save raidzero/4fcd8a8f6da9971e482c to your computer and use it in GitHub Desktop.
Launch a new terminal or just find one and bring it to the foreground - meant for a keyboard shortcut or WM menu option
This file contains 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/sh | |
HOSTNAME=`hostname` | |
# command to launch terminal | |
TERM_CMD="xfce4-terminal" | |
# what my terminal window name will always start with | |
NAME_PREFIX="#!" | |
# the name of the current terminal window - if more than one just guess and use the first | |
CURRENT_NAME=`wmctrl -l | grep "$NAME_PREFIX" | sed 's/^.*'"$HOSTNAME"' //' | head -n 1` | |
if [ -z "$CURRENT_NAME" ]; then | |
# not running, launch | |
$TERM_CMD & | |
else | |
# bring to foreground | |
wmctrl -a "$CURRENT_NAME" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment