aboutsummaryrefslogtreecommitdiffhomepage
path: root/share
diff options
context:
space:
mode:
authorGravatar Aaron Gyes <me@aaron.gy>2016-04-08 10:46:51 +0800
committerGravatar David Adam <zanchey@ucc.gu.uwa.edu.au>2016-04-08 10:49:29 +0800
commit36691df6fe4667645b71b550ce5eea90762ac23a (patch)
treeec2d420e797298da5fd83e4ee514f9643b231835 /share
parent790c7f80c7d0fa1c97380885201eb50a2abcce02 (diff)
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.
Diffstat (limited to 'share')
-rw-r--r--share/completions/apm.fish4
-rw-r--r--share/completions/git.fish6
-rw-r--r--share/completions/gpg.fish2
-rw-r--r--share/completions/npm.fish2
-rw-r--r--share/completions/rustc.fish8
-rw-r--r--share/completions/ssh.fish4
-rw-r--r--share/functions/__fish_complete_pids.fish4
-rw-r--r--share/functions/__fish_complete_users.fish6
-rw-r--r--share/functions/__fish_complete_wvdial_peers.fish6
-rw-r--r--share/functions/__fish_git_prompt.fish4
-rw-r--r--share/functions/__fish_paginate.fish2
-rw-r--r--share/functions/__fish_print_abook_emails.fish2
-rw-r--r--share/functions/__fish_print_hostnames.fish4
-rw-r--r--share/functions/__fish_print_pacman_repos.fish2
-rw-r--r--share/functions/__fish_print_users.fish4
-rw-r--r--share/tools/web_config/sample_prompts/acidhub.fish2
-rw-r--r--share/tools/web_config/sample_prompts/nim.fish4
17 files changed, 35 insertions, 31 deletions
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
)
"
diff --git a/share/functions/__fish_complete_pids.fish b/share/functions/__fish_complete_pids.fish
index 65ba4794..e974ed61 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 91c254da..199231be 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 11155b1e..5eab088b 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 4fb2f16c..128a3f97 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 7887cf6b..31cdd61f 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 c1a8d294..f32b2aed 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 38515776..40499d1e 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 81fe3de5..1998f721 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 f6d41fa9..d2915760 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 45a7223e..afb70246 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 347af1d4..5d2dac39 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-)