Retrieve totp in background for performance in .bashrc.
This commit is contained in:
19
.bashrc
19
.bashrc
@ -39,12 +39,21 @@ cpcmd="xclip -selection c"; if [[ "$XDG_SESSION_TYPE" == "wayland" ]]; then cpcm
|
|||||||
alias bwu='export BW_SESSION=$(bw unlock --raw > ~/.bw_session && cat ~/.bw_session)'
|
alias bwu='export BW_SESSION=$(bw unlock --raw > ~/.bw_session && cat ~/.bw_session)'
|
||||||
|
|
||||||
function bwgp () {
|
function bwgp () {
|
||||||
local test=$(export BW_SESSION=~/.bw_session) && bw get password "$1" | $cpcmd;
|
|
||||||
|
|
||||||
# If the login has a totp associated we should leave a follow-up prompt for it
|
# Retrieve full json
|
||||||
if totp=$(bw get totp "$1"); then
|
local test
|
||||||
read -p "Press enter when ready for totp"
|
test=$(eval $(export BW_SESSION=~/.bw_session) && bw get item "${1}");
|
||||||
echo "${totp}" | $cpcmd
|
|
||||||
|
# Update clipboard with initial value
|
||||||
|
echo ${test} | jq -r '.login.password' | "${cpcmd}"
|
||||||
|
|
||||||
|
# Check if a totp is associated
|
||||||
|
if [ $(echo ${test} | jq -r .login.totp) != "null" ]; then
|
||||||
|
|
||||||
|
# Retrieve totp in background
|
||||||
|
exec 3< <(echo $(bw get totp "${1}"))
|
||||||
|
read -r -p "Press enter when ready for totp"
|
||||||
|
read -r <&3 line && echo "${line}" | "${cpcmd}"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
function bwgt () { local test=$(export BW_SESSION=~/.bw_session) && bw get totp "$1" | $cpcmd; }
|
function bwgt () { local test=$(export BW_SESSION=~/.bw_session) && bw get totp "$1" | $cpcmd; }
|
||||||
|
|||||||
Reference in New Issue
Block a user