dotfiles/scripts/bootstrap

148 lines
3.3 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"
check_for_zsh() {
if ! (echo "$SHELL" | grep zsh > /dev/null)
then
echo "Switch to using zsh before continuing"
echo ""
echo "MacOS Instructions:"
echo "System Preferences > Users & Groups > Unlock"
echo "Right-click on user, Advanced Options..."
echo "Login shell: /bin/zsh"
exit 1
fi
echo "zsh ✓"
}
check_for_ohmyzsh() {
if [ ! -d ~/.oh-my-zsh ]
then
echo "oh-my-zsh ✕"
echo ""
echo "Install oh-my-zsh before continuing"
echo "You can run the script: install_ohmyzsh"
echo ""
exit 1
fi
echo "oh-my-zsh ✓"
}
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() {
brewfile=$DOTS/homebrew/Brewfile
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)
if ! (cat /etc/shells | grep $FISH_SHELL > /dev/null)
then
echo "Modifying /etc/shells"
echo "Requires sudo password"
sudo echo $FISH_SHELL >> /etc/shells
fi
if ! (echo "$SHELL" | grep fish > /dev/null)
then
echo "Changing default shell to fish"
echo "Requires sudo password"
sudo chsh -s $FISH_SHELL
fi
echo "fish ✓"
}
2020-06-08 00:16:24 +00:00
setup_tmux() {
if [[ ! -d ~/.tmux/plugins/tpm ]]; then
git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm
fi
echo "tmux ✓"
}
2020-07-31 01:12:17 +00:00
install_gitmux() {
if ! (which gitmux > /dev/null)
then
printf "gitmux ✕\n\n"
printf "\ninstalling gitmux..."
/bin/bash -c "$(curl -L -o gitmux.tar.gz https://github.com/arl/gitmux/releases/download/v0.6.0/gitmux_0.6.0_macOS_amd64.tar.gz)"
tar -xzf gitmux.tar.gz gitmux
mkdir -p ~/.local/bin
mv gitmux ~/.local/bin/
rm gitmux.tar.gz
echo ""
fi
echo "gitmux ✓"
}
2020-06-03 14:31:58 +00:00
install_spacemacs() {
emacsdir=~/.emacs.d
if ! (git -C "$emacsdir" pull > /dev/null 2>&1)
then
2020-06-04 18:58:33 +00:00
git clone -b develop https://github.com/syl20bnr/spacemacs "$emacsdir"
2020-06-03 14:31:58 +00:00
fi
echo "spacemacs ✓"
}
printf "\nbootstrapping...\n\n"
2020-07-31 01:12:17 +00:00
#check_for_zsh
#check_for_ohmyzsh
2020-06-03 14:31:58 +00:00
install_xcode
install_homebrew
install_brews
2020-06-08 00:16:24 +00:00
setup_tmux
2020-07-31 01:12:17 +00:00
install_gitmux
2020-06-03 14:31:58 +00:00
install_spacemacs
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:"
echo " - install_casks"
2020-06-03 14:31:58 +00:00
echo " - configure_macos"
echo " - setup_keybase"
echo " - install_python"
echo " - install_rust"
echo ""