diff --git a/completions/bash b/completions/bash index 8198d0429..b587a428c 100644 --- a/completions/bash +++ b/completions/bash @@ -49,7 +49,7 @@ __fastfetch_complete_path() __fastfetch_complete_logo() { - COMPREPLY=($(compgen -W "$(fastfetch --list-logos)" -- "$CURRENT_WORD")) + COMPREPLY=($(compgen -W "$(fastfetch --list-logos-autocompletion)" -- "$CURRENT_WORD")) } __fastfetch_complete_option() diff --git a/src/common/logo.c b/src/common/logo.c index 4eb22aa66..6bd09bb13 100644 --- a/src/common/logo.c +++ b/src/common/logo.c @@ -481,11 +481,11 @@ static FFlogo* getLogoVoid() FF_LOGO_RETURN } -typedef FFlogo*(*getLogoMethod)(); +typedef FFlogo*(*GetLogoMethod)(); -static getLogoMethod* getLogoMethods() +static GetLogoMethod* getLogoMethods() { - static getLogoMethod logoMethods[] = { + static GetLogoMethod logoMethods[] = { getLogoNone, getLogoUnknown, getLogoArch, @@ -525,7 +525,7 @@ static bool logoHasName(FFlogo* logo, const char* name) static bool loadLogoSet(FFinstance* instance, const char* name) { - getLogoMethod* logoMethod = getLogoMethods(); + GetLogoMethod* logoMethod = getLogoMethods(); while(*logoMethod != NULL) { @@ -743,7 +743,7 @@ void ffPrintRemainingLogo(FFinstance* instance) void ffPrintLogos(FFinstance* instance) { - getLogoMethod* methods = getLogoMethods(); + GetLogoMethod* methods = getLogoMethods(); while(*methods != NULL) { @@ -757,7 +757,7 @@ void ffPrintLogos(FFinstance* instance) void ffListLogos() { - getLogoMethod* methods = getLogoMethods(); + GetLogoMethod* methods = getLogoMethods(); while(*methods != NULL) { @@ -777,4 +777,15 @@ void ffListLogos() } } +void ffListLogosForAutocompletion() +{ + GetLogoMethod* methods = getLogoMethods(); + + while(*methods != NULL) + { + printf("%s\n", (*methods)()->names[0]); + ++methods; + } +} + #endif diff --git a/src/fastfetch.c b/src/fastfetch.c index eb4d2ab7b..77b990e86 100644 --- a/src/fastfetch.c +++ b/src/fastfetch.c @@ -515,6 +515,11 @@ static void parseOption(FFinstance* instance, FFdata* data, const char* key, con ffListLogos(); exit(0); } + else if(strcasecmp(key, "--list-logos-autocompletion") == 0) + { + ffListLogosForAutocompletion(); + exit(0); + } else if(strcasecmp(key, "--print-logos") == 0) { ffPrintLogos(instance); diff --git a/src/fastfetch.h b/src/fastfetch.h index c697f6e53..29155dad4 100644 --- a/src/fastfetch.h +++ b/src/fastfetch.h @@ -315,6 +315,7 @@ void ffPrintRemainingLogo(FFinstance* instance); #ifndef FASTFETCH_BUILD_FLASHFATCH void ffPrintLogos(FFinstance* instance); void ffListLogos(); + void ffListLogosForAutocompletion(); #endif //common/format.c