diff --git a/defaults.sh b/defaults.sh index f404165b..dd82a3c1 100644 --- a/defaults.sh +++ b/defaults.sh @@ -1,3 +1,5 @@ +#!/bin/bash /bin/zsh + ########################################################## # conventions ########################################################## @@ -94,11 +96,11 @@ OX_OXIDE[bkcv]="${OX_BACKUP}/app/verge.yaml" # vsk: vscode's keybindings.json # vss_: vscode's snippets folder declare -a OX_EXPORT_FILE -OX_EXPORT_FILE=(ox) +export OX_EXPORT_FILE=(ox) # files to be import from backup folder declare -a OX_IMPORT_FILE -OX_IMPORT_FILE=(ox) +export OX_IMPORT_FILE=(ox) ########################################################## # git settings @@ -242,7 +244,7 @@ export OX_STARTUP=1 startup() { # start directory - cd ${HOME}/Desktop + cd ${HOME}/Desktop || exit } ########################################################## diff --git a/install.sh b/install.sh index e7168226..691d90b4 100644 --- a/install.sh +++ b/install.sh @@ -1,3 +1,4 @@ +#!/bin/bash /bin/zsh export OXIDIZER=${OXIDIZER:-"${HOME}/oxidizer"} printf "📦 Installing Oxidizer\n" @@ -94,7 +95,7 @@ case ${SHELL} in export OX_SHELL=${HOME}/.zshrc ;; *bash) - if [[ $(bash --version | head -n1 | cut -d' ' -f4 | cut -d'.' -f1) < 5 ]]; then + if [[ $(bash --version | head -n1 | cut -d' ' -f4 | cut -d'.' -f1) -lt 5 ]]; then printf "📦 Installing latest Bash...\n" brew install bash bash-completion fi @@ -107,21 +108,21 @@ esac # Inject Oxidizer ################################################### -printf "⚙️ Adding Oxidizer into ${OX_SHELL}...\n" +printf '⚙️ Adding Oxidizer into %s...\n' ${OX_SHELL} echo "# Oxidizer" >>${OX_SHELL} if [[ -z ${OXIDIZER} ]]; then OXIDIZER="${HOME}/oxidizer" - append_str='export OXIDIZER='"${OXIDIZER}"' && source '"${OXIDIZER}"'/oxidizer.sh' + append_str='export OXIDIZER='${OXIDIZER}' && source '${OXIDIZER}'/oxidizer.sh' else - append_str='source '"${OXIDIZER}"'/oxidizer.sh' + append_str='source '${OXIDIZER}'/oxidizer.sh' fi -echo "${append_str}" >>"${OX_SHELL}" +echo "${append_str}" >>${OX_SHELL} printf "⚙️ Adding Custom settings..." -cp ${OXIDIZER}/defaults.sh ${OXIDIZER}/custom.sh +cp ${OXIDIZER}/defaults.sh "${OXIDIZER}/"custom.sh # load zoxide sed -i.bak "s|.* OX_STARTUP=.*|export OX_STARTUP=1|" ${OXIDIZER}/custom.sh diff --git a/oxidizer.sh b/oxidizer.sh index e5464dba..5e3942d3 100644 --- a/oxidizer.sh +++ b/oxidizer.sh @@ -1,3 +1,4 @@ +#!/bin/bash /bin/zsh export OXIDIZER=${OXIDIZER:-"${HOME}/oxidizer"} ########################################################## @@ -53,27 +54,27 @@ declare -A OX_OXIDE # load system plugin case $(uname -a) in *Darwin*) - . ${OX_OXYGEN[oxpm]} + . "${OX_OXYGEN[oxpm]}" ;; *Ubuntu* | *Debian* | *WSL*) - . ${OX_OXYGEN[oxpd]} + . "${OX_OXYGEN[oxpd]}" ;; esac # load custom plugins declare -a OX_PLUGINS -. ${OX_ELEMENT[ox]} +. "${OX_ELEMENT[ox]}" -for plugin in ${OX_PLUGINS[@]}; do - . ${OX_OXYGEN[$plugin]} +for plugin in "${OX_PLUGINS[@]}"; do + . "${OX_OXYGEN[$plugin]}" done declare -a OX_CORE_PLUGINS OX_CORE_PLUGINS=(oxpb oxput oxppu) # load core plugins -for core_plugin in ${OX_CORE_PLUGINS[@]}; do +for core_plugin in "${OX_CORE_PLUGINS[@]}"; do . ${OX_OXYGEN[$core_plugin]} done @@ -90,8 +91,8 @@ case ${SHELL} in OX_OXIDE[bkzs]=${OX_BACKUP}/shell/.zshrc ;; *bash) - [bs]=${HOME}/.bash_profile - [bshst]=${HOME}/.bash_history + OX_OXIDE[bs]=${HOME}/.bash_profile + OX_OXIDE[bshst]=${HOME}/.bash_history OX_OXIDE[bkbs]=${OX_BACKUP}/shell/.bash_profile ;; esac @@ -104,34 +105,34 @@ OX_OXIDE[bkvi]=${OX_BACKUP}/shell/.vimrc # update all packages up_all() { - for obj in ${OX_UPDATE_PROG[@]}; do - eval up_$obj + for obj in "${OX_UPDATE_PROG[@]}"; do + eval "up_$obj" done } # backup package lists back_all() { - for obj in ${OX_BACKUP_PROG[@]}; do - eval back_$obj + for obj in "${OX_BACKUP_PROG[@]}"; do + eval "back_$obj" done } # export configurations epall() { - for obj in ${OX_EXPORT_FILE[@]}; do - epf $obj + for obj in "${OX_EXPORT_FILE[@]}"; do + epf "$obj" done } # import configurations ipall() { - for obj in ${OX_IMPORT_FILE[@]}; do - ipf $obj + for obj in "${OX_IMPORT_FILE[@]}"; do + ipf "$obj" done } iiox() { - echo "Installing Required packages...\n" + print "Installing Required packages...\n" for pkg in $(cat ${OXIDIZER}/defaults/Brewfile.txt); do case $pkg in ripgrep) @@ -158,28 +159,28 @@ iiox() { # update Oxidizer upox() { - cd ${OXIDIZER} - echo "Updating Oxidizer...\n" + cd ${OXIDIZER} || exit + print "Updating Oxidizer...\n" git fetch origin master git reset --hard origin/master if [ ! -d ${OXIDIZER}/oxplugins-zsh ]; then - echo "\n\nCloning Oxidizer Plugins...\n" + print "\n\nCloning Oxidizer Plugins...\n" git clone --depth=1 https://github.com/ivaquero/oxplugins-zsh.git else - echo "\n\nUpdating Oxidizer Plugins...\n" - cd ${OXIDIZER}/oxplugins-zsh + print "\n\nUpdating Oxidizer Plugins...\n" + cd ${OXIDIZER}/oxplugins-zsh || exit git fetch origin main git reset --hard origin/main fi - cd ${OXIDIZER} - local ox_change=$(git diff defaults.sh) - if [ -n $ox_change ]; then - echo "\n\nDefaults changed, don't forget to update your custom.sh accordingly...\n" - echo "Compare the difference using 'edf oxd'" + cd ${OXIDIZER} || exit + ox_change=$(git diff defaults.sh) + if [ -n "$ox_change" ]; then + print "\n\nDefaults changed, don't forget to update your custom.sh accordingly...\n" + print "Compare the difference using 'edf oxd'" fi - cd ${HOME} + cd ${HOME} || exit } ##########################################################