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 send-keys types into a pane you are not looking at

Tmux
~/tips/tip-tmux-send-keys

tmux send-keys -t work:1.0 'docker compose logs -f' Enter

Sends a command to a chosen tmux pane from the shell, as if you had typed it there.

Scripts and shortcuts can drive a tmux pane too.

tmux send-keys -t work:1.0 'docker compose logs -f' Enter

-t work:1.0 means session work, window 1, pane 0. The final Enter is a key name, so the command actually runs.

Every tmux script builds on this. send-keys runs no command by itself. It types keys into a pane, so the pane has to be at a prompt that can accept them. Key names such as Enter, C-c and Up are written as words, and plain text goes in quotes.

You can also use it by hand. For example, restart a service in a pane where docker compose logs is running by sending C-c first and then the new command. I would keep it for small helper scripts, since a script that depends on the exact state of a pane is fragile.

tmux does not check what the pane is doing. If an editor has focus there, your text lands in the editor.

Try it without risk: start a throwaway session with tmux new -s scratch, use the shortcut or command above there, look at what changes, and close the session again with tmux kill-session -t scratch. Nothing else on your machine is touched.

Further reading: tmux manual page (OpenBSD, official), tmux wiki: Getting Started (official), On this site: Ctrl-b Alt-arrow resizes a tmux pane five cells at a time, On this site: setw synchronize-panes on types into every pane at once

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