[window] How to terminate a window in tmux?

How to terminate a window in tmux? Like the Ctrlak shortcut in screen with Ctrla being the prefix.

This question is related to window tmux

The answer is


By default
<Prefix> & for killing a window
<Prefix> x for killing a pane
And you can add config info

vi ~/.tmux.conf
bind-key X kill-session

then
<Prefix> X for killing a session


<Prefix> & for killing a window

<Prefix> x for killing a pane

If there is only one pane (i.e. the window is not split into multiple panes, <Prefix> x would kill the window)

As always iterated, <Prefix> is generally CTRL+b. (I think for beginner questions, we can just say CTRL+b all the time, and not talk about prefix at all, but anyway :) )


For me solution looks like:

  1. ctrl+b q to show pane numbers.
  2. ctrl+b x to kill pane.

Killing last pane will kill window.


Lot's of different ways to do this, but my favorite is simply typing 'exit' on the bash prompt.


try Prefix + &

if you have

bind q killp

in your .tmux.conf, you can press Prefix + q to kill the window too, only if there is only one panel in that window.

if you have multiple panes and want to kill the whole window at once use killw instead of killp in your config.

the default of Prefix above is Ctrl+b, so to terminate window by default you can use Ctrl+b &


ctrl + d kills a window in linux terminal, also works in tmux.

This is kind of a approach.


If you just want to do it once, without adding a shortcut, you can always type

<prefix> 
:
kill-window
<enter>

While you asked how to kill a window resp. pane, I often wouldn't want to kill it but simply to get it back to a working state (the layout of panes is of importance to me, killing a pane destroys it so I must recreate it); tmux provides the respawn commands to that effect: respawn-pane resp. respawn-window. Just that people like me may find this solution here.


Generally:

tmux kill-window -t window-number

So for example, if you are in window 1 and you want to kill window 9:

tmux kill-window -t 9