When a path is too long to fit on the terminal and it wraps, the following prompt is broken and you can't see properly what is typed. See screenshot below:
These are the contents of .bashrc that set the PS1, which is the default provided by Ubuntu.
if [ "$color_prompt" = yes ]; then
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
else
PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
fi
unset color_prompt force_color_prompt
# If this is an xterm set the title to user@host:dir
case "$TERM" in
xterm*|rxvt*)
PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"
;;
*)
;;
esac
The value of $PS1 is
echo "$PS1"
\[\e]0;\u@\h: \w\a\]${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$
Is there any way to fix it?
I have seen several other similar questions, and the proposed solution is to enclose the offending part in \[ \], or to set checkwinsize, but neither worked in my case.
If anyone wants to test with the path, it is the folowing:
/home/dimitriv/Dropbox/personal/kastoria/2018-2019/προγραμματισμός στο διαδίκτυο/newslides
