Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: determine whether vfox has been initialized in the parent process #311

Merged
merged 1 commit into from
Jun 20, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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