This makes adding more hooks simpler.
# 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=""
# Don't exit if <C-d> 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