From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25602 invoked from network); 20 Feb 2001 19:03:03 -0000 Received: from sunsite.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 20 Feb 2001 19:03:03 -0000 Received: (qmail 28872 invoked by alias); 20 Feb 2001 19:02:58 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 13511 Received: (qmail 28861 invoked from network); 20 Feb 2001 19:02:58 -0000 Message-ID: To: zsh-workers@sunsite.dk (Zsh hackers list) Subject: Re: Expanding interactively aliases In-Reply-To: Your message of "Tue, 20 Feb 2001 15:45:44 GMT." Date: Tue, 20 Feb 2001 19:02:31 +0000 From: Peter Stephenson I wrote: > expand-alias() { > # for safety, in case there's an = which will mess things up... > local alias=${LBUFFER#*=} > > if ! alias=$(alias $LBUFFER); then > zle beep > return 1 > fi > > LBUFFER=${(Q)${alias#*=}} > } > zle -N expand-alias > bindkey '^xa' expand-alias Here's this as a completer, _expand_alias. I decided there wasn't enough common ground with _expand to put it there. Could be tweaked: - checking for being the first word isn't good enough for knowing whether aliases should be expanded - probably need some other way of skipping it --- you may find you want to complete a command rather than expanding an alias - should probably be some style to force expansion in any position. - Sven can probably do it better anyway. No documentation until all this gets decided. Just stick it in your list of completers around where _expand goes or would go. ## --- start --- ## #autoload local word tmp expl # Completer to expand aliases. Doesn't seem to have enough natural # connection with normal expansion to put it in _expand. if [[ "$funcstack[2]" = _prefix ]]; then word="$IPREFIX$PREFIX$SUFFIX" else word="$IPREFIX$PREFIX$SUFFIX$ISUFFIX" fi [[ $CURRENT -eq 1 ]] || return 1 tmp="$(alias ${word#*=} 2>/dev/null)" || return 1 _wanted aliases expl alias compadd -UQ ${(Q)${tmp#*=}} ## --- end --- ## -- Peter Stephenson Software Engineer Cambridge Silicon Radio, Unit 300, Science Park, Milton Road, Cambridge, CB4 0XL, UK Tel: +44 (0)1223 392070