Skip to content

Instantly share code, notes, and snippets.

@mamemomonga
Created April 2, 2024 23:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mamemomonga/11a94a4f8cd939f901547264ada4da9d to your computer and use it in GitHub Desktop.
Save mamemomonga/11a94a4f8cd939f901547264ada4da9d to your computer and use it in GitHub Desktop.
macOSとシェルスクリプトでダイアログを表示する
#!/bin/bash
# macOSとシェルスクリプトでダイアログを表示する
set -eu
osadialog() {
local text=$1
set +e
osascript 2>&1 > /dev/null << EOS
tell me
activate
display dialog "$text"
end tell
EOS
local retval=$?
set -e
if [ "$retval" == "0" ]; then echo "OK"; else echo "CANCEL"; fi
}
if [ "$(osadialog 'おはようございます')" == "OK" ]; then
echo "OKがおされました"
else
echo "CANCELがおされました"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment