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 2021-09-11 06:39 PM, Lawrence Velázquez wrote:
On Sat, Sep 11, 2021, at 5:01 PM, Steve Dondley wrote:

> "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

Nice. Yeah, this annoyance has been bugging me for years. I'll share
this out to the TW community, I'm sure others will love this, too.

This is fun and all, but it's not clear to me why this is desirable
over, say:

    % tasn "call Tom's friend"

The technical answer is two-fold:

1) I may not know ahead of time if I double quotes are needed and would rather not have to go back and insert if I forget them. 2) I could address this by always putting in double quotes. But that's four keystrokes I'd rather not have to type if I don't have to. And actually, it's more like thousands upon thousand of keystrokes over a few years time. A 1/2 second here and there eventually adds up to hours typing a key I don't have. Why would I want to do that?

The non-technical answer is that computers should accommodate us, not vice versa. I shouldn't have to be knowledgeable about my shell to interact with an application. A good application should be accessible to non-technical users who may have no idea why they need to type in a slash into a sentence meant for humans to input and read.

So I can now introduce this program to my wife who knows nothing of shells and I don't have to explain to her "always surround the tasks with double quotes but if you want to use a double quote in between those quotes you have to escape it with a back slash (no, not that one, the one above the 'return' key). That would be a non-starter.

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