In the terminal, I can type CTRL-R to search for a matching command previously typed in BASH. E.g., if I type CTRL-R then grep is lists my last grep command, and I can hit enter to use it. This only gives one suggestion though. Is there any way to cycle through other previously typed matching commands?
|
|
||||
|
|
|
If I understand the question correctly you should be able to cycle through alternatives by repeatedly hitting Ctrl+R. E.g.: Ctrl+R
|
|||||||||||||||||||||
|
|
If you feel the command will be used frequently, you could add a tag
Then
This works because |
|||||||||||||||||
|
|
You can also set up the up and down arrows to do a slightly different search by adding these lines to ~/.inputrc:
Instead of searching for a substring anywhere in the command (like Ctrl-r) it will search for a command starting with the text to the left of the cursor. For example, if I run these commands:
then type These approaches both have their strengths, and both of them can save a lot of time. |
|||||||||||||
|
protected by Anthon Apr 11 '16 at 22:31
Thank you for your interest in this question.
Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).
Would you like to answer one of these unanswered questions instead?