From b647fdba3884ae0466cbe4b14d72b49779ffb30b Mon Sep 17 00:00:00 2001 From: David Runge Date: Thu, 8 Feb 2018 13:06:58 +0100 Subject: .zshrc: Fix usage of zsh extensions on other systems or when those extensions are not around. --- .zshrc | 43 ++++++++++++++++++++++++++++++------------- 1 file changed, 30 insertions(+), 13 deletions(-) diff --git a/.zshrc b/.zshrc index 4d500ec..b03cacb 100644 --- a/.zshrc +++ b/.zshrc @@ -391,20 +391,37 @@ zstyle ':completion:*:(ssh|scp|rsync):*:hosts-ipaddr' ignored-patterns '^(<->.<- # syntax-highlighting -source /usr/share/zsh/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh - -# history-substring-search -source /usr/share/zsh/plugins/zsh-history-substring-search/zsh-history-substring-search.zsh -# Vi -bindkey -M vicmd "k" history-substring-search-up -bindkey -M vicmd "j" history-substring-search-down - -# Emacs and Vi -for keymap in 'viins'; do - bindkey -M "$keymap" "$key_info[Up]" history-substring-search-up - bindkey -M "$keymap" "$key_info[Down]" history-substring-search-down -done +if [ -f /usr/share/zsh/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh ]; then + source /usr/share/zsh/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh +elif [ -f /usr/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh ]; then + source /usr/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh +fi +if [ -f /usr/share/zsh/plugins/zsh-history-substring-search/zsh-history-substring-search.zsh ]; then + # history-substring-search + source /usr/share/zsh/plugins/zsh-history-substring-search/zsh-history-substring-search.zsh + # Vi + bindkey -M vicmd "k" history-substring-search-up + bindkey -M vicmd "j" history-substring-search-down + + # Emacs and Vi + for keymap in 'viins'; do + bindkey -M "$keymap" "$key_info[Up]" history-substring-search-up + bindkey -M "$keymap" "$key_info[Down]" history-substring-search-down + done +elif [ -f /usr/share/zsh-history-substring-search/zsh-history-substring-search.zsh ]; then + # history-substring-search + source /usr/share/zsh-history-substring-search/zsh-history-substring-search.zsh + # Vi + bindkey -M vicmd "k" history-substring-search-up + bindkey -M vicmd "j" history-substring-search-down + + # Emacs and Vi + for keymap in 'viins'; do + bindkey -M "$keymap" "$key_info[Up]" history-substring-search-up + bindkey -M "$keymap" "$key_info[Down]" history-substring-search-down + done +fi # zsh.after # -- cgit v1.2.3-70-g09d2