Files
fastfetch/completions/bash
T

217 lines
4.9 KiB
Bash
Raw Normal View History

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"
"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-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-03-07 11:11:21 +01:00
COMPREPLY=($(compgen -W "$(fastfetch --list-logos)" -- "$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"
"--print-logos"
"--print-default-config"
2021-03-27 19:26:58 +01:00
"--print-default-structure"
"--print-available-modules"
2021-04-25 11:48:25 +02:00
"--print-available-presets"
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-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"
"--seperator"
"-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-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-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-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-03-06 22:40:05 +01:00
)
2021-03-11 22:15:48 +01:00
local FF_OPTIONS_PATH=(
2021-03-19 20:57:07 +01:00
"--lib-PCI"
"--lib-X11"
"--lib-Xrandr"
2021-05-02 21:06:01 +02:00
"--lib-gio"
2021-04-05 23:42:07 +02:00
"--lib-DConf"
2021-04-16 16:49:33 +02:00
"--lib-wayland"
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