From 7602e70ac45fb757acbc9c6e54af48828f6edbc9 Mon Sep 17 00:00:00 2001 From: self Date: Fri, 23 Sep 2022 22:54:47 +0100 Subject: Split out zshrc into several files for cleanliness --- zsh/.zshrc-mk | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'zsh/.zshrc-mk') diff --git a/zsh/.zshrc-mk b/zsh/.zshrc-mk index a93d7a0..ce1e387 100644 --- a/zsh/.zshrc-mk +++ b/zsh/.zshrc-mk @@ -2,6 +2,33 @@ mkwr() { nvim "$HOME/docs/wr/$1" } +mksec() { # Make an encrypted (secure entry). + [ -z "$DEFAULT_GPG" ] && echo "DEFAULT_GPG not set" && return + mkdir -p "/tmp/mksec" + nvim "/tmp/mksec/$1" + gpg --encrypt --armor --symmetric -r "$DEFAULT_GPG" --output "$HOME/docs/wr/sec/$1" "/tmp/mksec/$1" + rm "/tmp/mksec/$1" +} + +rdsec() { # Read a secure entry, will NOT write it back after. + [ ! -f "$HOME/docs/wr/sec/$1" ] && echo "File $1 does not exist" && return + mkdir -p "/tmp/mksec" + gpg -d --output "/tmp/mksec/$1.decrypted" "$HOME/docs/wr/sec/$1" + nvim "/tmp/mksec/$1.decrypted" + rm "/tmp/mksec/$1.decrypted" +} + +mdsec() { # Modify a secure entry, writing it back after. + [ -z "$DEFAULT_GPG" ] && echo "DEFAULT_GPG not set" && return + [ ! -f "$HOME/docs/wr/sec/$1" ] && echo "File $1 does not exist" && return + mkdir -p "/tmp/mksec" + gpg -d --output "/tmp/mksec/$1.decrypted" "$HOME/docs/wr/sec/$1" + nvim "/tmp/mksec/$1.decrypted" + gpg --encrypt --armor --symmetric -r "$DEFAULT_GPG" --output "$HOME/docs/wr/sec/$1" "/tmp/mksec/$1.decrypted" + rm "/tmp/mksec/$1.decrypted" + +} + mkrec() { mkwr "rec/$1" } -- cgit v1.2.1