Skip to content

Commit 66ec66e

Browse files
Dystopianscop
andauthored
kldload: look up more module dirs (#744)
Co-authored-by: Ville Skyttä <[email protected]>
1 parent dba3181 commit 66ec66e

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

completions/kldload

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,26 @@ _kldload()
77
local cur prev words cword
88
_init_completion || return
99

10-
local moddir=/modules/
11-
[[ -d $moddir ]] || moddir=/boot/kernel/
10+
if [[ "$cur" == */* ]]; then
11+
_filedir ko
12+
return
13+
fi
14+
15+
local moddirs modules i IFS=";"
16+
moddirs=($(kldconfig -r 2>/dev/null))
17+
_comp_unlocal IFS
1218

1319
compopt -o filenames
14-
COMPREPLY=($(compgen -f "$moddir$cur"))
15-
COMPREPLY=(${COMPREPLY[@]#$moddir})
20+
for i in "${moddirs[@]}"; do
21+
modules=($(compgen -f "$i/$cur"))
22+
modules=(${modules[@]#$i/})
23+
COMPREPLY+=("${modules[@]}")
24+
done
1625
COMPREPLY=(${COMPREPLY[@]%.ko})
1726

27+
# also add dirs in current dir
28+
_filedir -d
29+
1830
} &&
1931
complete -F _kldload kldload
2032

0 commit comments

Comments
 (0)