dotfiles/install

107 lines
2.6 KiB
Plaintext
Raw Normal View History

2017-05-01 08:22:20 +00:00
#!/bin/bash
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
platform=`uname`
2020-05-14 04:36:01 +00:00
confirm_link=0
os_is_windows is_windows
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() {
printf "Setting up zsh...\n"
2020-03-15 18:44:36 +00:00
sudo apt install zsh
2017-11-21 02:39:58 +00:00
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
fi
FILES=()
FILES+=('zsh')
FILES+=('zshrc')
FILES+=('zshenv')
FILES+=('zlogin')
FILES+=('zprofile')
for file in "${FILES[@]}"
do
2020-05-14 04:36:01 +00:00
setup_file "$file"
2017-11-21 02:39:58 +00:00
done
}
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+=('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
2017-05-01 08:22:20 +00:00
if [[ $platform == 'Darwin' ]]; then
2020-05-14 04:36:01 +00:00
printf "\n${BOLD}Running the OS X installer${NORMAL}\n"
./osx/install.sh
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"