Skip to content

Commit

Permalink
Small fix to tmux sessionizer from ThePrimeagen/.dotfiles#32
Browse files Browse the repository at this point in the history
  • Loading branch information
silasiebert committed May 20, 2024
1 parent 679a235 commit a7b0e11
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions bin/scripts/tmux-sessionizer.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/usr/bin/env bash

if [[ $# -eq 1 ]]; then
selected=$1
else
selected=$(find ~/work ~/personal/projects/ -mindepth 1 -maxdepth 1 -type d | fzf)
fi

if [[ -z $selected ]]; then
exit 0
fi

selected_name=$(basename "$selected" | tr . _)
tmux_running=$(pgrep tmux)

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

if [[ -z $TMUX ]]; then
tmux attach-session -t $selected_name
else
tmux switch-client -t $selected_name
fi

0 comments on commit a7b0e11

Please sign in to comment.