general: Started working on completion.
This commit is contained in:
parent
3889bf8dd4
commit
4afaff4223
1 changed files with 37 additions and 0 deletions
37
completions/neofetch-completion.bash
Normal file
37
completions/neofetch-completion.bash
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
#
|
||||||
|
# Shell completion for neofetch.
|
||||||
|
|
||||||
|
_neofetch_completions() {
|
||||||
|
local flags cur prev
|
||||||
|
|
||||||
|
# User input.
|
||||||
|
cur="${COMP_WORDS[COMP_CWORD]}"
|
||||||
|
prev="${COMP_WORDS[COMP_CWORD-1]}"
|
||||||
|
|
||||||
|
# Generate a list of flags.
|
||||||
|
IFS=$'\n' read -d "" -ra flags \
|
||||||
|
< <(neofetch --help | awk '/^ --/{print $1}')
|
||||||
|
|
||||||
|
# Complete partial matches.
|
||||||
|
IFS=$'\n' read -d "" -ra COMPREPLY \
|
||||||
|
< <(compgen -W "${flags[*]}" -- "$cur")
|
||||||
|
|
||||||
|
|
||||||
|
case "$prev" in
|
||||||
|
"--disable")
|
||||||
|
conf="${HOME}/.config/neofetch/config.conf"
|
||||||
|
|
||||||
|
[[ -f "$conf" ]] &&
|
||||||
|
IFS=$'\n' read -d "" -ra COMPREPLY \
|
||||||
|
< <(awk '/ info /&&!a[$0]++{print $NF}' "$conf")
|
||||||
|
;;
|
||||||
|
|
||||||
|
"--backend")
|
||||||
|
IFS=$'\n' read -d "" -ra COMPREPLY \
|
||||||
|
< <(neofetch --help | awk -F\' '/ Shortcut/ {print $2}')
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
|
complete -F _neofetch_completions neofetch
|
Loading…
Add table
Add a link
Reference in a new issue