Last active
December 26, 2015 23:38
-
-
Save takumakei/7231506 to your computer and use it in GitHub Desktop.
[macosx] shellでダイアログを表示する
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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