tmux sessionizer can attach when no client e attached

This commit is contained in:
Tiago Sousa 2024-04-02 19:22:13 +01:00
parent 44c53d68d0
commit 3852948adf
Signed by: tiago
SSH key fingerprint: SHA256:odOD9vln9U7qNe1R8o3UCbE3jkQCkr5/q5mgd5hwua0

View file

@ -14,13 +14,19 @@ fi
selected_name=$(basename "$selected" | tr . _) selected_name=$(basename "$selected" | tr . _)
tmux_running=$(pgrep tmux) tmux_running=$(pgrep tmux)
if [[ -z $TMUX ]] && [[ -z "$tmux_running" ]]; then
if [[ -z "$tmux_running" ]]; then
if [[ -z $TMUX ]]; then
tmux new-session -s "$selected_name" -c "$selected" tmux new-session -s "$selected_name" -c "$selected"
exit 0 exit 0
fi fi
else
if ! tmux has-session -t="$selected_name" 2> /dev/null; then if [[ -z $TMUX ]]; then
tmux a
fi
if ! tmux has-session -t="$selected_name" 2> /dev/null; then
tmux new-session -ds "$selected_name" -c "$selected" tmux new-session -ds "$selected_name" -c "$selected"
fi
tmux switch-client -t "$selected_name"
fi fi
tmux switch-client -t "$selected_name"