From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5016 invoked by alias); 24 Jul 2012 15:50:02 -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: 17186 Received: (qmail 18715 invoked from network); 24 Jul 2012 15:50:01 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) 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.2 Received-SPF: none (ns1.primenet.com.au: domain at closedmail.com does not designate permitted sender hosts) From: Bart Schaefer Message-id: <120724084939.ZM6427@torch.brasslantern.com> Date: Tue, 24 Jul 2012 08:49:39 -0700 In-reply-to: Comments: In reply to "Benjamin R. Haskell" "Completion for command-not-found "commands"" (Jul 24, 12:08am) References: X-Mailer: OpenZMail Classic (0.9.2 24April2005) To: Zsh Users Subject: Re: Completion for command-not-found "commands" MIME-version: 1.0 Content-type: text/plain; charset=us-ascii On Jul 24, 12:08am, Benjamin R. Haskell wrote: } } The very-short version of my question is: How can I dynamically get } completion for `git rm` when what I've typed on the commandline so far } is `grm`? ("dynamically" meaning without defining a bunch of compdef's } up front.) You probably want to write a completer function to insert into your "completers" style. This is a crude version but mostly works: _check_for_git_alias () { [[ $words[1] = g* ]] || return 1 local al=${words[1]#g} if valid_git_alias $al || valid_git_command $al then words[1]=(git $al) ((++CURRENT)) _normal else return 1 fi } zstyle ':completion:*' completer _check_for_git_alias \ whatever you already had for this style goes here Obviously there are a bunch more tests you can do to figure out whether it's even reasonable to treat $words[1] as a git alias or command, and you may want to try this in some other ordering of the zstyle rather than right at the beginning, but hopefully this gets you started. -- Barton E. Schaefer