From 405b8f220abe35eabc408566d7c4442a3a8149db Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Marc=20Cornell=C3=A0?= <marc.cornella@live.com>
Date: Wed, 26 Oct 2016 20:05:57 +0200
Subject: [PATCH] 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`.
---
 plugins/zsh_reload/zsh_reload.plugin.zsh | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

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