file-scripts/bash/search.sh

17 lines
407 B
Bash
Raw Normal View History

2022-09-28 21:26:39 -07:00
# Utility functions and helpers for searching
DEFAULT_FD_OPTS=('--hidden' '--type' 'f' '--type' 'l' '--threads' "$(nproc)")
# Search and return a string with filenames delimited by \n
# Parameters:
# $1: directory
# $2-n: extra arguments
find_files() {
2022-09-30 21:36:24 -07:00
if [[ -d "$1" ]]; then
local directory="$1"
shift
fd "${DEFAULT_FD_OPTS[@]}" "$@" -- . "$directory"
else
fd "${DEFAULT_FD_OPTS[@]}" "$@"
fi
2022-09-28 21:26:39 -07:00
}