zsh-users
 help / color / mirror / code / Atom feed
From: Anthony R Fletcher <arif@mail.nih.gov>
To: <zsh-users@zsh.org>
Subject: Re: Suffix alias for README files
Date: Wed, 20 Apr 2011 12:44:37 -0400	[thread overview]
Message-ID: <20110420164437.GA25496@cosy.cit.nih.gov> (raw)
In-Reply-To: <110420080625.ZM16423@torch.brasslantern.com>

On 20 Apr 2011 at 08:06:25, 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"
> > 
> > 	/some/path/README
> > 
> > will really run the command 
> > 
> > 	less /some/path/README
> 
> Depending on your version of zsh, you can do this either with the
> zle-line-finish widget or by replacing the accept-line widget.
> 
> zle-line-finish() {
>     setopt localoptions extendedglob
>     if [[ -z "$PREBUFFER" && "$BUFFER" = ([^[:space:]]#/)#README ]]
>     then BUFFER="less $BUFFER"
>     fi
> }
> zle -N zle-line-finish
> 
> Or
> 
> accept-line() {
>     setopt localoptions extendedglob
>     if [[ -z "$PREBUFFER" && "$BUFFER" = ([^[:space:]]#/)#README ]]
>     then BUFFER="less $BUFFER"
>     fi
>     zle .accept-line "$@"
> }
> zle -N accept-line

Great, the last works for me everywhere and the first works on my newer
machines. Thanks.

> Aside to zsh-workers:
> 
> If no external command is found but a function command_not_found_handler
> exists the shell executes this function with all command line arguments.
> 
> Perhaps "command found but permission denied" should be treated the same
> as "command not found"?  Then one could handle this there as well, and
> not have to mess with widgets.  See also recent discussion of bash/zsh
> differences when the command is literally an empty string.

Thanks for mentioning "command_not_found_handler". I'd missed that one.

		Anthony.



  reply	other threads:[~2011-04-20 16:44 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-04-19 13:59 Anthony R Fletcher
2011-04-20  9:23 ` Sebastian Stark
2011-04-20 12:41   ` Anthony R Fletcher
2011-04-20 15:06     ` Bart Schaefer
2011-04-20 16:44       ` Anthony R Fletcher [this message]
2011-04-20 17:25       ` John Eikenberry
2011-04-20 18:40         ` ZyX
2011-04-20 18:57           ` John Eikenberry
2011-04-20 19:22             ` ZyX

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20110420164437.GA25496@cosy.cit.nih.gov \
    --to=arif@mail.nih.gov \
    --cc=zsh-users@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).