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?

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.

I can't think of a scenario off the top of my head but I'm not saying you're wrong. Yes, it's hacky. However, issuing a bad command to TW is not some mission critical problem that can't be easily reversed. Doing the risk/reward calculus, it seems to have far more upsides than potential downs.

I wouldn't recommend this as an official part of the TW release, but since this is just a hack for my own use and convenience, I see no harm in deploying it.

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,

OK, right.

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.

I have modified PWS' solution to this:

accept-with-quote() {
if [[ $BUFFER = (tasn|tast|ta|tat|tm|taa|tai|tau|task)' '* && $BUFFER != *\\* ]]; then

This doesn't look nearly as elegant as your solution. But I can (mostly) understand it and modify it myself, which is probably more important for a zsh newb like me.

But huge thanks for your time and input. I enjoying kicking the ball around on this stuff. Helps me learn.

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