Skip to content

Instantly share code, notes, and snippets.

@fwal
Last active January 11, 2019 13:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fwal/171665a94131aac134d7 to your computer and use it in GitHub Desktop.
Save fwal/171665a94131aac134d7 to your computer and use it in GitHub Desktop.
My setup script for new macs
#! /bin/sh
# PUBLIC DOMAIN
#
# This is free and unencumbered software released into the public domain.
#
# Anyone is free to copy, modify, publish, use, compile, sell, or
# distribute this software, either in source code form or as a compiled
# binary, for any purpose, commercial or non-commercial, and by any
# means.
#
# In jurisdictions that recognize copyright laws, the author or authors
# of this software dedicate any and all copyright interest in the
# software to the public domain. We make this dedication for the benefit
# of the public at large and to the detriment of our heirs and
# successors. We intend this dedication to be an overt act of
# relinquishment in perpetuity of all present and future rights to this
# software under copyright law.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
# IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
# OTHER DEALINGS IN THE SOFTWARE.
#
# For more information, please refer to <http://unlicense.org>
# Prompt the user
function prompt {
while true; do
read -p "❓ $1 is not installed. Do you wish to install it? [y/n]:" yn
case $yn in
[Yy]* ) return 1;;
[Nn]* ) return 0;;
* ) echo "Please answer yes or no.";;
esac
done
}
# Check for command-line program
function program {
command -v $1 >/dev/null 2>&1 || {
if prompt "$2" $1;
then echo "πŸ’” $2" && echo "" && return 0;
else echo "πŸ“¦ Installing $2..." && $3;
fi
}
echo "πŸ‘ $2"
echo ""
}
# Check for app
function app {
if [ ! -d "/Applications/$1" ]; then
if prompt "$2" $1;
then echo "πŸ’” $2" && echo "" && return 0;
else echo "πŸ“¦ Installing $2..." && $3;
fi
fi
echo "πŸ‘ $2"
echo ""
}
echo "---"
echo "Yell-o! Let's get this mac up and running, shall we?"
echo "---"
# -- BEGIN CONFIG --
program brew "Homebrew" "/usr/bin/ruby -e \"$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)\""
app iTerm.app "iTerm" "brew cask install iterm2"
app Alfred\ 3.app "Alfred 3" "brew cask install alfred"
program zsh "zsh" "sh -c \"$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)\""
# -- END CONFIG --
echo "---"
echo "All done! See you next time! 🍹"
@fwal
Copy link
Author

fwal commented Feb 2, 2015

Protip: copy the link to the raw file and run with

bash <(curl -s https://gist.githubusercontent.com/path-to-raw/macinit.sh)

To run this exact file use the following

bash <(curl -s https://gist.githubusercontent.com/fwal/171665a94131aac134d7/raw/b6658d38a35021db6a20c2d64b5179496e60dbdd/macinit.sh)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment