Commit 10ab59a6518c

Vincent Demeester <vincent@sbr.pm>
2026-01-23 10:49:54
fix(yubikey-oath): extract only OTP code, not account name
Use grep to extract just the 6-8 digit code from ykman output, fixing issue where account name prefix was also being copied. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 1bca12d
Changed files (1)
pkgs
my
scripts
pkgs/my/scripts/bin/yubikey-oath
@@ -26,8 +26,8 @@ if [ -z "$selected" ]; then
     exit 0
 fi
 
-# Get the code for the selected account
-code=$(ykman oath accounts code --single "$selected" 2>&1 | awk '{print $NF}')
+# Get the code for the selected account (extract just the digits)
+code=$(ykman oath accounts code --single "$selected" 2>&1 | grep -oE '[0-9]{6,8}')
 
 if [ -z "$code" ]; then
     notify-send "YubiKey OATH" "Failed to get code for $selected" --urgency=critical