add bash-it
This commit is contained in:
112
dot_bash_it/completion/available/aliases.completion.bash
Normal file
112
dot_bash_it/completion/available/aliases.completion.bash
Normal file
@@ -0,0 +1,112 @@
|
||||
# shellcheck shell=bash
|
||||
about-plugin 'Automatic completion of aliases'
|
||||
# Load after all aliases and completions to understand what needs to be completed
|
||||
# BASH_IT_LOAD_PRIORITY: 800
|
||||
|
||||
# References:
|
||||
# http://superuser.com/a/437508/119764
|
||||
# http://stackoverflow.com/a/1793178/1228454
|
||||
|
||||
# Automatically add completion for all aliases to commands having completion functions
|
||||
function _bash-it-component-completion-callback-on-init-aliases() {
|
||||
local namespace="alias_completion"
|
||||
local tmp_file completion_loader alias_name line completions chars
|
||||
local alias_arg_words new_completion compl_func compl_wrapper alias_defn
|
||||
|
||||
# create array of function completion triggers, keeping multi-word triggers together
|
||||
IFS=$'\n' read -d '' -ra completions < <(complete -p)
|
||||
((${#completions[@]} == 0)) && return 0
|
||||
|
||||
completions=("${completions[@]##complete -* * -}") # strip all but last option plus trigger(s)
|
||||
completions=("${completions[@]#complete -}") # strip anything missed
|
||||
completions=("${completions[@]#? * }") # strip last option and arg, leaving only trigger(s)
|
||||
completions=("${completions[@]#? }") # strip anything missed
|
||||
#TODO: this will fail on some completions...
|
||||
|
||||
# create temporary file for wrapper functions and completions
|
||||
tmp_file="$(mktemp -t "${namespace}-${RANDOM}XXXXXX")" || return 1
|
||||
|
||||
IFS=$'\n' read -r completion_loader < <(complete -p -D 2> /dev/null)
|
||||
if [[ "${completion_loader#complete }" =~ '-F'[[:space:]]([[:alnum:]_]+)[[:space:]] ]]; then
|
||||
completion_loader="${BASH_REMATCH[1]}"
|
||||
else
|
||||
completion_loader=""
|
||||
fi
|
||||
|
||||
# read in "<alias> '<aliased command>' '<command args>'" lines from defined aliases
|
||||
# some aliases do have backslashes that needs to be interpreted
|
||||
# shellcheck disable=SC2162
|
||||
while read line; do
|
||||
line="${line#alias -- }"
|
||||
line="${line#alias }"
|
||||
alias_name="${line%%=*}"
|
||||
alias_defn="${line#*=\'}" # alias definition
|
||||
alias_defn="${alias_defn%\'}"
|
||||
alias_cmd="${alias_defn%%[[:space:]]*}" # first word of alias
|
||||
if [[ ${alias_defn} == ${alias_cmd} ]]; then
|
||||
alias_args=''
|
||||
else
|
||||
alias_args="${alias_defn#*[[:space:]]}" # everything after first word
|
||||
fi
|
||||
|
||||
# skip aliases to pipes, boolean control structures and other command lists
|
||||
chars='\|\&\;\)\(\n\<\>'
|
||||
if [[ "${alias_defn}" =~ [$chars] ]]; then
|
||||
continue
|
||||
fi
|
||||
# avoid expanding wildcards
|
||||
read -ra alias_arg_words <<< "$alias_args"
|
||||
|
||||
# skip alias if there is no completion function triggered by the aliased command
|
||||
if ! _bash-it-array-contains-element "$alias_cmd" "${completions[@]}"; then
|
||||
if [[ -n "$completion_loader" ]]; then
|
||||
# force loading of completions for the aliased command
|
||||
"${completion_loader:?}" "${alias_cmd}"
|
||||
# 124 means completion loader was successful
|
||||
[[ $? -eq 124 ]] || continue
|
||||
completions+=("$alias_cmd")
|
||||
else
|
||||
continue
|
||||
fi
|
||||
fi
|
||||
new_completion="$(complete -p "$alias_cmd" 2> /dev/null)"
|
||||
|
||||
# create a wrapper inserting the alias arguments if any
|
||||
if [[ -n $alias_args ]]; then
|
||||
compl_func="${new_completion/#* -F /}"
|
||||
compl_func="${compl_func%% *}"
|
||||
# avoid recursive call loops by ignoring our own functions
|
||||
if [[ "${compl_func#_"$namespace"::}" == "$compl_func" ]]; then
|
||||
compl_wrapper="_${namespace}::${alias_name}"
|
||||
echo "function $compl_wrapper {
|
||||
local compl_word=\${2?}
|
||||
local prec_word=\${3?}
|
||||
# check if prec_word is the alias itself. if so, replace it
|
||||
# with the last word in the unaliased form, i.e.,
|
||||
# alias_cmd + ' ' + alias_args.
|
||||
if [[ \$COMP_LINE == \"\$prec_word \$compl_word\" ]]; then
|
||||
prec_word='$alias_cmd $alias_args'
|
||||
prec_word=\${prec_word#* }
|
||||
fi
|
||||
(( COMP_CWORD += ${#alias_arg_words[@]} ))
|
||||
COMP_WORDS=(\"$alias_cmd\" \"${alias_arg_words[@]}\" \"\${COMP_WORDS[@]:1}\")
|
||||
(( COMP_POINT -= \${#COMP_LINE} ))
|
||||
COMP_LINE=\${COMP_LINE/$alias_name/$alias_cmd $alias_args}
|
||||
(( COMP_POINT += \${#COMP_LINE} ))
|
||||
\"$compl_func\" \"$alias_cmd\" \"\$compl_word\" \"\$prec_word\"
|
||||
}" >> "$tmp_file"
|
||||
new_completion="${new_completion/ -F $compl_func / -F $compl_wrapper }"
|
||||
fi
|
||||
fi
|
||||
|
||||
# replace completion trigger by alias
|
||||
if [[ -n $new_completion ]]; then
|
||||
new_completion="${new_completion% *} $alias_name"
|
||||
echo "$new_completion" >> "$tmp_file"
|
||||
fi
|
||||
done < <(alias -p)
|
||||
# shellcheck source=/dev/null
|
||||
source "$tmp_file" && command rm -f "$tmp_file"
|
||||
}
|
||||
|
||||
_bash-it-component-completion-callback-on-init-aliases
|
||||
4
dot_bash_it/completion/available/apm.completion.bash
Normal file
4
dot_bash_it/completion/available/apm.completion.bash
Normal file
@@ -0,0 +1,4 @@
|
||||
# shellcheck shell=bash
|
||||
about-completion "apm completion"
|
||||
# shellcheck disable=SC1090
|
||||
source "${BASH_IT}"/vendor/github.com/vigo/apm-bash-completion/apm
|
||||
5
dot_bash_it/completion/available/awless.completion.bash
Normal file
5
dot_bash_it/completion/available/awless.completion.bash
Normal file
@@ -0,0 +1,5 @@
|
||||
# shellcheck shell=bash
|
||||
if _command_exists awless; then
|
||||
# shellcheck disable=SC1090
|
||||
source <(awless completion bash)
|
||||
fi
|
||||
5
dot_bash_it/completion/available/awscli.completion.bash
Normal file
5
dot_bash_it/completion/available/awscli.completion.bash
Normal file
@@ -0,0 +1,5 @@
|
||||
# shellcheck shell=bash
|
||||
|
||||
if _command_exists aws_completer; then
|
||||
complete -C "$(command -v aws_completer)" aws
|
||||
fi
|
||||
95
dot_bash_it/completion/available/bash-it.completion.bash
Normal file
95
dot_bash_it/completion/available/bash-it.completion.bash
Normal file
@@ -0,0 +1,95 @@
|
||||
# shellcheck shell=bash
|
||||
|
||||
function _compreply_candidates() {
|
||||
local IFS=$'\n'
|
||||
|
||||
read -d '' -ra COMPREPLY < <(compgen -W "${candidates[*]}" -- "${cur}")
|
||||
}
|
||||
|
||||
function _bash-it() {
|
||||
local cur prev verb file_type candidates suffix
|
||||
COMPREPLY=()
|
||||
cur="${COMP_WORDS[COMP_CWORD]}"
|
||||
prev="${COMP_WORDS[COMP_CWORD - 1]}"
|
||||
verb="${COMP_WORDS[1]}"
|
||||
file_type="${COMP_WORDS[2]:-}"
|
||||
candidates=('disable' 'enable' 'help' 'migrate' 'reload' 'restart' 'preview' 'profile' 'doctor' 'search' 'show' 'update' 'version')
|
||||
case "${verb}" in
|
||||
show)
|
||||
candidates=('aliases' 'completions' 'plugins')
|
||||
_compreply_candidates
|
||||
;;
|
||||
help)
|
||||
if [[ "${prev}" == "aliases" ]]; then
|
||||
candidates=('all' "$(_bash-it-component-list "${file_type}")")
|
||||
_compreply_candidates
|
||||
else
|
||||
candidates=('aliases' 'completions' 'migrate' 'plugins' 'update')
|
||||
_compreply_candidates
|
||||
fi
|
||||
;;
|
||||
profile)
|
||||
case "${file_type}" in
|
||||
load | rm)
|
||||
if [[ "${file_type}" == "$prev" ]]; then
|
||||
candidates=("${BASH_IT}/profiles"/*.bash_it)
|
||||
candidates=("${candidates[@]##*/}")
|
||||
candidates=("${candidates[@]%%.bash_it}")
|
||||
|
||||
_compreply_candidates
|
||||
fi
|
||||
;;
|
||||
save | list) ;;
|
||||
*)
|
||||
candidates=('load' 'save' 'list' 'rm')
|
||||
_compreply_candidates
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
doctor)
|
||||
candidates=('errors' 'warnings' 'all')
|
||||
_compreply_candidates
|
||||
;;
|
||||
update)
|
||||
if [[ "${cur}" == -* ]]; then
|
||||
candidates=('-s' '--silent')
|
||||
else
|
||||
candidates=('stable' 'dev')
|
||||
fi
|
||||
_compreply_candidates
|
||||
;;
|
||||
migrate | reload | restart | search | version) ;;
|
||||
preview)
|
||||
_bash-it-preview # completes itself
|
||||
return 0
|
||||
;;
|
||||
enable | disable)
|
||||
if [[ "${verb}" == "enable" ]]; then
|
||||
suffix="disabled"
|
||||
else
|
||||
suffix="enabled"
|
||||
fi
|
||||
case "${file_type}" in
|
||||
alias | completion | plugin)
|
||||
candidates=('all' "$("_bash-it-component-list-${suffix}" "${file_type}")")
|
||||
_compreply_candidates
|
||||
;;
|
||||
*)
|
||||
candidates=('alias' 'completion' 'plugin')
|
||||
_compreply_candidates
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
*)
|
||||
_compreply_candidates
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
# Activate completion for bash-it and its common misspellings
|
||||
complete -F _bash-it bash-it
|
||||
complete -F _bash-it bash-ti
|
||||
complete -F _bash-it shit
|
||||
complete -F _bash-it bashit
|
||||
complete -F _bash-it batshit
|
||||
complete -F _bash-it bash_it
|
||||
30
dot_bash_it/completion/available/brew.completion.bash
Normal file
30
dot_bash_it/completion/available/brew.completion.bash
Normal file
@@ -0,0 +1,30 @@
|
||||
# shellcheck shell=bash
|
||||
cite "about-completion"
|
||||
about-completion "brew completion"
|
||||
|
||||
# Load late to make sure `system` completion loads first
|
||||
# BASH_IT_LOAD_PRIORITY: 375
|
||||
|
||||
if [[ "$OSTYPE" != 'darwin'* ]]; then
|
||||
_log_warning "unsupported operating system - only 'Darwin' is supported"
|
||||
return 0
|
||||
fi
|
||||
|
||||
# Make sure brew is installed
|
||||
_bash_it_homebrew_check || return 0
|
||||
|
||||
if [[ -r "$BASH_IT_HOMEBREW_PREFIX/etc/bash_completion.d/brew" ]]; then
|
||||
# shellcheck disable=1090
|
||||
source "$BASH_IT_HOMEBREW_PREFIX/etc/bash_completion.d/brew"
|
||||
|
||||
elif [[ -r "$BASH_IT_HOMEBREW_PREFIX/Library/Contributions/brew_bash_completion.sh" ]]; then
|
||||
# shellcheck disable=1090
|
||||
source "$BASH_IT_HOMEBREW_PREFIX/Library/Contributions/brew_bash_completion.sh"
|
||||
|
||||
elif [[ -f "$BASH_IT_HOMEBREW_PREFIX/completions/bash/brew" ]]; then
|
||||
# For the git-clone based installation, see here for more info:
|
||||
# https://github.com/Bash-it/bash-it/issues/1458
|
||||
# https://docs.brew.sh/Shell-Completion
|
||||
# shellcheck disable=1090
|
||||
source "$BASH_IT_HOMEBREW_PREFIX/completions/bash/brew"
|
||||
fi
|
||||
273
dot_bash_it/completion/available/bundler.completion.bash
Normal file
273
dot_bash_it/completion/available/bundler.completion.bash
Normal file
@@ -0,0 +1,273 @@
|
||||
#! bash
|
||||
# bash completion for the `bundle` command.
|
||||
#
|
||||
# Copyright (c) 2008 Daniel Luz
|
||||
|
||||
# Permission is hereby granted, free of charge, to any person
|
||||
# obtaining a copy of this software and associated documentation
|
||||
# files (the "Software"), to deal in the Software without
|
||||
# restriction, including without limitation the rights to use,
|
||||
# copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
# copies of the Software, and to permit persons to whom the
|
||||
# Software is furnished to do so, subject to the following
|
||||
# conditions:
|
||||
|
||||
# The above copyright notice and this permission notice shall be
|
||||
# included in all copies or substantial portions of the Software.
|
||||
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||
# OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||
# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
# OTHER DEALINGS IN THE SOFTWARE.
|
||||
#
|
||||
# To use, source this file on bash:
|
||||
# . completion-bundle
|
||||
|
||||
__bundle() {
|
||||
local bundle_bin=("${_RUBY_COMMAND_PREFIX[@]}" "$1")
|
||||
local cur prev
|
||||
_get_comp_words_by_ref -n : cur prev
|
||||
local bundle_command
|
||||
local bundle_command_index
|
||||
__bundle_get_command
|
||||
COMPREPLY=()
|
||||
|
||||
local options
|
||||
if [[ $cur = -* && $bundle_command != exec ]]; then
|
||||
options="-V --help --no-color --no-no-color --verbose --no-verbose"
|
||||
case $bundle_command in
|
||||
"")
|
||||
options="$options --version";;
|
||||
check)
|
||||
options="$options --dry-run --gemfile --path -r --retry";;
|
||||
clean)
|
||||
options="$options --dry-run --force";;
|
||||
config)
|
||||
options="$options --local --global --delete";;
|
||||
doctor)
|
||||
options="$options --gemfile --quiet --no-quiet";;
|
||||
gem)
|
||||
options="$options -b -e -t --bin --coc --no-coc --edit --exe
|
||||
--no-exe --ext --no-ext --mit --no-mit --test";;
|
||||
init)
|
||||
options="$options --gemspec";;
|
||||
install)
|
||||
options="$options --binstubs --clean --deployment --force --frozen
|
||||
--full-index --gemfile --jobs --local --no-cache
|
||||
--no-prune --path --quiet --retry --shebang --standalone
|
||||
--system --trust-policy --with --without";;
|
||||
lock)
|
||||
options="$options --add-platform --conservative --full-index
|
||||
--local --lockfile --major --minor --patch --print
|
||||
--remove-platform --strict --update";;
|
||||
package)
|
||||
options="$options --all --all-platforms";;
|
||||
platform)
|
||||
options="$options --ruby";;
|
||||
show)
|
||||
options="$options --outdated --paths --no-paths";;
|
||||
update)
|
||||
options="$options --bundler --conservative --force --full-index
|
||||
--group --jobs --local --major --minor --patch --quiet
|
||||
--ruby --source --strict";;
|
||||
viz)
|
||||
options="$options -f -F -R -v -W --file --format --requirements
|
||||
--no-requirements --version --no-version --without";;
|
||||
esac
|
||||
else
|
||||
case $bundle_command in
|
||||
"" | help)
|
||||
options="help install update package exec config
|
||||
check show outdated console open lock viz init gem
|
||||
platform clean doctor"
|
||||
;;
|
||||
check | install)
|
||||
case $prev in
|
||||
--binstubs | --path)
|
||||
_filedir -d
|
||||
return;;
|
||||
--standalone | --with | --without)
|
||||
__bundle_complete_groups
|
||||
return;;
|
||||
--trust-policy)
|
||||
options="HighSecurity MediumSecurity LowSecurity
|
||||
AlmostNoSecurity NoSecurity";;
|
||||
esac
|
||||
;;
|
||||
config)
|
||||
case $prev in
|
||||
config | --*)
|
||||
case $cur in
|
||||
local.*)
|
||||
options=($(__bundle_exec_ruby 'puts Bundler.definition.specs.to_hash.keys'))
|
||||
options=("${options[*]/#/local.}")
|
||||
;;
|
||||
*)
|
||||
options=(path frozen without bin gemfile ssl_ca_cert
|
||||
ssl_client_cert cache_path disable_multisource
|
||||
ignore_messages retry redirect timeout
|
||||
force_ruby_platform specific_platform
|
||||
disable_checksum_validation disable_version_check
|
||||
allow_offline_install auto_install
|
||||
cache_all_platforms cache_all clean console
|
||||
disable_exec_load disable_local_branch_check
|
||||
disable_shared_gems jobs major_deprecations
|
||||
no_install no_prune only_update_to_newer_versions
|
||||
plugins shebang silence_root_warning
|
||||
ssl_verify_mode system_bindir user_agent)
|
||||
# We want to suggest the options above as complete words,
|
||||
# and also "local." and "mirror." as prefixes
|
||||
# To achieve that, disable automatic space insertion,
|
||||
# insert it manually, then add the non-spaced prefixes
|
||||
compopt -o nospace
|
||||
options=("${options[@]/%/ }")
|
||||
# And add prefix suggestions
|
||||
options+=(local. mirror.)
|
||||
# Override $IFS for completion to work
|
||||
local IFS=$'\n'
|
||||
COMPREPLY=($(compgen -W '${options[@]}' -- "$cur"))
|
||||
return
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
path | local.*)
|
||||
_filedir -d
|
||||
return;;
|
||||
esac
|
||||
;;
|
||||
exec)
|
||||
if [[ $COMP_CWORD -eq $bundle_command_index ]]; then
|
||||
# Figure out Bundler's binaries dir
|
||||
local bundler_bin=$(__bundle_exec_ruby 'puts Bundler.bundle_path + "bin"')
|
||||
if [[ -d $bundler_bin ]]; then
|
||||
local binaries=("$bundler_bin"/*)
|
||||
# If there are binaries, strip directory name and use them
|
||||
[[ -f "$binaries" ]] && options="${binaries[@]##*/}"
|
||||
else
|
||||
# No binaries found; use full command completion
|
||||
COMPREPLY=($(compgen -c -- "$cur"))
|
||||
return
|
||||
fi
|
||||
else
|
||||
local _RUBY_COMMAND_PREFIX=("${bundle_bin[@]}" exec)
|
||||
_command_offset $bundle_command_index
|
||||
return
|
||||
fi
|
||||
;;
|
||||
gem)
|
||||
case $prev in
|
||||
-e | --edit)
|
||||
COMPREPLY=($(compgen -c -- "$cur"))
|
||||
return;;
|
||||
-t | --test)
|
||||
options="minitest rspec";;
|
||||
esac
|
||||
;;
|
||||
update)
|
||||
case $prev in
|
||||
--group)
|
||||
__bundle_complete_groups
|
||||
return;;
|
||||
*)
|
||||
options=($(__bundle_exec_ruby 'puts Bundler.definition.specs.to_hash.keys'))
|
||||
esac
|
||||
;;
|
||||
viz)
|
||||
case $prev in
|
||||
-F | --format)
|
||||
options="dot jpg png svg";;
|
||||
-W | --without)
|
||||
__bundle_complete_groups
|
||||
return;;
|
||||
esac
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
COMPREPLY=($(compgen -W "${options[*]}" -- "$cur"))
|
||||
}
|
||||
|
||||
__bundle_get_command() {
|
||||
local i
|
||||
for ((i=1; i < $COMP_CWORD; ++i)); do
|
||||
local arg=${COMP_WORDS[$i]}
|
||||
|
||||
case $arg in
|
||||
[^-]*)
|
||||
bundle_command=$arg
|
||||
bundle_command_index=$((i + 1))
|
||||
return;;
|
||||
--version)
|
||||
# Command-killer
|
||||
bundle_command=-
|
||||
return;;
|
||||
--help)
|
||||
bundle_command=help
|
||||
bundle_command_index=$((i + 1))
|
||||
return;;
|
||||
esac
|
||||
done
|
||||
}
|
||||
|
||||
# Provides completion for Bundler group names.
|
||||
#
|
||||
# Multiple groups can be entered, separated either by spaces or by colons.
|
||||
# Input is read from $cur, and the result is directly written to $COMPREPLY.
|
||||
__bundle_complete_groups() {
|
||||
# Group being currently written
|
||||
local cur_group=${cur##*[ :]}
|
||||
# All groups written before
|
||||
local prefix=${cur%"$cur_group"}
|
||||
local groups=$(__bundle_exec_ruby 'puts Bundler.definition.dependencies.map(&:groups).reduce(:|).map(&:to_s)')
|
||||
if [[ ! $groups ]]; then
|
||||
COMPREPLY=()
|
||||
return
|
||||
fi
|
||||
# Duplicate "default" and anything already in $prefix, so that `uniq`
|
||||
# strips it; groups may be separated by ':', ' ', or '\ '
|
||||
local excluded=$'\ndefault\n'${prefix//[: \'\"\\]/$'\n'}
|
||||
# Include them twice to ensure they are duplicates
|
||||
groups=$groups$excluded$excluded
|
||||
COMPREPLY=($(compgen -W "$(sort <<<"$groups" | uniq -u)" -- "$cur_group"))
|
||||
# Prepend prefix to all entries
|
||||
COMPREPLY=("${COMPREPLY[@]/#/$prefix}")
|
||||
__ltrim_colon_completions "$cur"
|
||||
}
|
||||
|
||||
# __bundle_exec_ruby <script> [args...]
|
||||
#
|
||||
# Runs a Ruby script with Bundler loaded.
|
||||
# Results may be cached.
|
||||
__bundle_exec_ruby() {
|
||||
local bundle_bin=(${bundle_bin[@]:-bundle})
|
||||
# Lockfile is inferred here, and might not be correct (for example, when
|
||||
# running on a subdirectory). However, a wrong file path won't be a
|
||||
# cadastrophic mistake; it just means the cache won't be invalidated when
|
||||
# the local gem list changes (but will still invalidate if the command is
|
||||
# run on another directory)
|
||||
local lockfile=$PWD/Gemfile.lock
|
||||
local cachedir=${XDG_CACHE_HOME:-~/.cache}/completion-ruby
|
||||
local cachefile=$cachedir/bundle--exec-ruby
|
||||
# A representation of all arguments with newlines replaced by spaces,
|
||||
# to fit in a single line as a cache identifier
|
||||
local cache_id_line="${bundle_bin[*]} @ $lockfile: ${*//$'\n'/ }"
|
||||
|
||||
if [[ (! -f $lockfile || $cachefile -nt $lockfile) &&
|
||||
$(head -n 1 -- "$cachefile" 2>/dev/null) = "$cache_id_line" ]]; then
|
||||
tail -n +2 -- "$cachefile"
|
||||
else
|
||||
local output=$("${bundle_bin[@]}" exec ruby -e "$@" 2>/dev/null)
|
||||
if [[ $? -eq 0 ]]; then
|
||||
(mkdir -p -- "$cachedir" &&
|
||||
echo "$cache_id_line"$'\n'"$output" >$cachefile) 2>/dev/null
|
||||
echo "$output"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
complete -F __bundle -o bashdefault -o default bundle
|
||||
# vim: ai ft=sh sw=4 sts=4 et
|
||||
24
dot_bash_it/completion/available/capistrano.completion.bash
Normal file
24
dot_bash_it/completion/available/capistrano.completion.bash
Normal file
@@ -0,0 +1,24 @@
|
||||
#!/usr/bin/env bash
|
||||
# Bash completion support for Capistrano.
|
||||
|
||||
export COMP_WORDBREAKS=${COMP_WORDBREAKS/\:/}
|
||||
|
||||
_capcomplete() {
|
||||
if [ -f Capfile ]; then
|
||||
recent=`ls -t .cap_tasks~ Capfile **/*.cap 2> /dev/null | head -n 1`
|
||||
if [[ $recent != '.cap_tasks~' ]]; then
|
||||
cap --version | grep 'Capistrano v2.' > /dev/null
|
||||
if [ $? -eq 0 ]; then
|
||||
# Capistrano 2.x
|
||||
cap --tool --verbose --tasks | cut -d " " -f 2 > .cap_tasks~
|
||||
else
|
||||
# Capistrano 3.x
|
||||
cap --all --tasks | cut -d " " -f 2 > .cap_tasks~
|
||||
fi
|
||||
fi
|
||||
COMPREPLY=($(compgen -W "`cat .cap_tasks~`" -- ${COMP_WORDS[COMP_CWORD]}))
|
||||
return 0
|
||||
fi
|
||||
}
|
||||
|
||||
complete -o default -o nospace -F _capcomplete cap
|
||||
6
dot_bash_it/completion/available/cargo.completion.bash
Normal file
6
dot_bash_it/completion/available/cargo.completion.bash
Normal file
@@ -0,0 +1,6 @@
|
||||
# shellcheck shell=bash
|
||||
# cargo (Rust package manager) completion
|
||||
|
||||
if _binary_exists rustup && _binary_exists cargo; then
|
||||
eval "$(rustup completions bash cargo)"
|
||||
fi
|
||||
129
dot_bash_it/completion/available/composer.completion.bash
Normal file
129
dot_bash_it/completion/available/composer.completion.bash
Normal file
@@ -0,0 +1,129 @@
|
||||
# shellcheck shell=bash
|
||||
cite "about-completion"
|
||||
about-completion "composer completion"
|
||||
|
||||
function __composer_completion() {
|
||||
local cur coms opts com words
|
||||
COMPREPLY=()
|
||||
_get_comp_words_by_ref -n : cur words
|
||||
|
||||
# lookup for command
|
||||
for word in "${words[@]:1}"; do
|
||||
if [[ "${word}" != -* ]]; then
|
||||
com="${word}"
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
# completing for an option
|
||||
if [[ ${cur} == --* ]]; then
|
||||
opts="--help --quiet --verbose --version --ansi --no-ansi --no-interaction --profile --no-plugins --working-dir"
|
||||
|
||||
case "${com}" in
|
||||
about)
|
||||
opts="${opts} "
|
||||
;;
|
||||
archive)
|
||||
opts="${opts} --format --dir --file"
|
||||
;;
|
||||
browse)
|
||||
opts="${opts} --homepage --show"
|
||||
;;
|
||||
clear-cache)
|
||||
opts="${opts} "
|
||||
;;
|
||||
config)
|
||||
opts="${opts} --global --editor --auth --unset --list --file --absolute"
|
||||
;;
|
||||
create-project)
|
||||
opts="${opts} --stability --prefer-source --prefer-dist --repository --repository-url --dev --no-dev --no-custom-installers --no-scripts --no-progress --no-secure-http --keep-vcs --no-install --ignore-platform-reqs"
|
||||
;;
|
||||
depends)
|
||||
opts="${opts} --recursive --tree"
|
||||
;;
|
||||
diagnose)
|
||||
opts="${opts} "
|
||||
;;
|
||||
dump-autoload)
|
||||
opts="${opts} --no-scripts --optimize --classmap-authoritative --apcu --no-dev"
|
||||
;;
|
||||
exec)
|
||||
opts="${opts} --list"
|
||||
;;
|
||||
global)
|
||||
opts="${opts} "
|
||||
;;
|
||||
help)
|
||||
opts="${opts} --xml --format --raw"
|
||||
;;
|
||||
init)
|
||||
opts="${opts} --name --description --author --type --homepage --require --require-dev --stability --license --repository"
|
||||
;;
|
||||
install)
|
||||
opts="${opts} --prefer-source --prefer-dist --dry-run --dev --no-dev --no-custom-installers --no-autoloader --no-scripts --no-progress --no-suggest --optimize-autoloader --classmap-authoritative --apcu-autoloader --ignore-platform-reqs"
|
||||
;;
|
||||
licenses)
|
||||
opts="${opts} --format --no-dev"
|
||||
;;
|
||||
list)
|
||||
opts="${opts} --xml --raw --format"
|
||||
;;
|
||||
outdated)
|
||||
opts="${opts} --outdated --all --direct --strict"
|
||||
;;
|
||||
prohibits)
|
||||
opts="${opts} --recursive --tree"
|
||||
;;
|
||||
remove)
|
||||
opts="${opts} --dev --no-progress --no-update --no-scripts --update-no-dev --update-with-dependencies --no-update-with-dependencies --ignore-platform-reqs --optimize-autoloader --classmap-authoritative --apcu-autoloader"
|
||||
;;
|
||||
require)
|
||||
opts="${opts} --dev --prefer-source --prefer-dist --no-progress --no-suggest --no-update --no-scripts --update-no-dev --update-with-dependencies --ignore-platform-reqs --prefer-stable --prefer-lowest --sort-packages --optimize-autoloader --classmap-authoritative --apcu-autoloader"
|
||||
;;
|
||||
run-script)
|
||||
opts="${opts} --timeout --dev --no-dev --list"
|
||||
;;
|
||||
search)
|
||||
opts="${opts} --only-name --type"
|
||||
;;
|
||||
self-update)
|
||||
opts="${opts} --rollback --clean-backups --no-progress --update-keys --stable --preview --snapshot"
|
||||
;;
|
||||
show)
|
||||
opts="${opts} --all --installed --platform --available --self --name-only --path --tree --latest --outdated --minor-only --direct --strict"
|
||||
;;
|
||||
status)
|
||||
opts="${opts} "
|
||||
;;
|
||||
suggests)
|
||||
opts="${opts} --by-package --by-suggestion --no-dev"
|
||||
;;
|
||||
update)
|
||||
opts="${opts} --prefer-source --prefer-dist --dry-run --dev --no-dev --lock --no-custom-installers --no-autoloader --no-scripts --no-progress --no-suggest --with-dependencies --optimize-autoloader --classmap-authoritative --apcu-autoloader --ignore-platform-reqs --prefer-stable --prefer-lowest --interactive --root-reqs"
|
||||
;;
|
||||
validate)
|
||||
opts="${opts} --no-check-all --no-check-lock --no-check-publish --with-dependencies --strict"
|
||||
;;
|
||||
|
||||
esac
|
||||
|
||||
# shellcheck disable=SC2207
|
||||
COMPREPLY=($(compgen -W "${opts}" -- "${cur}"))
|
||||
__ltrim_colon_completions "${cur}"
|
||||
|
||||
return 0
|
||||
fi
|
||||
|
||||
# completing for a command
|
||||
if [[ "${cur}" == "${com}" ]]; then
|
||||
coms="about archive browse clear-cache config create-project depends diagnose dump-autoload exec global help init install licenses list outdated prohibits remove require run-script search self-update show status suggests update validate"
|
||||
|
||||
# shellcheck disable=SC2207
|
||||
COMPREPLY=($(compgen -W "${coms}" -- "${cur}"))
|
||||
__ltrim_colon_completions "${cur}"
|
||||
|
||||
return 0
|
||||
fi
|
||||
}
|
||||
|
||||
complete -o default -F __composer_completion composer
|
||||
11
dot_bash_it/completion/available/conda.completion.bash
Normal file
11
dot_bash_it/completion/available/conda.completion.bash
Normal file
@@ -0,0 +1,11 @@
|
||||
# shellcheck shell=bash
|
||||
cite "about-completion"
|
||||
about-completion "conda completion"
|
||||
|
||||
if _command_exists conda; then
|
||||
if _command_exists register-python-argcomplete; then
|
||||
eval "$(register-python-argcomplete conda)"
|
||||
else
|
||||
_log_warning "Argcomplete not found. Please run 'conda install argcomplete'"
|
||||
fi
|
||||
fi
|
||||
7
dot_bash_it/completion/available/consul.completion.bash
Normal file
7
dot_bash_it/completion/available/consul.completion.bash
Normal file
@@ -0,0 +1,7 @@
|
||||
# shellcheck shell=bash
|
||||
cite "about-completion"
|
||||
about-completion "Hashicorp consul completion"
|
||||
|
||||
if _command_exists consul; then
|
||||
complete -C "$(command -v consul)" consul
|
||||
fi
|
||||
1
dot_bash_it/completion/available/crystal.completion.bash
Normal file
1
dot_bash_it/completion/available/crystal.completion.bash
Normal file
@@ -0,0 +1 @@
|
||||
_log_warning 'Bash completion for "crystal" is now covered by "system". This completion can be disabled.'
|
||||
48
dot_bash_it/completion/available/dart.completion.bash
Normal file
48
dot_bash_it/completion/available/dart.completion.bash
Normal file
@@ -0,0 +1,48 @@
|
||||
# shellcheck shell=bash
|
||||
|
||||
__dart_completion() {
|
||||
# shellcheck disable=SC2155
|
||||
local prev=$(_get_pword)
|
||||
# shellcheck disable=SC2155
|
||||
local curr=$(_get_cword)
|
||||
|
||||
local HELP="--help -h"
|
||||
local VERBOSE="-v --verbose"
|
||||
|
||||
case $prev in
|
||||
analyze)
|
||||
# shellcheck disable=SC2207
|
||||
COMPREPLY=($(compgen -W "$HELP --fatal-infos --no-fatal-warnings --fatal-warnings" -- "$curr"))
|
||||
;;
|
||||
compile)
|
||||
# shellcheck disable=SC2207
|
||||
COMPREPLY=($(compgen -W "$HELP aot-snapshot exe js jit-snapshot kernel" -- "$curr"))
|
||||
;;
|
||||
create)
|
||||
# shellcheck disable=SC2207
|
||||
COMPREPLY=($(compgen -W "$HELP --template -t --no-pub --pub --force" -- "$curr"))
|
||||
;;
|
||||
-t | --template)
|
||||
# shellcheck disable=SC2207
|
||||
COMPREPLY=($(compgen -W "console-simple console-full package-simple web-simple" -- "$curr"))
|
||||
;;
|
||||
format)
|
||||
# shellcheck disable=SC2207
|
||||
COMPREPLY=($(compgen -W "$HELP $VERBOSE -o --output --fix -l --line-length" -- "$curr"))
|
||||
;;
|
||||
pub)
|
||||
# shellcheck disable=SC2207
|
||||
COMPREPLY=($(compgen -W "$HELP $VERBOSE --version --no-trace --trace --verbosity cache deps downgrade get global logout outdated publish run upgrade uploader version" -- "$curr"))
|
||||
;;
|
||||
run)
|
||||
# shellcheck disable=SC2207
|
||||
COMPREPLY=($(compgen -W "$HELP --observe --enable-vm-service --no-pause-isolates-on-exit --no-pause-isolates-on-unhandled-exceptions --no-warn-on-pause-with-no-debugger --pause-isolates-on-exit --pause-isolates-on-unhandled-exceptions --warn-on-pause-with-no-debugger" -- "$curr"))
|
||||
;;
|
||||
dart)
|
||||
# shellcheck disable=SC2207
|
||||
COMPREPLY=($(compgen -W "$HELP $VERBOSE --version --enable-analytics --disable-analytics help analyze compile create format pub run test" -- "$curr"))
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
complete -F __dart_completion dart
|
||||
@@ -0,0 +1,5 @@
|
||||
# shellcheck shell=bash
|
||||
|
||||
if test -s "${BASH_IT?}/vendor/github.com/gaelicWizard/bash-progcomp/defaults.completion.bash"; then
|
||||
source "$_"
|
||||
fi
|
||||
15
dot_bash_it/completion/available/dirs.completion.bash
Normal file
15
dot_bash_it/completion/available/dirs.completion.bash
Normal file
@@ -0,0 +1,15 @@
|
||||
#!/usr/bin/env bash
|
||||
# Bash completion support for the 'dirs' plugin (commands G, R).
|
||||
|
||||
_dirs-complete() {
|
||||
local CURRENT_PROMPT="${COMP_WORDS[COMP_CWORD]}"
|
||||
|
||||
# parse all defined shortcuts from ~/.dirs
|
||||
if [ -r "$HOME/.dirs" ]; then
|
||||
COMPREPLY=($(compgen -W "$(grep -v '^#' ~/.dirs | sed -e 's/\(.*\)=.*/\1/')" -- ${CURRENT_PROMPT}) )
|
||||
fi
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
complete -o default -o nospace -F _dirs-complete G R
|
||||
4
dot_bash_it/completion/available/django.completion.bash
Normal file
4
dot_bash_it/completion/available/django.completion.bash
Normal file
@@ -0,0 +1,4 @@
|
||||
# shellcheck shell=bash
|
||||
about-completion "django completion"
|
||||
# shellcheck disable=SC1090
|
||||
source "${BASH_IT}"/vendor/github.com/django/django/extras/django_bash_completion
|
||||
22
dot_bash_it/completion/available/dmidecode.completion.bash
Normal file
22
dot_bash_it/completion/available/dmidecode.completion.bash
Normal file
@@ -0,0 +1,22 @@
|
||||
# shellcheck shell=bash
|
||||
|
||||
function __dmidecode_completion() {
|
||||
# shellcheck disable=SC2155
|
||||
local prev=$(_get_pword)
|
||||
# shellcheck disable=SC2155
|
||||
local curr=$(_get_cword)
|
||||
|
||||
case $prev in
|
||||
-s | --string | -t | --type)
|
||||
OPTS=$(dmidecode "$prev" 2>&1 | grep -E '^ ' | sed 's/ *//g')
|
||||
# shellcheck disable=SC2207
|
||||
COMPREPLY=($(compgen -W "$OPTS" -- "$curr"))
|
||||
;;
|
||||
dmidecode)
|
||||
# shellcheck disable=SC2207
|
||||
COMPREPLY=($(compgen -W "-d --dev-mem -h --help -q --quiet -s --string -t --type -H --handle -u --dump{,-bin} --from-dump --no-sysfs --oem-string -V --version" -- "$curr"))
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
complete -F __dmidecode_completion dmidecode
|
||||
@@ -0,0 +1,3 @@
|
||||
# shellcheck shell=bash
|
||||
_log_warning '"docker-machine" is now deprecated, and as such the bash completion for it is also deprecated.
|
||||
Please disable this completion.'
|
||||
24
dot_bash_it/completion/available/docker.completion.bash
Normal file
24
dot_bash_it/completion/available/docker.completion.bash
Normal file
@@ -0,0 +1,24 @@
|
||||
# shellcheck shell=bash
|
||||
cite "about-completion"
|
||||
about-completion "docker completion"
|
||||
|
||||
# Make sure docker is installed
|
||||
_command_exists docker || return
|
||||
|
||||
# Don't handle completion if it's already managed
|
||||
_completion_exists docker && return
|
||||
|
||||
_docker_bash_completion_paths=(
|
||||
# MacOS
|
||||
'/Applications/Docker.app/Contents/Resources/etc/docker.bash-completion'
|
||||
# Linux
|
||||
'/usr/share/bash-completion/completions/docker'
|
||||
)
|
||||
|
||||
for fn in "${_docker_bash_completion_paths[@]}"; do
|
||||
if [ -r "$fn" ]; then
|
||||
# shellcheck disable=SC1090
|
||||
source "$fn"
|
||||
break
|
||||
fi
|
||||
done
|
||||
14
dot_bash_it/completion/available/dotnet.completion.bash
Normal file
14
dot_bash_it/completion/available/dotnet.completion.bash
Normal file
@@ -0,0 +1,14 @@
|
||||
# shellcheck shell=bash
|
||||
about-completion "bash parameter completion for the dotnet CLI"
|
||||
# see https://docs.microsoft.com/en-us/dotnet/core/tools/enable-tab-autocomplete#bash
|
||||
|
||||
function _dotnet_bash_complete() {
|
||||
local cur="${COMP_WORDS[COMP_CWORD]}" IFS=$'\n'
|
||||
local candidates
|
||||
|
||||
read -d '' -ra candidates < <(dotnet complete --position "${COMP_POINT}" "${COMP_LINE}" 2> /dev/null)
|
||||
|
||||
read -d '' -ra COMPREPLY < <(compgen -W "${candidates[*]:-}" -- "$cur")
|
||||
}
|
||||
|
||||
complete -f -F _dotnet_bash_complete dotnet
|
||||
2
dot_bash_it/completion/available/drush.completion.bash
Normal file
2
dot_bash_it/completion/available/drush.completion.bash
Normal file
@@ -0,0 +1,2 @@
|
||||
_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.'
|
||||
@@ -0,0 +1,688 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
# Copyright (c) 2014 Docker, Inc
|
||||
|
||||
# bash completion for docker-compose
|
||||
#
|
||||
# This work is based on the completion for the docker command.
|
||||
#
|
||||
# This script provides completion of:
|
||||
# - commands and their options
|
||||
# - service names
|
||||
# - filepaths
|
||||
#
|
||||
# To enable the completions either:
|
||||
# - place this file in /etc/bash_completion.d
|
||||
# or
|
||||
# - copy this file to e.g. ~/.docker-compose-completion.sh and add the line
|
||||
# below to your .bashrc after bash completion features are loaded
|
||||
# . ~/.docker-compose-completion.sh
|
||||
|
||||
__docker_compose_previous_extglob_setting=$(shopt -p extglob)
|
||||
shopt -s extglob
|
||||
|
||||
__docker_compose_q() {
|
||||
docker-compose 2>/dev/null "${top_level_options[@]}" "$@"
|
||||
}
|
||||
|
||||
# Transforms a multiline list of strings into a single line string
|
||||
# with the words separated by "|".
|
||||
__docker_compose_to_alternatives() {
|
||||
local parts=( $1 )
|
||||
local IFS='|'
|
||||
echo "${parts[*]}"
|
||||
}
|
||||
|
||||
# Transforms a multiline list of options into an extglob pattern
|
||||
# suitable for use in case statements.
|
||||
__docker_compose_to_extglob() {
|
||||
local extglob=$( __docker_compose_to_alternatives "$1" )
|
||||
echo "@($extglob)"
|
||||
}
|
||||
|
||||
# Determines whether the option passed as the first argument exist on
|
||||
# the commandline. The option may be a pattern, e.g. `--force|-f`.
|
||||
__docker_compose_has_option() {
|
||||
local pattern="$1"
|
||||
for (( i=2; i < $cword; ++i)); do
|
||||
if [[ ${words[$i]} =~ ^($pattern)$ ]] ; then
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
return 1
|
||||
}
|
||||
|
||||
# Returns `key` if we are currently completing the value of a map option (`key=value`)
|
||||
# which matches the extglob passed in as an argument.
|
||||
# This function is needed for key-specific completions.
|
||||
__docker_compose_map_key_of_current_option() {
|
||||
local glob="$1"
|
||||
|
||||
local key glob_pos
|
||||
if [ "$cur" = "=" ] ; then # key= case
|
||||
key="$prev"
|
||||
glob_pos=$((cword - 2))
|
||||
elif [[ $cur == *=* ]] ; then # key=value case (OSX)
|
||||
key=${cur%=*}
|
||||
glob_pos=$((cword - 1))
|
||||
elif [ "$prev" = "=" ] ; then
|
||||
key=${words[$cword - 2]} # key=value case
|
||||
glob_pos=$((cword - 3))
|
||||
else
|
||||
return
|
||||
fi
|
||||
|
||||
[ "${words[$glob_pos]}" = "=" ] && ((glob_pos--)) # --option=key=value syntax
|
||||
|
||||
[[ ${words[$glob_pos]} == @($glob) ]] && echo "$key"
|
||||
}
|
||||
|
||||
# suppress trailing whitespace
|
||||
__docker_compose_nospace() {
|
||||
# compopt is not available in ancient bash versions
|
||||
type compopt &>/dev/null && compopt -o nospace
|
||||
}
|
||||
|
||||
|
||||
# Outputs a list of all defined services, regardless of their running state.
|
||||
# Arguments for `docker-compose ps` may be passed in order to filter the service list,
|
||||
# e.g. `status=running`.
|
||||
__docker_compose_services() {
|
||||
__docker_compose_q ps --services "$@"
|
||||
}
|
||||
|
||||
# Applies completion of services based on the current value of `$cur`.
|
||||
# Arguments for `docker-compose ps` may be passed in order to filter the service list,
|
||||
# see `__docker_compose_services`.
|
||||
__docker_compose_complete_services() {
|
||||
COMPREPLY=( $(compgen -W "$(__docker_compose_services "$@")" -- "$cur") )
|
||||
}
|
||||
|
||||
# The services for which at least one running container exists
|
||||
__docker_compose_complete_running_services() {
|
||||
local names=$(__docker_compose_services --filter status=running)
|
||||
COMPREPLY=( $(compgen -W "$names" -- "$cur") )
|
||||
}
|
||||
|
||||
|
||||
_docker_compose_build() {
|
||||
case "$prev" in
|
||||
--build-arg)
|
||||
COMPREPLY=( $( compgen -e -- "$cur" ) )
|
||||
__docker_compose_nospace
|
||||
return
|
||||
;;
|
||||
--memory|-m)
|
||||
return
|
||||
;;
|
||||
esac
|
||||
|
||||
case "$cur" in
|
||||
-*)
|
||||
COMPREPLY=( $( compgen -W "--build-arg --compress --force-rm --help --memory -m --no-cache --no-rm --pull --parallel -q --quiet" -- "$cur" ) )
|
||||
;;
|
||||
*)
|
||||
__docker_compose_complete_services --filter source=build
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
|
||||
_docker_compose_bundle() {
|
||||
case "$prev" in
|
||||
--output|-o)
|
||||
_filedir
|
||||
return
|
||||
;;
|
||||
esac
|
||||
|
||||
COMPREPLY=( $( compgen -W "--push-images --help --output -o" -- "$cur" ) )
|
||||
}
|
||||
|
||||
|
||||
_docker_compose_config() {
|
||||
case "$prev" in
|
||||
--hash)
|
||||
if [[ $cur == \\* ]] ; then
|
||||
COMPREPLY=( '\*' )
|
||||
else
|
||||
COMPREPLY=( $(compgen -W "$(__docker_compose_services) \\\* " -- "$cur") )
|
||||
fi
|
||||
return
|
||||
;;
|
||||
esac
|
||||
|
||||
COMPREPLY=( $( compgen -W "--hash --help --quiet -q --resolve-image-digests --services --volumes" -- "$cur" ) )
|
||||
}
|
||||
|
||||
|
||||
_docker_compose_create() {
|
||||
case "$cur" in
|
||||
-*)
|
||||
COMPREPLY=( $( compgen -W "--build --force-recreate --help --no-build --no-recreate" -- "$cur" ) )
|
||||
;;
|
||||
*)
|
||||
__docker_compose_complete_services
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
|
||||
_docker_compose_docker_compose() {
|
||||
case "$prev" in
|
||||
--tlscacert|--tlscert|--tlskey)
|
||||
_filedir
|
||||
return
|
||||
;;
|
||||
--file|-f)
|
||||
_filedir "y?(a)ml"
|
||||
return
|
||||
;;
|
||||
--log-level)
|
||||
COMPREPLY=( $( compgen -W "debug info warning error critical" -- "$cur" ) )
|
||||
return
|
||||
;;
|
||||
--project-directory)
|
||||
_filedir -d
|
||||
return
|
||||
;;
|
||||
$(__docker_compose_to_extglob "$daemon_options_with_args") )
|
||||
return
|
||||
;;
|
||||
esac
|
||||
|
||||
case "$cur" in
|
||||
-*)
|
||||
COMPREPLY=( $( compgen -W "$daemon_boolean_options $daemon_options_with_args $top_level_options_with_args --help -h --no-ansi --verbose --version -v" -- "$cur" ) )
|
||||
;;
|
||||
*)
|
||||
COMPREPLY=( $( compgen -W "${commands[*]}" -- "$cur" ) )
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
|
||||
_docker_compose_down() {
|
||||
case "$prev" in
|
||||
--rmi)
|
||||
COMPREPLY=( $( compgen -W "all local" -- "$cur" ) )
|
||||
return
|
||||
;;
|
||||
--timeout|-t)
|
||||
return
|
||||
;;
|
||||
esac
|
||||
|
||||
case "$cur" in
|
||||
-*)
|
||||
COMPREPLY=( $( compgen -W "--help --rmi --timeout -t --volumes -v --remove-orphans" -- "$cur" ) )
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
|
||||
_docker_compose_events() {
|
||||
case "$prev" in
|
||||
--json)
|
||||
return
|
||||
;;
|
||||
esac
|
||||
|
||||
case "$cur" in
|
||||
-*)
|
||||
COMPREPLY=( $( compgen -W "--help --json" -- "$cur" ) )
|
||||
;;
|
||||
*)
|
||||
__docker_compose_complete_services
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
|
||||
_docker_compose_exec() {
|
||||
case "$prev" in
|
||||
--index|--user|-u|--workdir|-w)
|
||||
return
|
||||
;;
|
||||
esac
|
||||
|
||||
case "$cur" in
|
||||
-*)
|
||||
COMPREPLY=( $( compgen -W "-d --detach --help --index --privileged -T --user -u --workdir -w" -- "$cur" ) )
|
||||
;;
|
||||
*)
|
||||
__docker_compose_complete_running_services
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
|
||||
_docker_compose_help() {
|
||||
COMPREPLY=( $( compgen -W "${commands[*]}" -- "$cur" ) )
|
||||
}
|
||||
|
||||
_docker_compose_images() {
|
||||
case "$cur" in
|
||||
-*)
|
||||
COMPREPLY=( $( compgen -W "--help --quiet -q" -- "$cur" ) )
|
||||
;;
|
||||
*)
|
||||
__docker_compose_complete_services
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
_docker_compose_kill() {
|
||||
case "$prev" in
|
||||
-s)
|
||||
COMPREPLY=( $( compgen -W "SIGHUP SIGINT SIGKILL SIGUSR1 SIGUSR2" -- "$(echo $cur | tr '[:lower:]' '[:upper:]')" ) )
|
||||
return
|
||||
;;
|
||||
esac
|
||||
|
||||
case "$cur" in
|
||||
-*)
|
||||
COMPREPLY=( $( compgen -W "--help -s" -- "$cur" ) )
|
||||
;;
|
||||
*)
|
||||
__docker_compose_complete_running_services
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
|
||||
_docker_compose_logs() {
|
||||
case "$prev" in
|
||||
--tail)
|
||||
return
|
||||
;;
|
||||
esac
|
||||
|
||||
case "$cur" in
|
||||
-*)
|
||||
COMPREPLY=( $( compgen -W "--follow -f --help --no-color --tail --timestamps -t" -- "$cur" ) )
|
||||
;;
|
||||
*)
|
||||
__docker_compose_complete_services
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
|
||||
_docker_compose_pause() {
|
||||
case "$cur" in
|
||||
-*)
|
||||
COMPREPLY=( $( compgen -W "--help" -- "$cur" ) )
|
||||
;;
|
||||
*)
|
||||
__docker_compose_complete_running_services
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
|
||||
_docker_compose_port() {
|
||||
case "$prev" in
|
||||
--protocol)
|
||||
COMPREPLY=( $( compgen -W "tcp udp" -- "$cur" ) )
|
||||
return;
|
||||
;;
|
||||
--index)
|
||||
return;
|
||||
;;
|
||||
esac
|
||||
|
||||
case "$cur" in
|
||||
-*)
|
||||
COMPREPLY=( $( compgen -W "--help --index --protocol" -- "$cur" ) )
|
||||
;;
|
||||
*)
|
||||
__docker_compose_complete_services
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
|
||||
_docker_compose_ps() {
|
||||
local key=$(__docker_compose_map_key_of_current_option '--filter')
|
||||
case "$key" in
|
||||
source)
|
||||
COMPREPLY=( $( compgen -W "build image" -- "${cur##*=}" ) )
|
||||
return
|
||||
;;
|
||||
status)
|
||||
COMPREPLY=( $( compgen -W "paused restarting running stopped" -- "${cur##*=}" ) )
|
||||
return
|
||||
;;
|
||||
esac
|
||||
|
||||
case "$prev" in
|
||||
--filter)
|
||||
COMPREPLY=( $( compgen -W "source status" -S "=" -- "$cur" ) )
|
||||
__docker_compose_nospace
|
||||
return;
|
||||
;;
|
||||
esac
|
||||
|
||||
case "$cur" in
|
||||
-*)
|
||||
COMPREPLY=( $( compgen -W "--all -a --filter --help --quiet -q --services" -- "$cur" ) )
|
||||
;;
|
||||
*)
|
||||
__docker_compose_complete_services
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
|
||||
_docker_compose_pull() {
|
||||
case "$cur" in
|
||||
-*)
|
||||
COMPREPLY=( $( compgen -W "--help --ignore-pull-failures --include-deps --no-parallel --quiet -q" -- "$cur" ) )
|
||||
;;
|
||||
*)
|
||||
__docker_compose_complete_services --filter source=image
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
|
||||
_docker_compose_push() {
|
||||
case "$cur" in
|
||||
-*)
|
||||
COMPREPLY=( $( compgen -W "--help --ignore-push-failures" -- "$cur" ) )
|
||||
;;
|
||||
*)
|
||||
__docker_compose_complete_services
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
|
||||
_docker_compose_restart() {
|
||||
case "$prev" in
|
||||
--timeout|-t)
|
||||
return
|
||||
;;
|
||||
esac
|
||||
|
||||
case "$cur" in
|
||||
-*)
|
||||
COMPREPLY=( $( compgen -W "--help --timeout -t" -- "$cur" ) )
|
||||
;;
|
||||
*)
|
||||
__docker_compose_complete_running_services
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
|
||||
_docker_compose_rm() {
|
||||
case "$cur" in
|
||||
-*)
|
||||
COMPREPLY=( $( compgen -W "--force -f --help --stop -s -v" -- "$cur" ) )
|
||||
;;
|
||||
*)
|
||||
if __docker_compose_has_option "--stop|-s" ; then
|
||||
__docker_compose_complete_services
|
||||
else
|
||||
__docker_compose_complete_services --filter status=stopped
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
|
||||
_docker_compose_run() {
|
||||
case "$prev" in
|
||||
-e)
|
||||
COMPREPLY=( $( compgen -e -- "$cur" ) )
|
||||
__docker_compose_nospace
|
||||
return
|
||||
;;
|
||||
--entrypoint|--label|-l|--name|--user|-u|--volume|-v|--workdir|-w)
|
||||
return
|
||||
;;
|
||||
esac
|
||||
|
||||
case "$cur" in
|
||||
-*)
|
||||
COMPREPLY=( $( compgen -W "--detach -d --entrypoint -e --help --label -l --name --no-deps --publish -p --rm --service-ports -T --use-aliases --user -u --volume -v --workdir -w" -- "$cur" ) )
|
||||
;;
|
||||
*)
|
||||
__docker_compose_complete_services
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
|
||||
_docker_compose_scale() {
|
||||
case "$prev" in
|
||||
=)
|
||||
COMPREPLY=("$cur")
|
||||
return
|
||||
;;
|
||||
--timeout|-t)
|
||||
return
|
||||
;;
|
||||
esac
|
||||
|
||||
case "$cur" in
|
||||
-*)
|
||||
COMPREPLY=( $( compgen -W "--help --timeout -t" -- "$cur" ) )
|
||||
;;
|
||||
*)
|
||||
COMPREPLY=( $(compgen -S "=" -W "$(__docker_compose_services)" -- "$cur") )
|
||||
__docker_compose_nospace
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
|
||||
_docker_compose_start() {
|
||||
case "$cur" in
|
||||
-*)
|
||||
COMPREPLY=( $( compgen -W "--help" -- "$cur" ) )
|
||||
;;
|
||||
*)
|
||||
__docker_compose_complete_services --filter status=stopped
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
|
||||
_docker_compose_stop() {
|
||||
case "$prev" in
|
||||
--timeout|-t)
|
||||
return
|
||||
;;
|
||||
esac
|
||||
|
||||
case "$cur" in
|
||||
-*)
|
||||
COMPREPLY=( $( compgen -W "--help --timeout -t" -- "$cur" ) )
|
||||
;;
|
||||
*)
|
||||
__docker_compose_complete_running_services
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
|
||||
_docker_compose_top() {
|
||||
case "$cur" in
|
||||
-*)
|
||||
COMPREPLY=( $( compgen -W "--help" -- "$cur" ) )
|
||||
;;
|
||||
*)
|
||||
__docker_compose_complete_running_services
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
|
||||
_docker_compose_unpause() {
|
||||
case "$cur" in
|
||||
-*)
|
||||
COMPREPLY=( $( compgen -W "--help" -- "$cur" ) )
|
||||
;;
|
||||
*)
|
||||
__docker_compose_complete_services --filter status=paused
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
|
||||
_docker_compose_up() {
|
||||
case "$prev" in
|
||||
=)
|
||||
COMPREPLY=("$cur")
|
||||
return
|
||||
;;
|
||||
--exit-code-from)
|
||||
__docker_compose_complete_services
|
||||
return
|
||||
;;
|
||||
--scale)
|
||||
COMPREPLY=( $(compgen -S "=" -W "$(__docker_compose_services)" -- "$cur") )
|
||||
__docker_compose_nospace
|
||||
return
|
||||
;;
|
||||
--timeout|-t)
|
||||
return
|
||||
;;
|
||||
esac
|
||||
|
||||
case "$cur" in
|
||||
-*)
|
||||
COMPREPLY=( $( compgen -W "--abort-on-container-exit --always-recreate-deps --build -d --detach --exit-code-from --force-recreate --help --no-build --no-color --no-deps --no-recreate --no-start --renew-anon-volumes -V --remove-orphans --scale --timeout -t" -- "$cur" ) )
|
||||
;;
|
||||
*)
|
||||
__docker_compose_complete_services
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
|
||||
_docker_compose_version() {
|
||||
case "$cur" in
|
||||
-*)
|
||||
COMPREPLY=( $( compgen -W "--short" -- "$cur" ) )
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
|
||||
_docker_compose() {
|
||||
local previous_extglob_setting=$(shopt -p extglob)
|
||||
shopt -s extglob
|
||||
|
||||
local commands=(
|
||||
build
|
||||
bundle
|
||||
config
|
||||
create
|
||||
down
|
||||
events
|
||||
exec
|
||||
help
|
||||
images
|
||||
kill
|
||||
logs
|
||||
pause
|
||||
port
|
||||
ps
|
||||
pull
|
||||
push
|
||||
restart
|
||||
rm
|
||||
run
|
||||
scale
|
||||
start
|
||||
stop
|
||||
top
|
||||
unpause
|
||||
up
|
||||
version
|
||||
)
|
||||
|
||||
# Options for the docker daemon that have to be passed to secondary calls to
|
||||
# docker-compose executed by this script.
|
||||
local daemon_boolean_options="
|
||||
--skip-hostname-check
|
||||
--tls
|
||||
--tlsverify
|
||||
"
|
||||
local daemon_options_with_args="
|
||||
--file -f
|
||||
--host -H
|
||||
--project-directory
|
||||
--project-name -p
|
||||
--tlscacert
|
||||
--tlscert
|
||||
--tlskey
|
||||
"
|
||||
|
||||
# These options are require special treatment when searching the command.
|
||||
local top_level_options_with_args="
|
||||
--log-level
|
||||
"
|
||||
|
||||
COMPREPLY=()
|
||||
local cur prev words cword
|
||||
_get_comp_words_by_ref -n : cur prev words cword
|
||||
|
||||
# search subcommand and invoke its handler.
|
||||
# special treatment of some top-level options
|
||||
local command='docker_compose'
|
||||
local top_level_options=()
|
||||
local counter=1
|
||||
|
||||
while [ $counter -lt $cword ]; do
|
||||
case "${words[$counter]}" in
|
||||
$(__docker_compose_to_extglob "$daemon_boolean_options") )
|
||||
local opt=${words[counter]}
|
||||
top_level_options+=($opt)
|
||||
;;
|
||||
$(__docker_compose_to_extglob "$daemon_options_with_args") )
|
||||
local opt=${words[counter]}
|
||||
local arg=${words[++counter]}
|
||||
top_level_options+=($opt $arg)
|
||||
;;
|
||||
$(__docker_compose_to_extglob "$top_level_options_with_args") )
|
||||
(( counter++ ))
|
||||
;;
|
||||
-*)
|
||||
;;
|
||||
*)
|
||||
command="${words[$counter]}"
|
||||
break
|
||||
;;
|
||||
esac
|
||||
(( counter++ ))
|
||||
done
|
||||
|
||||
local completions_func=_docker_compose_${command//-/_}
|
||||
_is_function $completions_func && $completions_func
|
||||
|
||||
eval "$previous_extglob_setting"
|
||||
return 0
|
||||
}
|
||||
|
||||
eval "$__docker_compose_previous_extglob_setting"
|
||||
unset __docker_compose_previous_extglob_setting
|
||||
|
||||
complete -F _docker_compose docker-compose docker-compose.exe
|
||||
1
dot_bash_it/completion/available/export.completion.bash
Normal file
1
dot_bash_it/completion/available/export.completion.bash
Normal file
@@ -0,0 +1 @@
|
||||
complete -o nospace -S = -W '$(printenv | awk -F= "{print \$1}")' export
|
||||
133
dot_bash_it/completion/available/fabric.completion.bash
Normal file
133
dot_bash_it/completion/available/fabric.completion.bash
Normal file
@@ -0,0 +1,133 @@
|
||||
#!/usr/bin/env bash
|
||||
#
|
||||
# Bash completion support for Fabric (http://fabfile.org/)
|
||||
#
|
||||
#
|
||||
# Copyright (C) 2011 by Konstantin Bakulin
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
# of this software and associated documentation files (the "Software"), to deal
|
||||
# in the Software without restriction, including without limitation the rights
|
||||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
# copies of the Software, and to permit persons to whom the Software is
|
||||
# furnished to do so, subject to the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be included in
|
||||
# all copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
# THE SOFTWARE.
|
||||
#
|
||||
# Thanks to:
|
||||
# - Adam Vandenberg,
|
||||
# https://github.com/adamv/dotfiles/blob/master/completion_scripts/fab_completion.bash
|
||||
#
|
||||
# - Enrico Batista da Luz,
|
||||
# https://github.com/ricobl/dotfiles/blob/master/bin/fab_bash_completion
|
||||
#
|
||||
|
||||
|
||||
# Use cache files for fab tasks or not.
|
||||
# If set to "false" command "fab --shortlist" will be executed every time.
|
||||
export FAB_COMPLETION_CACHE_TASKS=true
|
||||
|
||||
# File name where tasks cache will be stored (in current dir).
|
||||
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 -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_CACHED_TASKS_FILENAME | xargs -n 1 expr
|
||||
}
|
||||
|
||||
|
||||
#
|
||||
# Get time of last fabfile file/module modification as seconds since Epoch
|
||||
#
|
||||
function __fab_fabfile_mtime() {
|
||||
local f="fabfile"
|
||||
if [[ -e "$f.py" ]]; then
|
||||
${__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} {} + \
|
||||
| xargs -n 1 expr | sort -n -r | head -1
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
#
|
||||
# Completion for "fab" command
|
||||
#
|
||||
function __fab_completion() {
|
||||
# Return if "fab" command doesn't exists
|
||||
[[ -e `which fab 2> /dev/null` ]] || return 0
|
||||
|
||||
# Variables to hold the current word and possible matches
|
||||
local cur="${COMP_WORDS[COMP_CWORD]}"
|
||||
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 --help | egrep -o "\-\-[A-Za-z_\-]+\=?" | sort -u)
|
||||
fi
|
||||
opts="${__FAB_COMPLETION_LONG_OPT}"
|
||||
;;
|
||||
|
||||
# Completion for short options is not nessary.
|
||||
# It's left here just for history.
|
||||
# -*)
|
||||
# if [[ -z "${__FAB_COMPLETION_SHORT_OPT}" ]]; then
|
||||
# export __FAB_COMPLETION_SHORT_OPT=$(
|
||||
# fab --help | egrep -o "^ +\-[A-Za-z_\]" | sort -u)
|
||||
# fi
|
||||
# opts="${__FAB_COMPLETION_SHORT_OPT}"
|
||||
# ;;
|
||||
|
||||
*)
|
||||
# If "fabfile.py" or "fabfile" dir with "__init__.py" file exists
|
||||
local f="fabfile"
|
||||
if [[ -e "$f.py" || (-d "$f" && -e "$f/__init__.py") ]]; then
|
||||
# Build a list of the available tasks
|
||||
if $FAB_COMPLETION_CACHE_TASKS; then
|
||||
# If use cache
|
||||
if [[ ! -s ${FAB_COMPLETION_CACHED_TASKS_FILENAME} ||
|
||||
$(__fab_fabfile_mtime) -gt $(__fab_chache_mtime) ]]; then
|
||||
fab --shortlist > ${FAB_COMPLETION_CACHED_TASKS_FILENAME} \
|
||||
2> /dev/null
|
||||
fi
|
||||
opts=$(cat ${FAB_COMPLETION_CACHED_TASKS_FILENAME})
|
||||
else
|
||||
# Without cache
|
||||
opts=$(fab --shortlist 2> /dev/null)
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
|
||||
# Set possible completions
|
||||
COMPREPLY=($(compgen -W "${opts}" -- ${cur}))
|
||||
}
|
||||
complete -o default -o nospace -F __fab_completion fab
|
||||
5
dot_bash_it/completion/available/flutter.completion.bash
Normal file
5
dot_bash_it/completion/available/flutter.completion.bash
Normal file
@@ -0,0 +1,5 @@
|
||||
#!/usr/bin/bash
|
||||
|
||||
if _command_exists flutter; then
|
||||
eval "$(flutter bash-completion)"
|
||||
fi
|
||||
14
dot_bash_it/completion/available/gcloud.completion.bash
Normal file
14
dot_bash_it/completion/available/gcloud.completion.bash
Normal file
@@ -0,0 +1,14 @@
|
||||
# shellcheck shell=bash
|
||||
cite "about-completion"
|
||||
about-completion "Google Cloud SDK completion"
|
||||
|
||||
if _command_exists gcloud; then
|
||||
# get install path
|
||||
GOOGLE_SDK_ROOT=${GOOGLE_SDK_ROOT:-$(gcloud info --format="value(installation.sdk_root)")}
|
||||
|
||||
# source all the bash completion file that are available
|
||||
for i in "${GOOGLE_SDK_ROOT}"/*.bash.inc; do
|
||||
# shellcheck disable=SC1090
|
||||
source "$i"
|
||||
done
|
||||
fi
|
||||
35
dot_bash_it/completion/available/gem.completion.bash
Normal file
35
dot_bash_it/completion/available/gem.completion.bash
Normal file
@@ -0,0 +1,35 @@
|
||||
# shellcheck shell=bash
|
||||
cite "about-completion"
|
||||
about-completion "gem completion"
|
||||
|
||||
__gem_completion() {
|
||||
local cur=${COMP_WORDS[COMP_CWORD]}
|
||||
local prev=${COMP_WORDS[COMP_CWORD - 1]}
|
||||
case $prev in
|
||||
install)
|
||||
# list the remote gems and add to completion
|
||||
if [ -z "$REMOTE_GEMS" ]; then
|
||||
read -r -a REMOTE_GEMS <<< "$(gem list --remote --no-versions | sed 's/\*\*\* REMOTE GEMS \*\*\*//' | tr '\n' ' ')"
|
||||
fi
|
||||
|
||||
local cur=${COMP_WORDS[COMP_CWORD]}
|
||||
# shellcheck disable=SC2207
|
||||
COMPREPLY=($(compgen -W "${REMOTE_GEMS[*]}" -- "$cur"))
|
||||
return 0
|
||||
;;
|
||||
uninstall)
|
||||
# list all local installed gems and add to completion
|
||||
read -r -a LOCAL_GEMS <<< "$(gem list --no-versions | sed 's/\*\*\* LOCAL GEMS \*\*\*//' | tr '\n' ' ')"
|
||||
|
||||
local cur=${COMP_WORDS[COMP_CWORD]}
|
||||
# shellcheck disable=SC2207
|
||||
COMPREPLY=($(compgen -W "${LOCAL_GEMS[*]}" -- "$cur"))
|
||||
return 0
|
||||
;;
|
||||
esac
|
||||
local commands=(build cert check cleanup contents dependency environment fetch generate_index help install list lock outdated owner pristine push query rdoc search server sources specification stale uninstall unpack update which)
|
||||
# shellcheck disable=SC2207
|
||||
COMPREPLY=($(compgen -W "${commands[*]}" -- "$cur"))
|
||||
}
|
||||
|
||||
complete -F __gem_completion gem
|
||||
42
dot_bash_it/completion/available/git.completion.bash
Normal file
42
dot_bash_it/completion/available/git.completion.bash
Normal file
@@ -0,0 +1,42 @@
|
||||
# shellcheck shell=bash
|
||||
#
|
||||
# Locate and load completions for `git`.
|
||||
|
||||
# Make sure git is installed
|
||||
_command_exists git || return
|
||||
|
||||
# Don't handle completion if it's already managed
|
||||
if complete -p git &> /dev/null; then
|
||||
_log_warning "completion already loaded - this usually means it is safe to stop using this completion"
|
||||
return 0
|
||||
fi
|
||||
|
||||
_git_bash_completion_xcrun_git=
|
||||
if _command_exists xcrun; then
|
||||
_git_bash_completion_xcrun_git="$(xcrun --find git)"
|
||||
fi
|
||||
_git_bash_completion_paths=(
|
||||
# Standard locations
|
||||
"${GIT_EXE%/*}/../share/git-core/git-completion.bash"
|
||||
"${GIT_EXE%/*}/../share/git-core/contrib/completion/git-completion.bash"
|
||||
"${GIT_EXE%/*}/../etc/bash_completion.d/git-completion.bash"
|
||||
# MacOS non-system locations
|
||||
"${_git_bash_completion_xcrun_git%/bin/git}/share/git-core/git-completion.bash"
|
||||
)
|
||||
|
||||
# Load the first completion file found
|
||||
_git_bash_completion_found=false
|
||||
for _comp_path in "${_git_bash_completion_paths[@]}"; do
|
||||
if [[ -r "$_comp_path" ]]; then
|
||||
_git_bash_completion_found=true
|
||||
# shellcheck disable=SC1090 # don't follow
|
||||
source "$_comp_path"
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
# Cleanup
|
||||
if [[ "${_git_bash_completion_found}" == false ]]; then
|
||||
_log_warning "no completion files found - please try enabling the 'system' completion instead."
|
||||
fi
|
||||
unset "${!_git_bash_completion@}"
|
||||
178
dot_bash_it/completion/available/git_flow.completion.bash
Normal file
178
dot_bash_it/completion/available/git_flow.completion.bash
Normal file
@@ -0,0 +1,178 @@
|
||||
#!bash
|
||||
#
|
||||
# git-flow-completion
|
||||
# ===================
|
||||
#
|
||||
# Bash completion support for [git-flow](http://github.com/nvie/gitflow)
|
||||
#
|
||||
# The contained completion routines provide support for completing:
|
||||
#
|
||||
# * git-flow init and version
|
||||
# * feature, hotfix and release branches
|
||||
# * remote feature branch names (for `git-flow feature track`)
|
||||
#
|
||||
#
|
||||
# Installation
|
||||
# ------------
|
||||
#
|
||||
# To achieve git-flow completion nirvana:
|
||||
#
|
||||
# 0. Install git-completion.
|
||||
#
|
||||
# 1. Install this file. Either:
|
||||
#
|
||||
# a. Place it in a `bash-completion.d` folder:
|
||||
#
|
||||
# * /etc/bash-completion.d
|
||||
# * /usr/local/etc/bash-completion.d
|
||||
# * ~/bash-completion.d
|
||||
#
|
||||
# b. Or, copy it somewhere (e.g. ~/.git-flow-completion.sh) and put the following line in
|
||||
# your .bashrc:
|
||||
#
|
||||
# source ~/.git-flow-completion.sh
|
||||
#
|
||||
# 2. If you are using Git < 1.7.1: Edit git-completion.sh and add the following line to the giant
|
||||
# $command case in _git:
|
||||
#
|
||||
# flow) _git_flow ;;
|
||||
#
|
||||
#
|
||||
# The Fine Print
|
||||
# --------------
|
||||
#
|
||||
# Copyright (c) 2010 [Justin Hileman](http://justinhileman.com)
|
||||
#
|
||||
# Distributed under the [MIT License](http://creativecommons.org/licenses/MIT/)
|
||||
|
||||
_git_flow ()
|
||||
{
|
||||
local subcommands="init feature release hotfix"
|
||||
local subcommand="$(__git_find_subcommand "$subcommands")"
|
||||
if [ -z "$subcommand" ]; then
|
||||
__gitcomp "$subcommands"
|
||||
return
|
||||
fi
|
||||
|
||||
case "$subcommand" in
|
||||
feature)
|
||||
__git_flow_feature
|
||||
return
|
||||
;;
|
||||
release)
|
||||
__git_flow_release
|
||||
return
|
||||
;;
|
||||
hotfix)
|
||||
__git_flow_hotfix
|
||||
return
|
||||
;;
|
||||
*)
|
||||
COMPREPLY=()
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
__git_flow_feature ()
|
||||
{
|
||||
local subcommands="list start finish publish track diff rebase checkout pull"
|
||||
local subcommand="$(__git_find_subcommand "$subcommands")"
|
||||
if [ -z "$subcommand" ]; then
|
||||
__gitcomp "$subcommands"
|
||||
return
|
||||
fi
|
||||
|
||||
case "$subcommand" in
|
||||
pull)
|
||||
__gitcomp "$(__git_remotes)"
|
||||
return
|
||||
;;
|
||||
checkout|finish|diff|rebase)
|
||||
__gitcomp "$(__git_flow_list_features)"
|
||||
return
|
||||
;;
|
||||
publish)
|
||||
__gitcomp "$(comm -23 <(__git_flow_list_features) <(__git_flow_list_remote_features))"
|
||||
return
|
||||
;;
|
||||
track)
|
||||
__gitcomp "$(__git_flow_list_remote_features)"
|
||||
return
|
||||
;;
|
||||
*)
|
||||
COMPREPLY=()
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
__git_flow_list_features ()
|
||||
{
|
||||
git flow feature list 2> /dev/null | tr -d ' |*'
|
||||
}
|
||||
|
||||
__git_flow_list_remote_features ()
|
||||
{
|
||||
git branch -r 2> /dev/null | grep "origin/$(__git_flow_feature_prefix)" | awk '{ sub(/^origin\/$(__git_flow_feature_prefix)/, "", $1); print }'
|
||||
}
|
||||
|
||||
__git_flow_feature_prefix ()
|
||||
{
|
||||
git config gitflow.prefix.feature 2> /dev/null || echo "feature/"
|
||||
}
|
||||
|
||||
__git_flow_release ()
|
||||
{
|
||||
local subcommands="list start finish"
|
||||
local subcommand="$(__git_find_subcommand "$subcommands")"
|
||||
if [ -z "$subcommand" ]; then
|
||||
__gitcomp "$subcommands"
|
||||
return
|
||||
fi
|
||||
|
||||
case "$subcommand" in
|
||||
finish)
|
||||
__gitcomp "$(__git_flow_list_releases)"
|
||||
return
|
||||
;;
|
||||
*)
|
||||
COMPREPLY=()
|
||||
;;
|
||||
esac
|
||||
|
||||
}
|
||||
|
||||
__git_flow_list_releases ()
|
||||
{
|
||||
git flow release list 2> /dev/null
|
||||
}
|
||||
|
||||
__git_flow_hotfix ()
|
||||
{
|
||||
local subcommands="list start finish"
|
||||
local subcommand="$(__git_find_subcommand "$subcommands")"
|
||||
if [ -z "$subcommand" ]; then
|
||||
__gitcomp "$subcommands"
|
||||
return
|
||||
fi
|
||||
|
||||
case "$subcommand" in
|
||||
finish)
|
||||
__gitcomp "$(__git_flow_list_hotfixes)"
|
||||
return
|
||||
;;
|
||||
*)
|
||||
COMPREPLY=()
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
__git_flow_list_hotfixes ()
|
||||
{
|
||||
git flow hotfix list 2> /dev/null
|
||||
}
|
||||
|
||||
# temporarily wrap __git_find_on_cmdline() for backwards compatibility
|
||||
if ! _command_exists __git_find_subcommand
|
||||
then
|
||||
alias __git_find_subcommand=__git_find_on_cmdline
|
||||
fi
|
||||
511
dot_bash_it/completion/available/git_flow_avh.completion.bash
Normal file
511
dot_bash_it/completion/available/git_flow_avh.completion.bash
Normal file
@@ -0,0 +1,511 @@
|
||||
#!bash
|
||||
#
|
||||
# git-flow-completion
|
||||
# ===================
|
||||
#
|
||||
# Bash completion support for [git-flow (AVH Edition)](http://github.com/petervanderdoes/gitflow)
|
||||
#
|
||||
# The contained completion routines provide support for completing:
|
||||
#
|
||||
# * git-flow init and version
|
||||
# * feature, hotfix and release branches
|
||||
# * remote feature, hotfix and release branch names
|
||||
#
|
||||
#
|
||||
# Installation
|
||||
# ------------
|
||||
#
|
||||
# To achieve git-flow completion nirvana:
|
||||
#
|
||||
# 0. Install git-completion.
|
||||
#
|
||||
# 1. Install this file. Either:
|
||||
#
|
||||
# a. Place it in a `bash-completion.d` folder:
|
||||
#
|
||||
# * /etc/bash-completion.d
|
||||
# * /usr/local/etc/bash-completion.d
|
||||
# * ~/bash-completion.d
|
||||
#
|
||||
# b. Or, copy it somewhere (e.g. ~/.git-flow-completion.sh) and put the following line in
|
||||
# your .bashrc:
|
||||
#
|
||||
# source ~/.git-flow-completion.sh
|
||||
#
|
||||
# 2. If you are using Git < 1.7.1: Edit git-completion.sh and add the following line to the giant
|
||||
# $command case in _git:
|
||||
#
|
||||
# flow) _git_flow ;;
|
||||
#
|
||||
#
|
||||
# The Fine Print
|
||||
# --------------
|
||||
#
|
||||
# Author:
|
||||
# Copyright 2012-2013 Peter van der Does.
|
||||
#
|
||||
# Original Author:
|
||||
# Copyright (c) 2011 [Justin Hileman](http://justinhileman.com)
|
||||
#
|
||||
# Distributed under the [MIT License](http://creativecommons.org/licenses/MIT/)
|
||||
|
||||
__git_flow_config_file_options="
|
||||
--local --global --system --file=
|
||||
"
|
||||
|
||||
_git_flow ()
|
||||
{
|
||||
local subcommands="init feature release hotfix support help version config finish delete publish rebase"
|
||||
local subcommand="$(__git_find_on_cmdline "$subcommands")"
|
||||
if [ -z "$subcommand" ]; then
|
||||
__gitcomp "$subcommands"
|
||||
return
|
||||
fi
|
||||
|
||||
case "$subcommand" in
|
||||
init)
|
||||
__git_flow_init
|
||||
return
|
||||
;;
|
||||
feature)
|
||||
__git_flow_feature
|
||||
return
|
||||
;;
|
||||
release)
|
||||
__git_flow_release
|
||||
return
|
||||
;;
|
||||
hotfix)
|
||||
__git_flow_hotfix
|
||||
return
|
||||
;;
|
||||
support)
|
||||
__git_flow_support
|
||||
return
|
||||
;;
|
||||
config)
|
||||
__git_flow_config
|
||||
return
|
||||
;;
|
||||
*)
|
||||
COMPREPLY=()
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
__git_flow_init ()
|
||||
{
|
||||
local subcommands="help"
|
||||
local subcommand="$(__git_find_on_cmdline "$subcommands")"
|
||||
if [ -z "$subcommand" ]; then
|
||||
__gitcomp "$subcommands"
|
||||
fi
|
||||
|
||||
case "$cur" in
|
||||
--*)
|
||||
__gitcomp "
|
||||
--nodefaults --defaults
|
||||
--noforce --force
|
||||
$__git_flow_config_file_options
|
||||
"
|
||||
return
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
__git_flow_feature ()
|
||||
{
|
||||
local subcommands="list start finish publish track diff rebase checkout pull help delete"
|
||||
local subcommand="$(__git_find_on_cmdline "$subcommands")"
|
||||
|
||||
if [ -z "$subcommand" ]; then
|
||||
__gitcomp "$subcommands"
|
||||
return
|
||||
fi
|
||||
|
||||
case "$subcommand" in
|
||||
pull)
|
||||
__gitcomp_nl "$(__git_remotes)"
|
||||
return
|
||||
;;
|
||||
checkout)
|
||||
__gitcomp_nl "$(__git_flow_list_local_branches 'feature')"
|
||||
return
|
||||
;;
|
||||
delete)
|
||||
case "$cur" in
|
||||
--*)
|
||||
__gitcomp "
|
||||
--noforce --force
|
||||
--noremote --remote
|
||||
"
|
||||
return
|
||||
;;
|
||||
esac
|
||||
__gitcomp_nl "$(__git_flow_list_local_branches 'feature')"
|
||||
return
|
||||
;;
|
||||
finish)
|
||||
case "$cur" in
|
||||
--*)
|
||||
__gitcomp "
|
||||
--nofetch --fetch
|
||||
--norebase --rebase
|
||||
--nopreserve-merges --preserve-merges
|
||||
--nokeep --keep
|
||||
--keepremote
|
||||
--keeplocal
|
||||
--noforce_delete --force_delete
|
||||
--nosquash --squash
|
||||
--no-ff
|
||||
"
|
||||
return
|
||||
;;
|
||||
esac
|
||||
__gitcomp_nl "$(__git_flow_list_local_branches 'feature')"
|
||||
return
|
||||
;;
|
||||
diff)
|
||||
__gitcomp_nl "$(__git_flow_list_local_branches 'feature')"
|
||||
return
|
||||
;;
|
||||
rebase)
|
||||
case "$cur" in
|
||||
--*)
|
||||
__gitcomp "
|
||||
--nointeractive --interactive
|
||||
--nopreserve-merges --preserve-merges
|
||||
"
|
||||
return
|
||||
;;
|
||||
esac
|
||||
__gitcomp_nl "$(__git_flow_list_local_branches 'feature')"
|
||||
return
|
||||
;;
|
||||
publish)
|
||||
__gitcomp_nl "$(__git_flow_list_branches 'feature')"
|
||||
return
|
||||
;;
|
||||
track)
|
||||
__gitcomp_nl "$(__git_flow_list_branches 'feature')"
|
||||
return
|
||||
;;
|
||||
*)
|
||||
COMPREPLY=()
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
__git_flow_release ()
|
||||
{
|
||||
local subcommands="list start finish track publish help delete"
|
||||
local subcommand="$(__git_find_on_cmdline "$subcommands")"
|
||||
if [ -z "$subcommand" ]; then
|
||||
__gitcomp "$subcommands"
|
||||
return
|
||||
fi
|
||||
|
||||
case "$subcommand" in
|
||||
finish)
|
||||
case "$cur" in
|
||||
--*)
|
||||
__gitcomp "
|
||||
--nofetch --fetch
|
||||
--sign
|
||||
--signingkey
|
||||
--message
|
||||
--nomessagefile --messagefile=
|
||||
--nopush --push
|
||||
--nokeep --keep
|
||||
--keepremote
|
||||
--keeplocal
|
||||
--noforce_delete --force_delete
|
||||
--notag --tag
|
||||
--nonobackmerge --nobackmerge
|
||||
--nosquash --squash
|
||||
"
|
||||
return
|
||||
;;
|
||||
esac
|
||||
__gitcomp_nl "$(__git_flow_list_local_branches 'release')"
|
||||
return
|
||||
;;
|
||||
rebase)
|
||||
case "$cur" in
|
||||
--*)
|
||||
__gitcomp "
|
||||
--nointeractive --interactive
|
||||
--nopreserve-merges --preserve-merges
|
||||
"
|
||||
return
|
||||
;;
|
||||
esac
|
||||
__gitcomp_nl "$(__git_flow_list_local_branches 'release')"
|
||||
return
|
||||
;;
|
||||
delete)
|
||||
case "$cur" in
|
||||
--*)
|
||||
__gitcomp "
|
||||
--noforce --force
|
||||
--noremote --remote
|
||||
"
|
||||
return
|
||||
;;
|
||||
esac
|
||||
__gitcomp_nl "$(__git_flow_list_local_branches 'release')"
|
||||
return
|
||||
;;
|
||||
publish)
|
||||
__gitcomp_nl "$(__git_flow_list_branches 'release')"
|
||||
return
|
||||
;;
|
||||
track)
|
||||
__gitcomp_nl "$(__git_flow_list_branches 'release')"
|
||||
return
|
||||
;;
|
||||
start)
|
||||
case "$cur" in
|
||||
--*)
|
||||
__gitcomp "
|
||||
--nofetch --fetch
|
||||
"
|
||||
return
|
||||
;;
|
||||
esac
|
||||
return
|
||||
;;
|
||||
*)
|
||||
COMPREPLY=()
|
||||
;;
|
||||
esac
|
||||
|
||||
}
|
||||
|
||||
__git_flow_hotfix ()
|
||||
{
|
||||
local subcommands="list start finish track publish help delete"
|
||||
local subcommand="$(__git_find_on_cmdline "$subcommands")"
|
||||
if [ -z "$subcommand" ]; then
|
||||
__gitcomp "$subcommands"
|
||||
return
|
||||
fi
|
||||
|
||||
case "$subcommand" in
|
||||
finish)
|
||||
case "$cur" in
|
||||
--*)
|
||||
__gitcomp "
|
||||
--nofetch --fetch
|
||||
--sign
|
||||
--signingkey
|
||||
--message
|
||||
--nomessagefile --messagefile=
|
||||
--nopush --push
|
||||
--nokeep --keep
|
||||
--keepremote
|
||||
--keeplocal
|
||||
--noforce_delete --force_delete
|
||||
--notag --tag
|
||||
--nonobackmerge --nobackmerge
|
||||
"
|
||||
return
|
||||
;;
|
||||
esac
|
||||
__gitcomp_nl "$(__git_flow_list_local_branches 'hotfix')"
|
||||
return
|
||||
;;
|
||||
rebase)
|
||||
case "$cur" in
|
||||
--*)
|
||||
__gitcomp "
|
||||
--nointeractive --interactive
|
||||
--nopreserve-merges --preserve-merges
|
||||
"
|
||||
return
|
||||
;;
|
||||
esac
|
||||
__gitcomp_nl "$(__git_flow_list_local_branches 'hotfix')"
|
||||
return
|
||||
;;
|
||||
delete)
|
||||
case "$cur" in
|
||||
--*)
|
||||
__gitcomp "
|
||||
--noforce --force
|
||||
--noremote --remote
|
||||
"
|
||||
return
|
||||
;;
|
||||
esac
|
||||
__gitcomp_nl "$(__git_flow_list_local_branches 'hotfix')"
|
||||
return
|
||||
;;
|
||||
publish)
|
||||
__gitcomp_nl "$(__git_flow_list_branches 'hotfix')"
|
||||
return
|
||||
;;
|
||||
track)
|
||||
__gitcomp_nl "$(__git_flow_list_branches 'hotfix')"
|
||||
return
|
||||
;;
|
||||
start)
|
||||
case "$cur" in
|
||||
--*)
|
||||
__gitcomp "
|
||||
--nofetch --fetch
|
||||
"
|
||||
return
|
||||
;;
|
||||
esac
|
||||
return
|
||||
;;
|
||||
*)
|
||||
COMPREPLY=()
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
__git_flow_support ()
|
||||
{
|
||||
local subcommands="list start help"
|
||||
local subcommand="$(__git_find_on_cmdline "$subcommands")"
|
||||
if [ -z "$subcommand" ]; then
|
||||
__gitcomp "$subcommands"
|
||||
return
|
||||
fi
|
||||
|
||||
case "$subcommand" in
|
||||
start)
|
||||
case "$cur" in
|
||||
--*)
|
||||
__gitcomp "
|
||||
--nofetch --fetch
|
||||
"
|
||||
return
|
||||
;;
|
||||
esac
|
||||
return
|
||||
;;
|
||||
rebase)
|
||||
case "$cur" in
|
||||
--*)
|
||||
__gitcomp "
|
||||
--nointeractive --interactive
|
||||
--nopreserve-merges --preserve-merges
|
||||
"
|
||||
return
|
||||
;;
|
||||
esac
|
||||
__gitcomp_nl "$(__git_flow_list_local_branches 'support')"
|
||||
return
|
||||
;;
|
||||
*)
|
||||
COMPREPLY=()
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
__git_flow_config ()
|
||||
{
|
||||
local subcommands="list set base"
|
||||
local subcommand="$(__git_find_on_cmdline "$subcommands")"
|
||||
if [ -z "$subcommand" ]; then
|
||||
__gitcomp "$subcommands"
|
||||
return
|
||||
fi
|
||||
|
||||
case "$subcommand" in
|
||||
set)
|
||||
case "$cur" in
|
||||
--*)
|
||||
__gitcomp "
|
||||
$__git_flow_config_file_options
|
||||
"
|
||||
return
|
||||
;;
|
||||
esac
|
||||
__gitcomp "
|
||||
master develop
|
||||
feature hotfix release support
|
||||
versiontagprefix
|
||||
"
|
||||
return
|
||||
;;
|
||||
base)
|
||||
case "$cur" in
|
||||
--*)
|
||||
__gitcomp "
|
||||
set get
|
||||
"
|
||||
return
|
||||
;;
|
||||
esac
|
||||
__gitcomp_nl "$(__git_flow_list_local_branches)"
|
||||
return
|
||||
;;
|
||||
*)
|
||||
COMPREPLY=()
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
__git_flow_prefix ()
|
||||
{
|
||||
case "$1" in
|
||||
feature|release|hotfix|support)
|
||||
git config "gitflow.prefix.$1" 2> /dev/null || echo "$1/"
|
||||
return
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
__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 | \
|
||||
while read -r entry; do
|
||||
eval "$entry"
|
||||
ref="${ref#$prefix}"
|
||||
echo "$ref"
|
||||
done | sort
|
||||
else
|
||||
git for-each-ref --format="ref=%(refname:short)" refs/heads/ | sort
|
||||
|
||||
fi
|
||||
}
|
||||
|
||||
__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 | \
|
||||
while read -r entry; do
|
||||
eval "$entry"
|
||||
ref="${ref##$prefix}"
|
||||
echo "$ref"
|
||||
done | sort
|
||||
}
|
||||
|
||||
__git_flow_list_branches ()
|
||||
{
|
||||
local 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 | \
|
||||
while read -r entry; do
|
||||
eval "$entry"
|
||||
ref="${ref##$prefix}"
|
||||
echo "$ref"
|
||||
done | sort
|
||||
else
|
||||
git for-each-ref --format="%(refname:short)" refs/heads/ refs/remotes/$origin | sort
|
||||
fi
|
||||
}
|
||||
|
||||
# alias __git_find_on_cmdline for backwards compatibility
|
||||
if ! _command_exists __git_find_on_cmdline
|
||||
then
|
||||
alias __git_find_on_cmdline=__git_find_subcommand
|
||||
fi
|
||||
@@ -0,0 +1,9 @@
|
||||
# shellcheck shell=bash
|
||||
cite "about-completion"
|
||||
about-completion "GitHub CLI completion"
|
||||
|
||||
if _binary_exists gh; then
|
||||
# If gh already completed, stop
|
||||
_completion_exists gh && return
|
||||
eval "$(gh completion --shell=bash)"
|
||||
fi
|
||||
15
dot_bash_it/completion/available/go.completion.bash
Normal file
15
dot_bash_it/completion/available/go.completion.bash
Normal file
@@ -0,0 +1,15 @@
|
||||
# shellcheck shell=bash
|
||||
about-completion "completion for go command using gocomplete"
|
||||
|
||||
# bash completion for go tool
|
||||
# https://github.com/posener/complete
|
||||
|
||||
# Test `go version` because goenv creates shim scripts that will be found in PATH
|
||||
# but do not always resolve to a working install.
|
||||
if _command_exists go && go version &> /dev/null; then
|
||||
# Same idea here, but no need to test a subcommand
|
||||
if _command_exists gocomplete && gocomplete &> /dev/null; then
|
||||
# finally, apply completion
|
||||
complete -C gocomplete go
|
||||
fi
|
||||
fi
|
||||
316
dot_bash_it/completion/available/gradle.completion.bash
Normal file
316
dot_bash_it/completion/available/gradle.completion.bash
Normal file
@@ -0,0 +1,316 @@
|
||||
# Copyright (c) 2017 Eric Wendelin
|
||||
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
# this software and associated documentation files (the "Software"), to deal in
|
||||
# the Software without restriction, including without limitation the rights to
|
||||
# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
# of the Software, and to permit persons to whom the Software is furnished to do
|
||||
# so, subject to the following conditions:
|
||||
|
||||
# The above copyright notice and this permission notice shall be included in all
|
||||
# copies or substantial portions of the Software.
|
||||
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
# SOFTWARE.
|
||||
|
||||
# Bash breaks words on : by default. Subproject tasks have ':'
|
||||
# Avoid inaccurate completions for subproject tasks
|
||||
COMP_WORDBREAKS=$(echo "$COMP_WORDBREAKS" | sed -e 's/://g')
|
||||
|
||||
function __gradle-set-project-root-dir() {
|
||||
project_root_dir="$(_bash-it-find-in-ancestor "settings.gradle" "gradlew")"
|
||||
return "$?"
|
||||
}
|
||||
|
||||
__gradle-init-cache-dir() {
|
||||
cache_dir="$HOME/.gradle/completion"
|
||||
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" | \
|
||||
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')
|
||||
}
|
||||
|
||||
__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)")
|
||||
elif _command_exists md5sum; then
|
||||
gradle_files_checksum=$(cat "$cache_dir/$cache_name" | xargs ls -o 2>/dev/null | md5sum | awk '{print $1}')
|
||||
else
|
||||
echo "Cannot generate completions as neither md5 nor md5sum exist on \$PATH"
|
||||
fi
|
||||
}
|
||||
|
||||
__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)/"}
|
||||
|
||||
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 | egrep -v "$script_exclude_pattern")
|
||||
printf "%s\n" "${gradle_build_scripts[@]}" > $cache_dir/$cache_name
|
||||
fi
|
||||
}
|
||||
|
||||
__gradle-long-options() {
|
||||
local args="--build-cache - Enables the Gradle build cache
|
||||
--build-file - Specifies the build file
|
||||
--configure-on-demand - Only relevant projects are configured
|
||||
--console - Type of console output to generate (plain auto rich)
|
||||
--continue - Continues task execution after a task failure
|
||||
--continuous - Continuous mode. Automatically re-run build after changes
|
||||
--daemon - Use the Gradle Daemon
|
||||
--debug - Log at the debug level
|
||||
--dry-run - Runs the build with all task actions disabled
|
||||
--exclude-task - Specify a task to be excluded
|
||||
--full-stacktrace - Print out the full (very verbose) stacktrace
|
||||
--gradle-user-home - Specifies the Gradle user home directory
|
||||
--gui - Launches the Gradle GUI app (Deprecated)
|
||||
--help - Shows a help message
|
||||
--include-build - Run the build as a composite, including the specified build
|
||||
--info - Set log level to INFO
|
||||
--init-script - Specifies an initialization script
|
||||
--max-workers - Set the maximum number of workers that Gradle may use
|
||||
--no-build-cache - Do not use the Gradle build cache
|
||||
--no-daemon - Do not use the Gradle Daemon
|
||||
--no-rebuild - Do not rebuild project dependencies
|
||||
--no-scan - Do not create a build scan
|
||||
--no-search-upwards - Do not search in parent directories for a settings.gradle
|
||||
--offline - Build without accessing network resources
|
||||
--parallel - Build projects in parallel
|
||||
--profile - Profile build time and create report
|
||||
--project-cache-dir - Specifies the project-specific cache directory
|
||||
--project-dir - Specifies the start directory for Gradle
|
||||
--project-prop - Sets a project property of the root project
|
||||
--quiet - Log errors only
|
||||
--recompile-scripts - Forces scripts to be recompiled, bypassing caching
|
||||
--refresh-dependencies - Refresh the state of dependencies
|
||||
--rerun-tasks - Specifies that any task optimization is ignored
|
||||
--scan - Create a build scan
|
||||
--settings-file - Specifies the settings file
|
||||
--stacktrace - Print out the stacktrace also for user exceptions
|
||||
--status - Print Gradle Daemon status
|
||||
--stop - Stop all Gradle Daemons
|
||||
--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]}") )
|
||||
}
|
||||
|
||||
__gradle-properties() {
|
||||
local args="-Dorg.gradle.cache.reserved.mb= - Reserve Gradle Daemon memory for operations
|
||||
-Dorg.gradle.caching= - Set true to enable Gradle build cache
|
||||
-Dorg.gradle.daemon.debug= - Set true to debug Gradle Daemon
|
||||
-Dorg.gradle.daemon.idletimeout= - Kill Gradle Daemon after # idle millis
|
||||
-Dorg.gradle.debug= - Set true to debug Gradle Client
|
||||
-Dorg.gradle.jvmargs= - Set JVM arguments
|
||||
-Dorg.gradle.java.home= - Set JDK home dir
|
||||
-Dorg.gradle.logging.level= - Set default Gradle log level (quiet warn lifecycle info debug)
|
||||
-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]}") )
|
||||
return 0
|
||||
}
|
||||
|
||||
__gradle-short-options() {
|
||||
local args="-? - Shows a help message
|
||||
-a - Do not rebuild project dependencies
|
||||
-b - Specifies the build file
|
||||
-c - Specifies the settings file
|
||||
-d - Log at the debug level
|
||||
-g - Specifies the Gradle user home directory
|
||||
-h - Shows a help message
|
||||
-i - Set log level to INFO
|
||||
-m - Runs the build with all task actions disabled
|
||||
-p - Specifies the start directory for Gradle
|
||||
-q - Log errors only
|
||||
-s - Print out the stacktrace also for user exceptions
|
||||
-t - Continuous mode. Automatically re-run build after changes
|
||||
-u - Do not search in parent directories for a settings.gradle
|
||||
-v - Prints Gradle version info
|
||||
-w - Log warnings and errors only
|
||||
-x - Specify a task to be excluded
|
||||
-D - Set a system property
|
||||
-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]}") )
|
||||
}
|
||||
|
||||
__gradle-notify-tasks-cache-build() {
|
||||
# Notify user of cache rebuild
|
||||
echo -e " (Building completion cache. Please wait)\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\c"
|
||||
__gradle-generate-tasks-cache
|
||||
# Remove "please wait" message by writing a bunch of spaces then moving back to the left
|
||||
echo -e " \b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\c"
|
||||
}
|
||||
|
||||
__gradle-generate-tasks-cache() {
|
||||
__gradle-set-files-checksum
|
||||
|
||||
# Use Gradle wrapper when it exists.
|
||||
local gradle_cmd="gradle"
|
||||
if [[ -x "$project_root_dir/gradlew" ]]; then
|
||||
gradle_cmd="$project_root_dir/gradlew"
|
||||
fi
|
||||
|
||||
# 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)"
|
||||
else
|
||||
gradle_tasks_output="$($gradle_cmd -b $gradle_build_file --no-daemon -q tasks --all)"
|
||||
fi
|
||||
local output_line
|
||||
local task_description
|
||||
local -a gradle_all_tasks=()
|
||||
local -a root_tasks=()
|
||||
local -a subproject_tasks=()
|
||||
for output_line in $gradle_tasks_output; do
|
||||
if [[ $output_line =~ ^([[:lower:]][[:alnum:][:punct:]]*)([[:space:]]-[[:space:]]([[:print:]]*))? ]]; then
|
||||
task_name="${BASH_REMATCH[1]}"
|
||||
task_description="${BASH_REMATCH[3]}"
|
||||
gradle_all_tasks+=( "$task_name - $task_description" )
|
||||
# Completion for subproject tasks with ':' prefix
|
||||
if [[ $task_name =~ ^([[:alnum:][:punct:]]+):([[:alnum:]]+) ]]; then
|
||||
gradle_all_tasks+=( ":$task_name - $task_description" )
|
||||
subproject_tasks+=( "${BASH_REMATCH[2]}" )
|
||||
else
|
||||
root_tasks+=( "$task_name" )
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
# 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 )
|
||||
done
|
||||
fi
|
||||
|
||||
printf "%s\n" "${gradle_all_tasks[@]}" > $cache_dir/$gradle_files_checksum
|
||||
echo $gradle_files_checksum > $cache_dir/$cache_name.md5
|
||||
}
|
||||
|
||||
__gradle-completion-init() {
|
||||
local cache_dir cache_name gradle_build_file gradle_files_checksum project_root_dir
|
||||
|
||||
local OLDIFS="$IFS"
|
||||
local IFS=$'\n'
|
||||
|
||||
__gradle-init-cache-dir
|
||||
__gradle-set-project-root-dir
|
||||
__gradle-set-build-file
|
||||
if [[ -f $gradle_build_file ]]; then
|
||||
__gradle-set-cache-name
|
||||
__gradle-generate-script-cache
|
||||
__gradle-set-files-checksum
|
||||
__gradle-notify-tasks-cache-build
|
||||
fi
|
||||
|
||||
IFS="$OLDIFS"
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
_gradle() {
|
||||
local cache_dir cache_name gradle_build_file gradle_files_checksum project_root_dir
|
||||
local cur=${COMP_WORDS[COMP_CWORD]}
|
||||
# Set bash internal field separator to '\n'
|
||||
# This allows us to provide descriptions for options and tasks
|
||||
local OLDIFS="$IFS"
|
||||
local IFS=$'\n'
|
||||
|
||||
if [[ ${cur} == --* ]]; then
|
||||
__gradle-long-options
|
||||
elif [[ ${cur} == -D* ]]; then
|
||||
__gradle-properties
|
||||
elif [[ ${cur} == -* ]]; then
|
||||
__gradle-short-options
|
||||
else
|
||||
__gradle-init-cache-dir
|
||||
__gradle-set-project-root-dir
|
||||
__gradle-set-build-file
|
||||
if [[ -f $gradle_build_file ]]; then
|
||||
__gradle-set-cache-name
|
||||
__gradle-generate-script-cache
|
||||
__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)"
|
||||
local -a cached_tasks
|
||||
if [[ -z $cur ]]; then
|
||||
cached_tasks=( $(cat $cache_dir/$cached_checksum) )
|
||||
else
|
||||
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
|
||||
$(__gradle-generate-tasks-cache 1>&2 2>/dev/null &)
|
||||
fi
|
||||
else
|
||||
# Default tasks available outside Gradle projects
|
||||
local args="buildEnvironment - Displays all buildscript dependencies declared in root project.
|
||||
components - Displays the components produced by root project.
|
||||
dependencies - Displays all dependencies declared in root project.
|
||||
dependencyInsight - Displays the insight into a specific dependency in root project.
|
||||
dependentComponents - Displays the dependent components of components in root project.
|
||||
help - Displays a help message.
|
||||
init - Initializes a new Gradle build.
|
||||
model - Displays the configuration model of root project.
|
||||
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]}") )
|
||||
fi
|
||||
fi
|
||||
|
||||
IFS="$OLDIFS"
|
||||
|
||||
# Remove description ("[:space:]" and after) if only one possibility
|
||||
if [[ ${#COMPREPLY[*]} -eq 1 ]]; then
|
||||
COMPREPLY=( ${COMPREPLY[0]%% *} )
|
||||
fi
|
||||
|
||||
return 0
|
||||
}
|
||||
complete -F _gradle gradle
|
||||
complete -F _gradle gradle.bat
|
||||
complete -F _gradle gradlew
|
||||
complete -F _gradle gradlew.bat
|
||||
complete -F _gradle ./gradlew
|
||||
complete -F _gradle ./gradlew.bat
|
||||
|
||||
if hash gw 2>/dev/null || alias gw >/dev/null 2>&1; then
|
||||
complete -F _gradle gw
|
||||
fi
|
||||
75
dot_bash_it/completion/available/grunt.completion.bash
Normal file
75
dot_bash_it/completion/available/grunt.completion.bash
Normal file
@@ -0,0 +1,75 @@
|
||||
#!/bin/bash
|
||||
|
||||
# grunt-cli
|
||||
# http://gruntjs.com/
|
||||
#
|
||||
# Copyright jQuery Foundation and other contributors, https://jquery.org/
|
||||
|
||||
# This software consists of voluntary contributions made by many
|
||||
# individuals. For exact contribution history, see the revision history
|
||||
# available at https://github.com/gruntjs/grunt .
|
||||
|
||||
# The following license applies to all parts of this software except as
|
||||
# documented below:
|
||||
|
||||
# ====
|
||||
|
||||
# Permission is hereby granted, free of charge, to any person obtaining
|
||||
# a copy of this software and associated documentation files (the
|
||||
# "Software"), to deal in the Software without restriction, including
|
||||
# without limitation the rights to use, copy, modify, merge, publish,
|
||||
# distribute, sublicense, and/or sell copies of the Software, and to
|
||||
# permit persons to whom the Software is furnished to do so, subject to
|
||||
# the following conditions:
|
||||
|
||||
# The above copyright notice and this permission notice shall be
|
||||
# included in all copies or substantial portions of the Software.
|
||||
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
# Usage:
|
||||
#
|
||||
# To enable bash <tab> completion for grunt, add the following line (minus the
|
||||
# leading #, which is the bash comment character) to your ~/.bashrc file:
|
||||
#
|
||||
# eval "$(grunt --completion=bash)"
|
||||
|
||||
# Search the current directory and all parent directories for a gruntfile.
|
||||
function _grunt_gruntfile() {
|
||||
local curpath="$PWD"
|
||||
while [[ "$curpath" ]]; do
|
||||
for gruntfile in "$curpath/"{G,g}runtfile.{js,coffee}; do
|
||||
if [[ -e "$gruntfile" ]]; then
|
||||
echo "$gruntfile"
|
||||
return
|
||||
fi
|
||||
done
|
||||
curpath="${curpath%/*}"
|
||||
done
|
||||
return 1
|
||||
}
|
||||
|
||||
# Enable bash autocompletion.
|
||||
function _grunt_completions() {
|
||||
# The currently-being-completed word.
|
||||
local cur="${COMP_WORDS[COMP_CWORD]}"
|
||||
# The current gruntfile, if it exists.
|
||||
local gruntfile="$(_grunt_gruntfile)"
|
||||
# The current grunt version, available tasks, options, etc.
|
||||
local 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}')"
|
||||
# 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"))
|
||||
}
|
||||
|
||||
complete -o default -F _grunt_completions grunt
|
||||
50
dot_bash_it/completion/available/gulp.completion.bash
Normal file
50
dot_bash_it/completion/available/gulp.completion.bash
Normal file
@@ -0,0 +1,50 @@
|
||||
#!/bin/bash
|
||||
# Borrowed from grunt-cli
|
||||
# http://gruntjs.com/
|
||||
#
|
||||
# Copyright jQuery Foundation and other contributors, https://jquery.org/
|
||||
|
||||
# This software consists of voluntary contributions made by many
|
||||
# individuals. For exact contribution history, see the revision history
|
||||
# available at https://github.com/gruntjs/grunt .
|
||||
|
||||
# The following license applies to all parts of this software except as
|
||||
# documented below:
|
||||
|
||||
# ====
|
||||
|
||||
# Permission is hereby granted, free of charge, to any person obtaining
|
||||
# a copy of this software and associated documentation files (the
|
||||
# "Software"), to deal in the Software without restriction, including
|
||||
# without limitation the rights to use, copy, modify, merge, publish,
|
||||
# distribute, sublicense, and/or sell copies of the Software, and to
|
||||
# permit persons to whom the Software is furnished to do so, subject to
|
||||
# the following conditions:
|
||||
|
||||
# The above copyright notice and this permission notice shall be
|
||||
# included in all copies or substantial portions of the Software.
|
||||
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
# Usage:
|
||||
#
|
||||
# To enable bash <tab> completion for gulp, add the following line (minus the
|
||||
# leading #, which is the bash comment character) to your ~/.bashrc file:
|
||||
#
|
||||
# eval "$(gulp --completion=bash)"
|
||||
# Enable bash autocompletion.
|
||||
function _gulp_completions() {
|
||||
# The currently-being-completed word.
|
||||
local cur="${COMP_WORDS[COMP_CWORD]}"
|
||||
#Grab tasks
|
||||
local compls=$(gulp --tasks-simple)
|
||||
# Tell complete what stuff to show.
|
||||
COMPREPLY=($(compgen -W "$compls" -- "$cur"))
|
||||
}
|
||||
complete -o default -F _gulp_completions gulp
|
||||
7
dot_bash_it/completion/available/helm.completion.bash
Normal file
7
dot_bash_it/completion/available/helm.completion.bash
Normal file
@@ -0,0 +1,7 @@
|
||||
# shellcheck shell=bash
|
||||
cite "about-completion"
|
||||
about-completion "helm (Kubernetes Package Manager) completion"
|
||||
|
||||
if _command_exists helm; then
|
||||
eval "$(helm completion bash)"
|
||||
fi
|
||||
@@ -0,0 +1,2 @@
|
||||
_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.'
|
||||
408
dot_bash_it/completion/available/hub.completion.bash
Normal file
408
dot_bash_it/completion/available/hub.completion.bash
Normal file
@@ -0,0 +1,408 @@
|
||||
# hub tab-completion script for bash.
|
||||
# This script complements the completion script that ships with git.
|
||||
|
||||
# Copyright (c) 2009 Chris Wanstrath
|
||||
|
||||
# Permission is hereby granted, free of charge, to any person obtaining
|
||||
# a copy of this software and associated documentation files (the
|
||||
# "Software"), to deal in the Software without restriction, including
|
||||
# without limitation the rights to use, copy, modify, merge, publish,
|
||||
# distribute, sublicense, and/or sell copies of the Software, and to
|
||||
# permit persons to whom the Software is furnished to do so, subject to
|
||||
# the following conditions:
|
||||
|
||||
# The above copyright notice and this permission notice shall be
|
||||
# included in all copies or substantial portions of the Software.
|
||||
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
# If there is no git tab completion, but we have the _completion loader try to load it
|
||||
if ! _is_function _git && _is_function _completion_loader; then
|
||||
_completion_loader git
|
||||
fi
|
||||
|
||||
# Check that git tab completion is available and we haven't already set up completion
|
||||
if _is_function _git && ! _is_function __git_list_all_commands_without_hub; then
|
||||
# Duplicate and rename the 'list_all_commands' function
|
||||
eval "$(declare -f __git_list_all_commands | \
|
||||
sed 's/__git_list_all_commands/__git_list_all_commands_without_hub/')"
|
||||
|
||||
# Wrap the 'list_all_commands' function with extra hub commands
|
||||
__git_list_all_commands() {
|
||||
cat <<-EOF
|
||||
alias
|
||||
pull-request
|
||||
pr
|
||||
issue
|
||||
release
|
||||
fork
|
||||
create
|
||||
delete
|
||||
browse
|
||||
compare
|
||||
ci-status
|
||||
sync
|
||||
EOF
|
||||
__git_list_all_commands_without_hub
|
||||
}
|
||||
|
||||
# Ensure cached commands are cleared
|
||||
__git_all_commands=""
|
||||
|
||||
##########################
|
||||
# hub command completions
|
||||
##########################
|
||||
|
||||
# hub alias [-s] [SHELL]
|
||||
_git_alias() {
|
||||
local i c=2 s=-s sh shells="bash zsh sh ksh csh fish"
|
||||
while [ $c -lt $cword ]; do
|
||||
i="${words[c]}"
|
||||
case "$i" in
|
||||
-s)
|
||||
unset s
|
||||
;;
|
||||
*)
|
||||
for sh in $shells; do
|
||||
if [ "$sh" = "$i" ]; then
|
||||
unset shells
|
||||
break
|
||||
fi
|
||||
done
|
||||
;;
|
||||
esac
|
||||
((c++))
|
||||
done
|
||||
__gitcomp "$s $shells"
|
||||
}
|
||||
|
||||
# hub browse [-u] [--|[USER/]REPOSITORY] [SUBPAGE]
|
||||
_git_browse() {
|
||||
local i c=2 u=-u repo subpage
|
||||
local subpages_="commits issues tree wiki pulls branches stargazers
|
||||
contributors network network/ graphs graphs/"
|
||||
local subpages_network="members"
|
||||
local subpages_graphs="commit-activity code-frequency punch-card"
|
||||
while [ $c -lt $cword ]; do
|
||||
i="${words[c]}"
|
||||
case "$i" in
|
||||
-u)
|
||||
unset u
|
||||
;;
|
||||
*)
|
||||
if [ -z "$repo" ]; then
|
||||
repo=$i
|
||||
else
|
||||
subpage=$i
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
((c++))
|
||||
done
|
||||
if [ -z "$repo" ]; then
|
||||
__gitcomp "$u -- $(__hub_github_repos '\p')"
|
||||
elif [ -z "$subpage" ]; then
|
||||
case "$cur" in
|
||||
*/*)
|
||||
local pfx="${cur%/*}" cur_="${cur#*/}"
|
||||
local subpages_var="subpages_$pfx"
|
||||
__gitcomp "${!subpages_var}" "$pfx/" "$cur_"
|
||||
;;
|
||||
*)
|
||||
__gitcomp "$u ${subpages_}"
|
||||
;;
|
||||
esac
|
||||
else
|
||||
__gitcomp "$u"
|
||||
fi
|
||||
}
|
||||
|
||||
# hub compare [-u] [USER[/REPOSITORY]] [[START...]END]
|
||||
_git_compare() {
|
||||
local i c=$((cword - 1)) u=-u user remote owner repo arg_repo rev
|
||||
while [ $c -gt 1 ]; do
|
||||
i="${words[c]}"
|
||||
case "$i" in
|
||||
-u)
|
||||
unset u
|
||||
;;
|
||||
*)
|
||||
if [ -z "$rev" ]; then
|
||||
# Even though the logic below is able to complete both user/repo
|
||||
# and revision in the right place, when there is only one argument
|
||||
# (other than -u) in the command, that argument will be taken as
|
||||
# revision. For example:
|
||||
# $ hub compare -u upstream
|
||||
# > https://github.com/USER/REPO/compare/upstream
|
||||
if __hub_github_repos '\p' | grep -Eqx "^$i(/[^/]+)?"; then
|
||||
arg_repo=$i
|
||||
else
|
||||
rev=$i
|
||||
fi
|
||||
elif [ -z "$arg_repo" ]; then
|
||||
arg_repo=$i
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
((c--))
|
||||
done
|
||||
|
||||
# Here we want to find out the git remote name of user/repo, in order to
|
||||
# generate an appropriate revision list
|
||||
if [ -z "$arg_repo" ]; then
|
||||
user=$(__hub_github_user)
|
||||
if [ -z "$user" ]; then
|
||||
for i in $(__hub_github_repos); do
|
||||
remote=${i%%:*}
|
||||
repo=${i#*:}
|
||||
if [ "$remote" = origin ]; then
|
||||
break
|
||||
fi
|
||||
done
|
||||
else
|
||||
for i in $(__hub_github_repos); do
|
||||
remote=${i%%:*}
|
||||
repo=${i#*:}
|
||||
owner=${repo%%/*}
|
||||
if [ "$user" = "$owner" ]; then
|
||||
break
|
||||
fi
|
||||
done
|
||||
fi
|
||||
else
|
||||
for i in $(__hub_github_repos); do
|
||||
remote=${i%%:*}
|
||||
repo=${i#*:}
|
||||
owner=${repo%%/*}
|
||||
case "$arg_repo" in
|
||||
"$repo"|"$owner")
|
||||
break
|
||||
;;
|
||||
esac
|
||||
done
|
||||
fi
|
||||
|
||||
local pfx cur_="$cur"
|
||||
case "$cur_" in
|
||||
*..*)
|
||||
pfx="${cur_%%..*}..."
|
||||
cur_="${cur_##*..}"
|
||||
__gitcomp_nl "$(__hub_revlist $remote)" "$pfx" "$cur_"
|
||||
;;
|
||||
*)
|
||||
if [ -z "${arg_repo}${rev}" ]; then
|
||||
__gitcomp "$u $(__hub_github_repos '\o\n\p') $(__hub_revlist $remote)"
|
||||
elif [ -z "$rev" ]; then
|
||||
__gitcomp "$u $(__hub_revlist $remote)"
|
||||
else
|
||||
__gitcomp "$u"
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
# hub create [NAME] [-p] [-d DESCRIPTION] [-h HOMEPAGE]
|
||||
_git_create() {
|
||||
local i c=2 name repo flags="-p -d -h"
|
||||
while [ $c -lt $cword ]; do
|
||||
i="${words[c]}"
|
||||
case "$i" in
|
||||
-d|-h)
|
||||
((c++))
|
||||
flags=${flags/$i/}
|
||||
;;
|
||||
-p)
|
||||
flags=${flags/$i/}
|
||||
;;
|
||||
*)
|
||||
name=$i
|
||||
;;
|
||||
esac
|
||||
((c++))
|
||||
done
|
||||
if [ -z "$name" ]; then
|
||||
repo="$(basename "${PWD}")"
|
||||
fi
|
||||
case "$prev" in
|
||||
-d|-h)
|
||||
COMPREPLY=()
|
||||
;;
|
||||
-p|*)
|
||||
__gitcomp "$repo $flags"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
# hub fork [--no-remote] [--remote-name REMOTE] [--org ORGANIZATION]
|
||||
_git_fork() {
|
||||
local i c=2 flags="--no-remote --remote-name --org"
|
||||
while [ $c -lt $cword ]; do
|
||||
i="${words[c]}"
|
||||
case "$i" in
|
||||
--org)
|
||||
((c++))
|
||||
flags=${flags/$i/}
|
||||
;;
|
||||
--remote-name)
|
||||
((c++))
|
||||
flags=${flags/$i/}
|
||||
flags=${flags/--no-remote/}
|
||||
;;
|
||||
--no-remote)
|
||||
flags=${flags/$i/}
|
||||
flags=${flags/--remote-name/}
|
||||
;;
|
||||
esac
|
||||
((c++))
|
||||
done
|
||||
case "$prev" in
|
||||
--remote-name|--org)
|
||||
COMPREPLY=()
|
||||
;;
|
||||
*)
|
||||
__gitcomp "$flags"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
# hub pull-request [-f] [-m <MESSAGE>|-F <FILE>|-i <ISSUE>|<ISSUE-URL>] [-b <BASE>] [-h <HEAD>] [-a <USER>] [-M <MILESTONE>] [-l <LABELS>]
|
||||
_git_pull_request() {
|
||||
local i c=2 flags="-f -m -F -i -b -h -a -M -l"
|
||||
while [ $c -lt $cword ]; do
|
||||
i="${words[c]}"
|
||||
case "$i" in
|
||||
-m|-F|-i|-b|-h|-a|-M|-l)
|
||||
((c++))
|
||||
flags=${flags/$i/}
|
||||
;;
|
||||
-f)
|
||||
flags=${flags/$i/}
|
||||
;;
|
||||
esac
|
||||
((c++))
|
||||
done
|
||||
case "$prev" in
|
||||
-i)
|
||||
COMPREPLY=()
|
||||
;;
|
||||
-b|-h|-a|-M|-l)
|
||||
# (Doesn't seem to need this...)
|
||||
# Uncomment the following line when 'owner/repo:[TAB]' misbehaved
|
||||
#_get_comp_words_by_ref -n : cur
|
||||
__gitcomp_nl "$(__hub_heads)"
|
||||
# __ltrim_colon_completions "$cur"
|
||||
;;
|
||||
-F)
|
||||
COMPREPLY=( "$cur"* )
|
||||
;;
|
||||
-f|*)
|
||||
__gitcomp "$flags"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
###################
|
||||
# Helper functions
|
||||
###################
|
||||
|
||||
# __hub_github_user [HOST]
|
||||
# Return $GITHUB_USER or the default github user defined in hub config
|
||||
# HOST - Host to be looked-up in hub config. Default is "github.com"
|
||||
__hub_github_user() {
|
||||
if [ -n "$GITHUB_USER" ]; then
|
||||
echo $GITHUB_USER
|
||||
return
|
||||
fi
|
||||
local line h k v host=${1:-github.com} config=${HUB_CONFIG:-~/.config/hub}
|
||||
if [ -f "$config" ]; then
|
||||
while read line; do
|
||||
if [ "$line" = "---" ]; then
|
||||
continue
|
||||
fi
|
||||
k=${line%%:*}
|
||||
v=${line#*:}
|
||||
if [ -z "$v" ]; then
|
||||
if [ "$h" = "$host" ]; then
|
||||
break
|
||||
fi
|
||||
h=$k
|
||||
continue
|
||||
fi
|
||||
k=${k#* }
|
||||
v=${v#* }
|
||||
if [ "$h" = "$host" ] && [ "$k" = "user" ]; then
|
||||
echo "$v"
|
||||
break
|
||||
fi
|
||||
done < "$config"
|
||||
fi
|
||||
}
|
||||
|
||||
# __hub_github_repos [FORMAT]
|
||||
# List all github hosted repository
|
||||
# FORMAT - Format string contains multiple of these:
|
||||
# \m remote
|
||||
# \p owner/repo
|
||||
# \o owner
|
||||
# escaped characters (\n, \t ...etc) work
|
||||
# If omitted, prints all github repos in the format of "remote:owner/repo"
|
||||
__hub_github_repos() {
|
||||
local f format=$1
|
||||
if [ -z "$(__gitdir)" ]; then
|
||||
return
|
||||
fi
|
||||
if [ -z "$format" ]; then
|
||||
format='\1:\2'
|
||||
else
|
||||
format=${format//\m/\1}
|
||||
format=${format//\p/\2}
|
||||
format=${format//\o/\3}
|
||||
fi
|
||||
command git config --get-regexp 'remote\.[^.]*\.url' |
|
||||
grep -E ' ((https?|git)://|git@)github\.com[:/][^:/]+/[^/]+$' |
|
||||
sed -E 's#^remote\.([^.]+)\.url +.+[:/](([^/]+)/[^.]+)(\.git)?$#'"$format"'#'
|
||||
}
|
||||
|
||||
# __hub_heads
|
||||
# List all local "branch", and remote "owner/repo:branch"
|
||||
__hub_heads() {
|
||||
local i remote repo branch dir=$(__gitdir)
|
||||
if [ -d "$dir" ]; then
|
||||
command git --git-dir="$dir" for-each-ref --format='%(refname:short)' \
|
||||
"refs/heads/"
|
||||
for i in $(__hub_github_repos); do
|
||||
remote=${i%%:*}
|
||||
repo=${i#*:}
|
||||
command git --git-dir="$dir" for-each-ref --format='%(refname:short)' \
|
||||
"refs/remotes/${remote}/" | while read branch; do
|
||||
echo "${repo}:${branch#${remote}/}"
|
||||
done
|
||||
done
|
||||
fi
|
||||
}
|
||||
|
||||
# __hub_revlist [REMOTE]
|
||||
# List all tags, and branches under REMOTE, without the "remote/" prefix
|
||||
# REMOTE - Remote name to search branches from. Default is "origin"
|
||||
__hub_revlist() {
|
||||
local i remote=${1:-origin} dir=$(__gitdir)
|
||||
if [ -d "$dir" ]; then
|
||||
command git --git-dir="$dir" for-each-ref --format='%(refname:short)' \
|
||||
"refs/remotes/${remote}/" | while read i; do
|
||||
echo "${i#${remote}/}"
|
||||
done
|
||||
command git --git-dir="$dir" for-each-ref --format='%(refname:short)' \
|
||||
"refs/tags/"
|
||||
fi
|
||||
}
|
||||
|
||||
# Enable completion for hub even when not using the alias
|
||||
complete -o bashdefault -o default -o nospace -F _git hub 2>/dev/null \
|
||||
|| complete -o default -o nospace -F _git hub
|
||||
fi
|
||||
54
dot_bash_it/completion/available/invoke.completion.bash
Normal file
54
dot_bash_it/completion/available/invoke.completion.bash
Normal file
@@ -0,0 +1,54 @@
|
||||
# Invoke (pyinvoke.org) tab-completion script to be sourced with Bash shell.
|
||||
|
||||
# Copyright (c) 2020 Jeff Forcier.
|
||||
# All rights reserved.
|
||||
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
|
||||
# * Redistributions of source code must retain the above copyright notice,
|
||||
# this list of conditions and the following disclaimer.
|
||||
# * Redistributions in binary form must reproduce the above copyright notice,
|
||||
# this list of conditions and the following disclaimer in the documentation
|
||||
# and/or other materials provided with the distribution.
|
||||
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
# https://github.com/pyinvoke/invoke/blob/master/completion/bash
|
||||
|
||||
_complete_invoke() {
|
||||
local candidates
|
||||
|
||||
# COMP_WORDS contains the entire command string up til now (including
|
||||
# program name).
|
||||
# We hand it to Invoke so it can figure out the current context: spit back
|
||||
# core options, task names, the current task's options, or some combo.
|
||||
candidates=`invoke --complete -- ${COMP_WORDS[*]}`
|
||||
|
||||
# `compgen -W` takes list of valid options & a partial word & spits back
|
||||
# possible matches. Necessary for any partial word completions (vs
|
||||
# completions performed when no partial words are present).
|
||||
#
|
||||
# $2 is the current word or token being tabbed on, either empty string or a
|
||||
# partial word, and thus wants to be compgen'd to arrive at some subset of
|
||||
# our candidate list which actually matches.
|
||||
#
|
||||
# COMPREPLY is the list of valid completions handed back to `complete`.
|
||||
COMPREPLY=( $(compgen -W "${candidates}" -- $2) )
|
||||
}
|
||||
|
||||
|
||||
# Tell shell builtin to use the above for completing 'inv'/'invoke':
|
||||
# * -F: use given function name to generate completions.
|
||||
# * -o default: when function generates no results, use filenames.
|
||||
# * positional args: program names to complete for.
|
||||
complete -F _complete_invoke -o default invoke inv
|
||||
4
dot_bash_it/completion/available/jboss5.completion.bash
Normal file
4
dot_bash_it/completion/available/jboss5.completion.bash
Normal file
@@ -0,0 +1,4 @@
|
||||
# shellcheck shell=bash
|
||||
about-completion "jboss5 completion"
|
||||
# shellcheck disable=SC1090
|
||||
source "${BASH_IT}"/vendor/github.com/rparree/jboss-bash-completion/jboss5
|
||||
4
dot_bash_it/completion/available/jboss7.completion.bash
Normal file
4
dot_bash_it/completion/available/jboss7.completion.bash
Normal file
@@ -0,0 +1,4 @@
|
||||
# shellcheck shell=bash
|
||||
about-completion "jboss7 completion"
|
||||
# shellcheck disable=SC1090
|
||||
source "${BASH_IT}"/vendor/github.com/rparree/jboss-bash-completion/jboss7
|
||||
7
dot_bash_it/completion/available/jungle.completion.bash
Normal file
7
dot_bash_it/completion/available/jungle.completion.bash
Normal file
@@ -0,0 +1,7 @@
|
||||
# shellcheck shell=bash
|
||||
cite "about-completion"
|
||||
about-completion "jungle(AWS cli tool) completion"
|
||||
|
||||
if _command_exists jungle; then
|
||||
eval "$(_JUNGLE_COMPLETE=source jungle)"
|
||||
fi
|
||||
5
dot_bash_it/completion/available/kind.completion.bash
Normal file
5
dot_bash_it/completion/available/kind.completion.bash
Normal file
@@ -0,0 +1,5 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
if _command_exists kind; then
|
||||
eval "$(kind completion bash)"
|
||||
fi
|
||||
205
dot_bash_it/completion/available/knife.completion.bash
Normal file
205
dot_bash_it/completion/available/knife.completion.bash
Normal file
@@ -0,0 +1,205 @@
|
||||
# shellcheck shell=bash
|
||||
|
||||
# Published originally as public domain code at https://github.com/wk8/knife-bash-autocomplete
|
||||
|
||||
##############
|
||||
### CONFIG ###
|
||||
##############
|
||||
### feel free to change those constants
|
||||
# the dir where to store the cache (must be writable and readable by the current user)
|
||||
# must be an absolute path
|
||||
_KNIFE_AUTOCOMPLETE_CACHE_DIR="$HOME/.knife_autocomplete_cache"
|
||||
# the maximum # of _seconds_ after which a cache will be considered stale
|
||||
# (a cache is refreshed whenever it is used! this is only for caches that might not have been used for a long time)
|
||||
# WARNING: keep that value > 100
|
||||
_KNIFE_AUTOCOMPLETE_MAX_CACHE_AGE=86400
|
||||
|
||||
###############################################
|
||||
### END OF CONFIG - DON'T CHANGE CODE BELOW ###
|
||||
###############################################
|
||||
|
||||
### init
|
||||
_KAC_CACHE_TMP_DIR="$_KNIFE_AUTOCOMPLETE_CACHE_DIR/tmp"
|
||||
# make sure the cache dir exists
|
||||
mkdir -p "$_KAC_CACHE_TMP_DIR"
|
||||
|
||||
##############################
|
||||
### Cache helper functions ###
|
||||
##############################
|
||||
|
||||
# GNU or BSD stat?
|
||||
stat -c %Y /dev/null > /dev/null 2>&1 && _KAC_STAT_COMMAND="stat -c %Y" || _KAC_STAT_COMMAND="stat -f %m"
|
||||
|
||||
# returns 0 iff the file whose path is given as 1st argument
|
||||
# exists and has last been modified in the last $2 seconds
|
||||
# returns 1 otherwise
|
||||
_KAC_is_file_newer_than() {
|
||||
[ -f "$1" ] || return 1
|
||||
[ $(($(date +%s) - $($_KAC_STAT_COMMAND "$1"))) -gt "$2" ] && return 1 || return 0
|
||||
}
|
||||
|
||||
# helper function for _KAC_get_and_regen_cache, see doc below
|
||||
_KAC_regen_cache() {
|
||||
local CACHE_NAME=$1
|
||||
local CACHE_PATH="$_KNIFE_AUTOCOMPLETE_CACHE_DIR/$CACHE_NAME"
|
||||
# shellcheck disable=SC2155
|
||||
local TMP_FILE=$(mktemp "$_KAC_CACHE_TMP_DIR/$CACHE_NAME.XXXX")
|
||||
shift 1
|
||||
# discard the temp file if it's empty AND the previous command didn't exit successfully, but still mark the cache as updated
|
||||
if ! "$@" > "$TMP_FILE" 2> /dev/null; then
|
||||
[[ $(wc -l "$TMP_FILE") == 0 ]] && rm -f "$TMP_FILE" && touch "$CACHE_PATH" && return 1
|
||||
else
|
||||
mv -f "$TMP_FILE" "$CACHE_PATH"
|
||||
fi
|
||||
}
|
||||
|
||||
# cached files can't have spaces in their names
|
||||
_KAC_get_cache_name_from_command() {
|
||||
echo "${@// /_SPACE_}"
|
||||
}
|
||||
|
||||
# the reverse operation from the function above
|
||||
_KAC_get_command_from_cache_name() {
|
||||
echo "${@//_SPACE_/ }"
|
||||
}
|
||||
|
||||
# given a command as argument, it fetches the cache for that command if it can find it
|
||||
# otherwise it waits for the cache to be generated
|
||||
# in either case, it regenerates the cache, and sets the _KAC_CACHE_PATH env variable
|
||||
# for obvious reason, do NOT call that in a sub-shell (in particular, no piping)
|
||||
# shellcheck disable=SC2155
|
||||
_KAC_get_and_regen_cache() {
|
||||
# the cache name can't have space in it
|
||||
local CACHE_NAME=$(_KAC_get_cache_name_from_command "$@")
|
||||
local REGEN_CMD="_KAC_regen_cache $CACHE_NAME $*"
|
||||
_KAC_CACHE_PATH="$_KNIFE_AUTOCOMPLETE_CACHE_DIR/$CACHE_NAME"
|
||||
# no need to wait for the regen if the file already exists
|
||||
if [[ -f "$_KAC_CACHE_PATH" ]]; then
|
||||
($REGEN_CMD &)
|
||||
else
|
||||
$REGEN_CMD
|
||||
fi
|
||||
}
|
||||
|
||||
# performs two things: first, deletes all obsolete temp files
|
||||
# then refreshes stale caches that haven't been called in a long time
|
||||
_KAC_clean_cache() {
|
||||
local FILE CMD
|
||||
# delete all obsolete temp files, could be lingering there for any kind of crash in the caching process
|
||||
for FILE in "$_KAC_CACHE_TMP_DIR"/*; do
|
||||
_KAC_is_file_newer_than "$FILE" "$_KNIFE_AUTOCOMPLETE_MAX_CACHE_AGE" || rm -f "$FILE"
|
||||
done
|
||||
# refresh really stale caches
|
||||
find "$_KNIFE_AUTOCOMPLETE_CACHE_DIR" -maxdepth 1 -type f -not -name '.*' \
|
||||
| while read -r FILE; do
|
||||
_KAC_is_file_newer_than "$FILE" "$_KNIFE_AUTOCOMPLETE_MAX_CACHE_AGE" && continue
|
||||
# first let's get the original command
|
||||
CMD=$(_KAC_get_command_from_cache_name "$(basename "$FILE")")
|
||||
# then regen the cache
|
||||
_KAC_get_and_regen_cache "$CMD" > /dev/null
|
||||
done
|
||||
}
|
||||
|
||||
# perform a cache cleaning when loading this file
|
||||
# On big systems this could baloon up to a 30 second run or more, so not enabling by default.
|
||||
[[ -n "${KNIFE_CACHE_CLEAN}" ]] && _KAC_clean_cache
|
||||
|
||||
#####################################
|
||||
### End of cache helper functions ###
|
||||
#####################################
|
||||
|
||||
# returns all the possible knife sub-commands
|
||||
_KAC_knife_commands() {
|
||||
knife --help | grep -E "^knife" | sed -E 's/ \(options\)//g'
|
||||
}
|
||||
|
||||
# rebuilds the knife base command currently being completed, and assigns it to $_KAC_CURRENT_COMMAND
|
||||
# additionnally, returns 1 iff the current base command is not complete, 0 otherwise
|
||||
# also sets $_KAC_CURRENT_COMMAND_NB_WORDS if the base command is complete
|
||||
_KAC_get_current_base_command() {
|
||||
local PREVIOUS="knife"
|
||||
local I=1
|
||||
local CURRENT
|
||||
while [[ "${I}" -le "${COMP_CWORD}" ]]; do
|
||||
# command words are all lower-case
|
||||
echo "${COMP_WORDS[$I]}" | grep -E "^[a-z]+$" > /dev/null || break
|
||||
CURRENT="$PREVIOUS ${COMP_WORDS[$I]}"
|
||||
grep -E "^$CURRENT" "$_KAC_CACHE_PATH" > /dev/null || break
|
||||
PREVIOUS=$CURRENT
|
||||
I=$((I + 1))
|
||||
done
|
||||
_KAC_CURRENT_COMMAND=$PREVIOUS
|
||||
[[ "${I}" -le "${COMP_CWORD}" ]] && _KAC_CURRENT_COMMAND_NB_WORDS="${I}"
|
||||
}
|
||||
|
||||
# searches the position of the currently completed argument in the current base command
|
||||
# (i.e. handles "plural" arguments such as knife cookbook upload cookbook1 cookbook2 and so on...)
|
||||
# assumes the current base command is complete
|
||||
# shellcheck disable=SC2155
|
||||
_KAC_get_current_arg_position() {
|
||||
local CURRENT_ARG_POS=$((_KAC_CURRENT_COMMAND_NB_WORDS + 1))
|
||||
local COMPLETE_COMMAND=$(grep -E "^$_KAC_CURRENT_COMMAND" "$_KAC_CACHE_PATH")
|
||||
local CURRENT_ARG
|
||||
while [ "$CURRENT_ARG_POS" -le "$COMP_CWORD" ]; do
|
||||
CURRENT_ARG=$(echo "$COMPLETE_COMMAND" | cut -d ' ' -f "$CURRENT_ARG_POS")
|
||||
# we break if the current arg is a "plural" arg
|
||||
echo "$CURRENT_ARG" | grep -E "^\\[[^]]+(\\.\\.\\.\\]|$)" > /dev/null && break
|
||||
CURRENT_ARG_POS=$((CURRENT_ARG_POS + 1))
|
||||
done
|
||||
echo "$CURRENT_ARG_POS"
|
||||
}
|
||||
|
||||
# the actual auto-complete function
|
||||
_knife() {
|
||||
_KAC_get_and_regen_cache _KAC_knife_commands
|
||||
local RAW_LIST ITEM REGEN_CMD ARG_POSITION
|
||||
# shellcheck disable=SC2034
|
||||
COMREPLY=()
|
||||
# get correct command & arg pos
|
||||
_KAC_get_current_base_command && ARG_POSITION=$(_KAC_get_current_arg_position) || ARG_POSITION=$((COMP_CWORD + 1))
|
||||
RAW_LIST=$(grep -E "^${_KAC_CURRENT_COMMAND}" "${_KAC_CACHE_PATH}" | cut -d ' ' -f "${ARG_POSITION}" | uniq)
|
||||
|
||||
# we need to process that raw list a bit, most notably for placeholders
|
||||
# NOTE: I chose to explicitely fetch & cache _certain_ informations for the server (cookbooks & node names, etc)
|
||||
# as opposed to a generic approach by trying to find a 'list' knife command corresponding to the
|
||||
# current base command - that might limit my script in some situation, but that way I'm sure it caches only
|
||||
# not-sensitive stuff (a generic approach could be pretty bad e.g. with the knife-rackspace plugin)
|
||||
LIST=""
|
||||
for ITEM in $RAW_LIST; do
|
||||
# always relevant if only lower-case chars : continuation of the base command
|
||||
echo "$ITEM" | grep -E "^[a-z]+$" > /dev/null && LIST="$LIST $ITEM" && continue
|
||||
case "$ITEM" in
|
||||
*COOKBOOK*)
|
||||
# special case for cookbooks : from site or local
|
||||
[[ ${COMP_WORDS[2]} == 'site' ]] && REGEN_CMD="knife cookbook site list" || REGEN_CMD="knife cookbook list"
|
||||
_KAC_get_and_regen_cache "$REGEN_CMD"
|
||||
LIST="$LIST $(cut -d ' ' -f 1 < "$_KAC_CACHE_PATH")"
|
||||
continue
|
||||
;;
|
||||
*ITEM*)
|
||||
# data bag item : another special case
|
||||
local DATA_BAG_NAME=${COMP_WORDS[$((COMP_CWORD - 1))]}
|
||||
REGEN_CMD="knife data bag show $DATA_BAG_NAME"
|
||||
;;
|
||||
*INDEX*)
|
||||
# see doc @ http://docs.opscode.com/knife_search.html
|
||||
LIST="$LIST client environment node role"
|
||||
REGEN_CMD="knife data bag list"
|
||||
;;
|
||||
*BAG*) REGEN_CMD="knife data bag list" ;;
|
||||
*CLIENT*) REGEN_CMD="knife client list" ;;
|
||||
*NODE*) REGEN_CMD="knife node list" ;;
|
||||
*ENVIRONMENT*) REGEN_CMD="knife environment list" ;;
|
||||
*ROLE*) REGEN_CMD="knife role list" ;;
|
||||
*USER*) REGEN_CMD="knife user list" ;;
|
||||
# not a generic argument we support...
|
||||
*) continue ;;
|
||||
esac
|
||||
_KAC_get_and_regen_cache "$REGEN_CMD"
|
||||
LIST="$LIST $(cat "$_KAC_CACHE_PATH")"
|
||||
done
|
||||
# shellcheck disable=SC2207,SC2086
|
||||
COMPREPLY=($(compgen -W "${LIST}" -- ${COMP_WORDS[COMP_CWORD]}))
|
||||
}
|
||||
|
||||
complete -F _knife knife
|
||||
5
dot_bash_it/completion/available/kontena.completion.bash
Normal file
5
dot_bash_it/completion/available/kontena.completion.bash
Normal file
@@ -0,0 +1,5 @@
|
||||
# shellcheck shell=bash
|
||||
if _command_exists kontena; then
|
||||
# shellcheck disable=SC1090
|
||||
source "$(kontena whoami --bash-completion-path)"
|
||||
fi
|
||||
7
dot_bash_it/completion/available/kubectl.completion.bash
Normal file
7
dot_bash_it/completion/available/kubectl.completion.bash
Normal file
@@ -0,0 +1,7 @@
|
||||
# shellcheck shell=bash
|
||||
cite "about-completion"
|
||||
about-completion "kubectl (Kubernetes CLI) completion"
|
||||
|
||||
if _binary_exists kubectl; then
|
||||
eval "$(kubectl completion bash)"
|
||||
fi
|
||||
16
dot_bash_it/completion/available/laravel.completion.bash
Normal file
16
dot_bash_it/completion/available/laravel.completion.bash
Normal file
@@ -0,0 +1,16 @@
|
||||
# shellcheck shell=bash
|
||||
|
||||
_command_exists laravel || return
|
||||
|
||||
function __laravel_completion() {
|
||||
local OPTS=('-h' '--help' '-q' '--quiet' '--ansi' '--no-ansi' '-n' '--no-interaction' '-v' '-vv' '-vvv' '--verbose' 'help' 'list' 'new')
|
||||
local _opt_
|
||||
COMPREPLY=()
|
||||
for _opt_ in "${OPTS[@]}"; do
|
||||
if [[ "$_opt_" == "$2"* ]]; then
|
||||
COMPREPLY+=("$_opt_")
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
complete -F __laravel_completion laravel
|
||||
22
dot_bash_it/completion/available/lerna.completion.bash
Normal file
22
dot_bash_it/completion/available/lerna.completion.bash
Normal file
@@ -0,0 +1,22 @@
|
||||
# shellcheck shell=bash
|
||||
cite "about-completion"
|
||||
about-completion "lerna(javascript project manager tool) completion"
|
||||
|
||||
function __lerna_completion() {
|
||||
local cur compls
|
||||
|
||||
# The currently-being-completed word.
|
||||
cur="${COMP_WORDS[COMP_CWORD]}"
|
||||
|
||||
# Options
|
||||
compls="add bootstrap changed clean create diff exec \
|
||||
import init link list publish run version \
|
||||
--loglevel --concurrency --reject-cycles \
|
||||
--progress --sort --no-sort --help \
|
||||
--version"
|
||||
|
||||
# Tell complete what stuff to show.
|
||||
# shellcheck disable=2207
|
||||
COMPREPLY=($(compgen -W "$compls" -- "$cur"))
|
||||
}
|
||||
complete -o default -F __lerna_completion lerna
|
||||
34
dot_bash_it/completion/available/makefile.completion.bash
Normal file
34
dot_bash_it/completion/available/makefile.completion.bash
Normal file
@@ -0,0 +1,34 @@
|
||||
# Bash completion for Makefile
|
||||
# Loosely adapted from http://stackoverflow.com/a/38415982/1472048
|
||||
|
||||
_makecomplete() {
|
||||
COMPREPLY=()
|
||||
|
||||
# https://www.gnu.org/software/make/manual/html_node/Makefile-Names.html
|
||||
local files=()
|
||||
for f in 'GNUmakefile' 'makefile' 'Makefile' ; do
|
||||
[ -f "$f" ] && files+=("$f")
|
||||
done
|
||||
|
||||
[ "${#files[@]}" -eq 0 ] && return 0
|
||||
|
||||
# collect all targets
|
||||
local targets=()
|
||||
for f in "${files[@]}" ; do
|
||||
while IFS='' read -r line ; do
|
||||
targets+=("$line")
|
||||
done < <(grep -oE '^[a-zA-Z0-9_-]+:([^=]|$)' "$f" | cut -d':' -f1)
|
||||
done
|
||||
|
||||
[ "${#targets[@]}" -eq 0 ] && return 0
|
||||
|
||||
# use the targets for completion
|
||||
while IFS='' read -r line ; do
|
||||
COMPREPLY+=("$line")
|
||||
done < <(compgen -W "$(tr ' ' '\n' <<<"${targets[@]}" | sort -u)" -- "${COMP_WORDS[COMP_CWORD]}")
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
complete -o nospace -F _makecomplete make
|
||||
complete -o nospace -F _makecomplete gnumake
|
||||
36
dot_bash_it/completion/available/maven.completion.bash
Normal file
36
dot_bash_it/completion/available/maven.completion.bash
Normal file
@@ -0,0 +1,36 @@
|
||||
#!/usr/bin/env bash
|
||||
# Bash Maven completion
|
||||
|
||||
_mvn()
|
||||
{
|
||||
local cmds cur colonprefixes
|
||||
cmds="clean validate compile test package integration-test \
|
||||
verify install deploy test-compile site generate-sources \
|
||||
process-sources generate-resources process-resources \
|
||||
eclipse:eclipse eclipse:add-maven-repo eclipse:clean \
|
||||
idea:idea -DartifactId= -DgroupId= -Dmaven.test.skip=true \
|
||||
-Declipse.workspace= -DarchetypeArtifactId= \
|
||||
netbeans-freeform:generate-netbeans-project \
|
||||
tomcat:run tomcat:run-war tomcat:deploy jboss-as:deploy \
|
||||
versions:display-dependency-updates \
|
||||
versions:display-plugin-updates dependency:analyze \
|
||||
dependency:analyze-dep-mgt dependency:resolve \
|
||||
dependency:sources dependency:tree release:prepare \
|
||||
release:rollback release:perform --batch-mode"
|
||||
|
||||
COMPREPLY=()
|
||||
cur=${COMP_WORDS[COMP_CWORD]}
|
||||
# Work-around bash_completion issue where bash interprets a colon
|
||||
# as a separator.
|
||||
# Work-around borrowed from the darcs work-around for the same
|
||||
# issue.
|
||||
colonprefixes=${cur%"${cur##*:}"}
|
||||
COMPREPLY=( $(compgen -W '$cmds' -- $cur))
|
||||
local i=${#COMPREPLY[*]}
|
||||
while [ $((--i)) -ge 0 ]; do
|
||||
COMPREPLY[$i]=${COMPREPLY[$i]#"$colonprefixes"}
|
||||
done
|
||||
|
||||
return 0
|
||||
} &&
|
||||
complete -F _mvn mvn
|
||||
@@ -0,0 +1,6 @@
|
||||
# shellcheck shell=bash
|
||||
# minikube (Local Kubernetes) completion
|
||||
|
||||
if _command_exists minikube; then
|
||||
eval "$(minikube completion bash)"
|
||||
fi
|
||||
@@ -0,0 +1 @@
|
||||
_command_exists minishift && source <(minishift completion bash)
|
||||
8
dot_bash_it/completion/available/ng.completion.bash
Normal file
8
dot_bash_it/completion/available/ng.completion.bash
Normal file
@@ -0,0 +1,8 @@
|
||||
if _command_exists ng; then
|
||||
# No longer supported, please see https://github.com/angular/angular-cli/issues/11043
|
||||
# Fix courtesy of https://stackoverflow.com/questions/50194674/ng-completion-no-longer-exists
|
||||
# . <(ng completion --bash)
|
||||
|
||||
NG_COMMANDS="add build config doc e2e generate help lint new run serve test update version xi18n"
|
||||
complete -W "$NG_COMMANDS" ng
|
||||
fi
|
||||
47
dot_bash_it/completion/available/ngrok.completion.bash
Normal file
47
dot_bash_it/completion/available/ngrok.completion.bash
Normal file
@@ -0,0 +1,47 @@
|
||||
# shellcheck shell=bash
|
||||
|
||||
__ngrok_completion() {
|
||||
# shellcheck disable=SC2155
|
||||
local prev=$(_get_pword)
|
||||
# shellcheck disable=SC2155
|
||||
local curr=$(_get_cword)
|
||||
|
||||
local BASE_NO_CONF="--log --log-format --log-level --help"
|
||||
local BASE="--config $BASE_NO_CONF"
|
||||
local DEFAULT="$BASE --authtoken --region"
|
||||
|
||||
case $prev in
|
||||
authtoken)
|
||||
# shellcheck disable=SC2207
|
||||
COMPREPLY=($(compgen -W "$BASE" -- "$curr"))
|
||||
;;
|
||||
http)
|
||||
# shellcheck disable=SC2207
|
||||
COMPREPLY=($(compgen -W "$DEFAULT --auth --bind-tls --host-header --hostname --inspect --subdomain" -- "$curr"))
|
||||
;;
|
||||
start)
|
||||
# shellcheck disable=SC2207
|
||||
COMPREPLY=($(compgen -W "$DEFAULT --all --none" -- "$curr"))
|
||||
;;
|
||||
tcp)
|
||||
# shellcheck disable=SC2207
|
||||
COMPREPLY=($(compgen -W "$DEFAULT --remote-addr" -- "$curr"))
|
||||
;;
|
||||
tls)
|
||||
# shellcheck disable=SC2207
|
||||
COMPREPLY=($(compgen -W "$DEFAULT --client-cas --crt --hostname --key --subdomain" -- "$curr"))
|
||||
;;
|
||||
update)
|
||||
# shellcheck disable=SC2207
|
||||
COMPREPLY=($(compgen -W "$BASE_NO_CONF --channel" -- "$curr"))
|
||||
;;
|
||||
ngrok)
|
||||
# shellcheck disable=SC2207
|
||||
COMPREPLY=($(compgen -W "authtoken credits http start tcp tls update version help" -- "$curr"))
|
||||
;;
|
||||
*) ;;
|
||||
|
||||
esac
|
||||
}
|
||||
|
||||
complete -F __ngrok_completion ngrok
|
||||
21
dot_bash_it/completion/available/notify-send.completion.bash
Normal file
21
dot_bash_it/completion/available/notify-send.completion.bash
Normal file
@@ -0,0 +1,21 @@
|
||||
# shellcheck shell=bash
|
||||
|
||||
function __notify-send_completions() {
|
||||
# shellcheck disable=SC2155
|
||||
local curr=$(_get_cword)
|
||||
# shellcheck disable=SC2155
|
||||
local prev=$(_get_pword)
|
||||
|
||||
case $prev in
|
||||
-u | --urgency)
|
||||
# shellcheck disable=SC2207
|
||||
COMPREPLY=($(compgen -W "low normal critical" -- "$curr"))
|
||||
;;
|
||||
*)
|
||||
# shellcheck disable=SC2207
|
||||
COMPREPLY=($(compgen -W "-? --help -u --urgency -t --expire-time -a --app-name -i --icon -c --category -h --hint -v --version" -- "$curr"))
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
complete -F __notify-send_completions notify-send
|
||||
7
dot_bash_it/completion/available/npm.completion.bash
Normal file
7
dot_bash_it/completion/available/npm.completion.bash
Normal file
@@ -0,0 +1,7 @@
|
||||
# shellcheck shell=bash
|
||||
cite "about-completion"
|
||||
about-completion "npm (Node Package Manager) completion"
|
||||
|
||||
if _command_exists npm; then
|
||||
eval "$(npm completion)"
|
||||
fi
|
||||
8
dot_bash_it/completion/available/nvm.completion.bash
Normal file
8
dot_bash_it/completion/available/nvm.completion.bash
Normal file
@@ -0,0 +1,8 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# nvm (Node Version Manager) completion
|
||||
|
||||
if [ "$NVM_DIR" ] && [ -r "$NVM_DIR"/bash_completion ];
|
||||
then
|
||||
. "$NVM_DIR"/bash_completion
|
||||
fi
|
||||
@@ -0,0 +1 @@
|
||||
_command_exists oc && source <(oc completion bash)
|
||||
7
dot_bash_it/completion/available/packer.completion.bash
Normal file
7
dot_bash_it/completion/available/packer.completion.bash
Normal file
@@ -0,0 +1,7 @@
|
||||
# shellcheck shell=bash
|
||||
cite "about-completion"
|
||||
about-completion "packer completion"
|
||||
|
||||
if _binary_exists packer; then
|
||||
complete -C packer packer
|
||||
fi
|
||||
6
dot_bash_it/completion/available/pew.completion.bash
Normal file
6
dot_bash_it/completion/available/pew.completion.bash
Normal file
@@ -0,0 +1,6 @@
|
||||
# shellcheck shell=bash
|
||||
|
||||
if _command_exists pew
|
||||
then
|
||||
source "$(pew shell_config)"
|
||||
fi
|
||||
20
dot_bash_it/completion/available/pip.completion.bash
Normal file
20
dot_bash_it/completion/available/pip.completion.bash
Normal file
@@ -0,0 +1,20 @@
|
||||
# shellcheck shell=bash
|
||||
|
||||
# https://pip.pypa.io/en/stable/user_guide/#command-completion
|
||||
# Of course, you should first install pip, say on Debian:
|
||||
# sudo apt-get install python-pip
|
||||
# If the pip package is installed within virtual environments, say, python managed by pyenv,
|
||||
# you should first initialize the corresponding environment.
|
||||
# So that pip is in the system's path.
|
||||
_command_exists pip || return
|
||||
|
||||
function __bash_it_complete_pip() {
|
||||
if _command_exists _pip_completion; then
|
||||
complete -o default -F _pip_completion pip
|
||||
_pip_completion "$@"
|
||||
else
|
||||
eval "$(pip completion --bash)"
|
||||
_pip_completion "$@"
|
||||
fi
|
||||
}
|
||||
complete -o default -F __bash_it_complete_pip pip
|
||||
20
dot_bash_it/completion/available/pip3.completion.bash
Normal file
20
dot_bash_it/completion/available/pip3.completion.bash
Normal file
@@ -0,0 +1,20 @@
|
||||
# shellcheck shell=bash
|
||||
|
||||
# https://pip.pypa.io/en/stable/user_guide/#command-completion
|
||||
# Of course, you should first install pip, say on Debian:
|
||||
# sudo apt-get install python3-pip
|
||||
# If the pip package is installed within virtual environments, say, python managed by pyenv,
|
||||
# you should first initialize the corresponding environment.
|
||||
# So that pip3 is in the system's path.
|
||||
_command_exists pip3 || return
|
||||
|
||||
function __bash_it_complete_pip3() {
|
||||
if _command_exists _pip_completion; then
|
||||
complete -o default -F _pip_completion pip3
|
||||
_pip_completion "$@"
|
||||
else
|
||||
eval "$(pip3 completion --bash)"
|
||||
_pip_completion "$@"
|
||||
fi
|
||||
}
|
||||
complete -o default -F __bash_it_complete_pip3 pip3
|
||||
4
dot_bash_it/completion/available/pipenv.completion.bash
Normal file
4
dot_bash_it/completion/available/pipenv.completion.bash
Normal file
@@ -0,0 +1,4 @@
|
||||
# shellcheck shell=bash
|
||||
if _command_exists pipenv; then
|
||||
eval "$(_PIPENV_COMPLETE=bash_source pipenv)"
|
||||
fi
|
||||
6
dot_bash_it/completion/available/pipx.completion.bash
Normal file
6
dot_bash_it/completion/available/pipx.completion.bash
Normal file
@@ -0,0 +1,6 @@
|
||||
# shellcheck shell=bash
|
||||
# pipx completion
|
||||
|
||||
if _command_exists register-python-argcomplete && _command_exists pipx; then
|
||||
eval "$(register-python-argcomplete pipx)"
|
||||
fi
|
||||
46
dot_bash_it/completion/available/projects.completion.bash
Normal file
46
dot_bash_it/completion/available/projects.completion.bash
Normal file
@@ -0,0 +1,46 @@
|
||||
# Ensure that we log to doctor so the user can address these issues
|
||||
_is_function _init_completion ||
|
||||
_log_error '_init_completion not found. Ensure bash-completion 2.0 or newer is installed and configured properly.'
|
||||
_is_function _rl_enabled ||
|
||||
_log_error '_rl_enabled not found. Ensure bash-completion 2.0 or newer is installed and configured properly.'
|
||||
|
||||
_pj() {
|
||||
_is_function _init_completion || return
|
||||
_is_function _rl_enabled || return
|
||||
[ -n "$PROJECT_PATHS" ] || return
|
||||
shift
|
||||
[ "$1" == "open" ] && shift
|
||||
|
||||
local cur prev words cword
|
||||
_init_completion || return
|
||||
|
||||
local IFS=$'\n' i j k
|
||||
|
||||
compopt -o filenames
|
||||
|
||||
local -r mark_dirs=$(_rl_enabled mark-directories && echo y)
|
||||
local -r mark_symdirs=$(_rl_enabled mark-symlinked-directories && echo y)
|
||||
|
||||
for i in ${PROJECT_PATHS//:/$'\n'}; do
|
||||
# create an array of matched subdirs
|
||||
k="${#COMPREPLY[@]}"
|
||||
for j in $( compgen -d $i/$cur ); do
|
||||
if [[ ( $mark_symdirs && -h $j || $mark_dirs && ! -h $j ) && ! -d ${j#$i/} ]]; then
|
||||
j+="/"
|
||||
fi
|
||||
COMPREPLY[k++]=${j#$i/}
|
||||
done
|
||||
done
|
||||
|
||||
if [[ ${#COMPREPLY[@]} -eq 1 ]]; then
|
||||
i=${COMPREPLY[0]}
|
||||
if [[ "$i" == "$cur" && $i != "*/" ]]; then
|
||||
COMPREPLY[0]="${i}/"
|
||||
fi
|
||||
fi
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
complete -F _pj -o nospace pj
|
||||
complete -F _pj -o nospace pjo
|
||||
17
dot_bash_it/completion/available/rake.completion.bash
Normal file
17
dot_bash_it/completion/available/rake.completion.bash
Normal file
@@ -0,0 +1,17 @@
|
||||
#!/usr/bin/env bash
|
||||
# Bash completion support for Rake, Ruby Make.
|
||||
|
||||
export COMP_WORDBREAKS=${COMP_WORDBREAKS/\:/}
|
||||
|
||||
_rakecomplete() {
|
||||
if [ -f Rakefile ]; then
|
||||
recent=`ls -t .rake_tasks~ Rakefile **/*.rake 2> /dev/null | head -n 1`
|
||||
if [[ $recent != '.rake_tasks~' ]]; then
|
||||
rake --silent --tasks | cut -d " " -f 2 > .rake_tasks~
|
||||
fi
|
||||
COMPREPLY=($(compgen -W "`cat .rake_tasks~`" -- ${COMP_WORDS[COMP_CWORD]}))
|
||||
return 0
|
||||
fi
|
||||
}
|
||||
|
||||
complete -o default -o nospace -F _rakecomplete rake
|
||||
7
dot_bash_it/completion/available/rustup.completion.bash
Normal file
7
dot_bash_it/completion/available/rustup.completion.bash
Normal file
@@ -0,0 +1,7 @@
|
||||
# shellcheck shell=bash
|
||||
|
||||
# rustup (Rust toolchain installer) completion
|
||||
|
||||
if _binary_exists rustup; then
|
||||
eval "$(rustup completions bash)"
|
||||
fi
|
||||
5
dot_bash_it/completion/available/rvm.completion.bash
Normal file
5
dot_bash_it/completion/available/rvm.completion.bash
Normal file
@@ -0,0 +1,5 @@
|
||||
#!/usr/bin/env bash
|
||||
# Bash completion support for RVM.
|
||||
# Source: https://rvm.io/workflow/completion
|
||||
|
||||
[[ -r $rvm_path/scripts/completion ]] && . $rvm_path/scripts/completion
|
||||
343
dot_bash_it/completion/available/salt.completion.bash
Normal file
343
dot_bash_it/completion/available/salt.completion.bash
Normal file
@@ -0,0 +1,343 @@
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
# Copyright (c) 2020 SaltStack Team
|
||||
|
||||
# Original Author:
|
||||
# written by David Pravec
|
||||
# - feel free to /msg alekibango on IRC if you want to talk about this file
|
||||
|
||||
# TODO: check if --config|-c was used and use configured config file for queries
|
||||
# TODO: solve somehow completion for salt -G pythonversion:[tab]
|
||||
# (not sure what to do with lists)
|
||||
# TODO: --range[tab] -- how?
|
||||
# TODO: --compound[tab] -- how?
|
||||
# TODO: use history to extract some words, esp. if ${cur} is empty
|
||||
# TODO: TEST EVERYTHING a lot
|
||||
# TODO: cache results of some functions? where? how long?
|
||||
# TODO: is it ok to use '--timeout 2' ?
|
||||
|
||||
|
||||
_salt_get_grains(){
|
||||
if [ "$1" = 'local' ] ; then
|
||||
salt-call --out=txt -- grains.ls | sed 's/^.*\[//' | tr -d ",']" |sed 's:\([a-z0-9]\) :\1\: :g'
|
||||
else
|
||||
salt '*' --timeout 2 --out=txt -- grains.ls | sed 's/^.*\[//' | tr -d ",']" |sed 's:\([a-z0-9]\) :\1\: :g'
|
||||
fi
|
||||
}
|
||||
|
||||
_salt_get_grain_values(){
|
||||
if [ "$1" = 'local' ] ; then
|
||||
salt-call --out=txt -- grains.item $1 |sed 's/^\S*:\s//' |grep -v '^\s*$'
|
||||
else
|
||||
salt '*' --timeout 2 --out=txt -- grains.item $1 |sed 's/^\S*:\s//' |grep -v '^\s*$'
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
_salt(){
|
||||
local cur prev opts _salt_grains _salt_coms pprev ppprev
|
||||
COMPREPLY=()
|
||||
cur="${COMP_WORDS[COMP_CWORD]}"
|
||||
prev="${COMP_WORDS[COMP_CWORD-1]}"
|
||||
if [ ${COMP_CWORD} -gt 2 ]; then
|
||||
pprev="${COMP_WORDS[COMP_CWORD-2]}"
|
||||
fi
|
||||
if [ ${COMP_CWORD} -gt 3 ]; then
|
||||
ppprev="${COMP_WORDS[COMP_CWORD-3]}"
|
||||
fi
|
||||
|
||||
opts="-h --help -d --doc --documentation --version --versions-report -c \
|
||||
--config-dir= -v --verbose -t --timeout= -s --static -b --batch= \
|
||||
--batch-size= -E --pcre -L --list -G --grain --grain-pcre -N \
|
||||
--nodegroup -R --range -C --compound -I --pillar \
|
||||
--return= -a --auth= --eauth= --extended-auth= -T --make-token -S \
|
||||
--ipcidr --out=pprint --out=yaml --out=overstatestage --out=json \
|
||||
--out=raw --out=highstate --out=key --out=txt --no-color --out-indent= "
|
||||
|
||||
if [[ "${cur}" == -* ]] ; then
|
||||
COMPREPLY=($(compgen -W "${opts}" -- ${cur}))
|
||||
return 0
|
||||
fi
|
||||
|
||||
# 2 special cases for filling up grain values
|
||||
case "${pprev}" in
|
||||
-G|--grain|--grain-pcre)
|
||||
if [ "${cur}" = ":" ]; then
|
||||
COMPREPLY=($(compgen -W "`_salt_get_grain_values ${prev}`" ))
|
||||
return 0
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
case "${ppprev}" in
|
||||
-G|--grain|--grain-pcre)
|
||||
if [ "${prev}" = ":" ]; then
|
||||
COMPREPLY=( $(compgen -W "`_salt_get_grain_values ${pprev}`" -- ${cur}) )
|
||||
return 0
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
|
||||
if [ "${cur}" = "=" ] && [[ "${prev}" == --* ]]; then
|
||||
cur=""
|
||||
fi
|
||||
if [ "${prev}" = "=" ] && [[ "${pprev}" == --* ]]; then
|
||||
prev="${pprev}"
|
||||
fi
|
||||
|
||||
case "${prev}" in
|
||||
|
||||
-c|--config)
|
||||
COMPREPLY=($(compgen -f -- ${cur}))
|
||||
return 0
|
||||
;;
|
||||
salt)
|
||||
COMPREPLY=($(compgen -W "\'*\' ${opts} `salt-key --no-color -l acc`" -- ${cur}))
|
||||
return 0
|
||||
;;
|
||||
-E|--pcre)
|
||||
COMPREPLY=($(compgen -W "`salt-key --no-color -l acc`" -- ${cur}))
|
||||
return 0
|
||||
;;
|
||||
-G|--grain|--grain-pcre)
|
||||
COMPREPLY=($(compgen -W "$(_salt_get_grains)" -- ${cur}))
|
||||
return 0
|
||||
;;
|
||||
-C|--compound)
|
||||
COMPREPLY=() # TODO: finish this one? how?
|
||||
return 0
|
||||
;;
|
||||
-t|--timeout)
|
||||
COMPREPLY=($( compgen -W "1 2 3 4 5 6 7 8 9 10 15 20 30 40 60 90 120 180" -- ${cur}))
|
||||
return 0
|
||||
;;
|
||||
-b|--batch|--batch-size)
|
||||
COMPREPLY=($(compgen -W "1 2 3 4 5 6 7 8 9 10 15 20 30 40 50 60 70 80 90 100 120 150 200"))
|
||||
return 0
|
||||
;;
|
||||
-N|--nodegroup)
|
||||
MASTER_CONFIG='/etc/salt/master'
|
||||
COMPREPLY=($(compgen -W "`awk -F ':' 'BEGIN {print_line = 0}; /^nodegroups/ {print_line = 1;getline } print_line && /^ */ {print $1} /^[^ ]/ {print_line = 0}' <${MASTER_CONFIG}`" -- ${cur}))
|
||||
return 0
|
||||
;;
|
||||
esac
|
||||
|
||||
_salt_coms="$(salt '*' --timeout 2 --out=txt -- sys.list_functions | sed 's/^.*\[//' | tr -d ",']" )"
|
||||
all="${opts} ${_salt_coms}"
|
||||
COMPREPLY=( $(compgen -W "${all}" -- ${cur}) )
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
complete -F _salt salt
|
||||
|
||||
|
||||
_saltkey(){
|
||||
local cur prev opts prev pprev
|
||||
COMPREPLY=()
|
||||
cur="${COMP_WORDS[COMP_CWORD]}"
|
||||
prev="${COMP_WORDS[COMP_CWORD-1]}"
|
||||
opts="-c --config-dir= -h --help --version --versions-report -q --quiet \
|
||||
-y --yes --gen-keys= --gen-keys-dir= --keysize= --key-logfile= \
|
||||
-l --list= -L --list-all -a --accept= -A --accept-all \
|
||||
-r --reject= -R --reject-all -p --print= -P --print-all \
|
||||
-d --delete= -D --delete-all -f --finger= -F --finger-all \
|
||||
--out=pprint --out=yaml --out=overstatestage --out=json --out=raw \
|
||||
--out=highstate --out=key --out=txt --no-color --out-indent= "
|
||||
if [ ${COMP_CWORD} -gt 2 ]; then
|
||||
pprev="${COMP_WORDS[COMP_CWORD-2]}"
|
||||
fi
|
||||
if [ ${COMP_CWORD} -gt 3 ]; then
|
||||
ppprev="${COMP_WORDS[COMP_CWORD-3]}"
|
||||
fi
|
||||
if [[ "${cur}" == -* ]] ; then
|
||||
COMPREPLY=($(compgen -W "${opts}" -- ${cur}))
|
||||
return 0
|
||||
fi
|
||||
|
||||
if [ "${cur}" = "=" ] && [[ "${prev}" == --* ]]; then
|
||||
cur=""
|
||||
fi
|
||||
if [ "${prev}" = "=" ] && [[ "${pprev}" == --* ]]; then
|
||||
prev="${pprev}"
|
||||
fi
|
||||
|
||||
case "${prev}" in
|
||||
-a|--accept)
|
||||
COMPREPLY=($(compgen -W "$(salt-key -l un --no-color; salt-key -l rej --no-color)" -- ${cur}))
|
||||
return 0
|
||||
;;
|
||||
-r|--reject)
|
||||
COMPREPLY=($(compgen -W "$(salt-key -l acc --no-color)" -- ${cur}))
|
||||
return 0
|
||||
;;
|
||||
-d|--delete)
|
||||
COMPREPLY=($(compgen -W "$(salt-key -l acc --no-color; salt-key -l un --no-color; salt-key -l rej --no-color)" -- ${cur}))
|
||||
return 0
|
||||
;;
|
||||
-c|--config)
|
||||
COMPREPLY=($(compgen -f -- ${cur}))
|
||||
return 0
|
||||
;;
|
||||
--keysize)
|
||||
COMPREPLY=($(compgen -W "2048 3072 4096 5120 6144" -- ${cur}))
|
||||
return 0
|
||||
;;
|
||||
--gen-keys)
|
||||
return 0
|
||||
;;
|
||||
--gen-keys-dir)
|
||||
COMPREPLY=($(compgen -d -- ${cur}))
|
||||
return 0
|
||||
;;
|
||||
-p|--print)
|
||||
COMPREPLY=($(compgen -W "$(salt-key -l acc --no-color; salt-key -l un --no-color; salt-key -l rej --no-color)" -- ${cur}))
|
||||
return 0
|
||||
;;
|
||||
-l|--list)
|
||||
COMPREPLY=($(compgen -W "pre un acc accepted unaccepted rej rejected all" -- ${cur}))
|
||||
return 0
|
||||
;;
|
||||
--accept-all)
|
||||
return 0
|
||||
;;
|
||||
esac
|
||||
COMPREPLY=($(compgen -W "${opts} " -- ${cur}))
|
||||
return 0
|
||||
}
|
||||
|
||||
complete -F _saltkey salt-key
|
||||
|
||||
_saltcall(){
|
||||
local cur prev opts _salt_coms pprev ppprev
|
||||
COMPREPLY=()
|
||||
cur="${COMP_WORDS[COMP_CWORD]}"
|
||||
prev="${COMP_WORDS[COMP_CWORD-1]}"
|
||||
opts="-h --help -d --doc --documentation --version --versions-report \
|
||||
-m --module-dirs= -g --grains --return= --local -c --config-dir= -l --log-level= \
|
||||
--out=pprint --out=yaml --out=overstatestage --out=json --out=raw \
|
||||
--out=highstate --out=key --out=txt --no-color --out-indent= "
|
||||
if [ ${COMP_CWORD} -gt 2 ]; then
|
||||
pprev="${COMP_WORDS[COMP_CWORD-2]}"
|
||||
fi
|
||||
if [ ${COMP_CWORD} -gt 3 ]; then
|
||||
ppprev="${COMP_WORDS[COMP_CWORD-3]}"
|
||||
fi
|
||||
if [[ "${cur}" == -* ]] ; then
|
||||
COMPREPLY=($(compgen -W "${opts}" -- ${cur}))
|
||||
return 0
|
||||
fi
|
||||
|
||||
if [ "${cur}" = "=" ] && [[ ${prev} == --* ]]; then
|
||||
cur=""
|
||||
fi
|
||||
if [ "${prev}" = "=" ] && [[ ${pprev} == --* ]]; then
|
||||
prev="${pprev}"
|
||||
fi
|
||||
|
||||
case ${prev} in
|
||||
-m|--module-dirs)
|
||||
COMPREPLY=( $(compgen -d ${cur} ))
|
||||
return 0
|
||||
;;
|
||||
-l|--log-level)
|
||||
COMPREPLY=( $(compgen -W "info none garbage trace warning error debug" -- ${cur}))
|
||||
return 0
|
||||
;;
|
||||
-g|grains)
|
||||
return 0
|
||||
;;
|
||||
salt-call)
|
||||
COMPREPLY=($(compgen -W "${opts}" -- ${cur}))
|
||||
return 0
|
||||
;;
|
||||
esac
|
||||
|
||||
_salt_coms="$(salt-call --out=txt -- sys.list_functions|sed 's/^.*\[//' | tr -d ",']" )"
|
||||
COMPREPLY=( $(compgen -W "${opts} ${_salt_coms}" -- ${cur} ))
|
||||
return 0
|
||||
}
|
||||
|
||||
complete -F _saltcall salt-call
|
||||
|
||||
|
||||
_saltcp(){
|
||||
local cur prev opts target prefpart postpart helper filt pprev ppprev
|
||||
COMPREPLY=()
|
||||
cur="${COMP_WORDS[COMP_CWORD]}"
|
||||
prev="${COMP_WORDS[COMP_CWORD-1]}"
|
||||
opts="-t --timeout= -s --static -b --batch= --batch-size= \
|
||||
-h --help --version --versions-report -c --config-dir= \
|
||||
-E --pcre -L --list -G --grain --grain-pcre -N --nodegroup \
|
||||
-R --range -C --compound -I --pillar \
|
||||
--out=pprint --out=yaml --out=overstatestage --out=json --out=raw \
|
||||
--out=highstate --out=key --out=txt --no-color --out-indent= "
|
||||
if [[ "${cur}" == -* ]] ; then
|
||||
COMPREPLY=($(compgen -W "${opts}" -- ${cur}))
|
||||
return 0
|
||||
fi
|
||||
|
||||
if [ "${cur}" = "=" ] && [[ "${prev}" == --* ]]; then
|
||||
cur=""
|
||||
fi
|
||||
if [ "${prev}" = "=" ] && [[ "${pprev}" == --* ]]; then
|
||||
prev=${pprev}
|
||||
fi
|
||||
|
||||
case ${prev} in
|
||||
salt-cp)
|
||||
COMPREPLY=($(compgen -W "${opts} `salt-key -l acc --no-color`" -- ${cur}))
|
||||
return 0
|
||||
;;
|
||||
-t|--timeout)
|
||||
# those numbers are just a hint
|
||||
COMPREPLY=($(compgen -W "2 3 4 8 10 15 20 25 30 40 60 90 120 180 240 300" -- ${cur} ))
|
||||
return 0
|
||||
;;
|
||||
-E|--pcre)
|
||||
COMPREPLY=($(compgen -W "`salt-key -l acc --no-color`" -- ${cur}))
|
||||
return 0
|
||||
;;
|
||||
-L|--list)
|
||||
# IMPROVEMENTS ARE WELCOME
|
||||
prefpart="${cur%,*},"
|
||||
postpart=${cur##*,}
|
||||
filt="^\($(echo ${cur}| sed 's:,:\\|:g')\)$"
|
||||
helper=($(salt-key -l acc --no-color | grep -v "${filt}" | sed "s/^/${prefpart}/"))
|
||||
COMPREPLY=($(compgen -W "${helper[*]}" -- ${cur}))
|
||||
|
||||
return 0
|
||||
;;
|
||||
-G|--grain|--grain-pcre)
|
||||
COMPREPLY=($(compgen -W "$(_salt_get_grains)" -- ${cur}))
|
||||
return 0
|
||||
;;
|
||||
# FIXME
|
||||
-R|--range)
|
||||
# FIXME ??
|
||||
return 0
|
||||
;;
|
||||
-C|--compound)
|
||||
# FIXME ??
|
||||
return 0
|
||||
;;
|
||||
-c|--config)
|
||||
COMPREPLY=($(compgen -f -- ${cur}))
|
||||
return 0
|
||||
;;
|
||||
esac
|
||||
|
||||
# default is using opts:
|
||||
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
|
||||
}
|
||||
|
||||
complete -F _saltcp salt-cp
|
||||
86
dot_bash_it/completion/available/sdkman.completion.bash
Normal file
86
dot_bash_it/completion/available/sdkman.completion.bash
Normal file
@@ -0,0 +1,86 @@
|
||||
# shellcheck shell=bash
|
||||
|
||||
function _sdkman_complete() {
|
||||
local CANDIDATES
|
||||
local CANDIDATE_VERSIONS
|
||||
local SDKMAN_CANDIDATES_CSV="${SDKMAN_CANDIDATES_CSV:-}"
|
||||
|
||||
COMPREPLY=()
|
||||
|
||||
if [ "$COMP_CWORD" -eq 1 ]; then
|
||||
mapfile -t COMPREPLY < <(compgen -W "install uninstall rm list ls use default home env current upgrade ug version broadcast help offline selfupdate update flush" -- "${COMP_WORDS[COMP_CWORD]}")
|
||||
elif [ "$COMP_CWORD" -eq 2 ]; then
|
||||
case "${COMP_WORDS[COMP_CWORD - 1]}" in
|
||||
"install" | "i" | "uninstall" | "rm" | "list" | "ls" | "use" | "u" | "default" | "d" | "home" | "h" | "current" | "c" | "upgrade" | "ug")
|
||||
CANDIDATES="${SDKMAN_CANDIDATES_CSV//,/${IFS:0:1}}"
|
||||
mapfile -t COMPREPLY < <(compgen -W "$CANDIDATES" -- "${COMP_WORDS[COMP_CWORD]}")
|
||||
;;
|
||||
"env")
|
||||
mapfile -t COMPREPLY < <(compgen -W "init" -- "${COMP_WORDS[COMP_CWORD]}")
|
||||
;;
|
||||
"offline")
|
||||
mapfile -t COMPREPLY < <(compgen -W "enable disable" -- "${COMP_WORDS[COMP_CWORD]}")
|
||||
;;
|
||||
"selfupdate")
|
||||
mapfile -t COMPREPLY < <(compgen -W "force" -- "${COMP_WORDS[COMP_CWORD]}")
|
||||
;;
|
||||
"flush")
|
||||
mapfile -t COMPREPLY < <(compgen -W "archives tmp broadcast version" -- "${COMP_WORDS[COMP_CWORD]}")
|
||||
;;
|
||||
*) ;;
|
||||
|
||||
esac
|
||||
elif [ "$COMP_CWORD" -eq 3 ]; then
|
||||
case "${COMP_WORDS[COMP_CWORD - 2]}" in
|
||||
"uninstall" | "rm" | "use" | "u" | "default" | "d" | "home" | "h")
|
||||
_sdkman_candidate_local_versions "${COMP_WORDS[COMP_CWORD - 1]}"
|
||||
mapfile -t COMPREPLY < <(compgen -W "$CANDIDATE_VERSIONS" -- "${COMP_WORDS[COMP_CWORD]}")
|
||||
;;
|
||||
"install" | "i")
|
||||
_sdkman_candidate_all_versions "${COMP_WORDS[COMP_CWORD - 1]}"
|
||||
mapfile -t COMPREPLY < <(compgen -W "$CANDIDATE_VERSIONS" -- "${COMP_WORDS[COMP_CWORD]}")
|
||||
;;
|
||||
*) ;;
|
||||
|
||||
esac
|
||||
fi
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
function _sdkman_candidate_local_versions() {
|
||||
|
||||
CANDIDATE_VERSIONS=$(__sdkman_cleanup_local_versions "$1")
|
||||
|
||||
}
|
||||
|
||||
function _sdkman_candidate_all_versions() {
|
||||
|
||||
candidate="$1"
|
||||
CANDIDATE_LOCAL_VERSIONS=$(__sdkman_cleanup_local_versions "$candidate")
|
||||
if [[ "${SDKMAN_OFFLINE_MODE:-false}" == "true" ]]; then
|
||||
CANDIDATE_VERSIONS=$CANDIDATE_LOCAL_VERSIONS
|
||||
else
|
||||
# sdkman has a specific output format for Java candidate since
|
||||
# there are multiple vendors and builds.
|
||||
if [ "$candidate" = "java" ]; then
|
||||
CANDIDATE_ONLINE_VERSIONS="$(__sdkman_list_versions "$candidate" | grep " " | grep "\." | cut -c 62-)"
|
||||
else
|
||||
CANDIDATE_ONLINE_VERSIONS="$(__sdkman_list_versions "$candidate" | grep " " | grep "\." | cut -c 6-)"
|
||||
fi
|
||||
# the last grep is used to filter out sdkman flags, such as:
|
||||
# "+" - local version
|
||||
# "*" - installed
|
||||
# ">" - currently in use
|
||||
CANDIDATE_VERSIONS="$(echo "$CANDIDATE_ONLINE_VERSIONS $CANDIDATE_LOCAL_VERSIONS" | tr ' ' '\n' | grep -v -e '^[[:space:]|\*|\>|\+]*$' | sort -u) "
|
||||
fi
|
||||
|
||||
}
|
||||
|
||||
function __sdkman_cleanup_local_versions() {
|
||||
|
||||
__sdkman_build_version_csv "$1" | tr ',' ' '
|
||||
|
||||
}
|
||||
|
||||
complete -F _sdkman_complete sdk
|
||||
168
dot_bash_it/completion/available/sqlmap.completion.bash
Normal file
168
dot_bash_it/completion/available/sqlmap.completion.bash
Normal file
@@ -0,0 +1,168 @@
|
||||
# shellcheck shell=bash
|
||||
|
||||
# ---------------------------------------------------------------------------+
|
||||
# |
|
||||
# Thanks to Alexander Korznikov |
|
||||
# http://www.korznikov.com/2014/12/bash-tab-completion-for-awesome-tool.html |
|
||||
# |
|
||||
# ---------------------------------------------------------------------------+
|
||||
|
||||
if _command_exists sqlmap
|
||||
then
|
||||
|
||||
function _sqlmap()
|
||||
{
|
||||
local cur prev
|
||||
|
||||
COMPREPLY=()
|
||||
cur="$(_get_cword)"
|
||||
prev="$(_get_pword)"
|
||||
|
||||
case $prev in
|
||||
|
||||
# List directory content
|
||||
--tamper)
|
||||
COMPREPLY=( $( compgen -W "$tamper" -- "$cur" ) )
|
||||
return 0
|
||||
;;
|
||||
--output-dir|-t|-l|-m|-r|--load-cookies|--proxy-file|--sql-file|--shared-lib|--file-write)
|
||||
_filedir
|
||||
return 0
|
||||
;;
|
||||
-c)
|
||||
_filedir ini
|
||||
return 0
|
||||
;;
|
||||
--method)
|
||||
COMPREPLY=( $( compgen -W 'GET POST PUT' -- "$cur" ) )
|
||||
return 0
|
||||
;;
|
||||
--auth-type)
|
||||
COMPREPLY=( $( compgen -W 'Basic Digest NTLM PKI' -- "$cur" ) )
|
||||
return 0
|
||||
;;
|
||||
--tor-type)
|
||||
COMPREPLY=( $( compgen -W 'HTTP SOCKS4 SOCKS5' -- "$cur" ) )
|
||||
return 0
|
||||
;;
|
||||
-v)
|
||||
COMPREPLY=( $( compgen -W '1 2 3 4 5 6' -- "$cur" ) )
|
||||
return 0
|
||||
;;
|
||||
--dbms)
|
||||
COMPREPLY=( $( compgen -W 'mysql mssql access postgres' -- "$cur" ) )
|
||||
return 0
|
||||
;;
|
||||
--level|--crawl)
|
||||
COMPREPLY=( $( compgen -W '1 2 3 4 5' -- "$cur" ) )
|
||||
return 0
|
||||
;;
|
||||
--risk)
|
||||
COMPREPLY=( $( compgen -W '0 1 2 3' -- "$cur" ) )
|
||||
return 0
|
||||
;;
|
||||
--technique)
|
||||
COMPREPLY=( $( compgen -W 'B E U S T Q' -- "$cur" ) )
|
||||
return 0
|
||||
;;
|
||||
-s)
|
||||
_filedir sqlite
|
||||
return 0
|
||||
;;
|
||||
--dump-format)
|
||||
COMPREPLY=( $( compgen -W 'CSV HTML SQLITE' -- "$cur" ) )
|
||||
return 0
|
||||
;;
|
||||
-x)
|
||||
_filedir xml
|
||||
return 0
|
||||
;;
|
||||
esac
|
||||
|
||||
if [[ "$cur" == * ]]; then
|
||||
COMPREPLY=( $( compgen -W '-h --help -hh --version -v -d -u --url -l -x -m -r -g -c --method \
|
||||
--data --param-del --cookie --cookie-del --load-cookies \
|
||||
--drop-set-cookie --user-agent --random-agent --host --referer \
|
||||
--headers --auth-type --auth-cred --auth-private --ignore-401 \
|
||||
--proxy --proxy-cred --proxy-file --ignore-proxy --tor --tor-port \
|
||||
--tor-type --check-tor --delay --timeout --retries --randomize \
|
||||
--safe-url --safe-freq --skip-urlencode --csrf-token --csrf-url \
|
||||
--force-ssl --hpp --eval -o --predict-output --keep-alive \
|
||||
--null-connection --threads -p --skip --dbms --dbms-cred \
|
||||
--os --invalid-bignum --invalid-logical --invalid-string \
|
||||
--no-cast --no-escape --prefix --suffix --tamper --level \
|
||||
--risk --string --not-string --regexp --code --text-only \
|
||||
--titles --technique --time-sec --union-cols --union-char \
|
||||
--union-from --dns-domain --second-order -f --fingerprint \
|
||||
-a --all -b --banner --current-user --current-db --hostname \
|
||||
--is-dba --users --passwords --privileges --roles --dbs --tables \
|
||||
--columns --schema --count --dump --dump-all --search --comments \
|
||||
-D -T -C -X -U --exclude-sysdbs --where --start --stop \
|
||||
--first --last --sql-query --sql-shell --sql-file --common-tables \
|
||||
--common-columns --udf-inject --shared-lib --file-read --file-write \
|
||||
--file-dest --os-cmd --os-shell --os-pwn --os-smbrelay --os-bof \
|
||||
--priv-esc --msf-path --tmp-path --reg-read --reg-add --reg-del \
|
||||
--reg-key --reg-value --reg-data --reg-type -s -t --batch \
|
||||
--charset --crawl --csv-del --dump-format --eta --flush-session \
|
||||
--forms --fresh-queries --hex --output-dir --parse-errors \
|
||||
--pivot-column --save --scope --test-filter --update \
|
||||
-z --alert --answers --beep --check-waf --cleanup \
|
||||
--dependencies --disable-coloring --gpage --identify-waf \
|
||||
--mobile --page-rank --purge-output --smart \
|
||||
--sqlmap-shell --wizard' -- "$cur" ) )
|
||||
# this removes any options from the list of completions that have
|
||||
# already been specified somewhere on the command line, as long as
|
||||
# these options can only be used once (in a word, "options", in
|
||||
# opposition to "tests" and "actions", as in the find(1) manpage).
|
||||
onlyonce=' -h --help -hh --version -v -d -u --url -l -x -m -r -g -c \
|
||||
--drop-set-cookie --random-agent \
|
||||
--ignore-401 \
|
||||
--ignore-proxy --tor \
|
||||
--check-tor \
|
||||
--skip-urlencode \
|
||||
--force-ssl --hpp -o --predict-output --keep-alive \
|
||||
--null-connection -p \
|
||||
--invalid-bignum --invalid-logical --invalid-string \
|
||||
--no-cast --no-escape \
|
||||
--text-only \
|
||||
--titles \
|
||||
-f --fingerprint \
|
||||
-a --all -b --banner --current-user --current-db --hostname \
|
||||
--is-dba --users --passwords --privileges --roles --dbs --tables \
|
||||
--columns --schema --count --dump --dump-all --search --comments \
|
||||
-D -T -C -X -U --exclude-sysdbs \
|
||||
--sql-shell --common-tables \
|
||||
--common-columns --udf-inject \
|
||||
--os-shell --os-pwn --os-smbrelay --os-bof \
|
||||
--priv-esc --reg-read --reg-add --reg-del \
|
||||
-s -t --batch \
|
||||
--eta --flush-session \
|
||||
--forms --fresh-queries --hex --parse-errors \
|
||||
--save --update \
|
||||
-z --beep --check-waf --cleanup \
|
||||
--dependencies --disable-coloring --identify-waf \
|
||||
--mobile --page-rank --purge-output --smart \
|
||||
--sqlmap-shell --wizard '
|
||||
COMPREPLY=( $( \
|
||||
(while read -d ' ' i; do
|
||||
[[ -z "$i" || "${onlyonce/ ${i%% *} / }" == "$onlyonce" ]] &&
|
||||
continue
|
||||
# flatten array with spaces on either side,
|
||||
# otherwise we cannot grep on word boundaries of
|
||||
# first and last word
|
||||
COMPREPLY=" ${COMPREPLY[@]} "
|
||||
# remove word from list of completions
|
||||
COMPREPLY=( ${COMPREPLY/ ${i%% *} / } )
|
||||
done
|
||||
printf '%s ' "${COMPREPLY[@]}") <<<"${COMP_WORDS[@]}"
|
||||
) )
|
||||
|
||||
# else
|
||||
# _filedir bat
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
complete -F _sqlmap sqlmap
|
||||
|
||||
fi
|
||||
40
dot_bash_it/completion/available/ssh.completion.bash
Normal file
40
dot_bash_it/completion/available/ssh.completion.bash
Normal file
@@ -0,0 +1,40 @@
|
||||
#!/usr/bin/env bash
|
||||
# Bash completion support for ssh.
|
||||
|
||||
export COMP_WORDBREAKS=${COMP_WORDBREAKS/\:/}
|
||||
|
||||
_sshcomplete() {
|
||||
local CURRENT_PROMPT="${COMP_WORDS[COMP_CWORD]}"
|
||||
if [[ ${CURRENT_PROMPT} == *@* ]] ; then
|
||||
local OPTIONS="-P ${CURRENT_PROMPT/@*/}@ -- ${CURRENT_PROMPT/*@/}"
|
||||
else
|
||||
local OPTIONS=" -- ${CURRENT_PROMPT}"
|
||||
fi
|
||||
|
||||
# parse all defined hosts from .ssh/config and files included there
|
||||
for fl in "$HOME/.ssh/config" \
|
||||
$(grep "^\s*Include" "$HOME/.ssh/config" |
|
||||
awk '{for (i=2; i<=NF; i++) print $i}' |
|
||||
sed -Ee "s|^([^/~])|$HOME/.ssh/\1|" -e "s|^~/|$HOME/|")
|
||||
do
|
||||
if [ -r "$fl" ]; then
|
||||
COMPREPLY=( ${COMPREPLY[@]} $(compgen -W "$(grep -i ^Host "$fl" |grep -v '[*!]' | awk '{for (i=2; i<=NF; i++) print $i}' )" ${OPTIONS}) )
|
||||
fi
|
||||
done
|
||||
|
||||
# parse all hosts found in .ssh/known_hosts
|
||||
if [ -r "$HOME/.ssh/known_hosts" ]; then
|
||||
if grep -v -q -e '^ ssh-rsa' "$HOME/.ssh/known_hosts" ; then
|
||||
COMPREPLY=( ${COMPREPLY[@]} $(compgen -W "$( awk '{print $1}' "$HOME/.ssh/known_hosts" | grep -v ^\| | cut -d, -f 1 | sed -e 's/\[//g' | sed -e 's/\]//g' | cut -d: -f1 | grep -v ssh-rsa)" ${OPTIONS}) )
|
||||
fi
|
||||
fi
|
||||
|
||||
# parse hosts defined in /etc/hosts
|
||||
if [ -r /etc/hosts ]; then
|
||||
COMPREPLY=( ${COMPREPLY[@]} $(compgen -W "$( grep -v '^[[:space:]]*$' /etc/hosts | grep -v '^#' | awk '{for (i=2; i<=NF; i++) print $i}' )" ${OPTIONS}) )
|
||||
fi
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
complete -o default -o nospace -F _sshcomplete ssh scp slogin sftp
|
||||
40
dot_bash_it/completion/available/svn.completion.bash
Normal file
40
dot_bash_it/completion/available/svn.completion.bash
Normal file
@@ -0,0 +1,40 @@
|
||||
# shellcheck shell=bash
|
||||
#
|
||||
# Locate and load completions for `svn`.
|
||||
|
||||
# Make sure svn is installed
|
||||
_command_exists svn || return
|
||||
|
||||
# Don't handle completion if it's already managed
|
||||
if _completion_exists svn; then
|
||||
_log_warning "completion already loaded - this usually means it is safe to stop using this completion"
|
||||
return 0
|
||||
fi
|
||||
|
||||
_svn_bash_completion_xcrun_svn=
|
||||
if _command_exists xcrun; then
|
||||
_svn_bash_completion_xcrun_svn="$(xcrun --find svn)"
|
||||
fi
|
||||
_svn_bash_completion_paths=(
|
||||
# Standard locations
|
||||
"${SVN_EXE%/*}/../etc/bash_completion.d/subversion"
|
||||
# MacOS non-system locations
|
||||
"${_svn_bash_completion_xcrun_svn%/bin/svn}/etc/bash_completion.d/subversion"
|
||||
)
|
||||
|
||||
# Load the first completion file found
|
||||
_svn_bash_completion_found=false
|
||||
for _comp_path in "${_svn_bash_completion_paths[@]}"; do
|
||||
if [[ -r "$_comp_path" ]]; then
|
||||
_svn_bash_completion_found=true
|
||||
# shellcheck disable=SC1090 # don't follow
|
||||
source "$_comp_path"
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
# Cleanup
|
||||
if [[ "${_svn_bash_completion_found}" == false ]]; then
|
||||
_log_warning "no completion files found - please try enabling the 'system' completion instead."
|
||||
fi
|
||||
unset "${!_svn_bash_completion@}"
|
||||
52
dot_bash_it/completion/available/system.completion.bash
Normal file
52
dot_bash_it/completion/available/system.completion.bash
Normal file
@@ -0,0 +1,52 @@
|
||||
# shellcheck shell=bash
|
||||
#
|
||||
# Loads the system's Bash completion modules.
|
||||
# If Homebrew is installed (OS X), it's Bash completion modules are loaded.
|
||||
|
||||
# Load before other completions
|
||||
# BASH_IT_LOAD_PRIORITY: 325
|
||||
|
||||
# Bash-completion is too large and complex to expect to handle unbound variables throughout the whole codebase.
|
||||
if shopt -qo nounset; then
|
||||
__bash_it_restore_nounset=true
|
||||
shopt -uo nounset
|
||||
else
|
||||
__bash_it_restore_nounset=false
|
||||
fi
|
||||
|
||||
# shellcheck disable=SC1090 disable=SC1091
|
||||
if [[ -r "${BASH_COMPLETION:-}" ]]; then
|
||||
source "${BASH_COMPLETION}"
|
||||
elif [[ -r /etc/bash_completion ]]; then
|
||||
source /etc/bash_completion
|
||||
# Some distribution makes use of a profile.d script to import completion.
|
||||
elif [[ -r /etc/profile.d/bash_completion.sh ]]; then
|
||||
source /etc/profile.d/bash_completion.sh
|
||||
elif _bash_it_homebrew_check; then
|
||||
: "${BASH_COMPLETION_COMPAT_DIR:=${BASH_IT_HOMEBREW_PREFIX}/etc/bash_completion.d}"
|
||||
case "${BASH_VERSION}" in
|
||||
1* | 2* | 3.0* | 3.1*)
|
||||
_log_warning "Cannot load completion due to version of shell. Are you using Bash 3.2+?"
|
||||
;;
|
||||
3.2* | 4.0* | 4.1*)
|
||||
# Import version 1.x of bash-completion, if installed.
|
||||
BASH_COMPLETION="${BASH_IT_HOMEBREW_PREFIX}/opt/bash-completion@1/etc/bash_completion"
|
||||
if [[ -r "$BASH_COMPLETION" ]]; then
|
||||
source "$BASH_COMPLETION"
|
||||
else
|
||||
unset BASH_COMPLETION
|
||||
fi
|
||||
;;
|
||||
4.2* | 5* | *)
|
||||
# homebrew/versions/bash-completion2 (required for projects.completion.bash) is installed to this path
|
||||
if [[ -r "${BASH_IT_HOMEBREW_PREFIX}/opt/bash-completion@2/etc/profile.d/bash_completion.sh" ]]; then
|
||||
source "${BASH_IT_HOMEBREW_PREFIX}/opt/bash-completion@2/etc/profile.d/bash_completion.sh"
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
if [[ ${__bash_it_restore_nounset:-false} == "true" ]]; then
|
||||
shopt -so nounset
|
||||
fi
|
||||
unset __bash_it_restore_nounset
|
||||
10
dot_bash_it/completion/available/terraform.completion.bash
Normal file
10
dot_bash_it/completion/available/terraform.completion.bash
Normal file
@@ -0,0 +1,10 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Make sure terraform is installed
|
||||
_command_exists terraform || return
|
||||
|
||||
# Don't handle completion if it's already managed
|
||||
complete -p terraform &>/dev/null && return
|
||||
|
||||
# Terraform completes itself
|
||||
complete -C terraform terraform
|
||||
@@ -0,0 +1,30 @@
|
||||
__kitchen_instance_list () {
|
||||
# cache to .kitchen.list.yml
|
||||
if [[ .kitchen.yml -nt .kitchen.list.yml || .kitchen.local.yml -nt .kitchen.list.yml ]]; then
|
||||
# update list if config has updated
|
||||
kitchen list --bare > .kitchen.list.yml
|
||||
fi
|
||||
cat .kitchen.list.yml
|
||||
}
|
||||
|
||||
__kitchen_options () {
|
||||
cur="${COMP_WORDS[COMP_CWORD]}"
|
||||
prev="${COMP_WORDS[COMP_CWORD-1]}"
|
||||
COMPREPLY=()
|
||||
|
||||
case $prev in
|
||||
converge|create|destroy|diagnose|list|login|setup|test|verify)
|
||||
COMPREPLY=( $(compgen -W "$(__kitchen_instance_list)" -- ${cur} ))
|
||||
return 0
|
||||
;;
|
||||
driver)
|
||||
COMPREPLY=( $(compgen -W "create discover help" -- ${cur} ))
|
||||
return 0
|
||||
;;
|
||||
*)
|
||||
COMPREPLY=( $(compgen -W "console converge create destroy driver help init list login setup test verify version" -- ${cur} ))
|
||||
return 0
|
||||
;;
|
||||
esac
|
||||
}
|
||||
complete -F __kitchen_options kitchen
|
||||
186
dot_bash_it/completion/available/tmux.completion.bash
Normal file
186
dot_bash_it/completion/available/tmux.completion.bash
Normal file
@@ -0,0 +1,186 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# tmux completion
|
||||
# See: http://www.debian-administration.org/articles/317 for how to write more.
|
||||
# Usage: Put "source bash_completion_tmux.sh" into your .bashrc
|
||||
|
||||
_tmux_expand ()
|
||||
{
|
||||
[ "$cur" != "${cur%\\}" ] && cur="$cur"'\';
|
||||
if [[ "$cur" == \~*/* ]]; then
|
||||
eval cur=$cur;
|
||||
else
|
||||
if [[ "$cur" == \~* ]]; then
|
||||
cur=${cur#\~};
|
||||
COMPREPLY=($( compgen -P '~' -u $cur ));
|
||||
return ${#COMPREPLY[@]};
|
||||
fi;
|
||||
fi
|
||||
}
|
||||
|
||||
_tmux_filedir ()
|
||||
{
|
||||
local IFS='
|
||||
';
|
||||
_tmux_expand || return 0;
|
||||
if [ "$1" = -d ]; then
|
||||
COMPREPLY=(${COMPREPLY[@]} $( compgen -d -- $cur ));
|
||||
return 0;
|
||||
fi;
|
||||
COMPREPLY=(${COMPREPLY[@]} $( eval compgen -f -- \"$cur\" ))
|
||||
}
|
||||
|
||||
function _tmux_complete_client() {
|
||||
local IFS=$'\n'
|
||||
local cur="${1}"
|
||||
COMPREPLY=( ${COMPREPLY[@]:-} $(compgen -W "$(tmux -q list-clients 2>/dev/null | cut -f 1 -d ':')" -- "${cur}") )
|
||||
}
|
||||
function _tmux_complete_session() {
|
||||
local IFS=$'\n'
|
||||
local cur="${1}"
|
||||
COMPREPLY=( ${COMPREPLY[@]:-} $(compgen -W "$(tmux -q list-sessions 2>/dev/null | cut -f 1 -d ':')" -- "${cur}") )
|
||||
}
|
||||
function _tmux_complete_window() {
|
||||
local IFS=$'\n'
|
||||
local cur="${1}"
|
||||
local session_name="$(echo "${cur}" | sed 's/\\//g' | cut -d ':' -f 1)"
|
||||
local sessions
|
||||
|
||||
sessions="$(tmux -q list-sessions 2>/dev/null | sed -re 's/([^:]+:).*$/\1/')"
|
||||
if [[ -n "${session_name}" ]]; then
|
||||
sessions="${sessions}
|
||||
$(tmux -q list-windows -t "${session_name}" 2>/dev/null | sed -re 's/^([^:]+):.*$/'"${session_name}"':\1/')"
|
||||
fi
|
||||
cur="$(echo "${cur}" | sed -e 's/:/\\\\:/')"
|
||||
sessions="$(echo "${sessions}" | sed -e 's/:/\\\\:/')"
|
||||
COMPREPLY=( ${COMPREPLY[@]:-} $(compgen -W "${sessions}" -- "${cur}") )
|
||||
}
|
||||
|
||||
_tmux() {
|
||||
local cur prev
|
||||
local i cmd cmd_index option option_index
|
||||
local opts=""
|
||||
COMPREPLY=()
|
||||
cur="${COMP_WORDS[COMP_CWORD]}"
|
||||
prev="${COMP_WORDS[COMP_CWORD-1]}"
|
||||
|
||||
if [ ${prev} == -f ]; then
|
||||
_tmux_filedir
|
||||
else
|
||||
# Search for the command
|
||||
local skip_next=0
|
||||
for ((i=1; $i<=$COMP_CWORD; i++)); do
|
||||
if [[ ${skip_next} -eq 1 ]]; then
|
||||
#echo "Skipping"
|
||||
skip_next=0;
|
||||
elif [[ ${COMP_WORDS[i]} != -* ]]; then
|
||||
cmd="${COMP_WORDS[i]}"
|
||||
cmd_index=${i}
|
||||
break
|
||||
elif [[ ${COMP_WORDS[i]} == -f ]]; then
|
||||
skip_next=1
|
||||
fi
|
||||
done
|
||||
|
||||
# Search for the last option command
|
||||
skip_next=0
|
||||
for ((i=1; $i<=$COMP_CWORD; i++)); do
|
||||
if [[ ${skip_next} -eq 1 ]]; then
|
||||
#echo "Skipping"
|
||||
skip_next=0;
|
||||
elif [[ ${COMP_WORDS[i]} == -* ]]; then
|
||||
option="${COMP_WORDS[i]}"
|
||||
option_index=${i}
|
||||
if [[ ${COMP_WORDS[i]} == -- ]]; then
|
||||
break;
|
||||
fi
|
||||
elif [[ ${COMP_WORDS[i]} == -f ]]; then
|
||||
skip_next=1
|
||||
fi
|
||||
done
|
||||
|
||||
if [[ $COMP_CWORD -le $cmd_index ]]; then
|
||||
# The user has not specified a command yet
|
||||
COMPREPLY=( ${COMPREPLY[@]:-} $(compgen -W "$(tmux start-server \; list-commands | cut -d' ' -f1)" -- "${cur}") )
|
||||
else
|
||||
case ${cmd} in
|
||||
attach-session|attach)
|
||||
case "$prev" in
|
||||
-t) _tmux_complete_session "${cur}" ;;
|
||||
*) options="-t -d" ;;
|
||||
esac ;;
|
||||
detach-client|detach)
|
||||
case "$prev" in
|
||||
-t) _tmux_complete_client "${cur}" ;;
|
||||
*) options="-t" ;;
|
||||
esac ;;
|
||||
lock-client|lockc)
|
||||
case "$prev" in
|
||||
-t) _tmux_complete_client "${cur}" ;;
|
||||
*) options="-t" ;;
|
||||
esac ;;
|
||||
lock-session|locks)
|
||||
case "$prev" in
|
||||
-t) _tmux_complete_session "${cur}" ;;
|
||||
*) options="-t -d" ;;
|
||||
esac ;;
|
||||
new-session|new)
|
||||
case "$prev" in
|
||||
-t) _tmux_complete_session "${cur}" ;;
|
||||
-[n|d|s]) options="-d -n -s -t --" ;;
|
||||
*)
|
||||
if [[ ${COMP_WORDS[option_index]} == -- ]]; then
|
||||
_command_offset ${option_index}
|
||||
else
|
||||
options="-d -n -s -t --"
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
refresh-client|refresh)
|
||||
case "$prev" in
|
||||
-t) _tmux_complete_client "${cur}" ;;
|
||||
*) options="-t" ;;
|
||||
esac ;;
|
||||
rename-session|rename)
|
||||
case "$prev" in
|
||||
-t) _tmux_complete_session "${cur}" ;;
|
||||
*) options="-t" ;;
|
||||
esac ;;
|
||||
source-file|source) _tmux_filedir ;;
|
||||
has-session|has|kill-session)
|
||||
case "$prev" in
|
||||
-t) _tmux_complete_session "${cur}" ;;
|
||||
*) options="-t" ;;
|
||||
esac ;;
|
||||
suspend-client|suspendc)
|
||||
case "$prev" in
|
||||
-t) _tmux_complete_client "${cur}" ;;
|
||||
*) options="-t" ;;
|
||||
esac ;;
|
||||
switch-client|switchc)
|
||||
case "$prev" in
|
||||
-c) _tmux_complete_client "${cur}" ;;
|
||||
-t) _tmux_complete_session "${cur}" ;;
|
||||
*) options="-l -n -p -c -t" ;;
|
||||
esac ;;
|
||||
|
||||
send-keys|send)
|
||||
case "$option" in
|
||||
-t) _tmux_complete_window "${cur}" ;;
|
||||
*) options="-t" ;;
|
||||
esac ;;
|
||||
esac # case ${cmd}
|
||||
fi # command specified
|
||||
fi # not -f
|
||||
|
||||
if [[ -n "${options}" ]]; then
|
||||
COMPREPLY=( ${COMPREPLY[@]:-} $(compgen -W "${options}" -- "${cur}") )
|
||||
fi
|
||||
|
||||
return 0
|
||||
|
||||
}
|
||||
complete -F _tmux tmux
|
||||
|
||||
# END tmux completion
|
||||
2
dot_bash_it/completion/available/todo.completion.bash
Normal file
2
dot_bash_it/completion/available/todo.completion.bash
Normal file
@@ -0,0 +1,2 @@
|
||||
_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.'
|
||||
10
dot_bash_it/completion/available/travis.completion.bash
Normal file
10
dot_bash_it/completion/available/travis.completion.bash
Normal file
@@ -0,0 +1,10 @@
|
||||
# shellcheck shell=bash
|
||||
|
||||
if _command_exists travis
|
||||
then
|
||||
if [[ -s "${__TRAVIS_COMPLETION_SCRIPT:=${TRAVIS_CONFIG_PATH:-${HOME}/.travis}/travis.sh}" ]]
|
||||
then
|
||||
source "${__TRAVIS_COMPLETION_SCRIPT}"
|
||||
fi
|
||||
unset __TRAVIS_COMPLETION_SCRIPT
|
||||
fi
|
||||
163
dot_bash_it/completion/available/vagrant.completion.bash
Normal file
163
dot_bash_it/completion/available/vagrant.completion.bash
Normal file
@@ -0,0 +1,163 @@
|
||||
#!/bin/bash
|
||||
|
||||
# (The MIT License)
|
||||
#
|
||||
# Copyright (c) 2014 Kura
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
# of this software and associated documentation files (the 'Software'), to deal
|
||||
# in the Software without restriction, including without limitation the rights
|
||||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
# copies of the Software, and to permit persons to whom the Software is
|
||||
# furnished to do so, subject to the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be included in all
|
||||
# copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
# SOFTWARE.
|
||||
|
||||
|
||||
__pwdln() {
|
||||
pwdmod="${PWD}/"
|
||||
itr=0
|
||||
until [[ -z "$pwdmod" ]];do
|
||||
itr=$(($itr+1))
|
||||
pwdmod="${pwdmod#*/}"
|
||||
done
|
||||
echo -n $(($itr-1))
|
||||
}
|
||||
|
||||
__vagrantinvestigate() {
|
||||
if [ -f "${PWD}/.vagrant" -o -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
|
||||
echo "${pwdmod2}/.vagrant"
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
fi
|
||||
return 1
|
||||
}
|
||||
|
||||
_vagrant() {
|
||||
cur="${COMP_WORDS[COMP_CWORD]}"
|
||||
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
|
||||
COMPREPLY=($(compgen -W "${commands}" -- ${cur}))
|
||||
return 0
|
||||
fi
|
||||
|
||||
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-/\//')
|
||||
COMPREPLY=($(compgen -W "${box_list}" -- ${cur}))
|
||||
return 0
|
||||
;;
|
||||
"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 {} \;)
|
||||
fi
|
||||
local up_commands="--no-provision"
|
||||
COMPREPLY=($(compgen -W "${up_commands} ${vm_list}" -- ${cur}))
|
||||
return 0
|
||||
;;
|
||||
"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' ' ')
|
||||
else
|
||||
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
|
||||
;;
|
||||
"box")
|
||||
box_commands="add list outdated prune remove repackage update"
|
||||
COMPREPLY=($(compgen -W "${box_commands}" -- ${cur}))
|
||||
return 0
|
||||
;;
|
||||
"plugin")
|
||||
plugin_commands="expunge install license list repair uninstall update"
|
||||
COMPREPLY=($(compgen -W "${plugin_commands}" -- ${cur}))
|
||||
return 0
|
||||
;;
|
||||
"help")
|
||||
COMPREPLY=($(compgen -W "${commands}" -- ${cur}))
|
||||
return 0
|
||||
;;
|
||||
"snapshot")
|
||||
snapshot_commands="delete list pop push restore save"
|
||||
COMPREPLY=($(compgen -W "${snapshot_commands}" -- ${cur}))
|
||||
return 0
|
||||
;;
|
||||
*)
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
if [ $COMP_CWORD == 3 ]
|
||||
then
|
||||
action="${COMP_WORDS[COMP_CWORD-2]}"
|
||||
case "$action" in
|
||||
"up")
|
||||
if [ "$prev" == "--no-provision" ]; then
|
||||
COMPREPLY=($(compgen -W "${vm_list}" -- ${cur}))
|
||||
return 0
|
||||
fi
|
||||
;;
|
||||
"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-/\//')
|
||||
COMPREPLY=($(compgen -W "${box_list}" -- ${cur}))
|
||||
return 0
|
||||
;;
|
||||
*)
|
||||
esac
|
||||
;;
|
||||
"snapshot")
|
||||
if [ "$prev" == "restore" ]; then
|
||||
COMPREPLY=($(compgen -W "${vm_list}" -- ${cur}))
|
||||
return 0
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
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}')"
|
||||
COMPREPLY=($(compgen -W "${snapshot_list}" -- ${cur}))
|
||||
return 0
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
}
|
||||
complete -F _vagrant vagrant
|
||||
7
dot_bash_it/completion/available/vault.completion.bash
Normal file
7
dot_bash_it/completion/available/vault.completion.bash
Normal file
@@ -0,0 +1,7 @@
|
||||
# shellcheck shell=bash
|
||||
cite "about-completion"
|
||||
about-completion "vault completion"
|
||||
|
||||
if _binary_exists vault; then
|
||||
complete -C vault vault
|
||||
fi
|
||||
2
dot_bash_it/completion/available/virsh.completion.bash
Normal file
2
dot_bash_it/completion/available/virsh.completion.bash
Normal file
@@ -0,0 +1,2 @@
|
||||
_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.'
|
||||
222
dot_bash_it/completion/available/virtualbox.completion.bash
Normal file
222
dot_bash_it/completion/available/virtualbox.completion.bash
Normal file
@@ -0,0 +1,222 @@
|
||||
#!/usr/bin/bash
|
||||
_vboxmanage_realopts() {
|
||||
echo $(vboxmanage|grep -i vboxmanage|cut -d' ' -f2|grep '\['|tr -s '[\[\|\]\n' ' ')
|
||||
echo " "
|
||||
}
|
||||
|
||||
__vboxmanage_startvm() {
|
||||
RUNNING=$(vboxmanage list runningvms | cut -d' ' -f1 | tr -d '"')
|
||||
TOTAL=$(vboxmanage list vms | cut -d' ' -f1 | tr -d '"')
|
||||
|
||||
AVAILABLE=""
|
||||
for VM in $TOTAL; do
|
||||
MATCH=0;
|
||||
for RUN in $RUNNING "x"; do
|
||||
if [ "$VM" == "$RUN" ]; then
|
||||
MATCH=1
|
||||
fi
|
||||
done
|
||||
(( $MATCH == 0 )) && AVAILABLE="$AVAILABLE $VM "
|
||||
done
|
||||
echo $AVAILABLE
|
||||
}
|
||||
|
||||
__vboxmanage_list() {
|
||||
INPUT=$(vboxmanage list | tr -s '[\[\]\|\n]' ' ' | cut -d' ' -f4-)
|
||||
|
||||
PRUNED=""
|
||||
if [ "$1" == "long" ]; then
|
||||
for WORD in $INPUT; do
|
||||
[ "$WORD" == "-l" ] && continue;
|
||||
[ "$WORD" == "--long" ] && continue;
|
||||
|
||||
PRUNED="$PRUNED $WORD"
|
||||
done
|
||||
else
|
||||
PRUNED=$INPUT
|
||||
fi
|
||||
|
||||
echo $PRUNED
|
||||
}
|
||||
|
||||
|
||||
__vboxmanage_list_vms() {
|
||||
VMS=""
|
||||
if [ "x$1" == "x" ]; then
|
||||
SEPARATOR=" "
|
||||
else
|
||||
SEPARATOR=$1
|
||||
fi
|
||||
|
||||
for VM in $(vboxmanage list vms | cut -d' ' -f1 | tr -d '"'); do
|
||||
[ "$VMS" != "" ] && VMS="${VMS}${SEPARATOR}"
|
||||
VMS="${VMS}${VM}"
|
||||
done
|
||||
|
||||
echo $VMS
|
||||
}
|
||||
|
||||
__vboxmanage_list_runningvms() {
|
||||
VMS=""
|
||||
if [ "$1" == "" ]; then
|
||||
SEPARATOR=" "
|
||||
else
|
||||
SEPARATOR=$1
|
||||
fi
|
||||
|
||||
for VM in $(vboxmanage list runningvms | cut -d' ' -f1 | tr -d '"'); do
|
||||
[ "$VMS" != "" ] && VMS="${VMS}${SEPARATOR}"
|
||||
VMS="${VMS}${VM}"
|
||||
done
|
||||
|
||||
echo $VMS
|
||||
|
||||
}
|
||||
|
||||
__vboxmanage_controlvm() {
|
||||
echo "pause resume reset poweroff savestate acpipowerbutton"
|
||||
echo "acpisleepbutton keyboardputscancode guestmemoryballoon"
|
||||
echo "gueststatisticsinterval usbattach usbdetach vrde vrdeport"
|
||||
echo "vrdeproperty vrdevideochannelquality setvideomodehint"
|
||||
echo "screenshotpng setcredentials teleport plugcpu unplugcpu"
|
||||
echo "cpuexecutioncap"
|
||||
|
||||
# setlinkstate<1-N>
|
||||
# nic<1-N> null|nat|bridged|intnet|hostonly|generic
|
||||
# [<devicename>] |
|
||||
# nictrace<1-N> on|off
|
||||
# nictracefile<1-N> <filename>
|
||||
# nicproperty<1-N> name=[value]
|
||||
# natpf<1-N> [<rulename>],tcp|udp,[<hostip>],
|
||||
# <hostport>,[<guestip>],<guestport>
|
||||
# natpf<1-N> delete <rulename>
|
||||
|
||||
}
|
||||
|
||||
__vboxmanage_default() {
|
||||
realopts=$(_vboxmanage_realopts)
|
||||
opts=$realopts$(vboxmanage | grep -i vboxmanage | cut -d' ' -f2 | grep -v '\[' | sort | uniq)
|
||||
pruned=""
|
||||
|
||||
# echo ""
|
||||
# echo "DEBUG: cur: $cur, prev: $prev"
|
||||
# echo "DEBUG: default: |$p1|$p2|$p3|$p4|"
|
||||
case ${cur} in
|
||||
-*)
|
||||
echo $opts
|
||||
# COMPREPLY=($(compgen -W "${opts}" -- ${cur}))
|
||||
return 0
|
||||
;;
|
||||
esac;
|
||||
|
||||
for WORD in $opts; do
|
||||
MATCH=0
|
||||
for OPT in "${COMP_WORDS[@]}"; do
|
||||
# opts=$(echo ${opts} | grep -v $OPT);
|
||||
if [ "$OPT" == "$WORD" ]; then
|
||||
MATCH=1
|
||||
break;
|
||||
fi
|
||||
if [ "$OPT" == "-v" ] && [ "$WORD" == "--version" ]; then
|
||||
MATCH=1
|
||||
break;
|
||||
fi
|
||||
if [ "$OPT" == "--version" ] && [ "$WORD" == "-v" ]; then
|
||||
MATCH=1
|
||||
break;
|
||||
fi
|
||||
if [ "$OPT" == "-q" ] && [ "$WORD" == "--nologo" ]; then
|
||||
MATCH=1
|
||||
break;
|
||||
fi
|
||||
if [ "$OPT" == "--nologo" ] && [ "$WORD" == "-q" ]; then
|
||||
MATCH=1
|
||||
break;
|
||||
fi
|
||||
done
|
||||
(( $MATCH == 1 )) && continue;
|
||||
pruned="$pruned $WORD"
|
||||
|
||||
done
|
||||
|
||||
# COMPREPLY=($(compgen -W "${pruned}" -- ${cur}))
|
||||
echo $pruned
|
||||
return 0
|
||||
}
|
||||
|
||||
_vboxmanage() {
|
||||
# vboxmanage | grep -i vboxmanage | cut -d' ' -f2 | sort | uniq
|
||||
local cur p1 p2 p3 p4 opts
|
||||
COMPREPLY=()
|
||||
cur="${COMP_WORDS[COMP_CWORD]}"
|
||||
prev="${COMP_WORDS[COMP_CWORD-1]}"
|
||||
|
||||
# echo "cur: |$cur|"
|
||||
# echo "prev: |$prev|"
|
||||
|
||||
# In case current is complete command
|
||||
case $cur in
|
||||
startvm|list|controlvm)
|
||||
COMPREPLY=($(compgen -W "$cur "))
|
||||
return 0
|
||||
;;
|
||||
esac
|
||||
|
||||
case $prev in
|
||||
-v|--version)
|
||||
return 0
|
||||
;;
|
||||
|
||||
-l|--long)
|
||||
opts=$(__vboxmanage_list "long")
|
||||
COMPREPLY=($(compgen -W "${opts}" -- ${cur}))
|
||||
return 0
|
||||
;;
|
||||
startvm|list)
|
||||
opts=$(__vboxmanage_$prev)
|
||||
COMPREPLY=($(compgen -W "${opts}" -- ${cur}))
|
||||
return 0
|
||||
;;
|
||||
--type)
|
||||
COMPREPLY=($(compgen -W "gui headless" -- ${cur}))
|
||||
return 0
|
||||
;;
|
||||
gui|headless)
|
||||
# Done. no more completion possible
|
||||
return 0
|
||||
;;
|
||||
vboxmanage|-q|--nologo)
|
||||
# echo "Got vboxmanage"
|
||||
opts=$(__vboxmanage_default)
|
||||
COMPREPLY=($(compgen -W "${opts}" -- ${cur}))
|
||||
return 0
|
||||
;;
|
||||
controlvm)
|
||||
opts=$(__vboxmanage_list_vms)
|
||||
COMPREPLY=($(compgen -W "${opts}" -- ${cur}))
|
||||
return 0
|
||||
;;
|
||||
esac
|
||||
|
||||
for VM in $(__vboxmanage_list_vms); do
|
||||
if [ "$VM" == "$prev" ]; then
|
||||
pprev=${COMP_WORDS[COMP_CWORD-2]}
|
||||
# echo "previous: $pprev"
|
||||
case $pprev in
|
||||
startvm)
|
||||
opts="--type"
|
||||
COMPREPLY=($(compgen -W "${opts}" -- ${cur}))
|
||||
return 0
|
||||
;;
|
||||
controlvm)
|
||||
opts=$(__vboxmanage_controlvm)
|
||||
COMPREPLY=($(compgen -W "${opts}" -- ${cur}))
|
||||
return 0;
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
done
|
||||
|
||||
# echo "Got to end withoug completion"
|
||||
}
|
||||
complete -F _vboxmanage vboxmanage
|
||||
61
dot_bash_it/completion/available/vuejs.completion.bash
Normal file
61
dot_bash_it/completion/available/vuejs.completion.bash
Normal file
@@ -0,0 +1,61 @@
|
||||
# shellcheck shell=bash
|
||||
|
||||
__vuejs_completion() {
|
||||
# shellcheck disable=SC2155
|
||||
local prev=$(_get_pword)
|
||||
# shellcheck disable=SC2155
|
||||
local curr=$(_get_cword)
|
||||
|
||||
case $prev in
|
||||
create)
|
||||
# shellcheck disable=SC2207
|
||||
COMPREPLY=($(compgen -W "-p -d -i -m -r -g -n -f -c -x -b -h --help --preset --default --inilinePreset --packageManager --registry --git --no-git --force --merge --clone --proxy --bare --skipGetStarted" -- "$curr"))
|
||||
;;
|
||||
add | invoke)
|
||||
# shellcheck disable=SC2207
|
||||
COMPREPLY=($(compgen -W "--registry -h --help" -- "$curr"))
|
||||
;;
|
||||
inspect)
|
||||
# shellcheck disable=SC2207
|
||||
COMPREPLY=($(compgen -W "-v --help --verbose --mode --rule --plugin --plugins --rules" -- "$curr"))
|
||||
;;
|
||||
serve)
|
||||
# shellcheck disable=SC2207
|
||||
COMPREPLY=($(compgen -W "-o -h --help --open -c --copy -p --port" -- "$curr"))
|
||||
;;
|
||||
build)
|
||||
# shellcheck disable=SC2207
|
||||
COMPREPLY=($(compgen -W "-t --target -n --name -d --dest -h --help" -- "$curr"))
|
||||
;;
|
||||
ui)
|
||||
# shellcheck disable=SC2207
|
||||
COMPREPLY=($(compgen -W "-H --host -p --port -D --dev --quiet --headless -h --help" -- "$curr"))
|
||||
;;
|
||||
init)
|
||||
# shellcheck disable=SC2207
|
||||
COMPREPLY=($(compgen -W "-c --clone --offline -h --help" -- "$curr"))
|
||||
;;
|
||||
config)
|
||||
# shellcheck disable=SC2207
|
||||
COMPREPLY=($(compgen -W "-g --get -s --set -d --delete -e --edit --json -h --help" -- "$curr"))
|
||||
;;
|
||||
outdated)
|
||||
# shellcheck disable=SC2207
|
||||
COMPREPLY=($(compgen -W "--next -h --help" -- "$curr"))
|
||||
;;
|
||||
upgrade)
|
||||
# shellcheck disable=SC2207
|
||||
COMPREPLY=($(compgen -W "-t --to -f --from -r --registry --all --next -h --help" -- "$curr"))
|
||||
;;
|
||||
migrate)
|
||||
# shellcheck disable=SC2207
|
||||
COMPREPLY=($(compgen -W "-f --from -h --help" -- "$curr"))
|
||||
;;
|
||||
*)
|
||||
# shellcheck disable=SC2207
|
||||
COMPREPLY=($(compgen -W "-h --help -v --version create add invoke inspect serve build ui init config outdated upgrade migrate info" -- "$curr"))
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
complete -F __vuejs_completion vue
|
||||
16
dot_bash_it/completion/available/wpscan.completion.bash
Normal file
16
dot_bash_it/completion/available/wpscan.completion.bash
Normal file
@@ -0,0 +1,16 @@
|
||||
# shellcheck shell=bash
|
||||
|
||||
_command_exists wpscan || return
|
||||
|
||||
function __wpscan_completion() {
|
||||
local _opt_
|
||||
local OPTS=('--help' '--hh' '--version' '--url' '--ignore-main-redirect' '--verbose' '--output' '--format' '--detection-mode' '--scope' '--headers' '--user-agent' '--vhost' '--random-user-agent' '--user-agents-list' '--http-auth' '--max-threads' '--throttle' '--request-timeout' '--connect-timeout' '--disable-tlc-checks' '--proxy' '--proxy-auth' '--cookie-string' '--cookie-jar' '--cache-ttl' '--clear-cache' '--server' '--cache-dir' '--update' '--no-update' '--wp-content-dir' '--wp-plugins-dir' '--wp-version-detection' '--main-theme-detection' '--enumerate' '--exclude-content-based' '--plugins-list' '--plugins-detection' '--plugins-version-all' '--plugins-version-detection' '--themes-list' '--themes-detection' '--themes-version-all' '--themes-version-detection' '--timthumbs-list' '--timthumbs-detection' '--config-backups-list' '--config-backups-detection' '--db-exports-list' '--db-exports-detection' '--medias-detection' '--users-list' '--users-detection' '--passwords' '--usernames' '--multicall-max-passwords' '--password-attack' '--stealthy')
|
||||
COMPREPLY=()
|
||||
for _opt_ in "${OPTS[@]}"; do
|
||||
if [[ "$_opt_" == "$2"* ]]; then
|
||||
COMPREPLY+=("$_opt_")
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
complete -F __wpscan_completion wpscan
|
||||
Reference in New Issue
Block a user