From 86dcb2bc059a4482a366a5d16e51ed53fced2757 Mon Sep 17 00:00:00 2001 From: Yasmin Teles Date: Fri, 5 Apr 2024 21:06:28 -0300 Subject: [PATCH] fix: print colorful messages --- brew/Brewfile | 2 +- install.sh | 48 +++++++++++++++++++++++++++++++++++------------- uninstall.sh | 30 +++++++++++++++++++++++------- 3 files changed, 59 insertions(+), 21 deletions(-) diff --git a/brew/Brewfile b/brew/Brewfile index 66c2585..37b6fb8 100644 --- a/brew/Brewfile +++ b/brew/Brewfile @@ -42,7 +42,7 @@ brew "pyenv" cask "visual-studio-code" cask "firefox-developer-edition" cask "google-chrome" -cask "beekeeper-studio" +# cask "beekeeper-studio" cask "figma" cask "postman" diff --git a/install.sh b/install.sh index 79ae7ad..b6e7b56 100644 --- a/install.sh +++ b/install.sh @@ -7,23 +7,46 @@ set -e TOTAL_STEPS=7 STEP=1 function step_msg { - printf "\n\033[36;1m[%s/%s] %s...\033[0m\n" "$STEP" "$TOTAL_STEPS" "$1"; + printf "\033[36;1m[%s/%s] %s...\033[0m\n" "$STEP" "$TOTAL_STEPS" "$1"; ((STEP++)) } function title_msg { - printf "\n%s\n" "$1"; + printf "\033[35;1m%s\033[0m\n\n" "$1"; } +function success_msg { + printf "\n\033[32;1m%s\n\n" "$1"; +} + +function error_msg { + printf "\n\033[31;1m%s\n\n" "$1"; +} + + +# -- Getting Started ---------------------------------------------------------- + +printf "\n" +echo "██████╗ ██████╗ ████████╗███████╗██╗██╗ ███████╗███████╗" +echo "██╔══██╗██╔═══██╗╚══██╔══╝██╔════╝██║██║ ██╔════╝██╔════╝" +echo "██║ ██║██║ ██║ ██║ █████╗ ██║██║ █████╗ ███████╗" +echo "██║ ██║██║ ██║ ██║ ██╔══╝ ██║██║ ██╔══╝ ╚════██║" +echo "██████╔╝╚██████╔╝ ██║ ██║ ██║███████╗███████╗███████║" +echo "╚═════╝ ╚═════╝ ╚═╝ ╚═╝ ╚═╝╚══════╝╚══════╝╚══════╝" +printf "\n" + +title_msg "This script will install your workspace." + # -- Get some information ----------------------------------------------------- if [ "$CI" = true ] ; then GIT_EMAIL=name@mail.com else printf "Please enter some information.\n" read -r -p "What is your email? " GIT_EMAIL + printf "\n" fi -title_msg "Please wait! It will configure your environment." +title_msg "Please wait! It will configure your workspace." # -- Project folder ----------------------------------------------------------- step_msg "Creating the Projects folder" @@ -31,11 +54,11 @@ mkdir ~/Projects # -- Dependencies ------------------------------------------------------------- step_msg "Installing dependencies" -brew install git stow +brew install git stow >/dev/null # -- Dotfiles ----------------------------------------------------------------- step_msg "Setting up dotfiles" -git clone https://github.com/YasminTeles/dotfiles.git ~/.dotfiles +git clone https://github.com/YasminTeles/dotfiles.git ~/.dotfiles >/dev/null rm -rf ~/.gitconfig cd ~/.dotfiles @@ -43,11 +66,11 @@ stow --dotfiles git ssh brew # -- Productivity Apps --------------------------------------------------------- step_msg "Installing the productivity apps" -brew bundle install --file=~/Brewfile +brew bundle install --file=~/Brewfile >/dev/null # -- Oh My Zsh ----------------------------------------------------------------- step_msg "Installing the Oh My Zsh" -sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" "" --unattended +sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" "" --unattended >/dev/null rm -rf ~/.zshrc stow --dotfiles zsh echo "My current shell is $SHELL." @@ -59,16 +82,15 @@ git config --global user.email "$GIT_EMAIL" # -- SSH Key ------------------------------------------------------------------- step_msg "Generating a new SSH key" rm -rf ~/.ssh/id_ed25519 ~/.ssh/id_ed25519.pub -ssh-keygen -t ed25519 -C "$GIT_EMAIL" -f ~/.ssh/id_ed25519 -q -N "" -eval "$(ssh-agent -s)" -ssh-add ~/.ssh/id_ed25519 +ssh-keygen -t ed25519 -C "$GIT_EMAIL" -f ~/.ssh/id_ed25519 -q -N "" >/dev/null +eval "$(ssh-agent -s)" >/dev/null +ssh-add ~/.ssh/id_ed25519 >/dev/null # -- Next Steps ---------------------------------------------------------------- -echo -e "\n" title_msg "Next steps:" echo -e "- Run \033[1mmake ssh\033[0m to copy your SSH public Key and past it into your GitHub or GitLab account." echo -e "- Run \033[1mmake zsh\033[0m to change your shell to zsh mode." # -- Happy end ----------------------------------------------------------------- -printf "\n\nSuccess: Everything is ready!" -printf "\nHave a nice day!\n" +success_msg "Everything is ready!" +title_msg "Have a nice day!" diff --git a/uninstall.sh b/uninstall.sh index 31cc176..a2e7264 100644 --- a/uninstall.sh +++ b/uninstall.sh @@ -7,20 +7,35 @@ set -e TOTAL_STEPS=5 STEP=1 function step_msg { - printf "\n\033[36;1m[%s/%s] %s...\033[0m\n" "$STEP" "$TOTAL_STEPS" "$1"; + printf "\033[36;1m[%s/%s] %s...\033[0m\n" "$STEP" "$TOTAL_STEPS" "$1"; ((STEP++)) } -echo "This script will remove all configurations of the environment." +function title_msg { + printf "\033[35;1m%s\033[0m\n\n" "$1"; +} + +function success_msg { + printf "\n\033[32;1m%s\n\n" "$1"; +} + +function error_msg { + printf "\n\033[31;1m%s\n\n" "$1"; +} + + +# -- Getting Started ---------------------------------------------------------- +title_msg "This script will remove your workspace." if [ ! "$CI" ] then read -r -p "Are you sure you want to proceed? (y/n) " CONFIRM + printf "\n" fi if [[ "$CI" || "$CONFIRM" == [yY] || "$CONFIRM" == [yY][eE][sS] ]] then - printf "\nPlease wait! Proceeding with the removal of all configurations...\n" + title_msg "Please wait! Proceeding to remove your workspace..." # -- Symlinks ---------------------------------------------------------------- step_msg "Removing all symlinks" @@ -36,7 +51,8 @@ then # -- Productivity Apps ------------------------------------------------------- step_msg "Removing all productivity apps" - brew uninstall --force "$(brew list)" + # shellcheck disable=SC2046 + brew uninstall --force $(brew list) > /dev/null rm -rf ~/.oh-my-zsh rm -rf ~/Brewfile.lock.json @@ -45,11 +61,11 @@ then rm -rf ~/.dotfiles # -- Happy end ----------------------------------------------------------------- - printf "\nAll configurations have been removed." + success_msg "The workspace have been removed." else - printf "\nOperation cancelled." + error_msg "Operation cancelled." fi -printf "\nHave a nice day!\n" +title_msg "Have a nice day!"