• Marc Cornellà's avatar
    zsh_reload: use `exec zsh` instead of `source ~/.zshrc` · 405b8f22
    Marc Cornellà authored
    `source ~/.zshrc` is a bad practice, it doesn't make sure that the full
    zsh session is reloaded and it may have side effects.
    
    Use `$SHELL` as the path to zsh if it exists (this will fix edge cases
    where the zsh used is not the first on $PATH). Otherwise, use `zsh`.
    405b8f22
zsh_reload.plugin.zsh 322 Bytes
src() {
	local cache="$ZSH_CACHE_DIR"
	autoload -U compinit zrecompile
	compinit -i -d "$cache/zcomp-$HOST"

	for f in ~/.zshrc "$cache/zcomp-$HOST"; do
		zrecompile -p $f && command rm -f $f.zwc.old
	done

	# Use $SHELL if available; remove leading dash if login shell
	[[ -n "$SHELL" ]] && exec ${SHELL#-} || exec zsh
}