projects
/
grml-etc-core.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
fd1f19f
)
zsh: help-zle caching
author
Bernhard Tittelbach
<bernhard@tittelbach.org>
Wed, 27 Jul 2011 00:51:37 +0000
(
02:51
+0200)
committer
Michael Prokop
<mika@grml.org>
Tue, 8 Nov 2011 15:34:57 +0000
(16:34 +0100)
etc/zsh/zshrc
patch
|
blob
|
history
diff --git
a/etc/zsh/zshrc
b/etc/zsh/zshrc
index
a520696
..
84578f9
100644
(file)
--- 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 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()
{
#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 )
#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
#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[@]}")
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
}
typeset -g help_zle_sln
typeset -g -a help_zle_lines