Skip to content

Commit da73384

Browse files
committed
Update bash completions to be more consistent with the tools
Assisted-by: Cursor
1 parent a27fb4b commit da73384

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ Patchutils news
2929
Added manual pages for gitdiff, gitdiffview, svndiff, and svndiffview
3030
commands. Addresses GitHub issue #112.
3131

32+
Updated bash completions.
33+
3234
0.4.3 (stable)
3335

3436
Added --in-place option to more tools for editing files in place.

bash-completion-patchutils

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,12 @@ _patchutils_common_opts() {
66
echo "--help --version"
77
}
88

9-
_patchutils_filter_opts() {
10-
echo "--exclude -x --exclude-from-file -X --include -i --include-from-file -I --hunks -# --lines --files -F --annotate --as-numbered-lines --format --remove-timestamps --clean --in-place --decompress -z --strip-match -p --strip --addprefix --addoldprefix --addnewprefix --git-prefixes"
9+
_patchutils_shared_filter_opts() {
10+
echo "--exclude -x --exclude-from-file -X --include -i --include-from-file -I --hunks -# --lines --files -F --decompress -z --strip-match -p --strip --addprefix --addoldprefix --addnewprefix --git-prefixes"
11+
}
12+
13+
_patchutils_filterdiff_only_opts() {
14+
echo "--annotate --as-numbered-lines --format --remove-timestamps --clean --in-place"
1115
}
1216

1317
_patchutils_list_opts() {
@@ -35,7 +39,7 @@ _filterdiff() {
3539
cur="${COMP_WORDS[COMP_CWORD]}"
3640
prev="${COMP_WORDS[COMP_CWORD-1]}"
3741

38-
opts="$(_patchutils_common_opts) $(_patchutils_filter_opts) $(_patchutils_list_opts) --verbose -v --filter --grep --list"
42+
opts="$(_patchutils_common_opts) $(_patchutils_shared_filter_opts) $(_patchutils_filterdiff_only_opts) $(_patchutils_list_opts) --verbose -v --filter --grep --list"
3943

4044
case "${prev}" in
4145
--exclude|-x|--include|-i)
@@ -95,7 +99,7 @@ _lsdiff() {
9599
cur="${COMP_WORDS[COMP_CWORD]}"
96100
prev="${COMP_WORDS[COMP_CWORD-1]}"
97101

98-
opts="$(_patchutils_common_opts) $(_patchutils_filter_opts) $(_patchutils_list_opts) --verbose -v --filter --grep"
102+
opts="$(_patchutils_common_opts) $(_patchutils_shared_filter_opts) $(_patchutils_list_opts) --verbose -v --filter --grep"
99103

100104
case "${prev}" in
101105
--exclude|-x|--include|-i)
@@ -135,7 +139,7 @@ _grepdiff() {
135139
cur="${COMP_WORDS[COMP_CWORD]}"
136140
prev="${COMP_WORDS[COMP_CWORD-1]}"
137141

138-
opts="$(_patchutils_common_opts) $(_patchutils_filter_opts) $(_patchutils_list_opts) $(_patchutils_grep_opts) --verbose -v --filter --list"
142+
opts="$(_patchutils_common_opts) $(_patchutils_shared_filter_opts) $(_patchutils_list_opts) $(_patchutils_grep_opts) --verbose -v --filter --list"
139143

140144
case "${prev}" in
141145
--exclude|-x|--include|-i)
@@ -367,7 +371,7 @@ _patchview() {
367371
prev="${COMP_WORDS[COMP_CWORD-1]}"
368372

369373
# patchview is a wrapper around filterdiff, so use similar completion
370-
opts="$(_patchutils_common_opts) $(_patchutils_filter_opts) --verbose -v --filter --grep"
374+
opts="$(_patchutils_common_opts) $(_patchutils_shared_filter_opts) $(_patchutils_filterdiff_only_opts) --verbose -v --filter --grep"
371375

372376
case "${prev}" in
373377
--exclude|-x|--include|-i)
@@ -406,7 +410,7 @@ _gitdiff() {
406410
cur="${COMP_WORDS[COMP_CWORD]}"
407411

408412
# These are wrappers that pass arguments to filterdiff
409-
opts="$(_patchutils_filter_opts)"
413+
opts="$(_patchutils_shared_filter_opts) $(_patchutils_filterdiff_only_opts)"
410414

411415
if [[ ${cur} == -* ]]; then
412416
COMPREPLY=($(compgen -W "${opts}" -- ${cur}))

0 commit comments

Comments
 (0)