general: Started working on completion.
This commit is contained in:
parent
4afaff4223
commit
c0708d86c2
1 changed files with 30 additions and 6 deletions
|
@ -3,19 +3,19 @@
|
||||||
# Shell completion for neofetch.
|
# Shell completion for neofetch.
|
||||||
|
|
||||||
_neofetch_completions() {
|
_neofetch_completions() {
|
||||||
local flags cur prev
|
local flags cur prev usage
|
||||||
|
|
||||||
|
usage="$(neofetch --help)"
|
||||||
|
|
||||||
# User input.
|
# User input.
|
||||||
cur="${COMP_WORDS[COMP_CWORD]}"
|
cur="${COMP_WORDS[COMP_CWORD]}"
|
||||||
prev="${COMP_WORDS[COMP_CWORD-1]}"
|
prev="${COMP_WORDS[COMP_CWORD-1]}"
|
||||||
|
|
||||||
# Generate a list of flags.
|
# Generate a list of flags.
|
||||||
IFS=$'\n' read -d "" -ra flags \
|
IFS=$'\n' read -d "" -ra flags < <(awk '/^ --/{print $1}' <<< "$usage")
|
||||||
< <(neofetch --help | awk '/^ --/{print $1}')
|
|
||||||
|
|
||||||
# Complete partial matches.
|
# Complete partial matches.
|
||||||
IFS=$'\n' read -d "" -ra COMPREPLY \
|
IFS=$'\n' read -d "" -ra COMPREPLY < <(compgen -W "${flags[*]}" -- "$cur")
|
||||||
< <(compgen -W "${flags[*]}" -- "$cur")
|
|
||||||
|
|
||||||
|
|
||||||
case "$prev" in
|
case "$prev" in
|
||||||
|
@ -29,7 +29,31 @@ _neofetch_completions() {
|
||||||
|
|
||||||
"--backend")
|
"--backend")
|
||||||
IFS=$'\n' read -d "" -ra COMPREPLY \
|
IFS=$'\n' read -d "" -ra COMPREPLY \
|
||||||
< <(neofetch --help | awk -F\' '/ Shortcut/ {print $2}')
|
< <(awk -F\' '/ Shortcut/ {print $2}' <<< "$usage")
|
||||||
|
;;
|
||||||
|
|
||||||
|
"--os_arch"|\
|
||||||
|
"--speed_shorthand"|\
|
||||||
|
"--cpu_brand"|\
|
||||||
|
"--cpu_speed"|\
|
||||||
|
"--distro_shorthand"|\
|
||||||
|
"--kernel_shorthand"|\
|
||||||
|
"--uptime_shorthand"|\
|
||||||
|
"--refresh_rate"|\
|
||||||
|
"--gpu_brand"|\
|
||||||
|
"--gtk_shorthand"|\
|
||||||
|
"--gtk2"|\
|
||||||
|
"--gtk3"|\
|
||||||
|
"--shell_path"|\
|
||||||
|
"--shell_version"|\
|
||||||
|
"--song_shorthand"|\
|
||||||
|
"--install_time"|\
|
||||||
|
"--underline"|\
|
||||||
|
"--bold"|\
|
||||||
|
"--color_blocks"|\
|
||||||
|
"--bar_border"|\
|
||||||
|
"--ascii_bold")
|
||||||
|
COMPREPLY=("on" "off")
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue