Skip to content

Commit

Permalink
Release 2.8.4
Browse files Browse the repository at this point in the history
refactor(zshbop): Refactoring and clean up of old functions
refactor(zshbop): More refactoring of code, renaming and removing of unused code.
fix(zshbop): typo :(
improvement(zshbop): Improved zshbop branch command
feat(git): Created function gl for git log
refactor(zshbop): Changing variable ZSHBOP_CUSTOM to ZSHBOP_CUSTOM_CONFIG
fix(zshbop): Major bug with loading zshbop, retrieving version number  and setting $ZSHBOP_ROOT variable
  • Loading branch information
jordantrizz committed May 23, 2023
1 parent 7eef735 commit ac1db4f
Show file tree
Hide file tree
Showing 9 changed files with 50 additions and 83 deletions.
6 changes: 6 additions & 0 deletions cmds/cmds-git.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -195,4 +195,10 @@ function gpa {

_loading "Applying patch $1"
git apply $1
}

# -- gl - Git log
help_git[gl]="Git log"
function gl {
git log
}
3 changes: 1 addition & 2 deletions cmds/cmds-proxmox.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -364,8 +364,7 @@ function _proxmox_createtemp () {
# -- proxmox_info
_proxmox_info () {
_debug_all
_debug_all
_banner_green "Proxmox instance infornation"
_loading "Proxmox instance infornation"
echo "----------------------------"
echo "Version: $(pveversion)"
echo "Storage: $(pvesm status -content images | awk {'if (NR!=1) print $1 '})"
Expand Down
6 changes: 3 additions & 3 deletions cmds/cmds-software.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -146,11 +146,11 @@ gp-apt () {
# -- php-install
help_software[php-install]="One liner for PHP package install"
php-install () {
_banner_green "For Remi on CentOS"
_loading "For Remi on CentOS"
echo "yum install php74-{php-recode,php-snmp,php-pecl-apcu,php-ldap,php-pecl-memcached,php-imap,php-odbc,php-xmlrpc,php-intl,php-process,php-pecl-igbinary,php-pear,php-pecl-imagick,php-tidy,php-pspell,php-pdo,php-pecl-mcrypt,php-soap,php-mbstring,php-mysqli}"
_banner_green "For Ubuntu"
_loading "For Ubuntu"
echo "apt-get install php74-{mbstring,mysql}"
_banner_green "For Ubuntu and Litespeed"
_loading "For Ubuntu and Litespeed"
echo "apt-get install lsphp81-{recode,snmp,pecl-apcu,ldap,pecl-memcached,imap,odbc,xmlrpc,intl,process,pecl-igbinary,pear,pecl-imagick,tidy,pspell,pdo,pecl-mcrypt,soap,mbstring,mysqli}"
}

Expand Down
8 changes: 4 additions & 4 deletions cmds/cmds-system.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@ alias disk="lsblk"
# -- sysinfo
help_system[sysinfo]='Get system information'
sysinfo () {
_banner_green "CPU"
_loading "CPU"
cpu
_banner_green "Memory"
_loading "Memory"
mem
_banner_green "Disk"
_loading "Disk"
disk
_banner_green "Short Format"
_loading "Short Format"
}

# -- sysinfo
Expand Down
2 changes: 1 addition & 1 deletion lib/functions-core.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ _loading3 () { echo " - $fg[bright-grey]${@}${RSC}" | tee >(sed 's/^/[LOAD] /' >
_loading4 () { echo " -- $fg[bright-grey]${@}${RSC}" | tee >(sed 's/^/[LOAD] /' >> ${SCRIPT_LOG}) }
alias _loading_grey=_loading2

COLOR_FUNCTIONS=(_error _warning _success _noticebg _noticefg _banner_red _banner_green _banner_grey _loading _loading2 _loading3 _loading4)
COLOR_FUNCTIONS=(_error _warning _success _noticebg _noticefg _banner_red _banner_green _banner_grey _loading _loading2 _loading3 _loading4)

# -- Text Colors
_grey () { echo "$bg[bright-gray]$fg[black] $@ ${RSC}" }
Expand Down
94 changes: 30 additions & 64 deletions lib/functions.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ alias omz-plugins='escho "OMZ Plugins $OMZ_PLUGINS"'
# --
# -- clear cache for various tools
# -------------------------------------
help_zshbop[cc]='Clear cache for antigen + more'
alias cc="zshbop_cacheclear"
zshbop_cacheclear () {
help_zshbop[cache-clear]='Clear cache for antigen + more'
alias cc="zshbop_cache-clear"
zshbop_cache-clear () {
_log "${funcstack[1]}:start"
_loading "**** Start ZSH cache clear ****"
_loading2 "Clearing plugin manager cache"
Expand All @@ -53,10 +53,10 @@ zshbop_cacheclear () {
echo ""
}

# -- zshbop_scc
alias scc="zshbop_scc"
help_zshbop[zshbop_scc]='Clear everything, including zsh autocompletion'
zshbop_scc () {
# -- cache-clear-super
alias scc="cache-clear-super"
help_zshbop[cache-clear-super]='Clear everything, including zsh autocompletion'
zshbop_cache-clear-super () {
_loading "Clearing rm ~/.zcompdump*"
rm -f ~/.zcompdump*
}
Expand All @@ -72,32 +72,21 @@ zshbop_reload () {
if [[ $1 == "-q" ]]; then
_loading "Quick reload of zshbop"
export RUN_REPORT=0
zshbop_cacheclear
zshbop_cache-clear
source $ZBR/lib/*.zsh
source $ZBR/cmds/*.zsh
_loading "Load zshbop custom config"
zshbop_load_custom
zshbop_custom-load
else
_loading "Reloading zshbop"
export RUN_REPORT=1
export ZSHBOP_RELOAD=1
zshbop_cacheclear
zshbop_cache-clear
_log "Running exec zsh"
exec zsh
fi
}

# ---------------------
# -- zshbop_startup ()
# --
# -- Run zshbop startup
# ---------------------
help_zshbop[startup]='Run zshbop startup'
zshbop_startup () {
_debug_all
init_motd
}

# --------------------------
# -- zshbop_branch ($branch)
# --
Expand All @@ -107,11 +96,17 @@ help_zshbop[branch]='Run main or dev branch of zshbop'
zshbop_branch () {
_debug_all
if [[ -n $2 ]]; then
echo " -- Switching to $2 branch"
_loading " -- Switching to $2 branch"
GIT_CHECKOUT=$(git --git-dir=$ZSHBOP_ROOT/.git --work-tree=$ZSHBOP_ROOT checkout $2)
if [[ $? -ge "1" ]]; then
_error "Branch doesn't seem to exist"
fi
_debug "GIT_CHECKOUT: $GIT_CHECKOUT"
if [[ $? -eq "0" ]]; then
_success " -- Switched to $2 branch, pulling latest changes"
git pull
else
_error " -- Failed to switch to $2 branch"
fi
elif [[ $? -ge "1" ]]; then
_error "Branch doesn't seem to exist"
elif [ -z $2 ]; then
echo " -- zshbop: $ZSHBOP_ROOT branch: $ZSHBOP_BRANCH ----"
echo " -- To switch branch type 'zshbop branch dev' or 'zshbop branch main'"
Expand Down Expand Up @@ -195,11 +190,6 @@ zshbop_update () {
git --git-dir=$ZSHBOP_ROOT/.git --work-tree=$ZSHBOP_ROOT pull
fi

# Check if .zshrc is out of date - Called from script directly versus cached functions
_loading2 "Previous version check"
source $ZBR/lib/functions.zsh
zshbop_previous-version-check

# Update repos
repos update

Expand Down Expand Up @@ -235,36 +225,13 @@ zshbop_update () {
_banner_yellow "**** END UPDATING ZSHBOP ****"
echo ""
}
# -----------------------------------
# -- zshbop_pervious-version-check ()
# -----------------------------------
help_zshbop[previous-version-check]='Checking if \$HOME/.zshrc is pre v1.1.3 and replacing.'
zshbop_previous-version-check () {
_debug_all

# Replacing .zshrc previous to v1.1.2 256bb9511533e9697f639821ba63adb9
_debug " -- Current $HOME/.zshrc md5 is - $ZSHBOP_HOME_MD5"
_debug " -- zshbop .zshrc md5 is - $ZSHBOP_LATEST_MD5"
if [[ "$ZSHBOP_HOME_MD5" != "$ZSHBOP_LATEST_MD5" ]]; then
_error "-- Found old .zshrc"
_notice "-- Replacing $HOME/.zshrc"
cp $ZSHBOP_ROOT/.zshrc $HOME/.zshrc
else
_debug " -- No need to fix .zshrc"
fi
}

# --------------------
# -- zshbop_version ()
# --------------------
help_zshbop[version]='Get version information'
zshbop_version () {
echo "zshbop Version: ${fg[green]}${ZSHBOP_VERSION}/${fg[black]}${bg[cyan]}${ZSHBOP_BRANCH}${reset_color}"
}

help_zshbop[commit]='Get commit information'
zshbop_commit () {
echo "zshbop Commit: ${fg[black]}${bg[cyan]}${ZSHBOP_BRANCH}${reset_color}${fg[green]}/$ZSHBOP_COMMIT${RSC}"
echo "zshbop Version: ${fg[green]}${ZSHBOP_VERSION}/${fg[black]}${bg[cyan]}${ZSHBOP_BRANCH}${reset_color}/$ZSHBOP_COMMIT${RSC}"
}

# ------------------
Expand Down Expand Up @@ -339,26 +306,25 @@ zshbop_colors () {
# ----------------
help_zshbop[custom]='Custom zshbop configuration'
zshbop_custom () {
_banner_green "Instructions on how to utilize custom zshbop configuration."
_loading "Instructions on how to utilize custom zshbop configuration."
echo " - Create a file called .zshbop.custom in your /$HOME directory"
echo " - Done!"
echo " - You can also copy the .zshbop.custom file within this repository as a template"
}

# ---------------------
# -- zshbop_load_custom
# -- zshbop_custom-load
# ---------------------
help_zshbop[load_custom]='Load zshbop custom config'
zshbop_load_custom () {
help_zshbop[custom-load]='Load zshbop custom config'
zshbop_custom-load () {
if [[ $1 == "-q" ]]; then
[[ -f $HOME/.zshbop.conf ]] && source $HOME/.zshbop.conf
else
# -- Check for $HOME/.zshbop.config, load last to allow overwritten core functions
_log "Checking for $HOME/.zshbop.conf"
if [[ -f $HOME/.zshbop.conf ]]; then
ZSHBOP_CUSTOM="$HOME/.zshbop.conf"
_loading3 "Loaded custom zshbop config at $ZSHBOP_CUSTOM"
source $ZSHBOP_CUSTOM
ZSHBOP_CUSTOM_CFG="$HOME/.zshbop.conf"
_loading3 "Loaded custom zshbop config at $ZSHBOP_CUSTOM_CFG"
source $ZSHBOP_CUSTOM_CFG
else
_warning "No custom zshbop config found. Type zshbop custom for more information"
fi
Expand Down Expand Up @@ -437,8 +403,8 @@ zshbop_report () {
# ==============================================
# -- system_check - check usualy system stuff
# ==============================================
help_zshbop[systemcheck]='Print out errors and warnings'
zshbop_systemcheck () {
help_zshbop[check-system]='Print out errors and warnings'
zshbop_check-system () {
# -- start
_debug_all

Expand Down
4 changes: 2 additions & 2 deletions lib/init.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,7 @@ init_motd () {
echo ""

_loading "System check on $MACHINE_OS"
zshbop_systemcheck
zshbop_check-system
init_check_vm
echo ""

Expand Down Expand Up @@ -584,7 +584,7 @@ function init_zshbop () {
init-app-config # -- Common application configuration
init_omz_plugins # -- Init OhMyZSH plugins
init_p10k # -- Init powerlevel10k
zshbop_load_custom # -- Init custom zshbop
zshbop_custom-load # -- Init custom zshbop
init_os # -- Init os defaults # TODO Needs to be refactored
init_app_config # -- Init config
init_zsh_sweep # -- Init zsh-sweep if installed
Expand Down
2 changes: 1 addition & 1 deletion version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.8.3
2.8.4
8 changes: 2 additions & 6 deletions zshbop.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@

# -- Potential zshbop paths, including old zsh path, left over from .zshrc removal
ZSHBOP_PATHS=("$HOME/zshbop" "$HOME/zsh" "$HOME/git/zshbop" "$HOME/git/zsh" "/usr/local/sbin/zshbop" "/usr/local/sbin/zsh")
export ZSHBOP_ROOT=${0:a:h}
export ZSHBOP_VERSION=$(cat ${ZSHBOP_ROOT}/version) # -- Current version installed

# ---------------------------
# ---- Variables
Expand Down Expand Up @@ -50,7 +52,6 @@ export ZSHBOP_NAME="zshbop" # -- Current zshbop branch
export SCRIPT_DIR=${0:a:h} # -- Current working directory
export ZSHBOP_CACHE_DIR="${HOME}/.zshbop_cache"
export ZSHBOP_PLUGIN_MANAGER="init_antidote"
export ZSHBOP_VERSION=$(<$ZSHBOP_ROOT/version) # -- Current version installed
export ZSH_ROOT="${ZSHBOP_ROOT}" # -- Converting from ZSH_ROOT to ZSHBOP_ROOT
export ZBR="${ZSHBOP_ROOT}" # -- Short hand $ZSHBOP_ROOT
export KB="${ZSHBOP_ROOT}/kb"
Expand Down Expand Up @@ -181,11 +182,6 @@ source ${ZSHBOP_ROOT}/lib/kb.zsh # -- Built in Knolwedge Base

############################################################

# -- zshbop.config
if [[ -f $HOME/.zshbop.config ]]; then
source $HOME/.zshbop.config
fi

# -- Check for old bits
zshbop_cleanup

Expand Down

0 comments on commit ac1db4f

Please sign in to comment.