From 0706ce43ec2b252e3a5a0547e62581e4b44531c7 Mon Sep 17 00:00:00 2001 From: hequn Date: Wed, 9 Apr 2014 14:34:37 +0800 Subject: [PATCH] Add alternative alias/plugin/completion configuring method. Through configuring file .bash_profile, we can easily rebuild our bash_it environment. Add following variable in .bash_profile: aliases="general.aliases git.aliases" completion="defaults.completion git.completion" plugins="base.plugin dirs.plugin hg.plugin". Then I can put my .bash_profile in scm repos. --- bash_it.sh | 5 +++++ lib/helpers.bash | 17 +++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/bash_it.sh b/bash_it.sh index 226213fd..b9b33b37 100755 --- a/bash_it.sh +++ b/bash_it.sh @@ -44,6 +44,11 @@ do _load_bash_it_files $file_type done +# Load configured aliases, completion, plugins +load_bash_it_files "aliases" "${aliases}" +load_bash_it_files "completion" "${completion}" +load_bash_it_files "plugins" "${plugins}" + # Load any custom aliases that the user has added if [ -e "${BASH_IT}/aliases/custom.aliases.bash" ] then diff --git a/lib/helpers.bash b/lib/helpers.bash index b99ae3d3..941a876b 100644 --- a/lib/helpers.bash +++ b/lib/helpers.bash @@ -14,6 +14,23 @@ function _load_bash_it_files() { done } +# Helper function loading various enable-able files +function load_bash_it_files() { + subdirectory="$1" + enable_files="$2" + if [ ! -d "${BASH_IT}/${subdirectory}/available" ] + then + return + fi + for enable_file in ${enable_files} + do + config_file="${BASH_IT}/${subdirectory}/available/${enable_file}.bash" + if [ -e "${config_file}" ]; then + source $config_file + fi + done +} + # Function for reloading aliases function reload_aliases() { _load_bash_it_files "aliases"