dotfiles/.bin/webdev

35 lines
795 B
Plaintext
Raw Normal View History

2022-12-17 12:11:20 +01:00
#!/bin/sh -x
session=webdev
2022-12-17 19:27:19 +01:00
socket=~/.tmux.sock
arg="$1"
2022-12-17 12:11:20 +01:00
if ! tmux att -t webdev >/dev/null 2>&1
then
# create session
tmux new-session -s $session -d
# window 1
window=1
tmux rename-window -t $session:$window 'edit'
2022-12-17 19:27:19 +01:00
tmux send-keys -t $session:$window 'cd ~/website/site' Enter
if [ ! -z "$arg" ]
then
tmux send-keys -t $session:$window "vim $arg" Enter
else
tmux send-keys -t $session:$window "nnn" Enter
fi
2022-12-17 12:11:20 +01:00
# window 2
window=2
tmux new-window -t $session:$window -n 'build'
tmux send-keys -t $session:$window 'cd ~/website && make notify' Enter
2022-12-17 19:27:19 +01:00
# switch back to window 1
tmux select-window -t $session:1
cd ~/website && make show-local > /dev/null 2>&1
2022-12-17 12:11:20 +01:00
# attach to session
tmux att -t webdev
fi