summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc Cornellà <marc.cornella@live.com>2016-10-26 20:05:57 +0200
committerMarc Cornellà <marc.cornella@live.com>2018-04-22 12:55:13 +0200
commit405b8f220abe35eabc408566d7c4442a3a8149db (patch)
tree64e6d0848b289df1dddbee7c00fd34333600eace
parent8706c8eb64c7eb40fe1acda30404ebc24fdb7f73 (diff)
downloadzsh-405b8f220abe35eabc408566d7c4442a3a8149db.tar.gz
zsh-405b8f220abe35eabc408566d7c4442a3a8149db.tar.bz2
zsh-405b8f220abe35eabc408566d7c4442a3a8149db.zip
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`.
-rw-r--r--plugins/zsh_reload/zsh_reload.plugin.zsh3
1 files changed, 2 insertions, 1 deletions
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
}