Skip to content

Instantly share code, notes, and snippets.

@cesarLDsousa
Last active February 22, 2024 16:53
Show Gist options
  • Save cesarLDsousa/034dfccdcea701286c8beeda884dfba3 to your computer and use it in GitHub Desktop.
Save cesarLDsousa/034dfccdcea701286c8beeda884dfba3 to your computer and use it in GitHub Desktop.
Github and Bitbucket configuration for .zshrc
# colors
RED='\033[0;31m'
GREEN='\033[0;32m'
GRAY='\033[0;37m'
BLUE='\033[0;94m'
YELLOW='\033[0;33m'
NC='\033[0m' # No Color
# emojis
SUCCESS_EMOJI="✅"
ERROR_EMOJI="❌"
WARNING_EMOJI="⚠️"
# font
BOLD='\033[1m'
# github configuration
function git_config {
git config --global user.name "cesarLDsousa"
git config --global user.email "cesarluiz.git@gmail.com"
git_config_return_code=$?
if [ $git_config_return_code -eq 0 ]; then
echo -e "${SUCCESS_EMOJI} ${GREEN}${BOLD}Changed settings to ${GRAY} Github:${NC}"
else
echo -e "${ERROR_EMOJI} ${RED}Settings not changed${NC}"
fi
}
# bitbucket configuration
function git_config_bitbucket {
git config --global user.name "cesarLDsousa"
git config --global user.email "cesar.luiz@essentia.com.br"
git_config_return_code=$?
if [ $git_config_return_code -eq 0 ]; then
echo -e "${SUCCESS_EMOJI} ${GREEN}${BOLD}Changed settings to ${BLUE}Bitbucket:${NC}"
else
echo -e "${ERROR_EMOJI} ${RED}!! Settings not changed: error !!${NC}"
fi
}
# select git configuration based on argument
function git-config {
if [ "$1" = "--github" ]; then
git_config
elif [ "$1" = "--bitbucket" ]; then
git_config_bitbucket
else
echo -e "${WARNING_EMOJI} ${YELLOW} Origin not recognized.${NC}"
fi
git config --list | grep user | sed 's/^/ /'
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment