Initial commit
This commit is contained in:
44
bin/fqo
Normal file
44
bin/fqo
Normal file
@ -0,0 +1,44 @@
|
||||
#!/usr/bin/bash
|
||||
# Fuzzy find a file and then check which package owns it
|
||||
|
||||
declare -r scriptname="fqo"
|
||||
|
||||
printHelp() {
|
||||
cat << helpinfo
|
||||
${scriptname} - fuzzy find a file and then check which package owns it
|
||||
|
||||
Usage: ${scriptname} [-h] [patterns]
|
||||
|
||||
Options:
|
||||
-h, --help print this help page
|
||||
helpinfo
|
||||
}
|
||||
|
||||
while true; do
|
||||
case "${1}" in
|
||||
"-h"|"--help")
|
||||
printHelp
|
||||
exit
|
||||
;;
|
||||
--)
|
||||
shift
|
||||
break
|
||||
;;
|
||||
-*)
|
||||
printf '%s\n' "Unknown option: ${1}" >&2
|
||||
exit 1
|
||||
;;
|
||||
*)
|
||||
break
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
[[ ! -x '/usr/bin/locate' ]] && echo 'locate is not present' && exit 1
|
||||
[[ ! -x '/usr/bin/fzf' ]] && echo 'fzf is not present' && exit 1
|
||||
[[ -z "${*}" ]] && printf '%s\n' "No patterns entered" >&2 && exit 1
|
||||
|
||||
file="$(locate --all --ignore-case --null -- "${@}" | fzf --exit-0 --select-1 --read0 --no-mouse)"
|
||||
[[ ! "${file}" ]] && exit 1
|
||||
|
||||
pacman -Qo "${file}"
|
Reference in New Issue
Block a user