auto run command when selecting window

24 views
Skip to first unread message

cyphr3x

unread,
Jul 16, 2020, 1:28:35 PM7/16/20
to tmux-users
Hello,
  When selecting a tmux window is there a way to auto run a command?

(not creating, selecting)

Scott Rochford

unread,
Jul 16, 2020, 6:21:01 PM7/16/20
to cyphr3x, tmux-users
Hi Cyphr3x,

I haven't tried it myself, but usually you use hooks to run commands based on events.  Some of those are listed in the HOOKS section of the man page, however that states "All the notifications listed in the CONTROL MODE section are hooks...".  One of those is "window-pane-changed", so I suspect that is the one you need.

Regards,

Scott

--
You received this message because you are subscribed to the Google Groups "tmux-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tmux-users+...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/tmux-users/ccdb2077-b285-48e7-a5ed-f501fbed3055o%40googlegroups.com.

cyphr3x

unread,
Jul 16, 2020, 7:37:32 PM7/16/20
to tmux-users
This is perfect, thank you!

I ended up doing this to fix my issue:

tmux set-hook -g client-resized 'select-window -t 9 ; resize-pane -y 6 -t 1 ; last-window'

This resets my top pane in window 9 which was having issues when I would switch to a smaller overall ssh window.


On Thursday, July 16, 2020 at 3:21:01 PM UTC-7, Scott Rochford wrote:
Hi Cyphr3x,

I haven't tried it myself, but usually you use hooks to run commands based on events.  Some of those are listed in the HOOKS section of the man page, however that states "All the notifications listed in the CONTROL MODE section are hooks...".  One of those is "window-pane-changed", so I suspect that is the one you need.

Regards,

Scott

On Fri, 17 Jul 2020 at 03:28, cyphr3x <tgw...@gmail.com> wrote:
Hello,
  When selecting a tmux window is there a way to auto run a command?

(not creating, selecting)

--
You received this message because you are subscribed to the Google Groups "tmux-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tmux-...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages