zsh-git-prompt icon indicating copy to clipboard operation
zsh-git-prompt copied to clipboard

Turn off unicode symbols for Linux TTY

Open meskarune opened this issue 8 years ago โ€ข 4 comments

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

meskarune avatar Jul 04 '16 15:07 meskarune

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.

jpo-joyent avatar Nov 27 '18 20:11 jpo-joyent

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 avatar Mar 22 '19 16:03 burnettk

@burnettk The default linux TTY doesn't support unicode characters

meskarune avatar Mar 22 '19 21:03 meskarune

@meskarune cool cool. i just wanted to comment just in case anyone reading this experiences the same thing i did.

burnettk avatar Mar 25 '19 02:03 burnettk