Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

Hi when I pressed the up arrow to see the previous command, it rewrote the current command from half.

Example:

21 /usr/local/sphinx/etc >  /usr/local/sphinx/bin/search --config /usr/local/sphinx/etc/sphinx-blog.conf php

and when I press the up arrow, it shows:

21 /usr/local/sphinx/etc >  /usr/local/sudo /usr/local/sphinx/bin/indexer --config /usr/local/sphinx/etc/sphinx-blog.conf --all

and "/usr/local/" before SUDO is from previous command. Do you know where the problem would be? Here is my prompt setting:

PS1="\# \e[32;1m\w > \e[0m "
share|improve this question
    
and when i use BACKSPACE i will delete up to 21 /usr/local/sphinx/etc > /usr/local/ i'm not able to delete /usr/local/ –  vosy Jan 24 '12 at 20:32
    
Could you pleas execute read on the command line and then press the up-arrow? (you can exit read with ctrl+c) In theory, this should give ^[[A or \e[A (reps. ^[[B or \e[B for the down-arrow). Did you maybe configure bind for your arrow keys (eg. in the ~/.bash_profile)? –  Asmus Jan 24 '12 at 21:32
    
I tried it 18 ~ > /usr/local/read ^[[A^[[B^[[A^[[A^[[A^[[A^[[B^[[B^[[B –  vosy Jan 24 '12 at 23:02
    
All of those characters appeared when you pressed the up arrow just once?? If so, then @Asmus is correct and something is wrong with your configuration. –  cm2 Jan 25 '12 at 18:07

1 Answer 1

I tried around and finally managed to find the error: you need to use even more escape sequences in your PS1 - this should work:

export PS1="\# \[\e[32;1m\]\w > \[\e[0m\]"

note the additional \[ and \] that wrap the colour escape sequences.

share|improve this answer

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.