From 0266f1af31f36e188d2042503d2ce5883a243533 Mon Sep 17 00:00:00 2001 From: "Stanislav N. aka pztrn" Date: Sat, 3 Apr 2021 17:25:00 +0500 Subject: [PATCH] Ensure configuration consistency run in the very beginning and do not process empty apps and plugins. --- zsh/01-config.zsh | 18 +++++++++--------- zsh/04-apps.zsh | 4 ++++ zsh/05-plugins.zsh | 4 ++++ 3 files changed, 17 insertions(+), 9 deletions(-) diff --git a/zsh/01-config.zsh b/zsh/01-config.zsh index d14b51d..5680364 100644 --- a/zsh/01-config.zsh +++ b/zsh/01-config.zsh @@ -1,4 +1,13 @@ # Configuration file loader. +log 1 "Checking for configuration consistency..." +for file in `find ${CONFIG_PATH}/zsh/defaults/ -maxdepth 1 -type f -exec basename {} \; | sort`; do + if [ ! -f "${HOME}/.zsh-config.d/${file}" ]; then + cp "${CONFIG_PATH}/zsh/defaults/${file}" "${HOME}/.zsh-config.d/${file}" + log 0 "New configuration file '${file}' copied to your home directory (${HOME}/.zsh-config.d/)." + log 0 "Don't forget to take a look and configure, if neccessary!" + fi +done + if [ ! -d ${HOME}/.zsh-config.d/ ]; then log 1 "Copying configuration to user's home directory..." cp -R "${CONFIG_PATH}/zsh/defaults/" ${HOME}/.zsh-config.d @@ -9,12 +18,3 @@ for file in `find ${HOME}/.zsh-config.d/ -maxdepth 1 -type f -exec basename {} \ log 1 "Loading configuration file: ${file}" source "${HOME}/.zsh-config.d/${file}" done - -log 1 "Checking for configuration consistency..." -for file in `find ${CONFIG_PATH}/zsh/defaults/ -maxdepth 1 -type f -exec basename {} \; | sort`; do - if [ ! -f "${HOME}/.zsh-config.d/${file}" ]; then - cp "${CONFIG_PATH}/zsh/defaults/${file}" "${HOME}/.zsh-config.d/${file}" - log 0 "New configuration file '${file}' copied to your home directory (${HOME}/.zsh-config.d/)." - log 0 "Don't forget to take a look and configure, if neccessary!" - fi -done diff --git a/zsh/04-apps.zsh b/zsh/04-apps.zsh index 2cc2dbb..01bd39d 100644 --- a/zsh/04-apps.zsh +++ b/zsh/04-apps.zsh @@ -1,5 +1,9 @@ # Load enabled apps. for app in ${ENABLED_APPS[@]}; do + if [ "${app}" = "" ]; then + continue + fi + if [ ! -f "${CONFIG_PATH}/zsh/apps/${app}.app.zsh" ]; then error 0 "Application '${app}' doesn't exist" else diff --git a/zsh/05-plugins.zsh b/zsh/05-plugins.zsh index c8402f0..d0bc4b8 100644 --- a/zsh/05-plugins.zsh +++ b/zsh/05-plugins.zsh @@ -1,5 +1,9 @@ # Load enabled plugins. for plugin in "${ENABLED_PLUGINS[@]}"; do + if [ "${plugin}" = "" ]; then + continue + fi + if [ ! -f "${CONFIG_PATH}/zsh/plugins/${plugin}.plugin.zsh" ]; then error 0 "Plugin '${plugin}' doesn't exist" else