Add bash rewrites of fzf and search modules
This commit is contained in:
parent
84cb0a73d9
commit
482ef42403
8
misc/fzf
Normal file
8
misc/fzf
Normal file
@ -0,0 +1,8 @@
|
||||
#!/usr/bin/env bash
|
||||
## FZF helpers
|
||||
|
||||
FZF_OPTS=(--read0 --select-1 --exit-0 --print0)
|
||||
|
||||
run_fzf() {
|
||||
fzf "${FZF_OPTS[@]}" -- "$@"
|
||||
}
|
34
misc/search
Normal file
34
misc/search
Normal file
@ -0,0 +1,34 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Utility functions and helpers for searching
|
||||
DEFAULT_FD_OPTS=(--hidden --print0 --type f --type l --threads $(nproc))
|
||||
|
||||
# Locate options
|
||||
declare -a LOCATE_OPTS
|
||||
|
||||
# Platform-specific options
|
||||
# macOS doesn't support GNU-style long options
|
||||
if [[ "$OSTYPE" == "linux-gnu" ]]; then
|
||||
LOCATE_OPTS=(--all --ignore-case --null)
|
||||
elif [[ "$OSTYPE" == "darwin"* ]]; then
|
||||
LOCATE_OPTS=(-0 -i)
|
||||
fi
|
||||
|
||||
# Parameters:
|
||||
# $1: directory
|
||||
# $2-n: extra arguments
|
||||
find_files() {
|
||||
local directory="$1"
|
||||
shift
|
||||
fd "${DEFAULT_FD_OPTS[@]}" "$@" -- . "$directory"
|
||||
}
|
||||
|
||||
|
||||
# Parameters:
|
||||
# $1: pattern
|
||||
# $2-n: extra arguments
|
||||
locate_files() {
|
||||
local pattern="$1"
|
||||
shift
|
||||
locate "${LOCATE_OPTS[@]}" "$@" -- . "$pattern"
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user