@@ -111,7 +111,7 @@ intended as a workaround for [tmux/tmux#3991], which has been fixed in
111111[ tmux/tmux#3991 ] : https://github.com/tmux/tmux/issues/3991
112112[ tmux/tmux@a869693 ] : https://github.com/tmux/tmux/commit/a869693405f99c8ca8e2da32a08534489ce165f2
113113
114- > [ !NOTE ]
114+ > [ !Note ]
115115>
116116> The fix has been included in tmux v3.6, so this command is no longer
117117> necessary.
@@ -216,38 +216,29 @@ affect subsequent calls.
216216
217217## 🪝 Hooks
218218
219- A hook is used to run tmux commands on certain events. Each hook is preprocessed
220- by * xargs(1)* , which splits it into a token stream. The token stream is
221- collected and passed to tmux when the corresponding event fires. When writing
222- hooks, keep the following rules in mind:
223-
224- 1 . Two commands must be delimited by a semicolon (` ; ` ).
225- 2 . Line breaks are replaced with spaces, therefore, as rule * (1)* states,
226- remember to put a semicolon after each command.
227- 3 . Tokens can be protected by quotes (either ` ' ` or ` " ` ) from being split.
228- 4 . Any character preceded by a backslash (` \ ` ) is treated as a literal escape.
229- For instance, ` \n ` is interpreted as ` n ` rather than a line break.
230- 5 . For commands that take a command sequence as an argument, each command in
231- that sequence must be delimited by ` \; ` , just as you would do in
232- * .tmux.conf* . You can use either ` \\; ` or ` '\;' ` to input a ` \; ` .
233- Additionally, you may also put the entire sequence in a pair of quotes, as
234- the following example shows.
235-
236- To disable a hook, you should set it to ` nop ` instead of an empty string.
219+ A hook is used to run tmux commands on certain events. Each hook is sent to tmux
220+ using ` run-shell -C <hook> ` . Here are some general tips for writing hooks:
221+
222+ 1 . Separate two commands with a semicolon (` ; ` ).
223+ 2 . For commands that accept a command sequence as an argument, like ` bind-key ` ,
224+ separate each command in the sequence with ` \; ` .
225+ 3 . To disable a hook, set it to ` nop ` or an empty string.
237226
238227** Example** :
239228
240229``` tmux
241- # Hide the statusline and setup additional key bindings
242- set -g @popup-on-init ' set status off'
243- # In single quotes, no escape sequence will be recognized.
244- set -ga @popup-on-init '
245- ; bind -n M-1 confirm -p"inside a popup?" "run true" \\; display -d3000 "of course!"
230+ # tmux transforms everything inside braces into a single string that it can
231+ # parse. This string is then sent to tmux through `run-shell -C` right after we
232+ # we enter the popup session.
233+ set -g @popup-on-init {
234+ set status off
235+ bind -n M-t confirm -p " inside a popup?" " run true" \; display -d3000 " of course!"
236+ }
237+ # Outside tmux.conf, we need to manually escape and separate each command.
238+ set -g @popup-on-init '
239+ set status off;
240+ bind -n M-t confirm -p "inside a popup?" "run true" \; display -d3000 "of course!";
246241'
247- # While in double quotes, escape sequences work as usual.
248- set -ga @popup-on-init "
249- ; bind -n M-2 \" confirm -p'inside a popup?' 'run true' ; display -d3000 'of course!'\"
250- "
251242```
252243
253244### ` @popup-on-init `
@@ -331,7 +322,7 @@ if -F "#{!:#{@popup_did_init}}" {
331322}
332323` ` `
333324
334- > [! NOTE ]
325+ > [! Note ]
335326>
336327> Whenever you need to interact with the popup session, do it through the
337328> ` on-init` hook rather than ` #{@popup-toggle} some_script.sh` . This is because,
0 commit comments