Original answer: Regarding noglob behavior itself, I'm fairly certain the answer is "No", per this Github issue.
Edit/Update: But given the use-case you describe in the comments, there may be another way to avoid typing the quotes, albeit nowhere near as straightforward as noglob.
For the sake of keeping this as simple as possible, I deviated slightly from your example in the comments. According to that example, you use noglob in zsh to create an alias so that:
findf /path/*.ext maps to find /path -name "*.ext"
I went with using a space to separate the path and the name into two distinct parameters:
findf /path *.ext maps to find /path -name "*.ext"
Well, sort of - At least that's what you would type. The workaround in this case is to get fish to add the surrounding quotes for you automatically when you type an argument to findf with a * wildcard.
To do that, set up three functions (two of them are just one-liners), all in ~/.config/fish/functions:
findf.fish:
function findf --description 'alias findf=find {path} -name {name}'
find $argv[1..-2] -name $argv[-1]
end
Pretty straightforward - Just passes the last argument to findf as the -name argument to find.
Then the real workhorse. findf_binding.fish:
function findf_binding
commandline -i '*'
set -l tokens (commandline -bo)
if test (count $tokens) -gt 0
and [ $tokens[1] = "findf" ]
set -l currentToken (commandline -t)
if not contains "\"" (string split "" $currentToken)
set -l replaceToken "\""$currentToken"\""
set -l cursorPos (commandline --cursor)
commandline -t $replaceToken
commandline --cursor (math $cursorPos+1)
end
end
end
This basically boils down to "If * is pressed, and the line starts with findf, and argument with the * isn't quoted already, then quote it and move the cursor after the *."
Finally, bind the * to the findf_binding in fish_user_key_bindings.fish:
function fish_user_key_bindings
bind '*' findf_binding
end
Full disclosure - This is my first keybinding script in fish. It's a fish feature that I've been wanting to learn/try out for a while now, and I saw this as a good opportunity. As a result, though, there are undoubtedly some corner cases that I missed, and style or syntax improvements that could be made.
For instance, as a known limitation, if you ever want to use wildcards to match multiple paths (e.g. findf path* *.yaml) this binding will erroneously add quotes to the path component as well.
But hopefully this gets you close to what you are looking for, or at least puts you on the right track to tweak it or write your own.
noglobbehavior? I'm guessing it's something more subtle than the command-line usage you demonstrated itself. – NotTheDr01ds Jan 05 '21 at 20:59find /path -name "*.ext", and I shortened that with a zsh noglob alias to simply dofindf /path/*.extwhich finds all files in all subdirs under path, including those in /path. I've used '**' wildcards in fish. I'm perfectly open to the answer being "No", and I'm not a great fan of noglob either. But it is nice to have a function or alias with the noglob in it when I don't want to have to put quotes around args all the time. I'm just getting familiar with with fish recently, and this is one small thing I came across. – snapshoe Jan 05 '21 at 23:03aliascase is greatly simplified by havingnoglobprecede the command. Do you use additionalfindarguments withfindfor always as above? Can you provide your entire alias here? I think I might have a fish alternative. – NotTheDr01ds Jan 06 '21 at 23:27find /path**.extand other incantations led me to post this question. – snapshoe Jan 07 '21 at 16:40