Skip to content

Commit

Permalink
[#40] first pass at bash completion
Browse files Browse the repository at this point in the history
  • Loading branch information
zaquestion committed Nov 12, 2017
1 parent 39a8db2 commit e1afa8b
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions completion/lab.bash_completion.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Based on hub's autocompletion script at: https://github.com/github/hub
# If there is no git tab completion, but we have the _completion loader try to load it
if ! declare -F _git > /dev/null && declare -F _completion_loader > /dev/null; then
_completion_loader git
fi

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

# Wrap the 'list_all_commands' function with extra lab commands
__git_list_all_commands() {
cat <<-EOF
fork
mr
issue
merge-request
EOF
__git__list__all__commands_without_lab
}

# Ensure cached commands are cleared
__git_all_commands=""

_git_issue ()
{
__gitcomp "create list"
}

_git_mr ()
{
__gitcomp "checkout create list"
}

complete -o bashdefault -o default -o nospace -F _git lab 2>/dev/null \
|| complete -o default -o nospace -F _git lab
fi

0 comments on commit e1afa8b

Please sign in to comment.