On Jan 04, 2024 at 15:38, Bart Schaefer wrote:
On Thu, Jan 4, 2024 at 10:10 AM Sam B. <me@xxxxxx> wrote:I'm looking for a way to disable most shell expansion for the arguments to a script or functiontodo Text inc. $var, *glob?, events!, <redirs, > (sub) & moreaccept-and-do-nothing() { BUFFER=': !#:0:s/\://:p !"'"$BUFFER" zle accept-line } zle -N accept-and-do-nothing
That looks promising. Thanks.
If "todo" is the only command for which you want this effect, you could replace the ":" with "todo".
Might want a few more. But this should only apply to these selected commands.
Mostly I'm interested joting down some plain text which could include '?!&' and have "todo" receive it all without the shell having done some magic beforehand.However, have you considered using edit-command-line (possibly repeatedly) to jot things down, and then quote-region or similar when happy before executing?
I want this to be as frictionless and quick as possible. Opening up an editor is a bit much.
This made me realise though that I don't *need* it to be quoted, I would be happy if it would escape those chars individually, either as I type or on accepting the line.
I found this very similar question[1] from a few years ago which solves the problem for quotes. I'll also try this and see if it'll work for other special chars too.
[1]: https://www.zsh.org/mla/users/2021/msg00819.htmlWill have a play with all this when back from holiday though. Silly of me to ask a question just before being AFK for a few weeks.
I'll have a read through `url-quote-magic` too, which seems to do something similar.
Thanks.
Attachment:
signature.asc
Description: PGP signature