中文介绍 An easy to use shell menu, the view and function are seperated. The view is in msh.etc file, and the function is in msh.fun file. What's showing in the menu is easy to change by only editing the msh.etc file.
Get the code:
git clone https://github.com/qihaiyan/msh.git
Then run:
cd msh
sh msh.sh
or
chmod u+x msh.sh
./msh.sh
The definitation of the menu with msh.etc is very simple:
PROMPT Input your choice
BANNER banner banner
1 mysubmenu submenu banner1
1-1 menufun1-1 fun101 0
1-2 menufun1-2 fun102 1 1-1
2 menufun2 fun2 1 1-1
There are 5 fields separated with TAB char in this file for the menu contect.
- Menu Id
- Menu Name
- Function Name, if this menu has sub menus, the function name must be hard written to
submenu
. - Redo Flag, used to define if this menu can be executed repeatly.
- Depend Menu Id, current menu is ready only if the depended menu has succeed .
The fun101, fun102 ... is the function name we defined in msh.fun, when we choose a menu id, the correspond function will be called.
msh.fun is just a shell file, we can define functions refered in msh.etc .
banner(){
echo " TOP-MENU"
echo " ============================="
}
banner1(){
echo " SUB-MENU"
echo " ============================="
}
fun101(){
echo "function 101 executed."
}
fun102(){
date
}
fun2(){
echo "function 2 executed."
return 2
}