From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 15855 invoked by alias); 4 Nov 2014 10:43:47 -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: 19336 Received: (qmail 27842 invoked from network); 4 Nov 2014 10:43:44 -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=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.2 Date: Tue, 4 Nov 2014 11:43:39 +0100 From: Dominik Vogt To: zsh-users@zsh.org Subject: Re: Multi-word aliases? Message-ID: <20141104104339.GA6255@linux.vnet.ibm.com> Reply-To: vogt@linux.vnet.ibm.com Mail-Followup-To: zsh-users@zsh.org References: <20141104090838.GA27526@linux.vnet.ibm.com> <20141104095650.3f198112@pwslap01u.europe.root.pri> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20141104095650.3f198112@pwslap01u.europe.root.pri> User-Agent: Mutt/1.5.21 (2010-09-15) X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 14110410-0013-0000-0000-000001B9F438 On Tue, Nov 04, 2014 at 09:56:50AM +0000, Peter Stephenson wrote: > > Now, the shell already has an aliasing mechanism. For "normal" > > commands it would be just somethins like "alias ls='ls -F'" For > > now I've settled with a suboptimal approach using alises: > > > > # force treating the second argument like a command > > alias git="git " > > # aliasing rule for the first argument of git commands > > alias rebase="rebase --keep-empty" > > The usually way of handling this is to add a function that > interprets its arguments and can tweak them before passing > them through. Yes, I considered this too. But to get it right it's a lot of work, which seems to be silly for such a "small" problem. And then, if I don't do it right, using the alias approach above is much simpler and not much worse. :-/ Just to better understand the situation, is there any technical reason to limit the scope of aliases to the first word of the command line? After all, zsh already has to look everywhere for global aliases. Btw., there's no simple way to do regexp search and replace on command lines like s/^(git\w.*\wrebase\w)(.*)/\1 --keep-empty\2/ or is there? (\w is an ad-hoc expression for a token boundary) > I haven't tried myself, but presumably you tried > > git config --global alias.rebase "rebase --keep-empty" According to the man page, you can only define new aliases, not overwrite subcommands. $ man git-config ... To avoid confusion and troubles with script usage, aliases that hide existing git commands are ignored. Ciao Dominik ^_^ ^_^ -- Dominik Vogt IBM Germany