nix-files/pkgs/additional/sane-scripts/src/sane-secrets-dump

14 lines
494 B
Plaintext
Executable File

#!/usr/bin/env nix-shell
#!nix-shell -i bash -p gnugrep -p oath-toolkit -p sops
# use: `sane-dump-secret /path/to/accounts/website.yaml`
# dumps relevant information about the account, include a OTP code if present
secrets=$(sops -d --output-type dotenv $1)
function get_value() {
echo "$secrets" | grep "^$1=" | cut -d '=' -f 2-
}
echo username: $(get_value username)
echo password: $(get_value password)
totp=$(get_value totp-b32)
[[ -z "$totp" ]] || echo totp: $(oathtool -b --totp $totp)