Permalink
Browse files

organize and document completion scripts

  • Loading branch information...
1 parent eadde0a commit 3c0d9fee81bcd68ac1070dfeb0cb3dbd9abdd1f2 @mislav mislav committed Mar 20, 2012
Showing with 33 additions and 29 deletions.
  1. +8 −0 README.md
  2. +3 −6 tab_completion/bash → etc/hub.bash_completion.sh
  3. +22 −0 etc/hub.zsh_completion
  4. +0 −23 tab_completion/zsh
View
@@ -109,6 +109,14 @@ You should place this command in your `.bash_profile` or other startup script:
eval "$(hub alias -s)"
~~~
+### Shell tab-completion
+
+hub repository contains tab-completion scripts for bash and zsh. These scripts
+complement existing completion scripts that ship with git.
+
+* [hub bash completion](https://github.com/defunkt/hub/blob/master/etc/hub.bash_completion.sh)
+* [hub zsh completion](https://github.com/defunkt/hub/blob/master/etc/hub.zsh_completion)
+
Commands
--------
@@ -1,9 +1,5 @@
-#
-# Source this file from your ~/.bashrc
-#
-# bash completion support for hub.
-# Adds hub commands to __git_list_all_commands function.
-# -------------------------------------------------------------
+# hub tab-completion script for bash.
+# This script complements the completion script that ships with git.
# Check that git tab completion is available
if declare -F _git > /dev/null; then
@@ -14,6 +10,7 @@ if declare -F _git > /dev/null; then
# Wrap the 'list_all_commands' function with extra hub commands
__git_list_all_commands() {
cat <<-EOF
+alias
pull-request
fork
create
View
@@ -0,0 +1,22 @@
+# hub tab-completion script for zsh.
+# This script complements the completion script that ships with git.
+#
+# vim: ft=zsh sw=2 ts=2 et
+
+# Autoload _git completion functions
+if declare -f _git > /dev/null; then
+ _git
+fi
+
+if declare -f _git_commands > /dev/null; then
+ _hub_commands=(
+ 'alias:show shell instructions for wrapping git'
+ 'pull-request:open a pull request on GitHub'
+ 'fork:fork origin repo on GitHub'
+ 'create:create new repo on GitHub for the current project'
+ 'browse:browse the project on GitHub'
+ 'compare:open GitHub compare view'
+ )
+ # Extend the '_git_commands' function with hub commands
+ eval "$(declare -f _git_commands | sed -e 's/base_commands=(/base_commands=(${_hub_commands} /')"
+fi
View
@@ -1,23 +0,0 @@
-#
-# Source this file from your ~/.zshrc
-#
-# zsh completion support for hub.
-# Adds hub commands to _git_commands function.
-# -------------------------------------------------------------
-
-# Autoload _git completion functions
-if declare -f _git > /dev/null; then
- _git
-fi
-
-if declare -f _git_commands > /dev/null; then
- _hub_commands=(
- 'pull-request:create a pull request on github'
- 'fork:create a fork on github; add remote to local repo'
- 'create:create repo on github for the current directory'
- 'browse:open your browser to the repo'\''s page on github'
- 'compare:open your browser to the github compare page'
- )
- # Extend the '_git_commands' function with hub commands
- eval "$(declare -f _git_commands | sed -e 's/base_commands=(/base_commands=(${_hub_commands} /')"
-fi

0 comments on commit 3c0d9fe

Please sign in to comment.