diff options
author | Silvio Rhatto <rhatto@riseup.net> | 2017-08-20 23:17:30 -0300 |
---|---|---|
committer | Silvio Rhatto <rhatto@riseup.net> | 2017-08-20 23:17:30 -0300 |
commit | 5553760f97821ba88fc9fe01771a2a7df6fd829a (patch) | |
tree | 0de15e53fc749ad640b5f956c9c8bde577624bdf /wtmux | |
parent | 7dc7dfc9cab4d45bb193448d1ee0284f98772075 (diff) | |
download | termplex-5553760f97821ba88fc9fe01771a2a7df6fd829a.tar.gz termplex-5553760f97821ba88fc9fe01771a2a7df6fd829a.tar.bz2 |
Full session support at wtmux
Diffstat (limited to 'wtmux')
-rwxr-xr-x | wtmux | 44 |
1 files changed, 26 insertions, 18 deletions
@@ -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 |