configuration.nix/bin/ks

23 lines
443 B
Plaintext
Raw Permalink Normal View History

2023-12-16 08:40:35 +01:00
#!/usr/bin/env bash
doc_dir=$(xdg-user-dir DOCUMENTS)
ks_dir="$doc_dir/ks"
name="$1"
2023-12-16 11:19:57 +01:00
full_path="$ks_dir/$name.md.gpg"
tmpfile="/tmp/$name.md"
2023-12-16 08:40:35 +01:00
mkdir -p "$ks_dir"
2023-12-16 11:19:57 +01:00
cd "$ks_dir"
2023-12-16 08:40:35 +01:00
2023-12-16 11:19:57 +01:00
if [ -f "$full_path" ]; then
gpg --decrypt -o "$tmpfile" "$full_path"
else
touch "$tmpfile"
fi
2023-12-16 08:40:35 +01:00
2023-12-16 11:19:57 +01:00
$EDITOR "$tmpfile"
gpg --encrypt -r ivan@idimitrov.dev -o "$full_path" "$tmpfile"
2023-12-16 08:40:35 +01:00
2023-12-16 15:04:06 +01:00
git add . && git commit -m "editing $name" && git push --set-upstream origin HEAD