添加一个图标以在终端中弹出

时间:2017-05-31 16:48:32

标签: macos command-line terminal

基本上,我想在终端的弹出警报提示中添加一个图标。这是代码:

osascript -e 'tell app "System Events" to text returned of (display dialog "Enter Text: " default answer "")'

举个例子,当系统提示您输入密码窗口时,窗口中会显示一个“锁定”图标。谢谢!

1 个答案:

答案 0 :(得分:0)

要将图标添加到AppleScript对话框,您可以使用:

with icon file "path:to:icon.icns"

路径是位置和文件名(图标可以是.png等),所以最终会得到:

osascript -e 'tell app "System Events" to text returned of (display dialog "Enter Text: " default answer "" with icon file "path:to:icon.icns")'