notes/BASH List Highlighter and Selector-PuvQeYSt.sh
#!/bin/bash

#description     :selectable list with high lighting

#usage			 : used 'w' and 's' to move up and down

#				 : 'e' to select and 'q' to quit
#author			 :Kris Occhipinti https://filmsbykris.com

#date			 :  Jan 8th 2018

#license		 :GPLv3 https://www.gnu.org/licenses/gpl-3.0.txt


let x=0;

list=("BOB" "TIM" "TED" "BILL" "FRANK" "KELLY");
length=${#list[@]}

while [ 1 ]
do
  clear
  for (( i=0; i<$length;i++ ));
  do
    if [ $i = $x ]
    then
      echo -e "\e[7m${list[$i]}\e[0m"
    else
      echo "${list[$i]}"
    fi
  done
 
  read -rsn1 k

  case $k in
    "s") let x++;;
    "w") let x--;;
    "q") echo "Goodbye...";exit 0;;
    "e") echo "${list[$x]} was selected.";sleep 1;echo "GoodBye...";exit 0;;
  esac

  if [ $x -lt 0 ]
  then
    let x=0;
  elif [ $x -ge $length ]
  then
   let x=$length-1;
  fi

done

syntax highlighted by Code2HTML, v. 0.9.1