This question already has an answer here:

When using tmux, I have issues of ghost characters when using the Up and Down arrow keys in Bash. If I press UpArrow a few times and then press DownArrow a few times, then the first few characters of a previous command remain on the Bash line.

For instance, take this clean Bash line:


Now I press UpArrow three times:

$ ls /home/dotancohen/Downloads

Now I press DownArrow three times:

$ ls /home/do

I can reproduce the issue with no ~/.tmux.conf file, after exiting and restarting tmux. How should I diagnose this?

Edit: Here is my $PS1:

$ echo $PS1
\[\] - \h():\W$ \[\]

Note that everything from the second backslash up until the last close bracket is green. This function creates the prompt:



    RED=$(tput setaf 1)
    GREEN=$(tput setaf 2)
    STOP=$(tput sgr0)

    for i in $retval ${PIPESTATUS[@]}; do ((c += $i)); done

    if (($c == 0)); then
        PS1="\[$GREEN\] - \h(${WINDOW}):\W$ \[$STOP\]"
        PS1="\[$RED\] - \h(${WINDOW}):\W$ \[$STOP\]"

marked as duplicate by terdon linux Dec 21 '15 at 17:02

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • 1
    Put the result of echo $PS1 into your question. – JdeBP Mar 2 '14 at 11:14

This is, of course, the same problem and the same cause as at https://superuser.com/a/695350/38062 . In this particular case, the non-spacing escape sequence that you've forgotten to delimit with \[ and \], and that is banjanxing bash, is apparently somewhere in the expansion of ${WINDOW}.

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