diff --git a/share/completions/adduser.fish b/share/completions/adduser.fish
index 33d28182a..e55ff1c7d 100644
--- a/share/completions/adduser.fish
+++ b/share/completions/adduser.fish
@@ -16,7 +16,7 @@ complete -c adduser -l group --description 'When combined with --system, a group
complete -c adduser -l help --description 'Display brief instructions'
complete -c adduser -l home --description 'Use specified directory as the user\'s home directory' -x -a '(__fish_complete_directories)'
complete -c adduser -l shell --description 'Use shell as the user\'s login shell, rather than the default specified by the configuration file' -x -a '(cat /etc/shells)'
-complete -c adduser -l ingroup --description 'Add the new user to GROUP instead of a usergroup or the default group defined by USERS_GID in the configuration file' -x -a '(cat /etc/group|cut -d : -f 1)'
+complete -c adduser -l ingroup --description 'Add the new user to GROUP instead of a usergroup or the default group defined by USERS_GID in the configuration file' -x -a '(cut -d : -f 1 /etc/group)'
complete -c adduser -l no-create-home --description 'Do not create the home directory, even if it doesni\'t exist'
complete -c adduser -l quiet --description 'Suppress informational messages, only show warnings and errors'
complete -c adduser -l debug --description 'Be verbose, most useful if you want to nail down a problem with adduser'
diff --git a/share/completions/emerge.fish b/share/completions/emerge.fish
index e234be15f..589e41359 100644
--- a/share/completions/emerge.fish
+++ b/share/completions/emerge.fish
@@ -4,7 +4,7 @@
function __fish_emerge_print_installed_pkgs --description 'Prints completions for installed packages on the system from /var/db/pkg'
if test -d /var/db/pkg
- find /var/db/pkg/ -type d | cut -d'/' -f5-6 | sort | uniq | \
+ find /var/db/pkg/ -type d | cut -d'/' -f5-6 | sort -u | \
sed 's/-[0-9]\{1,\}\..*$//' | sed -e '/^ *$/d'
return
end
@@ -13,7 +13,7 @@ end
function __fish_emerge_print_all_pkgs --description 'Prints completions for all available packages on the system from /usr/portage'
if test -d /usr/portage
find /usr/portage/ -maxdepth 2 -type d | cut -d'/' -f4-5 | \
- sed 's/^\(distfiles\|profiles\|eclass\).*$//' | sort | uniq | \
+ sed 's/^\(distfiles\|profiles\|eclass\).*$//' | sort -u | \
sed 's/-[0-9]\{1,\}\..*$//' | sed -e '/^ *$/d'
return
end
diff --git a/share/completions/equery.fish b/share/completions/equery.fish
index 01d9cc157..3ff8ca620 100644
--- a/share/completions/equery.fish
+++ b/share/completions/equery.fish
@@ -4,21 +4,21 @@
function __fish_equery_print_installed_pkgs --description 'Prints completions for installed packages on the system from /var/db/pkg'
if test -d /var/db/pkg
- find /var/db/pkg/ -type d | cut -d'/' -f5-6 | sort | uniq | sed 's/-[0-9]\{1,\}\..*$//'
+ find /var/db/pkg/ -type d | cut -d'/' -f5-6 | sort -u | sed 's/-[0-9]\{1,\}\..*$//'
return
end
end
function __fish_equery_print_all_pkgs --description 'Prints completions for all available packages on the system from /usr/portage'
if test -d /usr/portage
- find /usr/portage/ -maxdepth 2 -type d | cut -d'/' -f4-5 | sed 's/^\(distfiles\|profiles\|eclass\).*$//' | sort | uniq | sed 's/-[0-9]\{1,\}\..*$//'
+ find /usr/portage/ -maxdepth 2 -type d | cut -d'/' -f4-5 | sed 's/^\(distfiles\|profiles\|eclass\).*$//' | sort -u | sed 's/-[0-9]\{1,\}\..*$//'
return
end
end
function __fish_equery_print_all_categories --description 'Prints completions for all available categories on the system from /usr/portage'
if test -d /usr/portage
- find /usr/portage/ -maxdepth 1 -type d | cut -d'/' -f4 | sed 's/^\(distfiles\|profiles\|eclass\).*$//' | sort | uniq | sed 's/-[0-9]\{1,\}\..*$//'
+ find /usr/portage/ -maxdepth 1 -type d | cut -d'/' -f4 | sed 's/^\(distfiles\|profiles\|eclass\).*$//' | sort -u | sed 's/-[0-9]\{1,\}\..*$//'
return
end
end
diff --git a/share/completions/gpg.fish b/share/completions/gpg.fish
index 9c236e654..dbccca0b1 100644
--- a/share/completions/gpg.fish
+++ b/share/completions/gpg.fish
@@ -48,8 +48,18 @@ function __fish_print_gpg_algo -d "Complete using all algorithms of the type spe
# 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 " "
+ # sed script explained:
+ # in the line that matches "$argv:"
+ # define label 'loop'
+ # if the line ends with a ','
+ # add next line to buffer
+ # transliterate '\n' with ' '
+ # goto loop
+ # remove everything until the first ':' of the line
+ # remove all blanks
+ # transliterate ',' with '\n' (OSX apparently doesn't like '\n' on RHS of the s-command)
+ # print result
+ gpg --version | sed -ne "/$argv:/"'{:loop; /,$/{N; y!\n! !; b loop}; s!^[^:]*:!!; s![ ]*!!g; y!,!\n!; p}'
end
diff --git a/share/completions/perl.fish b/share/completions/perl.fish
index 284dc4ef1..83203585a 100644
--- a/share/completions/perl.fish
+++ b/share/completions/perl.fish
@@ -2,7 +2,7 @@ begin
set -l unicode 'commandline | __fish_sgrep -qe "-[a-zA-Z]*C[a-zA-Z]*\$"'
set -l noopt 'commandline | not __fish_sgrep -qe "-[a-zA-Z]*C[a-zA-Z]*\$"'
set -l modules "(find (perl -lE'print for @INC') -name '*.pm' -printf '%P\n' ^/dev/null \
- | awk '{ gsub(\"/\", \"::\") } /[^-.]/' RS='\\\\\\\\.pm'\n | sort | uniq)"
+ | sed -e 's,/,::,g; s,\.pm$,,' | sort -u)"
complete -c perl -s 0 -n $noopt --description 'Specify record separator'
complete -c perl -s a -n $noopt --description 'Turn on autosplit mode'
complete -c perl -s c -n $noopt --description 'Check syntax'
diff --git a/share/completions/setxkbmap.fish b/share/completions/setxkbmap.fish
index 71aab63e8..6a557fb70 100644
--- a/share/completions/setxkbmap.fish
+++ b/share/completions/setxkbmap.fish
@@ -2,23 +2,23 @@
set -l filter '"s/\S+\s\S+\s(.+)\((.+)\)/\1\t\2/;"'
complete -c setxkbmap -o '?' -o help -d 'Print this message'
-complete -c setxkbmap -o compat -d 'Specifies compatibility map component name' -xa "(cat /usr/share/X11/xkb/compat.dir | sed -r $filter)"
+complete -c setxkbmap -o compat -d 'Specifies compatibility map component name' -xa "(sed -r $filter /usr/share/X11/xkb/compat.dir)"
complete -c setxkbmap -o config -d 'Specifies configuration file to use' -r
complete -c setxkbmap -o device -d 'Specifies the device ID to use' -x
complete -c setxkbmap -o display -d 'Specifies display to use' -x
-complete -c setxkbmap -o geometry -d 'Specifies geometry component name' -xa "(cat /usr/share/X11/xkb/geometry.dir | sed -r $filter)"
+complete -c setxkbmap -o geometry -d 'Specifies geometry component name' -xa "(sed -r $filter /usr/share/X11/xkb/geometry.dir)"
complete -c setxkbmap -o I -d 'Add
to list of directories to be used' -xa '(__fish_complete_directories)'
-complete -c setxkbmap -o keycodes -d 'Specifies keycodes component name' -xa "(cat /usr/share/X11/xkb/keycodes.dir | sed -r $filter)"
-complete -c setxkbmap -o keymap -d 'Specifies name of keymap to load' -xa "(cat /usr/share/X11/xkb/keymap.dir | sed -r $filter)"
+complete -c setxkbmap -o keycodes -d 'Specifies keycodes component name' -xa "(sed -r $filter /usr/share/X11/xkb/keycodes.dir)"
+complete -c setxkbmap -o keymap -d 'Specifies name of keymap to load' -xa "(sed -r $filter /usr/share/X11/xkb/keymap.dir)"
complete -c setxkbmap -o layout -d 'Specifies layout used to choose component names' -xa "(__fish_complete_setxkbmap layout)"
complete -c setxkbmap -o model -d 'Specifies model used to choose component names' -xa "(__fish_complete_setxkbmap model)"
complete -c setxkbmap -o option -d 'Adds an option used to choose component names' -xa "(__fish_complete_list , '__fish_complete_setxkbmap option')"
complete -c setxkbmap -o print -d 'Print a complete xkb_keymap description and exit'
complete -c setxkbmap -o query -d 'Print the current layout settings and exit'
complete -c setxkbmap -o rules -d 'Name of rules file to use' -x
-complete -c setxkbmap -o symbols -d 'Specifies symbols component name' -xa "(cat /usr/share/X11/xkb/symbols.dir | sed -r $filter)"
+complete -c setxkbmap -o symbols -d 'Specifies symbols component name' -xa "(sed -r $filter /usr/share/X11/xkb/symbols.dir)"
complete -c setxkbmap -o synch -d 'Synchronize request w/X server'
-complete -c setxkbmap -o types -d 'Specifies types component name' -xa "(cat /usr/share/X11/xkb/types.dir | sed -r $filter)"
+complete -c setxkbmap -o types -d 'Specifies types component name' -xa "(sed -r $filter /usr/share/X11/xkb/types.dir)"
complete -c setxkbmap -o v -o verbose -d 'Sets verbosity (1..10). Higher values yield more messages' -xa '(seq 1 10)'
complete -c setxkbmap -o variant -d 'Specifies layout variant used to choose component names' -xa "(__fish_complete_setxkbmap variant)"
diff --git a/share/completions/ssh.fish b/share/completions/ssh.fish
index a8896b627..691302982 100644
--- a/share/completions/ssh.fish
+++ b/share/completions/ssh.fish
@@ -23,7 +23,8 @@ 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| string match -r -v '^IP'|cut -d ' ' -f 1 ^/dev/null
+ # TODO /proc/net/arp is not POSIX compliant
+ cut -d ' ' -f 1 /proc/net/arp ^/dev/null | string match -r -v '^IP'
)
"
diff --git a/share/completions/umount.fish b/share/completions/umount.fish
index 85929fb82..7b164a071 100644
--- a/share/completions/umount.fish
+++ b/share/completions/umount.fish
@@ -16,7 +16,7 @@ complete -c umount -s d --description "In case the unmounted device was a loop d
complete -c umount -s i --description "Don't call the /sbin/umount. helper even if it exists"
complete -c umount -s a --description "Unmount all of the file systems described in /etc/mtab"
complete -c umount -s t --description "Actions should only be taken on file systems of the specified type" -xa "(__fish_print_filesystems)"
-complete -c umount -s O --description "Actions should only be taken on file systems with the specified options in /etc/fstab" -xa '(cat /etc/mtab | cut -d " " -f 4)\t"Mount option"'
+complete -c umount -s O --description "Actions should only be taken on file systems with the specified options in /etc/fstab" -xa '(cut -d " " -f 4 /etc/mtab)\t"Mount option"'
complete -c umount -s f --description "Force unmount (in case of an unreachable NFS system)"
complete -c umount -s l --description "Detach the filesystem from the filesystem hierarchy now, and cleanup all references to the filesystem as soon as it is not busy"
diff --git a/share/completions/useradd.fish b/share/completions/useradd.fish
index 37c9a7290..0719d6196 100644
--- a/share/completions/useradd.fish
+++ b/share/completions/useradd.fish
@@ -7,7 +7,7 @@
complete -c useradd -s c -l comment --description 'A comment about this user' -r
complete -c useradd -s d -l home --description 'Home directory for the new user' -x -a '(__fish_complete_directories)'
-complete -c useradd -s G -l groups --description 'Supplementary groups' -xa '(__fish_append , (cat /etc/group|cut -d : -f 1))'
+complete -c useradd -s G -l groups --description 'Supplementary groups' -xa '(__fish_append , (cut -d : -f 1 /etc/group))'
complete -c useradd -s h -l help --description 'Display help message and exit'
complete -c useradd -s m -l create-home --description 'The user\'s home directory will be created if it does not exist'
complete -c useradd -s n --description 'A group having the same name as the user being added to the system will be created by default (when -g is not specified)'
diff --git a/share/completions/xprop.fish b/share/completions/xprop.fish
index da56ea609..25bc299c3 100644
--- a/share/completions/xprop.fish
+++ b/share/completions/xprop.fish
@@ -1,3 +1,7 @@
+function __fish_xprop_list_properties
+ # TODO search commandline for a target window ("-root" or "-name foo")
+ xprop -root | cut -d'(' -f 1
+end
complete -c xprop -o help --description "Display help and exit"
complete -c xprop -o grammar --description "Display grammar and exit"
@@ -10,23 +14,9 @@ complete -c xprop -o len -x --description "Maximum display length"
complete -c xprop -o notype --description "Do not show property type"
complete -c xprop -o fs -r --description "Set format file"
complete -c xprop -o frame --description "Select a window by clicking on its frame"
-complete -c xprop -o remove --description "Remove property" -x -a "
-(
- xprop -root -notype|cut -d ' ' -f 1|cut -d \t -f 1
-)
-"
-
-complete -c xprop -o set --description "Set property" -x -a "
-(
- xprop -root -notype|cut -d ' ' -f 1|cut -d \t -f 1
-)
-"
-
+complete -c xprop -o remove --description "Remove property" -x -a "( __fish_xprop_list_properties)"
+complete -c xprop -o set --description "Set property" -x -a " (__fish_xprop_list_properties)"
complete -c xprop -o spy --description "Examine property updates forever"
complete -c xprop -o f --description "Set format"
-complete -c xprop -d Property -x -a "
-(
- xprop -root -notype|cut -d ' ' -f 1|cut -d \t -f 1
-)
-"
+complete -c xprop -d Property -x -a "( __fish_xprop_list_properties)"
diff --git a/share/functions/__fish_complete_lsusb.fish b/share/functions/__fish_complete_lsusb.fish
index eba9cd29e..b6814b29f 100644
--- a/share/functions/__fish_complete_lsusb.fish
+++ b/share/functions/__fish_complete_lsusb.fish
@@ -1,3 +1,3 @@
function __fish_complete_lsusb
- lsusb | awk '{print $2 ":" $4}' | cut -c1-7
+ lsusb | awk -F[ :] '{ print $2 ":" $4 }'
end
diff --git a/share/functions/__fish_print_function_prototypes.fish b/share/functions/__fish_print_function_prototypes.fish
index 862b8dcc9..d50c43d6d 100644
--- a/share/functions/__fish_print_function_prototypes.fish
+++ b/share/functions/__fish_print_function_prototypes.fish
@@ -1,5 +1,8 @@
function __fish_print_function_prototypes -d "Prints the names of all function prototypes found in the headers in the current directory"
- cat *.h* | sed -n "s/^\(.*[^[a-zA-Z_0-9]\|\)\([a-zA-Z_][a-zA-Z_0-9]*\) *(.*);.*\$/\2/p"
+ set -l headers *.h *.hh *.hpp *.hxx
+ if set -q headers[1]
+ sed -n "s/^\(.*[^[a-zA-Z_0-9]\|\)\([a-zA-Z_][a-zA-Z_0-9]*\) *(.*);.*\$/\2/p" $headers
+ end
end
diff --git a/share/functions/__fish_print_packages.fish b/share/functions/__fish_print_packages.fish
index 1dc0893c4..c3985cd13 100644
--- a/share/functions/__fish_print_packages.fish
+++ b/share/functions/__fish_print_packages.fish
@@ -56,7 +56,7 @@ function __fish_print_packages
if type -q -f zypper
# Use libzypp cache file if available
if test -f /var/cache/zypp/solv/@System/solv.idx
- cat /var/cache/zypp/solv/*/solv.idx | awk '!/application:|srcpackage:|product:|pattern:|patch:/ {print $1'\t$package'}'
+ awk '!/application:|srcpackage:|product:|pattern:|patch:/ {print $1'\t$package'}' /var/cache/zypp/solv/*/solv.idx
return
end
diff --git a/share/functions/__fish_print_xdg_mimetypes.fish b/share/functions/__fish_print_xdg_mimetypes.fish
index 39f9a2798..5d944a623 100644
--- a/share/functions/__fish_print_xdg_mimetypes.fish
+++ b/share/functions/__fish_print_xdg_mimetypes.fish
@@ -1,5 +1,3 @@
function __fish_print_xdg_mimetypes --description 'Print XDG mime types'
- cat ~/.local/share/applications/mimeinfo.cache | grep -v "\[MIME Cache\]" | tr = \t
- cat /usr/share/applications/mimeinfo.cache | grep -v "\[MIME Cache\]" | tr = \t
-
+ cat ~/.local/share/applications/mimeinfo.cache /usr/share/applications/mimeinfo.cache ^/dev/null | string match -v '[MIME Cache]' | string replace = \t
end
diff --git a/share/functions/__fish_svn_prompt.fish b/share/functions/__fish_svn_prompt.fish
index a201f4542..243c02285 100644
--- a/share/functions/__fish_svn_prompt.fish
+++ b/share/functions/__fish_svn_prompt.fish
@@ -126,7 +126,7 @@ function __fish_svn_prompt --description "Prompt function for svn"
if [ (count $column_status) -ne 0 ]
# we only want to display unique status flags (eg: if there are 5 modified files, the prompt should only show the modified status once)
- set -l column_unique_status (echo $column_status | sort | uniq)
+ set -l column_unique_status (echo $column_status | sort -u)
# parse the status flags for this column and create the formatting by calling out to the helper function
set -l svn_status_flags (__fish_svn_prompt_parse_status $column_unique_status)
@@ -146,4 +146,4 @@ function __fish_svn_prompt --description "Prompt function for svn"
# print the close of the svn status prompt
printf ')'
-end
\ No newline at end of file
+end