0

I want to write a hook in tmux to show a message that reports the config has been reloaded. Here is my code:

#binding a button to reload this config file
bind r source-file ~/.tmux.conf

#set hook to notify user when config file has been reloaded
set-hook -g after-source-file 'display-message "Config reloaded"'

I know that the hook does run because originally I wrote "echo 'Config reloaded'" and an error came up in the status bar about it being an unknown command.

Also I have included an example hook from here:

set-hook -g client-attached 'display-message "hello world"'

Which displays the message on client attachment no problem, so I am confused why the source-file hook is an exception

1

source-file does not have an after hook. I don't know why it worked for you with a different command, which tmux version are you using?

You could just do this instead: bind r source-file ~/.tmux.conf \; display-message "Config reloaded".

  • tmux version 2.9a, your solution worked fine though - I am not sure I understand why it works because it looks like you feed the interpreter two separate sequential commands and it somehow knows to store them together and execute both when the first line is called - but understanding the interpreter is waay beyond the scope of my question anyway – Scott Anderson Jun 6 at 21:18
  • It is a command sequence, look at the COMMANDS section in the tmux manual. – Nicholas Marriott Jun 7 at 8:42

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.