I recently changed my emacs config to hide backup files by prepending a dot to the file name. This got me to thinking - is there a ready way to change the behavior within Bash to use a list of arbitrary globs for what files to hide? A quick scan of the bash and ls man pages didn't turn up anything.

2 Answers
2

ls has a --hide=PATTERN option that looks like it does what you want and can be overridden to show them with -a or -A. If you want this to happen automatically, add an alias in your ~/.bashrc (or, in the likely case that there is already an alias for it, add it to that alias).

Thanks for the answer, I have just one question: why doesn't ls --hide=*1 a* not hide anything, but still lists all three a-1 a-2 a-3? I would have expected it to hide the a-1?
–
sdaauOct 11 '14 at 14:29

The a* is expanded by the shell and includes a-1. The hide option doesn't ignore files explicitly named as arguments.
–
KevinOct 11 '14 at 16:23