Last active
October 10, 2017 16:05
-
-
Save rey/bb8a71e1232d3132f97d36a12e25adde to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # Generates a heroku-style name | |
| # Adjectives and nouns taken from: https://gist.github.com/afriggeri/1266756 | |
| # Useage: `name` | |
| function name() { | |
| # Output variable values | |
| local debug=0 | |
| # Array of adjectives | |
| local adjectives=(autumn hidden bitter misty silent empty dry dark summer icy delicate quiet white cool spring winter patient twilight dawn crimson wispy weathered blue billowing broken cold damp falling frosty green long late lingering bold little morning muddy old red rough still small sparkling shy wandering withered wild black young holy solitary fragrant aged snowy proud floral restless divine) | |
| # Array of nouns | |
| local nouns=(waterfall river breeze moon rain wind sea morning snow lake sunset pine shadow leaf dawn glitter forest hill cloud meadow sun glade bird brook butterfly bush dew dust field fire flower firefly feather grass haze mountain night pond darkness snowflake silence sound sky shape surf thunder violet water wildflower wave water resonance sun wood dream cherry tree fog frost voice paper) | |
| # Munge date and random number for reasons | |
| local get_random=$$$(date +%s)$((1000 + $RANDOM % 9000)) | |
| # Get a random adjective | |
| local get_adjective=${adjectives[${get_random} % ${#adjectives[@]}]} | |
| # Get a random noun | |
| local get_noun=${nouns[${get_random} % ${#nouns[@]}]} | |
| # Get the last 4 digits of ${get_random} | |
| local get_number=`echo ${get_random} | tail -c 5` | |
| if [ ${debug} = 1 ]; then | |
| echo " ⚡️ there are ${#adjectives[@]} adjectives" | |
| echo " ⚡️ there are ${#nouns[@]} nouns" | |
| echo " ⚡️ random is ${get_random}" | |
| echo " ⚡️ adjective is ${get_adjective}" | |
| echo " ⚡️ noun is ${get_noun}" | |
| echo " ⚡️ number is ${get_number}" | |
| fi | |
| echo -e "🥔 Your name is \033[96m${get_adjective}-${get_noun}-${get_number}\033[0m" | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment