From 8d5c8c523121a417e89ad3e2ab42a2df078620a1 Mon Sep 17 00:00:00 2001 From: Simon Ruderich Date: Mon, 24 Nov 2008 00:55:31 +0100 Subject: [PATCH] Use add-zsh-hook for hook functions. This makes adding more hooks simpler. --- zsh/os/rc.Darwin | 5 ++++- zsh/rc | 3 +++ 2 files changed, 7 insertions(+), 1 deletion(-) 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 -- 2.44.1