Is there any option I can pass to ls to hide .un~ files from the output?
I want to be able to see all files (e.g. dotfiles) except .un~ files, so I need to run ls -A
and add something to hide the .un~ files.
Homebrew does provide GNU ls
through the coreutils
package.
brew install coreutils
Then, you could alias
your system ls
to GNU ls
, which Homebrew installs as gls
instead in order to prevent overriding the usage of system binaries:
alias ls='/usr/local/bin/gls'
Alternatively, as outlined in brew info coreutils
:
If you really need to use these commands with their normal names, you can add a "gnubin" directory to your PATH from your bashrc like:
PATH="$(brew --prefix coreutils)/libexec/gnubin:$PATH"
Proceed with using GNU ls
options if they better suit your needs, e.g.
ls -B
or similarly:
alias ls='/usr/local/bin/gls --hide=*~'
ls -B
Hides backups, files ending in ~
ls
, the -B
option has a totally different meaning in OS X (or BSD ls
for that matter).
ls
, i.e. compiling and aliasing to GNU ls, thus deviating from what comes with OS X.