Custom Bash prompt is overwriting itself

后端 未结 3 1286
半阙折子戏
半阙折子戏 2020-11-28 08:07

I\'m using custom bash prompt to show git branch.

Everything is in /etc/bash/bashrc:

function formattedGitBranch {
    _branch=\"$(git b         


        
3条回答
  •  被撕碎了的回忆
    2020-11-28 08:43

    Strings like \e[0;91m needs additional quoting, to prevent bash from calculating its length.

    Enclose these strings from formattedGitBranch in \[ & \] as, \[\e[0;91m\]

    You have done it correctly in other places. Just missed it in formattedGitBranch.

提交回复
热议问题