macOS Ventura with a 'MacPorts' installation that includes GNU replacements for numerous "Apple-sourced" utilities including ls. The original ls is located at /bin/ls, the GNU/MacPorts version of ls is located at /opt/local/libexec/gnubin/ls.
The GNU version of ls works for most things, but in some cases (one in particular) I need the "Apple-sourced" version of ls. For example, to list the 'file flags' (ref man chflags), I need the O option... the GNU version does not provide this.
I'd like to set an alias in ~/.zshrc that handles ls -lO, and possibly other options unique to the "Apple-sourced" version of ls.
I've tried several aliases in ~/.zshrc that didn't work; e.g.
alias ls -lO='/bin/ls -lO'
How to do this?
alias WORD=REPLACEMENT, but you have two words to the left of the equal sign. You could write a shell script or function ("shell script" would be more generally usable) with namels, which inspects the parameters and based on them calls the desiredls` version. However I find this fiddling withlserror prone; for instance, whichlsshould be executed forls -Ol?