mirror of
https://github.com/oh-my-fish/oh-my-fish.git
synced 2024-12-11 20:54:36 +08:00
18 lines
460 B
Fish
18 lines
460 B
Fish
|
# Print a random RRGGBB hexadecimal color from three min~max random beams
|
||
|
# where min = 0 and max = 255. Higher values produce lighter colors.
|
||
|
# @params [<min>][<max>]
|
||
|
function msg.util.random.color
|
||
|
set -l min 0
|
||
|
if [ (count $argv) -gt 0 ]
|
||
|
set min $argv[1]
|
||
|
end
|
||
|
|
||
|
set -l max 255
|
||
|
if [ (count $argv) -gt 1 ]
|
||
|
set max $argv[2]
|
||
|
end
|
||
|
|
||
|
set beam "math (random)%\($max-$min+1\)+$min"
|
||
|
printf "%02x%02x%02x" (eval $beam) (eval $beam) (eval $beam)
|
||
|
end
|