2021-03-07 11:11:21 +01:00
|
|
|
#!/usr/bin/env bash
|
2021-03-06 22:40:05 +01:00
|
|
|
|
|
|
|
|
__fastfetch_complete_help()
|
|
|
|
|
{
|
|
|
|
|
local __ff_helps=(
|
|
|
|
|
"color"
|
2021-03-21 11:18:06 +01:00
|
|
|
"format"
|
2021-04-25 11:48:25 +02:00
|
|
|
"load-config"
|
2021-03-12 10:17:49 +01:00
|
|
|
"os-format"
|
2021-03-12 12:16:41 +01:00
|
|
|
"host-format"
|
2021-03-19 20:57:07 +01:00
|
|
|
"kernel-format"
|
2021-03-12 12:16:41 +01:00
|
|
|
"packages-format"
|
2021-03-19 20:57:07 +01:00
|
|
|
"shell-format"
|
|
|
|
|
"resolution-format"
|
|
|
|
|
"de-format"
|
|
|
|
|
"wm-format"
|
|
|
|
|
"theme-format"
|
|
|
|
|
"icons-format"
|
2021-03-23 19:48:52 +01:00
|
|
|
"font-format"
|
2021-03-19 20:57:07 +01:00
|
|
|
"terminal-format"
|
|
|
|
|
"terminal-font-format"
|
|
|
|
|
"cpu-format"
|
2021-11-24 16:16:25 +08:00
|
|
|
"cpu-usage-format"
|
2021-03-19 20:57:07 +01:00
|
|
|
"gpu-format"
|
|
|
|
|
"memory-format"
|
|
|
|
|
"disk-format"
|
2021-03-12 12:16:41 +01:00
|
|
|
"battery-format"
|
2021-03-19 20:57:07 +01:00
|
|
|
"locale-format"
|
2021-10-17 12:42:15 +08:00
|
|
|
"local-ip-format"
|
2022-01-18 18:56:37 +01:00
|
|
|
"public-ip-format"
|
2022-02-25 13:30:37 +01:00
|
|
|
"datetime-format"
|
|
|
|
|
"date-format"
|
|
|
|
|
"time-format"
|
2021-03-06 22:40:05 +01:00
|
|
|
)
|
2021-03-07 11:11:21 +01:00
|
|
|
COMPREPLY=($(compgen -W "${__ff_helps[*]}" -- "$CURRENT_WORD"))
|
2021-03-06 22:40:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
__fastfetch_complete_bool()
|
|
|
|
|
{
|
2021-03-07 11:11:21 +01:00
|
|
|
COMPREPLY=($(compgen -W "true false" -- "$CURRENT_WORD"))
|
2021-03-06 22:40:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
__fastfetch_complete_string()
|
|
|
|
|
{
|
|
|
|
|
if [[ $CURRENT_WORD != "" ]]; then
|
|
|
|
|
COMPREPLY=("$CURRENT_WORD")
|
|
|
|
|
fi
|
|
|
|
|
}
|
|
|
|
|
|
2021-03-11 22:15:48 +01:00
|
|
|
__fastfetch_complete_path()
|
|
|
|
|
{
|
|
|
|
|
COMPREPLY=($(compgen -A file -- "$CURRENT_WORD"))
|
|
|
|
|
}
|
|
|
|
|
|
2021-03-06 22:40:05 +01:00
|
|
|
__fastfetch_complete_logo()
|
|
|
|
|
{
|
2021-11-09 16:53:08 +01:00
|
|
|
COMPREPLY=($(compgen -W "$(fastfetch --list-logos-autocompletion)" -- "$CURRENT_WORD"))
|
2021-03-06 22:40:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
__fastfetch_complete_option()
|
|
|
|
|
{
|
|
|
|
|
local FF_OPTIONS_ALL=(
|
|
|
|
|
"${FF_OPTIONS_BOOL[@]}"
|
|
|
|
|
"${FF_OPTIONS_STRING[@]}"
|
2021-03-11 22:15:48 +01:00
|
|
|
"${FF_OPTIONS_PATH[@]}"
|
2021-03-06 22:40:05 +01:00
|
|
|
"${FF_OPTIONS_LOGO[@]}"
|
|
|
|
|
)
|
|
|
|
|
|
2021-03-07 11:11:21 +01:00
|
|
|
if [[ $WORD_COUND -lt 3 ]]; then
|
2021-03-06 22:40:05 +01:00
|
|
|
FF_OPTIONS_ALL+=(
|
|
|
|
|
"${FF_OPTIONS_SINGLE[@]}"
|
|
|
|
|
"${FF_OPTIONS_HELP[@]}"
|
|
|
|
|
)
|
|
|
|
|
fi
|
|
|
|
|
|
2021-03-07 11:11:21 +01:00
|
|
|
for ff_word in ${COMP_WORDS[@]}; do
|
|
|
|
|
if [[ $ff_word == $CURRENT_WORD ]]; then
|
|
|
|
|
break
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
FF_OPTIONS_ALL=("${FF_OPTIONS_ALL[@]/$ff_word}")
|
|
|
|
|
done
|
|
|
|
|
|
2021-03-06 22:40:05 +01:00
|
|
|
COMPREPLY=($(compgen -W "${FF_OPTIONS_ALL[*]}" -- "$CURRENT_WORD"))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
__fastfetch_previous_matches()
|
|
|
|
|
{
|
|
|
|
|
for ff_option in "$@"; do
|
2021-03-07 11:11:21 +01:00
|
|
|
if [[ $ff_option == "$PREVIOUS_WORD" ]]; then
|
2021-03-06 22:40:05 +01:00
|
|
|
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"
|
2021-10-23 14:59:11 +02:00
|
|
|
"--list-modules"
|
|
|
|
|
"--list-presets"
|
|
|
|
|
"--list-features"
|
2021-03-06 22:40:05 +01:00
|
|
|
"--print-logos"
|
2021-10-23 14:59:11 +02:00
|
|
|
"--print-config"
|
|
|
|
|
"--print-structure"
|
2021-03-06 22:40:05 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
local FF_OPTIONS_HELP=(
|
|
|
|
|
"-h"
|
|
|
|
|
"--help"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
local FF_OPTIONS_BOOL=(
|
|
|
|
|
"-r"
|
|
|
|
|
"--recache"
|
2021-04-18 19:23:54 +02:00
|
|
|
"--nocache"
|
2021-03-06 22:40:05 +01:00
|
|
|
"--show-errors"
|
|
|
|
|
"--color-logo"
|
2021-03-19 21:23:15 +01:00
|
|
|
"--print-remaining-logo"
|
2021-04-07 17:36:03 +02:00
|
|
|
"--multithreading"
|
2021-05-09 21:41:17 +02:00
|
|
|
"--allow-slow-operations"
|
2021-06-17 13:49:25 +02:00
|
|
|
"--disable-linewrap"
|
|
|
|
|
"--hide-cursor"
|
2021-10-17 12:42:15 +08:00
|
|
|
"--localip-show-ipv4"
|
|
|
|
|
"--localip-show-ipv6"
|
|
|
|
|
"--localip-show-loop"
|
2021-03-06 22:40:05 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
local FF_OPTIONS_STRING=(
|
|
|
|
|
"-c"
|
|
|
|
|
"--color"
|
2021-03-21 17:02:31 +01:00
|
|
|
"--spacing"
|
2021-03-06 22:40:05 +01:00
|
|
|
"-s"
|
2021-05-15 12:36:25 +02:00
|
|
|
"--separator"
|
2021-03-06 22:40:05 +01:00
|
|
|
"-x"
|
|
|
|
|
"--offsetx"
|
2021-03-19 20:57:07 +01:00
|
|
|
"--structure"
|
|
|
|
|
"--set"
|
2021-03-12 10:17:49 +01:00
|
|
|
"--os-format"
|
2021-04-03 11:39:59 +02:00
|
|
|
"--os-key"
|
2021-03-12 12:16:41 +01:00
|
|
|
"--host-format"
|
2021-04-03 11:39:59 +02:00
|
|
|
"--host-key"
|
2021-03-19 20:57:07 +01:00
|
|
|
"--kernel-format"
|
2021-04-03 11:39:59 +02:00
|
|
|
"--kernel-key"
|
2021-03-19 20:57:07 +01:00
|
|
|
"--uptime-format"
|
2021-04-03 11:39:59 +02:00
|
|
|
"--uptime-key"
|
2021-10-18 22:38:00 +08:00
|
|
|
"--processes-format"
|
|
|
|
|
"--processes-key"
|
2021-03-11 19:40:46 +01:00
|
|
|
"--packages-format"
|
2021-04-03 11:39:59 +02:00
|
|
|
"--packages-key"
|
2021-03-19 20:57:07 +01:00
|
|
|
"--shell-format"
|
2021-04-03 11:39:59 +02:00
|
|
|
"--shell-key"
|
2021-03-11 22:15:48 +01:00
|
|
|
"--resolution-format"
|
2021-04-03 11:39:59 +02:00
|
|
|
"--resolution-key"
|
2021-03-19 20:57:07 +01:00
|
|
|
"--de-format"
|
2021-04-03 11:39:59 +02:00
|
|
|
"--de-key"
|
2021-03-19 20:57:07 +01:00
|
|
|
"--wm-format"
|
2021-04-03 11:39:59 +02:00
|
|
|
"--wm-key"
|
2021-04-03 23:10:14 +02:00
|
|
|
"--wm-theme-format"
|
|
|
|
|
"--wm-theme-key"
|
2021-03-19 20:57:07 +01:00
|
|
|
"--theme-format"
|
2021-04-03 11:39:59 +02:00
|
|
|
"--theme-key"
|
2021-03-19 20:57:07 +01:00
|
|
|
"--icons-format"
|
2021-04-03 11:39:59 +02:00
|
|
|
"--icons-key"
|
2021-03-23 19:48:52 +01:00
|
|
|
"--font-format"
|
2021-04-03 11:39:59 +02:00
|
|
|
"--font-key"
|
2021-06-20 21:04:55 +02:00
|
|
|
"--cursor-format"
|
|
|
|
|
"--cursor-key"
|
2021-03-19 20:57:07 +01:00
|
|
|
"--terminal-format"
|
2021-04-03 11:39:59 +02:00
|
|
|
"--terminal-key"
|
2021-03-19 20:57:07 +01:00
|
|
|
"--terminal-font-format"
|
2021-04-03 11:39:59 +02:00
|
|
|
"--terminal-font-key"
|
2021-03-19 20:57:07 +01:00
|
|
|
"--cpu-format"
|
2021-04-03 11:39:59 +02:00
|
|
|
"--cpu-key"
|
2021-11-24 16:16:25 +08:00
|
|
|
"--cpu-usage-format"
|
|
|
|
|
"--cpu-usage-key"
|
2021-03-19 20:57:07 +01:00
|
|
|
"--gpu-format"
|
2021-04-03 11:39:59 +02:00
|
|
|
"--gpu-key"
|
2021-03-19 20:57:07 +01:00
|
|
|
"--memory-format"
|
2021-04-03 11:39:59 +02:00
|
|
|
"--memory-key"
|
2021-03-19 20:57:07 +01:00
|
|
|
"--disk-format"
|
2021-04-03 11:39:59 +02:00
|
|
|
"--disk-key"
|
2021-03-06 22:40:05 +01:00
|
|
|
"--battery-format"
|
2021-04-03 11:39:59 +02:00
|
|
|
"--battery-key"
|
2021-03-19 20:57:07 +01:00
|
|
|
"--locale-format"
|
2021-04-03 11:39:59 +02:00
|
|
|
"--locale-key"
|
2021-03-28 15:38:52 +02:00
|
|
|
"--disk-folders"
|
2021-04-03 11:39:59 +02:00
|
|
|
"--disk-key"
|
2021-10-17 12:42:15 +08:00
|
|
|
"--local-ip-format"
|
|
|
|
|
"--local-ip-key"
|
2022-01-18 18:56:37 +01:00
|
|
|
"--public-ip-format"
|
|
|
|
|
"--public-ip-key"
|
2022-02-13 23:51:13 +01:00
|
|
|
"--player-format"
|
|
|
|
|
"--player-key"
|
|
|
|
|
"--song-format"
|
|
|
|
|
"--song-key"
|
2022-02-25 13:30:37 +01:00
|
|
|
"--datetime-key"
|
|
|
|
|
"--datetime-format"
|
|
|
|
|
"--date-format"
|
|
|
|
|
"--date-key"
|
|
|
|
|
"--time-format"
|
|
|
|
|
"--time-key"
|
2021-03-06 22:40:05 +01:00
|
|
|
)
|
|
|
|
|
|
2021-03-11 22:15:48 +01:00
|
|
|
local FF_OPTIONS_PATH=(
|
2022-01-18 18:56:37 +01:00
|
|
|
"--os-file"
|
2021-03-19 20:57:07 +01:00
|
|
|
"--lib-PCI"
|
2021-11-13 18:25:35 +01:00
|
|
|
"--lib-vulkan"
|
2022-01-05 14:40:57 +01:00
|
|
|
"--lib-wayland"
|
|
|
|
|
"--lib-xcb-randr"
|
|
|
|
|
"--lib-xcb"
|
2021-03-19 20:57:07 +01:00
|
|
|
"--lib-Xrandr"
|
2022-01-05 14:40:57 +01:00
|
|
|
"--lib-X11"
|
2021-05-02 21:06:01 +02:00
|
|
|
"--lib-gio"
|
2021-04-05 23:42:07 +02:00
|
|
|
"--lib-DConf"
|
2022-02-13 23:51:13 +01:00
|
|
|
"--lib-DBus"
|
2021-05-11 20:06:17 +02:00
|
|
|
"--lib-XFConf"
|
2021-11-06 19:31:28 +08:00
|
|
|
"--lib-RPM"
|
2021-04-24 13:05:43 +02:00
|
|
|
"--battery-dir"
|
2021-04-25 11:48:25 +02:00
|
|
|
"--load-config"
|
2021-03-11 22:15:48 +01:00
|
|
|
)
|
|
|
|
|
|
2021-03-06 22:40:05 +01:00
|
|
|
local FF_OPTIONS_LOGO=(
|
|
|
|
|
"-l"
|
|
|
|
|
"--logo"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
if __fastfetch_previous_matches "${FF_OPTIONS_SINGLE[@]}"; then
|
|
|
|
|
return
|
2021-03-07 11:11:21 +01:00
|
|
|
elif [[ $WORD_COUND -gt 3 && ( ${COMP_WORDS[$COMP_CWORD - 2]} == "--help" || ${COMP_WORDS[$COMP_CWORD - 2]} == "-h" ) ]]; then
|
2021-03-06 22:40:05 +01:00
|
|
|
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
|
2021-03-11 22:15:48 +01:00
|
|
|
elif __fastfetch_previous_matches "${FF_OPTIONS_PATH[@]}"; then
|
|
|
|
|
__fastfetch_complete_path
|
2021-03-06 22:40:05 +01:00
|
|
|
elif __fastfetch_previous_matches "${FF_OPTIONS_LOGO[@]}"; then
|
|
|
|
|
__fastfetch_complete_logo
|
|
|
|
|
else
|
|
|
|
|
__fastfetch_complete_option
|
|
|
|
|
fi
|
|
|
|
|
}
|
|
|
|
|
|
2021-03-27 18:14:19 +01:00
|
|
|
complete -F __fastfetch_completion fastfetch
|