> On Oct 30, 2017, at 7:47 AM, Dan Mack <[email protected]> wrote:
> 
> Devin Teske <[email protected]> writes:
> 
> <snip>
> 
>>> Or better yet, ctrl-r in bash and zsh, or up-arrow in tcsh.
>> 
>> Since we are responding to emaste's astute observation with random
>> personal favorites when it comes to history actions in an interactive
>> shell...
>> 
>> How about Esc-P and Esc-N?
> 
> In continuation of the tangent ---
> 
> I use ESC-P / ESC-N a lot; it's a neat feature that tcsh has had for a
> long time, maybe since the beginning.  However it's a tcsh feature, not
> sh, bash, or csh IIRC.  But csh is actually tcsh on FreeBSD but I'm sure
> most people already know this on this list.

zsh's default implementation matches that of tcsh.

csh would likely support it, but since /bin/csh and /bin/tcsh are hard links to 
each other, can't tell for certain.

That being said...

It actually works better in bash without your (below) inputrc change.

[t]csh, zsh, and bash implement this feature but bash implements it better than 
the others, though most people presume bash doesn't support it because it has 
to be used differently.

> To emulate this behaviour in bash, I simply create a .inputrc file in my
> $HOME with the following contents:
> 
> # .inputrc field
> "\ep": history-search-backward
> "\en": history-search-forward
> 
> 
> Works for me.

You probably won't want this for bash once you learn how to use bash's default 
implementation of Esc-N / Esc-P.

Putting those (above) lines into ~/.inputrc may indeed make bash's Esc-N / 
Esc-P behave like tcsh's/zsh's implementation, but bash's default 
implementation is better, imho (see below)

In tcsh/zsh:

1. Type letters that a previous cmd *begins with*
2. Esc-P

In bash:

1. Esc-P
(a ":" prompt appears)
2. Type letters that a previous cmd *contains* (or use ^ prefix for 
*begins-with*)

If you try to use bash's implementation in the tcsh/zsh way, you might be 
misled into thinking "nothing happened" because if the input line is not empty 
in bash, Esc-P does nothing.

The [t]csh/zsh implementation is limited to only searching for previous 
commands that start with something whilst the bash implementation allows 
searching for either text contained anywhere within a command or (if you put ^ 
as the first character) text that is at the start of a command.

Being able to search anywhere within a command or at the beginning, I feel, 
makes the default bash implementation far more valuable than the one in 
[t]csh/zsh; and thus I get very sad when people make the bash implementation 
emulate [t]csh's/zsh's.
-- 
Cheers,
Devin


_______________________________________________
[email protected] mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "[email protected]"

Reply via email to