带有图形菜单的 Bash 脚本

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/10576401/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 22:05:22  来源:igfitidea点击:

Bash script with graphical menus

bashshellmenu

提问by Cloud

I have been writing simple bash scripts for a while now, and I was wondering how I could implement simple menus and, if possible, use menus with color.

我编写简单的 bash 脚本已经有一段时间了,我想知道如何实现简单的菜单,如果可能的话,使用带有颜色的菜单。

In the past, I have written simple C applications that use ncursesand would like to (if possible) have menus in my bash script where the user can use the up/down arrows to select items in a list, and go back/forth through a series of yes/no/cancel prompts.

过去,我编写了使用ncurses 的简单 C 应用程序,并希望(如果可能)在我的 bash 脚本中有菜单,用户可以在其中使用向上/向下箭头选择列表中的项目,然后来回浏览一系列是/否/取消提示。

I am familiar with setting up colored text in bash, so there's a start (eg: bash using colors), so the only requirement left at this point is to see if bash has these capabilities. I would prefer to avoid having to code an application in C/C++ for this, as I would like to be able to edit it on the fly.

我熟悉在 bash 中设置彩色文本,因此有一个开始(例如:bash 使用 colors),因此此时唯一的要求是查看 bash 是否具有这些功能。我宁愿避免为此用 C/C++ 编写应用程序,因为我希望能够即时编辑它。

回答by Bela Vizer

there is a package called dialog, is this relevant to your requirement?

有一个名为dialog的包,这与您的要求有关吗?

回答by my_buffer_overflow-eth...

I haven't used this myself, but have you checked out bashsimplecurses? From the documentation, it looks like a possible solution.

我自己没有用过这个,但是你检查过bashsimplecurses吗?从文档中,它看起来像是一个可能的解决方案。