diff options
author | Clément Martinez <clementmartinezdev@gmail.com> | 2016-06-08 15:13:18 +0200 |
---|---|---|
committer | Clément Martinez <clementmartinezdev@gmail.com> | 2016-06-08 15:13:18 +0200 |
commit | 059e11078cf65269f17c8d100c49c9a6811b9ec9 (patch) | |
tree | d31f0191fab04008e75b586445652267f6dcfdb2 | |
parent | e30db95baa3916b008a4d4a9b265e98018854bc9 (diff) |
Split __fish_print_modules from modprob.fish and modinfo.fish
-rw-r--r-- | share/completions/modinfo.fish | 30 | ||||
-rw-r--r-- | share/completions/modprobe.fish | 6 | ||||
-rw-r--r-- | share/functions/__fish_print_modules.fish | 4 |
3 files changed, 20 insertions, 20 deletions
diff --git a/share/completions/modinfo.fish b/share/completions/modinfo.fish index 2d034d05..eca5014d 100644 --- a/share/completions/modinfo.fish +++ b/share/completions/modinfo.fish @@ -1,16 +1,16 @@ -function __fish_print_modules - find /lib/modules/(uname -r)/{kernel,misc} -type f 2>/dev/null | sed -e 's$/.*/\([^/.]*\).*$\1$' +if command -s uname > /dev/null ^/dev/null + if test (uname) = "Linux" + complete -c modinfo -a "(__fish_print_modules)" + complete -c modinfo -l author -s a -d "Print only 'author'" + complete -c modinfo -l description -s d -d "Print only 'description'" + complete -c modinfo -l license -s l -d "Print only 'license'" + complete -c modinfo -l parameters -s p -d "Print only 'parm'" + complete -c modinfo -l filename -s n -d "Print only 'filename'" + complete -c modinfo -l null -s 0 -d "Use \\0 instead of \\n" + complete -c modinfo -l field -s F -x -d "Print only provided FIELD" -a "author description license parm depends alias intree vermagic vermagic" + complete -c modinfo -l set-version -s k -x -d "Use VERSION instead of `uname -r`" + complete -c modinfo -l basedir -s b -r -d "Use DIR as filesystem root for /lib/modules" + complete -c modinfo -l version -s V -d "Show version" + complete -c modinfo -l help -s h -d "Show help" + end end - -complete -c modinfo -a "(__fish_print_modules)" -complete -c modinfo -l author -s a -d "Print only 'author'" -complete -c modinfo -l description -s d -d "Print only 'description'" -complete -c modinfo -l license -s l -d "Print only 'license'" -complete -c modinfo -l parameters -s p -d "Print only 'parm'" -complete -c modinfo -l filename -s n -d "Print only 'filename'" -complete -c modinfo -l null -s 0 -d "Use \\0 instead of \\n" -complete -c modinfo -l field -s F -x -d "Print only provided FIELD" -a "author description license parm depends alias intree vermagic vermagic" -complete -c modinfo -l set-version -s k -x -d "Use VERSION instead of `uname -r`" -complete -c modinfo -l basedir -s b -r -d "Use DIR as filesystem root for /lib/modules" -complete -c modinfo -l version -s V -d "Show version" -complete -c modinfo -l help -s h -d "Show help" diff --git a/share/completions/modprobe.fish b/share/completions/modprobe.fish index 8075d437..c3bd9938 100644 --- a/share/completions/modprobe.fish +++ b/share/completions/modprobe.fish @@ -1,9 +1,5 @@ -# -# Completions for the modprobe command -# - complete -c modprobe -n "__fish_contains_opt -s r remove" --no-files -d Module -a "(lsmod | cut -d' ' -f1)" -complete -c modprobe -n "not __fish_contains_opt -s r remove" --no-files -d Module -a "(find /lib/modules/(uname -r)/{kernel,misc} -type f 2>/dev/null | sed -e 's/\/.*\/\([^\/.]*\).*/\1/')" +complete -c modprobe -n "not __fish_contains_opt -s r remove" --no-files -d Module -a "(__fish_print_modules)" complete -c modprobe -s v -l verbose --description "Print messages about what the program is doing" complete -c modprobe -s C -l config --description "Configuration file" -r complete -c modprobe -s c -l showconfig --description "Dump configuration file" diff --git a/share/functions/__fish_print_modules.fish b/share/functions/__fish_print_modules.fish new file mode 100644 index 00000000..e237e7a1 --- /dev/null +++ b/share/functions/__fish_print_modules.fish @@ -0,0 +1,4 @@ +# Helper function for completions that need to enumerate Linux modules +function __fish_print_modules + find /lib/modules/(uname -r)/{kernel,misc} -type f ^ /dev/null | sed -e 's$/.*/\([^/.]*\).*$\1$' +end |