mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-25 20:33:08 +00:00
Merge pull request #3666 from drwilly/master
mixed bag of shell scripting improvements
This commit is contained in:
commit
a070dffc4e
15 changed files with 45 additions and 43 deletions
|
@ -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'
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
||||
|
||||
|
|
|
@ -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'
|
||||
|
|
|
@ -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 <dir> 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)"
|
||||
|
||||
|
|
|
@ -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'
|
||||
)
|
||||
"
|
||||
|
||||
|
|
|
@ -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.<filesystem> 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"
|
||||
|
||||
|
|
|
@ -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)'
|
||||
|
|
|
@ -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)"
|
||||
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
function __fish_complete_lsusb
|
||||
lsusb | awk '{print $2 ":" $4}' | cut -c1-7
|
||||
lsusb | awk -F[ :] '{ print $2 ":" $4 }'
|
||||
end
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue