Merge pull request #5 from numkem/picker

This commit is contained in:
Artturi 2022-01-02 19:28:08 +02:00 committed by GitHub
commit a4ddc08009
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

13
,
View File

@ -6,6 +6,17 @@
# If there are multiple candidates, the user chooses one using `fzy`.
set -euo pipefail
picker=fzy
if [ -n "${COMMA_PICKER+1}" ]; then
picker="${COMMA_PICKER}"
fi
# Test that the picker exists
if ! [ -x "$(command -v "${picker}")" ]; then
>&2 echo "picker ${picker} is not found in PATH"
exit 1
fi
if [[ $# -lt 1 ]]; then
>&2 echo "usage: , <program> [arguments]"
exit 1
@ -34,7 +45,7 @@ case "${argv0}" in
*)
attr="$(nix-locate --db "${database}" --top-level --minimal --at-root --whole-name "/bin/${argv0}")"
if [[ "$(echo "${attr}" | wc -l)" -ne 1 ]]; then
attr="$(echo "${attr}" | fzy)"
attr="$(echo "${attr}" | "${picker}")"
fi
;;
esac