Skip to content

Instantly share code, notes, and snippets.

@fernandoflorez
Last active December 11, 2015 23:48
Show Gist options
  • Save fernandoflorez/4679369 to your computer and use it in GitHub Desktop.
Save fernandoflorez/4679369 to your computer and use it in GitHub Desktop.
# 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