Skip to content

Instantly share code, notes, and snippets.

@ahknight
Last active May 5, 2017 18:04
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 ahknight/2e63697d0dfe02c8008ed6848cad17c9 to your computer and use it in GitHub Desktop.
Save ahknight/2e63697d0dfe02c8008ed6848cad17c9 to your computer and use it in GitHub Desktop.
sudoish - Authenticate shell commands with the system authentication dialog, including using Touch ID on MacBook Pros
#!/bin/sh
CMD=()
for i in "$@"; do
if [[ $i =~ "[[:space:]]" ]]; then
CMD+=(\\\"$i\\\")
else
CMD+=($i)
fi
done
SCRIPT="do shell script \"${CMD[@]}\" with administrator privileges"
osascript -e "$SCRIPT"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment