Skip to content

Instantly share code, notes, and snippets.

@joechrysler
Created February 16, 2026 14:32
Show Gist options
  • Select an option

  • Save joechrysler/39ec21c191c093f0c4ec6a6653e42770 to your computer and use it in GitHub Desktop.

Select an option

Save joechrysler/39ec21c191c093f0c4ec6a6653e42770 to your computer and use it in GitHub Desktop.
tmux-wrapper
# Alias: alias t='tmux-wrapper'
#!/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
New 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