From 532a08598d7c53a3828ee5df8825cdb80e6873d7 Mon Sep 17 00:00:00 2001 From: Daniel Barber Date: Mon, 15 Apr 2019 21:37:08 -0400 Subject: [PATCH] Refactor all the things! --- Brewfile | 15 +++--------- README.md | 8 ++----- lib/dotfiles.sh | 24 ++++++++++++++++++++ lib/git_author.sh | 8 +++++++ lib/homebrew.sh | 3 +++ lib/mas.sh | 9 ++++++++ mas.sh | 19 ---------------- setup.sh | 58 ++++++++++++++++++++++++++++++++++++----------- 8 files changed, 94 insertions(+), 50 deletions(-) create mode 100755 lib/dotfiles.sh create mode 100755 lib/git_author.sh create mode 100755 lib/homebrew.sh create mode 100755 lib/mas.sh delete mode 100755 mas.sh diff --git a/Brewfile b/Brewfile index 00f19e6..1a0bd2b 100644 --- a/Brewfile +++ b/Brewfile @@ -1,7 +1,9 @@ tap "thoughtbot/formulae" +tap "heroku/brew" brew "asdf" brew "direnv" brew "git" +brew "heroku" brew "imagemagick" brew "mas" brew "mackup" @@ -20,30 +22,19 @@ brew "zsh" cask "1password" cask "acorn" cask "choosy" -cask "colorpicker-skalacolor" cask "dropbox" -cask "fantastical" cask "firefox" cask "google-chrome" cask "imagealpha" cask "imageoptim" -cask "istat-menus" -cask "iterm2" -cask "ivolume" +cask "iterm2-nightly" cask "kaleidoscope" cask "macvim" -cask "mplayerx" -cask "mpv" cask "phantomjs" cask "sequel-pro" -cask "skype" -cask "spotify" -cask "superduper" cask "textmate" cask "vmware-fusion" -cask "vlc" -tap "caskroom/fonts" cask "font-vollkorn" cask "font-source-code-pro" cask "font-source-sans-pro" diff --git a/README.md b/README.md index 6c28b77..a315f4c 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,7 @@ ## Mac Setup -Script and Brewfiles to setup a Mac for development. +Script and Brewfile to setup a Mac for development. ## Instructions -Full Xcode install is required to compile MacVim. - -1. Install Xcode with `xcode-select --install`. Select "Get Xcode". - -2. Run the setup script with `curl -s https://raw.githubusercontent.com/danbee/mac-setup/master/setup.sh | sh` +1. Run the setup script with `curl -s https://raw.githubusercontent.com/danbee/mac-setup/master/setup.sh | sh` diff --git a/lib/dotfiles.sh b/lib/dotfiles.sh new file mode 100755 index 0000000..2b45a3e --- /dev/null +++ b/lib/dotfiles.sh @@ -0,0 +1,24 @@ +#!/bin/sh +cd "$HOME" + +if [ $SHELL != $(which zsh) ]; then + chsh -s $(which zsh) +fi + +if [ ! -d "$HOME/dotfiles" ]; then + git clone git@github.com:thoughtbot/dotfiles.git +else + cd "$HOME/dotfiles" + git pull + cd - +fi + +if [ ! -d "$HOME/dotfiles-local" ]; then + git clone git@github.com:danbee/dotfiles-local.git +else + cd "$HOME/dotfiles-local" + git pull + cd - +fi + +env RCRC="$HOME/dotfiles/rcrc" rcup diff --git a/lib/git_author.sh b/lib/git_author.sh new file mode 100755 index 0000000..3da2f5f --- /dev/null +++ b/lib/git_author.sh @@ -0,0 +1,8 @@ +#!/bin/sh + +DOTFILES="$HOME/dotfiles-local" + +if [ ! -f "$DOTFILES/gitconfig.author" ]; then + cp "$DOTFILES//gitconfig.author.example" "$DOTFILES/gitconfig.author" + vim "$DOTFILES/gitconfig.author" +fi diff --git a/lib/homebrew.sh b/lib/homebrew.sh new file mode 100755 index 0000000..e6694f8 --- /dev/null +++ b/lib/homebrew.sh @@ -0,0 +1,3 @@ +#!/bin/sh + +/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" diff --git a/lib/mas.sh b/lib/mas.sh new file mode 100755 index 0000000..1b76dca --- /dev/null +++ b/lib/mas.sh @@ -0,0 +1,9 @@ +#!/bin/sh + +# mas install 13764025890 +mas install 1107421413 +mas install 403504866 +mas install 1278508951 +mas install 497799835 +mas install 1179623856 +mas install 1082624744 diff --git a/mas.sh b/mas.sh deleted file mode 100755 index 691e39e..0000000 --- a/mas.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/sh - -mas install 904280696 -mas install 13764025890 -mas install 1084713122 -mas install 1107421413 -mas install 409183694 -mas install 403504866 -mas install 1278508951 -mas install 918858936 -mas install 530458789 -mas install 734335183 -mas install 409203825 -mas install 497799835 -mas install 409201541 -mas install 1179623856 -mas install 1082624744 -mas install 1225570693 -mas install 924726344 diff --git a/setup.sh b/setup.sh index cda3422..24e01a4 100755 --- a/setup.sh +++ b/setup.sh @@ -1,23 +1,55 @@ #!/bin/sh +MAC_SETUP_DIR="$HOME/mac-setup" -/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" +BOLD="\033[1m" +WHITE="\033[0;37m" +YELLOW="\033[1;33m" +GREEN="\033[1;32m" +NC="\033[0m" -# We want to be in the user home directory. -cd ~ +step() { + echo "${YELLOW}❯❯❯ ${WHITE}${BOLD}$1${NC} ${YELLOW}❮❮❮${NC}" +} -# Get Brewfiles. -echo 'Downloading...' -curl -s https://raw.githubusercontent.com/danbee/mac-setup/master/Brewfile > ~/Brewfile -curl -s https://raw.githubusercontent.com/danbee/mac-setup/master/mas.sh > ~/mas.sh -chmod +x ~/mas.sh +# Generate an SSH key if one does not already exist +if [ ! -f "$HOME/.ssh/id_ed25519.pub" ]; then + step "Generating SSH key" + ssh-keygen -t ed25519 -f "$HOME/.ssh/id_ed25519" + echo "Copy and paste the public portion of the key (below) to GitHub" + echo "and press a key when done." + echo "=========== Public key ==============" + cat ~/.ssh/id_ed25519.pub + echo "=====================================" + read -n 1 -s +fi + +# Clone setup repo +if [ ! -d "$MAC_SETUP_DIR" ]; then + git clone git@github.com:danbee/mac-setup.git "$HOME/mac-setup" +else + cd "$MAC_SETUP_DIR" + git pull + cd - +fi + +# Install Homebrew +step "Installing Homebrew" +"$MAC_SETUP_DIR/lib/homebrew.sh" # Install brew bundles -echo 'Installing Homebrew bundle...' -brew bundle +step "Installing Homebrew bundle" +brew bundle --file="$MAC_SETUP_DIR/Brewfile" # Install Mac App Store apps -echo 'Installing App Store apps' -~/mas.sh +step "Installing App Store apps" +"$MAC_SETUP_DIR/lib/mas.sh" -echo 'Done!' +# Install dotfiles +step "Installing dotfiles" +"$MAC_SETUP_DIR/lib/dotfiles.sh" +# Setup git author +step "Set git author" +"$MAC_SETUP_DIR/lib/git_author.sh" + +echo "${GREEN}✔ ${WHITE}${BOLD}Done!${NC} 🎉"