1

I am having similar problems to this thread here, with the command line overwriting the line and my up arrow overwriting all of the text.

Terminal prompt not wrapping correctly

When I run

$ shopt  | grep checkwinsize
checkwinsize    on

It seems like the issue is caused by not wrapping the right parts of the ps1 part of my bashrc. script in []. i have tried to follow the explanations in the other threads, but it hasn't seemed to help.

This is the part of my bashrc. script.

force_color_prompt=yes

if [ -n "$force_color_prompt" ]; then
    if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
    # We have color support; assume it's compliant with Ecma-48
    # (ISO/IEC-6429). (Lack of such support is extremely rare, and such
    # a case would tend to support setf rather than setaf.)
    color_prompt=yes
    else
    color_prompt=
    fi
fi

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

Is there anything wrong with my bashrc. script which is causing this problem?

I am running Ubuntu 16.04.4 Cinnamon version 3.6.7 and 4.13.0-36-generic kernel.

Thanks.

0

I can't reproduce this or see any problems with your script, though I might be missing something.

I would first ensure that the issue is actually with this part of your bashrc. Run 'echo $PS1' to check if the prompt is being modified elsewhere. To be sure, see if the problem still occurs after running:

bash -noprofile -norc
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"

If the issue is still present, the culprit may be your terminal emulator. Check that the value of '$TERM' is correct for the terminal emulator you use, and try using a different one. You might also try reinitialising the terminal and setting PS1 manually. Assuming you are using xterm:

TERM=xterm
tset $TERM
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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