24 lines
520 B
Plaintext
24 lines
520 B
Plaintext
|
|
#!/usr/bin/env zsh
|
||
|
|
|
||
|
|
selected=$(find ~/projects -maxdepth 1 -mindepth 1 | fzf)
|
||
|
|
if [[ -z "$selected" ]]; then
|
||
|
|
exit 0
|
||
|
|
fi
|
||
|
|
selected_name=$(basename $selected | tr ".,: " "____")
|
||
|
|
|
||
|
|
switch_to() {
|
||
|
|
if [[ -z "$TMUX" ]]; then
|
||
|
|
tmux attach-session -t $selected_name
|
||
|
|
else
|
||
|
|
tmux switch-client -t $selected_name
|
||
|
|
fi
|
||
|
|
}
|
||
|
|
|
||
|
|
if tmux has-session -t="$selected_name"; then
|
||
|
|
switch_to
|
||
|
|
else
|
||
|
|
tmux new-session -ds $selected_name -c $selected
|
||
|
|
tmux send-keys -t $selected_name "tmux-setup" ^M
|
||
|
|
switch_to
|
||
|
|
fi
|