#!/usr/bin/env bash

source header
edit_script (){
  # Displays a list of files in current directory and prompt for which
write_header
write_header " Edition Script LIST "
 PS3="  Use '${BLUE}Number${NOC}' to select a ${BLUE}Script${NOC} or '${YELLOW}0${NOC}' to ${YELLOW}Return ${NOC}: "
 # Create a list of files to display
 fileList=$(find $Bscripts/ -maxdepth 2 -type f)
 # Show a menu and ask for input. then invoke the editor on that file
  select fileName in $fileList
  do
    if [ -n "$fileName" ]; then
        nano ${fileName}
    fi

   # leave the loop if the user says '0'
    if [[ "$REPLY" ==  0  ]]; then break; fi
   # complain if no file was selected, and loop to ask again
    if [[ "$filename" == "" ]]; then
        echo "'$REPLY' is not a valid number"
        continue
    fi

#    break
  done
unset REPLY
echo -e "\n"
show_list_script
echo -e "\n"
}

