diff --git a/zsh/clone.zsh b/zsh/clone.zsh index ccc152f..8d62b2f 100644 --- a/zsh/clone.zsh +++ b/zsh/clone.zsh @@ -86,7 +86,7 @@ _CA__CLONE_SOURCE() { && touch .gitignore \ && git add .gitignore \ && git commit -m 'project init' \ - && git remote add "$_CA__GIT_MAIN_BRANCH" $REMOTE_TARGET \ + && git remote add $_CA__GET_GIT_MAIN_BRANCH $REMOTE_TARGET \ && cd .. \ ; } >/dev/null >&1 && echo ' success :)' || echo ' failed :c' diff --git a/zsh/helpers.zsh b/zsh/helpers.zsh index f68c007..f8acb44 100644 --- a/zsh/helpers.zsh +++ b/zsh/helpers.zsh @@ -78,6 +78,12 @@ _CA__GET_REMOTE_TARGET() { echo $REMOTE_TARGET } +_CA__GET_GIT_MAIN_BRANCH() { + { git config --list | grep 'init.defaultbranch' | sed 's/.*=//' \ + || echo 'main' + } 2>/dev/null +} + _CA__GET_PROJECT_NAME() { local REMOTE_TARGET="$1" local DEFAULT_NAME=$(basename $REMOTE_TARGET | sed 's/\.git$//') diff --git a/zsh/settings.zsh b/zsh/settings.zsh index 1461e5e..d26b102 100644 --- a/zsh/settings.zsh +++ b/zsh/settings.zsh @@ -22,7 +22,6 @@ export _CA__SOURCE_DIR_NAME='code' export _CA__VIRTUAL_ENV_NAME='env' export _CA__CUSTOM_ENV_NAME='custom-env' export _CA__NO_ENV_SENTINEL='no-env' -export _CA__GIT_MAIN_BRANCH='master' export _CA__CUSTOM_ENV_TEMPLATE="${0:a:h}/custom-env-template.zsh"