aboutsummaryrefslogtreecommitdiff
path: root/wtmux
diff options
context:
space:
mode:
authorSilvio Rhatto <rhatto@riseup.net>2016-05-19 18:53:35 -0300
committerSilvio Rhatto <rhatto@riseup.net>2016-05-19 18:53:35 -0300
commit4fbed988b5c787740dc08d27fecf9e9151baf281 (patch)
treecd85c1fa87077704237c6feed046cb725ec6459b /wtmux
parent757bcb115efa59abbb80424efef36f074d82ffc9 (diff)
downloadtermplex-4fbed988b5c787740dc08d27fecf9e9151baf281.tar.gz
termplex-4fbed988b5c787740dc08d27fecf9e9151baf281.tar.bz2
Adds wtmux
Diffstat (limited to 'wtmux')
-rwxr-xr-xwtmux31
1 files changed, 31 insertions, 0 deletions
diff --git a/wtmux b/wtmux
new file mode 100755
index 0000000..5a3f2a8
--- /dev/null
+++ b/wtmux
@@ -0,0 +1,31 @@
+#
+# Worktemux: tmux session wrapper
+# https://robots.thoughtbot.com/a-tmux-crash-course
+#
+
+# 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 [ "$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=""
+ fi
+fi
+
+# Start session.
+tmux $opts $session