Skip to content

Commit

Permalink
fix: determine whether vfox has been initialized in the parent process (
Browse files Browse the repository at this point in the history
  • Loading branch information
fangzhengjin authored Jun 20, 2024
1 parent 37804da commit 1bd1912
Showing 1 changed file with 18 additions and 16 deletions.
34 changes: 18 additions & 16 deletions internal/shell/zsh.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 1bd1912

Please sign in to comment.