You can disable the PATTERN(QUALIFIERS)
syntax by unsetting the bare_glob_qual
option:
setopt no_bare_glob_qual
If the option extended_glob
is set (and you should set it, the only reason not to set it is for backward compatibility with rare scripts that use unusual syntax), then there is another syntax for glob qualifiers: PATTERN(#qQUALIFIERS)
. So you can still use glob qualifiers, which are one of zsh's killer features, but you'll have to type a bit more.
Zsh lets you disable wildcard expansion (globbing) altogether, and this looks like a better choice for you. If a command is prefixed by noglob
, then no globbing is performed on its arguments. For example, to be able to type URLs containing ?
as arguments to wget
, I have alias wget='noglob wget'
. If you set alias ag='noglob ag'
, you can type ag mymethod(param)
.
If ag
takes both a search pattern and file names as arguments, then disabling globbing is not good. If you're able to parse the arguments of ag
, then you can perform wildcard expansion on them. I don't know the syntax of ag
, so I'll give an example where I assume that ag
only takes options that don't take arguments, and that its first non-option argument is a pattern and the rest are files.
ag () {
local i=1
while [[ ${(P)i} = -* ]]; do ((++i)); done
if ((i < $#)); then
set -- "${(@)@[1,$i]}" $~@[$((i+1)),$#]
fi
}
alias ag='noglob ag'
ag mymethod(param)
is a syntax error in all the other shells. Disabling one of the most powerful features ofzsh
just for that sounds a bit silly to me. Just quote that. (ag 'mymethod(param)'
like in all the other shells). – Stéphane Chazelas Aug 7 '14 at 22:31alias ag='noglob ag'
if you want to disable globbing in the arguments toag
. – Stéphane Chazelas Aug 7 '14 at 22:47ag
? – Gilles 'SO- stop being evil' Aug 8 '14 at 0:18