-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprepare-sessions.fish
29 lines (22 loc) · 1.08 KB
/
prepare-sessions.fish
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
26
27
28
29
#!/usr/bin/env fish
# Define sessions and their windows with commands
set sessions "system:monitor:top#disk-usage:df -h#processes:ps aux" \
"blog:helix:hx ../blog#gitui:cd ../blog && gitui#deploy:cd ../blog && hugo server" \
"qrcode:helix:cd ../qrcode && hx README.md#git:cd ../qrcode && gitui" \
"gession:helix:hx README.md#git:gitui#log:tail -f '../../Library/Application Support/gession/gession.log'"
for session_entry in $sessions
set session (echo $session_entry | cut -d: -f1)
set windows (echo $session_entry | cut -d: -f2- | string split "#")
set first_window_name (echo $windows | head -1 | cut -d: -f1)
for window_entry in $windows
set name (echo $window_entry | cut -d: -f1)
set cmd (echo $window_entry | cut -d: -f2-)
if not tmux has-session -t $session >/dev/null 2>&1
tmux new-session -d -s $session -n $first_window_name
else
tmux new-window -t $session -n $name "$SHELL"
end
tmux send-keys -t $session:$name "$cmd" C-m
end
end
echo "All sessions and windows have been configured."