Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 30 Oct 2017 11:45:04 -0700
From:      Devin Teske <devin@shxd.cx>
To:        Dan Mack <mack@macktronics.com>
Cc:        Cy Schubert <Cy.Schubert@komquats.com>, "src-committers@freebsd.org" <src-committers@freebsd.org>, Eitan Adler <eadler@freebsd.org>, "svn-src-all@freebsd.org" <svn-src-all@freebsd.org>, "svn-src-head@freebsd.org" <svn-src-head@freebsd.org>, Ed Maste <emaste@freebsd.org>, Warner Losh <imp@bsdimp.com>
Subject:   Re: svn commit: r325092 - head/usr.bin/fortune/datfiles
Message-ID:  <40AC7875-A7AF-4323-B6A6-0936C0507761@shxd.cx>
In-Reply-To: <ADCC1CEE-1EB0-4CFE-A3C9-30A52B418086@shxd.cx>
References:  <201710291851.v9TIpM0I073542@slippy.cwsent.com> <B855A05D-E1BB-485F-AB8D-9F9656F531CC@shxd.cx> <m28tfsofph.fsf@macktronics.com> <ADCC1CEE-1EB0-4CFE-A3C9-30A52B418086@shxd.cx>

next in thread | previous in thread | raw e-mail | index | archive | help

> On Oct 30, 2017, at 7:47 AM, Dan Mack <mack@macktronics.com> wrote:
>=20
> Devin Teske <devin@shxd.cx> writes:
>=20
> <snip>
>=20
>>> Or better yet, ctrl-r in bash and zsh, or up-arrow in tcsh.
>>=20
>> Since we are responding to emaste's astute observation with random
>> personal favorites when it comes to history actions in an interactive
>> shell...
>>=20
>> How about Esc-P and Esc-N?
>=20
> In continuation of the tangent ---
>=20
> 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 t=
han the others, though most people presume bash doesn't support it because i=
t has to be used differently.

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

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

Putting those (above) lines into ~/.inputrc may indeed make bash's Esc-N / E=
sc-P behave like tcsh's/zsh's implementation, but bash's default implementat=
ion 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 mi=
sled 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 comm=
ands that start with something whilst the bash implementation allows searchi=
ng for either text contained anywhere within a command or (if you put ^ as t=
he 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, m=
akes the default bash implementation far more valuable than the one in [t]cs=
h/zsh; and thus I get very sad when people make the bash implementation emul=
ate [t]csh's/zsh's.
--=20
Cheers,
Devin





Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?40AC7875-A7AF-4323-B6A6-0936C0507761>