[Bash-completion-devel] For the completion of modprobe could you add the following for the insert case?

Linda Walsh bash at tlinx.org
Tue Jan 29 10:51:40 UTC 2013


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" ) )





More information about the Bash-completion-devel mailing list