Prezto on Debian and Debian derived systems
Debian and debian-derived distros such as Ubuntu have a bunch of site-wide functions and bindings defined on /etc/zshrc
which may cause some conflict with prezto.
At the very least, it makes zsh
startup somewhat slower.
I noticed that when migrating my environment from FreeBSD whose zsh
port has no site-level customization, i.e. /etc/zsh/*
are blank from the get-go, and came to revisit this when trying to resolve prezto's issue #1536 reported by @hiqua. So i realised i finally put it on writing, so here it is in case someone finds this info helpful
I usually remove most of what debian does, in its site-wide files, however not all of it is bloat.
they do add important variables in /etc/zsh/zshenv
which gets executed anyways.
If this is your distro of choice, you could add the following to your dotfiles, so you don't have to clear the /etc/zsh/*
files when moving your environment to another machine or upgrading your OS:
export DEBIAN_PREVENT_KEYBOARD_CHANGES
typeset skip_global_compinit
prezto does compinit
and adds more sensible mappings later on, so this avoids going through initializing the completion system twice.
# add zrecompile to whatever is already on the line:
# zstyle ':prezto:load' zfunctions (mine looks like this):
zstyle ':prezto:load' zfunctions zargs zmv zrecompile zsh-add-hook
# internally prezto uses zargs and zmv. check man zshcontrib
# for other useful stuff you can add here
# before "compile completion dump..."
fpath=($fpath[@] /usr/share/zsh/functions /usr/share/zsh/vendor-completions )
# vendor-completions adds native zsh completion for *ugh* systemd cli utilities (journalct, systemctl, etc)
# and functions adds native zsh completions for almost all standard Linux commands
# after zcompile:
# autoload -Uz zrecompile # this gets done by the zstyle on .zpreztorc, uncomment if you
# decided not to modify .zpreztorc so the function gets autoloaded here.
bashcompinit
zrecompile
seems counterintuitive, but zrecompile
does some sort of magic and makes the function and
completion caches way faster. Basically "compiles" all functions to bytecode,and writes them to the cache (.zwc
files wherever there is a functions
directory) but avoids loading them to memory, so they still behave like lazy-loading functions (they get loaded only the first time you use them, and stay in memory afterwards). Also, the cache is refreshed ONLY when something changes, so next time you log in, all that work is already don and startup is orders of magnitude faster, without compromising on feature availability.
Another more drastic alternative is to add:
unsetopt GLOBAL_RCS
This will effectively skip loading any /etc/zsh/*
files from that point on. However you might want to add the following to your .zshrc
:
# makes completion work when doing sudo:
zstyle ':completion:*:sudo:*' command-path /usr/local/sbin \
/usr/local/bin \
/usr/sbin \
/usr/bin \
/sbin \
/bin \
/usr/X11R6/bin