Bw : Add bash wrappers.
This commit is contained in:
parent
b394a57bf4
commit
e59d82784e
|
@ -13,8 +13,8 @@
|
|||
}
|
||||
|
||||
# Unlock encrypted disk file.
|
||||
# Usage: unlock <FILE> <DIR>
|
||||
function unlock() {
|
||||
# Usage: funlock <FILE> <DIR>
|
||||
function funlock() {
|
||||
if [[ "''${UID}" != 0 ]]; then
|
||||
_error "Must be root."
|
||||
return 2
|
||||
|
@ -24,7 +24,7 @@
|
|||
local dir="''${2}"
|
||||
|
||||
if [[ "''${dir}" = "" ]]; then
|
||||
help unlock
|
||||
help funlock
|
||||
return 2
|
||||
fi
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
{ ... }: {
|
||||
text = ''
|
||||
# Check smartcard pin.
|
||||
function pincheck() {
|
||||
function scunlock() {
|
||||
pkill keyboxd &> /dev/null
|
||||
# pkill gpg-agent &> /dev/null
|
||||
echo verify | gpg --card-edit --no-tty --command-fd=0
|
||||
|
|
58
home/program/bash/module/Password.nix
Normal file
58
home/program/bash/module/Password.nix
Normal file
|
@ -0,0 +1,58 @@
|
|||
{ ... }: {
|
||||
text = ''
|
||||
# Setup the pw manager.
|
||||
function pwsetup() {
|
||||
bw config server 'https://pass.voronind.com'
|
||||
bw login
|
||||
}
|
||||
|
||||
# Unlock the vault for current shell.
|
||||
function pwunlock() {
|
||||
if [ -z ''${BW_SESSION} ]; then
|
||||
export BW_SESSION=$(bw unlock --raw)
|
||||
fi
|
||||
}
|
||||
|
||||
# Lock the vault for current shell.
|
||||
function pwlock() {
|
||||
bw lock
|
||||
unset BW_SESSION
|
||||
}
|
||||
|
||||
# List all password entries.
|
||||
function pwlist() {
|
||||
bw list items | jq -r '.[] | .name'
|
||||
}
|
||||
|
||||
# Get entry data.
|
||||
# Usage: pwget <NAME>
|
||||
function pwget() {
|
||||
local IFS=$'\n'
|
||||
local entry="''${*}"
|
||||
|
||||
if [[ "''${entry}" = "" ]]; then
|
||||
help pwget
|
||||
return 2
|
||||
fi
|
||||
|
||||
local ids=($(_pwids "''${entry}"))
|
||||
|
||||
for id in "''${ids[@]}"; do
|
||||
local result=($(bw get item "''${id}" | jq -r '(.name), (.login | .username, .password, .uris[].uri)'))
|
||||
local name="''${result[0]}"
|
||||
local login="''${result[1]}"
|
||||
local password="''${result[2]}"
|
||||
local urls=(''${result[@]:3})
|
||||
|
||||
printf "\nName: %s\n" "''${name}"
|
||||
printf "Login: %s\n" "''${login}"
|
||||
printf "Password: %s\n" "''${password}"
|
||||
printf "Url: %s\n" "''${urls[@]}"
|
||||
done
|
||||
}
|
||||
|
||||
function _pwids() {
|
||||
bw list items | jq -r '.[] | select(.name | match(".*'$*'.*")) | .id'
|
||||
}
|
||||
'';
|
||||
}
|
Loading…
Reference in a new issue