0

I'm using iTerm and Terminal in Mac OS X El Captain.

When I delete characters using "delete" button in the command line, it stuck at some point and don't move left further in both iTerm and Terminal.

For example, I typed

%ps -aef | grep test

and then tried to remove this command entirely from the last char using "delete" button.

But when I removed until e and I still had

%ps -a

and then stuck and couldn't remove from a. I can't completely remove the entire command. It happens so frequently and very annoying.

Does anyone know how to solve this issue?

Someone already replied and asked some and this is my reply:

  • export PS1="\e[\033[35m[\u:\W]\$ \e[m " in .bash_profile
  • echo $TERM output is xterm-256color delete
  • delete key is backspace key on mac book air
user2761895
  • 1,431
  • 4
  • 22
  • 38
  • This sounds similar to what happens when your prompt is misconfigured and `bash` doesn't know how long it actually is. What is the value of `PS1`? – chepner Feb 16 '17 at 20:44
  • wrong terminal-type? `echo $TERM` ? For the `delete` mean `backspace`? What happens when you press `CTRL-C`? – clt60 Feb 16 '17 at 20:45

1 Answers1

0

In your prompt

export PS1="\e[\033[35m[\u:\W]\$ \e[m "

bash does not know that the printable part is only

export PS1="[\u:\W]\$  "

Unless told otherwise, by bracketing the nonprintable characters with \[ and \], it assumes the whole string is printable, counting each ordinary character as one column (\u and \W mean something that the shell computes for itself).

You might have meant something like this:

export PS1="\[\033[35m\][\u:\W]\$ \[\e[m\] "

(trimming the spurious \e[ which does nothing useful).

Thomas Dickey
  • 51,086
  • 7
  • 70
  • 105