2013-04-04 16:13:46 +00:00
|
|
|
#!/bin/bash
|
2013-04-05 15:56:13 +00:00
|
|
|
TERMINAL_EMULATOR='urxvt'
|
2013-04-04 17:00:57 +00:00
|
|
|
tab=1
|
|
|
|
pgrep -l -u "$USER" -f "$TERMINAL_EMULATOR" | egrep -v "/bin/zsh|/bin/bash|/bin/sh" | grep -vq "$$"
|
|
|
|
if [ $? != "0" ]
|
2013-04-04 16:13:46 +00:00
|
|
|
then
|
2013-04-04 17:00:57 +00:00
|
|
|
/usr/bin/$TERMINAL_EMULATOR &
|
2013-04-04 16:13:46 +00:00
|
|
|
sleep 1
|
|
|
|
tab=0
|
2013-04-04 17:00:57 +00:00
|
|
|
fi
|
|
|
|
WID=`xdotool search --class $TERMINAL_EMULATOR | tail -1`
|
|
|
|
wmctrl -i -a $WID
|
|
|
|
if [ "x$1" != "x" ]
|
|
|
|
then
|
|
|
|
if [ "x$1" == "xhelp" ]
|
2013-04-04 16:13:46 +00:00
|
|
|
then
|
2013-04-04 17:00:57 +00:00
|
|
|
echo "Usage: $0 [command-in-new-window]"
|
|
|
|
else
|
2013-04-04 16:13:46 +00:00
|
|
|
if [ $tab == 1 ]
|
|
|
|
then
|
|
|
|
eval "tmux neww"
|
|
|
|
sleep 0.2
|
|
|
|
fi
|
|
|
|
xdotool type "$*"
|
|
|
|
xdotool key Return
|
|
|
|
fi
|
|
|
|
fi
|