5 if ! command -v oathtool > /dev/null 2>&1; then
6 echo "Note: you need to install oathtool or oath-toolkit, depending on your OS or distribution."
10 if ! command -v gpg > /dev/null 2>&1; then
11 echo "Note: you need to install gpg and create an ID using 'gpg --gen-key', unless you have one already."
17 if [[ -z "$1" ]]; then
18 echo "usage: $0 <profile.name>"
20 elif [ ! -f $OTP_HOME/$1.otp.asc ]; then
21 echo "missing profile $1, you might need to create it first using otp_add_device"
24 totpkey=$(gpg --decrypt $OTP_HOME/$1.otp.asc)
25 oathtool --totp --b $totpkey | tee /dev/stderr | clipcopy
29 function otp_add_device () {
30 if [[ "x$1" == "x" ]] then
31 echo "usage: $0 <profile.name>"
34 echo "Enter an email address attached to your GPG private key, then paste the secret configuration key followed by ^D"
36 rm -f $OTP_HOME/$1.otp.asc
37 gpg --armor --encrypt --output $OTP_HOME/$1.otp.asc /dev/stdin
41 function otp_devices () {
42 reply=($(find $OTP_HOME -name \*.otp.asc | xargs basename -s .otp.asc))
45 compctl -K otp_devices ot