add initial bash completions

This commit is contained in:
Eli Schwartz 2019-06-05 15:06:59 -04:00
parent d7031c7ccf
commit 1cb88d9739
No known key found for this signature in database
GPG Key ID: CEB167EFB5722BD6
3 changed files with 96 additions and 0 deletions

View File

@ -0,0 +1,27 @@
_arch_chroot() {
compopt +o dirnames
local cur prev opts
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
opts="-u -h"
for i in "${COMP_WORDS[@]:1:COMP_CWORD-1}"; do
if [[ -d ${i} ]]; then
return 0
fi
done
if [[ ${prev} = -u ]]; then
_usergroup -u
return 0
fi
if [[ ${cur} = -* ]]; then
COMPREPLY=($(compgen -W "${opts}" -- "${cur}"))
return 0
fi
compopt -o dirnames
}
complete -F _arch_chroot arch-chroot

31
completion/genfstab.bash Normal file
View File

@ -0,0 +1,31 @@
_genfstab() {
compopt -o dirnames
local cur prev words cword
_init_completion || return
local opts="-f -L -p -P -t -U -h"
case ${prev} in
-f)
return 0
;;
-t)
COMPREPLY=($(compgen -W "LABEL UUID PARTLABEL PARTUUID" -- "${cur}"))
return 0
;;
esac
if [[ ${cur} = -* ]]; then
COMPREPLY=($(compgen -W "${opts}" -- "${cur}"))
return 0
fi
for i in "${COMP_WORDS[@]:1:COMP_CWORD-1}"; do
if [[ -d ${i} ]]; then
compopt +o dirnames
return 0
fi
done
}
complete -F _genfstab genfstab

38
completion/pacstrap.bash Normal file
View File

@ -0,0 +1,38 @@
if ! declare -F _pacman_pkg > /dev/null; then
_completion_loader pacman
fi
_pacstrap() {
compopt +o dirnames +o default
local cur prev opts
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
opts="-C -c -G -i -M -h"
for i in "${COMP_WORDS[@]:1:COMP_CWORD-1}"; do
if [[ -d ${i} ]]; then
_pacman_pkg Slq
return 0
fi
done
case ${prev} in
-h)
return 0
;;
-C)
compopt -o default
return 0
;;
esac
if [[ ${cur} = -* ]]; then
COMPREPLY=($(compgen -W "${opts}" -- "${cur}"))
return 0
fi
compopt -o dirnames
}
complete -F _pacstrap pacstrap