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: tmux new-window -d opens a window without switching to it

Tmux
~/tips/tip-tmux-new-window-background

tmux new-window -d -n sync 'rsync -a ~/photos/ /mnt/backup/photos/'

Starts a command in a new window while you stay where you are.

A plain new-window drags you to the new window right away. When I just want something to run on the side, -d leaves me where I am.

tmux new-window -d -n sync 'rsync -a ~/photos/ /mnt/backup/photos/'

The window gets the name sync and runs the command, but your screen doesn’t change. You’ll see the new name appear in the status bar. When the command ends the window closes, unless remain-on-exit is set.

It is handy in a key binding for something you check now and then:

bind H new-window -d -n top htop

From a shell outside tmux you can add -t with a session name to drop a window into a session nobody is looking at, which is a neat way to start background jobs in a known place.

If the command fails straight away, the window is gone before you ever see the error. Test the command in a normal shell first, or set remain-on-exit failed so a failing window stays open.

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