From 96b3e1ce1bf8098d4b58b8695b1c2f5d7ba87f29 Mon Sep 17 00:00:00 2001 From: lordlycastle Date: Thu, 10 Dec 2015 14:20:46 +0000 Subject: [PATCH] Added OS X completions for open, and seq. Added missing stdout redirection to /dev/null when checking command's version. --- share/completions/cat.fish | 2 +- share/completions/cp.fish | 2 +- share/completions/head.fish | 4 ++-- share/completions/open.fish | 14 ++++++++++++++ share/completions/seq.fish | 18 ++++++++++++------ share/completions/stat.fish | 2 +- share/completions/tail.fish | 1 + share/completions/touch.fish | 2 +- 8 files changed, 33 insertions(+), 12 deletions(-) create mode 100644 share/completions/open.fish diff --git a/share/completions/cat.fish b/share/completions/cat.fish index b82ac4e04d87..f6c2d4af2eea 100644 --- a/share/completions/cat.fish +++ b/share/completions/cat.fish @@ -1,4 +1,4 @@ -if cat --version ^ /dev/null # GNU +if cat --version ^ /dev/null > /dev/null # GNU complete -c cat -s A -l show-all --description "Escape all non-printing characters" complete -c cat -s b -l number-nonblank --description "Number nonblank lines" complete -c cat -s e --description "Escape non-printing characters except tab" diff --git a/share/completions/cp.fish b/share/completions/cp.fish index ca92194d9c16..ffe920b53152 100644 --- a/share/completions/cp.fish +++ b/share/completions/cp.fish @@ -1,4 +1,4 @@ -if cp --version ^ /dev/null # GNU +if cp --version ^ /dev/null > /dev/null # GNU complete -c cp -s a -l archive --description "Same as -dpR" complete -c cp -s b -l backup --description "Make backup of each existing destination file" -a "none off numbered t existing nil simple never" complete -c cp -l copy-contents --description "Copy contents of special files when recursive" diff --git a/share/completions/head.fish b/share/completions/head.fish index 6aa0f11bfd2c..7e397d6a59f0 100644 --- a/share/completions/head.fish +++ b/share/completions/head.fish @@ -6,6 +6,6 @@ if head --version >/dev/null ^/dev/null complete -f -c head -l version -d 'Display version' complete -f -c head -l help -d 'Display help' else # OSX and similar - no longopts (and fewer shortopts) - complete -c head -s c -d 'Print the first N bytes; Leading '-', truncate the last N bytes' -r - complete -c head -s n -d 'Print the first N lines; Leading '-', truncate the last N lines' -r + complete -c head -s c -d 'Print the first N bytes' -r + complete -c head -s n -d 'Print the first N lines' -r end diff --git a/share/completions/open.fish b/share/completions/open.fish new file mode 100644 index 000000000000..c81e51709bf3 --- /dev/null +++ b/share/completions/open.fish @@ -0,0 +1,14 @@ +if test (uname) = 'Darwin' # OS X + complete -c open -s a -d 'Open APP, or open FILE(s), if supplied, with APP' -x -a "(mdfind -onlyin /Applications -onlyin ~/Applications -onlyin /Developer/Applications 'kMDItemKind==Application' | sed -E 's/.+\/(.+)\.app/\1/g')" + complete -c open -s b -d 'Bundle Identifier of APP to open, or to be used to open FILE' -x -a "(mdls (mdfind -onlyin /Applications -onlyin ~/Applications -onlyin /Developer/Applications 'kMDItemKind==Application') -name kMDItemCFBundleIdentifier | sed -E 's/kMDItemCFBundleIdentifier = \"(.+)\"/\1/g')" + complete -c open -s e -d 'Open FILE(s) with /Applications/TextEdit' + complete -c open -s t -d 'Open FILE(s) with default text editor from LaunchServices' + complete -c open -s f -d 'Open STDIN/PIPE with default text editor. End input with C-d.' + complete -c open -s F -d 'Don\'t restore previous application windows. Except Untitled documents.' + complete -c open -s W -d 'Wait until APP has exited' + complete -c open -s R -d 'Reveal FILE(s) in Finder' + complete -c open -s n -d 'Open new instace of APP' + complete -c open -s g -d 'Open in background' + complete -c open -s h -d 'Finds and opens for a header whose name matches the given string. Better performance with full names i.e. NSView.h' -r + complete -c open -l args -d 'Pass arguments to opened APP in the argv parameter to main()' -x +end diff --git a/share/completions/seq.fish b/share/completions/seq.fish index eaf5476179fe..69760099d934 100644 --- a/share/completions/seq.fish +++ b/share/completions/seq.fish @@ -1,6 +1,12 @@ - -complete -c seq -s f -l format -d 'Use printf style floating-point FORMAT' -complete -c seq -s s -l separator -d 'Use STRING to separate numbers' -complete -c seq -s w -l equal-width -d 'Equalize width with leading zeroes' -complete -c seq -l help -d 'Display this help' -complete -c seq -l version -d 'Output version information' +if seq --version ^ /dev/null > /dev/null #GNU + complete -c seq -s f -l format -d 'Use printf style floating-point FORMAT' + complete -c seq -s s -l separator -d 'Use STRING to separate numbers' + complete -c seq -s w -l equal-width -d 'Equalize width with leading zeroes' + complete -c seq -l help -d 'Display this help' + complete -c seq -l version -d 'Output version information' +else #OS X + complete -c seq -s f -d 'Use printf style floating-point FORMAT' + complete -c seq -s s -d 'Use STRING to separate numbers' + complete -c seq -s w -d 'Equalize width with leading zeroes' + complete -c seq -s t -d 'Use STRING to terminate sequence of numbers' +end diff --git a/share/completions/stat.fish b/share/completions/stat.fish index 3fc6742b2ec5..a87ca02a1b89 100644 --- a/share/completions/stat.fish +++ b/share/completions/stat.fish @@ -1,4 +1,4 @@ -if stat --version ^ /dev/null # GNU +if stat --version ^ /dev/null > /dev/null # GNU complete -c stat -s L -l dereference -d 'follow links' complete -c stat -s f -l file-system -d 'display file system status instead of file status' complete -c stat -s c -l format -x -d 'use the specified FORMAT instead of the default; output a newline after each use of FORMAT' diff --git a/share/completions/tail.fish b/share/completions/tail.fish index aa67e78437f6..66c426d664e3 100644 --- a/share/completions/tail.fish +++ b/share/completions/tail.fish @@ -12,6 +12,7 @@ if tail --version > /dev/null ^ /dev/null complete -c tail -l help -d 'display this help and exit' complete -c tail -l version -d 'output version information and exit' else # OSX and similar - no longopts (and fewer shortopts) + complete -c tail -s b -x -d 'output last K 512 byte blocks' complete -c tail -s c -x -d 'output the last K bytes or only K bytes with -r' complete -c tail -s f -d 'output appended data as the file grows' complete -c tail -s F -d 'Like -f, but also follow renamed or rotated files' diff --git a/share/completions/touch.fish b/share/completions/touch.fish index 62f54f16cb02..96e31ce5b458 100644 --- a/share/completions/touch.fish +++ b/share/completions/touch.fish @@ -1,4 +1,4 @@ -if touch --version ^ /dev/null # GNU +if touch --version ^ /dev/null > /dev/null # GNU complete -c touch -s a --description "Change access time" complete -c touch -s B -l backward -x --description "Set date back" complete -c touch -s c -l no-create --description "Do not create file"