#!/usr/bin/env bash __fastfetch_complete_help() { local __ff_helps=( "color" "format" "load-config" "os-format" "host-format" "kernel-format" "uptime-format" "processes-format" "packages-format" "shell-format" "resolution-format" "de-format" "wm-format" "wm-theme-format" "theme-format" "icons-format" "font-format" "cursor-format" "terminal-format" "terminal-font-format" "cpu-format" "cpu-usage-format" "gpu-format" "memory-format" "swap-format" "disk-format" "battery-format" "poweradapter-format" "locale-format" "local-ip-format" "public-ip-format" "player-format" "media-format" "datetime-format" "date-format" "time-format" "vulkan-format" "opengl-format" "opencl-format" ) COMPREPLY=($(compgen -W "${__ff_helps[*]}" -- "$CURRENT_WORD")) } __fastfetch_complete_bool() { COMPREPLY=($(compgen -W "true false" -- "$CURRENT_WORD")) } __fastfetch_complete_string() { if [[ $CURRENT_WORD != "" ]]; then COMPREPLY=("$CURRENT_WORD") fi } __fastfetch_complete_path() { COMPREPLY=($(compgen -A file -- "$CURRENT_WORD")) } __fastfetch_complete_logo() { COMPREPLY=($(compgen -W "$(fastfetch --list-logos-autocompletion)" -- "$CURRENT_WORD")) } __fastfetch_complete_logo_type() { local __ff_logo_types=( "auto" "builtin" "file" "raw" "sixel" "kitty" "chafa" ) COMPREPLY=($(compgen -W "${__ff_logo_types[*]}" -- "$CURRENT_WORD")) } __fastfetch_complete_binary_prefix() { local __ff_binary_prefixes=( "iec" "si" "jedec" ) COMPREPLY=($(compgen -W "${__ff_binary_prefixes[*]}" -- "$CURRENT_WORD")) } __fastfetch_complete_gl() { local __ff_gl_types=( "auto" "egl" "glx" "osmesa" ) COMPREPLY=($(compgen -W "${__ff_gl_types[*]}" -- "$CURRENT_WORD")) } __fastfetch_complete_option() { local FF_OPTIONS_ALL=( "${FF_OPTIONS_BOOL[@]}" "${FF_OPTIONS_STRING[@]}" "${FF_OPTIONS_PATH[@]}" "${FF_OPTIONS_LOGO[@]}" "${FF_OPTIONS_LOGO_TYPE[@]}" "${FF_OPTIONS_BINARY_PREFIX[@]}" "${FF_OPTIONS_GL[@]}" ) if [[ $WORD_COUND -lt 3 ]]; then FF_OPTIONS_ALL+=( "${FF_OPTIONS_SINGLE[@]}" "${FF_OPTIONS_HELP[@]}" ) fi for ff_word in ${COMP_WORDS[@]}; do if [[ $ff_word == $CURRENT_WORD ]]; then break fi FF_OPTIONS_ALL=("${FF_OPTIONS_ALL[@]/$ff_word}") done COMPREPLY=($(compgen -W "${FF_OPTIONS_ALL[*]}" -- "$CURRENT_WORD")) } __fastfetch_previous_matches() { for ff_option in "$@"; do if [[ $ff_option == "$PREVIOUS_WORD" ]]; then return 0 fi done return 1 } __fastfetch_completion() { local CURRENT_WORD="${COMP_WORDS[$COMP_CWORD]}" local PREVIOUS_WORD="${COMP_WORDS[$COMP_CWORD - 1]}" local WORD_COUND="${#COMP_WORDS[@]}" local FF_OPTIONS_SINGLE=( "-v" "--version" "--list-logos" "--list-modules" "--list-presets" "--list-features" "--print-logos" "--print-config-system" "--print-config-user" "--print-structure" "--gen-config" "--gen-config-force" ) local FF_OPTIONS_HELP=( "-h" "--help" ) local FF_OPTIONS_BOOL=( "-r" "--show-errors" "--logo-print-remaining" "--multithreading" "--stat" "--allow-slow-operations" "--disable-linewrap" "--hide-cursor" "--cpu-temp" "--gpu-temp" "--battery-temp" "--localip-show-ipv4" "--localip-show-ipv6" "--localip-show-loop" "--localip-name-prefix" "--escape-bedrock" "--pipe" "--title-fqdn" "--escape-bedrock" "--disk-show-removable" "--disk-show-hidden" "--gpu-hide-integrated" "--gpu-hide-discrete" ) local FF_OPTIONS_STRING=( "--logo-type" "--logo-padding" "--logo-padding-left" "--logo-padding-right" "--logo-padding-top" "--logo-color-1" "--logo-color-2" "--logo-color-3" "--logo-color-4" "--logo-color-5" "--logo-color-6" "--logo-color-7" "--logo-color-8" "--logo-width" "--logo-height" "--logo-color-9" "-c" "--color" "--color-keys" "--color-title" "--separator" "-s" "--structure" "--set" "--set-keyless" "--player-name" "--percent-type" "--public-ip-url" "--public-ip-timeout" "--weather-output-format" "--weather-timeout" "--os-key" "--os-format" "--os-error" "--host-key" "--host-format" "--host-error" "--kernel-key" "--kernel-format" "--kernel-error" "--uptime-key" "--uptime-format" "--uptime-error" "--processes-key" "--processes-format" "--processes-error" "--packages-key" "--packages-format" "--packages-error" "--shell-key" "--shell-format" "--shell-error" "--resolution-key" "--resolution-format" "--resolution-error" "--de-key" "--de-format" "--de-error" "--wm-key" "--wm-format" "--wm-error" "--wm-theme-key" "--wm-theme-format" "--wm-theme-error" "--theme-key" "--theme-format" "--theme-error" "--icons-key" "--icons-format" "--icons-error" "--font-key" "--font-format" "--font-error" "--cursor-key" "--cursor-format" "--cursor-error" "--terminal-key" "--terminal-format" "--terminal-error" "--terminal-font-key" "--terminal-font-format" "--terminal-font-error" "--cpu-key" "--cpu-format" "--cpu-error" "--cpu-useage-key" "--cpu-useage-format" "--cpu-useage-error" "--gpu-key" "--gpu-format" "--gpu-error" "--memory-key" "--memory-format" "--memory-error" "--swap-key" "--swap-format" "--swap-error" "--disk-key" "--disk-format" "--disk-error" "--battery-key" "--battery-format" "--battery-error" "--poweradapter-key" "--poweradapter-format" "--poweradapter-error" "--locale-key" "--locale-format" "--locale-error" "--local-ip-key" "--local-ip-format" "--local-ip-error" "--public-ip-key" "--public-ip-format" "--public-ip-error" "--wifi-key" "--wifi-format" "--wifi-error" "--weather-key" "--weather-format" "--weather-error" "--player-key" "--player-format" "--player-error" "--media-key" "--media-format" "--media-error" "--datetime-key" "--datetime-format" "--datetime-error" "--date-key" "--date-format" "--date-error" "--time-key" "--time-format" "--time-error" "--vulkan-key" "--vulkan-format" "--vulkan-error" "--opengl-key" "--opengl-format" "--opengl-error" "--opencl-key" "--opencl-format" "--opencl-error" "--users-key" "--users-format" "--users-error" ) local FF_OPTIONS_PATH=( "--load-config" "--os-file" "--lib-pci" "--lib-vulkan" "--lib-wayland" "--lib-xcb-randr" "--lib-xcb" "--lib-xrandr" "--lib-X11" "--lib-gio" "--lib-dconf" "--lib-dbus" "--lib-xfconf" "--lib-sqlite3" "--lib-rpm" "--lib-imagemagick" "--lib-z" "--lib-chafa" "--lib-egl" "--lib-glx" "--lib-osmesa" "--lib-opencl" "--battery-dir" ) local FF_OPTIONS_LOGO=( "-l" "--logo" ) local FF_OPTIONS_LOGO_TYPE=( "--logo-type" ) local FF_OPTIONS_BINARY_PREFIX=( "--binary-prefix" ) local FF_OPTIONS_GL=( "--gl" ) if __fastfetch_previous_matches "${FF_OPTIONS_SINGLE[@]}"; then return elif [[ $WORD_COUND -gt 3 && ( ${COMP_WORDS[$COMP_CWORD - 2]} == "--help" || ${COMP_WORDS[$COMP_CWORD - 2]} == "-h" ) ]]; then return elif [[ $CURRENT_WORD == "-"* ]]; then __fastfetch_complete_option elif __fastfetch_previous_matches "${FF_OPTIONS_HELP[@]}"; then __fastfetch_complete_help elif __fastfetch_previous_matches "${FF_OPTIONS_BOOL[@]}"; then __fastfetch_complete_bool elif __fastfetch_previous_matches "${FF_OPTIONS_STRING[@]}"; then __fastfetch_complete_string elif __fastfetch_previous_matches "${FF_OPTIONS_PATH[@]}"; then __fastfetch_complete_path elif __fastfetch_previous_matches "${FF_OPTIONS_LOGO[@]}"; then __fastfetch_complete_logo elif __fastfetch_previous_matches "${FF_OPTIONS_LOGO_TYPE[@]}"; then __fastfetch_complete_logo_type elif __fastfetch_previous_matches "${FF_OPTIONS_BINARY_PREFIX[@]}"; then __fastfetch_complete_binary_prefix elif __fastfetch_previous_matches "${FF_OPTIONS_GL[@]}"; then __fastfetch_complete_gl else __fastfetch_complete_option fi } complete -F __fastfetch_completion fastfetch