像这样:
#!/bin/bash
osascript -e 'Tell application "System Events" to display dialog "Some Funky Message"'
Run Code Online (Sandbox Code Playgroud)

或者,如果您希望用户输入内容并获得结果...
#!/bin/bash
input=$(osascript -e 'Tell application "System Events" to display dialog "Enter something:" default answer ""' -e 'text returned of result' 2>/dev/null)
echo $input
Run Code Online (Sandbox Code Playgroud)

并且,为了预测您的下一个问题,如果您想要bash对话框中的变量以及引号和内容,您可以使用以下形式将脚本发送到osascript其上stdin:
#!/bin/bash
var=7
input=$(osascript <<EOF
Tell application "System Events" to display dialog "Steve's Funky Message ($var) with apostrophe and variable"
EOF)
Run Code Online (Sandbox Code Playgroud)

| 归档时间: |
|
| 查看次数: |
392 次 |
| 最近记录: |