dotfiles/scripts/cached_pass
Geoffrey Frogeye ee178b7d57
nix: Make nix the root
Which means now I'll have to think about real prefixes in commit names.
2023-11-26 23:58:22 +01:00

31 lines
495 B
Plaintext
Executable file

#!/usr/bin/env nix-shell
#! nix-shell -i bash
#! nix-shell -p bash pass libnotify
# TODO Password changed?
set -euo pipefail
if [[ $# -ne 1 ]]
then
echo "Usage: $0 pass-name"
exit 2
fi
name="$1"
BASEDIR="/tmp/cached_pass_${UID}"
mkdir -p "$BASEDIR"
chmod 700 "$BASEDIR"
name_base64="$(echo "$name" | base64)"
file="${BASEDIR}/${name_base64}"
if [ ! -s "${file}" ]
then
notify-send -u low "cached_pass" "Asking to cache: ${name}"
pass ${name} > "${file}"
fi
cat "${file}"