Skip to content

Commit

Permalink
chore: 💄 update styles based on shellcheck
Browse files Browse the repository at this point in the history
  • Loading branch information
ivaquero committed Aug 11, 2023
1 parent 5efcb1f commit 17da41e
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 37 deletions.
8 changes: 5 additions & 3 deletions defaults.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/bin/bash /bin/zsh

##########################################################
# conventions
##########################################################
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -242,7 +244,7 @@ export OX_STARTUP=1

startup() {
# start directory
cd ${HOME}/Desktop
cd ${HOME}/Desktop || exit
}

##########################################################
Expand Down
13 changes: 7 additions & 6 deletions install.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#!/bin/bash /bin/zsh
export OXIDIZER=${OXIDIZER:-"${HOME}/oxidizer"}
printf "📦 Installing Oxidizer\n"

Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
57 changes: 29 additions & 28 deletions oxidizer.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#!/bin/bash /bin/zsh
export OXIDIZER=${OXIDIZER:-"${HOME}/oxidizer"}

##########################################################
Expand Down Expand Up @@ -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

Expand All @@ -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
Expand All @@ -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)
Expand All @@ -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
}

##########################################################
Expand Down

0 comments on commit 17da41e

Please sign in to comment.