From 46cc931b04c2fa0e3efcf09415ada266731903e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9o=20Bori?= Date: Sun, 17 Nov 2024 22:15:30 +0100 Subject: [PATCH] :sparkles: Randomize pokemons for the fish greeting --- modules/home/cli/shells/fish/default.nix | 41 ++++++++++++++++++++++-- 1 file changed, 38 insertions(+), 3 deletions(-) diff --git a/modules/home/cli/shells/fish/default.nix b/modules/home/cli/shells/fish/default.nix index 285ffdb..6b5784a 100644 --- a/modules/home/cli/shells/fish/default.nix +++ b/modules/home/cli/shells/fish/default.nix @@ -6,10 +6,40 @@ ... }: let - inherit (lib) mkIf getExe; + inherit (lib) + mkIf + getExe + map + optionals + fold + ; inherit (lib.${namespace}) mkBoolOpt; - + inherit (lib.strings) concatMapStrings; cfg = config.${namespace}.cli.shells.fish; + + mkPokemonCommands' = + isShiny: + { names, forms }: + let + mkCommands = + name: + let + p = map (form: "${getExe pkgs.krabby} name ${name} --no-title --form ${form}") forms; + s = map (command: command + " --shiny") p; + in + p ++ (optionals isShiny s); + in + fold (el: c: c ++ (mkCommands el)) [ ] names; + + mkShinyPokemonCommands = mkPokemonCommands' true; + + pokemonCommands = mkShinyPokemonCommands { + names = [ "gengar" ]; + forms = [ + "regular" + "gmax" + ]; + }; in { options.${namespace}.cli.shells.fish = { @@ -46,7 +76,12 @@ in functions = { fish_greeting = '' - ${getExe pkgs.krabby} name gengar --no-title + # Randomize the pokemon command + set pokemond_commands ${concatMapStrings (command: "\"${command}\" ") pokemonCommands} + set pokemon_index (random 1 (count $pokemond_commands)) + set pokemon_command $pokemond_commands[$pokemon_index] + + eval $pokemon_command ''; hmg = ''