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.

How can I configure my Linux terminal so that the current command isn't lost when I press the up arrow key?

share|improve this question

migrated from serverfault.com Aug 18 '11 at 6:10

This question came from our site for professional system and network administrators.

9  
If you press the down key it should come back (assuming bash). This is part of bash's history ability - every time you press up, you see the previous command, pressing down you see the most recent, including what you just typed. Effectively, in this instance, your 'undo'. –  Chad Feller Aug 18 '11 at 4:04
    
It doesn't comeback when you type fast. –  telnet Aug 18 '11 at 4:21
5  
What shell are you using & which terminal configuration (echo $SHELL; echo $TERM). –  O G Aug 18 '11 at 5:18

1 Answer 1

Add this to your .profile, .bashrc or .bash_profile:

bind -r "\e[A"

Then save the file. This will take effect when you open your next terminal (load it immediately with . <file> or source <file>).

This will unbind the Up arrow key from accessing your history. You can still use ctrl+P to move to the previous history item and ctrl+N to move to the next history item.

To unbind both up and down arrow keys, use this:

bind -r "\e[A"
bind -r "\e[B"
share|improve this answer

Your Answer

 
discard

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