mirror of
https://github.com/kazhala/dotbare
synced 2024-11-16 00:12:47 +00:00
feat(fgrep): added option to configure search delimiter
This commit is contained in:
parent
ce041753ff
commit
77657d3eb8
@ -202,11 +202,12 @@ function get_stash() {
|
||||
#######################################
|
||||
function grep_words() {
|
||||
local header="${1:-select matches to edit}"
|
||||
local delimiter="${2:-3}"
|
||||
set_fzf_multi "$2"
|
||||
cd "${DOTBARE_TREE}" || exit
|
||||
git --git-dir="${DOTBARE_DIR}" --work-tree="${DOTBARE_TREE}" \
|
||||
grep --line-number -- . \
|
||||
| fzf --delimiter : --nth 3.. --header="${header}" \
|
||||
| fzf --delimiter : --nth "${delimiter}".. --header="${header}" \
|
||||
--preview "${mydir}/../helper/preview.sh ${DOTBARE_TREE}/{}" \
|
||||
| awk -F ":" -v home="${DOTBARE_TREE}" '{
|
||||
print home "/" $1 ":" $2
|
||||
|
@ -26,9 +26,19 @@ Optional arguments:
|
||||
}
|
||||
|
||||
selected_lines=()
|
||||
fzf_search_delimiter=3
|
||||
|
||||
while [[ "$#" -gt 0 ]]; do
|
||||
case "$1" in
|
||||
-d|--delimiter)
|
||||
fzf_search_delimiter="$2"
|
||||
shift
|
||||
shift
|
||||
;;
|
||||
-f|--full)
|
||||
fzf_search_delimiter=1
|
||||
shift
|
||||
;;
|
||||
-h|--help)
|
||||
usage
|
||||
exit 0
|
||||
@ -52,7 +62,7 @@ while IFS= read -r line; do
|
||||
selected_lines+=("${line}")
|
||||
;;
|
||||
esac
|
||||
done < <(grep_words)
|
||||
done < <(grep_words "select matches to edit" "${fzf_search_delimiter}")
|
||||
|
||||
[[ "${#selected_lines[@]}" -eq 0 ]] && exit 1
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user