From 9656b56cece36280dec60deec72e1d5d9a930887 Mon Sep 17 00:00:00 2001 From: Noah Gorny Date: Sun, 18 Apr 2021 23:00:37 +0300 Subject: [PATCH] helpers: Add useful log in case of empty config --- lib/helpers.bash | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/lib/helpers.bash b/lib/helpers.bash index 63e10874de..87adfa967e 100755 --- a/lib/helpers.bash +++ b/lib/helpers.bash @@ -499,18 +499,30 @@ _bash-it-profile-save() { done fi + local something_exists echo "# This file is auto generated by Bash-it. Do not edit manually!" > "$profile_path" for subdirectory in "plugins" "completion" "aliases"; do + local component_exists="" echo "Saving $subdirectory configuration..." - echo "" >> "$profile_path" - echo "# $subdirectory" >> "$profile_path" for f in "${BASH_IT}/$subdirectory/available/"*.bash; do _bash-it-determine-component-status-from-path "$f" if [ "$enabled" == "x" ]; then + if [ -z "$component_exists" ]; then + # This is the first component of this type, print the header + component_exists="yes" + something_exists="yes" + echo "" >> "$profile_path" + echo "# $subdirectory" >> "$profile_path" + fi echo "$subdirectory $enabled_file_clean" >> "$profile_path" fi done done + if [ -z "$something_exists" ]; then + echo "It seems like no configuration was enabled.." + echo "Make sure to double check that this is the wanted behavior." + fi + echo "All done!" echo "" echo "Profile location: $profile_path"