z-shell / zi

✨ A Swiss Army Knife for Zsh - Unix Shell
https://wiki.zshell.dev
MIT License
735 stars 42 forks source link

[bug]: visual issue #277

Closed cattokomo closed 1 year ago

cattokomo commented 1 year ago

Environment

Arch Linux proot inside Termux, zsh 5.9 (armv7l-unknown-linux-gnueabihf), zi git commit 75929e8

Reproduction steps

`zi -h` or `exec zsh` to install plugins/snippets

Expected behavior

1. No error is shown while showing command usage.
2. Git clone progress bar not printed every line.

Current behavior

1. Errors about `character not in range` printed when executing zi with `-h` flag. (See screenshot)
2. The Git clone progress bar printed every 
line. (See screenshot)

Code snippet

{# OMZ plugins
}

{# plugins
    zi load "agkozak/agkozak-zsh-prompt"; {
        bindkey -v

        AGKOZAK_CMD_EXEC_TIME=3

        AGKOZAK_COLORS_CMD_EXEC_TIME=117
        AGKOZAK_COLORS_EXIT_STATUS=196
        AGKOZAK_COLORS_PATH=69
        AGKOZAK_COLORS_BRANCH_STATUS=76
        AGKOZAKTIDE_COLORS_PROMPT_NORMAL=76
        AGKOZAKTIDE_COLORS_PROMPT_VI=45
        AGKOZAKTIDE_COLORS_PROMPT_NONZERO=196
        AGKOZAKTIDE_COLORS_CLOCK=default

        AGKOZAK_CUSTOM_PROMPT=$'\n'
        # Directory
        AGKOZAK_CUSTOM_PROMPT+=$'%B%F{$AGKOZAK_COLORS_PATH}%2v%f%b'
        # Exec time
        AGKOZAK_CUSTOM_PROMPT+=$'%(9V.\n%F{$AGKOZAK_COLORS_CMD_EXEC_TIME}%9v :: %f.)'
        # Exit code & Job
        AGKOZAK_CUSTOM_PROMPT+=$'%(?..%(9V..\n)[%F{$AGKOZAK_COLORS_EXIT_STATUS}:%?%f%(1j..]))%(1j.%(?.\n[. )%F{$AGKOZAK_COLORS_BG_STRING}*%j%f].)'
        # Prompt
        AGKOZAK_CUSTOM_PROMPT+=$'\n%(?.%(4V.%F{$AGKOZAKTIDE_COLORS_PROMPT_VI}≈>%f.%F{$AGKOZAKTIDE_COLORS_PROMPT_NORMAL}=>%f).%F{$AGKOZAKTIDE_COLORS_PROMPT_NONZERO}=>%f) '

        AGKOZAK_CUSTOM_RPROMPT=""
        # Git status
        AGKOZAK_CUSTOM_RPROMPT+=$'%(3V.%F{${AGKOZAK_COLORS_BRANCH_STATUS}}%6v%(7V. %7v.)%f.) '
        # Clock
        AGKOZAK_CUSTOM_RPROMPT+="%F{$AGKOZAKTIDE_COLORS_CLOCK}%*%f"
    }

    zi ice pick"themes/catppuccin_mocha-zsh-syntax-highlighting.zsh"
    zi load "catppuccin/zsh-syntax-highlighting"

    zi ice pick"zsh-syntax-highlighting.zsh"
    zi load "zsh-users/zsh-syntax-highlighting"

    zi ice pick"zsh-autosuggestions.zsh"
    zi load "zsh-users/zsh-autosuggestions"; {
        ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE="fg=#9399b2"
    }

    zi ice pick"zsh-history-substring-search.zsh"
    zi load "zsh-users/zsh-history-substring-search"; {
        bindkey '^[[A' history-substring-search-up
        bindkey '^[[B' history-substring-search-down

        HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_FOUND="underline,bold"
        HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_NOT_FOUND="fg=1,underline,bold"
    }

    zi load "skywind3000/z.lua"; {}

    zi load "davidde/git"; {}

    zi load "cjayross/up"; {}

    zi load "jeffreytse/zsh-vi-mode"; {}

    zi load "hcgraf/zsh-sudo"; {}
}

Additional information

Screenshots: Screenshot_20230711-170945_Termux Screenshot_20230711-170617_Termux

Self-service

Have you read the Contributing Guidelines?

Are you familiar with the Contributor Covenant Code of Conduct?

Contact Details

No response

### Tasks
ss-o commented 1 year ago

Hi @UrNightmaree,

Thank you for opening an issue report :handshake: I have scheduled a triage and will update you on the progress :dart:

Please provide information about your terminal emulator :grey_question:

Thanks.

cattokomo commented 1 year ago

Hello @ss-o, thank you for responding my issue. 🙏

Please provide information about your terminal emulator ❔

It's Termux.

ss-o commented 1 year ago

It seems to be a locale issue and encounters an escape sequence which most likely is not valid for currently set encoding. To verify this you may try:

LC_ALL="UTF-8" echo '\u2603'
LC_CTYPE="UTF-8" echo '\u2603'
LC_CTYPE="en_US.UTF-8" echo "\u2603"

The above should print a symbol or if due to missing fonts may provide empty/incorrect output, but no error should be shown, but with the following example it should show error "character not in range":

LC_CTYPE="C" echo '\u2603'

Could you please confirm that this is the case?

Source related to locale: https://wiki.archlinux.org/title/locale

cattokomo commented 1 year ago

I tried above but still complain about character not in range. Screenshot_20230810-101858_Termux

ss-o commented 1 year ago

Pretty sure that the error is shown because of the locale and multiple scenarios may cause this, e.g. lack of configuration, misconfiguration, corrupted files, etc.

Try the following:

Open the /etc/locale.gen file and ensure there is a line as below and it is not prepended with a #, then run locale-gen (usually requires root access and executed with sudo)

en_US.UTF-8 UTF-8

Add at the top of your .zshrc, then run exec zsh.

export LANG=en_US.UTF-8
export LC_ALL=en_US.UTF-8

If the issue is not solved then check if it is caused by something in .zshrc:

mv ~/.zshrc ~/.zshrc.backup
touch ~/.zshrc
exec zsh
echo '\u2603'

If the character not in range error does not appear then recover .zshrc with cp -i ~/.zshrc.backup ~/.zshrc and remove components one by one while each time running exec zsh and echo '\u2603' afterward to identify what exactly causes the error.

cattokomo commented 1 year ago

Oh now it works, seems like I haven't setup locale.