Skip to content

Instantly share code, notes, and snippets.

@oppara
Created May 4, 2026 09:00
Show Gist options
  • Select an option

  • Save oppara/2c5cdb25d24e31d7039e6ff99a72c526 to your computer and use it in GitHub Desktop.

Select an option

Save oppara/2c5cdb25d24e31d7039e6ff99a72c526 to your computer and use it in GitHub Desktop.
tmux-session-killer
#!/usr/bin/env bash
#
# Fast tmux session switcher using fzf
#
# Lists sessions sorted by last attached time (most recent first),
# excludes current session, and switches to the selected one.
#
# Usage:
# Bind to a key in tmux.conf:
# bind C-j display-popup -E "tmux-session-switcher"
#
# Requirements: fzf
target=$(tmux list-sessions -F '#{session_last_attached} #{session_name}' \
| sort -rn \
| sed -E 's/^[0-9]* //' \
| grep -v "^$(tmux display-message -p '#S')$" \
| fzf --reverse)
if [[ -n $target ]]; then
tmux kill-session -t "$target"
fi
@oppara
Copy link
Copy Markdown
Author

oppara commented May 4, 2026

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment