Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: ndbroadbent/hub
base: master
...
head fork: ndbroadbent/hub
compare: tab_completion
Checking mergeability… Don’t worry, you can still create the pull request.
  • 6 commits
  • 3 files changed
  • 0 commit comments
  • 1 contributor
Showing with 71 additions and 0 deletions.
  1. +20 −0 README.md
  2. +28 −0 tab_completion/bash
  3. +23 −0 tab_completion/zsh
View
20 README.md
@@ -111,6 +111,26 @@ The alias command can also be eval'd directly using the `-s` flag:
$ eval `hub alias -s bash`
+Tab Completion
+--------------
+
+Install tab completion for the extra `hub` commands:
+
+#### Bash
+
+ # Download completion override
+ curl https://raw.github.com/defunkt/hub/master/tab_completion/bash -sLo $HOME/.hub.bash_completion &&
+ # Source from ~/.bashrc
+ echo "source $HOME/.hub.bash_completion" >> $HOME/.bashrc
+
+#### Zsh
+
+ # Download completion override
+ curl https://raw.github.com/defunkt/hub/master/tab_completion/zsh -sLo $HOME/.hub.zsh_completion &&
+ # Source from ~/.zshrc
+ echo "source $HOME/.hub.zsh_completion" >> $HOME/.zshrc
+
+
Commands
--------
View
28 tab_completion/bash
@@ -0,0 +1,28 @@
+#
+# Source this file from your ~/.bashrc
+#
+# bash completion support for hub.
+# Adds hub commands to __git_list_all_commands function.
+# -------------------------------------------------------------
+
+# Check that git tab completion is available
+if declare -F _git > /dev/null; then
+ # Duplicate and rename the 'list_all_commands' function
+ eval "$(declare -f __git_list_all_commands | \
+ sed 's/__git_list_all_commands/__git_list_all_commands_original/')"
+
+ # Wrap the 'list_all_commands' function with extra hub commands
+ __git_list_all_commands() {
+ cat <<-EOF
+pull-request
+fork
+create
+browse
+compare
+EOF
+ __git_list_all_commands_original
+ }
+
+ # Ensure cached commands are cleared
+ __git_all_commands=""
+fi
View
23 tab_completion/zsh
@@ -0,0 +1,23 @@
+#
+# 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

No commit comments for this range

Something went wrong with that request. Please try again.