working on it ...

Filters

Explore Public Snippets

Sort by

Found 3,987 snippets matching: osx

    public by Tim Brown modified May 27, 2016  38397  1  3  0

    OSX for Hackers: Yosemite/El Capitan Edition. This script tries not to be *too* opinionated and any major changes to your system require a prompt. You've been warned. Also, please don't email me about this script, my poor inbox...

    OSX for Hackers: Yosemite/El Capitan Edition. This script tries not to be *too* opinionated and any major changes to your system require a prompt. You've been warned. Also, please don't email me about this script, my poor inbox...: osx-for-hackers.sh
    #!/bin/sh
    
    # Alot of these configs have been taken from the various places
    # on the web, most from here
    # https://github.com/mathiasbynens/dotfiles/blob/master/.osx
    
    # Set the colours you can use
    black='\033[0;30m'
    white='\033[0;37m'
    red='\033[0;31m'
    green='\033[0;32m'
    yellow='\033[0;33m'
    blue='\033[0;34m'
    magenta='\033[0;35m'
    cyan='\033[0;36m'
    
    # Resets the style
    reset=`tput sgr0`
    
    # Color-echo. Improved. [Thanks @joaocunha]
    # arg $1 = message
    # arg $2 = Color
    cecho() {
      echo "${2}${1}${reset}"
      return
    }
    
    # Set continue to false by default
    CONTINUE=false
    
    echo ""
    cecho "###############################################" $red
    cecho "#        DO NOT RUN THIS SCRIPT BLINDLY       #" $red
    cecho "#         YOU'LL PROBABLY REGRET IT...        #" $red
    cecho "#                                             #" $red
    cecho "#              READ IT THOROUGHLY             #" $red
    cecho "#         AND EDIT TO SUIT YOUR NEEDS         #" $red
    cecho "###############################################" $red
    echo ""
    
    
    echo ""
    cecho "Have you read through the script you're about to run and " $red
    cecho "understood that it will make changes to your computer? (y/n)" $red
    read -r response
    if [[ $response =~ ^([yY][eE][sS]|[yY])$ ]]; then
      CONTINUE=true
    fi
    
    if ! $CONTINUE; then
      # Check if we're continuing and output a message if not
      cecho "Please go read the script, it only takes a few minutes" $red
      exit
    fi
    
    # Here we go.. ask for the administrator password upfront and run a
    # keep-alive to update existing `sudo` time stamp until script has finished
    sudo -v
    while true; do sudo -n true; sleep 60; kill -0 "$$" || exit; done 2>/dev/null &
    
    ###############################################################################
    # General UI/UX
    ###############################################################################
    
    echo ""
    echo "Would you like to set your computer name (as done via System Preferences >> Sharing)?  (y/n)"
    read -r response
    if [[ $response =~ ^([yY][eE][sS]|[yY])$ ]]; then
      echo "What would you like it to be?"
      read COMPUTER_NAME
      sudo scutil --set ComputerName $COMPUTER_NAME
      sudo scutil --set HostName $COMPUTER_NAME
      sudo scutil --set LocalHostName $COMPUTER_NAME
      sudo defaults write /Library/Preferences/SystemConfiguration/com.apple.smb.server NetBIOSName -string $COMPUTER_NAME
    fi
    
    echo ""
    echo "Hide the Time Machine, Volume, User, and Bluetooth icons?  (y/n)"
    read -r response
    if [[ $response =~ ^([yY][eE][sS]|[yY])$ ]]; then
      # Get the system Hardware UUID and use it for the next menubar stuff
      for domain in ~/Library/Preferences/ByHost/com.apple.systemuiserver.*; do
        defaults write "${domain}" dontAutoLoad -array \
          "/System/Library/CoreServices/Menu Extras/TimeMachine.menu" \
          "/System/Library/CoreServices/Menu Extras/Volume.menu" \
          "/System/Library/CoreServices/Menu Extras/User.menu"
      done
    
      defaults write com.apple.systemuiserver menuExtras -array \
        "/System/Library/CoreServices/Menu Extras/Bluetooth.menu" \
        "/System/Library/CoreServices/Menu Extras/AirPort.menu" \
        "/System/Library/CoreServices/Menu Extras/Battery.menu" \
        "/System/Library/CoreServices/Menu Extras/Clock.menu"
    fi
    
    echo ""
    echo "Hide the Spotlight icon? (y/n)"
    read -r response
    if [[ $response =~ ^([yY][eE][sS]|[yY])$ ]]; then
      sudo chmod 600 /System/Library/CoreServices/Search.bundle/Contents/MacOS/Search
    fi
    
    echo ""
    echo "Disable Spotlight indexing for any volume that gets mounted and has not yet been indexed before? (y/n)"
    read -r response
    if [[ $response =~ ^([yY][eE][sS]|[yY])$ ]]; then
      echo 'Use `sudo mdutil -i off "/Volumes/foo"` to stop indexing any volume.'
      sudo defaults write /.Spotlight-V100/VolumeConfiguration Exclusions -array "/Volumes"
    fi
    
    echo ""
    echo "Change indexing order and disable some search results in Spotlight? (y/n)"
    read -r response
    if [[ $response =~ ^([yY][eE][sS]|[yY])$ ]]; then
      # Yosemite-specific search results (remove them if your are using OS X 10.9 or older):
      #   MENU_DEFINITION
      #   MENU_CONVERSION
      #   MENU_EXPRESSION
      #   MENU_SPOTLIGHT_SUGGESTIONS (send search queries to Apple)
      #   MENU_WEBSEARCH             (send search queries to Apple)
      #   MENU_OTHER
      defaults write com.apple.spotlight orderedItems -array \
        '{"enabled" = 1;"name" = "APPLICATIONS";}' \
        '{"enabled" = 1;"name" = "SYSTEM_PREFS";}' \
        '{"enabled" = 1;"name" = "DIRECTORIES";}' \
        '{"enabled" = 1;"name" = "PDF";}' \
        '{"enabled" = 1;"name" = "FONTS";}' \
        '{"enabled" = 0;"name" = "DOCUMENTS";}' \
        '{"enabled" = 0;"name" = "MESSAGES";}' \
        '{"enabled" = 0;"name" = "CONTACT";}' \
        '{"enabled" = 0;"name" = "EVENT_TODO";}' \
        '{"enabled" = 0;"name" = "IMAGES";}' \
        '{"enabled" = 0;"name" = "BOOKMARKS";}' \
        '{"enabled" = 0;"name" = "MUSIC";}' \
        '{"enabled" = 0;"name" = "MOVIES";}' \
        '{"enabled" = 0;"name" = "PRESENTATIONS";}' \
        '{"enabled" = 0;"name" = "SPREADSHEETS";}' \
        '{"enabled" = 0;"name" = "SOURCE";}' \
        '{"enabled" = 0;"name" = "MENU_DEFINITION";}' \
        '{"enabled" = 0;"name" = "MENU_OTHER";}' \
        '{"enabled" = 0;"name" = "MENU_CONVERSION";}' \
        '{"enabled" = 0;"name" = "MENU_EXPRESSION";}' \
        '{"enabled" = 0;"name" = "MENU_WEBSEARCH";}' \
        '{"enabled" = 0;"name" = "MENU_SPOTLIGHT_SUGGESTIONS";}'
      # Load new settings before rebuilding the index
      killall mds > /dev/null 2>&1
      # Make sure indexing is enabled for the main volume
      sudo mdutil -i on / > /dev/null
      # Rebuild the index from scratch
      sudo mdutil -E / > /dev/null
    fi
    
    echo ""
    echo "Expanding the save panel by default"
    defaults write NSGlobalDomain NSNavPanelExpandedStateForSaveMode -bool true
    defaults write NSGlobalDomain PMPrintingExpandedStateForPrint -bool true
    defaults write NSGlobalDomain PMPrintingExpandedStateForPrint2 -bool true
    
    echo ""
    echo "Automatically quit printer app once the print jobs complete"
    defaults write com.apple.print.PrintingPrefs "Quit When Finished" -bool true
    
    # Try e.g. `cd /tmp; unidecode "\x{0000}" > cc.txt; open -e cc.txt`
    echo ""
    echo "Displaying ASCII control characters using caret notation in standard text views"
    defaults write NSGlobalDomain NSTextShowsControlCharacters -bool true
    
    echo ""
    echo "Save to disk, rather than iCloud, by default? (y/n)"
    read -r response
    if [[ $response =~ ^([yY][eE][sS]|[yY])$ ]]; then
      defaults write NSGlobalDomain NSDocumentSaveNewDocumentsToCloud -bool false
    fi
    
    echo ""
    echo "Reveal IP address, hostname, OS version, etc. when clicking the clock in the login window"
    sudo defaults write /Library/Preferences/com.apple.loginwindow AdminHostInfo HostName
    
    echo ""
    echo "Check for software updates daily, not just once per week"
    defaults write com.apple.SoftwareUpdate ScheduleFrequency -int 1
    
    echo ""
    echo "Removing duplicates in the 'Open With' menu"
    /System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister -kill -r -domain local -domain system -domain user
    
    echo ""
    echo "Disable smart quotes and smart dashes? (y/n)"
    read -r response
    if [[ $response =~ ^([yY][eE][sS]|[yY])$ ]]; then
      defaults write NSGlobalDomain NSAutomaticQuoteSubstitutionEnabled -bool false
      defaults write NSGlobalDomain NSAutomaticDashSubstitutionEnabled -bool false
    fi
    
    echo ""
    echo "Add ability to toggle between Light and Dark mode in Yosemite using ctrl+opt+cmd+t? (y/n)"
    # http://www.reddit.com/r/apple/comments/2jr6s2/1010_i_found_a_way_to_dynamically_switch_between/
    read -r response
    if [[ $response =~ ^([yY][eE][sS]|[yY])$ ]]; then
      sudo defaults write /Library/Preferences/.GlobalPreferences.plist _HIEnableThemeSwitchHotKey -bool true
    fi
    
    echo ""
    echo "Disable Photos.app from starting everytime a device is plugged in"
    defaults -currentHost write com.apple.ImageCapture disableHotPlug -bool true
    
    
    ###############################################################################
    # General Power and Performance modifications
    ###############################################################################
    
    echo ""
    echo "Disable hibernation? (speeds up entering sleep mode) (y/n)"
    read -r response
    if [[ $response =~ ^([yY][eE][sS]|[yY])$ ]]; then
      sudo pmset -a hibernatemode 0
    fi
    
    echo ""
    echo "Remove the sleep image file to save disk space? (y/n)"
    echo "(If you're on a <128GB SSD, this helps but can have adverse affects on performance. You've been warned.)"
    read -r response
    if [[ $response =~ ^([yY][eE][sS]|[yY])$ ]]; then
      sudo rm /Private/var/vm/sleepimage
      echo "Creating a zero-byte file instead"
      sudo touch /Private/var/vm/sleepimage
      echo "and make sure it can't be rewritten"
      sudo chflags uchg /Private/var/vm/sleepimage
    fi
    
    echo ""
    echo "Disable the sudden motion sensor? (it's not useful for SSDs/current MacBooks) (y/n)"
    read -r response
    if [[ $response =~ ^([yY][eE][sS]|[yY])$ ]]; then
      sudo pmset -a sms 0
    fi
    
    echo ""
    echo "Disable system-wide resume? (y/n)"
    read -r response
    if [[ $response =~ ^([yY][eE][sS]|[yY])$ ]]; then
      defaults write com.apple.systempreferences NSQuitAlwaysKeepsWindows -bool false
    fi
    
    echo ""
    echo "Disable the menubar transparency? (y/n)"
    read -r response
    if [[ $response =~ ^([yY][eE][sS]|[yY])$ ]]; then
      defaults write com.apple.universalaccess reduceTransparency -bool true
    fi
    
    echo ""
    echo "Speeding up wake from sleep to 24 hours from an hour"
    # http://www.cultofmac.com/221392/quick-hack-speeds-up-retina-macbooks-wake-from-sleep-os-x-tips/
    sudo pmset -a standbydelay 86400
    
    
    ################################################################################
    # Trackpad, mouse, keyboard, Bluetooth accessories, and input
    ###############################################################################
    
    echo ""
    echo "Increasing sound quality for Bluetooth headphones/headsets"
    defaults write com.apple.BluetoothAudioAgent "Apple Bitpool Min (editable)" -int 40
    
    echo ""
    echo "Enabling full keyboard access for all controls (enable Tab in modal dialogs, menu windows, etc.)"
    defaults write NSGlobalDomain AppleKeyboardUIMode -int 3
    
    echo ""
    echo "Disabling press-and-hold for special keys in favor of key repeat"
    defaults write NSGlobalDomain ApplePressAndHoldEnabled -bool false
    
    echo ""
    echo "Setting a blazingly fast keyboard repeat rate"
    defaults write NSGlobalDomain KeyRepeat -int 0
    
    echo ""
    echo "Disable auto-correct? (y/n)"
    read -r response
    if [[ $response =~ ^([yY][eE][sS]|[yY])$ ]]; then
      defaults write NSGlobalDomain NSAutomaticSpellingCorrectionEnabled -bool false
    fi
    
    echo ""
    echo "Setting trackpad & mouse speed to a reasonable number"
    defaults write -g com.apple.trackpad.scaling 2
    defaults write -g com.apple.mouse.scaling 2.5
    
    echo ""
    echo "Turn off keyboard illumination when computer is not used for 5 minutes"
    defaults write com.apple.BezelServices kDimTime -int 300
    
    echo ""
    echo "Disable display from automatically adjusting brightness? (y/n)"
    read -r response
    if [[ $response =~ ^([yY][eE][sS]|[yY])$ ]]; then
      sudo defaults write /Library/Preferences/com.apple.iokit.AmbientLightSensor "Automatic Display Enabled" -bool false
    fi
    
    echo ""
    echo "Disable keyboard from automatically adjusting backlight brightness in low light? (y/n)"
    read -r response
    if [[ $response =~ ^([yY][eE][sS]|[yY])$ ]]; then
      sudo defaults write /Library/Preferences/com.apple.iokit.AmbientLightSensor "Automatic Keyboard Enabled" -bool false
    fi
    
    ###############################################################################
    # Screen
    ###############################################################################
    
    echo ""
    echo "Requiring password immediately after sleep or screen saver begins"
    defaults write com.apple.screensaver askForPassword -int 1
    defaults write com.apple.screensaver askForPasswordDelay -int 0
    
    echo ""
    echo "Where do you want screenshots to be stored? (hit ENTER if you want ~/Desktop as default)"
    # Thanks https://github.com/omgmog
    read screenshot_location
    echo ""
    if [ -z "${screenshot_location}" ]
    then
      # If nothing specified, we default to ~/Desktop
      screenshot_location="${HOME}/Desktop"
    else
      # Otherwise we use input
      if [[ "${screenshot_location:0:1}" != "/" ]]
      then
        # If input doesn't start with /, assume it's relative to home
        screenshot_location="${HOME}/${screenshot_location}"
      fi
    fi
    echo "Setting location to ${screenshot_location}"
    defaults write com.apple.screencapture location -string "${screenshot_location}"
    
    echo ""
    echo "What format should screenshots be saved as? (hit ENTER for PNG, options: BMP, GIF, JPG, PDF, TIFF) "
    read screenshot_format
    if [ -z "$1" ]
    then
      echo ""
      echo "Setting screenshot format to PNG"
      defaults write com.apple.screencapture type -string "png"
    else
      echo ""
      echo "Setting screenshot format to $screenshot_format"
      defaults write com.apple.screencapture type -string "$screenshot_format"
    fi
    
    echo ""
    echo "Enabling subpixel font rendering on non-Apple LCDs"
    defaults write NSGlobalDomain AppleFontSmoothing -int 2
    
    echo ""
    echo "Enabling HiDPI display modes (requires restart)"
    sudo defaults write /Library/Preferences/com.apple.windowserver DisplayResolutionEnabled -bool true
    
    ###############################################################################
    # Finder
    ###############################################################################
    
    echo ""
    echo "Show icons for hard drives, servers, and removable media on the desktop? (y/n)"
    read -r response
    if [[ $response =~ ^([yY][eE][sS]|[yY])$ ]]; then
      defaults write com.apple.finder ShowExternalHardDrivesOnDesktop -bool true
    fi
    
    echo ""
    echo "Show hidden files in Finder by default? (y/n)"
    read -r response
    if [[ $response =~ ^([yY][eE][sS]|[yY])$ ]]; then
      defaults write com.apple.Finder AppleShowAllFiles -bool true
    fi
    
    echo ""
    echo "Show dotfiles in Finder by default? (y/n)"
    read -r response
    if [[ $response =~ ^([yY][eE][sS]|[yY])$ ]]; then
      defaults write com.apple.finder AppleShowAllFiles TRUE
    fi
    
    echo ""
    echo "Show all filename extensions in Finder by default? (y/n)"
    read -r response
    if [[ $response =~ ^([yY][eE][sS]|[yY])$ ]]; then
      defaults write NSGlobalDomain AppleShowAllExtensions -bool true
    fi
    
    echo ""
    echo "Show status bar in Finder by default? (y/n)"
    read -r response
    if [[ $response =~ ^([yY][eE][sS]|[yY])$ ]]; then
      defaults write com.apple.finder ShowStatusBar -bool true
    fi
    
    echo ""
    echo "Display full POSIX path as Finder window title? (y/n)"
    read -r response
    if [[ $response =~ ^([yY][eE][sS]|[yY])$ ]]; then
      defaults write com.apple.finder _FXShowPosixPathInTitle -bool true
    fi
    
    echo ""
    echo "Disable the warning when changing a file extension? (y/n)"
    read -r response
    if [[ $response =~ ^([yY][eE][sS]|[yY])$ ]]; then
      defaults write com.apple.finder FXEnableExtensionChangeWarning -bool false
    fi
    
    echo ""
    echo "Use column view in all Finder windows by default? (y/n)"
    read -r response
    if [[ $response =~ ^([yY][eE][sS]|[yY])$ ]]; then
      defaults write com.apple.finder FXPreferredViewStyle Clmv
    fi
    
    echo ""
    echo "Avoid creation of .DS_Store files on network volumes? (y/n)"
    read -r response
    if [[ $response =~ ^([yY][eE][sS]|[yY])$ ]]; then
      defaults write com.apple.desktopservices DSDontWriteNetworkStores -bool true
    fi
    
    echo ""
    echo "Disable disk image verification? (y/n)"
    read -r response
    if [[ $response =~ ^([yY][eE][sS]|[yY])$ ]]; then
      defaults write com.apple.frameworks.diskimages skip-verify -bool true
      defaults write com.apple.frameworks.diskimages skip-verify-locked -bool true
      defaults write com.apple.frameworks.diskimages skip-verify-remote -bool true
    fi
    
    echo ""
    echo "Allowing text selection in Quick Look/Preview in Finder by default"
    defaults write com.apple.finder QLEnableTextSelection -bool true
    
    echo ""
    echo "Show item info near icons on the desktop and in other icon views? (y/n)"
    read -r response
    if [[ $response =~ ^([yY][eE][sS]|[yY])$ ]]; then
      /usr/libexec/PlistBuddy -c "Set :DesktopViewSettings:IconViewSettings:showItemInfo true" ~/Library/Preferences/com.apple.finder.plist
      /usr/libexec/PlistBuddy -c "Set :FK_StandardViewSettings:IconViewSettings:showItemInfo true" ~/Library/Preferences/com.apple.finder.plist
      /usr/libexec/PlistBuddy -c "Set :StandardViewSettings:IconViewSettings:showItemInfo true" ~/Library/Preferences/com.apple.finder.plist
    fi
    
    echo ""
    echo "Show item info to the right of the icons on the desktop? (y/n)"
    read -r response
    if [[ $response =~ ^([yY][eE][sS]|[yY])$ ]]; then
      /usr/libexec/PlistBuddy -c "Set DesktopViewSettings:IconViewSettings:labelOnBottom false" ~/Library/Preferences/com.apple.finder.plist
    fi
    
    echo ""
    echo "Enable snap-to-grid for icons on the desktop and in other icon views? (y/n)"
    read -r response
    if [[ $response =~ ^([yY][eE][sS]|[yY])$ ]]; then
      /usr/libexec/PlistBuddy -c "Set :DesktopViewSettings:IconViewSettings:arrangeBy grid" ~/Library/Preferences/com.apple.finder.plist
      /usr/libexec/PlistBuddy -c "Set :FK_StandardViewSettings:IconViewSettings:arrangeBy grid" ~/Library/Preferences/com.apple.finder.plist
      /usr/libexec/PlistBuddy -c "Set :StandardViewSettings:IconViewSettings:arrangeBy grid" ~/Library/Preferences/com.apple.finder.plist
    fi
    
    echo ""
    echo "Increase grid spacing for icons on the desktop and in other icon views? (y/n)"
    read -r response
    if [[ $response =~ ^([yY][eE][sS]|[yY])$ ]]; then
      /usr/libexec/PlistBuddy -c "Set :DesktopViewSettings:IconViewSettings:gridSpacing 100" ~/Library/Preferences/com.apple.finder.plist
      /usr/libexec/PlistBuddy -c "Set :FK_StandardViewSettings:IconViewSettings:gridSpacing 100" ~/Library/Preferences/com.apple.finder.plist
      /usr/libexec/PlistBuddy -c "Set :StandardViewSettings:IconViewSettings:gridSpacing 100" ~/Library/Preferences/com.apple.finder.plist
    fi
    
    echo ""
    echo "Increase the size of icons on the desktop and in other icon views? (y/n)"
    read -r response
    if [[ $response =~ ^([yY][eE][sS]|[yY])$ ]]; then
      /usr/libexec/PlistBuddy -c "Set :DesktopViewSettings:IconViewSettings:iconSize 80" ~/Library/Preferences/com.apple.finder.plist
      /usr/libexec/PlistBuddy -c "Set :FK_StandardViewSettings:IconViewSettings:iconSize 80" ~/Library/Preferences/com.apple.finder.plist
      /usr/libexec/PlistBuddy -c "Set :StandardViewSettings:IconViewSettings:iconSize 80" ~/Library/Preferences/com.apple.finder.plist
    fi
    
    
    ###############################################################################
    # Dock & Mission Control
    ###############################################################################
    
    echo "Wipe all (default) app icons from the Dock? (y/n)"
    echo "(This is only really useful when setting up a new Mac, or if you don't use the Dock to launch apps.)"
    read -r response
    if [[ $response =~ ^([yY][eE][sS]|[yY])$ ]]; then
      defaults write com.apple.dock persistent-apps -array
    fi
    
    echo ""
    echo "Setting the icon size of Dock items to 36 pixels for optimal size/screen-realestate"
    defaults write com.apple.dock tilesize -int 36
    
    echo ""
    echo "Speeding up Mission Control animations and grouping windows by application"
    defaults write com.apple.dock expose-animation-duration -float 0.1
    defaults write com.apple.dock "expose-group-by-app" -bool true
    
    echo ""
    echo "Disable the over-the-top focus ring animation"
    defaults write NSGlobalDomain NSUseAnimatedFocusRing -bool false
    
    echo ""
    echo "Hide the menu bar?"
    read -r response
    if [[ $response =~ ^([yY][eE][sS]|[yY])$ ]]; then
      defaults write "Apple Global Domain" "_HIHideMenuBar" 1
    fi
    
    echo ""
    echo "Set Dock to auto-hide and remove the auto-hiding delay? (y/n)"
    read -r response
    if [[ $response =~ ^([yY][eE][sS]|[yY])$ ]]; then
      defaults write com.apple.dock autohide -bool true
      defaults write com.apple.dock autohide-delay -float 0
      defaults write com.apple.dock autohide-time-modifier -float 0
    fi
    
    
    ###############################################################################
    # Chrome, Safari, & WebKit
    ###############################################################################
    
    echo ""
    echo "Privacy: Don't send search queries to Apple"
    defaults write com.apple.Safari UniversalSearchEnabled -bool false
    defaults write com.apple.Safari SuppressSearchSuggestions -bool true
    
    echo ""
    echo "Hiding Safari's bookmarks bar by default"
    defaults write com.apple.Safari ShowFavoritesBar -bool false
    
    echo ""
    echo "Hiding Safari's sidebar in Top Sites"
    defaults write com.apple.Safari ShowSidebarInTopSites -bool false
    
    echo ""
    echo "Disabling Safari's thumbnail cache for History and Top Sites"
    defaults write com.apple.Safari DebugSnapshotsUpdatePolicy -int 2
    
    echo ""
    echo "Enabling Safari's debug menu"
    defaults write com.apple.Safari IncludeInternalDebugMenu -bool true
    
    echo ""
    echo "Making Safari's search banners default to Contains instead of Starts With"
    defaults write com.apple.Safari FindOnPageMatchesWordStartsOnly -bool false
    
    echo ""
    echo "Removing useless icons from Safari's bookmarks bar"
    defaults write com.apple.Safari ProxiesInBookmarksBar "()"
    
    echo ""
    echo "Enabling the Develop menu and the Web Inspector in Safari"
    defaults write com.apple.Safari IncludeDevelopMenu -bool true
    defaults write com.apple.Safari WebKitDeveloperExtrasEnabledPreferenceKey -bool true
    defaults write com.apple.Safari "com.apple.Safari.ContentPageGroupIdentifier.WebKit2DeveloperExtrasEnabled" -bool true
    
    echo ""
    echo "Adding a context menu item for showing the Web Inspector in web views"
    defaults write NSGlobalDomain WebKitDeveloperExtras -bool true
    
    echo ""
    echo "Disabling the annoying backswipe in Chrome"
    defaults write com.google.Chrome AppleEnableSwipeNavigateWithScrolls -bool false
    defaults write com.google.Chrome.canary AppleEnableSwipeNavigateWithScrolls -bool false
    
    echo ""
    echo "Using the system-native print preview dialog in Chrome"
    defaults write com.google.Chrome DisablePrintPreview -bool true
    defaults write com.google.Chrome.canary DisablePrintPreview -bool true
    
    
    ###############################################################################
    # Mail
    ###############################################################################
    
    echo ""
    echo "Setting email addresses to copy as 'foo@example.com' instead of 'Foo Bar <foo@example.com>' in Mail.app"
    defaults write com.apple.mail AddressesIncludeNameOnPasteboard -bool false
    
    
    ###############################################################################
    # Terminal
    ###############################################################################
    
    echo ""
    echo "Enabling UTF-8 ONLY in Terminal.app and setting the Pro theme by default"
    defaults write com.apple.terminal StringEncodings -array 4
    defaults write com.apple.Terminal "Default Window Settings" -string "Pro"
    defaults write com.apple.Terminal "Startup Window Settings" -string "Pro"
    
    
    ###############################################################################
    # Time Machine
    ###############################################################################
    
    echo ""
    echo "Prevent Time Machine from prompting to use new hard drives as backup volume? (y/n)"
    read -r response
    if [[ $response =~ ^([yY][eE][sS]|[yY])$ ]]; then
      defaults write com.apple.TimeMachine DoNotOfferNewDisksForBackup -bool true
    fi
    
    echo ""
    echo "Disable local Time Machine backups? (This can take up a ton of SSD space on <128GB SSDs) (y/n)"
    read -r response
    if [[ $response =~ ^([yY][eE][sS]|[yY])$ ]]; then
      hash tmutil &> /dev/null && sudo tmutil disablelocal
    fi
    
    
    ###############################################################################
    # Messages                                                                    #
    ###############################################################################
    
    echo ""
    echo "Disable automatic emoji substitution in Messages.app? (i.e. use plain text smileys) (y/n)"
    read -r response
    if [[ $response =~ ^([yY][eE][sS]|[yY])$ ]]; then
      defaults write com.apple.messageshelper.MessageController SOInputLineSettings -dict-add "automaticEmojiSubstitutionEnablediMessage" -bool false
    fi
    
    echo ""
    echo "Disable smart quotes in Messages.app? (it's annoying for messages that contain code) (y/n)"
    read -r response
    if [[ $response =~ ^([yY][eE][sS]|[yY])$ ]]; then
      defaults write com.apple.messageshelper.MessageController SOInputLineSettings -dict-add "automaticQuoteSubstitutionEnabled" -bool false
    fi
    
    echo ""
    echo "Disable continuous spell checking in Messages.app? (y/n)"
    read -r response
    if [[ $response =~ ^([yY][eE][sS]|[yY])$ ]]; then
      defaults write com.apple.messageshelper.MessageController SOInputLineSettings -dict-add "continuousSpellCheckingEnabled" -bool false
    fi
    
    
    ###############################################################################
    # Transmission.app                                                            #
    ###############################################################################
    
    
    echo ""
    echo "Do you use Transmission for torrenting? (y/n)"
    read -r response
    if [[ $response =~ ^([yY][eE][sS]|[yY])$ ]]; then
      mkdir -p ~/Downloads/Incomplete
    
      echo ""
      echo "Setting up an incomplete downloads folder in Downloads"
      defaults write org.m0k.transmission UseIncompleteDownloadFolder -bool true
      defaults write org.m0k.transmission IncompleteDownloadFolder -string "${HOME}/Downloads/Incomplete"
    
      echo ""
      echo "Setting auto-add folder to be Downloads"
      defaults write org.m0k.transmission AutoImportDirectory -string "${HOME}/Downloads"
    
      echo ""
      echo "Don't prompt for confirmation before downloading"
      defaults write org.m0k.transmission DownloadAsk -bool false
    
      echo ""
      echo "Trash original torrent files after adding them"
      defaults write org.m0k.transmission DeleteOriginalTorrent -bool true
    
      echo ""
      echo "Hiding the donate message"
      defaults write org.m0k.transmission WarningDonate -bool false
    
      echo ""
      echo "Hiding the legal disclaimer"
      defaults write org.m0k.transmission WarningLegal -bool false
    
      echo ""
      echo "Auto-resizing the window to fit transfers"
      defaults write org.m0k.transmission AutoSize -bool true
    
      echo ""
      echo "Auto updating to betas"
      defaults write org.m0k.transmission AutoUpdateBeta -bool true
    
      echo ""
      echo "Setting up the best block list"
      defaults write org.m0k.transmission EncryptionRequire -bool true
      defaults write org.m0k.transmission BlocklistAutoUpdate -bool true
      defaults write org.m0k.transmission BlocklistNew -bool true
      defaults write org.m0k.transmission BlocklistURL -string "http://john.bitsurge.net/public/biglist.p2p.gz"
    fi
    
    
    ###############################################################################
    # Sublime Text
    ###############################################################################
    echo ""
    echo "Do you use Sublime Text 3 as your editor of choice, and is it installed?"
    read -r response
    if [[ $response =~ ^([yY][eE][sS]|[yY])$ ]]; then
      # Installing from homebrew cask does the following for you!
      # echo ""
      # echo "Linking Sublime Text for command line usage as subl"
      # ln -s "/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl" /usr/local/bin/subl
    
      echo ""
      echo "Setting Git to use Sublime Text as default editor"
      git config --global core.editor "subl -n -w"
    fi
    
    ###############################################################################
    # Optional Extras
    ###############################################################################
    
    # Create a nice last-change git log message, from https://twitter.com/elijahmanor/status/697055097356943360
    git config --global alias.lastchange 'log -p --follow -n 1'
    
    
    
    ###############################################################################
    # Kill affected applications
    ###############################################################################
    
    echo ""
    cecho "Done!" $cyan
    echo ""
    echo ""
    cecho "################################################################################" $white
    echo ""
    echo ""
    cecho "Note that some of these changes require a logout/restart to take effect." $red
    cecho "Killing some open applications in order to take effect." $red
    echo ""
    
    find ~/Library/Application\ Support/Dock -name "*.db" -maxdepth 1 -delete
    for app in "Activity Monitor" "Address Book" "Calendar" "Contacts" "cfprefsd" \
      "Dock" "Finder" "Mail" "Messages" "Safari" "SystemUIServer" \
      "Terminal" "Transmission"; do
      killall "${app}" > /dev/null 2>&1
    done
    
    
    

    public by Kevin Elliott modified Sep 30, 2015  100047  0  3  0

    Mac OS X 10.11 El Capitan Setup

    Mac OS X 10.11 El Capitan Setup: osx-10.11-setup.md
    # Mac OS X 10.11 El Capitan
    
    Custom recipe to get OS X 10.11 El Capitan running from scratch, setup applications and developer environment. This is very similar (and currently mostly the same) as my 10.10 Yosemite setup recipe (as found on this gist https://gist.github.com/kevinelliott/0726211d17020a6abc1f). Note that I expect this to change significantly as I install El Capitan several times.
    
    I use this gist to keep track of the important software and steps required to have a functioning system after a semi-annual fresh install. On average, I reinstall each computer from scratch every 6 months, and I do not perform upgrades between distros.
    
    This keeps the system performing at top speeds, clean of trojans, spyware, and ensures that I maintain good organizational practices for my content and backups. I highly recommend this.
    
    You are encouraged to fork this and modify it to your heart's content to match your own needs.
    
    ## Install Software
    
    The software selected is software that is "tried and true" --- software I need after any fresh install. I often install other software not listed here, but is handled in a case-by-case basis.
    
    ### Install from App Store
    
    * [Airmail](https://itunes.apple.com/us/app/airmail/id573171375?mt=12&uo=4)
    * [Aperture](https://itunes.apple.com/us/app/aperture/id408981426?mt=12&uo=4)
    * [Degrees](https://itunes.apple.com/us/app/degrees/id430173763?mt=12&uo=4)
    * [Divvy](https://itunes.apple.com/us/app/divvy-window-manager/id413857545?mt=12&uo=4)
    * [Opera](https://itunes.apple.com/us/app/opera/id404764921?mt=12&uo=4)
    * [Pages](https://itunes.apple.com/us/app/pages/id409201541?mt=12&uo=4)
    * [Skitch](https://itunes.apple.com/us/app/skitch-snap.-mark-up.-share./id425955336?mt=12&uo=4)
    * [Twitter](https://itunes.apple.com/us/app/twitter/id409789998?mt=12&uo=4)
    * [WiFi Explorer](https://itunes.apple.com/us/app/wifi-explorer/id494803304?mt=12&uo=4)
    * [WiFi Signal](https://itunes.apple.com/us/app/wifi-signal/id525912054?mt=12&uo=4)
    * [Todoist](https://itunes.apple.com/us/app/todoist-to-do-list-task-list/id585829637?mt=12&uo=4)
    * [Xcode](https://itunes.apple.com/us/app/xcode/id497799835?mt=12&uo=4)
    
    ### Install from Third-Party Websites
    
    * Browsers
    	* Chrome (installed via Cask)
    	* [Firefox](http://firefox.com)
    	* Opera (installed via App Store)
    	* [Webkit](http://webkit.org)
    
    * Development
    	* [Dropbox](https://www.dropbox.com/install2)
    	* [GitHub](http://mac.github.com)
    	* [LiveReload](http://livereload.com)
    	* [LiveReload Extensions](http://help.livereload.com/kb/general-use/browser-extensions)
    	* [Sublime Text 3](http://www.sublimetext.com/3)
    
    * Utilities
    	* [1Password](https://agilebits.com/onepassword/mac)
    	* [GrandPerspective](http://grandperspectiv.sourceforge.net/)
    	* [HipChat](https://www.hipchat.com/downloads)
    	* iTerm 2 (installed via Cask)
    	* [Little Snitch](http://www.obdev.at/products/littlesnitch/download.html)
    	* [Quicksilver](http://qsapp.com)
    	* [Skype](http://www.skype.com/en/download-skype/skype-for-computer/)
    	* [Spotify](https://www.spotify.com/us/download/mac/)
    	* [Transmit](http://panic.com/transmit)
    
    * Virtualization
    	* Parallels Desktop (installed via Cask)
    	* Docker (installed via brew)
    	* Vagrant (installed via Cask)
    
    Fonts
    -----
    [Mensch coding font](http://robey.lag.net/2010/06/21/mensch-font.html)
    
    #Xcode Command Line Tools
    
    `Xcode > Preferences > Downloads > Command Line Tools`
    
    
    #Homebrew
    
    ## Run Xcode and accept the license
    
    Homebrew can not install properly until this occurs.
    
    ## Install Homebrew
    ```bash
    ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
    brew doctor
    ```
    
    At the time of this writing, `brew doctor` says that `Xcode 6.1` is required, which means downloading it from the Apple Developer Center until it is released in the Mac App Store.
    
    ## Install Homebrew extension Cask
    ```bash
    brew install caskroom/cask/brew-cask
    ```
    
    ## Install common applications via Homebrew
    *Databases are installed later.*
    ```bash
    brew install ack autojump automake colordiff curl git git-flow \
                 hub icoutils imagemagick libmemcached memcached openssl ossp-uuid qt \
                 readline redis tmux wget libxml2
    ```
    
    ## Install applications via Homebrew Cask
    ```bash
    brew cask install anvil
    brew cask install atom
    brew cask install authy-bluetooth
    brew cask install awareness
    brew cask install bartender
    brew cask install battery-guardian
    brew cask install github
    brew cask install google-chrome
    brew cask install joinme
    brew cask install iterm2
    brew cask install parallels
    brew cask install rescuetime
    brew cask install rubymine
    brew cask install satellite-eyes
    brew cask install sidestep
    brew cask install sonos
    brew cask install spotify
    brew cask install steam
    brew cask install vagrant
    brew cask install vagrant-manager
    ```
    
    ## Install Parallels plugin for Vagrant
    ```
    vagrant plugin install vagrant-parallels
    ```
    
    See http://parallels.github.io/vagrant-parallels/ for more details.
    
    
    #Shell
    
    Install custom .dotfiles
    ```bash
    git clone git@github.com:kevinelliott/.dotfiles.git ~/.dotfiles
    ~/.dotfiles/install.sh
    ```
    
    Update .bash_profile
    ```bash
    echo 'source ~/.dotfiles/base.sh' >> ~/.bash_profile
    ```
    
    # OS X Preferences
    
    ```bash
    
    #Set a blazingly fast keyboard repeat rate
    defaults write NSGlobalDomain KeyRepeat -int 0.02
    
    #Set a shorter Delay until key repeat
    defaults write NSGlobalDomain InitialKeyRepeat -int 12
    
    #Add a context menu item for showing the Web Inspector in web views
    defaults write NSGlobalDomain WebKitDeveloperExtras -bool true
    
    #Show the ~/Library folder
    chflags nohidden ~/Library
    
    #Store screenshots in subfolder on desktop
    mkdir ~/Desktop/Screenshots
    defaults write com.apple.screencapture location ~/Desktop/Screenshots
    ```
    
    Set hostname
    ------------
    `sudo scutil --set HostName SpaceX-Falcon-9`
    
    
    #Git
    
    Setup Github
    ------------
    ```bash
    ssh-keygen -t rsa -C "kevin@welikeinc.com"
    
    # Copy ssh key to github.com
    subl ~/.ssh/id_rsa.pub
    
    # Test connection
    ssh -T git@github.com
    
    # Set git config values
    git config --global user.name "Kevin Elliott"
    git config --global user.email "kevin@welikeinc.com"
    git config --global github.user kevinelliott
    git config --global github.token your_token_here
    
    git config --global core.editor "subl -w"
    git config --global color.ui true
    ```
    
    
    # Sublime Text
    
    Add Sublime Text CLI
    --------------------
    
    ```bash
    mkdir -p ~/bin && ln -s "/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl" ~/bin/subl
    ```
    
    Install Package Control
    -----------------------
    
    Run `Sublime Text 3` and access the console via the `CTRL + ``` shortcut or the `View > Show Console` menu.
    
    ```
    import urllib.request,os,hashlib; h = '7183a2d3e96f11eeadd761d777e62404' + 'e330c659d4bb41d3bdf022e94cab3cd0'; pf = 'Package Control.sublime-package'; ipp = sublime.installed_packages_path(); urllib.request.install_opener( urllib.request.build_opener( urllib.request.ProxyHandler()) ); by = urllib.request.urlopen( 'http://sublime.wbond.net/' + pf.replace(' ', '%20')).read(); dh = hashlib.sha256(by).hexdigest(); print('Error validating download (got %s instead of %s), please try manual install' % (dh, h)) if dh != h else open(os.path.join( ipp, pf), 'wb' ).write(by)
    ```
    
    See https://sublime.wbond.net/installation for more information. Their site has a note that this install code will change for each new release, so it would be good to check once in a while.
    
    Install Packages
    ----------------
    [BracketHighlighter](https://github.com/facelessuser/BracketHighlighter)
    [CoffeeScriptHaml](https://github.com/jisaacks/CoffeeScriptHaml)
    
    
    Install Soda Theme
    ----------------------
    ```bash
    git clone git://github.com/buymeasoda/soda-theme.git ~/Library/Application\ Support/Sublime\ Text\ 2/Packages/Theme\ -\ Soda
    ```
    
    Install Tomorrow Theme
    ----------------------
    ```bash
    git clone git://github.com/chriskempson/textmate-tomorrow-theme.git ~/Library/Application\ Support/Sublime\ Text\ 2/Packages/Color\ Scheme\ -\ Tomorrow
    ```
    
    Settings
    --------
    
    **Sublime Text > Preferences > Settings - User**
    
    ```json
    {
        "close_windows_when_empty": true,
        "color_scheme": "Packages/Color Scheme - Tomorrow/Tomorrow-Night-Eighties.tmTheme",
        "draw_indent_guides": false,
        "font_face": "Mensch",
        "font_size": 18,
        "highlight_modified_tabs": true,
        "show_tab_close_buttons": false,
        "tab_size": 2,
        "spell_check": false,
        "theme": "Soda Light.sublime-theme",
        "word_separators": "./\\()\"'-:,.;<>~!@#%^&*|+=[]{}`~?"
    }
    ```
    
    Key Bindings
    ------------
    
    ```json
    [
    	{ "keys": ["super+b"], "command": "expand_selection", "args": {"to": "brackets"} },
    	{ "keys": ["super+f"], "command": "show_panel", "args": {"panel": "replace"} },
    	{ "keys": ["super+alt+f"], "command": "show_panel", "args": {"panel": "find"} }
    ]
    ```
    
    
    Snippets
    --------
    ```bash
    git clone git@github.com:bytestudios/sublime-snippets.git "/Users/Joel/Library/Application Support/Sublime Text 2/Packages/Byte"
    ```
    
    
    ## Server
    
    
    ### Docker
    ```bash
    brew install docker boot2docker
    boot2docker init
    boot2docker up
    ```
    
    ### MySQL
    
    ```bash
    brew install mysql
    brew pin mysql
    ```
    
    ### MySQL Settings
    
    ```bash
    # Copy launch agent into place
    mkdir -p ~/Library/LaunchAgents && cp /usr/local/Cellar/mysql/VERSION/homebrew.mxcl.mysql.plist ~/Library/LaunchAgents/
    
    # Edit launch agent and set both keepalive and launch at startup to false
    vi ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
    
    # Inject launch agent
    launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
    
    # Set up databases to run as your user account
    unset TMPDIR && mysql_install_db --verbose --user=`whoami` --basedir="$(brew --prefix mysql)" --datadir=/usr/local/var/mysql --tmpdir=/tmp
    
    # Start mysql
    start mysql
    
    # Secure mysql
    /usr/local/Cellar/mysql/VERSION/bin/mysql_secure_installation
    ```
    
    
    ### PostgreSQL
    
    ```bash
    brew install postgres --no-ossp-uuid
    brew pin postgres
    ```
    
    ### PostgreSQL Settings
    
    ```bash
    # Initialize db if none exists already
    initdb /usr/local/var/postgres
    
    # Create launchctl script
    mkdir -p ~/Library/LaunchAgents
    cp /usr/local/Cellar/postgresql/VERSION/homebrew.mxcl.postgresql.plist ~/Library/LaunchAgents/
    
    # Edit launchctl script (set to not start automatically and keepalive false)
    subl ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
    
    # Inject launchctl script
    launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
    
    # Start PostgreSQL
    start pg
    ```
    
    ### Ruby Gems
    
    #### libv8 / therubyracer
    ```bash
    brew uninstall v8
    gem uninstall libv8
    brew install v8
    gem install therubyracer
    gem install libv8 -v 3.16.14.3 -- --with-system-v8
    ```
    
    #### nokogiri
    ```bash
    brew tap homebrew/dupes
    brew install libxml2 libxslt libiconv
    gem install nokogiri -- --with-iconv-dir=/usr/local/Cellar/libiconv/VERSION/
    ```
    
    #### capybara-webkit
    ```bash
    brew install -v https://raw.github.com/cliffrowley/homebrew/patched_qt/Library/Formula/qt.rb --HEAD --without-ssse3
    gem install capybara-webkit -v '0.9.0'
    ```
    
    ![aww yeah](http://i.imgur.com/AmFax.gif)
    
    

    public by FMXExpress modified Nov 13, 2014  9405  95  7  1

    Non Blocking Message Dialog For Delphi XE7 Firemonkey

    MessageDlg(‘Do you want to press yes or no?’, System.UITypes.TMsgDlgType.mtInformation,
      [System.UITypes.TMsgDlgBtn.mbYes, System.UITypes.TMsgDlgBtn.mbNo], 0,
        procedure(const AResult: TModalResult)
        begin
          case AResult of
            { Detect which button was pushed and show a different message }
            mrYes:
                begin
                // pressed yes
                end;
            mrNo:
                begin
                // pressed no
                end;
          end;
        end
      );
    // code here would get executed right away

    public by FMXExpress modified Nov 12, 2014  4501  20  6  1

    Decode GZIP Content From TRESTClient In Delphi XE7 Firemonkey

    RESTClient.AcceptEncoding := 'gzip, deflate';
    RESTClient.Execute;
    
    if RESTResponse.ContentEncoding=’gzip’ then
    DecodeGZIPContent(RESTResponse.RawBytes) // decode and do something with the content
    else
    RESTResponse.Content; // do something with the content
    
    function DecodeGZIPContent(RawBytes: System.TArray<System.Byte>): String;
    var
    MSI: TMemoryStream;
    MSO: TStringStream;
    begin
    MSI := TMemoryStream.Create;
    MSO := TStringStream.Create;
    MSI.WriteData(RawBytes,Length(RawBytes));
    MSI.Seek(0,0);
    // Zlib is a TIdCompressorZlib
    Zlib.DecompressGZipStream(MSI,MSO);
    MSI.DisposeOf;
    MSO.Seek(0,0);
    Result := MSO.DataString;
    MSO.Free;
    end;

    public by FMXExpress modified Nov 12, 2014  4910  2  7  1

    Process Strings Using A Parallel For Loop In Delphi XE7 Firemonkey

    TParallel.For(0,1000,
     procedure(I: Integer)
      begin
       TThread.Queue(TThread.CurrentThread,
        procedure
         begin
          Memo1.Lines.Append(I.ToString);
         end);
      end);

    public by javalonson modified Jun 14, 2016  2676  1  3  0

    PHPCS and PHPMD on OSX

    # Make a bin directory in your home folder, this will stop things being overwritten
    mkdir ~/bin
    cd ~/bin
     
    # Get the latest versions from git, make sure you have git installed
    git clone https://github.com/squizlabs/PHP_CodeSniffer.git phpcs
    git clone git://github.com/phpmd/phpmd.git
     
    # install composer into your bin folder
    curl -s http://getcomposer.org/installer | php
     
    # add composer, phpcs and phpmd to your path
    sudo ln -s ~/bin/phpcs/scripts/phpcs /usr/local/bin/phpcs
    sudo ln -s ~/bin/phpmd/src/bin/phpmd /usr/local/bin/phpmd
    sudo ln -s ~/bin/composer.phar /usr/local/bin/composer
     
    # configure phpmd
    cd ~/bin/phpmd
    composer install

    public by Barnabas Debreczeni modified Jul 12, 2015  1683  0  4  0

    cpp-ethereum build fails on OSX 10.9.5

    cpp-ethereum build fails on OSX 10.9.5: gistfile1.txt
    $ cmake .. -DGUI=1 -DJSCONSOLE=1 -DVMTRACE=1 -DNCURSES=1
    -- ctest path: /usr/local/bin/ctest
     - CryptoPP header: /usr/local/include/cryptopp
     - CryptoPP lib   : /usr/local/lib/libcryptopp.a
     - LevelDB header: /usr/local/include
     - LevelDB lib: /usr/local/lib/libleveldb.dylib
    -- Could NOT find rocksdb (missing:  ROCKSDB_INCLUDE_DIR ROCKSDB_LIBRARY)
     - v8 header: /usr/local/opt/v8-315/include
     - v8 lib   : /usr/local/opt/v8-315/lib/libv8.dylib
     - Jsoncpp header: /usr/local/include/jsoncpp
     - Jsoncpp lib   : /usr/local/lib/libjsoncpp.dylib
     - json-rpc-cpp header: /usr/local/include
     - json-rpc-cpp lib   : /usr/local/lib/libjsonrpccpp-common.dylib;/usr/local/lib/libjsonrpccpp-server.dylib;/usr/local/lib/libjsonrpccpp-client.dylib
     - microhttpd header: /usr/local/include
     - microhttpd lib   : /usr/local/lib/libmicrohttpd.dylib
     - microhttpd dll   :
     - readline header: /usr/include
     - readline lib   : /usr/lib/libreadline.dylib
     - miniupnpc header: /usr/local/include
     - miniupnpc lib   : /usr/local/lib/libminiupnpc.dylib
     - gmp header: /usr/local/include
     - gmp lib   : /usr/local/lib/libgmp.dylib
     - curl header: /usr/include
     - curl lib   : /usr/lib/libcurl.dylib
    -- Could NOT find cpuid (missing:  CPUID_INCLUDE_DIR CPUID_LIBRARY)
     - opencl header: /System/Library/Frameworks/OpenCL.framework
     - opencl lib   : /System/Library/Frameworks/OpenCL.framework
     - jsonrpcstub location    : /usr/local/bin/jsonrpcstub
     - macdeployqt path: /usr/local/opt/qt5/lib/cmake/Qt5Core/../../../bin/macdeployqt
     - appdmg location : ETH_APP_DMG-NOTFOUND
    -- Boost version: 1.58.0
    -- Found the following Boost libraries:
    --   thread
    --   date_time
    --   system
    --   regex
    --   chrono
    --   filesystem
    --   unit_test_framework
    --   program_options
     - boost header: /usr/local/include
     - boost lib   : /usr/local/lib/libboost_thread-mt.a;/usr/local/lib/libboost_date_time-mt.a;/usr/local/lib/libboost_system-mt.a;/usr/local/lib/libboost_regex-mt.a;/usr/local/lib/libboost_chrono-mt.a;/usr/local/lib/libboost_filesystem-mt.a;/usr/local/lib/libboost_unit_test_framework-mt.a;/usr/local/lib/libboost_program_options-mt.a
    ------------------------------------------------------------------------
    --                  CMake Version                            3.2.3
    -- CMAKE_BUILD_TYPE Build type                               Release
    -- TARGET_PLATFORM  Target platform                          Darwin
    -- BUNDLE           Build bundle                             none
    --------------------------------------------------------------- features
    --                  Chromium support                         1
    --                  Hardware identification support          FALSE
    --                  HTTP Request support                     TRUE
    -- VMTRACE          VM execution tracing                     ON
    -- PROFILING        Profiling support                        OFF
    -- NOBOOST          No BOOST macros in test functions        OFF
    -- FATDB            Full database exploring                  OFF
    -- JSONRPC          JSON-RPC support                         ON
    -- USENPM           Javascript source building               OFF
    -- ROCKSDB          Prefer rocksdb to leveldb                OFF
    ------------------------------------------------------------- components
    -- MINER            Build miner                              ON
    -- ETHKEY           Build wallet tools                       ON
    -- TOOLS            Build basic tools                        ON
    -- SOLIDITY         Build Solidity language components       ON
    -- SERPENT          Build Serpent language components        ON
    -- GUI              Build GUI components                     ON
    -- NCURSES          Build NCurses components                 ON
    -- TESTS            Build tests                              ON
    -- ETHASHCL         Build OpenCL components (experimental!)  OFF
    -- JSCONSOLE        Build with javascript console            ON
    -- EVMJIT           Build LLVM-based JIT EVM (experimental!) OFF
    ------------------------------------------------------------------------
    
    -- CXXFLAGS: -std=c++11 -Wall -Wno-unknown-pragmas -Wextra -DSHAREDLIB -fPIC
    -- test: ClientBase |  --eth_testfile=BlockTests/bcJS_API_Test --eth_threads=1; --eth_testfile=BlockTests/bcJS_API_Test --eth_threads=3; --eth_testfile=BlockTests/bcJS_API_Test --eth_threads=10; --eth_testfile=BlockTests/bcValidBlockTest --eth_threads=1; --eth_testfile=BlockTests/bcValidBlockTest --eth_threads=3; --eth_testfile=BlockTests/bcValidBlockTest --eth_threads=10
    -- test: JsonRpc |  --eth_testfile=BlockTests/bcJS_API_Test; --eth_testfile=BlockTests/bcValidBlockTest
    -- mix qmldir: -qmldir=/Users/keo/Code/OpenSource/Ethereum/cpp-ethereum/mix/qml
    -- Configuring done
    CMake Warning (dev):
      Policy CMP0042 is not set: MACOSX_RPATH is enabled by default.  Run "cmake
      --help-policy CMP0042" for policy details.  Use the cmake_policy command to
      set the policy and suppress this warning.
    
      MACOSX_RPATH is not specified for the following targets:
    
       ethash
       soljson
    
    This warning is for project developers.  Use -Wno-dev to suppress it.
    
    -- Generating done
    -- Build files have been written to: /Users/keo/Code/OpenSource/Ethereum/cpp-ethereum/build
    
    $ make -j2
    [  0%] Built target BuildInfo.h
    Scanning dependencies of target secp256k1
    [  1%] Building C object secp256k1/CMakeFiles/secp256k1.dir/secp256k1.c.o
    [  2%] Building CXX object libdevcore/CMakeFiles/devcore.dir/Common.cpp.o
    Linking C shared library libsecp256k1.dylib
    [  2%] Built target secp256k1
    Scanning dependencies of target scrypt
    [  2%] Building C object libscrypt/CMakeFiles/scrypt.dir/b64.c.o
    [  3%] Building C object libscrypt/CMakeFiles/scrypt.dir/crypto-mcf.c.o
    [  3%] Building C object libscrypt/CMakeFiles/scrypt.dir/crypto-scrypt-saltgen.c.o
    [  3%] Building C object libscrypt/CMakeFiles/scrypt.dir/crypto_scrypt-check.c.o
    [  3%] Building C object libscrypt/CMakeFiles/scrypt.dir/crypto_scrypt-hash.c.o
    [  4%] Building C object libscrypt/CMakeFiles/scrypt.dir/crypto_scrypt-hexconvert.c.o
    [  4%] Building C object libscrypt/CMakeFiles/scrypt.dir/crypto_scrypt-nosse.c.o
    [  4%] Building C object libscrypt/CMakeFiles/scrypt.dir/sha256.c.o
    [  4%] Building C object libscrypt/CMakeFiles/scrypt.dir/slowequals.c.o
    Linking C shared library libscrypt.dylib
    [  4%] Built target scrypt
    [  4%] Building CXX object libdevcore/CMakeFiles/devcore.dir/CommonData.cpp.o
    [  4%] Building CXX object libdevcore/CMakeFiles/devcore.dir/CommonIO.cpp.o
    [  4%] Building CXX object libdevcore/CMakeFiles/devcore.dir/CommonJS.cpp.o
    [  4%] Automatic moc for target sc
    [  4%] Built target sc_automoc
    [  5%] Building CXX object libdevcore/CMakeFiles/devcore.dir/FileSystem.cpp.o
    [  5%] Building CXX object libdevcore/CMakeFiles/devcore.dir/FixedHash.cpp.o
    [  5%] Building CXX object libdevcore/CMakeFiles/devcore.dir/Guards.cpp.o
    [  5%] Automatic moc for target ethash
    [  5%] Built target ethash_automoc
    [  6%] Building CXX object libdevcore/CMakeFiles/devcore.dir/Hash.cpp.o
    Scanning dependencies of target jsonrpcstub
    [  6%] Built target jsonrpcstub
    [  6%] Building CXX object libdevcore/CMakeFiles/devcore.dir/Log.cpp.o
    [  6%] Building CXX object libdevcore/CMakeFiles/devcore.dir/MemoryDB.cpp.o
    [  6%] Building CXX object libdevcore/CMakeFiles/devcore.dir/RangeMask.cpp.o
    [  6%] Generating JSEngineResources.hpp
    [  7%] Building CXX object libdevcore/CMakeFiles/devcore.dir/RLP.cpp.o
    Files "/Users/keo/Code/OpenSource/Ethereum/cpp-ethereum/build/libjsengine/JSEngineResources.hpp.tmp" to "/Users/keo/Code/OpenSource/Ethereum/cpp-ethereum/build/libjsengine/JSEngineResources.hpp" are different.
    Scanning dependencies of target jsengine
    [  7%] Building CXX object libjsengine/CMakeFiles/jsengine.dir/JSEngine.cpp.o
    [  7%] Building CXX object libjsengine/CMakeFiles/jsengine.dir/JSPrinter.cpp.o
    [  8%] Building CXX object libjsengine/CMakeFiles/jsengine.dir/JSV8Engine.cpp.o
    [  8%] Building CXX object libjsengine/CMakeFiles/jsengine.dir/JSV8Printer.cpp.o
    [  8%] Building CXX object libjsengine/CMakeFiles/jsengine.dir/JSV8RPC.cpp.o
    Linking CXX shared library libjsengine.dylib
    [  8%] Built target jsengine
    [  8%] Building CXX object libdevcore/CMakeFiles/devcore.dir/SHA3.cpp.o
    [  8%] Building CXX object libdevcore/CMakeFiles/devcore.dir/StructuredLogger.cpp.o
    [  8%] Building CXX object libdevcore/CMakeFiles/devcore.dir/TransientDirectory.cpp.o
    [  9%] Building CXX object libdevcore/CMakeFiles/devcore.dir/TrieCommon.cpp.o
    Scanning dependencies of target testeth_automoc
    [  9%] Automatic moc for target testeth
    [  9%] Built target testeth_automoc
    [  9%] Building CXX object libdevcore/CMakeFiles/devcore.dir/TrieDB.cpp.o
    [  9%] Building CXX object libdevcore/CMakeFiles/devcore.dir/TrieHash.cpp.o
    [ 10%] Building CXX object libdevcore/CMakeFiles/devcore.dir/Worker.cpp.o
    [ 12%] Automatic moc for target checkRandomStateTest
    [ 12%] Built target checkRandomStateTest_automoc
    [ 12%] Automatic moc for target checkRandomVMTest
    [ 12%] Built target checkRandomVMTest_automoc
    [ 12%] Automatic moc for target createRandomStateTest
    [ 12%] Built target createRandomStateTest_automoc
    [ 13%] Automatic moc for target createRandomTest
    [ 13%] Built target createRandomTest_automoc
    [ 13%] Automatic moc for target createRandomVMTest
    [ 13%] Built target createRandomVMTest_automoc
    [ 14%] Generating qrc_js.cpp
    Scanning dependencies of target jsqrc
    [ 14%] Building CXX object libjsqrc/CMakeFiles/jsqrc.dir/qrc_js.cpp.o
    Linking CXX static library libjsqrc.a
    [ 14%] Built target jsqrc
    [ 14%] Automatic moc for target AlethZero
    Generating moc_Connect.cpp
    Generating moc_DappLoader.cpp
    Linking CXX shared library libdevcore.dylib
    [ 14%] Built target devcore
    [ 14%] Automatic moc for target mix
    Generating moc_ClientModel.cpp
    Generating moc_Debugger.cpp
    Generating moc_Clipboard.cpp
    Generating moc_CodeModel.cpp
    Generating moc_DownloadView.cpp
    Generating moc_ExportState.cpp
    Generating moc_DebuggingStateWrapper.cpp
    Generating moc_MainWin.cpp
    Generating moc_FileIo.cpp
    Generating moc_MiningView.cpp
    Generating moc_OurWebThreeStubServer.cpp
    Generating moc_HttpServer.cpp
    Generating moc_InverseMouseArea.cpp
    Generating moc_MixApplication.cpp
    Generating moc_QBasicNodeDefinition.cpp
    Generating moc_QBigInt.cpp
    Generating moc_Transact.cpp
    Generating moc_QContractDefinition.cpp
    Generating moc_WebPage.cpp
    [ 14%] Built target AlethZero_automoc
    Scanning dependencies of target evmcore
    [ 15%] Building CXX object libevmcore/CMakeFiles/evmcore.dir/Instruction.cpp.o
    Generating moc_QEther.cpp
    [ 15%] Building CXX object libevmcore/CMakeFiles/evmcore.dir/Params.cpp.o
    Linking CXX shared library libevmcore.dylib
    [ 15%] Built target evmcore
    Generating moc_QFunctionDefinition.cpp
    Scanning dependencies of target devcrypto
    [ 15%] Building CXX object libdevcrypto/CMakeFiles/devcrypto.dir/AES.cpp.o
    [ 15%] Building CXX object libdevcrypto/CMakeFiles/devcrypto.dir/Common.cpp.o
    Generating moc_QVariableDeclaration.cpp
    [ 15%] Building CXX object libdevcrypto/CMakeFiles/devcrypto.dir/CryptoPP.cpp.o
    Generating moc_QVariableDefinition.cpp
    Generating moc_SortFilterProxyModel.cpp
    Generating moc_Web3Server.cpp
    [ 16%] Building CXX object libdevcrypto/CMakeFiles/devcrypto.dir/ECDHE.cpp.o
    [ 16%] Building CXX object libdevcrypto/CMakeFiles/devcrypto.dir/OverlayDB.cpp.o
    [ 16%] Built target mix_automoc
    [ 16%] Building CXX object libdevcrypto/CMakeFiles/devcrypto.dir/SecretStore.cpp.o
    Scanning dependencies of target ethash
    [ 17%] Building C object libethash/CMakeFiles/ethash.dir/io.c.o
    [ 17%] Building C object libethash/CMakeFiles/ethash.dir/internal.c.o
    [ 17%] Building C object libethash/CMakeFiles/ethash.dir/io_posix.c.o
    [ 17%] Building CXX object libethash/CMakeFiles/ethash.dir/sha3_cryptopp.cpp.o
    [ 18%] Building CXX object libethash/CMakeFiles/ethash.dir/ethash_automoc.cpp.o
    Linking CXX shared library libethash.dylib
    [ 18%] Built target ethash
    Scanning dependencies of target jsconsole
    [ 18%] Building CXX object libjsconsole/CMakeFiles/jsconsole.dir/CURLRequest.cpp.o
    [ 19%] Building CXX object libjsconsole/CMakeFiles/jsconsole.dir/JSConsole.cpp.o
    Linking CXX shared library libdevcrypto.dylib
    [ 19%] Built target devcrypto
    [ 19%] Building CXX object libjsconsole/CMakeFiles/jsconsole.dir/JSLocalConsole.cpp.o
    [ 19%] Building CXX object libjsconsole/CMakeFiles/jsconsole.dir/JSRemoteConsole.cpp.o
    [ 19%] Building CXX object libjsconsole/CMakeFiles/jsconsole.dir/JSV8Connector.cpp.o
    [ 19%] Generating qrc_natspec.cpp
    Scanning dependencies of target natspec
    [ 20%] Building CXX object libjsconsole/CMakeFiles/jsconsole.dir/JSV8RemoteConnector.cpp.o
    [ 20%] Building CXX object libnatspec/CMakeFiles/natspec.dir/NatspecExpressionEvaluator.cpp.o
    Linking CXX shared library libjsconsole.dylib
    [ 20%] Built target jsconsole
    Scanning dependencies of target rlp
    [ 20%] Building CXX object rlp/CMakeFiles/rlp.dir/main.cpp.o
    [ 20%] Building CXX object libnatspec/CMakeFiles/natspec.dir/qrc_natspec.cpp.o
    Linking CXX shared library libnatspec.dylib
    [ 20%] Built target natspec
    Scanning dependencies of target evmasm
    [ 20%] Building CXX object libevmasm/CMakeFiles/evmasm.dir/Assembly.cpp.o
    Linking CXX executable rlp
    [ 20%] Built target rlp
    [ 20%] Building CXX object libevmasm/CMakeFiles/evmasm.dir/AssemblyItem.cpp.o
    [ 20%] Building CXX object libevmasm/CMakeFiles/evmasm.dir/BlockDeduplicator.cpp.o
    [ 21%] Building CXX object libevmasm/CMakeFiles/evmasm.dir/CommonSubexpressionEliminator.cpp.o
    Scanning dependencies of target ethcore
    [ 23%] Building CXX object libethcore/CMakeFiles/ethcore.dir/ABI.cpp.o
    [ 23%] Building CXX object libevmasm/CMakeFiles/evmasm.dir/ConstantOptimiser.cpp.o
    [ 23%] Building CXX object libethcore/CMakeFiles/ethcore.dir/BlockInfo.cpp.o
    [ 23%] Building CXX object libevmasm/CMakeFiles/evmasm.dir/ControlFlowGraph.cpp.o
    [ 23%] Building CXX object libethcore/CMakeFiles/ethcore.dir/Common.cpp.o
    [ 23%] Building CXX object libevmasm/CMakeFiles/evmasm.dir/ExpressionClasses.cpp.o
    [ 23%] Building CXX object libethcore/CMakeFiles/ethcore.dir/CommonJS.cpp.o
    [ 24%] Building CXX object libethcore/CMakeFiles/ethcore.dir/Ethash.cpp.o
    [ 24%] Building CXX object libethcore/CMakeFiles/ethcore.dir/EthashAux.cpp.o
    [ 24%] Building CXX object libethcore/CMakeFiles/ethcore.dir/ICAP.cpp.o
    [ 24%] Building CXX object libethcore/CMakeFiles/ethcore.dir/KeyManager.cpp.o
    [ 25%] Building CXX object libevmasm/CMakeFiles/evmasm.dir/GasMeter.cpp.o
    [ 26%] Building CXX object libethcore/CMakeFiles/ethcore.dir/Miner.cpp.o
    [ 26%] Building CXX object libethcore/CMakeFiles/ethcore.dir/Params.cpp.o
    [ 26%] Building CXX object libevmasm/CMakeFiles/evmasm.dir/KnownState.cpp.o
    [ 26%] Building CXX object libethcore/CMakeFiles/ethcore.dir/ProofOfWork.cpp.o
    [ 27%] Building CXX object libethcore/CMakeFiles/ethcore.dir/Transaction.cpp.o
    [ 27%] Building CXX object libevmasm/CMakeFiles/evmasm.dir/PathGasMeter.cpp.o
    [ 27%] Building CXX object libevmasm/CMakeFiles/evmasm.dir/SemanticInformation.cpp.o
    Linking CXX shared library libethcore.dylib
    [ 27%] Built target ethcore
    Scanning dependencies of target p2p
    [ 28%] Building CXX object libp2p/CMakeFiles/p2p.dir/Capability.cpp.o
    Linking CXX shared library libevmasm.dylib
    [ 28%] Built target evmasm
    Scanning dependencies of target ethconsole
    [ 28%] Building CXX object ethconsole/CMakeFiles/ethconsole.dir/main.cpp.o
    Linking CXX executable ethconsole
    [ 28%] Built target ethconsole
    [ 28%] Building CXX object libp2p/CMakeFiles/p2p.dir/Common.cpp.o
    [ 28%] Building CXX object libp2p/CMakeFiles/p2p.dir/Host.cpp.o
    Scanning dependencies of target ethminer
    [ 29%] Building CXX object ethminer/CMakeFiles/ethminer.dir/main.cpp.o
    Linking CXX executable ethminer
    [ 29%] Built target ethminer
    [ 29%] Building CXX object libp2p/CMakeFiles/p2p.dir/HostCapability.cpp.o
    [ 30%] Building CXX object libp2p/CMakeFiles/p2p.dir/Network.cpp.o
    [ 30%] Building CXX object libp2p/CMakeFiles/p2p.dir/NodeTable.cpp.o
    [ 30%] Building CXX object libp2p/CMakeFiles/p2p.dir/Peer.cpp.o
    [ 31%] Building CXX object libp2p/CMakeFiles/p2p.dir/RLPXFrameCoder.cpp.o
    [ 31%] Building CXX object libp2p/CMakeFiles/p2p.dir/RLPxHandshake.cpp.o
    [ 31%] Building CXX object libp2p/CMakeFiles/p2p.dir/RLPXSocket.cpp.o
    Scanning dependencies of target ethkey
    [ 31%] Building CXX object ethkey/CMakeFiles/ethkey.dir/main.cpp.o
    [ 31%] Building CXX object libp2p/CMakeFiles/p2p.dir/Session.cpp.o
    Linking CXX executable ethkey
    [ 31%] Built target ethkey
    [ 32%] Building CXX object libp2p/CMakeFiles/p2p.dir/UDP.cpp.o
    [ 32%] Building CXX object libp2p/CMakeFiles/p2p.dir/UPnP.cpp.o
    Scanning dependencies of target lll
    [ 32%] Building CXX object liblll/CMakeFiles/lll.dir/CodeFragment.cpp.o
    Linking CXX shared library libp2p.dylib
    [ 32%] Built target p2p
    [ 32%] Building CXX object liblll/CMakeFiles/lll.dir/Compiler.cpp.o
    Scanning dependencies of target solidity
    [ 34%] [ 34%] Building CXX object libsolidity/CMakeFiles/solidity.dir/ArrayUtils.cpp.o
    Building CXX object liblll/CMakeFiles/lll.dir/CompilerState.cpp.o
    [ 34%] Building CXX object libsolidity/CMakeFiles/solidity.dir/AST.cpp.o
    [ 34%] Building CXX object liblll/CMakeFiles/lll.dir/Parser.cpp.o
    /Users/keo/Code/OpenSource/Ethereum/cpp-ethereum/libsolidity/AST.cpp:478:14: error: chosen constructor is explicit in copy-initialization
            check(this, {});
                        ^~
    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/set:428:14: note: constructor declared here
        explicit set(const value_compare& __comp = value_compare())
                 ^
    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/functional:1504:32: note: passing argument to parameter here
        _Rp operator()(_ArgTypes...) const;
                                   ^
    1 error generated.
    make[2]: *** [libsolidity/CMakeFiles/solidity.dir/AST.cpp.o] Error 1
    make[1]: *** [libsolidity/CMakeFiles/solidity.dir/all] Error 2
    make[1]: *** Waiting for unfinished jobs....
    Linking CXX shared library liblll.dylib
    [ 34%] Built target lll
    make: *** [all] Error 2
    
    

    public by Warren Gray modified Jul 22, 2015  1234  3  4  0

    Mac OSX Bash Profile

    Mac OSX Bash Profile: .bash_profile
    #  ---------------------------------------------------------------------------
    #
    #  Description:  This file holds all my BASH configurations and aliases
    #
    #  Sections:
    #  1.   Environment Configuration
    #  2.   Make Terminal Better (remapping defaults and adding functionality)
    #  3.   File and Folder Management
    #  4.   Searching
    #  5.   Process Management
    #  6.   Networking
    #  7.   System Operations & Information
    #  8.   Web Development
    #  9.   Reminders & Notes
    #
    #  ---------------------------------------------------------------------------
    
    #   -------------------------------
    #   1.  ENVIRONMENT CONFIGURATION
    #   -------------------------------
    
    #   Change Prompt
    #   ------------------------------------------------------------
        export PS1="________________________________________________________________________________\n| \w @ \h (\u) \n| => "
        export PS2="| => "
    
    #   Set Paths
    #   ------------------------------------------------------------
        export PATH="$PATH:/usr/local/bin/"
        export PATH="/usr/local/git/bin:/sw/bin/:/usr/local/bin:/usr/local/:/usr/local/sbin:/usr/local/mysql/bin:$PATH"
    
    #   Set Default Editor (change 'Nano' to the editor of your choice)
    #   ------------------------------------------------------------
        export EDITOR=/usr/bin/nano
    
    #   Set default blocksize for ls, df, du
    #   from this: http://hints.macworld.com/comment.php?mode=view&cid=24491
    #   ------------------------------------------------------------
        export BLOCKSIZE=1k
    
    #   Add color to terminal
    #   (this is all commented out as I use Mac Terminal Profiles)
    #   from http://osxdaily.com/2012/02/21/add-color-to-the-terminal-in-mac-os-x/
    #   ------------------------------------------------------------
    #   export CLICOLOR=1
    #   export LSCOLORS=ExFxBxDxCxegedabagacad
    
    
    #   -----------------------------
    #   2.  MAKE TERMINAL BETTER
    #   -----------------------------
    
    alias cp='cp -iv'                           # Preferred 'cp' implementation
    alias mv='mv -iv'                           # Preferred 'mv' implementation
    alias mkdir='mkdir -pv'                     # Preferred 'mkdir' implementation
    alias ll='ls -FGlAhp'                       # Preferred 'ls' implementation
    alias less='less -FSRXc'                    # Preferred 'less' implementation
    cd() { builtin cd "$@"; ll; }               # Always list directory contents upon 'cd'
    alias cd..='cd ../'                         # Go back 1 directory level (for fast typers)
    alias ..='cd ../'                           # Go back 1 directory level
    alias ...='cd ../../'                       # Go back 2 directory levels
    alias .3='cd ../../../'                     # Go back 3 directory levels
    alias .4='cd ../../../../'                  # Go back 4 directory levels
    alias .5='cd ../../../../../'               # Go back 5 directory levels
    alias .6='cd ../../../../../../'            # Go back 6 directory levels
    alias edit='subl'                           # edit:         Opens any file in sublime editor
    alias f='open -a Finder ./'                 # f:            Opens current directory in MacOS Finder
    alias ~="cd ~"                              # ~:            Go Home
    alias c='clear'                             # c:            Clear terminal display
    alias which='type -all'                     # which:        Find executables
    alias path='echo -e ${PATH//:/\\n}'         # path:         Echo all executable Paths
    alias show_options='shopt'                  # Show_options: display bash options settings
    alias fix_stty='stty sane'                  # fix_stty:     Restore terminal settings when screwed up
    alias cic='set completion-ignore-case On'   # cic:          Make tab-completion case-insensitive
    mcd () { mkdir -p "$1" && cd "$1"; }        # mcd:          Makes new Dir and jumps inside
    trash () { command mv "$@" ~/.Trash ; }     # trash:        Moves a file to the MacOS trash
    ql () { qlmanage -p "$*" >& /dev/null; }    # ql:           Opens any file in MacOS Quicklook Preview
    alias DT='tee ~/Desktop/terminalOut.txt'    # DT:           Pipe content to file on MacOS Desktop
    
    #   lr:  Full Recursive Directory Listing
    #   ------------------------------------------
    alias lr='ls -R | grep ":$" | sed -e '\''s/:$//'\'' -e '\''s/[^-][^\/]*\//--/g'\'' -e '\''s/^/   /'\'' -e '\''s/-/|/'\'' | less'
    
    #   mans:   Search manpage given in agument '1' for term given in argument '2' (case insensitive)
    #           displays paginated result with colored search terms and two lines surrounding each hit.             Example: mans mplayer codec
    #   --------------------------------------------------------------------
        mans () {
            man $1 | grep -iC2 --color=always $2 | less
        }
    
    #   showa: to remind yourself of an alias (given some part of it)
    #   ------------------------------------------------------------
        showa () { /usr/bin/grep --color=always -i -a1 $@ ~/Library/init/bash/aliases.bash | grep -v '^\s*$' | less -FSRXc ; }
    
    
    #   -------------------------------
    #   3.  FILE AND FOLDER MANAGEMENT
    #   -------------------------------
    
    zipf () { zip -r "$1".zip "$1" ; }          # zipf:         To create a ZIP archive of a folder
    alias numFiles='echo $(ls -1 | wc -l)'      # numFiles:     Count of non-hidden files in current dir
    alias make1mb='mkfile 1m ./1MB.dat'         # make1mb:      Creates a file of 1mb size (all zeros)
    alias make5mb='mkfile 5m ./5MB.dat'         # make5mb:      Creates a file of 5mb size (all zeros)
    alias make10mb='mkfile 10m ./10MB.dat'      # make10mb:     Creates a file of 10mb size (all zeros)
    
    #   cdf:  'Cd's to frontmost window of MacOS Finder
    #   ------------------------------------------------------
        cdf () {
            currFolderPath=$( /usr/bin/osascript <<EOT
                tell application "Finder"
                    try
                set currFolder to (folder of the front window as alias)
                    on error
                set currFolder to (path to desktop folder as alias)
                    end try
                    POSIX path of currFolder
                end tell
    EOT
            )
            echo "cd to \"$currFolderPath\""
            cd "$currFolderPath"
        }
    
    #   extract:  Extract most know archives with one command
    #   ---------------------------------------------------------
        extract () {
            if [ -f $1 ] ; then
              case $1 in
                *.tar.bz2)   tar xjf $1     ;;
                *.tar.gz)    tar xzf $1     ;;
                *.bz2)       bunzip2 $1     ;;
                *.rar)       unrar e $1     ;;
                *.gz)        gunzip $1      ;;
                *.tar)       tar xf $1      ;;
                *.tbz2)      tar xjf $1     ;;
                *.tgz)       tar xzf $1     ;;
                *.zip)       unzip $1       ;;
                *.Z)         uncompress $1  ;;
                *.7z)        7z x $1        ;;
                *)     echo "'$1' cannot be extracted via extract()" ;;
                 esac
             else
                 echo "'$1' is not a valid file"
             fi
        }
    
    
    #   ---------------------------
    #   4.  SEARCHING
    #   ---------------------------
    
    alias qfind="find . -name "                 # qfind:    Quickly search for file
    ff () { /usr/bin/find . -name "$@" ; }      # ff:       Find file under the current directory
    ffs () { /usr/bin/find . -name "$@"'*' ; }  # ffs:      Find file whose name starts with a given string
    ffe () { /usr/bin/find . -name '*'"$@" ; }  # ffe:      Find file whose name ends with a given string
    
    #   spotlight: Search for a file using MacOS Spotlight's metadata
    #   -----------------------------------------------------------
        spotlight () { mdfind "kMDItemDisplayName == '$@'wc"; }
    
    
    #   ---------------------------
    #   5.  PROCESS MANAGEMENT
    #   ---------------------------
    
    #   findPid: find out the pid of a specified process
    #   -----------------------------------------------------
    #       Note that the command name can be specified via a regex
    #       E.g. findPid '/d$/' finds pids of all processes with names ending in 'd'
    #       Without the 'sudo' it will only find processes of the current user
    #   -----------------------------------------------------
        findPid () { lsof -t -c "$@" ; }
    
    #   memHogsTop, memHogsPs:  Find memory hogs
    #   -----------------------------------------------------
        alias memHogsTop='top -l 1 -o rsize | head -20'
        alias memHogsPs='ps wwaxm -o pid,stat,vsize,rss,time,command | head -10'
    
    #   cpuHogs:  Find CPU hogs
    #   -----------------------------------------------------
        alias cpu_hogs='ps wwaxr -o pid,stat,%cpu,time,command | head -10'
    
    #   topForever:  Continual 'top' listing (every 10 seconds)
    #   -----------------------------------------------------
        alias topForever='top -l 9999999 -s 10 -o cpu'
    
    #   ttop:  Recommended 'top' invocation to minimize resources
    #   ------------------------------------------------------------
    #       Taken from this macosxhints article
    #       http://www.macosxhints.com/article.php?story=20060816123853639
    #   ------------------------------------------------------------
        alias ttop="top -R -F -s 10 -o rsize"
    
    #   my_ps: List processes owned by my user:
    #   ------------------------------------------------------------
        my_ps() { ps $@ -u $USER -o pid,%cpu,%mem,start,time,bsdtime,command ; }
    
    
    #   ---------------------------
    #   6.  NETWORKING
    #   ---------------------------
    
    alias myip='curl ip.appspot.com'                    # myip:         Public facing IP Address
    alias netCons='lsof -i'                             # netCons:      Show all open TCP/IP sockets
    alias flushDNS='dscacheutil -flushcache'            # flushDNS:     Flush out the DNS Cache
    alias lsock='sudo /usr/sbin/lsof -i -P'             # lsock:        Display open sockets
    alias lsockU='sudo /usr/sbin/lsof -nP | grep UDP'   # lsockU:       Display only open UDP sockets
    alias lsockT='sudo /usr/sbin/lsof -nP | grep TCP'   # lsockT:       Display only open TCP sockets
    alias ipInfo0='ipconfig getpacket en0'              # ipInfo0:      Get info on connections for en0
    alias ipInfo1='ipconfig getpacket en1'              # ipInfo1:      Get info on connections for en1
    alias openPorts='sudo lsof -i | grep LISTEN'        # openPorts:    All listening connections
    alias showBlocked='sudo ipfw list'                  # showBlocked:  All ipfw rules inc/ blocked IPs
    
    #   ii:  display useful host related informaton
    #   -------------------------------------------------------------------
        ii() {
            echo -e "\nYou are logged on ${RED}$HOST"
            echo -e "\nAdditionnal information:$NC " ; uname -a
            echo -e "\n${RED}Users logged on:$NC " ; w -h
            echo -e "\n${RED}Current date :$NC " ; date
            echo -e "\n${RED}Machine stats :$NC " ; uptime
            echo -e "\n${RED}Current network location :$NC " ; scselect
            echo -e "\n${RED}Public facing IP Address :$NC " ;myip
            #echo -e "\n${RED}DNS Configuration:$NC " ; scutil --dns
            echo
        }
    
    
    #   ---------------------------------------
    #   7.  SYSTEMS OPERATIONS & INFORMATION
    #   ---------------------------------------
    
    alias mountReadWrite='/sbin/mount -uw /'    # mountReadWrite:   For use when booted into single-user
    
    #   cleanupDS:  Recursively delete .DS_Store files
    #   -------------------------------------------------------------------
        alias cleanupDS="find . -type f -name '*.DS_Store' -ls -delete"
    
    #   finderShowHidden:   Show hidden files in Finder
    #   finderHideHidden:   Hide hidden files in Finder
    #   -------------------------------------------------------------------
        alias finderShowHidden='defaults write com.apple.finder ShowAllFiles TRUE'
        alias finderHideHidden='defaults write com.apple.finder ShowAllFiles FALSE'
    
    #   cleanupLS:  Clean up LaunchServices to remove duplicates in the "Open With" menu
    #   -----------------------------------------------------------------------------------
        alias cleanupLS="/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister -kill -r -domain local -domain system -domain user && killall Finder"
    
    #    screensaverDesktop: Run a screensaver on the Desktop
    #   -----------------------------------------------------------------------------------
        alias screensaverDesktop='/System/Library/Frameworks/ScreenSaver.framework/Resources/ScreenSaverEngine.app/Contents/MacOS/ScreenSaverEngine -background'
    
    #   ---------------------------------------
    #   8.  WEB DEVELOPMENT
    #   ---------------------------------------
    
    alias apacheEdit='sudo edit /etc/httpd/httpd.conf'      # apacheEdit:       Edit httpd.conf
    alias apacheRestart='sudo apachectl graceful'           # apacheRestart:    Restart Apache
    alias editHosts='sudo edit /etc/hosts'                  # editHosts:        Edit /etc/hosts file
    alias herr='tail /var/log/httpd/error_log'              # herr:             Tails HTTP error logs
    alias apacheLogs="less +F /var/log/apache2/error_log"   # Apachelogs:   Shows apache error logs
    httpHeaders () { /usr/bin/curl -I -L $@ ; }             # httpHeaders:      Grabs headers from web page
    
    #   httpDebug:  Download a web page and show info on what took time
    #   -------------------------------------------------------------------
        httpDebug () { /usr/bin/curl $@ -o /dev/null -w "dns: %{time_namelookup} connect: %{time_connect} pretransfer: %{time_pretransfer} starttransfer: %{time_starttransfer} total: %{time_total}\n" ; }
    
    
    #   ---------------------------------------
    #   9.  REMINDERS & NOTES
    #   ---------------------------------------
    
    #   remove_disk: spin down unneeded disk
    #   ---------------------------------------
    #   diskutil eject /dev/disk1s3
    
    #   to change the password on an encrypted disk image:
    #   ---------------------------------------
    #   hdiutil chpass /path/to/the/diskimage
    
    #   to mount a read-only disk image as read-write:
    #   ---------------------------------------
    #   hdiutil attach example.dmg -shadow /tmp/example.shadow -noverify
    
    #   mounting a removable drive (of type msdos or hfs)
    #   ---------------------------------------
    #   mkdir /Volumes/Foo
    #   ls /dev/disk*   to find out the device to use in the mount command)
    #   mount -t msdos /dev/disk1s1 /Volumes/Foo
    #   mount -t hfs /dev/disk1s1 /Volumes/Foo
    
    #   to create a file of a given size: /usr/sbin/mkfile or /usr/bin/hdiutil
    #   ---------------------------------------
    #   e.g.: mkfile 10m 10MB.dat
    #   e.g.: hdiutil create -size 10m 10MB.dmg
    #   the above create files that are almost all zeros - if random bytes are desired
    #   then use: ~/Dev/Perl/randBytes 1048576 > 10MB.dat
    
    

    public by canering modified Sep 29, 2016  663  4  3  0

    Mac OSX Bash Profile

    Mac OSX Bash Profile: .bash_profile
    #  ---------------------------------------------------------------------------
    #
    #  Description:  This file holds all my BASH configurations and aliases
    #
    #  Sections:
    #  1.   Environment Configuration
    #  2.   Make Terminal Better (remapping defaults and adding functionality)
    #  3.   File and Folder Management
    #  4.   Searching
    #  5.   Process Management
    #  6.   Networking
    #  7.   System Operations & Information
    #  8.   Web Development
    #  9.   Reminders & Notes
    #
    #  ---------------------------------------------------------------------------
    
    #   -------------------------------
    #   1.  ENVIRONMENT CONFIGURATION
    #   -------------------------------
    
    #   Change Prompt
    #   ------------------------------------------------------------
        export PS1="________________________________________________________________________________\n| \w @ \h (\u) \n| => "
        export PS2="| => "
    
    #   Set Paths
    #   ------------------------------------------------------------
        export PATH="$PATH:/usr/local/bin/"
        export PATH="/usr/local/git/bin:/sw/bin/:/usr/local/bin:/usr/local/:/usr/local/sbin:/usr/local/mysql/bin:$PATH"
    
    #   Set Default Editor (change 'Nano' to the editor of your choice)
    #   ------------------------------------------------------------
        export EDITOR=/usr/bin/nano
    
    #   Set default blocksize for ls, df, du
    #   from this: http://hints.macworld.com/comment.php?mode=view&cid=24491
    #   ------------------------------------------------------------
        export BLOCKSIZE=1k
    
    #   Add color to terminal
    #   (this is all commented out as I use Mac Terminal Profiles)
    #   from http://osxdaily.com/2012/02/21/add-color-to-the-terminal-in-mac-os-x/
    #   ------------------------------------------------------------
    #   export CLICOLOR=1
    #   export LSCOLORS=ExFxBxDxCxegedabagacad
    
    
    #   -----------------------------
    #   2.  MAKE TERMINAL BETTER
    #   -----------------------------
    
    alias cp='cp -iv'                           # Preferred 'cp' implementation
    alias mv='mv -iv'                           # Preferred 'mv' implementation
    alias mkdir='mkdir -pv'                     # Preferred 'mkdir' implementation
    alias ll='ls -FGlAhp'                       # Preferred 'ls' implementation
    alias less='less -FSRXc'                    # Preferred 'less' implementation
    cd() { builtin cd "$@"; ll; }               # Always list directory contents upon 'cd'
    alias cd..='cd ../'                         # Go back 1 directory level (for fast typers)
    alias ..='cd ../'                           # Go back 1 directory level
    alias ...='cd ../../'                       # Go back 2 directory levels
    alias .3='cd ../../../'                     # Go back 3 directory levels
    alias .4='cd ../../../../'                  # Go back 4 directory levels
    alias .5='cd ../../../../../'               # Go back 5 directory levels
    alias .6='cd ../../../../../../'            # Go back 6 directory levels
    alias edit='subl'                           # edit:         Opens any file in sublime editor
    alias f='open -a Finder ./'                 # f:            Opens current directory in MacOS Finder
    alias ~="cd ~"                              # ~:            Go Home
    alias c='clear'                             # c:            Clear terminal display
    alias which='type -all'                     # which:        Find executables
    alias path='echo -e ${PATH//:/\\n}'         # path:         Echo all executable Paths
    alias show_options='shopt'                  # Show_options: display bash options settings
    alias fix_stty='stty sane'                  # fix_stty:     Restore terminal settings when screwed up
    alias cic='set completion-ignore-case On'   # cic:          Make tab-completion case-insensitive
    mcd () { mkdir -p "$1" && cd "$1"; }        # mcd:          Makes new Dir and jumps inside
    trash () { command mv "$@" ~/.Trash ; }     # trash:        Moves a file to the MacOS trash
    ql () { qlmanage -p "$*" >& /dev/null; }    # ql:           Opens any file in MacOS Quicklook Preview
    alias DT='tee ~/Desktop/terminalOut.txt'    # DT:           Pipe content to file on MacOS Desktop
    
    #   lr:  Full Recursive Directory Listing
    #   ------------------------------------------
    alias lr='ls -R | grep ":$" | sed -e '\''s/:$//'\'' -e '\''s/[^-][^\/]*\//--/g'\'' -e '\''s/^/   /'\'' -e '\''s/-/|/'\'' | less'
    
    #   mans:   Search manpage given in agument '1' for term given in argument '2' (case insensitive)
    #           displays paginated result with colored search terms and two lines surrounding each hit.             Example: mans mplayer codec
    #   --------------------------------------------------------------------
        mans () {
            man $1 | grep -iC2 --color=always $2 | less
        }
    
    #   showa: to remind yourself of an alias (given some part of it)
    #   ------------------------------------------------------------
        showa () { /usr/bin/grep --color=always -i -a1 $@ ~/Library/init/bash/aliases.bash | grep -v '^\s*$' | less -FSRXc ; }
    
    
    #   -------------------------------
    #   3.  FILE AND FOLDER MANAGEMENT
    #   -------------------------------
    
    zipf () { zip -r "$1".zip "$1" ; }          # zipf:         To create a ZIP archive of a folder
    alias numFiles='echo $(ls -1 | wc -l)'      # numFiles:     Count of non-hidden files in current dir
    alias make1mb='mkfile 1m ./1MB.dat'         # make1mb:      Creates a file of 1mb size (all zeros)
    alias make5mb='mkfile 5m ./5MB.dat'         # make5mb:      Creates a file of 5mb size (all zeros)
    alias make10mb='mkfile 10m ./10MB.dat'      # make10mb:     Creates a file of 10mb size (all zeros)
    
    #   cdf:  'Cd's to frontmost window of MacOS Finder
    #   ------------------------------------------------------
        cdf () {
            currFolderPath=$( /usr/bin/osascript <<EOT
                tell application "Finder"
                    try
                set currFolder to (folder of the front window as alias)
                    on error
                set currFolder to (path to desktop folder as alias)
                    end try
                    POSIX path of currFolder
                end tell
    EOT
            )
            echo "cd to \"$currFolderPath\""
            cd "$currFolderPath"
        }
    
    #   extract:  Extract most know archives with one command
    #   ---------------------------------------------------------
        extract () {
            if [ -f $1 ] ; then
              case $1 in
                *.tar.bz2)   tar xjf $1     ;;
                *.tar.gz)    tar xzf $1     ;;
                *.bz2)       bunzip2 $1     ;;
                *.rar)       unrar e $1     ;;
                *.gz)        gunzip $1      ;;
                *.tar)       tar xf $1      ;;
                *.tbz2)      tar xjf $1     ;;
                *.tgz)       tar xzf $1     ;;
                *.zip)       unzip $1       ;;
                *.Z)         uncompress $1  ;;
                *.7z)        7z x $1        ;;
                *)     echo "'$1' cannot be extracted via extract()" ;;
                 esac
             else
                 echo "'$1' is not a valid file"
             fi
        }
    
    
    #   ---------------------------
    #   4.  SEARCHING
    #   ---------------------------
    
    alias qfind="find . -name "                 # qfind:    Quickly search for file
    ff () { /usr/bin/find . -name "$@" ; }      # ff:       Find file under the current directory
    ffs () { /usr/bin/find . -name "$@"'*' ; }  # ffs:      Find file whose name starts with a given string
    ffe () { /usr/bin/find . -name '*'"$@" ; }  # ffe:      Find file whose name ends with a given string
    
    #   spotlight: Search for a file using MacOS Spotlight's metadata
    #   -----------------------------------------------------------
        spotlight () { mdfind "kMDItemDisplayName == '$@'wc"; }
    
    
    #   ---------------------------
    #   5.  PROCESS MANAGEMENT
    #   ---------------------------
    
    #   findPid: find out the pid of a specified process
    #   -----------------------------------------------------
    #       Note that the command name can be specified via a regex
    #       E.g. findPid '/d$/' finds pids of all processes with names ending in 'd'
    #       Without the 'sudo' it will only find processes of the current user
    #   -----------------------------------------------------
        findPid () { lsof -t -c "$@" ; }
    
    #   memHogsTop, memHogsPs:  Find memory hogs
    #   -----------------------------------------------------
        alias memHogsTop='top -l 1 -o rsize | head -20'
        alias memHogsPs='ps wwaxm -o pid,stat,vsize,rss,time,command | head -10'
    
    #   cpuHogs:  Find CPU hogs
    #   -----------------------------------------------------
        alias cpu_hogs='ps wwaxr -o pid,stat,%cpu,time,command | head -10'
    
    #   topForever:  Continual 'top' listing (every 10 seconds)
    #   -----------------------------------------------------
        alias topForever='top -l 9999999 -s 10 -o cpu'
    
    #   ttop:  Recommended 'top' invocation to minimize resources
    #   ------------------------------------------------------------
    #       Taken from this macosxhints article
    #       http://www.macosxhints.com/article.php?story=20060816123853639
    #   ------------------------------------------------------------
        alias ttop="top -R -F -s 10 -o rsize"
    
    #   my_ps: List processes owned by my user:
    #   ------------------------------------------------------------
        my_ps() { ps $@ -u $USER -o pid,%cpu,%mem,start,time,bsdtime,command ; }
    
    
    #   ---------------------------
    #   6.  NETWORKING
    #   ---------------------------
    
    alias myip='curl ip.appspot.com'                    # myip:         Public facing IP Address
    alias netCons='lsof -i'                             # netCons:      Show all open TCP/IP sockets
    alias flushDNS='dscacheutil -flushcache'            # flushDNS:     Flush out the DNS Cache
    alias lsock='sudo /usr/sbin/lsof -i -P'             # lsock:        Display open sockets
    alias lsockU='sudo /usr/sbin/lsof -nP | grep UDP'   # lsockU:       Display only open UDP sockets
    alias lsockT='sudo /usr/sbin/lsof -nP | grep TCP'   # lsockT:       Display only open TCP sockets
    alias ipInfo0='ipconfig getpacket en0'              # ipInfo0:      Get info on connections for en0
    alias ipInfo1='ipconfig getpacket en1'              # ipInfo1:      Get info on connections for en1
    alias openPorts='sudo lsof -i | grep LISTEN'        # openPorts:    All listening connections
    alias showBlocked='sudo ipfw list'                  # showBlocked:  All ipfw rules inc/ blocked IPs
    
    #   ii:  display useful host related informaton
    #   -------------------------------------------------------------------
        ii() {
            echo -e "\nYou are logged on ${RED}$HOST"
            echo -e "\nAdditionnal information:$NC " ; uname -a
            echo -e "\n${RED}Users logged on:$NC " ; w -h
            echo -e "\n${RED}Current date :$NC " ; date
            echo -e "\n${RED}Machine stats :$NC " ; uptime
            echo -e "\n${RED}Current network location :$NC " ; scselect
            echo -e "\n${RED}Public facing IP Address :$NC " ;myip
            #echo -e "\n${RED}DNS Configuration:$NC " ; scutil --dns
            echo
        }
    
    
    #   ---------------------------------------
    #   7.  SYSTEMS OPERATIONS & INFORMATION
    #   ---------------------------------------
    
    alias mountReadWrite='/sbin/mount -uw /'    # mountReadWrite:   For use when booted into single-user
    
    #   cleanupDS:  Recursively delete .DS_Store files
    #   -------------------------------------------------------------------
        alias cleanupDS="find . -type f -name '*.DS_Store' -ls -delete"
    
    #   finderShowHidden:   Show hidden files in Finder
    #   finderHideHidden:   Hide hidden files in Finder
    #   -------------------------------------------------------------------
        alias finderShowHidden='defaults write com.apple.finder ShowAllFiles TRUE'
        alias finderHideHidden='defaults write com.apple.finder ShowAllFiles FALSE'
    
    #   cleanupLS:  Clean up LaunchServices to remove duplicates in the "Open With" menu
    #   -----------------------------------------------------------------------------------
        alias cleanupLS="/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister -kill -r -domain local -domain system -domain user && killall Finder"
    
    #    screensaverDesktop: Run a screensaver on the Desktop
    #   -----------------------------------------------------------------------------------
        alias screensaverDesktop='/System/Library/Frameworks/ScreenSaver.framework/Resources/ScreenSaverEngine.app/Contents/MacOS/ScreenSaverEngine -background'
    
    #   ---------------------------------------
    #   8.  WEB DEVELOPMENT
    #   ---------------------------------------
    
    alias apacheEdit='sudo edit /etc/httpd/httpd.conf'      # apacheEdit:       Edit httpd.conf
    alias apacheRestart='sudo apachectl graceful'           # apacheRestart:    Restart Apache
    alias editHosts='sudo edit /etc/hosts'                  # editHosts:        Edit /etc/hosts file
    alias herr='tail /var/log/httpd/error_log'              # herr:             Tails HTTP error logs
    alias apacheLogs="less +F /var/log/apache2/error_log"   # Apachelogs:   Shows apache error logs
    httpHeaders () { /usr/bin/curl -I -L $@ ; }             # httpHeaders:      Grabs headers from web page
    
    #   httpDebug:  Download a web page and show info on what took time
    #   -------------------------------------------------------------------
        httpDebug () { /usr/bin/curl $@ -o /dev/null -w "dns: %{time_namelookup} connect: %{time_connect} pretransfer: %{time_pretransfer} starttransfer: %{time_starttransfer} total: %{time_total}\n" ; }
    
    
    #   ---------------------------------------
    #   9.  REMINDERS & NOTES
    #   ---------------------------------------
    
    #   remove_disk: spin down unneeded disk
    #   ---------------------------------------
    #   diskutil eject /dev/disk1s3
    
    #   to change the password on an encrypted disk image:
    #   ---------------------------------------
    #   hdiutil chpass /path/to/the/diskimage
    
    #   to mount a read-only disk image as read-write:
    #   ---------------------------------------
    #   hdiutil attach example.dmg -shadow /tmp/example.shadow -noverify
    
    #   mounting a removable drive (of type msdos or hfs)
    #   ---------------------------------------
    #   mkdir /Volumes/Foo
    #   ls /dev/disk*   to find out the device to use in the mount command)
    #   mount -t msdos /dev/disk1s1 /Volumes/Foo
    #   mount -t hfs /dev/disk1s1 /Volumes/Foo
    
    #   to create a file of a given size: /usr/sbin/mkfile or /usr/bin/hdiutil
    #   ---------------------------------------
    #   e.g.: mkfile 10m 10MB.dat
    #   e.g.: hdiutil create -size 10m 10MB.dmg
    #   the above create files that are almost all zeros - if random bytes are desired
    #   then use: ~/Dev/Perl/randBytes 1048576 > 10MB.dat
    
    

    public by keramzyt modified May 23, 2017  354  6  4  0

    Mac OSX Bash Profile

    Mac OSX Bash Profile: .bash_profile
    #  ---------------------------------------------------------------------------
    #
    #  Description:  This file holds all my BASH configurations and aliases
    #
    #  Sections:
    #  1.   Environment Configuration
    #  2.   Make Terminal Better (remapping defaults and adding functionality)
    #  3.   File and Folder Management
    #  4.   Searching
    #  5.   Process Management
    #  6.   Networking
    #  7.   System Operations & Information
    #  8.   Web Development
    #  9.   Reminders & Notes
    #
    #  ---------------------------------------------------------------------------
    
    #   -------------------------------
    #   1.  ENVIRONMENT CONFIGURATION
    #   -------------------------------
    
    #   Change Prompt
    #   ------------------------------------------------------------
        export PS1="________________________________________________________________________________\n| \w @ \h (\u) \n| => "
        export PS2="| => "
    
    #   Set Paths
    #   ------------------------------------------------------------
        export PATH="$PATH:/usr/local/bin/"
        export PATH="/usr/local/git/bin:/sw/bin/:/usr/local/bin:/usr/local/:/usr/local/sbin:/usr/local/mysql/bin:$PATH"
    
    #   Set Default Editor (change 'Nano' to the editor of your choice)
    #   ------------------------------------------------------------
        export EDITOR=/usr/bin/nano
    
    #   Set default blocksize for ls, df, du
    #   from this: http://hints.macworld.com/comment.php?mode=view&cid=24491
    #   ------------------------------------------------------------
        export BLOCKSIZE=1k
    
    #   Add color to terminal
    #   (this is all commented out as I use Mac Terminal Profiles)
    #   from http://osxdaily.com/2012/02/21/add-color-to-the-terminal-in-mac-os-x/
    #   ------------------------------------------------------------
    #   export CLICOLOR=1
    #   export LSCOLORS=ExFxBxDxCxegedabagacad
    
    
    #   -----------------------------
    #   2.  MAKE TERMINAL BETTER
    #   -----------------------------
    
    alias cp='cp -iv'                           # Preferred 'cp' implementation
    alias mv='mv -iv'                           # Preferred 'mv' implementation
    alias mkdir='mkdir -pv'                     # Preferred 'mkdir' implementation
    alias ll='ls -FGlAhp'                       # Preferred 'ls' implementation
    alias less='less -FSRXc'                    # Preferred 'less' implementation
    cd() { builtin cd "$@"; ll; }               # Always list directory contents upon 'cd'
    alias cd..='cd ../'                         # Go back 1 directory level (for fast typers)
    alias ..='cd ../'                           # Go back 1 directory level
    alias ...='cd ../../'                       # Go back 2 directory levels
    alias .3='cd ../../../'                     # Go back 3 directory levels
    alias .4='cd ../../../../'                  # Go back 4 directory levels
    alias .5='cd ../../../../../'               # Go back 5 directory levels
    alias .6='cd ../../../../../../'            # Go back 6 directory levels
    alias edit='subl'                           # edit:         Opens any file in sublime editor
    alias f='open -a Finder ./'                 # f:            Opens current directory in MacOS Finder
    alias ~="cd ~"                              # ~:            Go Home
    alias c='clear'                             # c:            Clear terminal display
    alias which='type -all'                     # which:        Find executables
    alias path='echo -e ${PATH//:/\\n}'         # path:         Echo all executable Paths
    alias show_options='shopt'                  # Show_options: display bash options settings
    alias fix_stty='stty sane'                  # fix_stty:     Restore terminal settings when screwed up
    alias cic='set completion-ignore-case On'   # cic:          Make tab-completion case-insensitive
    mcd () { mkdir -p "$1" && cd "$1"; }        # mcd:          Makes new Dir and jumps inside
    trash () { command mv "$@" ~/.Trash ; }     # trash:        Moves a file to the MacOS trash
    ql () { qlmanage -p "$*" >& /dev/null; }    # ql:           Opens any file in MacOS Quicklook Preview
    alias DT='tee ~/Desktop/terminalOut.txt'    # DT:           Pipe content to file on MacOS Desktop
    
    #   lr:  Full Recursive Directory Listing
    #   ------------------------------------------
    alias lr='ls -R | grep ":$" | sed -e '\''s/:$//'\'' -e '\''s/[^-][^\/]*\//--/g'\'' -e '\''s/^/   /'\'' -e '\''s/-/|/'\'' | less'
    
    #   mans:   Search manpage given in agument '1' for term given in argument '2' (case insensitive)
    #           displays paginated result with colored search terms and two lines surrounding each hit.             Example: mans mplayer codec
    #   --------------------------------------------------------------------
        mans () {
            man $1 | grep -iC2 --color=always $2 | less
        }
    
    #   showa: to remind yourself of an alias (given some part of it)
    #   ------------------------------------------------------------
        showa () { /usr/bin/grep --color=always -i -a1 $@ ~/Library/init/bash/aliases.bash | grep -v '^\s*$' | less -FSRXc ; }
    
    
    #   -------------------------------
    #   3.  FILE AND FOLDER MANAGEMENT
    #   -------------------------------
    
    zipf () { zip -r "$1".zip "$1" ; }          # zipf:         To create a ZIP archive of a folder
    alias numFiles='echo $(ls -1 | wc -l)'      # numFiles:     Count of non-hidden files in current dir
    alias make1mb='mkfile 1m ./1MB.dat'         # make1mb:      Creates a file of 1mb size (all zeros)
    alias make5mb='mkfile 5m ./5MB.dat'         # make5mb:      Creates a file of 5mb size (all zeros)
    alias make10mb='mkfile 10m ./10MB.dat'      # make10mb:     Creates a file of 10mb size (all zeros)
    
    #   cdf:  'Cd's to frontmost window of MacOS Finder
    #   ------------------------------------------------------
        cdf () {
            currFolderPath=$( /usr/bin/osascript <<EOT
                tell application "Finder"
                    try
                set currFolder to (folder of the front window as alias)
                    on error
                set currFolder to (path to desktop folder as alias)
                    end try
                    POSIX path of currFolder
                end tell
    EOT
            )
            echo "cd to \"$currFolderPath\""
            cd "$currFolderPath"
        }
    
    #   extract:  Extract most know archives with one command
    #   ---------------------------------------------------------
        extract () {
            if [ -f $1 ] ; then
              case $1 in
                *.tar.bz2)   tar xjf $1     ;;
                *.tar.gz)    tar xzf $1     ;;
                *.bz2)       bunzip2 $1     ;;
                *.rar)       unrar e $1     ;;
                *.gz)        gunzip $1      ;;
                *.tar)       tar xf $1      ;;
                *.tbz2)      tar xjf $1     ;;
                *.tgz)       tar xzf $1     ;;
                *.zip)       unzip $1       ;;
                *.Z)         uncompress $1  ;;
                *.7z)        7z x $1        ;;
                *)     echo "'$1' cannot be extracted via extract()" ;;
                 esac
             else
                 echo "'$1' is not a valid file"
             fi
        }
    
    
    #   ---------------------------
    #   4.  SEARCHING
    #   ---------------------------
    
    alias qfind="find . -name "                 # qfind:    Quickly search for file
    ff () { /usr/bin/find . -name "$@" ; }      # ff:       Find file under the current directory
    ffs () { /usr/bin/find . -name "$@"'*' ; }  # ffs:      Find file whose name starts with a given string
    ffe () { /usr/bin/find . -name '*'"$@" ; }  # ffe:      Find file whose name ends with a given string
    
    #   spotlight: Search for a file using MacOS Spotlight's metadata
    #   -----------------------------------------------------------
        spotlight () { mdfind "kMDItemDisplayName == '$@'wc"; }
    
    
    #   ---------------------------
    #   5.  PROCESS MANAGEMENT
    #   ---------------------------
    
    #   findPid: find out the pid of a specified process
    #   -----------------------------------------------------
    #       Note that the command name can be specified via a regex
    #       E.g. findPid '/d$/' finds pids of all processes with names ending in 'd'
    #       Without the 'sudo' it will only find processes of the current user
    #   -----------------------------------------------------
        findPid () { lsof -t -c "$@" ; }
    
    #   memHogsTop, memHogsPs:  Find memory hogs
    #   -----------------------------------------------------
        alias memHogsTop='top -l 1 -o rsize | head -20'
        alias memHogsPs='ps wwaxm -o pid,stat,vsize,rss,time,command | head -10'
    
    #   cpuHogs:  Find CPU hogs
    #   -----------------------------------------------------
        alias cpu_hogs='ps wwaxr -o pid,stat,%cpu,time,command | head -10'
    
    #   topForever:  Continual 'top' listing (every 10 seconds)
    #   -----------------------------------------------------
        alias topForever='top -l 9999999 -s 10 -o cpu'
    
    #   ttop:  Recommended 'top' invocation to minimize resources
    #   ------------------------------------------------------------
    #       Taken from this macosxhints article
    #       http://www.macosxhints.com/article.php?story=20060816123853639
    #   ------------------------------------------------------------
        alias ttop="top -R -F -s 10 -o rsize"
    
    #   my_ps: List processes owned by my user:
    #   ------------------------------------------------------------
        my_ps() { ps $@ -u $USER -o pid,%cpu,%mem,start,time,bsdtime,command ; }
    
    
    #   ---------------------------
    #   6.  NETWORKING
    #   ---------------------------
    
    alias myip='curl ip.appspot.com'                    # myip:         Public facing IP Address
    alias netCons='lsof -i'                             # netCons:      Show all open TCP/IP sockets
    alias flushDNS='dscacheutil -flushcache'            # flushDNS:     Flush out the DNS Cache
    alias lsock='sudo /usr/sbin/lsof -i -P'             # lsock:        Display open sockets
    alias lsockU='sudo /usr/sbin/lsof -nP | grep UDP'   # lsockU:       Display only open UDP sockets
    alias lsockT='sudo /usr/sbin/lsof -nP | grep TCP'   # lsockT:       Display only open TCP sockets
    alias ipInfo0='ipconfig getpacket en0'              # ipInfo0:      Get info on connections for en0
    alias ipInfo1='ipconfig getpacket en1'              # ipInfo1:      Get info on connections for en1
    alias openPorts='sudo lsof -i | grep LISTEN'        # openPorts:    All listening connections
    alias showBlocked='sudo ipfw list'                  # showBlocked:  All ipfw rules inc/ blocked IPs
    
    #   ii:  display useful host related informaton
    #   -------------------------------------------------------------------
        ii() {
            echo -e "\nYou are logged on ${RED}$HOST"
            echo -e "\nAdditionnal information:$NC " ; uname -a
            echo -e "\n${RED}Users logged on:$NC " ; w -h
            echo -e "\n${RED}Current date :$NC " ; date
            echo -e "\n${RED}Machine stats :$NC " ; uptime
            echo -e "\n${RED}Current network location :$NC " ; scselect
            echo -e "\n${RED}Public facing IP Address :$NC " ;myip
            #echo -e "\n${RED}DNS Configuration:$NC " ; scutil --dns
            echo
        }
    
    
    #   ---------------------------------------
    #   7.  SYSTEMS OPERATIONS & INFORMATION
    #   ---------------------------------------
    
    alias mountReadWrite='/sbin/mount -uw /'    # mountReadWrite:   For use when booted into single-user
    
    #   cleanupDS:  Recursively delete .DS_Store files
    #   -------------------------------------------------------------------
        alias cleanupDS="find . -type f -name '*.DS_Store' -ls -delete"
    
    #   finderShowHidden:   Show hidden files in Finder
    #   finderHideHidden:   Hide hidden files in Finder
    #   -------------------------------------------------------------------
        alias finderShowHidden='defaults write com.apple.finder ShowAllFiles TRUE'
        alias finderHideHidden='defaults write com.apple.finder ShowAllFiles FALSE'
    
    #   cleanupLS:  Clean up LaunchServices to remove duplicates in the "Open With" menu
    #   -----------------------------------------------------------------------------------
        alias cleanupLS="/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister -kill -r -domain local -domain system -domain user && killall Finder"
    
    #    screensaverDesktop: Run a screensaver on the Desktop
    #   -----------------------------------------------------------------------------------
        alias screensaverDesktop='/System/Library/Frameworks/ScreenSaver.framework/Resources/ScreenSaverEngine.app/Contents/MacOS/ScreenSaverEngine -background'
    
    #   ---------------------------------------
    #   8.  WEB DEVELOPMENT
    #   ---------------------------------------
    
    alias apacheEdit='sudo edit /etc/httpd/httpd.conf'      # apacheEdit:       Edit httpd.conf
    alias apacheRestart='sudo apachectl graceful'           # apacheRestart:    Restart Apache
    alias editHosts='sudo edit /etc/hosts'                  # editHosts:        Edit /etc/hosts file
    alias herr='tail /var/log/httpd/error_log'              # herr:             Tails HTTP error logs
    alias apacheLogs="less +F /var/log/apache2/error_log"   # Apachelogs:   Shows apache error logs
    httpHeaders () { /usr/bin/curl -I -L $@ ; }             # httpHeaders:      Grabs headers from web page
    
    #   httpDebug:  Download a web page and show info on what took time
    #   -------------------------------------------------------------------
        httpDebug () { /usr/bin/curl $@ -o /dev/null -w "dns: %{time_namelookup} connect: %{time_connect} pretransfer: %{time_pretransfer} starttransfer: %{time_starttransfer} total: %{time_total}\n" ; }
    
    
    #   ---------------------------------------
    #   9.  REMINDERS & NOTES
    #   ---------------------------------------
    
    #   remove_disk: spin down unneeded disk
    #   ---------------------------------------
    #   diskutil eject /dev/disk1s3
    
    #   to change the password on an encrypted disk image:
    #   ---------------------------------------
    #   hdiutil chpass /path/to/the/diskimage
    
    #   to mount a read-only disk image as read-write:
    #   ---------------------------------------
    #   hdiutil attach example.dmg -shadow /tmp/example.shadow -noverify
    
    #   mounting a removable drive (of type msdos or hfs)
    #   ---------------------------------------
    #   mkdir /Volumes/Foo
    #   ls /dev/disk*   to find out the device to use in the mount command)
    #   mount -t msdos /dev/disk1s1 /Volumes/Foo
    #   mount -t hfs /dev/disk1s1 /Volumes/Foo
    
    #   to create a file of a given size: /usr/sbin/mkfile or /usr/bin/hdiutil
    #   ---------------------------------------
    #   e.g.: mkfile 10m 10MB.dat
    #   e.g.: hdiutil create -size 10m 10MB.dmg
    #   the above create files that are almost all zeros - if random bytes are desired
    #   then use: ~/Dev/Perl/randBytes 1048576 > 10MB.dat
    
    
    • Public Snippets
    • Channels Snippets