about summary refs log tree commit diff
path: root/Doc/Zsh/func.yo
diff options
context:
space:
mode:
authorPeter Stephenson <pws@users.sourceforge.net>2008-07-17 11:27:55 +0000
committerPeter Stephenson <pws@users.sourceforge.net>2008-07-17 11:27:55 +0000
commit0409391c7d08016de3f1ea8b1a74d5856669ffaa (patch)
tree08c73dd57ba775e380384f3b408cfda4446c1861 /Doc/Zsh/func.yo
parent4f7cf022b6963985a75c5a00ef59c7168551b225 (diff)
downloadzsh-0409391c7d08016de3f1ea8b1a74d5856669ffaa.tar.gz
zsh-0409391c7d08016de3f1ea8b1a74d5856669ffaa.tar.xz
zsh-0409391c7d08016de3f1ea8b1a74d5856669ffaa.zip
25272: add zshaddhistory hook
Diffstat (limited to 'Doc/Zsh/func.yo')
-rw-r--r--Doc/Zsh/func.yo28
1 files changed, 28 insertions, 0 deletions
diff --git a/Doc/Zsh/func.yo b/Doc/Zsh/func.yo
index 65bcd9abc..0d215dde3 100644
--- a/Doc/Zsh/func.yo
+++ b/Doc/Zsh/func.yo
@@ -241,6 +241,34 @@ size-limited version of the command (with things like function bodies
 elided); the third argument contains the full text that is being
 executed.
 )
+findex(zshaddhistory)
+vindex(zshaddhistory_functions)
+item(tt(zshaddhistory))(
+cindex(history, hook when line is saved)
+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.
+
+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
+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.
+
+example(zshaddhistory() {
+  print -sr -- ${1%%$'\n'}
+  fc -p .zsh_local_history
+})
+)
 findex(zshexit)
 vindex(zshexit_functions)
 item(tt(zshexit))(