Skip to content
Snippets Groups Projects
Commit ada5cf8e authored by Simon Oehrl's avatar Simon Oehrl
Browse files

Improve main menu

parent 57566b56
No related branches found
No related tags found
No related merge requests found
...@@ -41,7 +41,7 @@ function initial_setup() { ...@@ -41,7 +41,7 @@ function initial_setup() {
git checkout master git checkout master
git push -u origin master git push -u origin master
git checkout develop git checkout develop
# fi fi
echo "Done!" echo "Done!"
echo "Press [enter] to select plugins." echo "Press [enter] to select plugins."
read x read x
...@@ -251,8 +251,9 @@ function manage_plugins() { ...@@ -251,8 +251,9 @@ function manage_plugins() {
function show_main_menu() { function show_main_menu() {
selection=0 selection=0
exit=false exit=false
quit=false
while [ $exit = false ] while [ "$exit" == false ]
do do
clear clear
...@@ -281,27 +282,33 @@ function show_main_menu() { ...@@ -281,27 +282,33 @@ function show_main_menu() {
echo "" echo ""
echo "[Arrow Up/Down] Change Selection" echo "[Arrow Up/Down] Change Selection"
echo "[Enter] Select" echo "[Enter] Select"
echo "[Esc] Quit"
IFS='' IFS=''
escape_char=$(printf "\u1b") escape_char=$(printf "\u1b")
escape=false
read -rsn1 mode # get 1 character read -rsn1 mode # get 1 character
if [[ $mode == $escape_char ]]; then 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 fi
case $mode in case $mode in
"") exit=true ;; "") if [ "$escape" = true ]; then quit=true; fi; exit=true ;;
"[A") if [ "$selection" -gt "0" ]; then let selection-=1; fi ;; "[A") if [ "$selection" -gt "0" ]; then let selection-=1; fi ;;
"[B") if [ "$selection" -lt "3" ]; then let selection+=1; fi ;; "[B") if [ "$selection" -lt "2" ]; then let selection+=1; fi ;;
*) >&2 ;; *) >&2 ;;
esac esac
done done
if [ "$escape" == false ]
then
case $selection in case $selection in
0) initial_setup; show_main_menu ;; 0) initial_setup; show_main_menu ;;
1) manage_plugins; show_main_menu ;; 1) manage_plugins; show_main_menu ;;
2) ;; 2) ;;
*) >&2;; *) >&2;;
esac esac
fi
} }
show_main_menu show_main_menu
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment