Using dired-omit-file, I have a regex to find (and filter) all dot files. The issue being, I want to keep the . and .. in the listing of files.
This is the code I currently have:
(add-hook 'dired-mode-hook
(lambda ()
(setq dired-omit-files
(concat dired-omit-files "\\|^\\..+$"))))
How can I refine it to output what I wish?
My short answer is:
^\\.\\w.*$
Explanation: A string starting with '.' followed by a WORD, followed by 0 or more arbitrary symbols. The WORD excludes '.' character and makes sure you will keep you '.' and '..' entries.
If you want to learn more about regular expressions you can read the section in the emacs manual here: http://emacswiki.org/emacs/RegularExpression
Another really good way to test your regular expressions is the regular expressions builder that is build into emacs. M-x regexp-builder
. You can go into your *scratch*
buffer and write down some file names. Once you have a few, call the regexp-builder and it will highlight everything that matches your regular expression.