Skip to content

Commit

Permalink
✨ Randomize pokemons for the fish greeting
Browse files Browse the repository at this point in the history
  • Loading branch information
theobori committed Nov 17, 2024
1 parent e592ece commit 46cc931
Showing 1 changed file with 38 additions and 3 deletions.
41 changes: 38 additions & 3 deletions modules/home/cli/shells/fish/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down Expand Up @@ -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 = ''
Expand Down

0 comments on commit 46cc931

Please sign in to comment.