It doesn't handle the "-r" case that you already had, but it does
remove already loaded modules from the list that is displayed.

#!/bin/bash

function _clean_n_sort_mods {
  modprobe -l |
   sed -r  's!^.*/([^/]+)\.ko[   ]*$!\1! ' |
   sort
}

function _loaded_mods {
 lsmod |sed -r 's/ .*$//'
}

function _newmods {
 local cur prev words cword
# _init_completion || return
 local -a replies
readarray -t replies< <(echo "$(_clean_n_sort_mods) $(_loaded_mods)"|sort|uniq -u) COMPREPLY=( $(compgen -W "$(echo "$(_clean_n_sort_mods) $(_loaded_mods)"|sort|uniq -u)" -- "$cur" ) )



_______________________________________________
Bash-completion-devel mailing list
[email protected]
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/bash-completion-devel

Reply via email to