dotfiles/install

120 lines
3.0 KiB
Plaintext
Raw Normal View History

2020-07-25 23:39:09 +00:00
#!/usr/bin/env bash
if [[ $(uname) == 'Darwin' ]]; then
2020-07-25 23:39:09 +00:00
if ! command -v brew &>/dev/null
then
# We need to update bash, so we'll start with setting up homebrew.
./osx/pre_install
exit
fi
fi
2017-05-01 08:22:20 +00:00
2020-05-14 04:36:01 +00:00
source "script_helpers/printing.sh"
source "script_helpers/core.sh"
source "script_helpers/platform.sh"
source "script_helpers/file_ops.sh"
2017-05-01 08:22:20 +00:00
cwd=$PWD
2020-05-14 04:36:01 +00:00
confirm_link=0
os_is_windows is_windows
2020-07-25 23:39:09 +00:00
os_is_macos is_macos
os_is_linux is_linux
2020-05-14 04:36:01 +00:00
2020-03-15 18:44:36 +00:00
if [[ $is_windows -eq 1 ]]; then
2020-05-14 04:36:01 +00:00
# Check for admin permissions.
net session &>/dev/null
admin_error=$?
if [[ ! $admin_error -eq 0 ]]; then
fatal "You need to run this in an admin shell!"
fi
2017-05-01 08:22:20 +00:00
fi
2020-05-14 04:36:01 +00:00
set -e
2017-11-21 02:39:58 +00:00
2020-05-14 04:36:01 +00:00
####################################################################################################
# Helpers
####################################################################################################
2017-11-21 02:39:58 +00:00
setup_zsh() {
2020-07-25 23:39:09 +00:00
printf "Setting up zsh...\n"
if [[ $is_linux -eq 1 ]]; then
sudo apt install zsh
fi
TEST_CURRENT_SHELL=$(expr "$SHELL" : '.*/\(.*\)')
if [ "$TEST_CURRENT_SHELL" != "zsh" ]; then
if hash chsh >/dev/null 2>&1; then
printf "\n${BLUE}Changing the default shell to zsh${NORMAL}\n"
chsh -s $(grep /zsh$ /etc/shells | tail -1)
else
printf "\n${RED}Unable to change the shell because this system does not have chsh.\n"
printf "${BLUE}If this is Windows then you probably want to run the bash installer.${NORMAL}\n"
fi
2017-11-21 02:39:58 +00:00
fi
2020-07-25 23:39:09 +00:00
setup_dir .dotfiles/zsh/core .zsh
2020-07-25 23:39:09 +00:00
FILES=()
FILES+=('zshrc')
FILES+=('zshenv')
FILES+=('zlogin')
for file in "${FILES[@]}"
do
setup_file .dotfiles/zsh/$file .$file
2020-07-25 23:39:09 +00:00
done
2017-11-21 02:39:58 +00:00
}
2020-05-14 04:36:01 +00:00
####################################################################################################
# Setup
####################################################################################################
pushd "$HOME" &>/dev/null
#########################
# Setup root dirs
#########################
setup_dir $cwd .dotfiles
setup_dir .dotfiles/vim .vim
#########################
# Setup root files
#########################
FILES=()
FILES+=('common_env')
2020-05-14 04:36:01 +00:00
FILES+=('aliases')
FILES+=('gitconfig')
FILES+=('vimrc')
FILES+=('curlrc')
for file in "${FILES[@]}"
do
setup_file .dotfiles/$file .$file
done
#########################
# Setup non-root files
#########################
if [[ $is_windows -eq 1 ]]; then
setup_file .dotfiles/bash/bashrc .bashrc
setup_file .dotfiles/bash/bash_profile .bash_profile
setup_file .dotfiles/bash/inputrc .inputrc
setup_file .dotfiles/windows/gitconfig.platform .gitconfig.platform
fi
2017-11-21 02:39:58 +00:00
2020-05-14 04:36:01 +00:00
curl https://raw.githubusercontent.com/git/git/master/contrib/completion/git-completion.bash -o .git-completion.bash
2017-11-21 02:39:58 +00:00
2020-05-14 04:36:01 +00:00
if [[ $is_windows -eq 0 ]]; then
setup_zsh
fi
2017-11-21 02:39:58 +00:00
2020-07-25 23:39:09 +00:00
if [[ $is_macos -eq 1 ]]; then
printf "\n${BOLD}Running the MacOS installer${NORMAL}\n"
$cwd/osx/install
2017-05-01 08:22:20 +00:00
fi
2020-05-14 04:36:01 +00:00
popd "$HOME" &>/dev/null
printf "${BOLD}${GREEN}Done!${NORMAL}\n"