I would like to hide dotfiles only in the home directory in dired buffers, but I do not know how to achieve this. I have been trying with the following:
(use-package dired
:ensure nil
:commands (dired dired-jump)
:bind (("C-x C-j" . dired-jump)
(:map dired-mode-map ("C-c h" . dired-omit-mode)))
:config
(setq dired-omit-files (rx (seq bol "."))) ; hide dotfiles in dired-omit-mode
(defun najjt/dired-after-readin ()
"Turn on dired-omit-mode if current buffer is a dired buffer in the home directory."
(if (string-equal (buffer-name) "najjt") ; check if current buffer name is equal to name of home dir
(dired-omit-mode 1)
(dired-omit-mode nil)))
:hook ((dired-after-readin . (lambda () (najjt/dired-after-readin))))
)
But it seems to hide dotfiles in all directories, not just my home directory.
.dir-locals.el
may help