diff --git a/zsh/zshrc b/zsh/zshrc index e40aaae..85ebd7d 100755 --- a/zsh/zshrc +++ b/zsh/zshrc @@ -233,9 +233,19 @@ if command_exists git; then alias m='git merge' alias s='git status -sb' alias st='git stash' + alias stl='git stash list' alias stp='git stash pop' fi +function gup() { + BRANCH=$(git branch --no-color --list | grep '^\*' | awk '{print $2}') + if [[ "$BRANCH" != "(detached" ]]; then + git stash && git fetch origin && git rebase "origin/$BRANCH" && git stash pop + 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