Skip to content

Commit

Permalink
organize and document completion scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
mislav committed Mar 20, 2012
1 parent eadde0a commit 3c0d9fe
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 29 deletions.
8 changes: 8 additions & 0 deletions README.md
Expand Up @@ -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
--------
Expand Down
9 changes: 3 additions & 6 deletions tab_completion/bash → etc/hub.bash_completion.sh
@@ -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
Expand All @@ -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
Expand Down
22 changes: 22 additions & 0 deletions etc/hub.zsh_completion
@@ -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
23 changes: 0 additions & 23 deletions tab_completion/zsh

This file was deleted.

0 comments on commit 3c0d9fe

Please sign in to comment.