forked from scop/bash-completion
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
One of the useful features of grubby is the ability to use tab completion to easily find and specify the kernel version we want to do with it. This saves time compared to manually checking the full path of different kernel versions installed
- Loading branch information
1 parent
0543d1a
commit 9477af0
Showing
1 changed file
with
45 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# grubby(8) completion -*- shell-script -*- | ||
|
||
_grubby() { | ||
local cur prev commands | ||
commands="--default-kernel --default-index --default-title --info --make-default --set-default --set-default-index --update-kernel --args --remove-args" | ||
|
||
COMPREPLY=() | ||
cur="${COMP_WORDS[COMP_CWORD]}" | ||
prev="${COMP_WORDS[COMP_CWORD - 1]}" | ||
|
||
case "${prev}" in | ||
grubby) | ||
COMPREPLY=($(compgen -W "${commands}" -- ${cur})) | ||
return 0 | ||
;; | ||
--info) | ||
kernels=$(ls /boot/vmlinuz-*) | ||
COMPREPLY=($(compgen -W "ALL DEFAULT $kernels" -- ${cur})) | ||
return 0 | ||
;; | ||
--set-default) | ||
kernels=$(ls /boot/vmlinuz-*) | ||
COMPREPLY=($(compgen -W "$kernels" -- ${cur})) | ||
return 0 | ||
;; | ||
--set-default-index) | ||
numkernels=$(ls -t /boot/loader/entries/ | wc -l) | ||
maxindex=$((numkernels - 1)) | ||
indexes=$(echo $(seq 0 $maxindex)) | ||
COMPREPLY=($(compgen -W "$indexes" -- ${cur})) | ||
return 0 | ||
;; | ||
--update-kernel) | ||
kernels=$(ls /boot/vmlinuz-*) | ||
COMPREPLY=($(compgen -W "$kernels" -- ${cur})) | ||
return 0 | ||
;; | ||
--args | --remove-args) | ||
COMPREPLY=($(compgen -W "" -- ${cur})) | ||
return 0 | ||
;; | ||
*) ;; | ||
esac | ||
} | ||
complete -F _grubby grubby |