How to close panes in tmux?

Quick Answer

To close a tmux pane, press Ctrl+b followed by x. This will prompt for confirmation. Alternatively, you can type exit or press Ctrl+d in the pane you want to close.

Ctrl+b+x

Detailed Explanation

There are multiple ways to close panes in tmux, depending on your preference and whether you want to be prompted for confirmation. When the last pane in a window is closed, the window will also close. Similarly, when the last window in a session is closed, the session will end.

Using tmux commands:

  • Ctrl+b x - Kill the current pane with confirmation
  • Ctrl+b : then type kill-pane - Kill current pane without confirmation
  • Ctrl+b : then type kill-pane -t 2 - Kill pane number 2

Using shell commands within the pane:

  • exit - Type this command to close the current pane
  • Ctrl+d - Send EOF (end-of-file), which typically closes the shell and the pane

Closing multiple panes:

  • Ctrl+b ! - Break pane into a new window (removes it from current window)
  • Ctrl+b : then type kill-pane -a - Kill all panes except current one
  • Ctrl+b & - Kill the entire window (and all its panes) with confirmation

Respawn Pane

If you accidentally closed a pane, you can respawn it with: Ctrl+b : then type respawn-pane -k

Pro Tip: Skip Confirmation

To create a key binding that kills panes without confirmation, add this to your ~/.tmux.conf:

bind-key X kill-pane

Then you can use Ctrl+b X (capital X) to kill panes instantly.