简体   繁体   中英

zsh + powerline : prompt disappears with long command line

航天员

As you can see, when I write a long command line, zsh prompt disappears, and I don't know why


.zshrc :

autoload -U compinit promptinit
compinit
promptinit

zstyle ':completion:*:descriptions' format '%U%B%d%b%u'
zstyle ':completion:*:warnings' format '%BDésolé, pas de résultats pour : %d%b'
zstyle ':completion:*' menu select=2
zstyle ':completion:*' select-prompt %SScrolling active: current selection at %p%s


function powerline_precmd() {
    PS1="$(~/powerline-shell.py $? --shell zsh 2> /dev/null)"
}

function install_powerline_precmd() {
    for s in "${precmd_functions[@]}"; do
        if [ "$s" = "powerline_precmd" ]; then
            return
        fi
    done
    precmd_functions+=(powerline_precmd)
}

if [ "$TERM" != "linux" ]; then
    install_powerline_precmd
fi

bindkey ';5D' emacs-backward-word
bindkey ';5C' emacs-forward-word

I use Xfce4-terminal, i'm on Debian stretch

Thanks

This is due to how zsh decides the length of the prompt. Generally with standard commands it works correctly on it's own, however, running a python script and echoing that to the prompt confuses it and I have been unable to properly fix it, adding %27{ before and %} after $(~/powerline-shell.py $? --shell zsh 2> /dev/null) made it appear to work for me, but that is just a temporary work around based off of my powerline prompt.

A much more viable fix would be to dump powerline-shell and mess around with bash-powerline which is written entirely with bash commands, which is cross-compatible with zsh.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM