Added default priority for enable
parent
10a14585b4
commit
31dd740571
|
|
@ -1,3 +1,8 @@
|
||||||
|
BASH_IT_LOAD_PRIORITY_DEFAULT_ALIAS=150
|
||||||
|
BASH_IT_LOAD_PRIORITY_DEFAULT_PLUGIN=250
|
||||||
|
BASH_IT_LOAD_PRIORITY_DEFAULT_COMPLETION=350
|
||||||
|
BASH_IT_LOAD_PRIORITY_SEPARATOR="---"
|
||||||
|
|
||||||
# Helper function loading various enable-able files
|
# Helper function loading various enable-able files
|
||||||
function _load_bash_it_files() {
|
function _load_bash_it_files() {
|
||||||
subdirectory="$1"
|
subdirectory="$1"
|
||||||
|
|
@ -256,7 +261,7 @@ _enable-plugin ()
|
||||||
_example '$ enable-plugin rvm'
|
_example '$ enable-plugin rvm'
|
||||||
_group 'lib'
|
_group 'lib'
|
||||||
|
|
||||||
_enable-thing "plugins" "plugin" $1
|
_enable-thing "plugins" "plugin" $1 $BASH_IT_LOAD_PRIORITY_DEFAULT_PLUGIN
|
||||||
}
|
}
|
||||||
|
|
||||||
_enable-alias ()
|
_enable-alias ()
|
||||||
|
|
@ -266,7 +271,7 @@ _enable-alias ()
|
||||||
_example '$ enable-alias git'
|
_example '$ enable-alias git'
|
||||||
_group 'lib'
|
_group 'lib'
|
||||||
|
|
||||||
_enable-thing "aliases" "alias" $1
|
_enable-thing "aliases" "alias" $1 $BASH_IT_LOAD_PRIORITY_DEFAULT_ALIAS
|
||||||
}
|
}
|
||||||
|
|
||||||
_enable-completion ()
|
_enable-completion ()
|
||||||
|
|
@ -276,7 +281,7 @@ _enable-completion ()
|
||||||
_example '$ enable-completion git'
|
_example '$ enable-completion git'
|
||||||
_group 'lib'
|
_group 'lib'
|
||||||
|
|
||||||
_enable-thing "completion" "completion" $1
|
_enable-thing "completion" "completion" $1 $BASH_IT_LOAD_PRIORITY_DEFAULT_COMPLETION
|
||||||
}
|
}
|
||||||
|
|
||||||
_enable-thing ()
|
_enable-thing ()
|
||||||
|
|
@ -286,11 +291,13 @@ _enable-thing ()
|
||||||
_param '1: subdirectory'
|
_param '1: subdirectory'
|
||||||
_param '2: file_type'
|
_param '2: file_type'
|
||||||
_param '3: file_entity'
|
_param '3: file_entity'
|
||||||
_example '$ _enable-thing "plugins" "plugin" "ssh"'
|
_param '4: load priority'
|
||||||
|
_example '$ _enable-thing "plugins" "plugin" "ssh" "150"'
|
||||||
|
|
||||||
subdirectory="$1"
|
subdirectory="$1"
|
||||||
file_type="$2"
|
file_type="$2"
|
||||||
file_entity="$3"
|
file_entity="$3"
|
||||||
|
load_priority="$4"
|
||||||
|
|
||||||
if [ -z "$file_entity" ]; then
|
if [ -z "$file_entity" ]; then
|
||||||
reference "enable-$file_type"
|
reference "enable-$file_type"
|
||||||
|
|
@ -303,7 +310,7 @@ _enable-thing ()
|
||||||
do
|
do
|
||||||
plugin=$(basename $f)
|
plugin=$(basename $f)
|
||||||
if [ ! -h $BASH_IT/$subdirectory/enabled/$plugin ]; then
|
if [ ! -h $BASH_IT/$subdirectory/enabled/$plugin ]; then
|
||||||
ln -s ../available/$plugin $BASH_IT/$subdirectory/enabled/$plugin
|
ln -s ../available/$plugin $BASH_IT/$subdirectory/enabled/$load_priority$BASH_IT_LOAD_PRIORITY_SEPARATOR$plugin
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
else
|
else
|
||||||
|
|
@ -314,14 +321,19 @@ _enable-thing ()
|
||||||
fi
|
fi
|
||||||
|
|
||||||
plugin=$(basename $plugin)
|
plugin=$(basename $plugin)
|
||||||
if [ -e $BASH_IT/$subdirectory/enabled/$plugin ]; then
|
# Check for existence of the file using a wildcard, since we don't know which priority might have been used when enabling it.
|
||||||
|
for f in $BASH_IT/$subdirectory/enabled/*$BASH_IT_LOAD_PRIORITY_SEPARATOR$plugin; do
|
||||||
|
if [ -e "$f" ] ; then
|
||||||
printf '%s\n' "$file_entity is already enabled."
|
printf '%s\n' "$file_entity is already enabled."
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
break
|
||||||
|
done
|
||||||
|
|
||||||
mkdir -p $BASH_IT/$subdirectory/enabled
|
mkdir -p $BASH_IT/$subdirectory/enabled
|
||||||
|
|
||||||
ln -s ../available/$plugin $BASH_IT/$subdirectory/enabled/$plugin
|
ln -s ../available/$plugin $BASH_IT/$subdirectory/enabled/$load_priority$BASH_IT_LOAD_PRIORITY_SEPARATOR$plugin
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -n "$BASH_IT_AUTOMATIC_RELOAD_AFTER_CONFIG_CHANGE" ]; then
|
if [ -n "$BASH_IT_AUTOMATIC_RELOAD_AFTER_CONFIG_CHANGE" ]; then
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue