I'd like to create an alias that lets me browse all of my tmux windows with FZF and then attach that single window. What I have so far:

tmux list-windows -t main -F '#{session_name}:#{window_name}' | fzf | xargs "tmux attach -t"

# In FZF, I select a window named "main:mail".

This results in an error:

open terminal failed: not a terminal

When I add an echo, the outputted command looks fine though:

tmux list-windows -t main -F '#{session_name}:#{window_name}' | fzf | xargs echo tmux attach -t```

=> tmux attach -t main:mail

If I run tmux attach -t main:mail directly, it works fine.

Any idea what I'm doing wrong?

A simpler breakdown without fzf (that produces the same error) would be:

echo "main:mail" | xargs tmux attach -t

2 Answers 2


tmux needs stdin to be the terminal, but using a pipe will make stdin connect to the pipe output instead. Another possible solution for you is

tmux attach -t "$(tmux list-windows -t main -F '#{session_name}:#{window_name}' | fzf)"

The following is a workaround, but I'd appreciate knowing why the above didn't work and to have a better solutino:

run-shell tmux list-windows -t main -F "#{session_name}:#{window_name}" | fzf > /tmp/tmux-session && tmux attach -t $(cat /tmp/tmux-session)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .