0

When I use the Ctrl+p key binding (I use the default emacs key bindings) on my command line, it sometimes works as expected, showing the previous command that I've run. I'm using the bash shell on Ubuntu 18.04.

However, sometimes it glitches: it'll hold a part of the previous line in the command line. This does not affect the next command I run, but it's still bugging me. How can I fix this?

enter image description here(I'm aware that this explanation doesn't make much sense, so here's a screenshot. I cannot backspace anymore on the last command (the touch file line, for some reason.) When I say "this does not affect the next command I run", here's what I mean: enter image description here

Edit: my PS1 reads: \e[1;32mKR$ \e[m

1

Solution is to change the command prompt, the value of $PS1 by enclosing things that begin with \e in \[ and \]. This is from another answer.

I started out with the $PS1 being set to \e[1;32mKR$ \e[m.

The first solution I tried was to enclose the whole expression with those sequences, \[\e[1;32mKR$ \e[m\] but that didn't work, so I had to split this up into two different sections, one for each non-printable chunk. Hence, I was left with \[\e[1;32m\] and \[\e[m\] once I had added in those sequences .

The final solution was \[\e[1;32m\]KR$ \[\e[m\].

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.