From: Sven Wischnowsky <wischnow@informatik.hu-berlin.de>
To: zsh-users@sunsite.auc.dk
Subject: Re: expand-cmd-path
Date: Fri, 4 Feb 2000 13:07:40 +0100 (MET) [thread overview]
Message-ID: <200002041207.NAA24156@beta.informatik.hu-berlin.de> (raw)
In-Reply-To: Andy Spiegl's message of Fri, 4 Feb 2000 12:20:47 +0100
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
next reply other threads:[~2000-02-04 12:08 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2000-02-04 12:07 Sven Wischnowsky [this message]
-- strict thread matches above, loose matches on Subject: below --
2000-02-04 11:20 expand-cmd-path Andy Spiegl
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200002041207.NAA24156@beta.informatik.hu-berlin.de \
--to=wischnow@informatik.hu-berlin.de \
--cc=zsh-users@sunsite.auc.dk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).