#autoload _my_zrecompile () { _func_dir="${fpath[(r)*share/zsh*/functions*]/functions\/*/functions}" echo "Found site-wide functions at $_func_dir" if [[ -d "$_func_dir/Completion" ]]; then echo "This version was compiled with --enable-function-subdirs" _compinit_dir=( $_func_dir/**/compinit ) _compinit_dir=${${_compinit_dir[1]}%/compinit} _Completions_glob=( $_func_dir/Completion/**/_*(.N) ) _Prompts_glob=( $_func_dir/Prompts/prompt*(.) ) _site_funcs=( "$_Completions_glob[@]" "$_Prompts_glob[@]" ) else echo "This version was not compiled with --enable-function-subdirs" _compinit_dir="$_func_dir" _site_funcs=( $_func_dir/*~*.zwc*(.) ) fi # For some reason this always ends up 444. # 2009-06-27 Sat 15:51:36 BST always? commenting to see what happens #chmod u+w ~/.zsh/functions.zwc* # -p means sets of arguments in between -- get passed to # zcompile. See comments at top of the zrecompile source file # in /usr/share/zsh/$ZSH_VERSION/zrecompile for examples. # -R copies .zwc into shell process memory # -M mmaps the .zwc # -U suppresses alias expansion during reading of function # -z autoloads function as if KSH_AUTOLOAD unset. # -k autoloads function as if KSH_AUTOLOAD set. # Without -k or -z, takes value of KSH_AUTOLOAD when compiled # file is read. # Use -R for scripts, -M for autoloads # Info says -U and -z to be used for system functions. if [[ -w $_compinit_dir ]]; then _compinits=( -R $_compinit_dir/compinit -- -R $_compinit_dir/compaudit -- -R $_compinit_dir/compdump -- ) else _compinits=() fi # deal with shared $HOME zwcdir=~/.zsh/$ZSH_VERSION [ -d "$zwcdir" ] || mkdir -p "$zwcdir" rm -f ~/.zsh/*.zwc(N) # clean up old versions zrecompile "$@" -p -- \ -R ~/.zshenv -- \ -R ~/.zshrc -- \ "$_compinits[@]" \ -M -U $zwcdir/my-functions.zwc ~/.zsh/functions/*(-*) -- \ -M -U $zwcdir/site-functions.zwc "$_site_funcs[@]" -- \ -R ~/.zcompdump } zrec () { if [ -n "$OTHER_USER" ]; then echo "zrec invoked when OTHER_USER; skipping" >&2 return 1 fi rm -f ~/.zsh/functions.zwc # in case old versions are still around # Some really weird shit happens when you remove an entry from the # _comps array - it persists unless you really try to get rid of # it. Haven't figured out exactly how it refuses to die yet. rm -f ~/.zcompdump* compinit _my_zrecompile # This should be safe now. if [[ "$-" == *i* ]]; then restart fi } zrec "$@"