Skip to content

Commit

Permalink
fix: correct ANSI escapes for ZSH prompt
Browse files Browse the repository at this point in the history
  • Loading branch information
JPHutchins committed Mar 13, 2024
1 parent 72e25fb commit c9c7a6d
Show file tree
Hide file tree
Showing 7 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions envr.ps1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# envr v0.5.3
# envr v0.5.4
# https://www.github.com/JPHutchins/envr
# https://www.crumpledpaper.tech

Expand Down Expand Up @@ -270,7 +270,7 @@ _envr_set_prompt_prefix () {
if [[ -n "${BASH:-}" ]] ; then
PS1="\[\033[0;36m\](${_PROMPT}) ${PS1:-}"
elif [[ -n "${ZSH_VERSION:-}" ]] ; then
PS1="\033[0;36m(${_PROMPT}) ${PS1:-}"
PS1="%F{36}(${_PROMPT})%F{reset} ${PS1:-}"
fi
export PS1
Expand Down
2 changes: 1 addition & 1 deletion tests/sh/test_aliases.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ assertEqual "$(args User args)" "User args"
if [[ -n "${BASH:-}" ]] ; then
assertEqual "$(echo $PS1 | cut -c 15-)" "(envr)"
elif [[ -n "${ZSH_VERSION:-}" ]] ; then
assertEqual "$(echo $PS1 | cut -c 8-)" "(envr) "
assertEqual "$(echo $PS1)" "%F{36}(envr)%F{reset} "
fi

# some error is getting caught by unsource but it's not apparent in
Expand Down
2 changes: 1 addition & 1 deletion tests/sh/test_empty.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ assertEqual $(pwd) $(echo $ENVR_ROOT)
if [[ -n "${BASH:-}" ]] ; then
assertEqual "$(echo $PS1 | cut -c 15-)" "(envr)"
elif [[ -n "${ZSH_VERSION:-}" ]] ; then
assertEqual "$(echo $PS1 | cut -c 8-)" "(envr) "
assertEqual "$(echo $PS1)" "%F{36}(envr)%F{reset} "
fi

unsource
Expand Down
2 changes: 1 addition & 1 deletion tests/sh/test_full.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ assertNotEqual "$OLD_PS1" "${PS1:-}"
if [[ -n "${BASH:-}" ]] ; then
assertEqual "$(echo $PS1 | cut -c 15-)" "(poopsmith)"
elif [[ -n "${ZSH_VERSION:-}" ]] ; then
assertEqual "$(echo $PS1 | cut -c 8-)" "(poopsmith) "
assertEqual "$(echo $PS1)" "%F{36}(poopsmith)%F{reset} "
fi

# test aliases
Expand Down
2 changes: 1 addition & 1 deletion tests/sh/test_multi.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ assertNotEqual "$OLD_PS1" "${PS1:-}"
if [[ -n "${BASH:-}" ]] ; then
assertEqual "$(echo $PS1 | cut -c 15-)" "(2a)"
elif [[ -n "${ZSH_VERSION:-}" ]] ; then
assertEqual "$(echo $PS1 | cut -c 8-)" "(2a) "
assertEqual "$(echo $PS1)" "%F{36}(2a)%F{reset} "
fi

# test aliases
Expand Down
2 changes: 1 addition & 1 deletion tests/sh/test_project_options.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ assertEqual "$OLD_ALS" "$(alias)"
if [[ -n "${BASH:-}" ]] ; then
assertEqual "$(echo $PS1 | cut -c 15-)" "(my long project name 1337 !_*#? 3)"
elif [[ -n "${ZSH_VERSION:-}" ]] ; then
assertEqual "$(echo $PS1 | cut -c 8-)" "(my long project name 1337 !_*#? 3) "
assertEqual "$(echo $PS1)" "%F{36}(my long project name 1337 !_*#? 3)%F{reset} "
fi

assertEqual "my long project name 1337 !_*#? 3" "$ENVR_PROJECT_NAME"
Expand Down
2 changes: 1 addition & 1 deletion tests/sh/test_python_venv.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ assertEqual "$OLD_ALS" "$(alias)"
if [[ -n "${BASH:-}" ]] ; then
assertEqual "$(echo $PS1 | cut -c 15-)" "(envr)"
elif [[ -n "${ZSH_VERSION:-}" ]] ; then
assertEqual "$(echo $PS1 | cut -c 8-)" "(envr) "
assertEqual "$(echo $PS1)" "%F{36}(envr)%F{reset} "
fi

unsource
Expand Down

0 comments on commit c9c7a6d

Please sign in to comment.