diff --git a/README.md b/README.md index f05acb8..aec8baa 100644 --- a/README.md +++ b/README.md @@ -7,5 +7,5 @@ Script and Brewfile to setup a Mac for development. 1. Run the setup script with: ```sh - curl -s https://raw.githubusercontent.com/danbee/mac-setup/master/setup.sh | sh` + $ sh <( curl -s https://raw.githubusercontent.com/danbee/mac-setup/master/setup.sh ) ``` diff --git a/extra.sh b/extra.sh index ccf80f6..7c03cad 100755 --- a/extra.sh +++ b/extra.sh @@ -1,4 +1,5 @@ #!/bin/sh + MAC_SETUP_DIR="$HOME/mac-setup" BOLD="\033[1m" diff --git a/lib/dotfiles.sh b/lib/dotfiles.sh index 2b45a3e..98fae75 100755 --- a/lib/dotfiles.sh +++ b/lib/dotfiles.sh @@ -1,4 +1,5 @@ #!/bin/sh + cd "$HOME" if [ $SHELL != $(which zsh) ]; then diff --git a/lib/macos.sh b/lib/macos.sh index 43c069b..0f75aee 100755 --- a/lib/macos.sh +++ b/lib/macos.sh @@ -1,4 +1,4 @@ -#!/usr/bin/env bash +#!/bin/sh # Close any open System Preferences panes, to prevent them from overriding # settings we’re about to change diff --git a/lib/shell.sh b/lib/shell.sh new file mode 100755 index 0000000..e67e064 --- /dev/null +++ b/lib/shell.sh @@ -0,0 +1,9 @@ +#!/bin/sh + +SHELL_PATH=$(command -v zsh) + +if ! grep "$SHELL_PATH" /etc/shells > /dev/null 2>&1 ; then + sudo sh -c "echo $SHELL_PATH >> /etc/shells" +fi + +sudo chsh -s "$SHELL_PATH" "$USER" diff --git a/setup.sh b/setup.sh index a977edf..db0aed1 100755 --- a/setup.sh +++ b/setup.sh @@ -1,4 +1,5 @@ #!/bin/sh + MAC_SETUP_DIR="$HOME/mac-setup" BOLD="\033[1m" @@ -11,6 +12,9 @@ step() { echo "${YELLOW}❯❯❯ ${WHITE}${BOLD}$1${NC} ${YELLOW}❮❮❮${NC}" } +# Ask for the administrator password upfront +sudo -v + # Generate an SSH key if one does not already exist if [ ! -f "$HOME/.ssh/id_ed25519.pub" ]; then step "Generating SSH key" @@ -53,6 +57,10 @@ brew bundle --file="$MAC_SETUP_DIR/Brewfile" step "Installing dotfiles" "$MAC_SETUP_DIR/lib/dotfiles.sh" +# Change the shell +step "Changing shell to zsh" +"$MAC_SETUP_DIR/lib/shell.sh" + # Setup git author step "Set git author" "$MAC_SETUP_DIR/lib/git_author.sh"