oh-my-fish/plugins/msg/msg.util.random.color.fish
Jorge Bucaran 2542929eb9 Separate msg utility functions into their own file:
+ 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
2015-01-09 14:08:47 +09:00

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