update multiple base dirs; added env sentinel; silenced the app
This commit is contained in:
parent
89137fa65e
commit
3a4e170962
@ -45,6 +45,7 @@ CODE_ACTIVATOR() {
|
||||
|
||||
case $1 in
|
||||
deactivate ) _CA__RESTORE_ENVIRONMENT && cd || ERROR=1 ;;
|
||||
|
||||
clone ) _CA__CLONE ${@:2} || ERROR=1 ;;
|
||||
new ) IS_NEW_PROJECT=1 _CA__CLONE ${@:2} || ERROR=1 ;;
|
||||
* ) _CA__ACTIVATE ${@:1} || ERROR=42 ;;
|
||||
@ -107,9 +108,10 @@ _CA__ERROR_CLEANUP() {
|
||||
[[ $CODE_ACTIVATOR__DISABLE_SHORTCUT -eq 0 ]] && {
|
||||
_CA__ZSH_SHORTCUT_PLUGIN() {
|
||||
local OPTIONS=$(_CA__GET_COMMANDS_AND_PROJECTS | sed 's/\s\+/\n/g')
|
||||
[ ! $__CUSTOM_ENV_ACTIVE ] && OPTIONS=$(echo $OPTIONS | grep -v 'deactivate')
|
||||
|
||||
local ARGUMENT=$(\
|
||||
_CA__GET_COMMANDS_AND_PROJECTS \
|
||||
echo $OPTIONS \
|
||||
| sed 's/\s\+/\n/g' \
|
||||
| $_CA__FZF --prompt 'select a project: ' \
|
||||
)
|
||||
|
@ -35,9 +35,7 @@ _CA__ACTIVATE_VIRTUAL_ENV() {
|
||||
[ -f $ACTIVATE ] && {
|
||||
source $ACTIVATE
|
||||
} || {
|
||||
[ -f $NO_ENV ] && {
|
||||
echo 'no virtual environment here, boss!'
|
||||
} || {
|
||||
[ ! -f $NO_ENV ] && {
|
||||
_CA__INTERACTIVE_ENV_SETUP $PROJECT_PATH && source $ACTIVATE
|
||||
}
|
||||
}
|
||||
@ -47,7 +45,8 @@ _CA__ACTIVATE_CUSTOM_ENV() {
|
||||
local PROJECT_PATH="$1"
|
||||
local CUSTOM_ENV="$PROJECT_PATH/$_CA__CUSTOM_ENV_NAME"
|
||||
|
||||
[ -f $CUSTOM_ENV ] && source $CUSTOM_ENV
|
||||
[ ! -f $CUSTOM_ENV ] && _CA__INIT_CUSTOM_ENV $PROJECT_PATH
|
||||
source $CUSTOM_ENV
|
||||
}
|
||||
|
||||
_CA__ACTIVATE_SOURCE_PATH() {
|
||||
|
@ -5,10 +5,10 @@ export RESTORE_PATH="$PATH"
|
||||
|
||||
# Store a list of project-specific environment variables; unset on env exit
|
||||
export RESTORE_ENV=(
|
||||
CUSTOM_ENV_VAR
|
||||
__CUSTOM_ENV_ACTIVE
|
||||
)
|
||||
|
||||
#####################################################################
|
||||
|
||||
# example env var
|
||||
export CUSTOM_ENV_VAR=69
|
||||
export __CUSTOM_ENV_ACTIVE=69
|
||||
|
@ -20,7 +20,11 @@ _CA__GET_FULL_PATH() {
|
||||
local PROJECT_ROOT_SHORT=$(dirname $PROJECT)
|
||||
local PROJECT_NAME=$(basename $PROJECT)
|
||||
|
||||
local FULL_BASE_DIR=$(echo $CODE_ACTIVATOR__DIRS | grep "^.*/$PROJECT_ROOT_SHORT$")
|
||||
local FULL_BASE_DIR=$(\
|
||||
echo $CODE_ACTIVATOR__DIRS \
|
||||
| sed 's/\s\+/\n/' \
|
||||
| grep "^.*/$PROJECT_ROOT_SHORT$" \
|
||||
)
|
||||
|
||||
echo "$FULL_BASE_DIR/$PROJECT_NAME"
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
#####################################################################
|
||||
|
||||
[ ! $CODE_ACTIVATOR__DIRS ] && export CODE_ACTIVATOR__DIRS=("$HOME/Code")
|
||||
[[ ${#CODE_ACTIVATOR__DIRS[@]} -eq 0 ]] && export CODE_ACTIVATOR__DIRS=("$HOME/Code")
|
||||
|
||||
export CODE_ACTIVATOR__KNOWN_TARGETS=(
|
||||
$CODE_ACTIVATOR__KNOWN_TARGETS
|
||||
@ -21,7 +21,7 @@ export CODE_ACTIVATOR__KNOWN_TARGETS=(
|
||||
[ ! $_CA__SOURCE_DIR_NAME ] && export _CA__SOURCE_DIR_NAME='code'
|
||||
[ ! $_CA__VIRTUAL_ENV_NAME ] && export _CA__VIRTUAL_ENV_NAME='env'
|
||||
[ ! $_CA__CUSTOM_ENV_NAME ] && export _CA__CUSTOM_ENV_NAME='custom-env'
|
||||
[ ! $_CA__NO_ENV_SENTINEL ] && export _CA__NO_ENV_SENTINEL='.no-env'
|
||||
[ ! $_CA__NO_ENV_SENTINEL ] && export _CA__NO_ENV_SENTINEL='no-env'
|
||||
[ ! $_CA__GIT_MAIN_BRANCH ] && export _CA__GIT_MAIN_BRANCH='master'
|
||||
|
||||
[ ! $_CA__CUSTOM_ENV_TEMPLATE ] && export _CA__CUSTOM_ENV_TEMPLATE="${0:a:h}/custom-env-template.zsh"
|
||||
|
Loading…
Reference in New Issue
Block a user