Issue
I know about the bash history navigation with the Up and Down arrows.
I would like a lazy way to select a previous command that matches some regex (that is shorter than the whole command, so it takes less time to be typed).
Is it possible with bash?
If not, do other shells have such a feature?
Solution
You can always use CTRL-R
to search your history backward, and type some part of the previous command. Hitting CTRL-R
again (after the first hit) repeats your query (jumps to the next match if any).
Personally I use this for regex search (as regex searching is not possible yet (AFAIK)):
# search (using perl regexp syntax) your entire history
function histgrep()
{
grep -P $@ ~/.bash_history
}
Edit: For searching most recent history items via that function, see this (on setting $PROMPT_COMMAND ).
Answered By - Zsolt Botykai Answer Checked By - Timothy Miller (WPSolving Admin)