Skip to content

Instantly share code, notes, and snippets.

@senhorinha
Last active August 29, 2015 14:05
Show Gist options
  • Save senhorinha/2c1328d5a0b84f1dd82d to your computer and use it in GitHub Desktop.
Save senhorinha/2c1328d5a0b84f1dd82d to your computer and use it in GitHub Desktop.
git-bash
# Configurações do Git
function git_branch () {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
}
function git_status () {
verifica_repositorio=$(ls -la | grep -wc ".git")
if [[ $verifica_repositorio != "0" ]]; then
count_modificados=$(git status | grep -c modificado )
echo "Modificados:"$count_modificados
#n_linhas_do_status=$(git status | wc -l)
#n_da_linha_do_nao_monitorados=$(git status | grep -n "Arquivos não monitorados:" | cut -f1 -d:)
#n_tail=$(($n_linhas_do_status-$n_da_linha_do_nao_monitorados-2))
#n_arquivos_nao_monitorados=$(git status | tail -n $n_tail | wc -l )
fi
}
# Cores http://www.arwin.net/tech/bash.php
RED="\[\033[0;31m\]"
BROWN="\[\033[0;33m\]"
YELLOW="\[\033[1;33m\]"
GREEN="\[\033[0;32m\]"
BLUE="\[\033[0;34m\]"
WHITE="\[\033[1;37m\]"
NO_COLOR="\[\033[0m\]"
PS1="$RED\w$BROWN\$(git_branch) $BLUE\$(git_status)$NO_COLOR $ "
# Com nome do usuario
#PS1="$GREEN\u@\h$NO_COLOR:\w$BROWN\$(parse_git_branch)$NO_COLOR\$ "
# Atalhos globais
alias gotocore='cd ~/codigo_fonte/trabalho/core'
alias gotoesus='cd ~/codigo_fonte/trabalho/esus'
alias pullesus='gotoesus; git checkout master; git pull oficial master'
alias pullcore='gotocore; git checkout master; git pull oficial master'
alias refreshcore='pullcore; maven clean install -U'
alias refreshesus='pullesus; maven clean install -U'
# g(it) e ultima letra do comando por exemplo: (statu)s
alias gau='git add -u'
alias gs='git status'
alias gp='git push'
alias gsh='git show'
alias gl='git log'
alias gb='git branch'
alias gch='git checkout'
alias gd='git diff'
# Atalho para git commit -m
function gc {
local commitmessage
if [ "" = "$1" ]; then
echo -n 'Commit message: '
commitmessage="$(ruby -e "puts gets")"
git commit -m "$commitmessage"
else
git commit -m "$1"
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment