Skip to content

Commit

Permalink
Merge pull request #2284 from Bash-it/ira/cleanup6-completions
Browse files Browse the repository at this point in the history
  • Loading branch information
seefood authored Feb 1, 2025
2 parents 719827f + 9f3cf40 commit 081457e
Show file tree
Hide file tree
Showing 19 changed files with 199 additions and 218 deletions.
57 changes: 1 addition & 56 deletions clean_files.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
# root directories
#
aliases/
completions/
docs/
hooks/
lib/
Expand All @@ -32,62 +33,6 @@ clean_files.txt
install.sh
lint_clean_files.sh

# completions
#
completion/available/aliases.completion.bash
completion/available/apm.completion.bash
completion/available/awless.completion.bash
completion/available/awscli.completion.bash
completion/available/bash-it.completion.bash
completion/available/brew.completion.bash
completion/available/bundler.completion.bash
completion/available/capistrano.completion.bash
completion/available/cargo.completion.bash
completion/available/composer.completion.bash
completion/available/conda.completion.bash
completion/available/consul.completion.bash
completion/available/dart.completion.bash
completion/available/dirs.completion.bash
completion/available/django.completion.bash
completion/available/dmidecode.completion.bash
completion/available/docker-compose.completion.bash
completion/available/docker-machine.completion.bash
completion/available/docker.completion.bash
completion/available/dotnet.completion.bash
completion/available/export.completion.bash
completion/available/flutter.completion.bash
completion/available/gcloud.completion.bash
completion/available/gem.completion.bash
completion/available/git.completion.bash
completion/available/github-cli.completion.bash
completion/available/go.completion.bash
completion/available/helm.completion.bash
completion/available/jboss5.completion.bash
completion/available/jboss7.completion.bash
completion/available/jungle.completion.bash
completion/available/knife.completion.bash
completion/available/kontena.completion.bash
completion/available/kubectl.completion.bash
completion/available/laravel.completion.bash
completion/available/lerna.completion.bash
completion/available/minikube.completion.bash
completion/available/ngrok.completion.bash
completion/available/notify-send.completion.bash
completion/available/npm.completion.bash
completion/available/packer.completion.bash
completion/available/pip.completion.bash
completion/available/pip3.completion.bash
completion/available/pipenv.completion.bash
completion/available/pipx.completion.bash
completion/available/rustup.completion.bash
completion/available/salt.completion.bash
completion/available/sdkman.completion.bash
completion/available/system.completion.bash
completion/available/vault.completion.bash
completion/available/vuejs.completion.bash
completion/available/wpscan.completion.bash
completion/available/yarn.completion.bash

# themes
#
themes/90210
Expand Down
22 changes: 13 additions & 9 deletions completion/available/git_flow.completion.bash
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!bash
# shellcheck shell=bash
#
# git-flow-completion
# ===================
Expand Down Expand Up @@ -46,8 +46,9 @@
# Distributed under the [MIT License](http://creativecommons.org/licenses/MIT/)

_git_flow() {
local subcommands="init feature release hotfix"
local subcommand="$(__git_find_subcommand "$subcommands")"
local subcommands subcommand
subcommands="init feature release hotfix"
subcommand="$(__git_find_subcommand "$subcommands")"
if [ -z "$subcommand" ]; then
__gitcomp "$subcommands"
return
Expand All @@ -73,8 +74,9 @@ _git_flow() {
}

__git_flow_feature() {
local subcommands="list start finish publish track diff rebase checkout pull"
local subcommand="$(__git_find_subcommand "$subcommands")"
local subcommands subcommand
subcommands="list start finish publish track diff rebase checkout pull"
subcommand="$(__git_find_subcommand "$subcommands")"
if [ -z "$subcommand" ]; then
__gitcomp "$subcommands"
return
Expand Down Expand Up @@ -116,8 +118,9 @@ __git_flow_feature_prefix() {
}

__git_flow_release() {
local subcommands="list start finish"
local subcommand="$(__git_find_subcommand "$subcommands")"
local subcommands subcommand
subcommands="list start finish"
subcommand="$(__git_find_subcommand "$subcommands")"
if [ -z "$subcommand" ]; then
__gitcomp "$subcommands"
return
Expand All @@ -140,8 +143,9 @@ __git_flow_list_releases() {
}

__git_flow_hotfix() {
local subcommands="list start finish"
local subcommand="$(__git_find_subcommand "$subcommands")"
local subcommands subcommand
subcommands="list start finish"
subcommand="$(__git_find_subcommand "$subcommands")"
if [ -z "$subcommand" ]; then
__gitcomp "$subcommands"
return
Expand Down
65 changes: 38 additions & 27 deletions completion/available/git_flow_avh.completion.bash
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!bash
# shellcheck shell=bash
# shellcheck disable=SC2154,SC2030,SC2031
#
# git-flow-completion
# ===================
Expand Down Expand Up @@ -54,8 +55,9 @@ __git_flow_config_file_options="
"

_git_flow() {
local subcommands="init feature release hotfix support help version config finish delete publish rebase"
local subcommand="$(__git_find_on_cmdline "$subcommands")"
local subcommands subcommand
subcommands="init feature release hotfix support help version config finish delete publish rebase"
subcommand="$(__git_find_on_cmdline "$subcommands")"
if [ -z "$subcommand" ]; then
__gitcomp "$subcommands"
return
Expand Down Expand Up @@ -93,8 +95,9 @@ _git_flow() {
}

__git_flow_init() {
local subcommands="help"
local subcommand="$(__git_find_on_cmdline "$subcommands")"
local subcommands subcommand
subcommands="help"
subcommand="$(__git_find_on_cmdline "$subcommands")"
if [ -z "$subcommand" ]; then
__gitcomp "$subcommands"
fi
Expand All @@ -112,8 +115,9 @@ __git_flow_init() {
}

__git_flow_feature() {
local subcommands="list start finish publish track diff rebase checkout pull help delete"
local subcommand="$(__git_find_on_cmdline "$subcommands")"
local subcommands subcommand
subcommands="list start finish publish track diff rebase checkout pull help delete"
subcommand="$(__git_find_on_cmdline "$subcommands")"

if [ -z "$subcommand" ]; then
__gitcomp "$subcommands"
Expand Down Expand Up @@ -194,8 +198,9 @@ __git_flow_feature() {
}

__git_flow_release() {
local subcommands="list start finish track publish help delete"
local subcommand="$(__git_find_on_cmdline "$subcommands")"
local subcommands subcommand
subcommands="list start finish track publish help delete"
subcommand="$(__git_find_on_cmdline "$subcommands")"
if [ -z "$subcommand" ]; then
__gitcomp "$subcommands"
return
Expand Down Expand Up @@ -279,8 +284,9 @@ __git_flow_release() {
}

__git_flow_hotfix() {
local subcommands="list start finish track publish help delete"
local subcommand="$(__git_find_on_cmdline "$subcommands")"
local subcommands subcommand
subcommands="list start finish track publish help delete"
subcommand="$(__git_find_on_cmdline "$subcommands")"
if [ -z "$subcommand" ]; then
__gitcomp "$subcommands"
return
Expand Down Expand Up @@ -362,8 +368,9 @@ __git_flow_hotfix() {
}

__git_flow_support() {
local subcommands="list start help"
local subcommand="$(__git_find_on_cmdline "$subcommands")"
local subcommands subcommand
subcommands="list start help"
subcommand="$(__git_find_on_cmdline "$subcommands")"
if [ -z "$subcommand" ]; then
__gitcomp "$subcommands"
return
Expand Down Expand Up @@ -401,8 +408,9 @@ __git_flow_support() {
}

__git_flow_config() {
local subcommands="list set base"
local subcommand="$(__git_find_on_cmdline "$subcommands")"
local subcommands subcommand
subcommands="list set base"
subcommand="$(__git_find_on_cmdline "$subcommands")"
if [ -z "$subcommand" ]; then
__gitcomp "$subcommands"
return
Expand Down Expand Up @@ -454,11 +462,12 @@ __git_flow_prefix() {

__git_flow_list_local_branches() {
if [ -n "$1" ]; then
local prefix="$(__git_flow_prefix $1)"
git for-each-ref --shell --format="ref=%(refname:short)" refs/heads/$prefix \
local prefix
prefix="$(__git_flow_prefix "$1")"
git for-each-ref --shell --format="ref=%(refname:short)" "refs/heads/$prefix" \
| while read -r entry; do
eval "$entry"
ref="${ref#$prefix}"
ref="${ref#"$prefix"}"
echo "$ref"
done | sort
else
Expand All @@ -468,28 +477,30 @@ __git_flow_list_local_branches() {
}

__git_flow_list_remote_branches() {
local prefix="$(__git_flow_prefix $1)"
local origin="$(git config gitflow.origin 2> /dev/null || echo "origin")"
git for-each-ref --shell --format='%(refname:short)' refs/remotes/$origin/$prefix \
local prefix origin
prefix="$(__git_flow_prefix "$1")"
origin="$(git config gitflow.origin 2> /dev/null || echo "origin")"
git for-each-ref --shell --format='ref=%refname:short)' "refs/remotes/$origin/$prefix" \
| while read -r entry; do
eval "$entry"
ref="${ref##$prefix}"
ref="${ref##"$prefix"}"
echo "$ref"
done | sort
}

__git_flow_list_branches() {
local origin="$(git config gitflow.origin 2> /dev/null || echo "origin")"
local origin prefix
origin="$(git config gitflow.origin 2> /dev/null || echo "origin")"
if [ -n "$1" ]; then
local prefix="$(__git_flow_prefix $1)"
git for-each-ref --shell --format="ref=%(refname:short)" refs/heads/$prefix refs/remotes/$origin/$prefix \
prefix="$(__git_flow_prefix "$1")"
git for-each-ref --shell --format="ref=%(refname:short)" "refs/heads/$prefix" "refs/remotes/$origin/$prefix" \
| while read -r entry; do
eval "$entry"
ref="${ref##$prefix}"
ref="${ref##"$prefix"}"
echo "$ref"
done | sort
else
git for-each-ref --format="%(refname:short)" refs/heads/ refs/remotes/$origin | sort
git for-each-ref --format="%(refname:short)" refs/heads/ "refs/remotes/$origin" | sort
fi
}

Expand Down
16 changes: 9 additions & 7 deletions completion/available/grunt.completion.bash
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
# shellcheck shell=bash

# grunt-cli
# http://gruntjs.com/
Expand Down Expand Up @@ -57,19 +57,21 @@ function _grunt_gruntfile() {

# Enable bash autocompletion.
function _grunt_completions() {
local cur gruntfile gruntinfo opts compls line
# The currently-being-completed word.
local cur="${COMP_WORDS[COMP_CWORD]}"
cur="${COMP_WORDS[COMP_CWORD]}"
# The current gruntfile, if it exists.
local gruntfile="$(_grunt_gruntfile)"
gruntfile="$(_grunt_gruntfile)"
# The current grunt version, available tasks, options, etc.
local gruntinfo="$(grunt --version --verbose 2> /dev/null)"
gruntinfo="$(grunt --version --verbose 2> /dev/null)"
# Options and tasks.
local opts="$(echo "$gruntinfo" | awk '/Available options: / {$1=$2=""; print $0}')"
local compls="$(echo "$gruntinfo" | awk '/Available tasks: / {$1=$2=""; print $0}')"
opts="$(echo "$gruntinfo" | awk '/Available options: / {$1=$2=""; print $0}')"
compls="$(echo "$gruntinfo" | awk '/Available tasks: / {$1=$2=""; print $0}')"
# Only add -- or - options if the user has started typing -
[[ "$cur" == -* ]] && compls="$compls $opts"
# Tell complete what stuff to show.
COMPREPLY=($(compgen -W "$compls" -- "$cur"))

while IFS='' read -r line; do COMPREPLY+=("$line"); done < <(compgen -W "$compls" -- "$cur")
}

complete -o default -F _grunt_completions grunt
7 changes: 4 additions & 3 deletions completion/available/gulp.completion.bash
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
# shellcheck shell=bash
# Borrowed from grunt-cli
# http://gruntjs.com/
#
Expand Down Expand Up @@ -43,8 +43,9 @@ function _gulp_completions() {
# The currently-being-completed word.
local cur="${COMP_WORDS[COMP_CWORD]}"
#Grab tasks
local compls=$(gulp --tasks-simple)
local line compls
compls=$(gulp --tasks-simple)
# Tell complete what stuff to show.
COMPREPLY=($(compgen -W "$compls" -- "$cur"))
while IFS='' read -r line; do COMPREPLY+=("$line"); done < <(compgen -W "$compls" -- "$cur")
}
complete -o default -F _gulp_completions gulp
Loading

0 comments on commit 081457e

Please sign in to comment.