zsh-git-prompt
zsh-git-prompt copied to clipboard
Turn off unicode symbols for Linux TTY
Hello, I have a feature request to turn off the unicode symbols and use ascii for linux TTY. It could be done with something like this:
if [[ ${TERM} == "linux" ]]; then
GIT_PROMPT_SYMBOL="%{$fg[green]%}git:"
GIT_PROMPT_CLEAN="%{$fg_bold[green]%}-"
GIT_PROMPT_AHEAD="%{$fg_bold[yellow]%}> NUM"
GIT_PROMPT_BEHIND="%{$fg_bold[yellow]%}< NUM"
GIT_PROMPT_MERGING="%{$fg_bold[magenta]%}Y"
GIT_PROMPT_UNTRACKED="${fg_alert}!"
GIT_PROMPT_MODIFIED="${fg_alert}+"
GIT_PROMPT_STAGED="%{$fg_bold[blue]%}="
else
GIT_PROMPT_SYMBOL="%{$fg[green]%}๎ "
GIT_PROMPT_CLEAN="%{$fg_bold[green]%}โ "
GIT_PROMPT_AHEAD="%{$fg_bold[yellow]%}๐กฉ NUM "
GIT_PROMPT_BEHIND="%{$fg_bold[yellow]%}behind: ๐กซ NUM "
GIT_PROMPT_MERGING="%{$fg_bold[magenta]%}๐ "
GIT_PROMPT_UNTRACKED="${fg_alert}โ "
GIT_PROMPT_MODIFIED="${fg_alert}โ "
GIT_PROMPT_STAGED="%{$fg_bold[blue]%}๐ "
fi
I have this working with a zsh prompt I wrote from scratch: https://gist.github.com/meskarune/6a647b067de3addd045f11c07aaf1cfc
I sometimes need to use my computer with a TTY and with unicode it messes up the prompt. This way you can detect if it's a TTY and still have a usable prompt.
edit: here is a list of unicode symbols and ascii characters that could be used:
Unicode: branch: ๎ โ clean: โ โ untracked: โ X modified files: โ ๐ ๐ staged: ๐ ๐ฒ ๐ merge: ๐ ๐ ๐ ahead: ๐กฉ ๐ behind: ๐กซ ๐
Ascii: branch: git: , # clean: -- , ok , ~~ untracked: ! , X , % modified files: + , ... , * staged: = , O , S merge: Y , {{ , >> , |- ahead: > NUM, ^ NUM behind: < NUM, v NUM
Might want to detect if the locale is *.UTF-8
instead, since that would be consistent with how other utilities decide whether to use special chars or not, and would not require special-casing TERM values.
As far as I'm aware, there is no "supports utf8" termcap bit.
I believe the correct (consistent with POSIX) behavior would be checking LC_ALL
, LC_CTYPE
, and LANG
in that order.
if your linux terminal supports utf8, and if it's displaying the unicode characters, but they are printing on top of each other, try a different font.
@burnettk The default linux TTY doesn't support unicode characters
@meskarune cool cool. i just wanted to comment just in case anyone reading this experiences the same thing i did.