Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I write some functions in .bashrc to make tmux easy to use:

#!/bin/bash
# .bashrc

# vim            tmux
#-----  --------------------
tabc()  { tmux kill-window; }
tabe()  { tmux new-window; }
tabf()  { tmux find-window $@; }
tabn()  { tmux next-window; }
tabo()  { ; }                         # <-- How to `tabonly`?
tabp()  { tmux previous-window; }
qa()    { tmux kill-session; }
sp()    { tmux split-window; }
vsp()   { tmux split-window -h; }
on()    { tmux kill-pane -a; }

typeset -fx tab{c,e,f,n,o,p} {,v}sp qa on

I want to implement the tabonly command, but don't know how.

share|improve this question
add comment

2 Answers

up vote 3 down vote accepted

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
share|improve this answer
    
This command works great! Thanks. –  kev May 28 '12 at 4:33
4  
The next release of tmux (i.e. 1.7) will have kill-window -a to kill all windows except the current window. –  Chris Johnsen May 28 '12 at 7:57
add comment

For easy copying, tmux >= 1.7:

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

Thanks Chris Johnsen.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.