make gup an alias, move function to ~/bin

This commit is contained in:
Sami Samhuri 2015-03-05 19:34:48 -08:00
parent 1a7617f16d
commit 45cd33c3c3

View file

@ -233,6 +233,7 @@ if command_exists git; then
alias gl='git log'
alias glo='git log --oneline --decorate'
alias gls='git log --stat'
alias gup='git update'
alias m='git merge'
alias s='git status -sb'
alias st='git stash'
@ -240,21 +241,6 @@ if command_exists git; then
alias stp='git stash pop'
fi
function gup() {
BRANCH=$(git branch --no-color --list | grep '^\*' | awk '{print $2}')
if [[ "$BRANCH" != "(detached" ]]; then
STASH_OUTPUT=$(git stash)
if [[ "$STASH_OUTPUT" = "No local changes to save" ]]; then
POP_STASH=0
else
POP_STASH=1
fi
git fetch --prune --tags origin && git rebase "origin/$BRANCH" && ([[ $POP_STASH -eq 1 ]] && git stash pop) || true
else
echo "Cannot update in a detached HEAD state"
fi
}
# `cd /path/to/a/file` does `cd /path/to/a`
function cd () {
if [[ -f "$1" ]]; then