From e06d62e9d12ef075ac6cfb3f4cc745b81355c421 Mon Sep 17 00:00:00 2001 From: Atif Chowdhury Date: Wed, 14 May 2025 23:56:26 +0600 Subject: [PATCH 1/2] fish complete: add `--logo-color-[1-9]` completion --- completions/fastfetch.fish | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/completions/fastfetch.fish b/completions/fastfetch.fish index 7badab3881..5b2e3f88f2 100755 --- a/completions/fastfetch.fish +++ b/completions/fastfetch.fish @@ -60,13 +60,21 @@ function __fastfetch_complete_structure end echo ' -import json, subprocess, sys +import json +import subprocess +import sys + def main(): data: dict[str, list[dict]] = json.loads(subprocess.check_output(["fastfetch", "--help-raw"])) for key in data: for flag in data[key]: + if flag["long"] == "logo-color-[1-9]": + for i in range(1, 10): + print(f"""complete -c fastfetch -d "{flag["desc"]}" -l "logo-color-{i}" -x -a "(__fastfetch_complete_color)" """) + continue + if flag.get("pseudo", False): continue @@ -75,7 +83,7 @@ def main(): command_prefix += f""" -o {flag["short"]}""" if "arg" in flag: - type: str = flag["arg"]["type"]; + type: str = flag["arg"]["type"] if type == "bool": print(f"{command_prefix} -x -a \"(__fastfetch_complete_bool)\"") elif type == "color": @@ -98,9 +106,11 @@ def main(): else: print(f"{command_prefix} -f") + if __name__ == "__main__": try: main() - except: + except Exception as e: + print(f"Error: {e}", file=sys.stderr) sys.exit(1) ' | python3 | source From ce87f8965789de28b3a7487858f925553896966b Mon Sep 17 00:00:00 2001 From: Atif Chowdhury Date: Thu, 15 May 2025 12:31:53 +0600 Subject: [PATCH 2/2] reverted unnecessary changes --- completions/fastfetch.fish | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/completions/fastfetch.fish b/completions/fastfetch.fish index 5b2e3f88f2..f4804f5f50 100755 --- a/completions/fastfetch.fish +++ b/completions/fastfetch.fish @@ -60,9 +60,7 @@ function __fastfetch_complete_structure end echo ' -import json -import subprocess -import sys +import json, subprocess, sys def main(): @@ -110,7 +108,6 @@ def main(): if __name__ == "__main__": try: main() - except Exception as e: - print(f"Error: {e}", file=sys.stderr) + except: sys.exit(1) ' | python3 | source