40c47a737571468b759bbc30e4b4dc4b5f77470f

Author
Christian Höltje <docwhat@gerf.org>
Committer
Christian Höltje <docwhat@gerf.org>
Date

Message

lib/termsupport now uses add-zsh-hook

This is needed to play nice with plugins that need various hooks.

Diff

 1diff --git a/lib/termsupport.zsh b/lib/termsupport.zsh
 2index 22e7f372fffdb1da78ffd3852130340a5d9aa448..221989502360e4182d14489765578b5ee9ff5491 100644
 3--- a/lib/termsupport.zsh
 4+++ b/lib/termsupport.zsh
 5@@ -4,7 +4,7 @@
 6 #Limited support for Apple Terminal (Terminal can't set window or tab separately)
 7 function title {
 8   [ "$DISABLE_AUTO_TITLE" != "true" ] || return
 9-  if [[ "$TERM" == screen* ]]; then 
10+  if [[ "$TERM" == screen* ]]; then
11     print -Pn "\ek$1:q\e\\" #set screen hardstatus, usually truncated at 20 chars
12   elif [[ "$TERM" == xterm* ]] || [[ $TERM == rxvt* ]] || [[ "$TERM_PROGRAM" == "iTerm.app" ]]; then
13     print -Pn "\e]2;$2:q\a" #set window name
14@@ -16,14 +16,18 @@ ZSH_THEME_TERM_TAB_TITLE_IDLE="%15<..<%~%<<" #15 char left truncated PWD
15 ZSH_THEME_TERM_TITLE_IDLE="%n@%m: %~"
16 
17 #Appears when you have the prompt
18-function precmd {
19+function omz_termsupport_precmd {
20   title $ZSH_THEME_TERM_TAB_TITLE_IDLE $ZSH_THEME_TERM_TITLE_IDLE
21 }
22 
23 #Appears at the beginning of (and during) of command execution
24-function preexec {
25+function omz_termsupport_preexec {
26   emulate -L zsh
27   setopt extended_glob
28   local CMD=${1[(wr)^(*=*|sudo|ssh|-*)]} #cmd name only, or if this is sudo or ssh, the next cmd
29   title "$CMD" "%100>...>$2%<<"
30 }
31+
32+autoload -U add-zsh-hook
33+add-zsh-hook precmd  omz_termsupport_precmd
34+add-zsh-hook preexec omz_termsupport_preexec