Skip to content

Commit 407e7de

Browse files
committed
kgrep: Allow narrowing selection with --match=
Signed-off-by: Vitaly Chikunov <[email protected]>
1 parent 32dde37 commit 407e7de

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

kgrep

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ _grep=grep
1313
_setx=:
1414
grep_opt=
1515
git_fp=
16+
match=
1617
for opt do
1718
shift
1819
case "$opt" in
@@ -24,6 +25,7 @@ for opt do
2425
--first-parent) git_fp=$opt ;;
2526
-x | --extra) all=y ;;
2627
-a | --alt) alt=y ;;
28+
--match=*) match=${opt#*=} ;;
2729
-*) echo >&2 "unknown option: $opt"; exit 1 ;;
2830
*) set -- "$@" "$opt";;
2931
esac
@@ -37,6 +39,7 @@ cd ~/linux
3739
while read -r root br dir; do
3840
[[ "$root" =~ ^[[:space:]]*\# ]] && continue
3941
[[ "$root" =~ ^\? ]] && [ ! -v all ] && continue
42+
[[ "$root $br $dir" =~ $match ]] || continue
4043
root=${root#\?}
4144
cd ~/linux/"$root"
4245
if [ "${br:-@}" = '@' ]; then

0 commit comments

Comments
 (0)