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

Re: strictly literal command lines?

2009/11/3 Eric De Mund <ead@xxxxxxxxx>:
> Hello,
> I'd like to be able to issue a command without any quotation characters
> or with only one quotation character at the beginning. Is this possible
> in zsh (ignore my line breaks here, done manually for legibility)?
>    % wget http://www.nytimes.com/2009/11/04/world/europe/04levistrauss\
>    .html?hp=&pagewanted=print
> In this particular example, the "&" is the problem for me. I want it
> taken literally.
> I can envision two kinds of solutions right off the bat.
> 1.  Is there a "literal-to-end-of-line" character? If the single quote
>    (') were such a character, the command would look like this:
>        % wget 'http://www.nytimes.com/2009/11/04/world/europe/04levist\
>        rauss.html?hp=&pagewanted=print
> 2.  Or is there an option to make a command line completely literal,
>    akin to noglob but stronger, in order to handle ampersands (&)s and
>    anything and everything else, too:
>        % literal wget http://www.nytimes.com/2009/11/04/world/europe/0\
>        4levistrauss.html?hp=&pagewanted=print
> Or am I missing some way of accomplishing this that already exists in
> zsh?

The easiest way is to write a ', paste, write another ' ;). Another way is
to press ctrl-space before, paste the url, then press quote-region (alt-" by
default i think). This is more keypresses than just typing the 's though.

Another way which is more automatic:
autoload -Uz url-quote-magic
zle -N self-insert url-quote-magic

Mikael Magnusson

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