diff options
author | self <george@gabbott.dev> | 2022-09-23 22:54:47 +0100 |
---|---|---|
committer | self <george@gabbott.dev> | 2022-09-23 22:54:47 +0100 |
commit | 7602e70ac45fb757acbc9c6e54af48828f6edbc9 (patch) | |
tree | 98524e05075c5d90a02efa949a0e9212cad178a5 /zsh/.zshrc-mk | |
parent | a8fce0f82a19527a25734c317d2ef9a490a200a7 (diff) |
Split out zshrc into several files for cleanliness
Diffstat (limited to 'zsh/.zshrc-mk')
-rw-r--r-- | zsh/.zshrc-mk | 27 |
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" } |