Permalink
Browse files

.osx: Ask for the administrator password upfront

Use @cowboy’s `sudo` keep-alive snippet (https://gist.github.com/3118588)
to continuously update the existing `sudo` time stamp until `.osx` has
finished running.
  • Loading branch information...
1 parent 7bbbe8d commit 96c2696096e9c3b140ba15420ca3877043550413 @mathiasbynens committed Aug 3, 2012
Showing with 11 additions and 3 deletions.
  1. +11 −3 .osx
View
14 .osx
@@ -1,13 +1,21 @@
+#!/bin/bash
+
# ~/.osx — http://mths.be/osx
+# Ask for the administrator password upfront
+sudo -v
+
+# Keep-alive: update existing `sudo` time stamp until `.osx` has finished
+while true; do sudo -n true; sleep 60; kill -0 "$$" || exit; done 2>/dev/null &
+
###############################################################################
# General UI/UX #
###############################################################################
# Set computer name (as done via System Preferences → Sharing)
-scutil --set ComputerName "MathBook Pro"
-scutil --set HostName "MathBook Pro"
-scutil --set LocalHostName "MathBook-Pro"
+sudo scutil --set ComputerName "MathBook Pro"
+sudo scutil --set HostName "MathBook Pro"
+sudo scutil --set LocalHostName "MathBook-Pro"
# Menu bar: disable transparency
defaults write NSGlobalDomain AppleEnableMenuBarTransparency -bool false

0 comments on commit 96c2696

Please sign in to comment.