Merge pull request #1801 from NoahGorny/cleanup/gh-completions

cleanup/gh completions
pull/1798/head
Noah Gorny 2021-01-28 17:44:21 +02:00 committed by GitHub
commit c2d971f20e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 16 additions and 5 deletions

View File

@ -64,6 +64,7 @@ completion/available/conda.completion.bash
completion/available/consul.completion.bash completion/available/consul.completion.bash
completion/available/docker.completion.bash completion/available/docker.completion.bash
completion/available/gcloud.completion.bash completion/available/gcloud.completion.bash
completion/available/github-cli.completion.bash
completion/available/helm.completion.bash completion/available/helm.completion.bash
completion/available/knife.completion.bash completion/available/knife.completion.bash
completion/available/packer.completion.bash completion/available/packer.completion.bash

View File

@ -1,10 +1,9 @@
#!/usr/bin/env bash # shellcheck shell=bash
cite "about-completion" cite "about-completion"
about-completion "GitHub CLI completion" about-completion "GitHub CLI completion"
if _binary_exists gh; then if _binary_exists gh; then
if _command_exists brew; then # If gh already completed, stop
_log_warning "You don't need github-cli completion enabled if you have system completion enabled" _completion_exists gh && return
fi
eval "$(gh completion --shell=bash)" eval "$(gh completion --shell=bash)"
fi fi

View File

@ -37,6 +37,17 @@ function _binary_exists ()
type -P "$1" &> /dev/null || (_log_warning "$msg" && return 1) ; 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() { function _make_reload_alias() {
echo "source \${BASH_IT}/scripts/reloader.bash ${1} ${2}" echo "source \${BASH_IT}/scripts/reloader.bash ${1} ${2}"
} }