Skip to content

Commit

Permalink
feat(scripts): added tmux a check
Browse files Browse the repository at this point in the history
  • Loading branch information
AlejandroSuero committed Apr 4, 2024
1 parent e95c066 commit 08437c0
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions roles/zsh/files/zsh/bin/tmux-sessionizer
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,20 @@ fi
selected_name=$(basename "$selected" | tr . _)
tmux_running=$(pgrep tmux)

if ! tmux a 2> /dev/null; then
tmux a -t "$selected_name"
exit
fi

if [[ -z $TMUX ]] && [[ -z $tmux_running ]]; then
tmux new-session -s $selected_name -c $selected
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
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
tmux switch-client -t "$selected_name"

# vi:ft=sh

0 comments on commit 08437c0

Please sign in to comment.