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:
PROMPT_COMMAND=$(
cat<<-'EOF'
retval=$?
RED=$(tput setaf 1)
GREEN=$(tput setaf 2)
STOP=$(tput sgr0)
c=0
for i in $retval ${PIPESTATUS[@]}; do ((c += $i)); done
if (($c == 0)); then
PS1="\[$GREEN\] - \h(${WINDOW}):\W$ \[$STOP\]"
else
PS1="\[$RED\] - \h(${WINDOW}):\W$ \[$STOP\]"
fi
EOF
)
echo $PS1
into your question.