From 9a7c56dcddfd007499bc59560c1de282611f6813 Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Wed, 26 Oct 2016 20:04:14 +0200 Subject: zsh_reload: fix code style and indent with tabs --- plugins/zsh_reload/zsh_reload.plugin.zsh | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) (limited to 'plugins/zsh_reload/zsh_reload.plugin.zsh') diff --git a/plugins/zsh_reload/zsh_reload.plugin.zsh b/plugins/zsh_reload/zsh_reload.plugin.zsh index cde9ebeca..e3aed5d7a 100644 --- a/plugins/zsh_reload/zsh_reload.plugin.zsh +++ b/plugins/zsh_reload/zsh_reload.plugin.zsh @@ -1,13 +1,11 @@ -# reload zshrc -function src() -{ - local cache=$ZSH_CACHE_DIR - autoload -U compinit zrecompile - compinit -d "$cache/zcomp-$HOST" +src() { + local cache="$ZSH_CACHE_DIR" + autoload -U compinit zrecompile + compinit -d "$cache/zcomp-$HOST" - for f in ~/.zshrc "$cache/zcomp-$HOST"; do - zrecompile -p $f && command rm -f $f.zwc.old - done + for f in ~/.zshrc "$cache/zcomp-$HOST"; do + zrecompile -p $f && command rm -f $f.zwc.old + done - source ~/.zshrc + source ~/.zshrc } -- cgit v1.2.3-70-g09d2 From 8706c8eb64c7eb40fe1acda30404ebc24fdb7f73 Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Wed, 26 Oct 2016 20:09:08 +0200 Subject: zsh_reload: ignore insecure compinit files --- plugins/zsh_reload/zsh_reload.plugin.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'plugins/zsh_reload/zsh_reload.plugin.zsh') diff --git a/plugins/zsh_reload/zsh_reload.plugin.zsh b/plugins/zsh_reload/zsh_reload.plugin.zsh index e3aed5d7a..b3a0094d1 100644 --- a/plugins/zsh_reload/zsh_reload.plugin.zsh +++ b/plugins/zsh_reload/zsh_reload.plugin.zsh @@ -1,7 +1,7 @@ src() { local cache="$ZSH_CACHE_DIR" autoload -U compinit zrecompile - compinit -d "$cache/zcomp-$HOST" + compinit -i -d "$cache/zcomp-$HOST" for f in ~/.zshrc "$cache/zcomp-$HOST"; do zrecompile -p $f && command rm -f $f.zwc.old -- cgit v1.2.3-70-g09d2 From 405b8f220abe35eabc408566d7c4442a3a8149db Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Wed, 26 Oct 2016 20:05:57 +0200 Subject: 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(-) (limited to 'plugins/zsh_reload/zsh_reload.plugin.zsh') 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 } -- cgit v1.2.3-70-g09d2