|
|
@@ -0,0 +1,70 @@
|
|
|
+#!/bin/zsh
|
|
|
+while true; do
|
|
|
+ tput civis;
|
|
|
+ items=("zsh" "alpha")
|
|
|
+ items+=("${(@f)$(tmux list-sessions -F '#S' | grep -v '^alpha$' | cat - <(echo 'beta\ngamma') | uniq | head -n 2)}")
|
|
|
+ items+=("${(z)$(~/.scripts/ssh_launch.zsh 2)}")
|
|
|
+ printf "\r\n"
|
|
|
+ printf " Welcome to \e[31m${TERM}\e[0m, \e[33m${USER}\e[0m@\e[33m${HOST}\e[0m.\n"
|
|
|
+ printf "\n"
|
|
|
+ printf " a) Open a \e[36mlocal\e[0m \e[4m${items[1]}\e[0m shell.\n"
|
|
|
+ printf " r) \e[3m(Default)\e[0m Attach the \e[33m${items[2]}\e[0m \e[4mtmux\e[0m session.\n"
|
|
|
+ printf " s) Attach the \e[33m${items[3]}\e[0m \e[4mtmux\e[0m session.\n"
|
|
|
+ printf " t) Attach the \e[33m${items[4]}\e[0m \e[4mtmux\e[0m session.\n"
|
|
|
+ printf " n) Start an \e[4mssh\e[0m session for \e[31m${items[5]}\e[0m.\n"
|
|
|
+ printf " e) Start an \e[4mssh\e[0m session for \e[31m${items[6]}\e[0m.\n"
|
|
|
+ printf " i) \e[33mSelect\e[0m a \e[4mtmux\e[0m session.\n"
|
|
|
+ printf " o) \e[31mSelect\e[0m an \e[4mssh\e[0m session.\n"
|
|
|
+ printf "\n"
|
|
|
+ for countdown in 10 9 8 7 6 5 4 3 2 1; do
|
|
|
+ for dots in 0 1 2 3 4 5; do
|
|
|
+ if [[ -z "$selection" ]]; then
|
|
|
+ printf "\r Defaulting to \e[4mtmux\e[0m \e[33m${items[2]}\e[0m in ${countdown}";
|
|
|
+ for dotprint in 0 1 2 3 4 5; do
|
|
|
+ if (( $dots > dotprint )); then
|
|
|
+ printf "."
|
|
|
+ else
|
|
|
+ printf " "
|
|
|
+ fi;
|
|
|
+ done;
|
|
|
+ read -k1 -s -t 0.2 selection
|
|
|
+ fi
|
|
|
+ done;
|
|
|
+ done;
|
|
|
+ clear;
|
|
|
+ tput cnorm;
|
|
|
+ case $selection in
|
|
|
+ a)
|
|
|
+ /bin/zsh
|
|
|
+ ;;
|
|
|
+ r|"")
|
|
|
+ tmux new-session -A -s ${items[2]}
|
|
|
+ ;;
|
|
|
+ s)
|
|
|
+ tmux new-session -A -s ${items[3]}
|
|
|
+ ;;
|
|
|
+ t)
|
|
|
+ tmux new-session -A -s ${items[4]}
|
|
|
+ ;;
|
|
|
+ n)
|
|
|
+ /bin/zsh -c "~/.scripts/ssh_launch.zsh ${items[5]}"
|
|
|
+ ;;
|
|
|
+ e)
|
|
|
+ /bin/zsh -c "~/.scripts/ssh_launch.zsh ${items[6]}"
|
|
|
+ ;;
|
|
|
+ i)
|
|
|
+ # It's hard to know if we're is already in a tmux pane; but, if the
|
|
|
+ # `choose-tree` command fails instantly, then we're probably not!
|
|
|
+ starttime=$(date +%s);
|
|
|
+ tmux choose-tree;
|
|
|
+ if [ $starttime -eq $(date +%s) ]; then
|
|
|
+ tmux new-session -A -s ${items[2]}\; choose-tree;
|
|
|
+ fi
|
|
|
+ ;;
|
|
|
+ o)
|
|
|
+ /bin/zsh -c ~/.scripts/ssh_launch.zsh
|
|
|
+ ;;
|
|
|
+ esac;
|
|
|
+ selection=""
|
|
|
+ clear;
|
|
|
+done;
|