diff --git a/completions/neofetch-completion.bash b/completions/neofetch-completion.bash index b4b43f48..8c3468ca 100644 --- a/completions/neofetch-completion.bash +++ b/completions/neofetch-completion.bash @@ -4,410 +4,418 @@ shopt -s nullglob _neofetch_completions() { - local cur prev + local cur prev usage cur="${COMP_WORDS[COMP_CWORD]}" prev="${COMP_WORDS[COMP_CWORD-1]}" - IFS=$'\n' read -d "" -ra COMPREPLY \ - < <(compgen -W "$(neofetch -h | awk '/ --/{printf $1" "}')" -- "$cur") + if [[ "$cur" == -* ]]; then + usage="$(neofetch -h | awk '/^ --/{printf $1" "}')" - case "$prev" in - "--disable") - conf="${HOME}/.config/neofetch/config.conf" + IFS=$'\n' read -d "" -ra COMPREPLY \ + < <(compgen -W "$usage" -- "$cur") - [[ -f "$conf" ]] && - IFS=$'\n' read -d "" -ra COMPREPLY \ - < <(awk '/ info /&&!a[$0]++{print $NF}' "$conf") - ;; + else + case "$prev" in + "--disable") + conf="${HOME}/.config/neofetch/config.conf" - "--backend") - COMPREPLY=( - "ascii" - "caca" - "iterm2" - "jp2a" - "kitty" - "pixterm" - "sixel" - "termpix" - "tycat" - "w3m" - "off" - ) - ;; + [[ -f "$conf" ]] && + IFS=$'\n' read -d "" -ra values \ + < <(awk '/ info /&&!a[$0]++{print $NF}' "$conf") + ;; - "--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" - ) - ;; + "--backend") + values=( + "ascii" + "caca" + "iterm2" + "jp2a" + "kitty" + "pixterm" + "sixel" + "termpix" + "tycat" + "w3m" + "off" + ) + ;; - "--speed_type") - COMPREPLY=( - "current" - "min" - "max" - "bios" - "scaling_current" - "scaling_min" - "scaling_max" - ) - ;; + "--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") + values=( + "on" + "off" + ) + ;; - "--cpu_cores") - COMPREPLY=( - "logical" - "physical" - "off" - ) - ;; + "--speed_type") + values=( + "current" + "min" + "max" + "bios" + "scaling_current" + "scaling_min" + "scaling_max" + ) + ;; - "--cpu_temp") - COMPREPLY=( - "C" - "F" - "off" - ) - ;; + "--cpu_cores") + values=( + "logical" + "physical" + "off" + ) + ;; - "--gpu_type") - COMPREPLY=( - "all" - "dedicated" - "integrated" - ) - ;; + "--cpu_temp") + values=( + "C" + "F" + "off" + ) + ;; - "--disk_show") - COMPREPLY=( - "/dev/sd"* - "/" - ) - ;; + "--gpu_type") + values=( + "all" + "dedicated" + "integrated" + ) + ;; - "--disk_subtitle") - COMPREPLY=( - "name" - "mount" - "dir" - ) - ;; + "--disk_show") + values=( + "/dev/sd"* + "/" + ) + ;; - "--ip_host") - COMPREPLY=( - "http://ident.me" - ) - ;; + "--disk_subtitle") + values=( + "name" + "mount" + "dir" + ) + ;; - "--song_format") - COMPREPLY=( - "\"%artist% - %album% - %title%\"" - "\"%artist - %title\"" - ) - ;; + "--ip_host") + values=( + "http://ident.me" + ) + ;; - "--music_player") - COMPREPLY=( - "amarok" - "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" - ) - ;; + "--song_format") + values=( + "\"%artist% - %album% - %title%\"" + "\"%artist - %title\"" + ) + ;; - "--install_time_format") - COMPREPLY=( - "12h" - "24h" - ) - ;; + "--music_player") + values=( + "amarok" + "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") - COMPREPLY=( - "_" - "-" - "." - "⎯" - "―" - ) - ;; + "--install_time_format") + values=( + "12h" + "24h" + ) + ;; - "--block_width"|\ - "--block_height"|\ - "--bar_length") - COMPREPLY=( - {1..9} - ) - ;; + "--underline_char") + values=( + "_" + "-" + "." + "⎯" + "―" + ) + ;; - "--cpu_display"|\ - "--memory_display"|\ - "--battery_display"|\ - "--disk_display") - COMPREPLY=( - "bar" - "infobar" - "barinfo" - "off" - ) - ;; + "--block_width"|\ + "--block_height"|\ + "--bar_length") + values=( + {1..9} + ) + ;; - "--source"|\ - "--ascii"|\ - "--caca"|\ - "--iterm2"|\ - "--jp2a"|\ - "--kitty"|\ - "--pixterm"|\ - "--sixel"|\ - "--termpix"|\ - "--tycat"|\ - "--w3m") - COMPREPLY=( - "auto" - "ascii" - "wallpaper" - "/path/to/img.jpg" - "/path/to/images" - "/path/to/ascii_file" - ) + "--cpu_display"|\ + "--memory_display"|\ + "--battery_display"|\ + "--disk_display") + values=( + "bar" + "infobar" + "barinfo" + "off" + ) + ;; - ;; + "--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") - COMPREPLY=( - "00px" - "00%" - "auto" - "none" - ) - ;; + "--ascii_distro") + values=( + "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" + ) + ;; - "--crop_mode") - COMPREPLY=( - "normal" - "fit" - "fill" - ) - ;; + "--size") + values=( + "00px" + "00%" + "auto" + "none" + ) + ;; - "--crop_offset") - COMPREPLY=( - "northwest" - "north" - "northeast" - "west" - "center" - "east" - "southwest" - "south" - "southeast" - ) - ;; + "--crop_mode") + values=( + "normal" + "fit" + "fill" + ) + ;; - "--config") - COMPREPLY=( - "none" - "/path/to/config" - ) - ;; - esac + "--crop_offset") + values=( + "northwest" + "north" + "northeast" + "west" + "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