mirror of
https://github.com/Lissy93/dotfiles.git
synced 2024-11-25 08:43:26 +01:00
Adds PlugInstall, make user input optional, refactor setup into own function
This commit is contained in:
parent
05d971ba24
commit
d80635e3ec
87
install.sh
87
install.sh
@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
# IMPORTANT: Before running, read through everything, and confirm it's what you want!
|
# IMPORTANT: Before running, read through everything, and confirm it's what you want!
|
||||||
|
|
||||||
set -e
|
# set -e
|
||||||
|
|
||||||
# Configuration Params
|
# Configuration Params
|
||||||
REPO_NAME="Lissy93/Dotfiles"
|
REPO_NAME="Lissy93/Dotfiles"
|
||||||
@ -28,6 +28,9 @@ PLAIN_B='\033[1;37m'
|
|||||||
RESET='\033[0m'
|
RESET='\033[0m'
|
||||||
PURPLE='\033[0;35m'
|
PURPLE='\033[0;35m'
|
||||||
|
|
||||||
|
# Other params
|
||||||
|
PROMPT_TIMEOUT=15 # When user is prompted for input, skip after x seconds
|
||||||
|
|
||||||
# Start timer
|
# Start timer
|
||||||
start_time=`date +%s`
|
start_time=`date +%s`
|
||||||
|
|
||||||
@ -87,15 +90,6 @@ function pre_setup_tasks () {
|
|||||||
# Downloads / updates dotfiles and symlinks them
|
# Downloads / updates dotfiles and symlinks them
|
||||||
function setup_dot_files () {
|
function setup_dot_files () {
|
||||||
|
|
||||||
# If ZSH not the default shell, ask user if they'd like to set it
|
|
||||||
if [[ $SHELL != *"zsh"* ]] && command_exists zsh; then
|
|
||||||
read -p "Would you like to set ZSH as your default shell? (y/N)" -n 1 -r
|
|
||||||
echo
|
|
||||||
if [[ $REPLY =~ ^[Yy]$ ]]; then
|
|
||||||
chsh -s $(which zsh) $USER
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Download / update dotfiles repo with git
|
# Download / update dotfiles repo with git
|
||||||
if [[ ! -d "$DOTFILES_DIR" ]]
|
if [[ ! -d "$DOTFILES_DIR" ]]
|
||||||
then
|
then
|
||||||
@ -104,7 +98,7 @@ function setup_dot_files () {
|
|||||||
git clone --recursive ${REPO_PATH} ${DOTFILES_DIR}
|
git clone --recursive ${REPO_PATH} ${DOTFILES_DIR}
|
||||||
else
|
else
|
||||||
echo -e "${PURPLE}Pulling changes from ${REPO_NAME} into ${DOTFILES_DIR}"
|
echo -e "${PURPLE}Pulling changes from ${REPO_NAME} into ${DOTFILES_DIR}"
|
||||||
cd "${DOTFILES_DIR}" && git pull && git submodule update --recursive
|
cd "${DOTFILES_DIR}" && git pull origin master && git submodule update --recursive
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# If git clone / pull failed, then exit with error
|
# If git clone / pull failed, then exit with error
|
||||||
@ -123,35 +117,57 @@ function setup_dot_files () {
|
|||||||
"${DOTFILES_DIR}/${DOTBOT_DIR}/${DOTBOT_BIN}" -d "${DOTFILES_DIR}" -c "${CONFIG}" "${@}"
|
"${DOTFILES_DIR}/${DOTBOT_DIR}/${DOTBOT_BIN}" -d "${DOTFILES_DIR}" -c "${CONFIG}" "${@}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Applies application-specific preferences, and runs some setup tasks
|
||||||
|
function apply_preferences () {
|
||||||
|
|
||||||
|
# If ZSH not the default shell, ask user if they'd like to set it
|
||||||
|
if [[ $SHELL != *"zsh"* ]] && command_exists zsh; then
|
||||||
|
read -t $PROMPT_TIMEOUT -p "Would you like to set ZSH as your default shell? (y/N)" -n 1 -r
|
||||||
|
echo
|
||||||
|
if [[ $REPLY =~ ^[Yy]$ ]]; then
|
||||||
|
chsh -s $(which zsh) $USER
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Install / update vim plugins with Plug
|
||||||
|
vim +PlugInstall +qall
|
||||||
|
|
||||||
|
# Install / update Tmux plugins with TPM
|
||||||
|
chmod ug+x "${XDG_DATA_HOME}/tmux/tpm"
|
||||||
|
}
|
||||||
|
|
||||||
# Based on system type, uses appropriate package manager to install / updates apps
|
# Based on system type, uses appropriate package manager to install / updates apps
|
||||||
function install_packages () {
|
function install_packages () {
|
||||||
# Mac OS
|
|
||||||
if [ "$system_type" = "Darwin" ]; then
|
read -t $PROMPT_TIMEOUT -p "Would you like to install / update system packages? (y/N) " -n 1 -r
|
||||||
# Homebrew not installed, ask user if they'd like to download it now
|
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
|
||||||
if ! command_exists brew; then
|
echo -e "\n${PURPLE}Skipping package installs${RESET}"
|
||||||
read -p "Would you like to install Homebrew? (y/N)" -n 1 -r
|
return
|
||||||
echo
|
fi
|
||||||
if [[ $REPLY =~ ^[Yy]$ ]]; then
|
|
||||||
echo -en "🍺 ${YELLOW_B}Installing Homebrew...${RESET}\n"
|
# Mac OS
|
||||||
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
|
if [ "$system_type" = "Darwin" ]; then
|
||||||
export PATH=/opt/homebrew/bin:$PATH
|
# Homebrew not installed, ask user if they'd like to download it now
|
||||||
fi
|
if ! command_exists brew; then
|
||||||
fi
|
read -t $PROMPT_TIMEOUT -p "Would you like to install Homebrew? (y/N)" -n 1 -r
|
||||||
# Update / Install the Homebrew packages in ~/.Brewfile
|
echo
|
||||||
if command_exists brew && [ -f "$HOME/.Brewfile" ]
|
if [[ $REPLY =~ ^[Yy]$ ]]; then
|
||||||
then
|
echo -en "🍺 ${YELLOW_B}Installing Homebrew...${RESET}\n"
|
||||||
echo -e "${PURPLE}Updating homebrew and packages...${RESET}"
|
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
|
||||||
brew update
|
export PATH=/opt/homebrew/bin:$PATH
|
||||||
brew upgrade
|
|
||||||
BREW_PREFIX=$(brew --prefix)
|
|
||||||
brew bundle --global --file $HOME/.Brewfile
|
|
||||||
brew cleanup
|
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
# Windows (WIP)
|
# Update / Install the Homebrew packages in ~/.Brewfile
|
||||||
if [ "$system_type" = "WindowsNT" ] || [ "$OSTYPE" = "msys" ] || [ "$OSTYPE" = "cygwin" ]; then
|
if command_exists brew && [ -f "$HOME/.Brewfile" ]
|
||||||
"${DOTFILES_DIR}/installs/windows.sh"
|
then
|
||||||
|
echo -e "${PURPLE}Updating homebrew and packages...${RESET}"
|
||||||
|
brew update
|
||||||
|
brew upgrade
|
||||||
|
BREW_PREFIX=$(brew --prefix)
|
||||||
|
brew bundle --global --file $HOME/.Brewfile
|
||||||
|
brew cleanup
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# Updates current session, and outputs summary
|
# Updates current session, and outputs summary
|
||||||
@ -168,6 +184,7 @@ function finishing_up () {
|
|||||||
# Begin!
|
# Begin!
|
||||||
pre_setup_tasks # Print start message, and check requirements are met
|
pre_setup_tasks # Print start message, and check requirements are met
|
||||||
setup_dot_files # Clone / updatae dotfiles, and create the symlinks
|
setup_dot_files # Clone / updatae dotfiles, and create the symlinks
|
||||||
|
apply_preferences # Set settings for individual applications
|
||||||
install_packages # Prompt to install / update OS-specific packages
|
install_packages # Prompt to install / update OS-specific packages
|
||||||
finishing_up # Re-source .zshenv, and print summary
|
finishing_up # Re-source .zshenv, and print summary
|
||||||
# All done!
|
# All done!
|
||||||
|
Loading…
Reference in New Issue
Block a user