hub.bash_completion.sh 844 字节
Newer Older
1 2
# hub tab-completion script for bash.
# This script complements the completion script that ships with git.
N
Nathan Broadbent 已提交
3 4 5 6 7 8 9 10 11 12

# 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_without_hub/')"

  # Wrap the 'list_all_commands' function with extra hub commands
  __git_list_all_commands() {
    cat <<-EOF
13
alias
N
Nathan Broadbent 已提交
14 15 16 17 18
pull-request
fork
create
browse
compare
19
ci-status
N
Nathan Broadbent 已提交
20 21 22 23 24 25
EOF
    __git_list_all_commands_without_hub
  }

  # Ensure cached commands are cleared
  __git_all_commands=""
26 27 28 29

  # Enable completion for hub even when not using the alias
  complete -o bashdefault -o default -o nospace -F _git hub 2>/dev/null \
    || complete -o default -o nospace -F _git hub
N
Nathan Broadbent 已提交
30
fi