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.

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 ?

share|improve this question
1  
A better question would be - how do I fix this problem with my bash history. –  Neil Butterworth Jun 9 '11 at 11:36
1  
Do you have vi bindings set on bash? –  karategeek6 Jun 9 '11 at 11:49
1  
What does your prompt look like? What is "$PS1"? –  glenn jackman Jun 9 '11 at 14:30
add comment

migrated from stackoverflow.com Jun 9 '11 at 12:21

This question came from our site for professional and enthusiast programmers.

2 Answers

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.

share|improve this answer
    
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 Jun 10 '11 at 8:23
add comment

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.