Minor mode to cloak sensitive data
I used to use hidepw
package but it only supports a plain list of regexs and also use font locking which have some conflicts with other packages, cloak-mode
allows to setup a regex by major mode, which fits betters for my use case.
Clone this repo somewhere, and add this to your config:
(add-to-list 'load-path "path where the repo was cloned")
;; for example we load it for envrc files
(require 'cloak-mode)
(setq cloak-mode-patterns '((envrc-file-mode . "[a-zA-Z0-9_]+[ \t]*=[ \t]*\\(.*+\\)$")))
(global-cloak-mode)
(use-package cloak-mode
:ensure t
:config
(global-cloak-mode))
(use-package cloak-mode
:straight (cloak-mode
:type git
:host github
:repo "erickgnavar/cloak-mode")
:config
(global-cloak-mode))
In case we need just one pattern we can define directly as a string
(setq cloak-mode-patterns '((envrc-file-mode . "[a-zA-Z0-9_]+[ \t]*=[ \t]*\\(.*+\\)$")))
In case we need many patterns we can define a list of strings
(setq cloak-mode-patterns '((envrc-file-mode . ("first-pattern" "second pattern"))))