emacsdired

How to hide one dot (current directory) in Dired mode


Double dot (..) is useful since it allows navigating up one level. But I don't need the single dot... Is it possible to hide it?

enter image description here

Windows 7, Emacs 25.1, Dired+.


Solution

  • Elaborating upon my comment from https://stackoverflow.com/questions/43605918#comment74265589_43606275, you can use:

    (add-hook 'dired-mode-hook 'dired-omit-mode)
    

    to omit . and .. and certain other files by default.

    See C-hig (dired-x)Omitting Variables for more information (including how to customize what is omitted).

    In emacs 25.2 the default dired-omit-files regexp is "^\\.?#\\|^\\.$\\|^\\.\\.$" which we could alternatively set using rx like so:

    (setq dired-omit-files
          (rx (or (seq bol (? ".") "#")
                  (seq bol "." eol)
                  (seq bol ".." eol)
                  )))
    

    If you wanted to keep .. visible, you could just remove or comment out the (seq bol ".." eol) line from that code.