From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 490 invoked from network); 4 Feb 2000 12:08:09 -0000 Received: from sunsite.auc.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 4 Feb 2000 12:08:09 -0000 Received: (qmail 17899 invoked by alias); 4 Feb 2000 12:07:46 -0000 Mailing-List: contact zsh-users-help@sunsite.auc.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 2909 Received: (qmail 17889 invoked from network); 4 Feb 2000 12:07:42 -0000 Date: Fri, 4 Feb 2000 13:07:40 +0100 (MET) Message-Id: <200002041207.NAA24156@beta.informatik.hu-berlin.de> From: Sven Wischnowsky To: zsh-users@sunsite.auc.dk In-reply-to: Andy Spiegl's message of Fri, 4 Feb 2000 12:20:47 +0100 Subject: Re: expand-cmd-path Andy Spiegl wrote: > While playing around with zle's "expand-cmd-path" I found that I'd like a > different behavior of it (similar to tcsh). I'd prefer if it didn't expand > the first word/command on the input line, but the word before the cursor. > Is that possible somehow? > > And I noticed that it does not expand aliases. Is that intended? Can it > be changed? Why not write your own little widget function? Like so: expand-last-word() { local word="${(M)LBUFFER%%[^ \;\|\{\}]##}" exp if (( $+commands[$word] )); then exp="$commands[$word]" elif (( $+aliases[$word] )); then exp="$aliases[$word]" fi [[ -n "$exp" ]] && LBUFFER="${LBUFFER%$word}$exp" } zle -N expand-last-word bindkey ... expand-last-word Plus obvious improvements: The pattern in the first line should match only thos characters that should be considered part of the word. If the cursor is after a space (or other non-word characters) it could search back for the word to expand. It could append a space to the string inserted. Etc. Bye Sven -- Sven Wischnowsky wischnow@informatik.hu-berlin.de