diff --git a/share/completions/apm.fish b/share/completions/apm.fish index 6b80a1b81..f9bf2f97a 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 8ffdb071c..82ea0e8bf 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 4e9d19104..9c236e654 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 05393b858..534967ad0 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 d5caa03ca..8dadcaf67 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 896b542ed..6131c2545 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 ) " diff --git a/share/functions/__fish_complete_pids.fish b/share/functions/__fish_complete_pids.fish index 65ba47946..e974ed61f 100644 --- a/share/functions/__fish_complete_pids.fish +++ b/share/functions/__fish_complete_pids.fish @@ -1,11 +1,11 @@ function __fish_complete_pids -d "Print a list of process identifiers along with brief descriptions" # This may be a bit slower, but it's nice - having the tty displayed is really handy # 'tail -n +2' deletes the first line, which contains the headers - # 'grep -v...' removes self from the output + # %self is removed from output by string match -r -v set -l SELF %self # Display the tty if available # But not if it's just question marks, meaning no tty - ps axc -o pid,ucomm,tty | grep -v '^\s*'$SELF'\s' | tail -n +2 | string replace -r ' *([0-9]+) +([^ ].*[^ ]|[^ ]) +([^ ]+) *$' '$1\t$2 [$3]' | string replace -r ' *\[\?*\] *$' '' + ps axc -o pid,ucomm,tty | string match -r -v '^\s*'$SELF'\s' | tail -n +2 | string replace -r ' *([0-9]+) +([^ ].*[^ ]|[^ ]) +([^ ]+) *$' '$1\t$2 [$3]' | string replace -r ' *\[\?*\] *$' '' end diff --git a/share/functions/__fish_complete_users.fish b/share/functions/__fish_complete_users.fish index 91c254daa..199231be1 100644 --- a/share/functions/__fish_complete_users.fish +++ b/share/functions/__fish_complete_users.fish @@ -1,8 +1,10 @@ function __fish_complete_users --description "Print a list of local users, with the real user name as a description" if test -x /usr/bin/getent - getent passwd | cut -d : -f 1,5 | sed 's/:/\t/' + getent passwd | cut -d : -f 1,5 | string replace -r ':' \t + else if test -x /usr/bin/dscl + dscl . -list /Users RealName | string match -r -v '^_' | string replace -r ' {2,}' \t else - __fish_sgrep -ve '^#' /etc/passwd | cut -d : -f 1,5 | sed 's/:/\t/' + string match -v -r '^\s*#' < /etc/passwd | cut -d : -f 1,5 | string replace ':' \t end end diff --git a/share/functions/__fish_complete_wvdial_peers.fish b/share/functions/__fish_complete_wvdial_peers.fish index 11155b1e2..5eab088bc 100644 --- a/share/functions/__fish_complete_wvdial_peers.fish +++ b/share/functions/__fish_complete_wvdial_peers.fish @@ -15,15 +15,15 @@ function __fish_complete_wvdial_peers --description 'Complete wvdial peers' --ar case -C --config set store_next true case '--config=*' - set cfgfiles (echo $opt | sed 's/--config=//') + set cfgfiles (echo $opt | string replace '--config=' '') end end for file in $cfgfiles if test -f $file - cat $file | grep '\[Dialer' | sed 's/\[Dialer \(.\+\)\]/\1/' + string match -r '\[Dialer' < $file | string replace -r '\[Dialer (.+)\]' '$1' end - end | sort -u | grep -v Defaults + end | sort -u | string match -v Defaults end diff --git a/share/functions/__fish_git_prompt.fish b/share/functions/__fish_git_prompt.fish index 4fb2f16c8..128a3f975 100644 --- a/share/functions/__fish_git_prompt.fish +++ b/share/functions/__fish_git_prompt.fish @@ -286,8 +286,8 @@ function __fish_git_prompt_show_upstream --description "Helper function for __fi set -l os set -l commits (command git rev-list --left-right $upstream...HEAD ^/dev/null; set os $status) if test $os -eq 0 - set -l behind (count (for arg in $commits; echo $arg; end | grep '^<')) - set -l ahead (count (for arg in $commits; echo $arg; end | grep -v '^<')) + set -l behind (count (for arg in $commits; echo $arg; end | string match -r '^<')) + set -l ahead (count (for arg in $commits; echo $arg; end | string match -r -v '^<')) set count "$behind $ahead" else set count diff --git a/share/functions/__fish_paginate.fish b/share/functions/__fish_paginate.fish index 7887cf6b2..31cdd61fa 100644 --- a/share/functions/__fish_paginate.fish +++ b/share/functions/__fish_paginate.fish @@ -5,7 +5,7 @@ function __fish_paginate -d "Paginate the current command using the users defaul set cmd $PAGER end - if commandline -j|grep -v "$cmd *\$" >/dev/null + if commandline -j| string match -q -r -v "$cmd *\$" commandline -aj " ^&1 |$cmd;" end diff --git a/share/functions/__fish_print_abook_emails.fish b/share/functions/__fish_print_abook_emails.fish index c1a8d294e..f32b2aed6 100644 --- a/share/functions/__fish_print_abook_emails.fish +++ b/share/functions/__fish_print_abook_emails.fish @@ -1,4 +1,4 @@ function __fish_print_abook_emails --description 'Print email addresses (abook)' - abook --mutt-query "" | egrep -v '^\s*$' + abook --mutt-query "" | string match -r -v '^\s*$' end diff --git a/share/functions/__fish_print_hostnames.fish b/share/functions/__fish_print_hostnames.fish index 385157768..40499d1e7 100644 --- a/share/functions/__fish_print_hostnames.fish +++ b/share/functions/__fish_print_hostnames.fish @@ -5,11 +5,11 @@ function __fish_print_hostnames -d "Print a list of known hostnames" # Print all hosts from /etc/hosts if type -q getent # Ignore zero ips - getent hosts | grep -v '^0.0.0.0' \ + getent hosts | string match -r -v '^0.0.0.0' \ | string replace -r '[0-9.]*\s*' '' | string split " " else if test -r /etc/hosts # Ignore commented lines and functionally empty lines - grep -v '^\s*0.0.0.0\|^\s*#\|^\s*$' /etc/hosts \ + string match -r -v '^\s*0.0.0.0|^\s*#|^\s*$' < /etc/hosts \ # Strip comments | string replace -ra '#.*$' '' \ | string replace -r '[0-9.]*\s*' '' | string trim | string replace -ra '\s+' '\n' diff --git a/share/functions/__fish_print_pacman_repos.fish b/share/functions/__fish_print_pacman_repos.fish index 81fe3de5d..1998f7216 100644 --- a/share/functions/__fish_print_pacman_repos.fish +++ b/share/functions/__fish_print_pacman_repos.fish @@ -1,3 +1,3 @@ function __fish_print_pacman_repos --description "Print the repositories configured for arch's pacman package manager" - sed -n -e 's/\[\(.\+\)\]/\1/p' /etc/pacman.conf | grep -v "#\|options" + string replace -r -a "\[(.+)\]" "\1" < /etc/pacman.conf | string match -r -v "^#|options" end diff --git a/share/functions/__fish_print_users.fish b/share/functions/__fish_print_users.fish index f6d41fa93..d2915760f 100644 --- a/share/functions/__fish_print_users.fish +++ b/share/functions/__fish_print_users.fish @@ -3,9 +3,9 @@ function __fish_print_users --description "Print a list of local users" if test -x /usr/bin/getent getent passwd | cut -d : -f 1 else if test -x /usr/bin/dscl # OS X support - dscl . -list /Users | __fish_sgrep -v '^_' + dscl . -list /Users | string match -r -v '^_' else - __fish_sgrep -ve '^#' /etc/passwd | cut -d : -f 1 + string match -v -r '^\w*#' < /etc/passwd | cut -d : -f 1 end end diff --git a/share/tools/web_config/sample_prompts/acidhub.fish b/share/tools/web_config/sample_prompts/acidhub.fish index 45a7223e4..afb702463 100644 --- a/share/tools/web_config/sample_prompts/acidhub.fish +++ b/share/tools/web_config/sample_prompts/acidhub.fish @@ -12,7 +12,7 @@ function fish_prompt -d "Write out the prompt" if [ (_git_branch_name) ] set -l git_branch (set_color -o blue)(_git_branch_name) if [ (_is_git_dirty) ] - for i in (git branch -qv --no-color|grep \*|cut -d' ' -f4-|cut -d] -f1|tr , \n)\ + for i in (git branch -qv --no-color| string match -r \*|cut -d' ' -f4-|cut -d] -f1|tr , \n)\ (git status --porcelain | cut -c 1-2 | uniq) switch $i case "*[ahead *" diff --git a/share/tools/web_config/sample_prompts/nim.fish b/share/tools/web_config/sample_prompts/nim.fish index 347af1d4d..5d2dac394 100644 --- a/share/tools/web_config/sample_prompts/nim.fish +++ b/share/tools/web_config/sample_prompts/nim.fish @@ -3,7 +3,7 @@ function fish_prompt and set retc green; or set retc red - tty|grep -q tty; and set tty tty; or set tty pts + tty|string match -q -r tty; and set tty tty; or set tty pts set_color $retc if [ $tty = tty ] @@ -48,7 +48,7 @@ function fish_prompt echo -n ] if type -q acpi - if [ (acpi -a 2> /dev/null | grep off) ] + if [ (acpi -a 2> /dev/null | string match -r off) ] echo -n '─[' set_color -o red echo -n (acpi -b|cut -d' ' -f 4-)