Browse Source

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`.
Marc Cornellà 8 years ago
parent
commit
405b8f220a
1 changed files with 2 additions and 1 deletions
  1. 2 1
      plugins/zsh_reload/zsh_reload.plugin.zsh

+ 2 - 1
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
 }