#!/bin/bash # If error was caused, stop script set -e # Install to ~/Codes/dotfiles DOT_DIRECTORY="${HOME}/Codes/dotfiles" REMOTE_URL="https://github.com/umeruma/dotfiles.git" uname_s="$(uname -s)" is_exist() { type "$1" > /dev/null 2>&1 } install() { # Create ~/Codes directory if it doesn't exist mkdir -p "${HOME}/Codes" # Clone the dotfiles repo if it doesn't exist if [ -d "${DOT_DIRECTORY}" ]; then echo "DOTFILES have already been installed at ${DOT_DIRECTORY}" else if is_exist "git"; then echo "Cloning dotfiles to ${DOT_DIRECTORY}..." git clone --filter=blob:none --depth 1 --recurse-submodules --shallow-submodules "${REMOTE_URL}" "${DOT_DIRECTORY}" else echo "git required" exit 1 fi fi echo "" echo "Start to setup DOTFILES" echo "" cd "${DOT_DIRECTORY}" if [ "$uname_s" = "Linux" ]; then bash ./init/init-linux.sh fi if [ "$uname_s" = "Darwin" ]; then bash ./init/init-macos.sh fi # Check if just is installed; if not, download and install to ./bin/just echo "" if is_exist ./bin/just; then echo "just is installed" ./bin/just --version || { echo "just command not working"; exit 1; } else # create ./bin mkdir -p ./bin # download and extract just to ./bin/just curl --proto '=https' --tlsv1.2 -sSf https://just.systems/install.sh | bash -s -- --to ./bin # just should now be executable ./bin/just --version || { echo "just install failed"; exit 1; } echo "just install succeeded" fi # Check if Homebrew is installed; if not, install it echo "" if type brew >/dev/null 2>&1; then echo "brew is installed"; else if [ "$uname_s" = 'Linux' ]; then sh -c "$(curl -fsSL https://raw.githubusercontent.com/Linuxbrew/install/master/install.sh)" elif [ "$uname_s" = 'Darwin' ]; then /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" fi fi # Run just deploy to create symlinks and install packages ./bin/just deploy # Change default shell to /bin/zsh if not already echo "" if [ "$SHELL" = "/bin/zsh" ]; then echo "Using /bin/zsh" else echo "Change default shell to /bin/zsh" chsh -s /bin/zsh fi echo "" echo "If you want to install apps, run: just install-apps" } install