This repository has been archived on 2024-03-28. You can view files and clone it, but cannot push or open issues or pull requests.
dotfiles/common/bin/pass-otp
2021-05-14 15:13:43 -05:00

13 lines
372 B
Bash
Executable file

#!/usr/bin/env bash
# TODO: check for pass
key="$1"; shift
args=("$@")
otp="$(set -e; pass "$key" 2>/dev/null | grep -Pi '^otp' | cut -d ':' -f 2 | sed 's/ //g')"
otp_status="$?"
[[ $otp_status != 0 ]] && { echo "pass command failed with exit code $otp_status"; exit 1; }
[[ -z $otp ]] && { echo "No OTP secret found for pass entry '$key'"; exit 2; }
simple-otp "$otp"