abduco (934B)
1 #!/bin/bash 2 OPTIONS="$OPTIONS -noi" 3 TERMEXEC="urxvt -e" 4 5 B="$1"; shift 6 case $B in 7 main) 8 PROMPT="$(abduco | sed 1q)" 9 10 while read -r S; do 11 [ "$S" ] || continue 12 LEAVES[${#LEAVES[*]}]="$S" 13 ACTIONS[${#ACTIONS[*]}]="child manage '$S'" 14 done <<EOF 15 $(abduco | sed -n '2,$s/\t/ /gp' | awk 'NF{print}') 16 EOF 17 18 LEAVES[${#LEAVES[*]}]="+ new session..." 19 ACTIONS[${#ACTIONS[*]}]="child new" 20 LEAVES[${#LEAVES[*]}]="+ dial a host..." 21 ACTIONS[${#ACTIONS[*]}]="tchild dialer" 22 ;; 23 manage) 24 PSEL="$(echo "$*" | sed 's/^[*+] //' | tr -s "[:blank:]" " ")" 25 S=$(echo "$PSEL" | awk '$1=$2=$3=$4="";1' | sed 's/^ *//') 26 PID=$(echo "$PSEL" | awk '{print $4}') 27 PROMPT="Manage session: $S" 28 LEAVES=("attach" "kill") 29 ACTIONS=("run $TERMEXEC abduco -a '$S'" "kill $PID");; 30 new) 31 unset OPTIONS 32 INPUT="create" 33 PROMPT="new session: ";; 34 esac 35 36 create() { 37 NAME="$(basename "$1")" 38 $TERMEXEC abduco -c "${NAME:-$(basename $SHELL)}.$$" ${*:-$SHELL} & 39 }