dotfiles/scripts/bootstrap

80 lines
1.8 KiB
Plaintext
Raw Normal View History

2020-06-03 14:31:58 +00:00
#!/bin/sh
DOTS=$(dirname "$0")/..
cd "$DOTS" || (echo "Directory not found: $DOTS"; exit 1)
DOTS="$PWD"
install_xcode() {
if [ "$(uname)" = "Darwin" ]
then
if ! (xcode-select --version > /dev/null 2>&1)
then
xcode-select --install
fi
echo "xcode ✓"
fi
}
install_homebrew() {
if ! (which /usr/local/bin/brew > /dev/null)
then
printf "homebrew ✕\n\n"
printf "\ninstalling homebrew..."
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
echo ""
fi
echo "homebrew ✓"
}
install_brews() {
2020-11-28 17:53:42 +00:00
brewfile=$DOTS/homebrew/core.Brewfile
2020-06-03 14:31:58 +00:00
if ! (/usr/local/bin/brew bundle check --file "$brewfile" > /dev/null)
then
/usr/local/bin/brew bundle --file "$brewfile"
fi
echo "brews installed ✓"
}
2020-07-31 01:12:17 +00:00
use_fish_shell() {
if ! (which fish > /dev/null)
then
echo "Install fish before continuing"
echo "You can do: brew install fish"
echo "Or add fish to homebrew/Brewfile and rerun"
exit 1
fi
FISH_SHELL=$(which fish)
2021-04-28 12:58:14 +00:00
if ! (grep "$FISH_SHELL" /etc/shells > /dev/null)
2020-07-31 01:12:17 +00:00
then
echo "Modifying /etc/shells"
echo "Requires sudo password"
2021-04-28 12:58:14 +00:00
echo "$FISH_SHELL" | sudo tee -a /etc/shells
2020-07-31 01:12:17 +00:00
fi
if ! (echo "$SHELL" | grep fish > /dev/null)
then
echo "Changing default shell to fish"
echo "Requires sudo password"
2021-04-28 12:58:14 +00:00
sudo chsh -s "$FISH_SHELL"
2020-07-31 01:12:17 +00:00
fi
echo "fish ✓"
}
2020-06-03 14:31:58 +00:00
printf "\nbootstrapping...\n\n"
install_xcode
install_homebrew
install_brews
2020-07-31 01:12:17 +00:00
use_fish_shell
2020-06-03 14:31:58 +00:00
("$DOTS/scripts/setup_symlinks")
echo ""
echo "consider running other scripts:"
2021-04-28 12:58:14 +00:00
echo " - brews"
echo " - casks"
2020-06-03 14:31:58 +00:00
echo " - configure_macos"
2021-04-28 12:58:14 +00:00
echo " - rust"
echo " - cargos"
2020-06-03 14:31:58 +00:00
echo ""