dotfiles/install

120 lines
2.1 KiB
Plaintext
Raw Normal View History

2017-05-01 08:22:20 +00:00
#!/bin/bash
2020-03-15 18:44:36 +00:00
source "$HOME/.dotfiles/script_helpers/all.sh"
2017-05-01 08:22:20 +00:00
set -e
cwd=$PWD
platform=`uname`
2020-03-15 18:44:36 +00:00
echo platform: $platform
os_is_windows is_windows
2020-03-15 18:44:36 +00:00
if [[ $is_windows -eq 1 ]]; then
error "This is only supported on Linux or MacOS.\n"
exit 1
2017-05-01 08:22:20 +00:00
fi
2017-11-21 02:39:58 +00:00
setup_dotfile_repo() {
if [ ! -d "$HOME/.dotfiles" ]; then
printf "${YELLOW}Creating dotfiles symlink${NORMAL}\n"
ln -s $cwd $HOME/.dotfiles
fi
2017-11-21 04:08:51 +00:00
# Used by various things (e.g. vim history)
mkdir -p $HOME/tmp
2017-11-21 02:39:58 +00:00
}
2017-05-01 08:22:20 +00:00
link() {
2017-11-21 02:39:58 +00:00
file=$1
link_file "$HOME/.dotfiles/$file" "$HOME/.$file" 0
2017-11-21 02:39:58 +00:00
}
setup_git() {
printf "Setting up git...\n"
FILES=()
FILES+=('gitconfig')
FILES+=('githelpers')
for file in "${FILES[@]}"
do
link "$file"
2017-11-21 02:39:58 +00:00
done
}
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
link "$file"
2017-11-21 02:39:58 +00:00
done
}
setup_vim() {
printf "Setting up vim...\n"
FILES=()
FILES+=('vim')
FILES+=('vimrc')
for file in "${FILES[@]}"
do
link "$file"
2017-11-21 02:39:58 +00:00
done
}
setup_misc() {
printf "Setting up misc...\n"
FILES=()
FILES+=('curlrc')
for file in "${FILES[@]}"
do
link "$file"
2017-11-21 02:39:58 +00:00
done
}
2017-05-01 08:22:20 +00:00
# ////////////////////////////////////////////////////////////////////////////////////////
# OSX
2017-11-21 02:39:58 +00:00
setup_osx() {
./osx/install.sh
}
# ////////////////////////////////////////////////////////////////////////////////////////
# Run
setup_dotfile_repo
setup_git
setup_zsh
setup_vim
setup_misc
2017-05-01 08:22:20 +00:00
if [[ $platform == 'Darwin' ]]; then
2017-05-02 22:14:36 +00:00
printf "\n${BOLD}Running the OS X installer${NORMAL}\n"
2017-11-21 02:39:58 +00:00
setup_osx
2017-05-01 08:22:20 +00:00
fi