mirror of
https://github.com/oh-my-fish/oh-my-fish.git
synced 2024-12-02 22:13:47 +08:00
2542929eb9
+ msg.util.get.color.fish + msg.util.random.color.fish + msg.util.set.color.fish + msg.util.str.get.fish + msg.util.str.has.fish
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
|