Skip to content

Instantly share code, notes, and snippets.

@takumakei
Last active December 26, 2015 23:38
Show Gist options
  • Save takumakei/7231506 to your computer and use it in GitHub Desktop.
Save takumakei/7231506 to your computer and use it in GitHub Desktop.
[macosx] shellでダイアログを表示する
#!/bin/bash
function input-text {
script='
set answer to ""
try
tell application "SystemUIServer"
set result to display dialog "question" default answer "" with title "title" buttons {"cancel", "ok"} default button 2
if (get button returned of result) is equal to "ok" then
set answer to (get text returned of result)
end if
end tell
end try
activate application (path to frontmost application as text)
answer
'
result=$(osascript -e "$script")
echo "[$result]"
}
input-text
function yes-or-no {
script='
set answer to ""
try
tell application "SystemUIServer"
set answer to display dialog "message" with title "title" buttons { "No", "Yes" } default button 2
set answer to (get button returned of answer)
end
end try
activate app (path to frontmost application as text)
answer
'
result=$(osascript -e "$script")
echo "[$result]"
}
yes-or-no
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment