Skip to content

Instantly share code, notes, and snippets.

@maykon-oliveira
Last active December 20, 2018 16:44
Show Gist options
  • Save maykon-oliveira/018a40672b35d87b7688c41f67d3e8e5 to your computer and use it in GitHub Desktop.
Save maykon-oliveira/018a40672b35d87b7688c41f67d3e8e5 to your computer and use it in GitHub Desktop.
Estilo do meu bash para trabalhar com o git
# Configuracao git-prompt
# Cores
MAGENTA="\[\033[0;35m\]"
AMARELO="\[\033[01;33m\]"
AZUL="\[\033[00;34m\]"
LIGHT_GRAY="\[\033[0;37m\]"
BRANCO="\[\033[0;39m\]"
CYAN="\[\033[01;36m\]"
VERDE="\[\033[01;32m\]"
VERMELHO="\[\033[0;31m\]"
export LS_OPTIONS='--color=auto'
export CLICOLOR='Yes'
export LSCOLORS=gxfxbEaEBxxEhEhBaDaCaD
function colorir_prompt {
local __usuario_e_host="$VERDE\u:" # Adicionr '\h' para exibi o nome do host
local __caminho="$CYAN\w" # Exibi o caminho ('\W': atual | '\w': completo)
local __git_branch_cor="$VERDE"
local __prompt_tail="$BRANCO$"
local __usuario_input="$BRANCO"
local __git_branch='$(__git_ps1)';
# Colore o branch dependendo do estado
if [[ "$(__git_ps1)" =~ "*" ]]; then # Se repositorio sujo
__git_branch_cor="$VERMELHO"
elif [[ "$(__git_ps1)" =~ "$" ]]; then # Se existe alguma coisa em stashed
__git_branch_cor="$AMARELO"
elif [[ "$(__git_ps1)" =~ "%" ]]; then # Se somente existe arquivos untracked
__git_branch_cor="$LIGHT_GRAY"
elif [[ "$(__git_ps1)" =~ "+" ]]; then # Se existe arquivos em staged
__git_branch_cor="$CYAN"
fi
# Constroi a string do prompt
PS1="$__usuario_e_host $__caminho$__git_branch_cor$__git_branch $__prompt_tail$__usuario_input "
}
# Chama PROMPT_COMMAND que e executado antes de PS1
export PROMPT_COMMAND=colorir_prompt
if [ -f ~/.git-prompt.sh ]; then
GIT_PS1_SHOWDIRTYSTATE=true
GIT_PS1_SHOWSTASHSTATE=true
GIT_PS1_SHOWUNTRACKEDFILES=true
GIT_PS1_SHOWUPSTREAM="auto"
GIT_PS1_HIDE_IF_PWD_IGNORED=true
GIT_PS1_SHOWCOLORHINTS=true
. ~/.git-prompt.sh
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment