Sample Header Ad - 728x90

PS1: tab completion or line break leads to cursor shift

0 votes
0 answers
60 views
I recently changed my PS1 in my .bashrc and I notice that my prompt has problems when the command line has more characters typed into than the number of columns of my terminal window. I also recognised that I cannot use ^R (search for commands in the history) properly: the cursor seems to be shifted by several tabstops in both cases. I'm quite sure that this comes from my new PS1, but I couldn't spot where' exactly the mistake. If I knew how to insert a line break into my PS1, I'd be very happy. My definition of PS1 in my .bashrc:
PS1='\[\033[1;37m\]$? $(if [[ $? == 0 ]]; then echo "\[\033[01;32m\]\342\234\223"; else echo "\[\033[01;31m\]\342\234\227"; fi) \# \[\033[1;32m\]\u\[\033[31m\]@\[\033[1;35m\]\H\[\033[1;33m\]:\e[47m\[\033[1;34m\]\w\[\033[0m\]\$\[\033[0m\] '
Asked by muggi (759 rep)
Jan 14, 2025, 03:44 PM