Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Improving spelling correction prompt to generate aliases for future use
- X-seq: zsh-users 12073
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: zsh-users@xxxxxxxxxx
- Subject: Re: Improving spelling correction prompt to generate aliases for future use
- Date: Sun, 21 Oct 2007 14:45:11 -0700
- In-reply-to: <200710211804.l9LI4w23004771@xxxxxxxxxxxxxxxxxxx>
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- References: <200710211804.l9LI4w23004771@xxxxxxxxxxxxxxxxxxx>
On Oct 21, 7:04pm, Peter Stephenson wrote:
}
} You could "setopt promptsubst" and have typo output the prompt (as
} well as whatever else it's doing)
I don't think that'll do what Gwern is after. He wants to feed the
results (original and suggested replacement) of spelling correction
to "typo" as command-line arguments.
E.g. he wants to do
typo ${(%):-%R} ${(%):-%r}
but he can't because prompt substitution in parameters doesn't have
access to the SPROMPT escapes.
The following works for simple commands but not loop constructs or other
compound commands:
accept-line() {
emulate -L zsh
local -a words
words=(${(z)BUFFER})
typeset -g ACCEPTED_CMD=$words[1]
zle .accept-line "$@"
}
zle -N accept-line
preexec() {
emulate -L zsh
local -a words
words=(${(z)1})
if [[ $words[1] != $ACCEPTED_CMD ]]
then
typo $ACCEPTED_CMD $words[1]
fi
}
Messages sorted by:
Reverse Date,
Date,
Thread,
Author