Re: why does the shell show commands foolishly when I press UP key?
[This message has also been posted to linux.debian.user.]
In article <9nwMV-4pJ-13@gated-at.bofh.it>, Serena Cantor wrote:
> I often use UP key to get commands entered previously. The shell show some commands again and
> again, just because I have used them several times. Can the shell be more smart?
This is bash, right? Bash is already smart. It's keeping the
whole history in case you forgot what you did. Don't fight
it, use it.
1. Edit your /etc/inputrc file and add the line
set editing-mode vi
near the beginning of the file. Now your shell, and
anything else that uses GNU Readline, will have a fine
set of history editing commands. Emacs users feel
free to set it to emacs.
If you just want to change the shell, and leave everything
else emacs-ish, type
set -o vi
into your shell, or put that in ~/.bashrc
2. Don't use the uparrow any more. That's what the
k key is for. Escape k k k k k
Notice most visual editing commands work, so you can
change the commands instead of just recalling them.
When you get tired of that, there is a search command.
Escape /^grep
to find the last command that began with grep.
Your favorite regular expressions work. Now you can blow
past the duplicate commands to the one you want.
Cameron
Reply to: