Hiding emacs backup files in Finder

I would like to find a way to hide all the *~ files in Finder, which are used as backup files by Emacs. Is there a general approach to make Finder hide all the files with their names matching certain patterns? Thanks.


If you don't like all the #*# and *~ files floating around in your working directory, put the following elisp code in your .emacs file.

;; Put autosave files (ie #foo#) and backup files (ie foo~) in ~/.emacs-backups/.
(custom-set-variables
  '(auto-save-file-name-transforms '((".*" "~/.emacs-backups/autosaves/\\1" t)))
  '(backup-directory-alist '((".*" . "~/.emacs-backups/backups/"))))

;; create the autosave dir if necessary, since emacs won't.
(make-directory "~/.emacs-backups/autosaves/" t)

Reference: http://snarfed.org/gnu_emacs_backup_files


If you want to hide a file from GUI you can use chflags utility, e.g.

chflags hidden *~

As a permanent solution you can install a launchd agent with command

find $HOME -type f -name '*~' -exec chflags hidden '{}' ';'

I used Lingon for that.