2

To list all docker repositories I need to use an asterisk. But I am forced to add quotes because zsh globbing catches the asterisk.

sudo docker image list "hub.local/*"

I try aliasing with noglob, but sudo will fail, and docker needs sudo

alias docker="noglob docker"

I thought I could set zsh to not complain when it fails to match, but it seems zsh will remove the asterisk anyway.

setopt nomatch

I want to either disable zsh globbing entirely, or get zsh to pass through the globbing character if it fails to match. Or possibly set zsh globbing to behave like bash. I want to get around typing quotes all the time.

caduceus
  • 145

1 Answers1

2
alias docker='noglob sudo docker'

Would cause globs to never be expanded on a line that starts with docker and would run docker under sudo. If you still occasionally need to run docker not as root, you could make it a sudo-docker or sdocker alias instead.

I wouldn't recommend enabling the Bourne/bash behaviour which is really a bad design and is dangerous, but it you really wanted to, that could be done with set +o nomatch (or setopt nonomatch or unsetopt nomatch...).