[PATCH] Use Vim's conceal feature to hide the password in pass edit

Guthrie McAfee Armstrong guthrie.armstrong at gmail.com
Wed Nov 15 03:32:42 CET 2017


Using pass edit will conceal the first line and start the cursor at the
second line, hiding the password unless the user intentionally reveals
it. This allows users to edit metadata without revealing the password to
the screen.
---
 contrib/vim/passconceal.vim | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)
 create mode 100644 contrib/vim/passconceal.vim

diff --git a/contrib/vim/passconceal.vim b/contrib/vim/passconceal.vim
new file mode 100644
index 0000000..10fd4fb
--- /dev/null
+++ b/contrib/vim/passconceal.vim
@@ -0,0 +1,24 @@
+"
+" Conceals the first line, containing the password, of pass(1) password files.
+" The line is revealed when the cursor moves onto it.
+"
+" Either append this to the end of your .vimrc, or install it as a plugin with
+" a plugin manager like Tim Pope's Pathogen.
+"
+" Author: Guthrie McAfee Armstrong <guthrie.armstrong at gmail.com>
+"
+
+augroup passconceal
+    autocmd!
+
+    " Create the second line if it does not already exist
+    autocmd BufNewFile,BufRead */pass.*/* if line('$') == 1 | $put _ | endif
+
+    " Jump to the second line
+    autocmd BufNewFile,BufRead */pass.*/* 2
+
+    " Conceal the first line with an asterisk
+    autocmd BufNewFile,BufRead */pass.*/* syntax match Concealed '\%1l.*' conceal cchar=*
+    autocmd BufNewFile,BufRead */pass.*/* set conceallevel=1
+
+augroup END
-- 
2.15.0



More information about the Password-Store mailing list