Add fallback to entry name if no username field
Will look for the username as before within the metadata of the entry, but if there is no field which satisfies the conditions (by default being named username, user, or login), will fall back to using the entry name in pass (i.e. the filename). fixes #3
This commit is contained in:
parent
87f20b7e05
commit
846c679353
1 changed files with 7 additions and 3 deletions
10
pass-pick
10
pass-pick
|
@ -203,12 +203,16 @@ _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() {
|
||||||
_p_get_field "$1" "${PASS_USERNAME_FIELD}"
|
result=$(_p_get_field "$1" "${PASS_USERNAME_FIELD}")
|
||||||
|
if [ -z "$result" ]; then
|
||||||
|
echo "${1##*/}"
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
clip_username() {
|
clip_username() {
|
||||||
_p_get_field "$1" "${PASS_USERNAME_FIELD}" | _clipper
|
show_username "$1" "${PASS_USERNAME_FIELD}" | _clipper
|
||||||
}
|
}
|
||||||
|
|
||||||
show_field() {
|
show_field() {
|
||||||
|
@ -216,7 +220,7 @@ show_field() {
|
||||||
}
|
}
|
||||||
|
|
||||||
clip_field() {
|
clip_field() {
|
||||||
_p_get_field "$1" "$2" | _clipper
|
show_field "$1" "$2" | _clipper
|
||||||
}
|
}
|
||||||
|
|
||||||
list_fields() {
|
list_fields() {
|
||||||
|
|
Loading…
Reference in a new issue