Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

Note: I am using Putty and my TERM is set to XTERM.

I have added the color to my bash prompt as

PS1="\[\033[0;32m\]\d \t \u\e[1;33m@\H /\W $ \[\033[1;37m\]"

just to simplify PS1 in English -

${GREEN}\d \t \u{YELLOW}@\H \W $ {reset-color}

Now, whenever my command is long and doesn't fit into the line of screen, it should come over to the next line, but it doesn't and the initial character start getting replaced which each character I type. The whole command is present but is not seen completely. It executes normally, so it's just the display that is getting distorted.

The situation worsens when I go back to the first character and try to delete the characters, the whole command line moves up and up erasing the previous data that was on screen.

After some trial and error removing some-part I found that addition a @ leads to the above behavior

\e[1;33m

I really don't remember why I had put this and I am not able to trace this back.

Can you help me in resolving this issue? The long commands should get on the next line and not on the same line.

share|improve this question
add comment

1 Answer 1

up vote 2 down vote accepted

The ANSI escape sequence right before the “@” sign is not enclosed in \[ and \]. Enclose it and should be fine:

PS1='\[\033[0;32m\]\d \t \u\[\e[1;33m\]@\H /\W $ \[\033[1;37m\]'

By the way, what you call “reset-color” is just setting it to white. To actually reset it use \033[0m.

share|improve this answer
    
Perfect. Thanks a lot :) –  mtk Mar 25 '13 at 10:36
add comment

Your Answer

 
discard

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.