0

My Bash prompt clears itself when deleting the text after it or going too far in the history.

When logging in, the prompt looks normal. There are white brackets around a colored username and then a white > as my prompt, however if I move up twice in my history, the history command overwrites my prompt:

[stonewareslord] >        #Initial prompt. stonewareslord is green
                   | Cursor is above this pipe symbol

[stonewareslord] > ls     #Up arrow pressed once. ls was my last command. Colors are normal, ls is white
                     | Cursor is above this pipe symbol

pwdonewareslord] > ls     #Up arrow a second time. pwd overwrite [st. pwd is white and the other colors are normal. 
   | Cursor is above this pipe symbol

It also happens when I delete the command:

[stonewareslord] > ls     #Typed command after initial prompt. stonewareslord is green
                     | Cursor is above this pipe symbol

[stonewareslord] > l      #Deleted one character
                    | Cursor is above this pipe symbol

                          #Deleted second character (line is blank). Anything I type is white
| Cursor is above this pipe symbol

The lines in the bashrc that probably could have affected this are:

color='\e[0;32m'  #Green
reset='\e[0m'     #Color is set back to normal (white)
prompt(){
    printf "[$color%s$reset]>" `whoami`
}
PS1=""
PROMPT_COMMAND=prompt

export HISTFILESIZE=
export HISTSIZE=
export HISTTIMEFORMAT="%Y-%m-%d_%H:%M:%S "
export HISTFILE=~/.bash_eternal_history

readonly HOME
readonly HISTIGNORE
0

Well I figured out a way around it:

PROMPT_COMMAND=prompt

was changed to:

PROMPT_COMMAND='PS1=`prompt`'

Edit: and the colors were wrapped in \[ \] (i.e. color='\[\e[0;32m\]')

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.