tmux’s built-in session and window switching is clunky, but fzf makes it fluid.

Here’s a tmux setup that uses fzf to let you fuzzy find your tmux sessions and windows. This means you can type a few characters and instantly jump to the session or window you want, instead of cycling through them with prefix + s or prefix + w.

First, let’s get fzf installed if you don’t have it. On macOS, it’s brew install fzf. On Debian/Ubuntu, it’s sudo apt install fzf.

Now, add these lines to your ~/.tmux.conf:

# ~/.tmux.conf

# Fuzzy find sessions
bind-key S choose-tree -s -w

# Fuzzy find windows within the current session
bind-key w choose-tree -w

After saving ~/.tmux.conf, reload your tmux configuration by running tmux source-file ~/.tmux.conf in a tmux pane, or by detaching from all tmux sessions and starting a new one.

Now, when you press prefix + S (where prefix is usually Ctrl+b), you’ll see a fuzzy finder pop up listing all your current tmux sessions. Type a few letters of the session name, and fzf will filter the list. Press Enter, and you’ll switch to that session.

Similarly, prefix + w will bring up a fuzzy finder for windows within your current tmux session. This is incredibly useful when you have many windows open.

The magic behind choose-tree is that it generates a tree-like representation of your tmux environment (sessions, windows, panes) and pipes it into fzf. fzf then provides its interactive filtering interface. The -s flag in choose-tree -s -w tells it to list sessions, and -w tells it to list windows. Without -s, choose-tree defaults to listing windows and panes.

The real power comes when you combine this with fzf’s ability to execute commands. You can configure fzf to directly switch you to the selected session or window. Let’s refine the configuration.

Instead of just listing, we want to act on the selection. We’ll use fzf’s --bind option to execute tmux switch-client or tmux select-window.

Update your ~/.tmux.conf with this:

# ~/.tmux.conf

# Fuzzy find sessions and switch
bind-key S run-shell "tmux list-sessions -F '#{session_name}' | fzf --prompt 'Switch to session: ' --no-sort | xargs tmux switch-client -t"

# Fuzzy find windows and switch
bind-key w run-shell "tmux list-windows -F '#{window_index}: #{window_name}' | fzf --prompt 'Switch to window: ' --no-sort | cut -d: -f1 | xargs tmux select-window -t"

Reload your tmux configuration again.

Now, prefix + S will prompt you to select a session, and pressing Enter will immediately switch you to it. The tmux list-sessions -F '#{session_name}' command lists only the session names, which are then piped to fzf. The xargs tmux switch-client -t part takes the selected session name from fzf and passes it as an argument to tmux switch-client -t.

For prefix + w, the tmux list-windows -F '#{window_index}: #{window_name}' command lists windows with their index and name. fzf lets you pick one. The cut -d: -f1 command extracts just the window index (the part before the colon) from the selected line, and xargs tmux select-window -t uses that index to switch to the correct window.

This setup transforms session and window management from a chore into a seamless experience. You can now manage dozens of sessions and windows with just a few keystrokes and some fuzzy typing.

The next step is to integrate this with pane switching, or to use fzf to create new sessions and windows directly.

Want structured learning?

Take the full Tmux course →