1

Due to some unknown reason I am not able to edit/delete the last character of any bash command from the bash history i.e. when I access last bash command using 'up' arrow I cannot change or delete the last character in that command and also I cannot add anything to that command after the last character.

If I can add a space to the end of every command then I can edit the last command as I want. So my question is can I add a space automatically after every command I type in bash ?

3
  • 1
    A better question would be - how do I fix this problem with my bash history.
    – Neil Butterworth
    Commented Jun 9, 2011 at 11:36
  • 1
    Do you have vi bindings set on bash?
    – cledoux
    Commented Jun 9, 2011 at 11:49
  • 1
    What does your prompt look like? What is "$PS1"? Commented Jun 9, 2011 at 14:30

2 Answers 2

3

Adding a character to commands is not the solution you need. You probably have the key bindings for your terminal setup funny. Perhaps you have a special edit mode (such as emacs of vi emulation) set and unbeknownst to you it is in edit mode, but the cursor is one in from the end? Perhaps your delete key is not mapped to the right function?

In any event, fix your terminal issues, don't try to hack the command itself or even the history.

1
  • The behavior I have explained in the question was the result of using vi bindings. And it is resolved once I've changed it to emacs.
    – Mahesh
    Commented Jun 10, 2011 at 8:23
1

If you are using vi bindings you should hit Esc (exit to normal mode) and then A (edit after last character in line) to start typing after the last char.

Vi mode is great if you learn to use it.

0

You must log in to answer this question.