@@ 39,9 39,9 @@ HELP
exit "${1:-0}"
}
-log() { printf '%s\n' "${*}" >&2; exit 1; }
-die() { printf '%s\n\n' "${*}" >&2; help 1; }
-check_dep() { [[ -n "$(command -v "${1}")" ]] || log "${1} not installed"; }
+die() { printf '%s\n' "${*}" >&2; exit 1; }
+die_help() { printf '%s\n\n' "${*}" >&2; help 1; }
+check_dep() { [[ -n "$(command -v "${1}")" ]] || die "${1} not installed"; }
menu() { check_dep bemenu; bemenu --prompt "${1:-${0##*/}}" | head -1; }
@@ 49,15 49,15 @@ menu() { check_dep bemenu; bemenu --prompt "${1:-${0##*/}}" | head -1; }
parse_args() {
while [[ "${#}" -gt 0 ]]; do
case "${1}" in
- -h|--help) help ;;
- -c|--copy) cmd=wl-copy ;;
- -u|--user) asset=user ;;
- -b|--both) asset=both ;;
- -o|--otp) asset=otp ;;
- -cu) cmd=wl-copy asset=user ;;
- -co) cmd=wl-copy asset=otp ;;
- -*) die "Wrong option: ${1}" ;;
- *) url="${1}"; break ;;
+ -h|--help) help ;;
+ -c|--copy) cmd=wl-copy ;;
+ -u|--user) asset=user ;;
+ -b|--both) asset=both ;;
+ -o|--otp) asset=otp ;;
+ -cu) cmd=wl-copy asset=user ;;
+ -co) cmd=wl-copy asset=otp ;;
+ -*) die_help "Wrong option: ${1}" ;;
+ *) url="${1}"; break ;;
esac
shift
@@ 92,6 92,7 @@ filter_list() {
if [[ -n "${url}" ]]; then
_url="${url#*://}"
_url="${_url%%/*}"
+ _url="${_url%%:*}"
# Get matching pass values, check (sub)domains from the right.
for _name in "${pass_list[@]}"; do
@@ 108,9 109,9 @@ filter_list() {
1) selection="${_match[0]}"; return ;;
esac
- selection="$(printf '%s\n' "${_match[@]}" | menu 'select:')"
+ selection="$(printf '%s\n' "${_match[@]}" | tac | menu 'select:')"
- [[ -n "${selection}" ]] || log 'No selection... abort.'
+ [[ -n "${selection}" ]] || die 'No selection... abort.'
}
@@ 133,6 134,7 @@ get_pass_content() {
&& content[otp]="$(pass otp "${selection}")" \
&& continue
done < <(pass "${selection}")
+ true
}