From a2b894aa4b719a34b84e573b434b2d7ea3e6b659 Mon Sep 17 00:00:00 2001 From: Kevin Zhuang Date: Tue, 28 Jul 2020 10:25:48 +1000 Subject: [PATCH] refactor(fgrep): adjust function name to be more readable --- helper/git_query.sh | 4 ++-- scripts/fgrep | 4 ++-- tests/fgrep.bats | 2 +- tests/fzf | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/helper/git_query.sh b/helper/git_query.sh index 24f04b0..25ce9c3 100644 --- a/helper/git_query.sh +++ b/helper/git_query.sh @@ -200,8 +200,8 @@ function get_stash() { # the selected file name with it's line number and line, seperated by ":" # e.g. .bash_profile:1:echo hello ####################################### -function grep_lines() { - local header="${1:-select lines to edit}" +function grep_words() { + local header="${1:-select matches to edit}" set_fzf_multi "$2" cd "${DOTBARE_TREE}" || exit git --git-dir="${DOTBARE_DIR}" --work-tree="${DOTBARE_TREE}" \ diff --git a/scripts/fgrep b/scripts/fgrep index 3eb80a4..ebe2e29 100755 --- a/scripts/fgrep +++ b/scripts/fgrep @@ -19,7 +19,7 @@ source "${mydir}"/../helper/git_query.sh function usage() { echo -e "Usage: dotbare fgrep [-h] ... -Grep words within tracked files and select to edit them through fzf. +Grep words within tracked files and select to edit matches. Optional arguments: -h, --help\t\tshow this help message and exit." @@ -52,7 +52,7 @@ while IFS= read -r line; do selected_lines+=("${line}") ;; esac -done < <(grep_lines) +done < <(grep_words) [[ "${#selected_lines[@]}" -eq 0 ]] && exit 1 diff --git a/tests/fgrep.bats b/tests/fgrep.bats index 5b5ef81..c0dc4e0 100755 --- a/tests/fgrep.bats +++ b/tests/fgrep.bats @@ -28,5 +28,5 @@ edit_lines() { @test "fgrep edit lines" { run edit_lines - [[ "${output}" =~ "fgrep_lines" ]] + [[ "${output}" =~ "fgrep_words" ]] } diff --git a/tests/fzf b/tests/fzf index 7a685fe..b027fd7 100755 --- a/tests/fzf +++ b/tests/fzf @@ -62,7 +62,7 @@ elif [[ "$*" =~ '--header=select stash to apply' ]] && [[ "$*" =~ "show -p __ -- echo "fstash_apply" elif [[ "$*" =~ '--delimiter : --nth 3..' ]]; then # dotbare fgrep -- "./fgrep.bats" @test "fgrep edit lines" - echo "fgrep_lines" + echo "fgrep_words" else echo "$@" fi