#!/bin/sh
#
# Parse the zshrc file and print a alias's definition

LIST_ALIAS=$(cat /etc/zsh/zshrc | grep -v '^#' | grep '^[a-zA-Z].*#.*' | cut -d '#' -f2-)

NUMBER_ALIAS=$(cat /etc/zsh/zshrc | grep -v '^#' | grep '^[a-zA-Z].*#.*' | cut -d '#' -f2- | wc -l)

NUM_ALIAS=$((echo $RANDOM % ${NUMBER_ALIAS} + 1 | bc))

#r=$(( echo $RANDOM % 10 ))
#r=$(($RANDOM)
#r=$RANDOM

#printf 'There is %s alias in my zshrc file. And i choose the %s\n' ${NUMBER_ALIAS} ${NUM_ALIAS}

#printf 'Random = %s\n' ${RANDOM}
#printf 'r = %s\n' ${r}

#echo $RANDOM % ${NUMBER_ALIAS} + 1 | bc

#AWKSCRIPT=' { srand(); print int(rand() * 50) } '
AWKSCRIPT=' { srand(); print int(rand() * $1) } '
#            Command(s) / parameters passed to awk
# Note that srand() reseeds awk's random number generator. } '

echo -n "Random number between 0 and 1 = "

echo | awk "$AWKSCRIPT"
# What happens if you leave out the 'echo'?

exit 0
