Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

In a terminal window any smaller than fullscreen, if I type in a long command it starts overwriting the current line I'm on. If I type an additional line's worth, it finally moves to the next line. Does anyone know how to fix this?

This is what happens visually:

enter image description here

Edit: These are my prompt settings:
PS1: [\e]0;\u@\h: \w\a]${debian_chroot:+($debian_chroot)}\u@\h:\w\033[1m`__git_ps1`\033[0m\$
TERM: xterm

if [ "$color_prompt" = yes ]; then
    PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
    PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\033[1m`__git_ps1`\033[0m\$ '

# If this is an xterm set the title to user@host:dir
case "$TERM" in
    PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"
share|improve this question
up vote 1 down vote accepted

For some reason the terminal size is mis-reporting. It should change when you resize the terminal.

Try this in your .bashrc command file:

# check the window size after each command and, if necessary,
# update the values of LINES and COLUMNS.
shopt -s checkwinsize
share|improve this answer
It looks like this was already in my .bashrc file. Running shopt shows that checkwinsize is on. – thebaer Aug 4 '12 at 19:48
Hmm, what are the values of LINES and COLUMNS when the text is messed up? – Julian Knight Aug 7 '12 at 20:56
LINES is 24, COLUMNS is 80. Resizing the window does change these values, but the text is still messed up. – thebaer Aug 8 '12 at 15:39
Ah. OK, I suspect the setting for the PROMPT now. Can you post the values of PS1 and TERM. In fact, post the line defining PS1 in .bashrc – Julian Knight Aug 8 '12 at 20:41
I updated the question with these answers. – thebaer Aug 10 '12 at 15:43

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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