--- /dev/null
+#!/bin/sh
+
+usage() {
+ echo "usage: gpotp KEY-NAME"
+}
+
+set -e
+while getopts h opt; do
+ case "$opt" in
+ h)
+ usage
+ exit 0
+ ;;
+ *)
+ usage >&2
+ exit 1
+ ;;
+ esac
+done
+shift $((OPTIND - 1))
+if [ $# -lt 1 ]; then
+ usage >&2
+ exit 1
+fi
+
+if ! echo "$1" | grep -q /; then
+ key="$HOME/passwd/otp/$1.gpg"
+else
+ key="$1"
+fi
+if [ ! -e "$key" ]; then
+ echo "gpotp: $key: does not exist" >&2
+ exit 1
+fi
+
+gpg --quiet --decrypt --armor <"$key" | (
+ read type secret dig
+ oathtool "--$type" -d "$dig" "$secret"
+)