#!/bin/bash source "script_helpers/printing.sh" source "script_helpers/core.sh" source "script_helpers/platform.sh" source "script_helpers/file_ops.sh" cwd=$PWD platform=`uname` confirm_link=0 os_is_windows is_windows if [[ $is_windows -eq 1 ]]; then # 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 fi set -e #################################################################################################### # Helpers #################################################################################################### setup_zsh() { printf "Setting up zsh...\n" sudo apt install zsh 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 setup_file "$file" done } #################################################################################################### # 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 curl https://raw.githubusercontent.com/git/git/master/contrib/completion/git-completion.bash -o .git-completion.bash if [[ $is_windows -eq 0 ]]; then setup_zsh fi if [[ $platform == 'Darwin' ]]; then printf "\n${BOLD}Running the OS X installer${NORMAL}\n" ./osx/install.sh fi popd "$HOME" &>/dev/null printf "${BOLD}${GREEN}Done!${NORMAL}\n"