Created
February 16, 2026 14:32
-
-
Save joechrysler/39ec21c191c093f0c4ec6a6653e42770 to your computer and use it in GitHub Desktop.
tmux-wrapper
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
| # 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