diff options
Diffstat (limited to 'Doc/Zsh/func.yo')
-rw-r--r-- | Doc/Zsh/func.yo | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/Doc/Zsh/func.yo b/Doc/Zsh/func.yo index 7c391f80d..6e9cfeee9 100644 --- a/Doc/Zsh/func.yo +++ b/Doc/Zsh/func.yo @@ -264,9 +264,16 @@ Executed when a history line has been read interactively, but before it is executed. The sole argument is the complete history line (so that any terminating newline will still be present). -If any of the hook functions return a non-zero value the history -line will not be saved, although it lingers in the history until the -next line is executed allow you to reuse or edit it immediately. +If any of the hook functions returns status 1 (or any non-zero value +other than 2, though this is not guaranteed for future versions of the +shell) the history line will not be saved, although it lingers in the +history until the next line is executed, allowing you to reuse or edit +it immediately. + +If any of the hook functions returns status 2 the history line +will be saved on the internal history list, but not written to +the history file. In case of a conflict, the first non-zero status +value is taken. A hook function may call `tt(fc -p) var(...)' to switch the history context so that the history is saved in a different file from the @@ -274,10 +281,13 @@ that in the global tt(HISTFILE) parameter. This is handled specially: the history context is automatically restored after the processing of the history line is finished. -The following example function first adds the history line to the normal -history with the newline stripped, which is usually the correct behaviour. -Then it switches the history context so that the line will -be written to a history file in the current directory. +The following example function works with one of the options +tt(INC_APPEND_HISTORY) or tt(SHARE_HISTORY) set, in order that the line +is written out immediately after the history entry is added. It first +adds the history line to the normal history with the newline stripped, +which is usually the correct behaviour. Then it switches the history +context so that the line will be written to a history file in the +current directory. example(zshaddhistory+LPAR()RPAR() { print -sr -- ${1%%$'\n'} |