From 202b21752082b206c95c7a382944d497dda8916b Mon Sep 17 00:00:00 2001 From: Ivan Malison Date: Mon, 25 Aug 2014 17:06:42 -0700 Subject: [PATCH] osx updates, brew.sh updates. --- dotfiles/lib/shellrc/brew.sh | 51 ++++++++++++++++++------------- dotfiles/lib/shellrc/functions.sh | 8 +---- dotfiles/lib/shellrc/python.sh | 8 +++++ resources/osx.sh | 33 ++------------------ setup.sh | 49 ++++++++++++++++------------- 5 files changed, 68 insertions(+), 81 deletions(-) diff --git a/dotfiles/lib/shellrc/brew.sh b/dotfiles/lib/shellrc/brew.sh index daf8671d..a9eef843 100755 --- a/dotfiles/lib/shellrc/brew.sh +++ b/dotfiles/lib/shellrc/brew.sh @@ -1,10 +1,11 @@ function brew_install_items() { + echo $@ for package_install_string in $@; do # Horrible hack to induce word splitting. eval "package_args=($package_install_string)" brew install $package_args; - brew link $package_args[0]; + brew link $package_args[1]; done } @@ -25,6 +26,7 @@ function do_the_brew() { "greadlink" "vim --override-system-vi" "zsh" + "make" ) # `find`, `locate`, `updatedb`, and `xargs`, g-prefixed # core utilities (those that come with OS X are outdated) @@ -47,7 +49,6 @@ function do_the_brew() { "wget --enable-iri" ) SHOULD_INSTALL=( - "watch" "nmap" "readline" "netcat" @@ -61,7 +62,10 @@ function do_the_brew() { "hub" "tig" "heroku" - "make" + "scala" + "sbt" + "node" + "npm" ) MISC=( "file-formula" @@ -69,48 +73,51 @@ function do_the_brew() { "less" "openssh --with-brewed-openssl" "perl518" - "python --with-brewed-openssl" "rsync" "svn" "unzip" "macvim --override-system-vim --custom-system-icons" ) - SCALA=(scala sbt) - JAVASCRIPT=(node npm) - brew update - brew tap homebrew/dupes - brew install homebrew/dupes/grep - while getopts "uebsma" OPTCHAR; + install_items=() + while getopts "uebsmah" OPTCHAR; do case $OPTCHAR in u) brew upgrade ;; e) - brew_install_items $ESSENTIAL + install_items=("${install_items[@]}" "${ESSENTIAL[@]}") fix_brew_htop ;; b) - brew_install_items $BASICS + install_items=("${install_items[@]}" "${BASICS[@]}") ;; s) - brew_install_items $SHOULD_INSTALL + install_items=("${install_items[@]}" "${SHOULD_INSTALL[@]}") ;; m) - brew_install_items $MISC - brew_install_items $SCALA - brew_install_items $JAVASCRIPT + install_items=("${install_items[@]}" "${MISC[@]}") ;; a) - brew_install_items $ESSENTIAL - brew_install_items $BASICS - brew_install_items $SHOULD_INSTALL - brew_install_items $MISC - brew_install_items $SCALA - brew_install_items $JAVASCRIPT + install_items=("${install_items[@]}" "${ESSENTIAL[@]}" "${BASICS[@]}" "${SHOULD_INSTALL[@]}" "${MISC[@]}") ;; + h) + echo "Usage: +-a install all packages. +-u upgrade brew packages. +-e install essential packages +-b install GNU basics including replacements for non GNU versions included in OSX. +-s install a wider range of packages. +-m install very non-essential packages. +-h display this help message. +" + return esac done + echo "Installing:" + for package_name in $install_items; do echo $package_name; done; + brew update + brew_install_items $install_items brew cleanup } diff --git a/dotfiles/lib/shellrc/functions.sh b/dotfiles/lib/shellrc/functions.sh index 855f1d52..7877fffb 100644 --- a/dotfiles/lib/shellrc/functions.sh +++ b/dotfiles/lib/shellrc/functions.sh @@ -226,12 +226,6 @@ function get_keyboard_vendor_id_product_id_pairs() { ioreg -n IOHIDKeyboard -r | grep -e 'class IOHIDKeyboard' -e VendorID\" -e Product | gawk 'BEGIN { RS = "class IOHIDKeyboard" } match($0, /VendorID. = ([0-9]*)/, arr) { printf arr[1]} match($0, /ProductID. = ([0-9]*)/, arr) { printf " %s\n", arr[1]} ' } -function startss() { - #reattach-to-user-namespace "/System/Library/Frameworks/ScreenSaver.framework/Versions/A/Resources/ScreenSaverEngine.app/Contents/MacOS/ScreenSaverEngine" & - #reattach-to-user-namespace "zsh" -c "source ~/.zshrc && ssosa" - reattach-to-user-namespace "open" "/System/Library/Frameworks/ScreenSaver.framework/Versions/A/Resources/ScreenSaverEngine.app" -} - -function ssosa() { +function ss() { osascript -e "tell application \"/System/Library/Frameworks/ScreenSaver.framework/Versions/A/Resources/ScreenSaverEngine.app\" to activate" } diff --git a/dotfiles/lib/shellrc/python.sh b/dotfiles/lib/shellrc/python.sh index 82d1c737..e5e0960b 100644 --- a/dotfiles/lib/shellrc/python.sh +++ b/dotfiles/lib/shellrc/python.sh @@ -33,3 +33,11 @@ function install_pygame() { brew install sdl sdl_image sdl_mixer sdl_ttf portmidi /usr/local/share/python/pip install hg+http://bitbucket.org/pygame/pygame } + +function install_powerline() { + hash pip 2>/dev/null || sudo easy_install pip + if test -z $(pip show Powerline | grep Location | awk '{print $2}'); + then + sudo pip install --user git+git://github.com/Lokaltog/powerline + fi +} diff --git a/resources/osx.sh b/resources/osx.sh index 41b89bbf..991e3e9e 100755 --- a/resources/osx.sh +++ b/resources/osx.sh @@ -10,9 +10,6 @@ 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) -set_osx_hostname - # Menu bar: disable transparency defaults write NSGlobalDomain AppleEnableMenuBarTransparency -bool false @@ -87,7 +84,6 @@ defaults write com.apple.universalaccess closeViewScrollWheelToggle -bool true defaults write com.apple.universalaccess HIDScrollZoomModifierMask -int 262144 # Follow the keyboard focus while zoomed in defaults write com.apple.universalaccess closeViewZoomFollowsFocus -bool true - # Disable press-and-hold for keys in favor of key repeat defaults write NSGlobalDomain ApplePressAndHoldEnabled -bool false @@ -206,8 +202,8 @@ defaults write com.apple.finder FXPreferredViewStyle -string "Nlsv" # Disable the warning before emptying the Trash defaults write com.apple.finder WarnOnEmptyTrash -bool false -# Empty Trash securely by default -defaults write com.apple.finder EmptyTrashSecurely -bool true +# Don't Empty Trash securely by default +defaults write com.apple.finder EmptyTrashSecurely -bool false # Enable AirDrop over Ethernet and on unsupported Macs running Lion defaults write com.apple.NetworkBrowser BrowseAllInterfaces -bool true @@ -289,21 +285,6 @@ hash tmutil &> /dev/null && sudo tmutil disablelocal # Address Book, Dashboard, iCal, TextEdit, and Disk Utility # ############################################################################### -# Enable the debug menu in Address Book -defaults write com.apple.addressbook ABShowDebugMenu -bool true - -# Enable Dashboard dev mode (allows keeping widgets on the desktop) -defaults write com.apple.dashboard devmode -bool true - -# Enable the debug menu in iCal (pre-10.8) -defaults write com.apple.iCal IncludeDebugMenu -bool true - -# Use plain text mode for new TextEdit documents -defaults write com.apple.TextEdit RichText -int 0 -# Open and save files as UTF-8 in TextEdit -defaults write com.apple.TextEdit PlainTextEncoding -int 4 -defaults write com.apple.TextEdit PlainTextEncodingForWrite -int 4 - # Enable the debug menu in Disk Utility defaults write com.apple.DiskUtility DUDebugMenuEnabled -bool true defaults write com.apple.DiskUtility advanced-image-options -bool true @@ -326,16 +307,6 @@ defaults write com.apple.appstore ShowDebugMenu -bool true defaults write com.google.Chrome ExtensionInstallSources -array "https://*.github.com/*" "http://userscripts.org/*" defaults write com.google.Chrome.canary ExtensionInstallSources -array "https://*.github.com/*" "http://userscripts.org/*" -############################################################################### -# SizeUp.app # -############################################################################### - -# Start SizeUp at login -defaults write com.irradiatedsoftware.SizeUp StartAtLogin -bool true - -# Don’t show the preferences window on next start -defaults write com.irradiatedsoftware.SizeUp ShowPrefsOnNextStart -bool false - ############################################################################### # Transmission.app # ############################################################################### diff --git a/setup.sh b/setup.sh index 95329718..de830b48 100755 --- a/setup.sh +++ b/setup.sh @@ -1,26 +1,33 @@ #!/usr/bin/env bash -cd `dirname $BASH_SOURCE` && source resources/bootstrapping.sh -source dotfiles/lib/shellrc/functions.sh +function setup() { + cd `dirname $BASH_SOURCE` && source resources/bootstrapping.sh + source dotfiles/lib/shellrc/functions.sh + source dotfiles/lib/shellrc/brew.sh + source dotfiles/lib/shellrc/python.sh + case `uname` in + 'Darwin') + osx_setup + ;; + 'Linux') + source resources/apt-get.sh + ;; + esac -case `uname` in - 'Darwin') - source resources/osx.sh - source resources/brew.sh - ;; - 'Linux') - source resources/apt-get.sh - ;; -esac - - -function install_powerline() { - hash pip 2>/dev/null || sudo easy_install pip - if test -z $(pip show Powerline | grep Location | awk '{print $2}'); - then - sudo pip install --user git+git://github.com/Lokaltog/powerline - fi + install_powerline + source bootstrap.sh } -install_powerline -source bootstrap.sh + +function osx_setup() { + while getopts "uebsmaho" OPTCHAR; + do + case $OPTCHAR in + h) + echo "brew options:" + do_the_brew -h + exit + ;; + source resources/osx.sh + do_the_brew $@ +}