dotfiles/.config/scripts/new-session.sh

34 lines
1,020 B
Bash
Raw Normal View History

2025-04-02 06:16:00 -05:00
#!/bin/bash
dir=${1:-}
2025-04-05 14:43:48 -05:00
[ -z "${dir}" ] && dir=$(find $HOME/Documents/gitlab -mindepth 2 -maxdepth 2 -type d | awk -F/ '{print $(NF-1)"/"$NF " " $0}' | fzf --with-nth=1 | awk '{print $2}')
2025-04-02 05:52:16 -05:00
[ -z "$dir" ] && return 1
name=$(basename "$dir")
if [[ $name == .* ]]; then
name=${name#.}
fi
tmux has-session -t ${name} >/dev/null && {
tmux switch-client -t ${name}
return
}
tmux new-session -d -s "$name" -c "$dir"
RIGHT_PANE_WIDTH=60
BOTTOM_PANE_WIDTH=15
tmux split-window -h -t "$name:1" -c "$dir"
tmux resize-pane -t "$name:1.2" -x $RIGHT_PANE_WIDTH
tmux split-window -v -t "$name:1.1" -c "$dir"
tmux resize-pane -t "$name:1.1" -y $(($(tmux display -p '#{window_height}') - $BOTTOM_PANE_WIDTH))
tmux new-window "$name" -n lazygit -c "$dir"
sleep 1
2025-04-03 05:38:20 -05:00
tmux send-keys -t "$name:1.1" 'nvim' C-m
2025-04-02 05:52:16 -05:00
sleep 0.1
tmux send-keys -t "$name:1.3" 'set-env; nvim +CodeCompanionChat -c only' C-m
sleep 1
tmux send-keys -t "$name:2" 'lg' C-m
tmux select-window -t "$name:1"
tmux select-pane -t "$name:1.1"
tmux switch-client -t "$name"