mirror of
https://github.com/artizirk/dotfiles.git
synced 2024-11-22 16:30:59 +02:00
Add Nitrokey Start Identity switch command
Uses gnupg scdaemon directly instead of killing and bypassing it like nitropy set-identity command
This commit is contained in:
parent
d8c80454ed
commit
71331702a5
23
.zshrc
23
.zshrc
@ -279,3 +279,26 @@ if [[ -e /dev/lxss ]]; then
|
|||||||
# Create pretty serial device names
|
# Create pretty serial device names
|
||||||
reg.exe query HKLM\\HARDWARE\\DEVICEMAP\\SERIALCOMM | awk '/Device/ {gsub("\r","",$3); print "/dev/ttyS" substr($3,4), "/dev/tty" substr($1,9)}' | sudo xargs -n2 ln -sf
|
reg.exe query HKLM\\HARDWARE\\DEVICEMAP\\SERIALCOMM | awk '/Device/ {gsub("\r","",$3); print "/dev/ttyS" substr($3,4), "/dev/tty" substr($1,9)}' | sudo xargs -n2 ln -sf
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
function nitroid {
|
||||||
|
# Switch Nitrokey Start Identity
|
||||||
|
# https://github.com/Nitrokey/pynitrokey/tree/70398d9d87d002c14402591dfa6e4fe9e7182351#switching-id
|
||||||
|
|
||||||
|
local ID=$1
|
||||||
|
|
||||||
|
if ! [[ "$ID" =~ [0-2] ]]; then
|
||||||
|
echo "Usage: $0 ID"
|
||||||
|
echo "Where identity ID is in range 0-2"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if gpg-connect-agent --hex "scd apdu 00 85 00 0$ID" /bye | grep -q ERR; then
|
||||||
|
sleep 1
|
||||||
|
gpg-connect-agent --decode "scd serialno" /bye
|
||||||
|
else
|
||||||
|
echo "already set"
|
||||||
|
fi
|
||||||
|
|
||||||
|
}
|
||||||
|
compdef 'compadd -X "Identity" 0 1 2' nitroid
|
||||||
|
Loading…
Reference in New Issue
Block a user