Skip to content

Instantly share code, notes, and snippets.

@glidenote
Created February 24, 2012 06:36
Show Gist options
  • Save glidenote/1898417 to your computer and use it in GitHub Desktop.
Save glidenote/1898417 to your computer and use it in GitHub Desktop.
_git.diff
diff --git a/_git b/_git
index 8a48c04..f1efd6d 100644
--- a/_git
+++ b/_git
@@ -4449,6 +4449,44 @@ _git-stripspace () {
'(-s --strip-comments)'{-s,--strip-comments}'[also strip lines starting with #]'
}
+# HUB CUSTOM COMPLETION FUNCTIONS
+
+(( $+functions[_git-create] )) ||
+_git-create () {
+ _arguments \
+ '-p[create a private repository]' \
+ '-d[set the repository description]' \
+ '-h[set the homepage URL]'
+}
+
+(( $+functions[_git-browse] )) ||
+_git-browse () {
+ _arguments \
+ '-u[set USER and REPOSITORY (USER/REPOSITORY)]' \
+}
+
+(( $+functions[_git-compare] )) ||
+_git-compare () {
+ _arguments \
+ '-u[set USER]' \
+}
+
+(( $+functions[_git-fork] )) ||
+_git-fork () {
+ _arguments \
+ '--no-remote[ ]'
+}
+
+(( $+functions[_git-pull-request] )) ||
+_git-pull-request () {
+ _arguments \
+ '-f[skip check]' \
+ '-b[set BASE pull request]' \
+ '-h[set HEAD pull request]' \
+ '-i[set ISSUE number]' \
+}
+
+
# INTERNAL GIT COMPLETION FUNCTIONS
# Generic Helpers
@@ -4700,6 +4738,15 @@ _git_commands () {
patch-id:'compute unique ID for a patch'
stripspace:'filter out empty lines')
+ local -a hub_custom_commands
+ hub_custom_commands=(
+ create:"repo created on GitHub"
+ browse:"open repository's GitHub page in the system's default web browser"
+ compare:"open a GitHub compare view page in the system's default web browser."
+ fork:"repo forked on GitHub"
+ pull-request:"opens a pull request on GitHub for the project that the 'origin' remote points to."
+ )
+
local -a user_commands
zstyle -a :completion:$curcontext: user-commands user_commands
@@ -4725,6 +4772,7 @@ _git_commands () {
plumbing_sync_commands[(I)$name:*] ||
plumbing_sync_helper_commands[(I)$name:*] ||
plumbing_internal_helper_commands[(I)$name:*] )) || unique_aliases+=$alias
+ hub_custom_commands[(I)$name:*] ||
done
integer ret=1
@@ -4743,6 +4791,7 @@ _git_commands () {
_describe -t plumbing-sync-commands 'plumbing sync command' plumbing_sync_commands && ret=0
_describe -t plumbing-sync-helper-commands 'plumbing sync helper command' plumbing_sync_helper_commands && ret=0
_describe -t plumbing-internal-helper-commands 'plumbing internal helper command' plumbing_internal_helper_commands && ret=0
+ _describe -t hub-custom-command 'hub custom command' hub_custom_commands && ret=0
return ret
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment