12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273 |
- #!/usr/bin/env bash
- PROGNAME=$(basename $0)
- OPTSTRING="${PROGNAME} (-x) [ -h | -l | -z | -c name | -n name | -e name tab command ]"
- if [[ $# -eq 0 ]] ; then
- echo ${OPTSTRING} >&2
- exit 1
- fi
- XWINFLAG=false
- while getopts "c:n:e:zlxh" OPT
- do
- # shift
- case "$OPT" in
- x)
- XWINFLAG=true
- ;;
- z)
- exec urxvto -class XTermScreen -e screen
- ;;
- l)
- if [[ $XWINFLAG != "true" ]] ; then
- screen -list | sed '$ d' | sed 1d | awk '{print $1}'
- else
- if [[ -e `which rofi` ]] ; then
- NAME=`screen -list | sed '$ d' | sed 1d | awk '{print $1}' | rofi -dmenu -p "screen session"`
- else
- NAME=`screen -list | sed '$ d' | sed 1d | awk '{print $1}' | dmenu -p "screen session:"`
- fi
- [[ $NAME != "" ]] && exec urxvto -class XTermScreen -e screen -x $NAME
- fi
- ;;
- c)
- if [[ $XWINFLAG != "true" ]] ; then
- exec screen -x "${OPTARG}"
- else
- exec urxtvo -class XTermScreen -e "screen -x \"${OPTARG}\""
- fi
- ;;
- n)
- if [[ $XWINFLAG != "true" ]] ; then
- exec screen -S "${OPTARG}"
- else
- exec urxtvo -class XTermScreen -e "screen -S \"${OPTARG}\""
- fi
- ;;
- e)
- OPTIND1=$(( OPTIND + 1 ))
- TAB=${!OPTIND}
- COMMAND=${!OPTIND1}
- screen -x "${OPTARG}" -X screen -t ${TAB} ${COMMAND}
- exit
- ;;
- h)
- echo ${OPTSTRING} >&2
- cat <<HELP >&2
- -h Show this help.
- -x Turn on X-windows interaction.
- -z Create a new, unnamed screen session with X Terminal.
- -l List screen sessions (with -x, show in ROFI).
- -c name Connect (as an additional screen) to session "name".
- -n name Create and connect to a new screen session "name".
- -e name tab command
- Create a tab named "tab" running the command "command" in session "name".
- HELP
- exit
- ;;
- esac
- done
|