Skip to content
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions completion/available/crystal.completion.bash
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
# shellcheck shell=bash
_log_warning 'Bash completion for "crystal" is now covered by "system". This completion can be disabled.'
1 change: 1 addition & 0 deletions completion/available/defaults.completion.bash
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# shellcheck shell=bash
# shellcheck disable=SC1090

if test -s "${BASH_IT?}/vendor/github.com/gaelicWizard/bash-progcomp/defaults.completion.bash"; then
source "$_"
Expand Down
1 change: 1 addition & 0 deletions completion/available/drush.completion.bash
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
# shellcheck shell=bash
_log_warning 'Bash completion for "drush" is now deprecated, as it used code with incompatible license.
Please disable this completion and use the instructions from "drush" developers instead.'
19 changes: 11 additions & 8 deletions completion/available/fabric.completion.bash
Original file line number Diff line number Diff line change
Expand Up @@ -41,18 +41,19 @@ export FAB_COMPLETION_CACHED_TASKS_FILENAME=".fab_tasks~"
# Set command to get time of last file modification as seconds since Epoch
case "$OSTYPE" in
'darwin'* | 'freebsd'*)
__FAB_COMPLETION_MTIME_COMMAND="stat -f '%m'"
__FAB_COMPLETION_MTIME_COMMAND=(stat -f '%m')
;;
*)
__FAB_COMPLETION_MTIME_COMMAND="stat -c '%Y'"
# shellcheck disable=SC2089
__FAB_COMPLETION_MTIME_COMMAND=(stat -c '%Y')
;;
esac

#
# Get time of last fab cache file modification as seconds since Epoch
#
function __fab_chache_mtime() {
${__FAB_COMPLETION_MTIME_COMMAND} \
"${__FAB_COMPLETION_MTIME_COMMAND[@]}" \
$FAB_COMPLETION_CACHED_TASKS_FILENAME | xargs -n 1 expr
}

Expand All @@ -62,10 +63,11 @@ function __fab_chache_mtime() {
function __fab_fabfile_mtime() {
local f="fabfile"
if [[ -e "$f.py" ]]; then
${__FAB_COMPLETION_MTIME_COMMAND} "$f.py" | xargs -n 1 expr
"${__FAB_COMPLETION_MTIME_COMMAND[@]}" "$f.py" | xargs -n 1 expr
else
# Suppose that it's a fabfile dir
find $f/*.py -exec ${__FAB_COMPLETION_MTIME_COMMAND} {} + \
# shellcheck disable=SC2038
find "$f"/*.py -exec "${__FAB_COMPLETION_MTIME_COMMAND[@]}" {} + \
| xargs -n 1 expr | sort -n -r | head -1
fi
}
Expand All @@ -79,13 +81,13 @@ function __fab_completion() {

# Variables to hold the current word and possible matches
local cur="${COMP_WORDS[COMP_CWORD]}"
local opts=()
local opts

# Generate possible matches and store them in variable "opts"
case "${cur}" in
-*)
if [[ -z "${__FAB_COMPLETION_LONG_OPT}" ]]; then
export __FAB_COMPLETION_LONG_OPT=$(
__FAB_COMPLETION_LONG_OPT=$(
fab --help | grep -E -o "\-\-[A-Za-z_\-]+\=?" | sort -u
)
fi
Expand Down Expand Up @@ -124,6 +126,7 @@ function __fab_completion() {
esac

# Set possible completions
COMPREPLY=($(compgen -W "${opts}" -- ${cur}))
COMPREPLY=()
while IFS='' read -r line; do COMPREPLY+=("$line"); done < <(compgen -W "${opts}" -- "${cur}")
}
complete -o default -o nospace -F __fab_completion fab
69 changes: 39 additions & 30 deletions completion/available/gradle.completion.bash
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

# Bash breaks words on : by default. Subproject tasks have ':'
# Avoid inaccurate completions for subproject tasks
COMP_WORDBREAKS=$(echo "$COMP_WORDBREAKS" | sed -e 's/://g')
COMP_WORDBREAKS="${COMP_WORDBREAKS//:/}"

function __gradle-set-project-root-dir() {
project_root_dir="$(_bash-it-find-in-ancestor "settings.gradle" "gradlew")"
Expand All @@ -31,31 +31,32 @@ function __gradle-set-project-root-dir() {

__gradle-init-cache-dir() {
cache_dir="$HOME/.gradle/completion"
mkdir -p $cache_dir
mkdir -p "$cache_dir"
}

__gradle-set-build-file() {
# Look for default build script in the settings file (settings.gradle by default)
# Otherwise, default is the file 'build.gradle' in the current directory.
gradle_build_file="$project_root_dir/build.gradle"
if [[ -f "$project_root_dir/settings.gradle" ]]; then
local build_file_name=$(grep "^rootProject\.buildFileName" "$project_root_dir/settings.gradle" \
local build_file_name
build_file_name=$(grep "^rootProject\.buildFileName" "$project_root_dir/settings.gradle" \
| sed -n -e "s/rootProject\.buildFileName = [\'\"]\(.*\)[\'\"]/\1/p")
gradle_build_file="$project_root_dir/${build_file_name:-build.gradle}"
fi
}

__gradle-set-cache-name() {
# Cache name is constructed from the absolute path of the build file.
cache_name=$(echo $gradle_build_file | sed -e 's/\//_/g')
cache_name=${gradle_build_file//'/'/_}
}

__gradle-set-files-checksum() {
# Cache MD5 sum of all Gradle scripts and modified timestamps
if _command_exists md5; then
gradle_files_checksum=$(md5 -q -s "$(cat "$cache_dir/$cache_name" | xargs ls -o 2> /dev/null)")
gradle_files_checksum=$(md5 -q -s "$(xargs ls -o < "$cache_dir/$cache_name" 2> /dev/null)")
elif _command_exists md5sum; then
gradle_files_checksum=$(cat "$cache_dir/$cache_name" | xargs ls -o 2> /dev/null | md5sum | awk '{print $1}')
gradle_files_checksum=$(xargs ls -o < "$cache_dir/$cache_name" 2> /dev/null | md5sum | awk '{print $1}')
else
echo "Cannot generate completions as neither md5 nor md5sum exist on \$PATH"
fi
Expand All @@ -66,10 +67,11 @@ __gradle-generate-script-cache() {
local cache_ttl_mins=${GRADLE_CACHE_TTL_MINUTES:-30240}
local script_exclude_pattern=${GRADLE_COMPLETION_EXCLUDE_PATTERN:-"/(build|integTest|out)/"}

if [[ ! $(find $cache_dir/$cache_name -mmin -$cache_ttl_mins 2> /dev/null) ]]; then
if [[ ! $(find "$cache_dir/$cache_name" -mmin "-$cache_ttl_mins" 2> /dev/null) ]]; then
# Cache all Gradle scripts
local gradle_build_scripts=$(find $project_root_dir -type f -name "*.gradle" -o -name "*.gradle.kts" 2> /dev/null | grep -E -v "$script_exclude_pattern")
printf "%s\n" "${gradle_build_scripts[@]}" > $cache_dir/$cache_name
local gradle_build_scripts
gradle_build_scripts=$(find "$project_root_dir" -type f -name "*.gradle" -o -name "*.gradle.kts" 2> /dev/null | grep -E -v "$script_exclude_pattern")
printf "%s\n" "${gradle_build_scripts[@]}" > "$cache_dir/$cache_name"
fi
}

Expand Down Expand Up @@ -115,7 +117,8 @@ __gradle-long-options() {
--system-prop - Set a system property
--version - Prints Gradle version info
--warn - Log warnings and errors only"
COMPREPLY=($(compgen -W "$args" -- "${COMP_WORDS[COMP_CWORD]}"))
COMPREPLY=()
while IFS='' read -r line; do COMPREPLY+=("$line"); done < <(compgen -W "$args" -- "${COMP_WORDS[COMP_CWORD]}")
}

__gradle-properties() {
Expand All @@ -130,7 +133,8 @@ __gradle-properties() {
-Dorg.gradle.parallel= - Set true to enable parallel project builds (incubating)
-Dorg.gradle.parallel.intra= - Set true to enable intra-project parallel builds (incubating)
-Dorg.gradle.workers.max= - Set the number of workers Gradle is allowed to use"
COMPREPLY=($(compgen -W "$args" -- "${COMP_WORDS[COMP_CWORD]}"))
COMPREPLY=()
while IFS='' read -r line; do COMPREPLY+=("$line"); done < <(compgen -W "$args" -- "${COMP_WORDS[COMP_CWORD]}")
return 0
}

Expand All @@ -156,7 +160,8 @@ __gradle-short-options() {
-I - Specifies an initialization script
-P - Sets a project property of the root project
-S - Print out the full (very verbose) stacktrace"
COMPREPLY=($(compgen -W "$args" -- "${COMP_WORDS[COMP_CWORD]}"))
COMPREPLY=()
while IFS='' read -r line; do COMPREPLY+=("$line"); done < <(compgen -W "$args" -- "${COMP_WORDS[COMP_CWORD]}")
}

__gradle-notify-tasks-cache-build() {
Expand All @@ -179,10 +184,10 @@ __gradle-generate-tasks-cache() {
# Run gradle to retrieve possible tasks and cache.
# Reuse Gradle Daemon if IDLE but don't start a new one.
local gradle_tasks_output
if [[ ! -z "$($gradle_cmd --status 2> /dev/null | grep IDLE)" ]]; then
gradle_tasks_output="$($gradle_cmd -b $gradle_build_file --daemon -q tasks --all)"
if "$gradle_cmd" --status 2> /dev/null | grep -q IDLE; then
gradle_tasks_output="$("$gradle_cmd" -b "$gradle_build_file" --daemon -q tasks --all)"
else
gradle_tasks_output="$($gradle_cmd -b $gradle_build_file --no-daemon -q tasks --all)"
gradle_tasks_output="$("$gradle_cmd" -b "$gradle_build_file" --no-daemon -q tasks --all)"
fi
local output_line
local task_description
Expand All @@ -206,15 +211,17 @@ __gradle-generate-tasks-cache() {

# subproject tasks can be referenced implicitly from root project
if [[ $GRADLE_COMPLETION_UNQUALIFIED_TASKS == "true" ]]; then
local -a implicit_tasks=()
implicit_tasks=($(comm -23 <(printf "%s\n" "${subproject_tasks[@]}" | sort) <(printf "%s\n" "${root_tasks[@]}" | sort)))
for task in $(printf "%s\n" "${implicit_tasks[@]}"); do
gradle_all_tasks+=($task)
local -a implicit_tasks
while IFS='' read -r line; do
implicit_tasks+=("$line")
done < <(comm -23 <(printf "%s\n" "${subproject_tasks[@]}" | sort) <(printf "%s\n" "${root_tasks[@]}" | sort))
for task in "${implicit_tasks[@]}"; do
gradle_all_tasks+=("$task")
done
fi

printf "%s\n" "${gradle_all_tasks[@]}" > $cache_dir/$gradle_files_checksum
echo $gradle_files_checksum > $cache_dir/$cache_name.md5
printf "%s\n" "${gradle_all_tasks[@]}" > "$cache_dir/$gradle_files_checksum"
echo "$gradle_files_checksum" > "$cache_dir/$cache_name.md5"
}

__gradle-completion-init() {
Expand Down Expand Up @@ -262,22 +269,23 @@ _gradle() {
__gradle-set-files-checksum

# The cache key is md5 sum of all gradle scripts, so it's valid if it exists.
if [[ -f $cache_dir/$cache_name.md5 ]]; then
local cached_checksum="$(cat $cache_dir/$cache_name.md5)"
if [[ -f "$cache_dir/$cache_name.md5" ]]; then
local cached_checksum
cached_checksum="$(cat "$cache_dir/$cache_name.md5")"
local -a cached_tasks
if [[ -z $cur ]]; then
cached_tasks=($(cat $cache_dir/$cached_checksum))
while IFS='' read -r line; do cached_tasks+=("$line"); done < "$cache_dir/$cached_checksum"
else
cached_tasks=($(grep "^$cur" $cache_dir/$cached_checksum))
while IFS='' read -r line; do cached_tasks+=("$line"); done < <(grep "^$cur" "$cache_dir/$cached_checksum")
fi
COMPREPLY=($(compgen -W "${cached_tasks[*]}" -- "$cur"))
while IFS='' read -r line; do COMPREPLY+=("$line"); done < <(compgen -W "${cached_tasks[*]}" -- "$cur")
else
__gradle-notify-tasks-cache-build
fi

# Regenerate tasks cache in the background
if [[ $gradle_files_checksum != "$(cat $cache_dir/$cache_name.md5)" || ! -f $cache_dir/$gradle_files_checksum ]]; then
$(__gradle-generate-tasks-cache 1>&2 2> /dev/null &)
if [[ $gradle_files_checksum != "$(cat "$cache_dir/$cache_name.md5")" || ! -f "$cache_dir/$gradle_files_checksum" ]]; then
"$(__gradle-generate-tasks-cache 1>&2 2> /dev/null &)"
fi
else
# Default tasks available outside Gradle projects
Expand All @@ -293,15 +301,16 @@ projects - Displays the sub-projects of root project.
properties - Displays the properties of root project.
tasks - Displays the tasks runnable from root project.
wrapper - Generates Gradle wrapper files."
COMPREPLY=($(compgen -W "$args" -- "${COMP_WORDS[COMP_CWORD]}"))
COMPREPLY=()
while IFS='' read -r line; do COMPREPLY+=("$line"); done < <(compgen -W "${args}" -- "${cur}")
fi
fi

IFS="$OLDIFS"

# Remove description ("[:space:]" and after) if only one possibility
if [[ ${#COMPREPLY[*]} -eq 1 ]]; then
COMPREPLY=(${COMPREPLY[0]%% *})
COMPREPLY=("${COMPREPLY[0]%% *}")
fi

return 0
Expand Down
1 change: 1 addition & 0 deletions completion/available/homesick.completion.bash
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
# shellcheck shell=bash
_log_warning 'Bash completion for "homesick" is now deprecated, as it used unlicensed code.
Please disable this completion and use the instructions from "homesick" bash completion developers instead.'
2 changes: 1 addition & 1 deletion completion/available/maven.completion.bash
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ _mvn() {
COMPREPLY=($(compgen -W "$cmds" -- "$cur"))
local i=${#COMPREPLY[*]}
while [ "$((--i))" -ge 0 ]; do
COMPREPLY[$i]=${COMPREPLY[$i]#"$colonprefixes"}
COMPREPLY[i]=${COMPREPLY[i]#"$colonprefixes"}
done

return 0
Expand Down
2 changes: 2 additions & 0 deletions completion/available/minishift.completion.bash
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
# shellcheck shell=bash
# shellcheck disable=SC1090
_command_exists minishift && source <(minishift completion bash)
2 changes: 2 additions & 0 deletions completion/available/openshift.completion.bash
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
# shellcheck shell=bash
# shellcheck disable=SC1090
_command_exists oc && source <(oc completion bash)
1 change: 1 addition & 0 deletions completion/available/pew.completion.bash
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# shellcheck shell=bash
# shellcheck disable=SC1090

if _command_exists pew; then
source "$(pew shell_config)"
Expand Down
7 changes: 4 additions & 3 deletions completion/available/rvm.completion.bash
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/usr/bin/env bash
# Bash completion support for RVM.
# shellcheck shell=bash
# shellcheck disable=SC2154,SC1091
# Bash completion support for RVM.
# Source: https://rvm.io/workflow/completion

[[ -r $rvm_path/scripts/completion ]] && . $rvm_path/scripts/completion
[[ -r $rvm_path/scripts/completion ]] && . "$rvm_path/scripts/completion"
1 change: 1 addition & 0 deletions completion/available/todo.completion.bash
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
# shellcheck shell=bash
_log_warning 'Bash completion for "todo.txt-cli" is now deprecated, as it used code with incompatible license.
Please disable this completion and use the instructions from "todo.txt-cli" developers instead.'
1 change: 1 addition & 0 deletions completion/available/travis.completion.bash
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# shellcheck shell=bash
# shellcheck disable=SC1090

if _command_exists travis; then
if [[ -s "${__TRAVIS_COMPLETION_SCRIPT:=${TRAVIS_CONFIG_PATH:-${HOME}/.travis}/travis.sh}" ]]; then
Expand Down
Loading
Loading