Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Is there any possible way to automatically escape characters when executing an alias in zsh?



On Sat, Sep 11, 2021 at 6:27 PM Steve Dondley <s@xxxxxxxxxxx> wrote:
>
> If I launch a command with the shell
> and pass it some argument to open up a full-blown GUI for with a
> particular color theme, that doesn't mean I'm interacting with the
> shell.

You're interacting with the up the point where you launch the command,
and then you're interacting with the application you launched.

> And what could possibly be the harm in having the shell do some typing
> for me without me having to think about it?

Having the shell do some typing for you is not the same as having the
shell ignore something you typed in a context where it would normally
pay attention.  Eventually you're going to type something the shell
should not have ignored and the wrong thing is going to happen.

See for example url-quote-magic.  That does the typing for you, and
you can see what it did to make sure it didn't do anything wrong.
PWS's solution (and even my edit thereof) change the input at a time
and place where it's too late for you to fix anything that's awry.

> > zle -N taskwarrior-literal
> > autoload add-zle-hook-widget
> > add-zle-hook-widget line-finish taskwarrior-literal
>
> Yeah, so I don't think this would work because I need <tab> for
> autocompletion. Or am I not understanding this?

You're not understanding.  Given that you said --
> minor completions (none of which will ever contain special characters
> that need to be escaped)
-- taskwarrior-literal should work fine.  As with PWS's suggestion,
this kicks in when you press enter (accept-line), so all your
completions are already out of the way, and it only quotes things that
need quoting.  The difference is that it blindly quotes ANYTHING that
might be interpreted by the shell, including filename globs, etc.




Messages sorted by: Reverse Date, Date, Thread, Author