-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtmux-sessionizer
executable file
·49 lines (39 loc) · 1.05 KB
/
tmux-sessionizer
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/usr/bin/env zsh
PROJECTS=(
"$HOME/Developer"
"$HOME/Developer/dev-practice"
"$HOME/.config/nvim"
)
if [[ $# -eq 1 ]]; then
selected=$1
else
selected=$(find "${PROJECTS[@]}" -mindepth 0 -maxdepth 3 -type d \
-not -path "*/.git*" \
-not -path "*/node_modules*" \
-not -path "*/.github*" | sort | uniq | fzf)
fi
if [[ -z $selected ]]; then
exit 0
fi
selected_name=$(basename "$selected" | tr . _)
tmux_running=$(pgrep tmux)
selected_names=(
"sso-project" "nvim" "kantan" "rustlings"
"learn-go-with-tests"
"the_rust_programming_language"
"3D-Portfolio"
"attendance-criteria-manager"
"rustdesk"
)
if [[ " ${selected_names[*]} " == *" $selected_name "* ]]; then
tmuxifier load-session $selected_name
exit 0
fi
if [[ -z $TMUX ]] && [[ -z $tmux_running ]]; then
tmux new-session -s $selected_name -c $selected
exit 0
fi
if ! tmux has-session -t=$selected_name 2> /dev/null; then
tmux new-session -ds $selected_name -c $selected
fi
tmux switch-client -t $selected_name