Compare commits

..

No commits in common. "846c6793538514a2ea8bbbddad5ff82fddf21a33" and "96728de2735792c2c0c648d2746390cbe2e706c4" have entirely different histories.

View file

@ -71,19 +71,6 @@ _picker() {
exit 1 exit 1
fi fi
} }
# copies to clipboard, removes any trailing newlines,
# and only keeps it in for 1 paste (1 loop to read in script, 1 to output)
_clipper() {
if command -v wl-copy 1>/dev/null 2>/dev/null; then
wl-copy -o -n
elif command -v xclip 1>/dev/null 2>/dev/null; then
xclip -i -selection 'clipboard' -loops 2 -rmlastnl
elif command -v xsel 1>/dev/null 2>/dev/null; then
xsel -b
else
notify-send "No clipboard utility" "Install wl-copy, xclip or xsel."
fi
}
# parse, see https://unix.stackexchange.com/a/331965/8541 # parse, see https://unix.stackexchange.com/a/331965/8541
_parse_config() { _parse_config() {
@ -177,6 +164,7 @@ clip_password() {
_p_get_field() { _p_get_field() {
local gp_entry="$1" local gp_entry="$1"
local gp_field="$2" local gp_field="$2"
local clip="$3"
# return on first successfully returned key # return on first successfully returned key
for key in $gp_field; do for key in $gp_field; do
@ -185,8 +173,24 @@ _p_get_field() {
# found entry # found entry
if [ -n "$value" ]; then if [ -n "$value" ]; then
if [ -n "$clip" ]; then
# copies to clipboard, removes any trailing newlines,
# and only keeps it in for 1 paste (1 loop to read in script, 1 to output)
if command -v wl-copy; then
echo "$value" | wl-copy -o && break
elif command -v xclip; then
echo "$value" | xclip -i -selection 'clipboard' -loops 2 -rmlastnl && break
elif command -v xsel; then
echo "$value" | xsel -b && break
else
notify-send "No clipboard utility" "Install wl-copy, xclip or xsel."
fi
else
echo "$value" && break echo "$value" && break
fi fi
fi
done done
} }
@ -203,16 +207,12 @@ _p_get_key_value() {
} }
# return username for argument passed # return username for argument passed
# Prefers in-metadata username, falls back to filename
show_username() { show_username() {
result=$(_p_get_field "$1" "${PASS_USERNAME_FIELD}") _p_get_field "$1" "${PASS_USERNAME_FIELD}"
if [ -z "$result" ]; then
echo "${1##*/}"
fi
} }
clip_username() { clip_username() {
show_username "$1" "${PASS_USERNAME_FIELD}" | _clipper _p_get_field "$1" "${PASS_USERNAME_FIELD}" "-c"
} }
show_field() { show_field() {
@ -220,7 +220,7 @@ show_field() {
} }
clip_field() { clip_field() {
show_field "$1" "$2" | _clipper _p_get_field "$1" "$2" "-c"
} }
list_fields() { list_fields() {