X-Git-Url: http://git.grml.org/?a=blobdiff_plain;f=etc%2Fzsh%2Fzshrc;h=84578f994af468c67d4c2a7e6883f36adab3c79d;hb=e325343ac8a1d1d347208974a05ec2aa20c085d4;hp=a520696f0d8c9355016309a2528ffb1818163baf;hpb=fd1f19fe10cbffe5c343eb9d865beba4ac573faf;p=grml-etc-core.git diff --git a/etc/zsh/zshrc b/etc/zsh/zshrc index a520696..84578f9 100644 --- a/etc/zsh/zshrc +++ b/etc/zsh/zshrc @@ -2109,6 +2109,8 @@ alias help-zshglob=H-Glob #v1# set number of lines to display per page HELP_LINES_PER_PAGE=20 +#v1# set location of help-zle cache file +HELP_ZLE_CACHE_FILE=~/.cache/zsh_help_zle_lines.zsh #f1# helper function for help-zle, actually generates the help text help_zle_parse_keybindings() { @@ -2119,6 +2121,12 @@ help_zle_parse_keybindings() #v1# choose files that help-zle will parse for keybindings ((${+HELPZLE_KEYBINDING_FILES})) || HELPZLE_KEYBINDING_FILES=( /etc/zsh/zshrc ~/.zshrc.pre ~/.zshrc ~/.zshrc.local ) + if [[ -r $HELP_ZLE_CACHE_FILE ]]; then + local load_cache=0 + for f ($KEYBINDING_FILES) [[ $f -nt $HELP_ZLE_CACHE_FILE ]] && load_cache=1 + [[ $load_cache -eq 0 ]] && . $HELP_ZLE_CACHE_FILE && return + fi + #fill with default keybindings, possibly to be overwriten in a file later #Note that due to zsh inconsistency on escaping assoc array keys, we encase the key in '' which we will remove later local -A help_zle_keybindings @@ -2197,6 +2205,9 @@ help_zle_parse_keybindings() done #sort lines alphabetically help_zle_lines=("${(i)help_zle_lines[@]}") + [[ -d ${HELP_ZLE_CACHE_FILE:h} ]] || mkdir -p "${HELP_ZLE_CACHE_FILE:h}" + echo "help_zle_lines=(${(q)help_zle_lines[@]})" >| $HELP_ZLE_CACHE_FILE + zcompile $HELP_ZLE_CACHE_FILE } typeset -g help_zle_sln typeset -g -a help_zle_lines