aboutsummaryrefslogtreecommitdiff
path: root/wtmux
diff options
context:
space:
mode:
authorSilvio Rhatto <rhatto@riseup.net>2017-08-20 23:17:30 -0300
committerSilvio Rhatto <rhatto@riseup.net>2017-08-20 23:17:30 -0300
commit5553760f97821ba88fc9fe01771a2a7df6fd829a (patch)
tree0de15e53fc749ad640b5f956c9c8bde577624bdf /wtmux
parent7dc7dfc9cab4d45bb193448d1ee0284f98772075 (diff)
downloadtermplex-5553760f97821ba88fc9fe01771a2a7df6fd829a.tar.gz
termplex-5553760f97821ba88fc9fe01771a2a7df6fd829a.tar.bz2
Full session support at wtmux
Diffstat (limited to 'wtmux')
-rwxr-xr-xwtmux44
1 files changed, 26 insertions, 18 deletions
diff --git a/wtmux b/wtmux
index 5a3f2a8..4c6d336 100755
--- a/wtmux
+++ b/wtmux
@@ -2,30 +2,38 @@
# Worktemux: tmux session wrapper
# https://robots.thoughtbot.com/a-tmux-crash-course
#
+# Alternatives:
+# https://github.com/tmuxinator/tmuxinator
+# https://github.com/tony/tmuxp
# Default options.
opts=""
# Session selection.
if [ ! -z "$1" ]; then
- if tmux list-sessions 2> /dev/null | grep -q "^$1:"; then
- tmux attach -t $1
- exit $?
- else
- session="new -s $1"
- fi
+ if ! tmux list-sessions 2> /dev/null | grep -q "^$1:"; then
+ session="new-session -d -s $1"
+
+ if [ "$1" = "root" ]; then
+ sudo tmux attach
+ exit
+ elif [ -f "$HOME/.tmux/$1" ]; then
+ opts="$HOME/.tmux/$1"
+ elif [ -f "$HOME/.tmux/base" ]; then
+ opts="$HOME/.tmux/base"
+ else
+ opts=""
+ fi
- if [ "$1" == "root" ]; then
- sudo tmux attach
- exit
- elif [ -f "$HOME/.tmux/$1" ]; then
- opts="-f $HOME/.tmux/$1"
- elif [ -f "$HOME/.tmux/base" ]; then
- opts="-f $HOME/.tmux/base"
- else
- opts=""
+ # Start session.
+ if [ ! -z "$opts" ]; then
+ tmux $session \; source-file $opts
+ else
+ tmux $session
+ fi
fi
-fi
-# Start session.
-tmux $opts $session
+ tmux attach -t $1
+else
+ tmux
+fi