For context, I'm using zsh. Every time I use locate
, I want to pass the -i
and -A
flags.
Usually, if I can get away with it, I create an alias
with the same name as the existing command to do this. But according to this question, aliases can't accept arguments, so I have to use a function instead. Usually I stop there because the idea of a function with the same name as a command feels wrong to me, though I can't say why.
I was about to finally create such a function when I had this thought: this is a common pattern for me, wanting to default flags for command; is there an easier way of going about it? Perhaps zsh provides a better solution to this problem?
That brought me to another thought: is it an anti-pattern to override an existing command? I've always done it because it allows me to skip an association in my head: e.g., "Why doesn't ll
have a man
page? Oh yeah: ll
really means ls -la
. I need to do man ls
, not man ll
. Etc."
To summarize:
- Is it alright/idiomatic to override an existing command with an alias/function?
- Does zsh or some other tool provide a more direct way to default flags for a specific command?