]> git.sev.monster Git - dotfiles.git/blame_incremental - bin/ykman-oath-reload
install.sh: suppress more link errors, fix l() msg
[dotfiles.git] / bin / ykman-oath-reload
... / ...
CommitLineData
1#!/bin/zsh
2# find the right binary under mingw, cygwin
3for x ({/mnt,}/c/Program\ Files{,\ \(x86\)}/Yubico/YubiKey\ Manager/ykman.exe ykman) {
4 if [[ -x $x ]] {
5 yk=$x
6 } elif [[ -v commands[$x] ]] {
7 yk=$commands[$x]
8 }
9}
10read -s 'p?Password:'$'\n'
11typeset -a oath
12if [[ -f ./oath.txt ]] {
13 # attempt to pull from local file first
14 cat ./oath.txt | while {read -r x} {
15 echo $x
16 [[ -n $x && ! $x =~ '^\s*#' ]] && oath+=($x)
17 }
18} else {
19 # read from stdin otherwise, empty line to stop
20 echo OATH URIs:
21 while {read -r x} {
22 [[ -z $x ]] && break
23 [[ ! $x =~ '^\s*#' ]] && oath+=($x)
24 }
25}
26for x ($($yk list --serials)) {
27 # NOTE: `%$'\r'` to strip carriage return from Windows binary output
28 x=${x/%$'\r'}
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'}
32 }
33 for y ("$oath[@]") {
34 $yk -d $x oath accounts uri -fp $p $y
35 echo Added $y
36 }
37}
This page took 0.045211 seconds and 4 git commands to generate.