#!/bin/sh -e
# extracted from https://rgz.ee/bin/pass

totp_seed="$(kanako -v "$@" | grep 'totp: ' | head -n1 | cut -d' ' -f2)"
if ! [ -z "$totp_seed" ]; then
    if command -v oathtool >/dev/null 2>&1; then
	oathtool --totp -b "$totp_seed"
    else
	echo 'oathtool(1) should be installed'
	exit 1
    fi
fi
