Running a docker alpine container, my PS1 is:

PS1="\u@\h:\w\$ "

So when logging into the container, you get


So if I type in something like

root@worker:/$ cd /tmp/dir/path

And then do a reverse-i-search for tmp/di

The prompt looks like this for each character along the way:

(reverse-i-search)`t': cd /tmp/dir/path
(reverse-i-search)`tm: cd /tmp/dir/path
(reverse-i-search)`tmp cd /tmp/dir/path
(reverse-i-search)`tmp/cd /tmp/dir/path
(reverse-i-search)`tmp/dd /tmp/dir/path
(reverse-i-search)`tmp/di /tmp/dir/path

So now that I've typed tmp/di, if I hit the end key the prompt looks like this:


Worth noting that if I hit enter it performs the correct command, and if I scroll back through the history, it shows the correct command, so it's clearly just something to do with the presentation.

I'm wondering if this is a problem with my PS1 or if I've done something else wrong.

Thank you!


Here is the entire .bashrc

PS1="\u@\h:\w\$ "
alias app='cd /var/www/pricing'

# enable color support of ls and also add handy aliases
if [ -x /usr/bin/dircolors ]; then
    test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
    alias ls='ls --color=auto'

    alias grep='grep --color=auto'
    alias fgrep='fgrep --color=auto'
    alias egrep='egrep --color=auto'

# some more ls aliases
alias ll='ls -alF'
alias la='ls -A'
alias l='ls -CF'

# append to the history file, don't overwrite it
shopt -s histappend
shopt -s checkwinsize

case "$TERM" in
    xterm-color) color_prompt=yes;;
  • What terminal program are you using? What does echo $TERM say? – Andy Dalton Jun 25 '18 at 22:05
  • 1
    This is not a problem with your PS1 as written above; it will not cause this behavior unless you are adding in non-printing characters such as coloration or effects. – jeremysprofile Jun 25 '18 at 22:05
  • The $TERM is xterm-color. I've also edited the post to include the full .bashrc. I'm using cmder on windows, but the problem also arises when using a normal windows command prompt. – treeface Jun 25 '18 at 22:43

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.