Remnant characters when tab completing with ZSH

后端 未结 6 455
终归单人心
终归单人心 2021-01-30 17:09

I\'m using oh-my-zsh in Arch linux with the robbyrussell theme loaded. When I try to tab complete I end up with remnant characters appended to the prompt. If I delete the auto-c

相关标签:
6条回答
  • 2021-01-30 17:33

    I had a similar issue, though not with oh-my-zsh but promptline; for me the solution was to remove from my configuration:

    ZLE_PROMPT_INDENT=0
    
    0 讨论(0)
  • 2021-01-30 17:33

    I had a similar issue, with the theme tjkirch_mod though. Whenever I was working in a dirty git repo and used tab completion, the first character of the line was duplicated. Changing the character that indicates the git repo state solved the problem for me. Changed

    ZSH_THEME_GIT_PROMPT_DIRTY=" %{$fg[red]%}⚡"

    to

    ZSH_THEME_GIT_PROMPT_DIRTY=" %{$fg[red]%}x"

    0 讨论(0)
  • 2021-01-30 17:43

    I had the same problem, so on my quest for a solution I have encountered this article: https://wiki.archlinux.org/index.php/Locale

    And, as it was suggested, to enable some locale system-wide, you just need uncomment the desired locale on /etc/locale.gen, for example, in my case:

    en_US.UTF-8 UTF-8
    

    After saving the changes on the file, execute (as root) on command line:

    locale-gen
    

    Reboot, and it works! (at least for me)

    0 讨论(0)
  • 2021-01-30 17:47

    As suggested by simont it is likely that the prompt you are using is using unprintable characters (like color escape codes) but does not indicate that those characters are unprintable. So when the prompt is redrawn the terminal believes that the prompt is wider than it actually is.

    You indicate that a character sequence in the zsh prompt has zero width using the %{ and %} delimiters. For example my prompt is:

    %{%(?.%F{green}.%F{red})%}➜%{%f%}
    

    The (?...) is a ternary which sets the color of the prompt and it has been marked up to indicate that it is zero width. In the same way the %f resets the color and that has also been marked up.

    You can test changes to your prompt by updating the PS1 variable, so you can try out different arrangements and see what works for you.

    You can mark any characters in this way, so be careful about making your prompt too short!

    0 讨论(0)
  • 2021-01-30 17:52

    Turns out it was a locale issue. Running locale-gen didn't work until I deleted some config file somewhere and reran it.

    Your advice is good for the prompt though. Thank you.

    0 讨论(0)
  • 2021-01-30 17:57

    It seems I had issues with locale configuration and non UTF8 configuration

    In my case the fix was:

    export LC_ALL="en_US.UTF-8"
    

    and keep it permanent adding the line to .zshrc:

    echo "export LC_ALL=en_US.UTF-8" >> .zshrc
    

    More info in Ubuntu doc https://help.ubuntu.com/community/Locale

    0 讨论(0)
提交回复
热议问题