mirror of
https://github.com/Lissy93/dotfiles.git
synced 2025-06-26 12:01:21 +02:00
Refactors how read commands and auto-yes work
This commit is contained in:
parent
9206b5fc9e
commit
a6c9f934b0
10
.gitmodules
vendored
10
.gitmodules
vendored
@ -1,6 +1,12 @@
|
|||||||
[submodule "dotbot"]
|
[submodule "dotbot"]
|
||||||
path = dotbot
|
path = lib/dotbot
|
||||||
url = https://github.com/anishathalye/dotbot
|
url = https://github.com/anishathalye/dotbot
|
||||||
[submodule "tpm"]
|
[submodule "tpm"]
|
||||||
path = tpm
|
path = lib/tpm
|
||||||
|
url = https://github.com/tmux-plugins/tpm.git
|
||||||
|
[submodule "lib/dotbot"]
|
||||||
|
path = lib/dotbot
|
||||||
|
url = https://github.com/anishathalye/dotbot
|
||||||
|
[submodule "lib/tpm"]
|
||||||
|
path = lib/tpm
|
||||||
url = https://github.com/tmux-plugins/tpm.git
|
url = https://github.com/tmux-plugins/tpm.git
|
||||||
|
60
install.sh
60
install.sh
@ -20,7 +20,7 @@ DOTFILES_REPO="${DOTFILES_REPO:-https://github.com/${REPO_NAME}.git}"
|
|||||||
# Config Names and Locations
|
# Config Names and Locations
|
||||||
TITLE="🧰 ${REPO_NAME} Setup"
|
TITLE="🧰 ${REPO_NAME} Setup"
|
||||||
SYMLINK_FILE="${SYMLINK_FILE:-symlinks.yaml}"
|
SYMLINK_FILE="${SYMLINK_FILE:-symlinks.yaml}"
|
||||||
DOTBOT_DIR="dotbot"
|
DOTBOT_DIR="lib/dotbot"
|
||||||
DOTBOT_BIN="bin/dotbot"
|
DOTBOT_BIN="bin/dotbot"
|
||||||
|
|
||||||
# Set variables for reference
|
# Set variables for reference
|
||||||
@ -48,7 +48,7 @@ fi
|
|||||||
# If set to auto-yes - then don't wait for user reply
|
# If set to auto-yes - then don't wait for user reply
|
||||||
if [[ $PARAMS == *"--auto-yes"* ]]; then
|
if [[ $PARAMS == *"--auto-yes"* ]]; then
|
||||||
PROMPT_TIMEOUT=1
|
PROMPT_TIMEOUT=1
|
||||||
REPLY='Y'
|
AUTO_YES=true
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Function that prints important text in a banner with colored border
|
# Function that prints important text in a banner with colored border
|
||||||
@ -130,8 +130,8 @@ function pre_setup_tasks () {
|
|||||||
|
|
||||||
# Confirm that the user would like to proceed
|
# Confirm that the user would like to proceed
|
||||||
echo -e "\n${CYAN_B}Are you happy to continue? (y/N)${RESET}"
|
echo -e "\n${CYAN_B}Are you happy to continue? (y/N)${RESET}"
|
||||||
read -t $PROMPT_TIMEOUT -n 1 -r
|
read -t $PROMPT_TIMEOUT -n 1 -r ans_start
|
||||||
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
|
if [[ ! $ans_start =~ ^[Yy]$ ]] && [[ $AUTO_YES != true ]] ; then
|
||||||
echo -e "\n${PURPLE}No worries, feel free to come back another time.\nTerminating...${RESET}"
|
echo -e "\n${PURPLE}No worries, feel free to come back another time.\nTerminating...${RESET}"
|
||||||
make_banner "🚧 Installation Aborted" ${YELLOW_B} 1
|
make_banner "🚧 Installation Aborted" ${YELLOW_B} 1
|
||||||
exit 0
|
exit 0
|
||||||
@ -182,9 +182,9 @@ function apply_preferences () {
|
|||||||
|
|
||||||
# If ZSH not the default shell, ask user if they'd like to set it
|
# If ZSH not the default shell, ask user if they'd like to set it
|
||||||
if [[ $SHELL != *"zsh"* ]] && command_exists zsh; then
|
if [[ $SHELL != *"zsh"* ]] && command_exists zsh; then
|
||||||
read -t $PROMPT_TIMEOUT -p "$(echo -e $CYAN_B)Would you like to set ZSH as your default shell? (y/N)" -n 1 -r
|
echo "\n${CYAN_B}Would you like to set ZSH as your default shell? (y/N)${RESET}"
|
||||||
echo
|
read -t $PROMPT_TIMEOUT -n 1 -r ans_zsh
|
||||||
if [[ $REPLY =~ ^[Yy]$ ]]; then
|
if [[ $ans_zsh =~ ^[Yy]$ ]] || [ $AUTO_YES = "true" ] ; then
|
||||||
echo -e "${PURPLE}Setting ZSH as default shell${RESET}"
|
echo -e "${PURPLE}Setting ZSH as default shell${RESET}"
|
||||||
chsh -s $(which zsh) $USER
|
chsh -s $(which zsh) $USER
|
||||||
fi
|
fi
|
||||||
@ -205,11 +205,12 @@ function apply_preferences () {
|
|||||||
/bin/zsh -i -c "antigen update && antigen-apply"
|
/bin/zsh -i -c "antigen update && antigen-apply"
|
||||||
|
|
||||||
# Apply general system, app and OS security preferences (prompt user first)
|
# Apply general system, app and OS security preferences (prompt user first)
|
||||||
read -t $PROMPT_TIMEOUT -p "$(echo -e $CYAN_B)Would you like to apply system preferences? (y/N)" -n 1 -r
|
echo -e "${CYAN_B}Would you like to apply system preferences? (y/N)${RESET}"
|
||||||
if [[ $REPLY =~ ^[Yy]$ ]]; then
|
read -t $PROMPT_TIMEOUT -n 1 -r ans_syspref
|
||||||
|
if [[ $ans_syspref =~ ^[Yy]$ ]] || [ $AUTO_YES = "true" ]; then
|
||||||
if [ "$SYSTEM_TYPE" = "Darwin" ]; then
|
if [ "$SYSTEM_TYPE" = "Darwin" ]; then
|
||||||
echo -e "\n${PURPLE}Applying MacOS system preferences, ensure you've understood before proceeding${RESET}\n"
|
echo -e "\n${PURPLE}Applying MacOS system preferences, ensure you've understood before proceeding${RESET}\n"
|
||||||
macos_settings_dir="$DOTFILES_DIR/system-specific/macos/system-settings"
|
macos_settings_dir="$DOTFILES_DIR/scripts/macos-setup"
|
||||||
for macScript in "macos-security.sh" "macos-preferences.sh" "macos-apps.sh"; do
|
for macScript in "macos-security.sh" "macos-preferences.sh" "macos-apps.sh"; do
|
||||||
chmod +x $macos_settings_dir/$macScript && $macos_settings_dir/$macScript --quick-exit
|
chmod +x $macos_settings_dir/$macScript && $macos_settings_dir/$macScript --quick-exit
|
||||||
done
|
done
|
||||||
@ -221,16 +222,16 @@ function apply_preferences () {
|
|||||||
function intall_macos_packages () {
|
function intall_macos_packages () {
|
||||||
# Homebrew not installed, ask user if they'd like to download it now
|
# Homebrew not installed, ask user if they'd like to download it now
|
||||||
if ! command_exists brew; then
|
if ! command_exists brew; then
|
||||||
read -t $PROMPT_TIMEOUT -p "$(echo -e $CYAN_B)Would you like to install Homebrew? (y/N)" -n 1 -r
|
echo -e "\n${CYAN_B}Would you like to install Homebrew? (y/N)${RESET}"
|
||||||
echo
|
read -t $PROMPT_TIMEOUT -n 1 -r ans_homebrewins
|
||||||
if [[ $REPLY =~ ^[Yy]$ ]]; then
|
if [[ $ans_homebrewins =~ ^[Yy]$ ]] || [ $AUTO_YES = "true" ] ; then
|
||||||
echo -en "🍺 ${PURPLE}Installing Homebrew...${RESET}\n"
|
echo -en "🍺 ${PURPLE}Installing Homebrew...${RESET}\n"
|
||||||
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
|
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
|
||||||
export PATH=/opt/homebrew/bin:$PATH
|
export PATH=/opt/homebrew/bin:$PATH
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
# Update / Install the Homebrew packages in ~/.Brewfile
|
# Update / Install the Homebrew packages in ~/.Brewfile
|
||||||
if command_exists brew && [ -f "$DOTFILES_DIR/installs/Brewfile" ]; then
|
if command_exists brew && [ -f "$DOTFILES_DIR/scripts/installs/Brewfile" ]; then
|
||||||
echo -e "\n${PURPLE}Updating homebrew and packages...${RESET}"
|
echo -e "\n${PURPLE}Updating homebrew and packages...${RESET}"
|
||||||
brew doctor # Check for any app issues
|
brew doctor # Check for any app issues
|
||||||
brew update # Update Brew to latest version
|
brew update # Update Brew to latest version
|
||||||
@ -242,7 +243,7 @@ function intall_macos_packages () {
|
|||||||
echo -e "${PURPLE}Skipping Homebrew as requirements not met${RESET}"
|
echo -e "${PURPLE}Skipping Homebrew as requirements not met${RESET}"
|
||||||
fi
|
fi
|
||||||
# Restore launchpad structure with lporg
|
# Restore launchpad structure with lporg
|
||||||
launchpad_layout="${DOTFILES_DIR}/system-specific/macos/app-configs/launchpad.yml"
|
launchpad_layout="${DOTFILES_DIR}/config/macos/launchpad.yml"
|
||||||
if command_exists lporg && [ -f $launchpad_layout ]; then
|
if command_exists lporg && [ -f $launchpad_layout ]; then
|
||||||
echo -e "${PURPLE}Restoring Launchpad Layout...${RESET}"
|
echo -e "${PURPLE}Restoring Launchpad Layout...${RESET}"
|
||||||
yes "" | lporg load $launchpad_layout
|
yes "" | lporg load $launchpad_layout
|
||||||
@ -252,10 +253,10 @@ function intall_macos_packages () {
|
|||||||
pending_updates=$(softwareupdate -l 2>&1)
|
pending_updates=$(softwareupdate -l 2>&1)
|
||||||
if [[ ! $pending_updates == *"No new software available."* ]]; then
|
if [[ ! $pending_updates == *"No new software available."* ]]; then
|
||||||
echo -e "${PURPLE}A new version of Mac OS is availbile${RESET}"
|
echo -e "${PURPLE}A new version of Mac OS is availbile${RESET}"
|
||||||
read -t $PROMPT_TIMEOUT -p "$(echo -e $CYAN_B)Would you like to update to the latest version of MacOS? (y/N)" -n 1 -r
|
echo -e "${CYAN_B}Would you like to update to the latest version of MacOS? (y/N)${RESET}"
|
||||||
echo -e "${RESET}"
|
read -t $PROMPT_TIMEOUT -n 1 -r ans_macosupdate
|
||||||
if [[ $REPLY =~ ^[Yy]$ ]]; then
|
if [[ $ans_macosupdate =~ ^[Yy]$ ]] || [ $AUTO_YES = "true" ]; then
|
||||||
echo "${PURPLE}Updating MacOS${RESET}"
|
echo -e "${PURPLE}Updating MacOS${RESET}"
|
||||||
softwareupdate -i -a
|
softwareupdate -i -a
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
@ -266,9 +267,9 @@ function intall_macos_packages () {
|
|||||||
|
|
||||||
# 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 () {
|
||||||
read -t $PROMPT_TIMEOUT -p "$(echo -e $CYAN_B)Would you like to install / update system packages? (y/N) " -n 1 -r
|
echo -e "\n${CYAN_B}Would you like to install / update system packages? (y/N)${RESET}"
|
||||||
echo
|
read -t $PROMPT_TIMEOUT -n 1 -r ans_syspackages
|
||||||
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
|
if [[ ! $ans_syspackages =~ ^[Yy]$ ]] && [[ $AUTO_YES != true ]] ; then
|
||||||
echo -e "${PURPLE}Skipping package installs${RESET}"
|
echo -e "${PURPLE}Skipping package installs${RESET}"
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
@ -277,12 +278,12 @@ function install_packages () {
|
|||||||
intall_macos_packages
|
intall_macos_packages
|
||||||
elif [ -f "/etc/arch-release" ]; then
|
elif [ -f "/etc/arch-release" ]; then
|
||||||
# Arch Linux
|
# Arch Linux
|
||||||
arch_pkg_install_script="${DOTFILES_DIR}/installs/arch-pacman.sh"
|
arch_pkg_install_script="${DOTFILES_DIR}/scripts/installs/arch-pacman.sh"
|
||||||
chmod +x $arch_pkg_install_script
|
chmod +x $arch_pkg_install_script
|
||||||
$arch_pkg_install_script $params
|
$arch_pkg_install_script $params
|
||||||
fi
|
fi
|
||||||
# If running in Linux desktop mode, prompt to install desktop apps via Flatpak
|
# If running in Linux desktop mode, prompt to install desktop apps via Flatpak
|
||||||
flatpak_script="${DOTFILES_DIR}/installs/flatpak.sh"
|
flatpak_script="${DOTFILES_DIR}/scripts/installs/flatpak.sh"
|
||||||
if [[ $(uname -s) == "Linux" ]] && [ ! -z $XDG_CURRENT_DESKTOP ] && [ -f $flatpak_script ]; then
|
if [[ $(uname -s) == "Linux" ]] && [ ! -z $XDG_CURRENT_DESKTOP ] && [ -f $flatpak_script ]; then
|
||||||
chmod +x $flatpak_script
|
chmod +x $flatpak_script
|
||||||
$flatpak_script
|
$flatpak_script
|
||||||
@ -294,7 +295,7 @@ function finishing_up () {
|
|||||||
# Update source to ZSH entry point
|
# Update source to ZSH entry point
|
||||||
source "${HOME}/.zshenv"
|
source "${HOME}/.zshenv"
|
||||||
|
|
||||||
# Print success message, and time taken
|
# Calculate time taken
|
||||||
total_time=$((`date +%s`-START_TIME))
|
total_time=$((`date +%s`-START_TIME))
|
||||||
if [[ $total_time -gt 60 ]]; then
|
if [[ $total_time -gt 60 ]]; then
|
||||||
total_time="$(($total_time/60)) minutes"
|
total_time="$(($total_time/60)) minutes"
|
||||||
@ -302,6 +303,7 @@ function finishing_up () {
|
|||||||
total_time="${total_time} seconds"
|
total_time="${total_time} seconds"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Print success msg and pretty picture
|
||||||
make_banner "✨ Dotfiles configured succesfully in $total_time" ${GREEN_B} 1
|
make_banner "✨ Dotfiles configured succesfully in $total_time" ${GREEN_B} 1
|
||||||
echo -e "\033[0;92m .--.\n |o_o |\n |:_/ |\n // \
|
echo -e "\033[0;92m .--.\n |o_o |\n |:_/ |\n // \
|
||||||
\ \\ \n (| | ) \n /'\_ _/\`\\ \n \\___)=(___/\n"
|
\ \\ \n (| | ) \n /'\_ _/\`\\ \n \\___)=(___/\n"
|
||||||
@ -309,9 +311,15 @@ function finishing_up () {
|
|||||||
# Refresh ZSH sesssion
|
# Refresh ZSH sesssion
|
||||||
SKIP_WELCOME=true || exec zsh
|
SKIP_WELCOME=true || exec zsh
|
||||||
|
|
||||||
# Exit script with success code
|
# Show press any key to exit
|
||||||
echo -e "${CYAN_B}Press any key to exit.${RESET}\n"
|
echo -e "${CYAN_B}Press any key to exit.${RESET}\n"
|
||||||
read -t $PROMPT_TIMEOUT -n 1 -s
|
read -t $PROMPT_TIMEOUT -n 1 -s
|
||||||
|
|
||||||
|
# Unset re-used variables
|
||||||
|
unset PROMPT_TIMEOUT
|
||||||
|
unset AUTO_YES
|
||||||
|
|
||||||
|
# Bye
|
||||||
exit 0
|
exit 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
1
lib/dotbot
Submodule
1
lib/dotbot
Submodule
@ -0,0 +1 @@
|
|||||||
|
Subproject commit d2f76a25933f97cd37ef94e3bf9c134b9c55a02a
|
1
lib/tpm
Submodule
1
lib/tpm
Submodule
@ -0,0 +1 @@
|
|||||||
|
Subproject commit b699a7e01c253ffb7818b02d62bce24190ec1019
|
Loading…
x
Reference in New Issue
Block a user