2 # find the right binary under mingw, cygwin
3 for x ({/mnt,}/c/Program\ Files{,\ \(x86\)}/Yubico/YubiKey\ Manager/ykman.exe ykman) {
6 } elif [[ -v commands[$x] ]] {
10 read -s 'p?Password:'$'\n'
12 if [[ -f ./oath.txt ]] {
13 # attempt to pull from local file first
14 cat ./oath.txt | while {read -r x} {
16 [[ -n $x && ! $x =~ '^\s*#' ]] && oath+=($x)
19 # read from stdin otherwise, empty line to stop
23 [[ ! $x =~ '^\s*#' ]] && oath+=($x)
26 for x ($($yk list --serials)) {
27 # NOTE: `%$'\r'` to strip carriage return from Windows binary output
29 # WARN: delete existing codes, remove this if you don't need it
30 $yk -d $x oath accounts list -Hp $p | while {read -r y} {
31 $yk -d $x oath accounts delete -fp $p ${y/%$'\r'}
34 $yk -d $x oath accounts uri -fp $p $y