From: Peter Stephenson <p.w.stephenson@ntlworld.com>
To: zsh-users@zsh.org
Subject: Re: Is there any possible way to automatically escape characters when executing an alias in zsh?
Date: Sat, 11 Sep 2021 21:53:43 +0100 [thread overview]
Message-ID: <b3bc02378aadd4e50efe7fab771a3a276bfda484.camel@ntlworld.com> (raw)
In-Reply-To: <01fed731885d32a336c7b0f31c8f4156@dondley.com>
On Sat, 2021-09-11 at 16:45 -0400, Steve Dondley wrote:
> On 2021-09-11 03:28 PM, Peter Stephenson wrote:
> > On Sat, 2021-09-11 at 20:16 +0100, Peter Stephenson wrote:
> > > accept-with-quote() {
> > > if [[ $BUFFER = 'tasn '* && $BUFFER != *\\* ]]; then
> > > BUFFER=${BUFFER//\'/\\\'}
> > > fi
> > > }
> > > zle -N zle-line-finish accept-quote
>
> Very cool. It works! No idea what the zle command does but I'll google
> it. Thanks!
>
> I have a number of aliases that begin with "ta" and "tm" that could
> benefit from this trick. I imagine I could turn the 'tasn '* bit into a
> regex test to check for a match.
"man zshzle" will tell you about special widgets. Basically, they're
just user defined commands that instead of being called by a keystroke
are called at particular points during editing.
The test is just an ordinary zsh pattern, as used for globbing / file
matching, so it's easy to extend...
if [[ $BUFFER = (tasn|taxx|tmxx)' '* && $BUFFER != *\\* ]]; then
...
pws
next prev parent reply other threads:[~2021-09-11 20:54 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-09-11 18:41 Steve Dondley
2021-09-11 19:00 ` zzapper
2021-09-11 19:16 ` Peter Stephenson
2021-09-11 19:28 ` Peter Stephenson
2021-09-11 20:45 ` Steve Dondley
2021-09-11 20:53 ` Peter Stephenson [this message]
2021-09-11 21:01 ` Steve Dondley
2021-09-11 22:39 ` Lawrence Velázquez
2021-09-11 23:15 ` Steve Dondley
2021-09-12 0:23 ` Bart Schaefer
2021-09-12 1:27 ` Steve Dondley
2021-09-12 2:26 ` Bart Schaefer
2021-09-12 3:02 ` Steve Dondley
2021-09-11 23:17 ` Bart Schaefer
2021-09-11 23:33 ` Steve Dondley
2021-09-12 3:33 ` Ray Andrews
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=b3bc02378aadd4e50efe7fab771a3a276bfda484.camel@ntlworld.com \
--to=p.w.stephenson@ntlworld.com \
--cc=zsh-users@zsh.org \
/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).