#!/bin/sh # (f)ocus (or) (e)xecute a script/program depending of if it's # already running or not. focus() { xdotool search --onlyvisible "^${1}$" windowactivate 2> /dev/null } if [ $# -lt 1 ] then printf 'usage: %s command\n' "${0##*/}" exit 1 fi case "$1" in -t) shift; focus "$1" || "$TERMINAL" -T "$1" -e "$@" ;; *) focus "$1" || "$@" ;; esac