complete brief yak shave

This commit is contained in:
maren 2024-02-09 23:43:43 -05:00
parent 4b84f46a83
commit 3de4803734

View file

@ -1,35 +1,19 @@
#!/bin/bash -e #!/bin/bash
set -e
case $1 in function isExistingDeck {
kill)
# kill
;;
restart)
# restart
;;
"")
newDeck
;;
*)
# error
;;
esac
function newDeck {
set +e set +e
sessions=$(tmux list-sessions) sessions=$(tmux list-sessions)
set -e set -e
if [[ $sessions == *"bunkdeck"* ]]; then if [[ $sessions == *"bunkdeck"* ]]; then
tmux attach-session -t bunkdeck return 0
exit 1 else
return 1
fi fi
}
function startNewDeck {
tmux new -d -s bunkdeck heed tmux new -d -s bunkdeck heed
tmux split-window -h -t bunkdeck -p 70 tmux split-window -h -t bunkdeck -p 70
tmux split-window -t bunkdeck:0.0 -v -p 10 tmux split-window -t bunkdeck:0.0 -v -p 10
@ -37,3 +21,29 @@ function newDeck {
tmux send-keys -t bunkdeck:0.2 'cowsay "press [CTRL+b then o] to cycle through panes"' C-m tmux send-keys -t bunkdeck:0.2 'cowsay "press [CTRL+b then o] to cycle through panes"' C-m
tmux attach -t bunkdeck:0.2 tmux attach -t bunkdeck:0.2
} }
function killDeck {
tmux kill-session -t bunkdeck
}
case $1 in
kill)
killDeck
;;
"")
if isExistingDeck; then
tmux attach-session -t bunkdeck
else
startNewDeck
fi
;;
*)
echo "usage: bunkdeck [COMMAND]"
echo
echo "commands:"
echo " (none) attach to existing bunkdeck or start new one"
echo " kill kill running bunkdeck"
exit 1
;;
esac