diff --git a/internal/shell/zsh.go b/internal/shell/zsh.go index b3189978..c0e94650 100644 --- a/internal/shell/zsh.go +++ b/internal/shell/zsh.go @@ -25,25 +25,27 @@ type zsh struct{} var Zsh = zsh{} const zshHook = ` -{{.EnvContent}} +if [[ -z "$__VFOX_PID" ]]; then + {{.EnvContent}} -export __VFOX_PID=$$; + export __VFOX_PID=$$; -_vfox_hook() { - trap -- '' SIGINT; - eval "$("{{.SelfPath}}" env -s zsh)"; - trap - SIGINT; -} -typeset -ag precmd_functions; -if [[ -z "${precmd_functions[(r)_vfox_hook]+1}" ]]; then - precmd_functions=( _vfox_hook ${precmd_functions[@]} ) -fi -typeset -ag chpwd_functions; -if [[ -z "${chpwd_functions[(r)_vfox_hook]+1}" ]]; then - chpwd_functions=( _vfox_hook ${chpwd_functions[@]} ) -fi + _vfox_hook() { + trap -- '' SIGINT; + eval "$("{{.SelfPath}}" env -s zsh)"; + trap - SIGINT; + } + typeset -ag precmd_functions; + if [[ -z "${precmd_functions[(r)_vfox_hook]+1}" ]]; then + precmd_functions=( _vfox_hook ${precmd_functions[@]} ) + fi + typeset -ag chpwd_functions; + if [[ -z "${chpwd_functions[(r)_vfox_hook]+1}" ]]; then + chpwd_functions=( _vfox_hook ${chpwd_functions[@]} ) + fi -trap 'vfox env --cleanup' EXIT + trap 'vfox env --cleanup' EXIT +fi ` func (z zsh) Activate() (string, error) {