From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3719 invoked by alias); 20 Apr 2011 17:34:03 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: X-Seq: 15974 Received: (qmail 28348 invoked from network); 20 Apr 2011 17:33:52 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_PASS autolearn=ham version=3.3.1 Received-SPF: pass (ns1.primenet.com.au: SPF record at zhar.net designates 68.118.117.234 as permitted sender) Date: Wed, 20 Apr 2011 13:25:43 -0400 From: John Eikenberry To: zsh-users@zsh.org Subject: Re: Suffix alias for README files Message-ID: <20110420172543.GK6935@mollari.zhar.net> Mail-Followup-To: John Eikenberry , zsh-users@zsh.org References: <20110419135909.GA21897@cosy.cit.nih.gov> <1590CA5C-3329-4DF1-8E73-E7FE218A21D9@biskalar.de> <20110420124129.GB18289@cosy.cit.nih.gov> <110420080625.ZM16423@torch.brasslantern.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="LQ77YLfPrO/qF/pM" Content-Disposition: inline In-Reply-To: <110420080625.ZM16423@torch.brasslantern.com> User-Agent: Mutt/1.5.21 (2010-09-15) --LQ77YLfPrO/qF/pM Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Bart Schaefer wrote: > > I can use suffix aliases to display various .txt files. > > Can I do a similar thing for README files? So the "command" > >=20 > > /some/path/README > >=20 > > will really run the command=20 > >=20 > > less /some/path/README >=20 > Depending on your version of zsh, you can do this either with the > zle-line-finish widget or by replacing the accept-line widget. >=20 > zle-line-finish() { > setopt localoptions extendedglob > if [[ -z "$PREBUFFER" && "$BUFFER" =3D ([^[:space:]]#/)#README ]] > then BUFFER=3D"less $BUFFER" > fi > } > zle -N zle-line-finish >=20 > Or >=20 > accept-line() { > setopt localoptions extendedglob > if [[ -z "$PREBUFFER" && "$BUFFER" =3D ([^[:space:]]#/)#README ]] > then BUFFER=3D"less $BUFFER" > fi > zle .accept-line "$@" > } > zle -N accept-line =20 Is there any way to get either of these to work without changing the command that is stored in history? So the history contains '/some/path/README' and = not 'less /some/path/README'? --=20 John Eikenberry [ jae@zhar.net - http://zhar.net ] [ PGP public key @ http://zhar.net/jae_at_zhar_net.gpg ] ________________________________________________________________________ "Perfection is attained, not when no more can be added, but when no more=20 can be removed." -- Antoine de Saint-Exupery --LQ77YLfPrO/qF/pM Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (GNU/Linux) iQEcBAEBCAAGBQJNrxcXAAoJED2anlkTqUWiK+oH/AvzRV/+outH//7usdONI0Mw btGxSJJKWt6b5EtMhG92OABj3O+wk5ajQ2RhRYtQoS0XXW1qAEkraNmDr7zxwglA 28GQLeCYObrHYEkM2YATXtYgHfIyEpKxGamFa49q9L6yIY8lZAPcGbo3Tb2Fla0V TxmVUDc23Ku9dK1Ls4UxnVdH61WHtvj+tOLMovOEddzdV+UfsmCg3nHAkIgmn11F 165f+AMMqBtyH+x4DKS9o16aTFVVXgz3rFOaZykehR6c+SrqgWLeN5HcYcFVctsT sLzMaVQVkwcGhhmwvHDGnpNrv3lyfmz7i0Z+kMQ74cvhmx4THEahzrCmIbp+PYk= =Bub1 -----END PGP SIGNATURE----- --LQ77YLfPrO/qF/pM--