From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2619 invoked by alias); 20 Apr 2011 15:06:48 -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: 15972 Received: (qmail 26517 invoked from network); 20 Apr 2011 15:06:47 -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,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received-SPF: none (ns1.primenet.com.au: domain at closedmail.com does not designate permitted sender hosts) From: Bart Schaefer Message-id: <110420080625.ZM16423@torch.brasslantern.com> Date: Wed, 20 Apr 2011 08:06:25 -0700 In-reply-to: <20110420124129.GB18289@cosy.cit.nih.gov> Comments: In reply to Anthony R Fletcher "Re: Suffix alias for README files" (Apr 20, 8:41am) References: <20110419135909.GA21897@cosy.cit.nih.gov> <1590CA5C-3329-4DF1-8E73-E7FE218A21D9@biskalar.de> <20110420124129.GB18289@cosy.cit.nih.gov> X-Mailer: OpenZMail Classic (0.9.2 24April2005) To: Subject: Re: Suffix alias for README files MIME-version: 1.0 Content-type: text/plain; charset=us-ascii > 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 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.