-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdev.sh
More file actions
25 lines (19 loc) · 732 Bytes
/
Copy pathdev.sh
File metadata and controls
25 lines (19 loc) · 732 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#!/usr/bin/env bash
# dev: start tmux with 2 tabs (Neovim + shell)
# chmod +x ~/.local/bin/dev (don't use .sh in the file extension)
# run "dev" to open a tmux session with nvim in the pwd and a zsh shell behind it
SESSION_NAME=$(basename "$PWD")
# Reattach if already running
if tmux has-session -t "$SESSION_NAME" 2>/dev/null; then
tmux attach -t "$SESSION_NAME"
exit 0
fi
# Create session detached
tmux new-session -d -s "$SESSION_NAME" -n nvim -c "$PWD"
# First tab: open Neovim
tmux send-keys -t "$SESSION_NAME":nvim 'nvim' C-m
# Second tab: normal shell
tmux new-window -t "$SESSION_NAME" -n shell -c "$PWD"
# Attach with Neovim tab selected
tmux select-window -t "$SESSION_NAME":nvim
tmux attach -t "$SESSION_NAME"