This repository has no description
0

Configure Feed

Select the types of activity you want to include in your feed.

superconfig / tools / name-generator / name-generator.sh
1.0 kB 42 lines
1#!/usr/bin/env bash 2set -euo pipefail 3 4# Default separator 5SEPARATOR="-" 6 7# Parse command line options 8while [[ $# -gt 0 ]]; do 9 case $1 in 10 -s|--separator) 11 SEPARATOR="$2" 12 shift 2 13 ;; 14 -h|--help) 15 echo "Usage: $0 [OPTIONS]" 16 echo "Generate a random name in the format: adjective-noun" 17 echo "" 18 echo "Options:" 19 echo " -s, --separator CHAR Use CHAR as separator (default: -)" 20 echo " -h, --help Show this help message" 21 exit 0 22 ;; 23 *) 24 echo "Unknown option: $1" 25 exit 1 26 ;; 27 esac 28done 29 30# Get script directory 31SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" 32 33# Read adjectives and nouns 34mapfile -t ADJECTIVES < "$SCRIPT_DIR/adjectives.txt" 35mapfile -t NOUNS < "$SCRIPT_DIR/nouns.txt" 36 37# Select random adjective and noun 38ADJ_INDEX=$((RANDOM % ${#ADJECTIVES[@]})) 39NOUN_INDEX=$((RANDOM % ${#NOUNS[@]})) 40 41# Output the generated name 42echo "${ADJECTIVES[$ADJ_INDEX]}${SEPARATOR}${NOUNS[$NOUN_INDEX]}"