Last active
December 11, 2015 23:48
-
-
Save fernandoflorez/4679369 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# git bash auto-completion | |
source `brew --prefix git`/etc/bash_completion.d/git-completion.bash | |
# latest versions of git has the prompt stuff on an extra file | |
__git_prompt_file=`brew --prefix git`/etc/bash_completion.d/git-prompt.sh | |
if [ -f "$__git_prompt_file" ] | |
then | |
source $__git_prompt_file | |
fi | |
# alias 'git' to 'g' | |
alias g='git' | |
# Autocomplete g command too | |
complete -o default -o nospace -F _git g | |
# very useful git related methods | |
function current_branch() { | |
ref=$(git symbolic-ref HEAD 2> /dev/null) || return | |
echo ${ref#refs/heads/} | |
} | |
function gpull() { | |
git pull $1 $([[ $2 ]] && echo $2 || echo $(current_branch)) | |
} | |
function gpush() { | |
git push $1 $([[ $2 ]] && echo $2 || echo $(current_branch)) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment