A command-line interface for when you need some randomness. Generate random strings and numbers, flip a coin, roll dice, or select one of many.
random [COMMAND] [FLAGS]
Use the help
command (or --help, -h
flag) to see more details. random help
or random --help
or random [COMMAND] --help
.
Command | Description |
---|---|
select |
Select one entry from a list randomly |
number |
Generate a random number |
string |
Generate a random string |
uuid |
Generate a random UUID/GUID |
toss |
Toss a coin |
roll |
Roll a die |
shuffle |
Shuffles the given list |
Randomly select one entry from a list.
random select [...ENTRIES]
Takes a variable amount of arguments representing the list of all entries.
random select one two three four five ...
Can also accept input from a redirected stdin.
gh repo list | random select
-
--repeat, -r
or--count, -c
: Number of times to repeat the execution of this command. -
--separator, -s
or--delimiter, -d
: Separator to use to format the results (default:\n
)
gh repo list | random select --repeat 3
random select pizza burger pasta # Selects either pizza, burger or pasta
gh repo list | random select # Select one entry piped through stdin
Generate random numbers.
random number [NUM1] [NUM2]
[NUM1]
and [NUM2]
are optional positional parameters that determine the range within which to generate the number.
- If both
[NUM1]
and[NUM2]
are specified, the command generates a number between[NUM1]
and[NUM2]
. - If only
[NUM1]
is specified, the command generates a number between0
and[NUM1]
. - If no parameters are specified, the command generates a number between
0
and1000
.
-
--repeat, -r
or--count, -c
: Number of times to repeat the execution of this command. -
--separator, -s
or--delimiter, -d
: Separator to use to format the results (default:\n
)
random number # Generates a number between 0 and 1000
random number 5 # Generates a number between 0 and 5
random number 5 15 # Generates a number between 5 and 15
random number 5 10 --repeat 5 # Generate 5 numbers between 5 and 15
Generate random strings using alphanumeric and special characters.
random string
-
--length, -l
: Specify the length of the generated strings (default:16
). -
--charset
: Specify the character-set to use. options:lowercase
,uppercase
,alphabets
,numbers
,alphanumeric
,special
andall
. If the charset is anything other than the specified options, the literal characters itself are used as the charset. -
--repeat, -r
or--count, -c
: Number of times to repeat the execution of this command. -
--separator, -s
or--delimiter, -d
: Separator to use to format the results (default:\n
)
random string # Generates a random 16-character string
random string --length 8 # Generates a radom 8-character string
random string --length 8 --repeat 3 # Generates three 8-character strings
Generate a random UUID/GUID
random uuid
# or
random guid
random uuid # Generates a random uuid
random guid # Does the same thing. guid is an alias for uuid
Generates a random boolean (50% chance to return true
and false
).
random toss
-
--weight, -w
: Probabilistic weight of gettingtrue
(default:0.5
) -
--coin
: Reformats the result asHeads
orTails
(instead oftrue
orfalse
) -
--repeat, -r
or--count, -c
: Number of times to repeat the execution of this command. -
--separator, -s
or--delimiter, -d
: Separator to use to format the results (default:\n
)
random toss # Generates a random boolean
random toss --coin # Flip a coin
random toss --coin --repeat 3 # Toss three coins
Roll a die.
random roll [DIE]
Roll die [DIE]
accepts input in the {n}d{S}+X
format; where {n}
is the number of dice thrown and {S}
is the number of sides each die has and {X}
is the number to add to the result. (example: 3d8
- Three 8-sided die, 2d6+4 - Two 6-sided dice and add 4 to the result)
default: 1d20
-
--with-advantage, -a
: Rolls the die with advantage. Takes the greatest value. -
--with-disadvantage, -d
: Rolls the die with disadvantage. Takes the smallest value. -
--difficulty-check
: Difficulty check. The rolls total must be higher than this value to succeed.
random roll # Rolls a 1d20
random roll 3d8 --with-advantage # Rolls 3d8 with advantage
random roll 1d8+5 # Rolls a 1d8 and adds 5
random roll 1d8+2d6+3 # Rolls 1d8 and 2d6 and adds 3 to the results
random roll 2d8 --difficulty-check 10 # Roll 2d8 and check against 10
Shuffles the given list.
random shuffle [...ENTRIES]
Takes a variable amount of arguments representing the list of all entries.
random shuffle one two three four five ...
Can also accept input from a redirected stdin.
gh repo list | random shuffle
--separator, -s
or--delimiter, -d
: Separator to use to format the results (default:\n
)
random shuffle 1 2 3 4 5 6 7 8 9 # Shuffles the numbers 8 5 9 1 7 3 6 4 2
gh repo list | random shuffle # Shuffles the repository list
This project is licensed under the MIT License.