405b8f220abe35eabc408566d7c4442a3a8149db

Author
Marc Cornellà <marc.cornella@live.com>
Committer
Marc Cornellà <marc.cornella@live.com>
Date

Message

zsh_reload: use `exec zsh` instead of `source ~/.zshrc`

`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`.

Diff

 1diff --git a/plugins/zsh_reload/zsh_reload.plugin.zsh b/plugins/zsh_reload/zsh_reload.plugin.zsh
 2index b3a0094d1d3735c3969c01c1621b7663453fccaa..51048ba9d09e0ba26a14963c12af9cab84266f1f 100644
 3--- a/plugins/zsh_reload/zsh_reload.plugin.zsh
 4+++ b/plugins/zsh_reload/zsh_reload.plugin.zsh
 5@@ -7,5 +7,6 @@ src() {
 6 		zrecompile -p $f && command rm -f $f.zwc.old
 7 	done
 8 
 9-	source ~/.zshrc
10+	# Use $SHELL if available; remove leading dash if login shell
11+	[[ -n "$SHELL" ]] && exec ${SHELL#-} || exec zsh
12 }