diff --git a/clean_files.txt b/clean_files.txt index b49952d1..ddafc469 100644 --- a/clean_files.txt +++ b/clean_files.txt @@ -64,6 +64,7 @@ completion/available/conda.completion.bash completion/available/consul.completion.bash completion/available/docker.completion.bash completion/available/gcloud.completion.bash +completion/available/github-cli.completion.bash completion/available/helm.completion.bash completion/available/knife.completion.bash completion/available/packer.completion.bash diff --git a/completion/available/github-cli.completion.bash b/completion/available/github-cli.completion.bash index 7b7c9fa0..4a611394 100644 --- a/completion/available/github-cli.completion.bash +++ b/completion/available/github-cli.completion.bash @@ -1,10 +1,9 @@ -#!/usr/bin/env bash +# shellcheck shell=bash cite "about-completion" about-completion "GitHub CLI completion" if _binary_exists gh; then - if _command_exists brew; then - _log_warning "You don't need github-cli completion enabled if you have system completion enabled" - fi - eval "$(gh completion --shell=bash)" + # If gh already completed, stop + _completion_exists gh && return + eval "$(gh completion --shell=bash)" fi diff --git a/lib/helpers.bash b/lib/helpers.bash index 436fc59e..b89bad3d 100644 --- a/lib/helpers.bash +++ b/lib/helpers.bash @@ -37,6 +37,17 @@ function _binary_exists () type -P "$1" &> /dev/null || (_log_warning "$msg" && return 1) ; } +function _completion_exists () +{ + _about 'checks for existence of a completion' + _param '1: command to check' + _param '2: (optional) log message to include when completion is found' + _example '$ _completion_exists gh && echo exists' + _group 'lib' + local msg="${2:-Completion for '$1' already exists!}" + complete -p "$1" &> /dev/null && _log_warning "$msg" ; +} + function _make_reload_alias() { echo "source \${BASH_IT}/scripts/reloader.bash ${1} ${2}" }