Skip to content

Instantly share code, notes, and snippets.

@joechrysler
Created February 7, 2026 12:59
Show Gist options
  • Select an option

  • Save joechrysler/659338e3caab7a4fd90f626348da7755 to your computer and use it in GitHub Desktop.

Select an option

Save joechrysler/659338e3caab7a4fd90f626348da7755 to your computer and use it in GitHub Desktop.
A nice session picker for tmux
#!/usr/bin/env zsh
# Get list of sessions
sessions=$(tmux list-sessions -F "#{session_name}" 2>/dev/null)
if [ -z "$sessions" ]; then
# No sessions exist, create a new one
exec tmux new-session -s "$(date +'%Y-%m-%d %H:%M')"
else
# Show picker with existing sessions and a New option
selected=$(printf "%s\nNew Session" "$sessions" | fzf \
--prompt="Select tmux session: " \
--height=40% \
--reverse \
--header="enter: attach ctrl-d: kill session" \
--bind="ctrl-d:execute-silent(tmux kill-session -t {})+reload(tmux list-sessions -F '#{session_name}' 2>/dev/null; echo 'New Session')")
if [ "$selected" = "New Session" ]; then
exec tmux new-session -s "$(date +'%Y-%m-%d %H:%M')"
elif [ -n "$selected" ]; then
exec tmux attach-session -t "$selected"
fi
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment