#!/bin/bash # # bashprompt # # if there is an xterm open at a bash prompt, raise/focus that window # if there isn't start a new xterm # # requires that your xterm window title has "bash" at the end # when there is no command running and doesn't have "bash" at the end # when a command is running # # see for more details # and an example .bashrc to set the title (requires bash 3.2 or newer) # # Mikel Ward # change this to whatever is unique about your window title # (i.e. a string that appears in the title when the shell is at a prompt # but does not appear when running a command) prompttitle="bash$" terminalprog="xterm" if ! type wmctrl >/dev/null 2>&1; then echo "wmctrl can't be found, please install it" 1>&2 exit 1 fi if ! output="$(wmctrl -l)"; then echo "Error running wmctrl -l" 1>&2 exit 1 fi while IFS=$'\n' read -r line; do if [[ $line =~ $prompttitle ]]; then id=${line%% *} break fi done <