summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGaetan Semet <gaetan@xeberon.net>2013-06-05 15:16:51 +0200
committerGaetan Semet <gaetan@xeberon.net>2013-06-05 15:16:51 +0200
commit46f0d8dba95aae400e4d9fc825691d0119cf7189 (patch)
tree581550cab80fc98f860ffb18f3c030e84e9e83e2
parent86a889ea083d341ba2bc48656008e5af46a3df2d (diff)
downloadzsh-46f0d8dba95aae400e4d9fc825691d0119cf7189.tar.gz
zsh-46f0d8dba95aae400e4d9fc825691d0119cf7189.tar.bz2
zsh-46f0d8dba95aae400e4d9fc825691d0119cf7189.zip
Improvement in the git plugin
Signed-off-by: Gaetan Semet <gaetan@xeberon.net>
-rw-r--r--plugins/git/README.md4
-rw-r--r--plugins/git/_git-branch62
-rw-r--r--plugins/git/_git-remote74
-rw-r--r--plugins/git/git.plugin.zsh13
4 files changed, 153 insertions, 0 deletions
diff --git a/plugins/git/README.md b/plugins/git/README.md
new file mode 100644
index 000000000..8462dda1c
--- /dev/null
+++ b/plugins/git/README.md
@@ -0,0 +1,4 @@
+## git
+**Maintainer:** [Stibbons](https://github.com/Stibbons)
+
+This plugin adds several git aliases and increase the completion function provided by zsh
diff --git a/plugins/git/_git-branch b/plugins/git/_git-branch
new file mode 100644
index 000000000..86d03bc30
--- /dev/null
+++ b/plugins/git/_git-branch
@@ -0,0 +1,62 @@
+#compdef git-branch
+
+_git-branch ()
+{
+ declare l c m d
+
+ l='--color --no-color -r -a --all -v --verbose --abbrev --no-abbrev'
+ c='-l -f --force -t --track --no-track --set-upstream --contains --merged --no-merged'
+ m='-m -M'
+ d='-d -D'
+
+ declare -a dependent_creation_args
+ if (( words[(I)-r] == 0 )); then
+ dependent_creation_args=(
+ "($l $m $d): :__git_branch_names"
+ "::start-point:__git_revisions")
+ fi
+
+ declare -a dependent_deletion_args
+ if (( words[(I)-d] || words[(I)-D] )); then
+ dependent_creation_args=
+ dependent_deletion_args=(
+ '-r[delete only remote-tracking branches]')
+ if (( words[(I)-r] )); then
+ dependent_deletion_args+='*: :__git_ignore_line_inside_arguments __git_remote_branch_names'
+ else
+ dependent_deletion_args+='*: :__git_ignore_line_inside_arguments __git_branch_names'
+ fi
+ fi
+
+ declare -a dependent_modification_args
+ if (( words[(I)-m] || words[(I)-M] )); then
+ dependent_creation_args=
+ dependent_modification_args=(
+ ':old or new branch name:__git_branch_names'
+ '::new branch name:__git_branch_names')
+ fi
+
+ _arguments -w -S -s \
+ "($c $m $d --no-color :)--color=-[turn on branch coloring]:: :__git_color_whens" \
+ "($c $m $d : --color)--no-color[turn off branch coloring]" \
+ "($c $m -a --all)-r[list or delete only remote-tracking branches]" \
+ "($c $m $d : -r)"{-a,--all}"[list both remote-tracking branches and local branches]" \
+ "($c $m $d : -v --verbose)"{-v,--verbose}'[show SHA1 and commit subject line for each head]' \
+ "($c $m $d :)--abbrev=[set minimum SHA1 display-length]: :__git_guard_number length" \
+ "($c $m $d :)--no-abbrev[do not abbreviate sha1s]" \
+ "($l $m $d)-l[create the branch's reflog]" \
+ "($l $m $d -f --force)"{-f,--force}"[force the creation of a new branch]" \
+ "($l $m $d -t --track)"{-t,--track}"[set up configuration so that pull merges from the start point]" \
+ "($l $m $d)--no-track[override the branch.autosetupmerge configuration variable]" \
+ "($l $m $d)--set-upstream[set up configuration so that pull merges]" \
+ "($l $m $d)--contains=[only list branches which contain the specified commit]: :__git_committishs" \
+ "($l $m $d)--merged=[only list branches which are fully contained by HEAD]: :__git_committishs" \
+ "($l $m $d)--no-merged=[do not list branches which are fully contained by HEAD]: :__git_committishs" \
+ $dependent_creation_args \
+ "($l $c $d -M)-m[rename a branch and the corresponding reflog]" \
+ "($l $c $d -m)-M[rename a branch even if the new branch-name already exists]" \
+ $dependent_modification_args \
+ "($l $c $m -D)-d[delete a fully merged branch]" \
+ "($l $c $m -d)-D[delete a branch]" \
+ $dependent_deletion_args
+}
diff --git a/plugins/git/_git-remote b/plugins/git/_git-remote
new file mode 100644
index 000000000..4ba62a357
--- /dev/null
+++ b/plugins/git/_git-remote
@@ -0,0 +1,74 @@
+#compdef git-remote
+
+# NOTE: --track is undocumented.
+# TODO: --track, -t, --master, and -m should take remote branches, I guess.
+# NOTE: --master is undocumented.
+# NOTE: --fetch is undocumented.
+_git-remote () {
+ local curcontext=$curcontext state line
+ declare -A opt_args
+
+ _arguments -C \
+ ':command:->command' \
+ '*::options:->options' && ret=0
+
+ case $state in
+ (command)
+ declare -a commands
+
+ commands=(
+ 'add:add a new remote'
+ 'show:show information about a given remote'
+ 'prune:delete all stale tracking branches for a given remote'
+ 'update:fetch updates for a set of remotes'
+ 'rm:remove a remote from .git/config and all associated tracking branches'
+ 'rename:rename a remote from .git/config and update all associated tracking branches'
+ 'set-head:sets or deletes the default branch'
+ 'set-branches:changes the list of branches tracked by the named remote.'
+ 'set-url:changes URL remote points to.'
+ )
+
+ _describe -t commands 'sub-command' commands && ret=0
+ ;;
+ (options)
+ case $line[1] in
+ (add)
+ _arguments \
+ '*'{--track,-t}'[track given branch instead of default glob refspec]:branch:__git_branch_names' \
+ '(--master -m)'{--master,-m}'[set the remote'\''s HEAD to point to given master branch]:branch:__git_branch_names' \
+ '(--fetch -f)'{--fetch,-f}'[run git-fetch on the new remote after it has been created]' \
+ ':branch name:__git_remotes' \
+ ':url:_urls' && ret=0
+ ;;
+ (show)
+ _arguments \
+ '-n[do not contact the remote for a list of branches]' \
+ ':remote:__git_remotes' && ret=0
+ ;;
+ (prune)
+ _arguments \
+ '(--dry-run -n)'{-n,--dry-run}'[do not actually prune, only list what would be done]' \
+ ':remote:__git_remotes' && ret=0
+ ;;
+ (update)
+ __git_remote-groups && ret=0
+ ;;
+ (rm)
+ __git_remotes && ret=0
+ ;;
+ (rename)
+ __git_remotes && ret=0
+ ;;
+ (set-url)
+ _arguments \
+ '*--push[manipulate push URLs]' \
+ '(--add)--add[add URL]' \
+ '(--delete)--delete[delete URLs]' \
+ ':branch name:__git_remotes' \
+ ':url:_urls' && ret=0
+ ;;
+
+ esac
+ ;;
+ esac
+}
diff --git a/plugins/git/git.plugin.zsh b/plugins/git/git.plugin.zsh
index 6c016aa6b..cf897239c 100644
--- a/plugins/git/git.plugin.zsh
+++ b/plugins/git/git.plugin.zsh
@@ -37,6 +37,12 @@ alias grset='git remote set-url'
compdef _git grset=git-remote
alias grup='git remote update'
compdef _git grset=git-remote
+alias grbi='git rebase -i'
+compdef _git grbi=git-rebase
+alias grbc='git rebase --continue'
+compdef _git grbc=git-rebase
+alias grba='git rebase --abort'
+compdef _git grba=git-rebase
alias gb='git branch'
compdef _git gb=git-branch
alias gba='git branch -a'
@@ -65,6 +71,13 @@ alias grhh='git reset HEAD --hard'
alias gwc='git whatchanged -p --abbrev-commit --pretty=medium'
alias gf='git ls-files | grep'
alias gpoat='git push origin --all && git push origin --tags'
+alias gmt='git mergetool --no-prompt'
+compdef _git gm=git-mergetool
+
+alias gg='git gui citool'
+alias gga='git gui citool --amend'
+alias gk='gitk --all --branches'
+alias gss='git stash show --text'
# Will cd into the top of the current repository
# or submodule.