Skip to content

Instantly share code, notes, and snippets.

@florido
Created May 1, 2019 05:03
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 florido/305f8468c5af51fac7a225d05cf4de10 to your computer and use it in GitHub Desktop.
Save florido/305f8468c5af51fac7a225d05cf4de10 to your computer and use it in GitHub Desktop.
#!/bin/bash
/usr/bin/osascript <<EOT
set theResponse to display dialog "What's your code?" default answer "" with icon stop buttons {"Cancel", "Continue"} default button "Continue" with hidden answer
display dialog "My Secret Code is " & (text returned of theResponse) & "."
EOT
OR
#!/bin/bash
HWNAME=$(osascript <<EOD
tell application "System Events"
text returned of (display dialog "Please enter your desired hostname: (Use dashes for spaces)" default answer "")
end tell
EOD)
scutil --set ComputerName "$HWNAME"
scutil --set LocalHostName "$HWNAME"
dscacheutil -flushcache
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment