diff --git a/setup.sh b/setup.sh index 62ce28dd6a94df1c099d6d859bb3ba1855b213c3..40c802b541f3313f59fcf7f0f2a1cf87a23094fd 100644 --- a/setup.sh +++ b/setup.sh @@ -41,7 +41,7 @@ function initial_setup() { git checkout master git push -u origin master git checkout develop - # fi + fi echo "Done!" echo "Press [enter] to select plugins." read x @@ -251,8 +251,9 @@ function manage_plugins() { function show_main_menu() { selection=0 exit=false + quit=false - while [ $exit = false ] + while [ "$exit" == false ] do clear @@ -281,27 +282,33 @@ function show_main_menu() { echo "" echo "[Arrow Up/Down] Change Selection" echo "[Enter] Select" + echo "[Esc] Quit" IFS='' escape_char=$(printf "\u1b") + escape=false read -rsn1 mode # get 1 character if [[ $mode == $escape_char ]]; then - read -rsn2 mode # read 2 more chars + escape=true + read -rsn2 -t 0.1 mode # read 2 more chars fi case $mode in - "") exit=true ;; + "") if [ "$escape" = true ]; then quit=true; fi; exit=true ;; "[A") if [ "$selection" -gt "0" ]; then let selection-=1; fi ;; - "[B") if [ "$selection" -lt "3" ]; then let selection+=1; fi ;; - *) >&2;; + "[B") if [ "$selection" -lt "2" ]; then let selection+=1; fi ;; + *) >&2 ;; esac done - case $selection in - 0) initial_setup; show_main_menu ;; - 1) manage_plugins; show_main_menu ;; - 2) ;; - *) >&2;; - esac + if [ "$escape" == false ] + then + case $selection in + 0) initial_setup; show_main_menu ;; + 1) manage_plugins; show_main_menu ;; + 2) ;; + *) >&2;; + esac + fi } show_main_menu \ No newline at end of file