Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 2 additions & 0 deletions completion/available/crystal.completion.bash
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
# 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,5 +1,6 @@
# shellcheck shell=bash

if test -s "${BASH_IT?}/vendor/github.com/gaelicWizard/bash-progcomp/defaults.completion.bash"; then
# shellcheck disable=SC1090
source "$_"
fi
2 changes: 2 additions & 0 deletions completion/available/drush.completion.bash
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
# 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.'
13 changes: 7 additions & 6 deletions completion/available/fabric.completion.bash
Original file line number Diff line number Diff line change
Expand Up @@ -41,18 +41,18 @@ 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'"
__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 +62,10 @@ 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} {} + \
find "$f"/*.py -exec "${__FAB_COMPLETION_MTIME_COMMAND[@]}" {} + \
| xargs -n 1 expr | sort -n -r | head -1
fi
}
Expand All @@ -85,9 +85,10 @@ function __fab_completion() {
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
)
export __FAB_COMPLETION_LONG_OPT
fi
opts="${__FAB_COMPLETION_LONG_OPT}"
;;
Expand Down
38 changes: 20 additions & 18 deletions completion/available/gradle.completion.bash
Original file line number Diff line number Diff line change
Expand Up @@ -31,23 +31,24 @@

__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=$(echo "$gradle_build_file" | sed -e 's/\//_/g')
}

__gradle-set-files-checksum() {
Expand All @@ -63,13 +64,14 @@

__gradle-generate-script-cache() {
# Invalidate cache after 3 weeks by default
local cache_ttl_mins=${GRADLE_CACHE_TTL_MINUTES:-30240}
local script_exclude_pattern=${GRADLE_COMPLETION_EXCLUDE_PATTERN:-"/(build|integTest|out)/"}
local cache_ttl_mins script_exclude_pattern gradle_build_scripts
cache_ttl_mins=${GRADLE_CACHE_TTL_MINUTES:-30240}
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
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 @@ -179,10 +181,10 @@
# 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 [[ -n "$("$gradle_cmd" --status 2> /dev/null | grep 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 @@ -209,12 +211,12 @@
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)
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 @@ -263,20 +265,20 @@

# 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)"
local cached_checksum="$(cat "$cache_dir/$cache_name.md5")"
local -a cached_tasks
if [[ -z $cur ]]; then
cached_tasks=($(cat $cache_dir/$cached_checksum))
cached_tasks=($(cat "$cache_dir/$cached_checksum"))
else
cached_tasks=($(grep "^$cur" $cache_dir/$cached_checksum))
cached_tasks=($(grep "^$cur" "$cache_dir/$cached_checksum"))
fi
COMPREPLY=($(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
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
Expand Down
2 changes: 2 additions & 0 deletions completion/available/homesick.completion.bash
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
# 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.'
3 changes: 3 additions & 0 deletions completion/available/minishift.completion.bash
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
# shellcheck shell=bash

# shellcheck disable=SC1090
_command_exists minishift && source <(minishift completion bash)
3 changes: 3 additions & 0 deletions completion/available/openshift.completion.bash
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
# 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,5 +1,6 @@
# shellcheck shell=bash

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

[[ -r $rvm_path/scripts/completion ]] && . $rvm_path/scripts/completion
# shellcheck disable=SC2086
[[ -r "$rvm_path/scripts/completion" ]] && . "$rvm_path/scripts/completion"
2 changes: 2 additions & 0 deletions completion/available/todo.completion.bash
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
# 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
Expand Up @@ -2,6 +2,7 @@

if _command_exists travis; then
if [[ -s "${__TRAVIS_COMPLETION_SCRIPT:=${TRAVIS_CONFIG_PATH:-${HOME}/.travis}/travis.sh}" ]]; then
# shellcheck disable=SC1090
source "${__TRAVIS_COMPLETION_SCRIPT}"
fi
unset __TRAVIS_COMPLETION_SCRIPT
Expand Down
30 changes: 16 additions & 14 deletions completion/available/vagrant.completion.bash
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
# shellcheck shell=bash

# (The MIT License)
#
Expand Down Expand Up @@ -26,21 +26,21 @@ __pwdln() {
pwdmod="${PWD}/"
itr=0
until [[ -z "$pwdmod" ]]; do
itr=$(($itr + 1))
itr=$((itr + 1))
pwdmod="${pwdmod#*/}"
done
echo -n $(($itr - 1))
echo -n $((itr - 1))
}

__vagrantinvestigate() {
if [ -f "${PWD}/.vagrant" -o -d "${PWD}/.vagrant" ]; then
if [ -f "${PWD}/.vagrant" ] || [ -d "${PWD}/.vagrant" ]; then
echo "${PWD}/.vagrant"
return 0
else
pwdmod2="${PWD}"
for ((i = 2; i <= $(__pwdln); i++)); do
pwdmod2="${pwdmod2%/*}"
if [ -f "${pwdmod2}/.vagrant" -o -d "${pwdmod2}/.vagrant" ]; then
if [ -f "${pwdmod2}/.vagrant" ] || [ -d "${pwdmod2}/.vagrant" ]; then
echo "${pwdmod2}/.vagrant"
return 0
fi
Expand All @@ -54,12 +54,12 @@ _vagrant() {
prev="${COMP_WORDS[COMP_CWORD - 1]}"
commands="box cloud destroy global-status halt help hostmanager init login package plugin port powershell provision push rdp reload resume scp snapshot ssh ssh-config status suspend up upload validate vbguest version winrm winrm-config"

if [ $COMP_CWORD == 1 ]; then
if [ "$COMP_CWORD" == 1 ]; then
COMPREPLY=($(compgen -W "${commands}" -- ${cur}))
return 0
fi

if [ $COMP_CWORD == 2 ]; then
if [ "$COMP_CWORD" == 2 ]; then
case "$prev" in
"init")
local box_list=$(find "$HOME/.vagrant.d/boxes" -mindepth 1 -maxdepth 1 -type d -exec basename {} \; | sed -e 's/-VAGRANTSLASH-/\//')
Expand All @@ -69,7 +69,7 @@ _vagrant() {
"up")
vagrant_state_file=$(__vagrantinvestigate) || return 1
if [[ -d $vagrant_state_file ]]; then
vm_list=$(find $vagrant_state_file/machines -mindepth 1 -maxdepth 1 -type d -exec basename {} \;)
vm_list=$(find "$vagrant_state_file/machines" -mindepth 1 -maxdepth 1 -type d -exec basename {} \;)
fi
local up_commands="--no-provision"
COMPREPLY=($(compgen -W "${up_commands} ${vm_list}" -- ${cur}))
Expand All @@ -78,9 +78,9 @@ _vagrant() {
"ssh" | "provision" | "reload" | "halt" | "suspend" | "resume" | "ssh-config")
vagrant_state_file=$(__vagrantinvestigate) || return 1
if [[ -f $vagrant_state_file ]]; then
running_vm_list=$(grep 'active' $vagrant_state_file | sed -e 's/"active"://' | tr ',' '\n' | cut -d '"' -f 2 | tr '\n' ' ')
running_vm_list=$(grep 'active' "$vagrant_state_file" | sed -e 's/"active"://' | tr ',' '\n' | cut -d '"' -f 2 | tr '\n' ' ')
else
running_vm_list=$(find $vagrant_state_file -type f -name "id" | awk -F"/" '{print $(NF-2)}')
running_vm_list=$(find "$vagrant_state_file" -type f -name "id" | awk -F"/" '{print $(NF-2)}')
fi
COMPREPLY=($(compgen -W "${running_vm_list}" -- ${cur}))
return 0
Expand Down Expand Up @@ -108,7 +108,7 @@ _vagrant() {
esac
fi

if [ $COMP_CWORD == 3 ]; then
if [ "$COMP_CWORD" == 3 ]; then
action="${COMP_WORDS[COMP_CWORD - 2]}"
case "$action" in
"up")
Expand All @@ -120,7 +120,8 @@ _vagrant() {
"box")
case "$prev" in
"remove" | "repackage")
local box_list=$(find "$HOME/.vagrant.d/boxes" -mindepth 1 -maxdepth 1 -type d -exec basename {} \; | sed -e 's/-VAGRANTSLASH-/\//')
local box_list
box_list=$(find "$HOME/.vagrant.d/boxes" -mindepth 1 -maxdepth 1 -type d -exec basename {} \; | sed -e 's/-VAGRANTSLASH-/\//')
COMPREPLY=($(compgen -W "${box_list}" -- ${cur}))
return 0
;;
Expand All @@ -136,13 +137,14 @@ _vagrant() {
esac
fi

if [ $COMP_CWORD == 4 ]; then
if [ "$COMP_CWORD" == 4 ]; then
action="${COMP_WORDS[COMP_CWORD - 3]}"
prev="${COMP_WORDS[COMP_CWORD - 2]}"
case "$action" in
"snapshot")
if [ "$prev" == "restore" ]; then
local snapshot_list="$(vagrant snapshot list ${cur} 2> /dev/null | awk '{ORS=" "} /==>/ {next} {print}')"
local snapshot_list
snapshot_list="$(vagrant snapshot list ${cur} 2> /dev/null | awk '{ORS=" "} /==>/ {next} {print}')"
COMPREPLY=($(compgen -W "${snapshot_list}" -- ${cur}))
return 0
fi
Expand Down
2 changes: 2 additions & 0 deletions completion/available/virsh.completion.bash
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
# shellcheck shell=bash

_log_warning 'Bash completion for "virsh" is now deprecated, as it used code with incompatible license.
Please disable this completion and use the instructions from "virsh" developers instead.'
Loading