aboutsummaryrefslogtreecommitdiffstats
path: root/.zshrc-remote
diff options
context:
space:
mode:
authorshmibs <shmibs@shmibbles.me>2015-12-22 18:39:39 -0700
committershmibs <shmibs@shmibbles.me>2015-12-22 18:39:39 -0700
commit3e89d89cd8558e2848eab872de6b6a3d0067b7d3 (patch)
tree4bb9b2dd3b9a64ff52dec82c52a7ae7526b63e8f /.zshrc-remote
parent277bc9cb29ed4a05eab37c5304a6ad7c18c9bafb (diff)
downloaddotfiles-3e89d89cd8558e2848eab872de6b6a3d0067b7d3.tar.gz
tmux session handling
Diffstat (limited to '.zshrc-remote')
-rw-r--r--.zshrc-remote59
1 files changed, 57 insertions, 2 deletions
diff --git a/.zshrc-remote b/.zshrc-remote
index f7e5c0d..c257774 100644
--- a/.zshrc-remote
+++ b/.zshrc-remote
@@ -1,4 +1,59 @@
-if [[ $TERM != "screen" ]]; then
- tmux
+[[ $TERM != "screen" ]]; then
+ tmux has-session 2>/dev/null
+ if [[ "$?" != "0" ]]; then
+ tmux
+ fi
+
+ tmux has-session 2>/dev/null
+ if [[ "$?" != "0" ]]; then
+ logout
+ fi
+
+ {
+ while true; do
+ tmux has-session 2>/dev/null
+ if [[ "$?" != "0" ]]; then
+ logout
+ fi
+
+ echo ""
+ tmux list-sessions
+
+ echo -n "> "
+ read -A args
+ case "${args[1]}" in
+ a)
+ if [[ "${args[2]}" != "" ]]; then
+ tmux has-session -t "${args[2]}"
+ if [[ "$?" == "0" ]]; then
+ tmux attach-session -t "${args[2]}"
+ fi
+ fi
+ ;;
+
+ k)
+ if [[ "${args[2]}" != "" ]]; then
+ tmux has-session -t "${args[2]}"
+ if [[ "$?" == "0" ]]; then
+ tmux kill-session -t "${args[2]}"
+ fi
+ fi
+ ;;
+
+ n)
+ tmux new-session
+ ;;
+
+ q)
+ break;
+ ;;
+
+ *)
+ ;;
+ esac
+
+ done
+ }
+
logout
fi