completion: Finish args

This commit is contained in:
Dylan Araps 2018-05-30 20:55:19 +10:00
parent f8b5e3bb32
commit 530928186f

View file

@ -4,410 +4,418 @@
shopt -s nullglob shopt -s nullglob
_neofetch_completions() { _neofetch_completions() {
local cur prev local cur prev usage
cur="${COMP_WORDS[COMP_CWORD]}" cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}" prev="${COMP_WORDS[COMP_CWORD-1]}"
IFS=$'\n' read -d "" -ra COMPREPLY \ if [[ "$cur" == -* ]]; then
< <(compgen -W "$(neofetch -h | awk '/ --/{printf $1" "}')" -- "$cur") usage="$(neofetch -h | awk '/^ --/{printf $1" "}')"
case "$prev" in IFS=$'\n' read -d "" -ra COMPREPLY \
"--disable") < <(compgen -W "$usage" -- "$cur")
conf="${HOME}/.config/neofetch/config.conf"
[[ -f "$conf" ]] && else
IFS=$'\n' read -d "" -ra COMPREPLY \ case "$prev" in
< <(awk '/ info /&&!a[$0]++{print $NF}' "$conf") "--disable")
;; conf="${HOME}/.config/neofetch/config.conf"
"--backend") [[ -f "$conf" ]] &&
COMPREPLY=( IFS=$'\n' read -d "" -ra values \
"ascii" < <(awk '/ info /&&!a[$0]++{print $NF}' "$conf")
"caca" ;;
"iterm2"
"jp2a"
"kitty"
"pixterm"
"sixel"
"termpix"
"tycat"
"w3m"
"off"
)
;;
"--os_arch"|\ "--backend")
"--speed_shorthand"|\ values=(
"--cpu_brand"|\ "ascii"
"--cpu_speed"|\ "caca"
"--distro_shorthand"|\ "iterm2"
"--kernel_shorthand"|\ "jp2a"
"--uptime_shorthand"|\ "kitty"
"--refresh_rate"|\ "pixterm"
"--gpu_brand"|\ "sixel"
"--gtk_shorthand"|\ "termpix"
"--gtk2"|\ "tycat"
"--gtk3"|\ "w3m"
"--shell_path"|\ "off"
"--shell_version"|\ )
"--song_shorthand"|\ ;;
"--install_time"|\
"--underline"|\
"--bold"|\
"--color_blocks"|\
"--bar_border"|\
"--ascii_bold")
COMPREPLY=(
"on"
"off"
)
;;
"--speed_type") "--os_arch"|\
COMPREPLY=( "--speed_shorthand"|\
"current" "--cpu_brand"|\
"min" "--cpu_speed"|\
"max" "--distro_shorthand"|\
"bios" "--kernel_shorthand"|\
"scaling_current" "--uptime_shorthand"|\
"scaling_min" "--refresh_rate"|\
"scaling_max" "--gpu_brand"|\
) "--gtk_shorthand"|\
;; "--gtk2"|\
"--gtk3"|\
"--shell_path"|\
"--shell_version"|\
"--song_shorthand"|\
"--install_time"|\
"--underline"|\
"--bold"|\
"--color_blocks"|\
"--bar_border"|\
"--ascii_bold")
values=(
"on"
"off"
)
;;
"--cpu_cores") "--speed_type")
COMPREPLY=( values=(
"logical" "current"
"physical" "min"
"off" "max"
) "bios"
;; "scaling_current"
"scaling_min"
"scaling_max"
)
;;
"--cpu_temp") "--cpu_cores")
COMPREPLY=( values=(
"C" "logical"
"F" "physical"
"off" "off"
) )
;; ;;
"--gpu_type") "--cpu_temp")
COMPREPLY=( values=(
"all" "C"
"dedicated" "F"
"integrated" "off"
) )
;; ;;
"--disk_show") "--gpu_type")
COMPREPLY=( values=(
"/dev/sd"* "all"
"/" "dedicated"
) "integrated"
;; )
;;
"--disk_subtitle") "--disk_show")
COMPREPLY=( values=(
"name" "/dev/sd"*
"mount" "/"
"dir" )
) ;;
;;
"--ip_host") "--disk_subtitle")
COMPREPLY=( values=(
"http://ident.me" "name"
) "mount"
;; "dir"
)
;;
"--song_format") "--ip_host")
COMPREPLY=( values=(
"\"%artist% - %album% - %title%\"" "http://ident.me"
"\"%artist - %title\"" )
) ;;
;;
"--music_player") "--song_format")
COMPREPLY=( values=(
"amarok" "\"%artist% - %album% - %title%\""
"audacious" "\"%artist - %title\""
"banshee" )
"bluemindo" ;;
"clementine"
"cmus"
"deadbeef"
"deepin-music"
"elisa"
"exaile"
"gnome-music"
"Google Play"
"guayadeque"
"iTunes"
"juk"
"lollypop"
"mocp"
"mopidy"
"mpd"
"pogo"
"pragha"
"qmmp"
"quodlibet"
"rhythmbox"
"sayonara"
"spotify"
"Spotify"
"tomahawk"
"vlc"
"xmms2d"
"yarock"
)
;;
"--install_time_format") "--music_player")
COMPREPLY=( values=(
"12h" "amarok"
"24h" "audacious"
) "banshee"
;; "bluemindo"
"clementine"
"cmus"
"deadbeef"
"deepin-music"
"elisa"
"exaile"
"gnome-music"
"Google Play"
"guayadeque"
"iTunes"
"juk"
"lollypop"
"mocp"
"mopidy"
"mpd"
"pogo"
"pragha"
"qmmp"
"quodlibet"
"rhythmbox"
"sayonara"
"spotify"
"Spotify"
"tomahawk"
"vlc"
"xmms2d"
"yarock"
)
;;
"--underline_char") "--install_time_format")
COMPREPLY=( values=(
"_" "12h"
"-" "24h"
"." )
"⎯" ;;
"―"
)
;;
"--block_width"|\ "--underline_char")
"--block_height"|\ values=(
"--bar_length") "_"
COMPREPLY=( "-"
{1..9} "."
) "⎯"
;; "―"
)
;;
"--cpu_display"|\ "--block_width"|\
"--memory_display"|\ "--block_height"|\
"--battery_display"|\ "--bar_length")
"--disk_display") values=(
COMPREPLY=( {1..9}
"bar" )
"infobar" ;;
"barinfo"
"off"
)
;;
"--source"|\ "--cpu_display"|\
"--ascii"|\ "--memory_display"|\
"--caca"|\ "--battery_display"|\
"--iterm2"|\ "--disk_display")
"--jp2a"|\ values=(
"--kitty"|\ "bar"
"--pixterm"|\ "infobar"
"--sixel"|\ "barinfo"
"--termpix"|\ "off"
"--tycat"|\ )
"--w3m") ;;
COMPREPLY=(
"auto"
"ascii"
"wallpaper"
"/path/to/img.jpg"
"/path/to/images"
"/path/to/ascii_file"
)
;; "--source"|\
"--ascii"|\
"--caca"|\
"--iterm2"|\
"--jp2a"|\
"--kitty"|\
"--pixterm"|\
"--sixel"|\
"--termpix"|\
"--tycat"|\
"--w3m")
values=(
"auto"
"ascii"
"wallpaper"
"/path/to/img.jpg"
"/path/to/images"
"/path/to/ascii_file"
)
"--ascii_distro") ;;
COMPREPLY=(
"aix"
"alpine"
"alpine_small"
"amazon"
"anarchy"
"android"
"antergos"
"antix"
"aosc"
"apricity"
"arch"
"arch_old"
"arch_small"
"archbox"
"archlabs"
"archmerge"
"arcolinux"
"artix"
"arya"
"bitrig"
"blag"
"blankon"
"bsd"
"bunsenlabs"
"calculate"
"centos"
"chakra"
"chaletos"
"chapeau"
"chrom"
"clover"
"crux"
"crux_small"
"darwin"
"debian"
"debian_small"
"deepin"
"desaos"
"devuan"
"dracos"
"dragonfly"
"dragonfly_old"
"dragonfly_small"
"elementary"
"endless"
"exherbo"
"fedora"
"freebsd"
"freebsd_small"
"freemint"
"frugalware"
"funtoo"
"galliumos"
"gentoo"
"gentoo_small"
"gnewsense"
"gnu"
"gobolinux"
"grombyang"
"guixsd"
"haiku"
"hyperbola"
"irix"
"kali"
"kaos"
"kde"
"kogaion"
"korora"
"kslinux"
"kubuntu"
"lede"
"linux"
"linux mint"
"lmde"
"lubuntu"
"lunar"
"mac"
"mageia"
"magpieos"
"manjaro"
"maui"
"mer"
"minix"
"mx"
"netbsd"
"netrunner"
"nitrux"
"nixos"
"nixos_small"
"nurunner"
"nutyx"
"obrevenge"
"open source media center"
"openbsd"
"openbsd_small"
"openindiana"
"openmandriva"
"opensuse"
"openwrt"
"oracle"
"pacbsd"
"parabola"
"pardus"
"parrot"
"parsix"
"pcbsd"
"pclinuxos"
"peppermint"
"porteus"
"postmarketos"
"puppy"
"qubes"
"raspbian"
"red star"
"redcore"
"redhat"
"rosa"
"sabayon"
"sabotage"
"sailfishos"
"salentos"
"scientific"
"siduction"
"slackware"
"slitaz"
"smartos"
"solus"
"sparky"
"steamos"
"sunos"
"swagarch"
"tails"
"trisquel"
"ubuntu"
"ubuntu_old"
"void"
"void_small"
"windows"
"windows 10"
"xferience"
"xubuntu"
"zorin"
)
;;
"--size") "--ascii_distro")
COMPREPLY=( values=(
"00px" "aix"
"00%" "alpine"
"auto" "alpine_small"
"none" "amazon"
) "anarchy"
;; "android"
"antergos"
"antix"
"aosc"
"apricity"
"arch"
"arch_old"
"arch_small"
"archbox"
"archlabs"
"archmerge"
"arcolinux"
"artix"
"arya"
"bitrig"
"blag"
"blankon"
"bsd"
"bunsenlabs"
"calculate"
"centos"
"chakra"
"chaletos"
"chapeau"
"chrom"
"clover"
"crux"
"crux_small"
"darwin"
"debian"
"debian_small"
"deepin"
"desaos"
"devuan"
"dracos"
"dragonfly"
"dragonfly_old"
"dragonfly_small"
"elementary"
"endless"
"exherbo"
"fedora"
"freebsd"
"freebsd_small"
"freemint"
"frugalware"
"funtoo"
"galliumos"
"gentoo"
"gentoo_small"
"gnewsense"
"gnu"
"gobolinux"
"grombyang"
"guixsd"
"haiku"
"hyperbola"
"irix"
"kali"
"kaos"
"kde"
"kogaion"
"korora"
"kslinux"
"kubuntu"
"lede"
"linux"
"linux mint"
"lmde"
"lubuntu"
"lunar"
"mac"
"mageia"
"magpieos"
"manjaro"
"maui"
"mer"
"minix"
"mx"
"netbsd"
"netrunner"
"nitrux"
"nixos"
"nixos_small"
"nurunner"
"nutyx"
"obrevenge"
"open source media center"
"openbsd"
"openbsd_small"
"openindiana"
"openmandriva"
"opensuse"
"openwrt"
"oracle"
"pacbsd"
"parabola"
"pardus"
"parrot"
"parsix"
"pcbsd"
"pclinuxos"
"peppermint"
"porteus"
"postmarketos"
"puppy"
"qubes"
"raspbian"
"red star"
"redcore"
"redhat"
"rosa"
"sabayon"
"sabotage"
"sailfishos"
"salentos"
"scientific"
"siduction"
"slackware"
"slitaz"
"smartos"
"solus"
"sparky"
"steamos"
"sunos"
"swagarch"
"tails"
"trisquel"
"ubuntu"
"ubuntu_old"
"void"
"void_small"
"windows"
"windows 10"
"xferience"
"xubuntu"
"zorin"
)
;;
"--crop_mode") "--size")
COMPREPLY=( values=(
"normal" "00px"
"fit" "00%"
"fill" "auto"
) "none"
;; )
;;
"--crop_offset") "--crop_mode")
COMPREPLY=( values=(
"northwest" "normal"
"north" "fit"
"northeast" "fill"
"west" )
"center" ;;
"east"
"southwest"
"south"
"southeast"
)
;;
"--config") "--crop_offset")
COMPREPLY=( values=(
"none" "northwest"
"/path/to/config" "north"
) "northeast"
;; "west"
esac "center"
"east"
"southwest"
"south"
"southeast"
)
;;
"--config")
values=(
"none"
"/path/to/config"
)
;;
esac
IFS=$'\n' read -d "" -ra COMPREPLY \
< <(compgen -W "${values[*]}" -- "$cur")
fi
} }
complete -F _neofetch_completions neofetch complete -F _neofetch_completions neofetch