From: Simon Ruderich Date: Sun, 23 Nov 2008 23:55:31 +0000 (+0100) Subject: Use add-zsh-hook for hook functions. X-Git-Url: https://ruderich.org/simon/gitweb/?a=commitdiff_plain;h=8d5c8c523121a417e89ad3e2ab42a2df078620a1;p=config%2Fdotfiles.git Use add-zsh-hook for hook functions. This makes adding more hooks simpler. --- diff --git a/zsh/os/rc.Darwin b/zsh/os/rc.Darwin index 0922f1f..a910c7b 100644 --- a/zsh/os/rc.Darwin +++ b/zsh/os/rc.Darwin @@ -3,9 +3,12 @@ # Store the current clipboard in CLIPBOARD before every command so it can be # used in commands. -preexec () { +os_darwin_preexec() { export CLIPBOARD="$(pbpaste)" } +# Add the function as preexec hook. +add-zsh-hook preexec os_darwin_preexec + # Initialize CLIPBOARD so it's available for completion directly after # startup. CLIPBOARD="" diff --git a/zsh/rc b/zsh/rc index fb37a6a..9c0fc35 100644 --- a/zsh/rc +++ b/zsh/rc @@ -84,6 +84,9 @@ setopt extendedglob # Don't exit if is pressed. setopt ignoreeof +# Autoload add-zsh-hook to add/remove zsh hook functions easily. +autoload -Uz add-zsh-hook + # If ^C is pressed while typing a command, add it to the history so it can be # easily retrieved later and then abort like ^C normally does. This is useful # when I want to abort an command to do something in between and then finish