Skip to content

Instantly share code, notes, and snippets.

@edude03
Created April 9, 2019 06:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save edude03/78cac288cee221ba5cae23d6fcd09162 to your computer and use it in GitHub Desktop.
Save edude03/78cac288cee221ba5cae23d6fcd09162 to your computer and use it in GitHub Desktop.

run with nix-build random-name.nix then run result/bin/random-name

with import <nixpkgs>{};
let
aspell = aspellWithDicts (d: [d.en]);
wordlist = runCommand "mkWordList" {} ''
mkdir $out
${aspell}/bin/aspell -d en dump master | ${aspell}/bin/aspell -l en expand > $out/dict
'';
in writeScriptBin "random-name" ''
#!${bash}/bin/bash
WORD_ONE=$(${coreutils}/bin/shuf -n1 ${wordlist}/dict)
WORD_TWO=$(${coreutils}/bin/shuf -n1 ${wordlist}/dict)
COMBINED=''${WORD_ONE//[^[:alnum:]]/}-''${WORD_TWO//[^[:alnum:]]/}
echo ''${COMBINED,,}
'';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment