summaryrefslogtreecommitdiff
path: root/zsh/.zshrc-mk
diff options
context:
space:
mode:
Diffstat (limited to 'zsh/.zshrc-mk')
-rw-r--r--zsh/.zshrc-mk27
1 files changed, 27 insertions, 0 deletions
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"
}