5

I use incremental-search (Ctl-r/Ctl-s) a lot in bash, and find it incredibly useful.

I noticed Meta-p (Esc p) runs non-incremental search, and I'm curious what purpose it serves, given the existence of it's incremental equivalent. Does it have some tricks up it's sleeve that I'm overlooking? Maybe it's faster if you're command history is absolutely enormous?

Since it doesn't give you the same interactive feedback you get from incremental search, I'm wondering why you'd use it.

2 Answers 2

1

I presume one could prefer non-incremental search in the Bash history for the same reasons as one would do in other interfaces; it may be somewhat distracting to see irrelevant matches whirr past when you know exactly what you're looking for.

Also, efficiency. Not so much nowadays, but in the olden days, I can imagine that doing an incremental search would be much much slower.

0

I actually found a really nice feature of non-incremental search. By default, Readline binds:

  • M-n to non-incremental-forward-search-history
  • M-p to non-incremental-reverse-search-history

These kinda suck, IMHO. But Readline also has another pair of non-incremental search functions, with no default bindings:

  • history-search-forward
  • history-search-backward

Search forward/backward through the history for the string of characters between the start of the current line and the point.

These are actually pretty useful. I've bound them to M-n and M-p, replacing the default non-incremental functions.

If I've started typing a command and decide to search for a matching history entry, I can tap Escape p (since I don't actually have a Meta key).

Repeated taps cycle farther back and Escape n cycles forward again.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .