Merge hooks into options and make each one an array option. This allows

multiple commands to be easily bound to one hook. set-hook and
show-hooks remain but they are now variants of set-option and
show-options. show-options now has a -H flag to show hooks (by default
they are not shown).
This commit is contained in:
nicm
2019-04-26 11:38:51 +00:00
parent f1e14f86c4
commit dfb7bb6830
20 changed files with 356 additions and 414 deletions

30
tmux.1
View File

@ -3383,7 +3383,7 @@ function key sequences; these have a number included to indicate modifiers such
as Shift, Alt or Ctrl.
.El
.It Xo Ic show-options
.Op Fl gqsvw
.Op Fl gHqsvw
.Op Fl t Ar target-session | Ar target-window
.Op Ar option
.Xc
@ -3415,6 +3415,8 @@ If
is set, no error will be returned if
.Ar option
is unset.
.Fl H
includes hooks (omitted by default).
.It Xo Ic show-window-options
.Op Fl gv
.Op Fl t Ar target-window
@ -3439,6 +3441,26 @@ commands have an
.Em after
hook and there are a number of hooks not associated with commands.
.Pp
Hooks are stored as array options, members of the array are executed in
order when the hook is triggered.
Hooks may be configured with the
.Ic set-hook
or
.Ic set-option
commands and displayed with
.Ic show-hooks
or
.Ic show-options
.Fl H .
The following two commands are equivalent:
.Bd -literal -offset indent.
set-hook -g pane-mode-changed[42] 'set -g status-left-style bg=red'
set-option -g pane-mode-changed[42] 'set -g status-left-style bg=red'
.Ed
.Pp
Setting a hook without specifying an array index clears the hook and sets the
first member of the array.
.Pp
A command's after
hook is run after it completes, except when the command is run as part of a hook
itself.
@ -3449,7 +3471,7 @@ For example, the following command adds a hook to select the even-vertical
layout after every
.Ic split-window :
.Bd -literal -offset indent
set-hook after-split-window "selectl even-vertical"
set-hook -g after-split-window "selectl even-vertical"
.Ed
.Pp
All the notifications listed in the
@ -3513,7 +3535,7 @@ Run when a window is unlinked from a session.
Hooks are managed with these commands:
.Bl -tag -width Ds
.It Xo Ic set-hook
.Op Fl gRu
.Op Fl agRu
.Op Fl t Ar target-session
.Ar hook-name
.Ar command
@ -3535,6 +3557,8 @@ hooks (for
.Ar target-session
with
.Fl t ) .
.Fl a
appends to a hook.
Like options, session hooks inherit from the global ones.
.Pp
With