Skip to content

Instantly share code, notes, and snippets.

@zaki
Created August 9, 2018 01:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zaki/e7a1eb35a82bf5897c0051d51ba9c1ef to your computer and use it in GitHub Desktop.
Save zaki/e7a1eb35a82bf5897c0051d51ba9c1ef to your computer and use it in GitHub Desktop.
A few aliases
alias grhod='git reset --hard origin/develop; git clean -fd; git submodule update --recursive'
alias remod='git reset --hard; git clean -fd; git checkout -f develop; git remote update origin --prune; git reset --hard origin/develop; git clean -fd; git submodule update --recursive'
alias l='ls -la'
compdef g=git
__git_complete g __git_main
__git_complete grh _git_complete_refs
function endreview() {
gitdir=$(git rev-parse --show-toplevel)/.git
review_file=${gitdir}/review-branch
if [[ ! -f $review_file ]]
then
echo "No review in progress"
return 1
fi
echo "Finishing review"
git reset --hard
git checkout -f develop
git remote update origin --prune
git reset --hard origin/develop
git clean -fd
git submodule update --recursive
rm ${review_file}
}
function review() {
if [[ $# -ne 2 ]] then
echo "Usage: review <remote> <branch>"
return 1
fi
remote=$1
branch=$2
gitdir=$(git rev-parse --show-toplevel)/.git
review_file=${gitdir}/review-branch
if [[ -f $review_file ]]
then
echo "A review is already in progress: $(cat $review_file)"
return 1
fi
git reset --hard
git clean -fd
git checkout -f develop
git remote update --prune
git reset --hard origin/develop
git merge $remote/$branch
git submodule update --recursive
echo "${remote}/${branch}" > ${review_file}
}
# rest of git prompt setup from zaki/dotfiles/zsh/config
function set_review_prompt() {
review_file=$(git rev-parse --show-toplevel)/.git/review-branch
if [[ ! -f ${review_file} ]]
then
return
fi
review_branch=$(cat $review_file)
echo " %F{yellow}[REVIEW:${review_branch}]%f "
}
PROMPT='%F{green}%c`set_git_prompt``set_review_prompt` %(?/%F{green}/%F{red})%(!.#.$) %f'
RPROMPT='%F{red}%T%F{green}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment