Skip to content

Instantly share code, notes, and snippets.

@peabnuts123
Last active January 14, 2019 02:10
Show Gist options
  • Save peabnuts123/91e993df2d1ede07d19f95cd2e36f0ed to your computer and use it in GitHub Desktop.
Save peabnuts123/91e993df2d1ede07d19f95cd2e36f0ed to your computer and use it in GitHub Desktop.
Small function to show local git changes and prompt whether you want to push
# Usage: git-prompt (when in a git repo)
# Print the output of `git status` then prompt the user for whether
# they wish to `git push`
function git-prompt() {
git log "origin/$(git rev-parse --abbrev-ref HEAD)"..HEAD
echo '------------------------------------------';
git status --untracked-files no;
echo '------------------------------------------';
while true; do
read -rp "Do you wish to run \`git push\`? " yn
case ${yn} in
[Yy]* ) git push; break;;
[NnQq]* ) break;;
* ) echo "Please answer Y or N.";;
esac
done
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment