0

So I just created a bunch of panes in detached mode. Now I'd like to put a clock in the second pane (pane number 1).

here's my code:

tmux new-session -d -s ssh_tmux
tmux splitw -v -p 30 -t ssh_tmux:1.0
tmux splitw -h -p 60 -t ssh_tmux:1.1
#required; otherwise pane numbering is bs
tmux select-pane -t ssh_tmux:1.0
tmux splitw -h -p 30 -t ssh_tmux:1.0
tmux send-keys -t ssh_tmux:1.2 htop Enter
tmux send-keys -t ssh_tmux:1.1 'tmux clock' Enter
tmux a -t ssh_tmux

The problem is that, while 'tmux clock' is entered in the correct pane, the clock is actually displayed in the active pane. The only workaround I've been able to find is to set ssh_tmux:1.1 as the active pane, create the clock with send-keys, send a sleep of >0.1s (0.2 worked, 0.1 wasn't enough), and then set ssh_tmux:1.0 as the active pane.

That workaround kind of sucks. Surely there's something better?

2

The problem is that, while 'tmux clock' is entered in the correct pane, the clock is actually displayed in the active pane.

Yes, that's how it's supposed to work.

The full, unabbreviated name is tmux clock-mode. It isn't a standalone app and doesn't draw a clock like ttyclock would; it just connects to the tmux server and tells it to reconfigure a pane to display a clock. (And the tmux server has no idea which pane you ran it from, anyway.)

You can see that it is similar to other tmux subcommands (like tmux send-keys) in that regard.

That workaround kind of sucks. Surely there's something better?

Yes, similarly to other tmux subcommands, you can directly tell it which pane to configure by having your script run tmux clock -t ssh_tmux:1.1. It's documented as:

clock-mode [-t target-pane]
        Display a large clock.
  • Thanks. When I googled tmux clock stuff I kept being directed to cheatsheets and tutorials, not the man page. I should have realized that the man page would help with this once I started using it for all the other commands I made. I will try to be less dumb in the future. – jeremysprofile Jul 6 '18 at 21:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.