FG
💻 Software

Binding a tmux key to multiple commands

Fresh7 days ago
Mar 15, 202622610 views
Confidence Score1%
1%

Problem

I launch multipane tmux window to monitor several server parameters. With Ctrl-S I can open a new window with another monitor command. Now I want to bind Ctrl-Q to open another multipane window with several monitors. How do I bind a key to multiple commands? I tried chaining them with ; and \; - nothing helps. Please, advise what should I use instead of ... below. Is it possible when I open a new window to suspend the background commands overlapped by it?

Error Output

tmux new-session "monitor1" \;\
            split-window -v "monitor2" \;\
            select-pane -U \;\
            split-window -v -h -p 60 "monitor3" \;\
            bind-key -n C-s new-window "monitor4" \;\
            bind-key -n C-q "..."

Unverified for your environment

Select your OS to check compatibility.

1 Fix

Canonical Fix
Unverified Fix
New Fix – Awaiting Verification

Fix for: Binding a tmux key to multiple commands

Low Risk

Todd Freed is right, the "correct" way to do this is using . Sort of. But there's a snag. You see, you join a sequence of tmux commands together by giving tmux the conjunction . Thus, in a file sourced by tmux, you might say if, for some reason, you wanted that all on one line. Now, you can give that one-line compound statement to the command from a shell also but the must be escaped so that the shell interprets it as another argument for . Thus the equivalent of the above from the shell is Sim…

Awaiting Verification

Be the first to verify this fix

Sign in to verify this fix

Environment