tmux is king scripting and configs abound

This commit is contained in:
Daylin Morgan 2023-01-12 13:46:41 -06:00
parent 6958f1ea95
commit 3f70a3fba5
3 changed files with 46 additions and 0 deletions

View file

@ -74,3 +74,6 @@ alias g="git"
is-executable gum && alias plz="gum input --prompt='🔒' --password | sudo -nS"
alias dockdots='docker run --rm -it -u "$(id -u):$(id -g)" -v "$PWD:/home/$USER/data" dots'
alias tmux-labbook="$DOTFILES_DIR/tmux/labbook.sh"

34
tmux/labbook.sh Executable file
View file

@ -0,0 +1,34 @@
#!/usr/bin/env bash
CURDIR="$(dirname "$(readlink -f "$0")")"
source "$CURDIR/tmux-functions.sh"
# Set Session Name
SESSION="labbook"
WORK_DIR="$HOME/$SESSION"
if ! [[ -d "$WORK_DIR" ]]; then
echo "expected to find $WORK_DIR but didn't"
exit 1
fi
# Only create tmux session if it doesn't already exist
if ! tmux list-sessions | grep $SESSION; then
# Start New Session with our name
tmux new-session -d -s $SESSION -c "$HOME/labbook"
# Name first Pane and start zsh
tmux rename-window -t $SESSION:0 'Main'
tmux send-keys -t 'Main'
# Create and setup pane for sphinx
tnw -t $SESSION:1 -n 'sphinx'
tsk -t 'sphinx' 'source ./.venv/bin/activate' Enter
tsk -t 'sphinx' 'make live' Enter
# setup writing window
tnw -t $SESSION:2 -n 'writing'
tsk -t 'writing' "nvim ./now.md" Enter
fi
# Attach Session, on the Main window
tmux attach-session -t $SESSION:0

9
tmux/tmux-functions.sh Normal file
View file

@ -0,0 +1,9 @@
#!/usr/bin/env bash
# Custom tmux new window to apply $WORK_DIR for all commands
tnw() {
tmux new-window -c "$WORK_DIR" "$@"
}
tsk() {
tmux send-keys "$@"
}