Created
February 7, 2026 12:59
-
-
Save joechrysler/659338e3caab7a4fd90f626348da7755 to your computer and use it in GitHub Desktop.
A nice session picker for tmux
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/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