Added script

This commit is contained in:
Marco Raber 2020-08-23 01:00:30 +02:00
parent 57f20aa79b
commit 28563efe0c
2 changed files with 34 additions and 1 deletions

View File

@ -2,7 +2,7 @@
Bash script that copies passwords into the clipboard from the bitwarden-cli Bash script that copies passwords into the clipboard from the bitwarden-cli
## Installation ## Installation
Download the file, make it executable, run, enjoy Download the file, make it executable (`chmod +x /path/to/bwSearch`), run, enjoy
## Usage ## Usage
`bwSearch name_of_the_website` `bwSearch name_of_the_website`

33
bwSearch Executable file
View File

@ -0,0 +1,33 @@
#!/bin/bash
export BW_SESSION="I3J/FBkJVUwu+Aa2vRBuHZYxZ66kGKJ4TQa2km3JhxI9WfSLRMl2Ew0BxlNMrGMMGxfqH56MYEc5pW+xszGZww=="
[[ $# -eq 0 ]] && query=$(zenity --entry --text="Sito" --entry-text="git..") || query=$@
usersdmenu=""
userssplit=""
passwords=""
json=$(bw list items --search $query)
length=$(bw list items --search $query | jq -r 'length')
for row in $(echo "${json}" | jq -r '.[] | @base64'); do
_jq() {
echo ${row} | base64 --decode | jq -r ${1}
}
# echo $(_jq '.login.username')
user="$(echo $(_jq '.login.username'))"
usersdmenu="$usersdmenu$user\n"
userssplit="$userssplit$user,"
password="$(_jq '.login.password')"
passwords="$passwords$password,"
done
IFS=","
read -r -a usersarray <<< "$userssplit"
read -r -a passwordsarray <<< "$passwords"
unset IFS
[[ $length -eq 1 ]] && scelta=${usersarray[0]} || scelta="$(echo -e $usersdmenu | dmenu)"
for index in "${!usersarray[@]}"
do
# echo "$index ${sarray[index]}"
[[ ${usersarray[index]} = $scelta ]] && echo "${passwordsarray[index]}" | xclip -selection c && notify-send Found "copied to clipboard password of user:${usersarray[index]}, site:$query"
done