12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- #!/bin/zsh -f
- if [[ $# -eq 0 ]] ; then
- echo "connect-screen [ screen-instance [ -x ] | list | dmenu ]"
- exit
- fi
- function open-screen {
- screen -r $1
- }
- function open-screen-x {
- xterm -e "screen -r $1"
- }
- function list-screen-sessions {
- screen -list | sed '$ d' | sed 1d | awk '{print $1}'
- }
- function with-external-completion {
- if [[ -e `which rofi` ]] ; then
- SCREEN=`list-screen-sessions | rofi -dmenu -p "screen session:"`
- [[ $SCREEN != "" ]] && open-screen-x $SCREEN
- else
- SCREEN=`list-screen-sessions | dmenu -p "screen session:"`
- [[ $SCREEN != "" ]] && open-screen-x $SCREEN
- fi
- }
- SCREEN=$1
- shift
- case ${SCREEN} in
- list)
- list-screen-sessions
- ;;
- dmenu)
- with-external-completion
- ;;
- *)
- if [[ $1 == "-x" ]] ; then
- open-screen-x $SCREEN
- else
- open-screen $SCREEN
- fi
- esac
|