0

I made my own .bashrc (part of code below) and in test by pressed arrows up/down: i found that history of commands override static text of line or leaves last command and print new over it. How to fix that?

function parse_git_branch {
  git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'
}

RESTORE=$(echo -en '\033[0m')
RKNAME=$(echo -en '\033[38;5;106m')
RKPATH=$(echo -en '\033[38;5;229m')
RKBRANCH=$(echo -en '\033[38;5;44m')
RKGIT=$(echo -en '\033[38;5;250m')

pathToFolder=$PWD;

if [[ $pathToFolder =~ .*_GitRepo.* ]]
then
    PS1='${RKNAME}\u@\h${RESTORE} ${RKGIT}Git ${RKPATH}\W\ ${RKBRANCH}$(parse_git_branch) \n ${RKGIT}-- $ ${RESTORE} '
    fi
rikimaru2013
  • 401
  • 4
  • 13

1 Answers1

0

Resolve my problem is:

However, I had the same line-wrapping problem you did. The fix was to insert [ and ] around the ANSI escapes so that the shell knows not to include them in the line wrapping calculation.

Thanks, @Gillies for link Why is this bash prompt acting strangely/disappearing, and how do I fix it (OS X)?

Community
  • 1
  • 1
rikimaru2013
  • 401
  • 4
  • 13