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.

  • 1
    If you are only concerned about Emacs backup files, would storing them all in a single folder (e.g. ~/.emacs-backups/) be an option as well? – nohillside Jun 13 '12 at 12:32
  • @patrix Thank you, I did so. Sometimes, it's easier to customize the Emacs OS than Mac OS:) – Ning Jun 13 '12 at 14:09
  • That's truly true. Please post the specific settings for backup-directory-alist etc. as the answer so others can benefit from it in the future. – nohillside Jun 13 '12 at 14:11

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/.
  '(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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .