diff --git a/bashrc/.bashrc b/bashrc/.bashrc index 5a7500b..1220d2f 100644 --- a/bashrc/.bashrc +++ b/bashrc/.bashrc @@ -27,7 +27,13 @@ alias dirs='dirs -v' alias bashsource='source ~/.bashrc' -## short forms for tmux commands +# short forms for tmux commands + +## run script to setup default tmux session and then attach the session +## attaching the session needs to be done from the calling shell, otherwise +## the setup script will only terminate after detaching or killing the session +alias dmux='default-tmux-session && tmux attach' + alias tma='tmux attach' alias tmd='tmux detach -P' diff --git a/misc/scripts/default-tmux-session b/misc/scripts/default-tmux-session new file mode 100755 index 0000000..3d50d56 --- /dev/null +++ b/misc/scripts/default-tmux-session @@ -0,0 +1,23 @@ +#!/usr/bin/env bash + +SESSION='quak' +# dont forget the '-d' option, otherwise the rest of +# the commands will get executed after the session is closed + +if $(tmux has-session -t ${SESSION}); then + echo "default session ${SESSION} already exists" + + # return 1 to report error and abort the `dmux` alias + return 1 +else + tmux new-session -d -s "$SESSION" -n "temp" + tmux new-window -t "$SESSION" -n "dotfiles" -c $HOME/dotfiles + tmux new-window -t "$SESSION" -n "docs" -c $HOME/collection + tmux new-window -t "$SESSION" -n "stuff" -c $HOME + tmux kill-window -t "temp" + + # this causes the script to exit only, when the session is ended or detached + # it also causes the tmux detach command with hang up signal to fail + # therefore the following line is commented out and an alias setup in .bashrc + #tmux attach -t "$SESSION" +fi diff --git a/misc/scripts/dmux b/misc/scripts/dmux deleted file mode 100755 index c8d678d..0000000 --- a/misc/scripts/dmux +++ /dev/null @@ -1,11 +0,0 @@ -#!/usr/bin/env bash - -SESSION='quak' -# dont forget the '-d' option, otherwise the rest of -# the commands will get executed after the session is closed -tmux new-session -d -s "$SESSION" -n "temp" -tmux new-window -t "$SESSION" -n "dotfiles" -c $HOME/dotfiles -tmux new-window -t "$SESSION" -n "docs" -c $HOME/collection -tmux new-window -t "$SESSION" -n "stuff" -c $HOME -tmux kill-window -t "temp" -tmux attach -t "$SESSION"