Refactoring install
This commit is contained in:
28
.local/bin/station-get-username-password
Executable file
28
.local/bin/station-get-username-password
Executable file
@@ -0,0 +1,28 @@
|
||||
#! /bin/zsh
|
||||
|
||||
local label="$1"
|
||||
|
||||
if [[ -z "$MASTERPW" ]]; then
|
||||
export MASTERPW=$(gum input --password --placeholder "Enter Enpass Master Password")
|
||||
fi
|
||||
local entry=$(enpass-cli -vault="$HOME/.local/share/Enpass/Enpass/Vaults/primary" -json -sort show "$label" | sed 's/\\/\\\\/g') # Escaping backslashes for jq
|
||||
|
||||
len=$(echo "$entry" | jq '. | length')
|
||||
if [[ $len -eq 0 ]]; then
|
||||
exit 1
|
||||
fi
|
||||
if [[ $len -gt 1 ]];then
|
||||
logins=$(echo "$entry" | jq -r '.[].login')
|
||||
|
||||
login=$(echo "$logins" | gum choose --header "Select which account to use" --selected="stofflees@gmail.com" --height=$(echo "$logins" | wc -l) --ordered)
|
||||
|
||||
entry=$(echo "$entry" | jq -c --arg login "$login" '.[] | select(.login == $login) | [.]')
|
||||
fi
|
||||
username=$(echo "$entry" | jq -r '.[].login')
|
||||
password=$(echo "$entry" | jq -r '.[].password')
|
||||
|
||||
if [[ -z "$username" || -z "$password" ]]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "$username $password"
|
||||
Reference in New Issue
Block a user