Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: expand-cmd-path
- X-seq: zsh-users 2909
- From: Sven Wischnowsky <wischnow@xxxxxxxxxxxxxxxxxxxxxxx>
- To: zsh-users@xxxxxxxxxxxxxx
- Subject: Re: expand-cmd-path
- Date: Fri, 4 Feb 2000 13:07:40 +0100 (MET)
- In-reply-to: Andy Spiegl's message of Fri, 4 Feb 2000 12:20:47 +0100
- Mailing-list: contact zsh-users-help@xxxxxxxxxxxxxx; run by ezmlm
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@xxxxxxxxxxxxxxxxxxxxxxx
Messages sorted by:
Reverse Date,
Date,
Thread,
Author