cleanup tracks around xtal
[hardpass.git] / oled / pass-test.sh
1 #!/bin/bash
2
3 # (c) 2016 Tobias Girstmair
4 # traverse password store on the oled
5
6 LAYER=1 #for awk call
7 SELECTED=""
8 while true; do
9 sudo ./oled_menu $(pass list $SELECTED | tail -n +2|awk -F/ "{ print \$${LAYER} }" | sed 's/\.gpg\(\x1B\[[0-9]\+m\)\{0,1\}\( ->\|$\)/\1\2/g' | uniq |cut -c 1-21|xargs echo)
10 RETVAL=$?
11
12 NEW=$(pass list $SELECTED| tail -n +2 | awk -F/ "{ print \$${LAYER} }" | uniq |head -n $((RETVAL)) | tail -n 1)
13
14 if [ -z "$SELECTED" ]; then
15 SELECTED=$NEW
16 else
17 SELECTED=${SELECTED}/$NEW
18 fi
19
20 if [[ "$SELECTED" == *.gpg ]]; then
21 # is a file
22 echo "Requested Password: $(echo $SELECTED|sed 's/\.gpg//g')"
23 echo "Username: $(echo $NEW|sed 's/\.gpg//g')"
24 # PASSWORD_STORE_GPG_OPTS="--passphrase 12345" pass show $(echo $SELECTED|sed 's/\.gpg\(\x1B\[[0-9]\+m\)\{0,1\}\( ->\|$\)/\1\2/g') | head -n 1 | xargs echo -n |sudo ./scan /dev/hidg0 2 2
25 break
26 else
27 #is a dir
28 LAYER=$((LAYER+1))
29 continue
30 fi
31 done
Imprint / Impressum