Min*_*mus 104 command-line terminal
如何从命令行创建消息框,无论是 GUI 消息框还是终端内显示的消息框?
能够从用户那里获得简单的输入也很有趣,例如,通过单选按钮(是/否、确定等)给出的输入。
pol*_*lym 160
对于标准的“消息框”,请使用boxes:
echo 'This is a test' | boxes
Run Code Online (Sandbox Code Playgroud)
boxes看起来像这样(第一个。第二个是像这样的自定义cowsay):

如果您的意思是警报框,请使用notify-send:
notify-send 'title' 'message'
Run Code Online (Sandbox Code Playgroud)
notify-send 看起来像这样:

您还可以zenity用于弹出窗口:
zenity --error --text="An error occurred\!" --title="Warning\!"
Run Code Online (Sandbox Code Playgroud)
Zenity 更图形化并且有更多选项,比如让窗口显示为一个问题,使用:
zenity --question --text="Do you wish to continue/?"
Run Code Online (Sandbox Code Playgroud)
甚至进度条,使用:
find /usr | zenity --progress --pulsate --auto-close --auto-kill --text="Working..."
Run Code Online (Sandbox Code Playgroud)
zenity 看起来像这样:

或使用dialog, 用于仅命令行的消息框:
dialog --checklist "Choose OS:" 15 40 5 \
1 Linux off \
2 Solaris on \
3 'HP UX' off \
4 AIX off
Run Code Online (Sandbox Code Playgroud)
dialog 看起来像这样:

另一种选择是whiptail:
whiptail --title "Example Dialog" --msgbox "This is an example of a message box. You must hit OK to continue." 8 78
Run Code Online (Sandbox Code Playgroud)
whiptail 看起来像这样:

如果你真的很疯狂,请使用toilet:
toilet -F border -F gay "CRAZY"
Run Code Online (Sandbox Code Playgroud)
toilet 看起来像这样:

Cir*_*郝海东 48
消息
这是 GUI 警报的鼻祖:
xmessage -center "Hello, World!"
Run Code Online (Sandbox Code Playgroud)

纯粹的复古善良。
我还打赌它应该在 X11 系统上广泛可用。
SO 线程:如何从 linux 中的 bash 脚本显示 GUI 消息框?| 堆栈溢出
在 Ubuntu 18.04 中测试。
HBr*_*ijn 12
然后仅仅因为@polym 完全超出了顶级答案而错过了经典消息:
write <username> [<terminal>]- 向另一个用户发送消息。以交互方式或作为管道的一部分echo "message" | write username

和补充写,wall发送消息给所有用户

如果您愿意将文本通过管道传输到 Python 包装器,则可以使用terminaltables:
pip3 install colorclass
pip3 install terminaltables
Run Code Online (Sandbox Code Playgroud)
然后在GitHub Repo 中,您可以使用其中一个示例编写 Python 包装器。