Skip to content

Commit 24c8d37

Browse files
sw-squareampagent
andauthored
Guard zsh prompt prefix updates (#555)
## Summary - only capture `_HERMIT_OLD_PS1` and prepend the Hermit prompt once in `update_hermit_ps1` - avoid re-prepending the Hermit prompt on later precmd runs once the original prompt has been recorded ## Testing - `go test ./...` Co-authored-by: Amp <amp@ampcode.com>
1 parent 46614a7 commit 24c8d37

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

shell/files/activate.tmpl.sh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,10 @@ if test -n "${PS1+_}"; then
6666
# setup (for example from /etc/zshrc).
6767
precmd_functions+=( update_hermit_ps1 )
6868
update_hermit_ps1 () {
69-
[[ ! -v _HERMIT_OLD_PS1 ]] && typeset -g +x _HERMIT_OLD_PS1="${PS1}";
70-
PS1="{{if eq .Prompt "env"}}{{ .EnvName }}{{end}}🐚 ${PS1}"
69+
if [[ ! -v _HERMIT_OLD_PS1 ]]; then
70+
typeset -g +x _HERMIT_OLD_PS1="${PS1}"
71+
PS1="{{if eq .Prompt "env"}}{{ .EnvName }}{{end}}🐚 ${PS1}"
72+
fi
7173
}
7274
{{- end}}
7375

0 commit comments

Comments
 (0)