This commit is contained in:
He4eT 2024-07-11 05:45:22 +02:00
commit 9a6539919c

12
bwc
View file

@ -16,25 +16,25 @@ function save_sessionkey () {
sudo chmod 600 $sessionfile sudo chmod 600 $sessionfile
} }
copy_item_to_clipboard () { process_item () {
local id=$1 local id=$1
local login=$2 local login=$2
local sessionkey=$3 local sessionkey=$3
local totp
echo "" echo ""
echo "$(jq -r ".id" <<< $login)" echo "$(jq -r ".id" <<< $login)"
echo "$(jq -r ".name" <<< $login)" echo "$(jq -r ".name" <<< $login)"
echo "" echo ""
jq -r ".login.username" <<< $login | xclip -sel clip local username="$(jq -r ".login.username" <<< $login)"
echo "Username \"$(jq -r ".login.username" <<< $login)\" copied to clipboard." echo $username | xclip -sel clip
echo "Username \"$username\" copied to clipboard."
read -s -k $'?Press any key to copy the password...\n' read -s -k $'?Press any key to copy the password...\n'
jq -r ".login.password" <<< $login | xclip -sel clip jq -r ".login.password" <<< $login | xclip -sel clip
echo "Password copied to clipboard." echo "Password copied to clipboard."
totp=$(jq -r ".login.totp" <<< $login) local totp=$(jq -r ".login.totp" <<< $login)
if [[ $totp != "null" ]]; then if [[ $totp != "null" ]]; then
read -s -k $'?Press any key to copy the TOTP Token...\n' read -s -k $'?Press any key to copy the TOTP Token...\n'
bw get totp $id --session $sessionkey | xclip -sel clip bw get totp $id --session $sessionkey | xclip -sel clip
@ -79,7 +79,7 @@ main() {
if [[ -n $id ]]; then if [[ -n $id ]]; then
# Process the selected item # Process the selected item
local login="$(jq ".[] | select(.id == \"$id\")" <<< $logins)" local login="$(jq ".[] | select(.id == \"$id\")" <<< $logins)"
copy_item_to_clipboard $id $login $sessionkey process_item $id $login $sessionkey
else else
echo "No entry found." echo "No entry found."
fi fi