From 63de85e5706030fe302681edb5e9ac2055786801 Mon Sep 17 00:00:00 2001 From: James Blair Date: Sun, 19 Mar 2023 21:31:12 +1300 Subject: [PATCH] Added automated totp followup for bwgp helper. --- .bashrc | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/.bashrc b/.bashrc index 601f662..e8e681a 100644 --- a/.bashrc +++ b/.bashrc @@ -32,7 +32,16 @@ alias gpa='git remote | xargs -L1 git push --all' # simplify bitwarden cli usage cpcmd="xclip -selection c"; if [[ "$XDG_SESSION_TYPE" == "wayland" ]]; then cpcmd="wl-copy"; fi alias bwu='export BW_SESSION=$(bw unlock --raw > ~/.bw_session && cat ~/.bw_session)' -function bwgp () { local test=$(export BW_SESSION=~/.bw_session) && bw get password "$1" | $cpcmd; } + +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 + if totp=$(bw get totp "$1"); then + read -p "Press enter when ready for totp" + echo "${totp}" | $cpcmd + fi +} function bwgt () { local test=$(export BW_SESSION=~/.bw_session) && bw get totp "$1" | $cpcmd; } function bwgi () { local test=$(export BW_SESSION=~/.bw_session) && bw get item --pretty "$1"; } function bwli () { local test=$(export BW_SESSION=~/.bw_session) && bw list items --search "$1" --pretty | egrep -i 'name|"id":'; }