brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: set -g remain-on-exit failed keeps a crashed tmux pane open

Tmux
~/tips/tip-tmux-remain-on-exit

set -g remain-on-exit failed

Lets you read the error when a pane's command fails.

Start a pane with a command, like tmux split-window 'make test', and the pane disappears the moment the command ends. If it failed, the error leaves with it.

The remain-on-exit option keeps the dead pane on screen. My favourite value only does that when something went wrong:

set -g remain-on-exit failed

A command that exits with status 0 closes its pane as usual. One that fails leaves the pane in place, with the output still readable and a line at the bottom saying which status it exited with. Use on instead of failed if you want to keep every pane.

From there you have two options. Ctrl-b x closes the dead pane, or you run the command again in the same spot:

tmux respawn-pane

The failed value needs tmux 3.2 or later. Newer versions also have key and failed-key, which close the pane on the next keypress, and remain-on-exit-format to change the text on that last line.

Dead panes pile up quietly if you use on for everything, so I’d keep that value for windows where you really want to read every result.

Further reading: tmux manual page (OpenBSD)

More Tmux tips tmux new -d -s report -x 200 -y 50 'top' tmux wait-for build-done set -g allow-passthrough on tmux kill-server Ctrl-b [ All Tmux tips (125) All topics

Link