YosysHQ / oss-cad-suite-build

Multi-platform nightly builds of open source digital design and verification tools
ISC License
783 stars 71 forks source link

Pretty PS1 colors and brackets #2

Closed clairexen closed 3 years ago

clairexen commented 3 years ago

I think this looks reasonably good on dark and bright backgrounds, without looking aggressive on either:

image

image

(sorry for the bikeshedding :wink:)

mmicko commented 3 years ago

Probably needs to be PS1="\033[1;35m\342\246\227${VIRTUAL_ENV}\342\246\230\033[0m ${PS1-}" to reset colors at the end otherwise it ruins up rest of prompt. Thing is it does not work on macOS because ZSH handles colors differently so will need to have if/else/fi block to check for it.

mmicko commented 3 years ago

Would suggest this change, zsh is quite verbose so you can see intention there:

_OLD_ENVIRONMENT_PS1="${PS1-}"
if [ -n "${ZSH_VERSION-}" ] ; then
    open=$'\U2997' closed=$'\U2998'
    PS1="%{$fg[magenta]%}${open}${VIRTUAL_ENV}${closed}%{$reset_color%} ${PS1-}"
else
    PS1="\033[1;35m\342\246\227${VIRTUAL_ENV}\342\246\230\033[0m ${PS1-}"
fi
export PS1
clairexen commented 3 years ago

Probably needs to be PS1="\033[1;35m\342\246\227${VIRTUAL_ENV}\342\246\230\033[0m ${PS1-}" to reset colors at the end otherwise it ruins up rest of prompt.

\033[0m resets all attributes. \033[39m only reset the foreground color. Since we are only changing the foreground color I thought it's sensible to only reset that attribute. (But in the end I don't really care. :D Just wanted to explain why I used \033[39m instead of \033[0m.)