From 83e9f0dd910d7320f420b5105e3a641ec19c082d Mon Sep 17 00:00:00 2001 From: Greg Dietsche Date: Wed, 3 Apr 2013 15:56:13 -0500 Subject: [PATCH] grep: add support for egrep, fgrep, rgrep Signed-off-by: Greg Dietsche --- share/completions/egrep.fish | 1 + share/completions/fgrep.fish | 1 + share/completions/grep.fish | 54 +---------------------- share/completions/rgrep.fish | 1 + share/functions/__fish_complete_grep.fish | 51 +++++++++++++++++++++ 5 files changed, 55 insertions(+), 53 deletions(-) create mode 100644 share/completions/egrep.fish create mode 100644 share/completions/fgrep.fish create mode 100644 share/completions/rgrep.fish create mode 100644 share/functions/__fish_complete_grep.fish diff --git a/share/completions/egrep.fish b/share/completions/egrep.fish new file mode 100644 index 000000000..2eb7139e5 --- /dev/null +++ b/share/completions/egrep.fish @@ -0,0 +1 @@ +__fish_complete_grep egrep diff --git a/share/completions/fgrep.fish b/share/completions/fgrep.fish new file mode 100644 index 000000000..0cf390935 --- /dev/null +++ b/share/completions/fgrep.fish @@ -0,0 +1 @@ +__fish_complete_grep fgrep diff --git a/share/completions/grep.fish b/share/completions/grep.fish index 7f8df25c0..c9d1015e2 100644 --- a/share/completions/grep.fish +++ b/share/completions/grep.fish @@ -1,53 +1 @@ -# -# Completions for the grep command -# - -complete -c grep -s A -l after-context --description "Print NUM lines of trailing context" -complete -c grep -s a -l text --description "Process binary file as text" -complete -c grep -s B -l before-context --description "Print NUM lines of leading context" -complete -c grep -s C -l context --description "Print NUM lines of context" -complete -c grep -s b -l byte-offset --description "Print byte offset of matches" -complete -c grep -l binary-files --description "Assume data type for binary files" -x -a "binary text" -complete -c grep -l colour -x -a "never always auto" -complete -c grep -l color -x -a "never always auto" -complete -c grep -s c -l count --description "Only print number of matches" -complete -c grep -s D -l devices -x -a "read skip" --description "Action for devices" -complete -c grep -s d -l directories -x -a "read skip recurse" --description "Action for directories" -complete -c grep -s E -l extended-regexp --description "Pattern is extended regexp" -complete -xc grep -s e -l regexp --description "Pattern is a regexp" -complete -rc grep -l exclude-from --description "Read pattern list from file. Skip files whose base name matches list" -complete -rc grep -l exclude-dir --description "Exclude matching directories from recursive searches" -complete -c grep -s F -l fixed-strings --description "Pattern is a fixed string" -complete -rc grep -s f -l file -r --description "Use patterns from a file" -complete -c grep -s G -l basic-regexp --description "Pattern is basic regex" -complete -c grep -s H -l with-filename --description "Print filename" -complete -c grep -s h -l no-filename --description "Suppress printing filename" -complete -c grep -l help --description "Display help and exit" -complete -c grep -s I --description "Skip binary files" -complete -c grep -s i -l ignore-case --description "Ignore case" -complete -c grep -s L -l files-without-match --description "Print first non-matching file" -complete -c grep -s l -l files-with-match --description "Print first matching file" -complete -c grep -s m -l max-count --description "Stop reading after NUM matches" -complete -c grep -l mmap --description "Use the mmap system call to read input" -complete -c grep -s n -l line-number --description "Print line number" -complete -c grep -s o -l only-matching --description "Show only matching part" -complete -c grep -l label --description "Rename stdin" -complete -c grep -l line-buffered --description "Use line buffering" -complete -c grep -s P -l perl-regexp --description "Pattern is a Perl regexp (PCRE) string" -complete -c grep -s q -l quiet --description "Do not write anything" -complete -c grep -l silent --description "Do not write anything" -complete -c grep -s R -l recursive --description "Read files under each directory, recursively" -complete -c grep -s r --description "Read files under each directory, recursively" -complete -c grep -l include --description "Search only files matching PATTERN" -complete -c grep -l exclude --description "Skip files matching PATTERN" -complete -c grep -s s -l no-messages --description "Suppress error messages" -complete -c grep -s T -l initial-tab --description "Ensure first character of actual line content lies on a tab stop" -complete -c grep -s U -l binary --description "Treat files as binary" -complete -c grep -s u -l unix-byte-offsets --description "Report Unix-style byte offsets" -complete -c grep -s V -l version --description "Display version and exit" -complete -c grep -s v -l invert-match --description "Invert the sense of matching" -complete -c grep -s w -l word-regexp --description "Only whole matching words" -complete -c grep -s x -l line-regexp --description "Only whole matching lines" -complete -c grep -s y --description "Obsolete synonym for -i" -complete -c grep -s z -l null-data --description 'treat input as a set of lines each terminated by a zero byte' -complete -c grep -s Z -l null --description "Output a zero byte after filename" +__fish_complete_grep grep diff --git a/share/completions/rgrep.fish b/share/completions/rgrep.fish new file mode 100644 index 000000000..e4dab5d68 --- /dev/null +++ b/share/completions/rgrep.fish @@ -0,0 +1 @@ +__fish_complete_grep rgrep diff --git a/share/functions/__fish_complete_grep.fish b/share/functions/__fish_complete_grep.fish new file mode 100644 index 000000000..dd2e45b06 --- /dev/null +++ b/share/functions/__fish_complete_grep.fish @@ -0,0 +1,51 @@ +function __fish_complete_grep -d 'Complete grep, egrep, fgrep, rgrep' --argument-names grep + complete -c $grep -s A -l after-context --description "Print NUM lines of trailing context" + complete -c $grep -s a -l text --description "Process binary file as text" + complete -c $grep -s B -l before-context --description "Print NUM lines of leading context" + complete -c $grep -s C -l context --description "Print NUM lines of context" + complete -c $grep -s b -l byte-offset --description "Print byte offset of matches" + complete -c $grep -l binary-files --description "Assume data type for binary files" -x -a "binary text" + complete -c $grep -l colour -x -a "never always auto" + complete -c $grep -l color -x -a "never always auto" + complete -c $grep -s c -l count --description "Only print number of matches" + complete -c $grep -s D -l devices -x -a "read skip" --description "Action for devices" + complete -c $grep -s d -l directories -x -a "read skip recurse" --description "Action for directories" + complete -c $grep -s E -l extended-regexp --description "Pattern is extended regexp" + complete -xc $grep -s e -l regexp --description "Pattern is a regexp" + complete -rc $grep -l exclude-from --description "Read pattern list from file. Skip files whose base name matches list" + complete -rc $grep -l exclude-dir --description "Exclude matching directories from recursive searches" + complete -c $grep -s F -l fixed-strings --description "Pattern is a fixed string" + complete -rc $grep -s f -l file -r --description "Use patterns from a file" + complete -c $grep -s G -l basic-regexp --description "Pattern is basic regex" + complete -c $grep -s H -l with-filename --description "Print filename" + complete -c $grep -s h -l no-filename --description "Suppress printing filename" + complete -c $grep -l help --description "Display help and exit" + complete -c $grep -s I --description "Skip binary files" + complete -c $grep -s i -l ignore-case --description "Ignore case" + complete -c $grep -s L -l files-without-match --description "Print first non-matching file" + complete -c $grep -s l -l files-with-match --description "Print first matching file" + complete -c $grep -s m -l max-count --description "Stop reading after NUM matches" + complete -c $grep -l mmap --description "Use the mmap system call to read input" + complete -c $grep -s n -l line-number --description "Print line number" + complete -c $grep -s o -l only-matching --description "Show only matching part" + complete -c $grep -l label --description "Rename stdin" + complete -c $grep -l line-buffered --description "Use line buffering" + complete -c $grep -s P -l perl-regexp --description "Pattern is a Perl regexp (PCRE) string" + complete -c $grep -s q -l quiet --description "Do not write anything" + complete -c $grep -l silent --description "Do not write anything" + complete -c $grep -s R -l recursive --description "Read files under each directory, recursively" + complete -c $grep -s r --description "Read files under each directory, recursively" + complete -c $grep -l include --description "Search only files matching PATTERN" + complete -c $grep -l exclude --description "Skip files matching PATTERN" + complete -c $grep -s s -l no-messages --description "Suppress error messages" + complete -c $grep -s T -l initial-tab --description "Ensure first character of actual line content lies on a tab stop" + complete -c $grep -s U -l binary --description "Treat files as binary" + complete -c $grep -s u -l unix-byte-offsets --description "Report Unix-style byte offsets" + complete -c $grep -s V -l version --description "Display version and exit" + complete -c $grep -s v -l invert-match --description "Invert the sense of matching" + complete -c $grep -s w -l word-regexp --description "Only whole matching words" + complete -c $grep -s x -l line-regexp --description "Only whole matching lines" + complete -c $grep -s y --description "Obsolete synonym for -i" + complete -c $grep -s z -l null-data --description 'treat input as a set of lines each terminated by a zero byte' + complete -c $grep -s Z -l null --description "Output a zero byte after filename" +end