How to close other windows in tmux?

Solution 1:

With the window you want to keep as the current window, just call next-window and kill-window repeatedly, until next-window fails:

while tmux next-window 2> /dev/null; do
    tmux kill-window
done

Solution 2:

For easy copying, tmux >= 1.7:

tabo()  { tmux kill-window -a; }

Thanks Chris Johnsen.