From 36691df6fe4667645b71b550ce5eea90762ac23a Mon Sep 17 00:00:00 2001 From: Aaron Gyes Date: Fri, 8 Apr 2016 10:46:51 +0800 Subject: Stringify many completions and functions, with --invert stringification. I believe apm must have been buggy - example output that I found online showed `tr` was mangling paths with spaces in it. Should be fixed. Also, use dscl on OS X in __fish_complete_users.fish like __fish_print_users.fish already does. --- share/completions/apm.fish | 4 ++-- share/completions/git.fish | 6 +++--- share/completions/gpg.fish | 2 ++ share/completions/npm.fish | 2 +- share/completions/rustc.fish | 8 ++++---- share/completions/ssh.fish | 4 ++-- 6 files changed, 14 insertions(+), 12 deletions(-) (limited to 'share/completions') diff --git a/share/completions/apm.fish b/share/completions/apm.fish index 6b80a1b8..f9bf2f97 100644 --- a/share/completions/apm.fish +++ b/share/completions/apm.fish @@ -61,7 +61,7 @@ end # Lists all apm config items function __fish_apm_config_items - apm config list | grep -v '^;\|^$' | tr "\ =\ " "\t" + apm config list | string match -r -v "^\s*;|^\s*\$" | string replace "\w*=\w*" \t end # Lists all installed atom packages @@ -69,7 +69,7 @@ function __fish_apm_list_packages apm list -b end -if apm -h ^| grep -q "Atom Package Manager" +if apm -h ^| string match -q "Atom Package Manager*" # Completions for Atom Package Manager ################## diff --git a/share/completions/git.fish b/share/completions/git.fish index 8ffdb071..82ea0e8b 100644 --- a/share/completions/git.fish +++ b/share/completions/git.fish @@ -11,13 +11,13 @@ function __fish_git_commits end function __fish_git_branches - command git branch --no-color -a ^/dev/null | __fish_sgrep -v ' -> ' | string trim -c "* " | string replace -r "^remotes/" "" + command git branch --no-color -a ^/dev/null | string match -r -v ' -> ' | string trim -c "* " | string replace -r "^remotes/" "" end function __fish_git_unique_remote_branches # Allow all remote branches with one remote without the remote part # This is useful for `git checkout` to automatically create a remote-tracking branch - command git branch --no-color -a ^/dev/null | __fish_sgrep -v ' -> ' | string trim -c "* " | string replace -r "^remotes/[^/]*/" "" | sort | uniq -u + command git branch --no-color -a ^/dev/null | string match -r -v ' -> ' | string trim -c "* " | string replace -r "^remotes/[^/]*/" "" | sort | uniq -u end function __fish_git_tags @@ -473,7 +473,7 @@ complete -f -c git -n '__fish_git_using_command status' -l ignore-submodules -x ### tag complete -f -c git -n '__fish_git_needs_command' -a tag -d 'Create, list, delete or verify a tag object signed with GPG' -complete -f -c git -n '__fish_git_using_command tag; and __fish_not_contain_opt -s d; and __fish_not_contain_opt -s v; and test (count (commandline -opc | __fish_sgrep -v -e \'^-\')) -eq 3' -a '(__fish_git_branches)' -d 'Branch' +complete -f -c git -n '__fish_git_using_command tag; and __fish_not_contain_opt -s d; and __fish_not_contain_opt -s v; and test (count (commandline -opc | string match -r -v \'^-\')) -eq 3' -a '(__fish_git_branches)' -d 'Branch' complete -f -c git -n '__fish_git_using_command tag' -s a -l annotate -d 'Make an unsigned, annotated tag object' complete -f -c git -n '__fish_git_using_command tag' -s s -l sign -d 'Make a GPG-signed tag' complete -f -c git -n '__fish_git_using_command tag' -s d -l delete -d 'Remove a tag' diff --git a/share/completions/gpg.fish b/share/completions/gpg.fish index 4e9d1910..9c236e65 100644 --- a/share/completions/gpg.fish +++ b/share/completions/gpg.fish @@ -47,6 +47,8 @@ function __fish_print_gpg_algo -d "Complete using all algorithms of the type spe # expire when the function goes out of scope, and the original locale # will take effect again. set -lx LC_ALL C + + # XXX this misses certain ciphers in gpg --version - redo this entirely and use fish's annoying group printing as a feature finally! gpg --version | __fish_sgrep "$argv:"| __fish_sgrep -v "Home:"|cut -d : -f 2 |tr , \n|tr -d " " end diff --git a/share/completions/npm.fish b/share/completions/npm.fish index 05393b85..534967ad 100644 --- a/share/completions/npm.fish +++ b/share/completions/npm.fish @@ -60,7 +60,7 @@ complete -f -c npm -n 'not __fish_npm_needs_option' -a "(__fish_complete_npm)" # list available npm scripts and their parial content function __fish_npm_run - command npm run | command grep -v '^[^ ]' | command grep -v '^$' | command sed "s/^ *//" | while read -l name + command npm run | string match -r -v '^[^ ]|^$' | string trim | while read -l name set -l trim 20 read -l value echo "$value" | cut -c1-$trim | read -l value diff --git a/share/completions/rustc.fish b/share/completions/rustc.fish index d5caa03c..8dadcaf6 100644 --- a/share/completions/rustc.fish +++ b/share/completions/rustc.fish @@ -49,13 +49,13 @@ for line in $rust_docs end set -l rust_docs (rustc -W help \ - | egrep \ - '(\s+)(.+)(\s+)(allow|warn|deny|forbid)(\s+){2}([^\n]+)' \ + | string match -r \ + '(?:\s+)(?:.+)(?:\s+)(?:allow|warn|deny|forbid)(?:\s+){2}(?:[^\n]+)' \ | string replace -r -i \ '(\s+)(.+)(\s+)(allow|warn|deny|forbid)(\s+){2}([^\n]+)' '$2 $6' \ | string match -r '^.*[^:]$' \ - | egrep -v '^(allow|warn|deny|forbid)$' \ - | egrep -v '^([a-z\-]+)(\s+)(allow|warn|deny|forbid)') + | string match -r -v '^(allow|warn|deny|forbid)$' \ + | string match -r -v '^([a-z\-]+)(\s+)(allow|warn|deny|forbid)') for line in $rust_docs set docs (string split -m 1 ' ' $line) diff --git a/share/completions/ssh.fish b/share/completions/ssh.fish index 896b542e..6131c254 100644 --- a/share/completions/ssh.fish +++ b/share/completions/ssh.fish @@ -15,7 +15,7 @@ complete -x -c ssh -d Hostname -a " " complete -x -c ssh -d User -a " -(__fish_print_users | __fish_sgrep -v '^_')@ +(__fish_print_users | string match -r -v '^_')@ " complete -c ssh --description "Command to run" -x -a '(__fish_complete_subcommand --fcs-skip=2)' @@ -23,7 +23,7 @@ complete -c ssh -s a --description "Disables forwarding of the authentication ag complete -c ssh -s A --description "Enables forwarding of the authentication agent" complete -x -c ssh -s b --description "Interface to transmit from" -a " ( - cat /proc/net/arp ^/dev/null| __fish_sgrep -v '^IP'|cut -d ' ' -f 1 ^/dev/null + cat /proc/net/arp ^/dev/null| string match -r -v '^IP'|cut -d ' ' -f 1 ^/dev/null ) " -- cgit v1.2.3