From 7d71c44075b54def2c75bc9302eed5d23613137b Mon Sep 17 00:00:00 2001 From: Schwarzy1 Date: Wed, 24 May 2017 07:08:21 -0500 Subject: [PATCH] Added git-sp --- README.md | 1 + bin/git-sp | 39 +++++++++++++++++++++++++++++++++++ git-extra-commands.plugin.zsh | 1 + 3 files changed, 41 insertions(+) create mode 100755 bin/git-sp diff --git a/README.md b/README.md index 47c165858..b7e81018b 100644 --- a/README.md +++ b/README.md @@ -196,6 +196,7 @@ If you aren't using any zsh frameworks, or if you're a bash user, do the followi | `git-run-command-on-revisions` | Gary Bernhardt's [dotfiles](https://github.com/garybernhardt/dotfiles) | Runs a given command over a range of Git revisions | | `git-shamend` | Danielle Sucher's [git-shamend](http://www.daniellesucher.com/2014/05/08/git-shamend/) blog post | Amends your staged changes as a fixup (keeping the pre-existing commit message) to the specified commit, or HEAD if no revision is specified | | `git-show-overwritten` | Mislav Marohnić's [dotfiles](https://github.com/mislav/dotfiles) | Aggregates `git blame` information about the original owners of lines changed or removed in the '...' diff.| +| `git-sp` | A. Schwarz's [git-sp](https://github.com/Schwarzy1/git-sp) | "Simple push", single short command to commit, and push. Use -a flag to add all files to commit.| | `git-submodule-rm` | Greg V's [dotfiles](https://github.com/myfreeweb/dotfiles) | Allows you to remove a submodule easily with `git submodule-rm path/to/submodule` | | `git-thanks` | Mislav Marohnić's [dotfiles](https://github.com/mislav/dotfiles) | List the contributors to a repository in descending commit order, even if their contribution has been completely replaced | | `git-track` | Zach Holman's [dotfiles](https://github.com/holman/dotfiles) | Sets up your branch to track a remote branch. Assumes you mean origin/localbranchname | diff --git a/bin/git-sp b/bin/git-sp new file mode 100755 index 000000000..6089066e2 --- /dev/null +++ b/bin/git-sp @@ -0,0 +1,39 @@ +#!/usr/bin/env bash +# +# Author: A. Schwarz +# Usage: git sp [-a] +# +# "Simple push": commit with message and push. Use -a flag to add changed files +# to commit. +# +# See https://github.com/Schwarzy1/git-sp for more information. +# + + +usage(){ + echo "usage: git sp [-a] + + Commits and pushes to current working branch. + -a Run 'git add -A' prior to committing." + exit 1 +} + + +# -a should trigger `git add -A` +while getopts 'a' flag; do + aflag='true' +done + +if test "$#" -lt 1 +then + usage +else + if test $aflag + then + git add -A + git commit -m "$2" + else + git commit -m "$1" + fi + git push +fi diff --git a/git-extra-commands.plugin.zsh b/git-extra-commands.plugin.zsh index e2cf59085..709fd2480 100644 --- a/git-extra-commands.plugin.zsh +++ b/git-extra-commands.plugin.zsh @@ -54,6 +54,7 @@ zstyle ':completion:*:*:git:*' user-commands \ run-command-on-revisions:'Runs a given command over a range of Git revisions' \ shamend:'Amends your staged changes as a fixup to the specified older commit in the current branch' \ show-overwritten:"Aggregates git blame information about original owners of lines changed or removed in the '...' diff" \ + sp:"'Simple push', commits and pushes. Use -a flag to add"\ submodule-rm:'Remove submodules from current repo' \ thanks:'List authors with commit count' \ track:'Sets up your branch to track a remote branch' \