Merge pull request #1801 from NoahGorny/cleanup/gh-completions
cleanup/gh completionspull/1798/head
commit
c2d971f20e
|
|
@ -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
|
||||||
|
|
|
||||||
|
|
@ -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
|
||||||
|
|
|
||||||
|
|
@ -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}"
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue