From b524bb604756d33ec330abe5300a7a1a6d3a833b Mon Sep 17 00:00:00 2001 From: Travis Swicegood Date: Mon, 26 Mar 2012 11:19:38 -0500 Subject: [PATCH] Extract loading of enable-able files and add reload_* functions --- bash_it.sh | 12 +----------- lib/helpers.bash | 30 ++++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 11 deletions(-) create mode 100644 lib/helpers.bash diff --git a/bash_it.sh b/bash_it.sh index 7844f37..66363f9 100644 --- a/bash_it.sh +++ b/bash_it.sh @@ -35,17 +35,7 @@ done # Load enabled aliases, completion, plugins for file_type in "aliases" "completion" "plugins" do - if [ ! -d "${BASH_IT}/${file_type}/enabled" ] - then - continue - fi - FILES="${BASH_IT}/${file_type}/enabled/*.bash" - for config_file in $FILES - do - if [ -e "${config_file}" ]; then - source $config_file - fi - done + _load_bash_it_files $file_type done # Load any custom aliases that the user has added diff --git a/lib/helpers.bash b/lib/helpers.bash new file mode 100644 index 0000000..ec6587e --- /dev/null +++ b/lib/helpers.bash @@ -0,0 +1,30 @@ +# Helper function loading various enable-able files +function _load_bash_it_files() { + file_type="$1" + if [ ! -d "${BASH_IT}/${file_type}/enabled" ] + then + continue + fi + FILES="${BASH_IT}/${file_type}/enabled/*.bash" + for config_file in $FILES + do + if [ -e "${config_file}" ]; then + source $config_file + fi + done +} + +# Function for reloading aliases +function reload_aliases() { + _load_bash_it_files "aliases" +} + +# Function for reloading auto-completion +function reload_completion() { + _load_bash_it_files "completion" +} + +# Function for reloading plugins +function reload_plugins() { + _load_bash_it_files "plugins" +} -- 2.17.1