From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12865 invoked by alias); 4 Nov 2014 11:42:29 -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: 19338 Received: (qmail 5429 invoked from network); 4 Nov 2014 11:42:27 -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=-6.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_HI, SPF_HELO_PASS autolearn=ham version=3.3.2 X-AuditID: cbfec7f5-b7f956d000005ed7-24-5458b944c0e3 Date: Tue, 04 Nov 2014 11:32:19 +0000 From: Peter Stephenson To: zsh-users@zsh.org Subject: Re: Multi-word aliases? Message-id: <20141104113219.03a4a527@pwslap01u.europe.root.pri> In-reply-to: <20141104104339.GA6255@linux.vnet.ibm.com> References: <20141104090838.GA27526@linux.vnet.ibm.com> <20141104095650.3f198112@pwslap01u.europe.root.pri> <20141104104339.GA6255@linux.vnet.ibm.com> Organization: Samsung Cambridge Solution Centre X-Mailer: Claws Mail 3.7.9 (GTK+ 2.22.0; i386-redhat-linux-gnu) MIME-version: 1.0 Content-type: text/plain; charset=US-ASCII Content-transfer-encoding: 7bit X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFuphluLIzCtJLcpLzFFi42I5/e/4FV2XnREhBttu61nsOLmS0YHRY9XB D0wBjFFcNimpOZllqUX6dglcGQvvZhT0c1e8uf6JvYHxKUcXIyeHhICJxPc7f5ghbDGJC/fW s3UxcnEICSxllNiwdA8TlMMk8eDJXkaQKhYBVYnONVuYQGw2AUOJqZtmg8VFBEQllq/YzA5i CwsoSEw/2gM0iYODV8Be4s+JKpAwp4C5xJfVXVALZjFKHPj6hgUkwS+gL3H17ycmiCvsJWZe OQM2k1dAUOLH5HtgNcwCWhKbtzWxQtjyEpvXvGWewAg0BaFsFpKyWUjKFjAyr2IUTS1NLihO Ss810itOzC0uzUvXS87P3cQICcGvOxiXHrM6xCjAwajEw7siPiJEiDWxrLgy9xCjBAezkgjv 6iqgEG9KYmVValF+fFFpTmrxIUYmDk6pBkbhrDjBXx/mXmGX+Hne6oE137rd56KPOh/5zP41 q+Lm4khVj9snZ+6Of/CpO3wBg4NGhvGvIEXOpIImgctVz+Q8V0Y5PXrbqJRYnXVX/qT5AW8J K5dW9ZevfZfEvhHZr6tU8PL6t5A7/yfekstdX8xSpXfkZnfG0zurSnreL+H/xjCTx4gp3lSJ pTgj0VCLuag4EQC1TrMzHwIAAA== On Tue, 04 Nov 2014 11:43:39 +0100 Dominik Vogt wrote: > 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. Yes, the space triggers the expansion. Then the resulting token is passed up to the lexical analyser. There's no obvious way of having it expand multi-word aliases without it not being able to parse token by token. This rather destroys the shell's ability to parse at all. > 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'm not sure if you mean "on a command line passed to a script" or "on a command line I'm editing". In context, I'm assuming the former. In that case you can do stuff like integer index=${argv[(I)rebase]} if (( index )); then argv[index]=(rebase --keep-empty) fi The way I've done it it's been careful about keeping command line elements separate; there's no problem with word-splitting. Tested, for once. You could do that in a git wrapper, but you still have the problem that the "rebase" could be some later argument along the command line (or even an argument to a global option). pws