Skip to content

Instantly share code, notes, and snippets.

@code-inflation
Created June 29, 2025 21:00
Show Gist options
  • Select an option

  • Save code-inflation/98f743340831623bcb255c51f28e598e to your computer and use it in GitHub Desktop.

Select an option

Save code-inflation/98f743340831623bcb255c51f28e598e to your computer and use it in GitHub Desktop.
Fuzzy find and switch to tmux sessions for git repositories
# Fuzzy find and switch to tmux sessions for git repositories
# Usage: tmux-sessionizer [directory]
# If no directory provided, opens fzf to select from ~/git subdirectories
function tmux-sessionizer
if test (count $argv) -eq 1
set selected $argv[1]
else
set selected (find ~/git -mindepth 1 -maxdepth 1 -type d | fzf)
end
if test -z "$selected"
return 0
end
set selected_name (basename "$selected" | tr . _)
set tmux_running (pgrep tmux)
if test -z "$TMUX" -a -z "$tmux_running"
tmux new-session -s $selected_name -c $selected
return 0
end
if not tmux has-session -t=$selected_name 2>/dev/null
tmux new-session -ds $selected_name -c $selected
end
tmux switch-client -t $selected_name
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment