From 880cfd00f8773effa4b85046e1370398d0548c64 Mon Sep 17 00:00:00 2001 From: Xmetalfanx Date: Fri, 17 Nov 2023 14:49:07 -0500 Subject: [PATCH] Various Additions - Added fancy_message script (thanks to https://github.com/wimpysworld/deb-get) - Added function to check if zsh is installed before adding additions (may need to call this more) - Added Zap Plugin Manager --- components/general.sh | 41 ++++++++++++++++++++++++++++++++++++++--- components/plugins.sh | 10 ++++++++++ setupZSH.sh | 13 ++++++++----- 3 files changed, 56 insertions(+), 8 deletions(-) diff --git a/components/general.sh b/components/general.sh index 3b63c9c..007baa5 100644 --- a/components/general.sh +++ b/components/general.sh @@ -7,10 +7,40 @@ function userPrompt() { read -rp "Press Any Key to continue" } -# function checkLastCommandStatus() { +function checkLastCommandStatus() { -# [ $? == "0" ] && fancy_message info "${1}" || fancy_message error "${2}" -# } + [ $? == "0" ] && fancy_message info "${1}" && result="pass" || fancy_message error "${2}" || result="fail" +} + +function fancy_message() { + + # can i do the && thing in place of this if statement, here? + if [ -z "${1}" ] || [ -z "${2}" ]; then + return + fi + + local RED="\e[31m" + local GREEN="\e[32m" + local YELLOW="\e[33m" + local MAGENTA="\e[35m" + local RESET="\e[0m" + local MESSAGE_TYPE="" + local MESSAGE="" + MESSAGE_TYPE="${1}" + MESSAGE="${2}" + + case ${MESSAGE_TYPE} in + info) echo -e " [${GREEN}-${RESET}] ${MESSAGE}";; + action) echo -e " [${YELLOW}*${RESET}] ${MESSAGE}";; + # SHOULD THIS BE BACKWARS WITH THE ? AT THE END? + question) echo -e " [${YELLOW}?${RESET}] ${MESSAGE}";; + recommend) echo -e " [${blue}!${RESET}] ${MESSAGE}";; + # for warnigs that dont need a "Warning: " addition + lwarn) echo -e " [${RED}*${RESET}] ${MESSAGE}";; + warn) echo -e " [${RED}*${RESET}] WARNING! ${MESSAGE}";; + error) echo -e " [${RED}!${RESET}] ERROR! ${MESSAGE}";; + esac +} @@ -148,6 +178,11 @@ function downloadOhMyZSH(){ echo "zshCounter=${zshCounter}" > ${settingsFile} +} + +function check-if-zsh-is-installed() { + zsh --version && checkLastCommandStatus "zsh is installed" "zsh is not installed yet" + [ "${result}" == "fail" ] && clear && echo "zsh is not installed yet, please install zsh shell first" && selectSetupType } \ No newline at end of file diff --git a/components/plugins.sh b/components/plugins.sh index 0b3beee..d54c377 100644 --- a/components/plugins.sh +++ b/components/plugins.sh @@ -173,3 +173,13 @@ function coloredManPages() { echo -e "colored-man-pages from ${repoName} repo Added\v" } + +function installZapPluginManager() { + + # note to self: Official instructions, below + + check-if-zsh-is-installed + + fancy_message action "Installing Zap Plugin Manager for zsh" && zsh <(curl -s https://raw.githubusercontent.com/zap-zsh/zap/master/install.zsh) --branch release-v1 && fancy_message info "Zap Plugin Manager now installed, a restart of your terminal maybe needed" || echo "ZSH Shell not installed, yet" || userPrompt + +} \ No newline at end of file diff --git a/setupZSH.sh b/setupZSH.sh index 7f4a40b..2e5ac43 100644 --- a/setupZSH.sh +++ b/setupZSH.sh @@ -16,14 +16,15 @@ clearZSHRC function selectSetupType() { echo -e "Brief Description + ZapPluginManager - Complete - Adds OhmyZsh and zsh-user plugins manually, theming, tweaks and aliases NonTheme Complete (NT) - SAME as complete, expect NO THEMING Medium - Adds theming, tweaks and aliases Slim - Adds tweaks and aliases -\vDo you want the Slim, Medium or Complete setup? +\vDo you want the Slim, Medium or Complete setup or do you want to install the Zap Plugin Manager? " - read -rp "(s/m/nt/c)" setupTypeSelection + read -rp "(z/s/m/nt/c)" setupTypeSelection case $setupTypeSelection in @@ -47,14 +48,16 @@ function selectSetupType() { metaAliasAndOthers ;; - [tT]) clear + [tT]) clear ohmyzshPlugins #zshUserPlugins && zshPluginAutoComplete && coloredManPages && userPrompt #themeChooser #metaAliasAndOthers ;; - - *) echo -e "invalid selection" && sleep 1 && selectSetupType ;; + + [zZ]) installZapPluginManager ;; + + *) echo -e "invalid selection" && sleep 1 && selectSetupType ;; esac