From a50d452c1123c7502fd59b019d100babbf3cadde Mon Sep 17 00:00:00 2001 From: Daniel Barber Date: Mon, 22 Apr 2019 21:37:35 -0400 Subject: [PATCH 1/3] Hopefully fix the read being skipped issue --- lib/chunkwm.sh | 2 +- setup.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/chunkwm.sh b/lib/chunkwm.sh index 045edaf..4a05668 100755 --- a/lib/chunkwm.sh +++ b/lib/chunkwm.sh @@ -2,7 +2,7 @@ # Ask the user to generate a code signing key for `chunkwm` echo "Please generate a code signing certificate called 'chunkwm-cert' in Keychain Access" -read -r -p "Press any key to continue... " -n 1 +sh -c 'read -r -p "Press any key to continue... " -n 1' # We need to code sign chunkwm and skhd in order for them to be added to the # accessibility allowed list. diff --git a/setup.sh b/setup.sh index 441d066..f393d76 100755 --- a/setup.sh +++ b/setup.sh @@ -19,7 +19,7 @@ if [ ! -f "$HOME/.ssh/id_ed25519.pub" ]; then echo "============ Public key =============" cat ~/.ssh/id_ed25519.pub echo "=====================================" - read -r -p "Press any key to continue... " -n 1 + sh -c 'read -r -p "Press any key to continue... " -n 1' fi # Add the SSH key to the agent now to avoid multiple prompts From a67e85a0369baee9f795320c1515ebd7273d96eb Mon Sep 17 00:00:00 2001 From: Daniel Barber Date: Mon, 22 Apr 2019 22:25:50 -0400 Subject: [PATCH 2/3] Use process substitution to run the script This ensures that we can get input from the terminal. --- README.md | 2 +- extra.sh | 1 + lib/chunkwm.sh | 2 +- lib/dotfiles.sh | 1 + lib/macos.sh | 2 +- setup.sh | 3 ++- 6 files changed, 7 insertions(+), 4 deletions(-) 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/chunkwm.sh b/lib/chunkwm.sh index 4a05668..045edaf 100755 --- a/lib/chunkwm.sh +++ b/lib/chunkwm.sh @@ -2,7 +2,7 @@ # Ask the user to generate a code signing key for `chunkwm` echo "Please generate a code signing certificate called 'chunkwm-cert' in Keychain Access" -sh -c 'read -r -p "Press any key to continue... " -n 1' +read -r -p "Press any key to continue... " -n 1 # We need to code sign chunkwm and skhd in order for them to be added to the # accessibility allowed list. 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/setup.sh b/setup.sh index f393d76..e0466f3 100755 --- a/setup.sh +++ b/setup.sh @@ -1,4 +1,5 @@ #!/bin/sh + MAC_SETUP_DIR="$HOME/mac-setup" BOLD="\033[1m" @@ -19,7 +20,7 @@ if [ ! -f "$HOME/.ssh/id_ed25519.pub" ]; then echo "============ Public key =============" cat ~/.ssh/id_ed25519.pub echo "=====================================" - sh -c 'read -r -p "Press any key to continue... " -n 1' + read -r -p "Press any key to continue... " -n 1 fi # Add the SSH key to the agent now to avoid multiple prompts From 5f4e1e18ee24b82cea5b2d43ce22657823ab6cd1 Mon Sep 17 00:00:00 2001 From: Daniel Barber Date: Tue, 23 Apr 2019 08:57:56 -0400 Subject: [PATCH 3/3] Change shell --- lib/shell.sh | 9 +++++++++ setup.sh | 7 +++++++ 2 files changed, 16 insertions(+) create mode 100755 lib/shell.sh 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 e0466f3..daa8115 100755 --- a/setup.sh +++ b/setup.sh @@ -12,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" @@ -54,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"