update stack trace 2

pull/2211/head
Doraken 2023-08-02 13:05:59 +02:00
parent 2ff8e6c5a1
commit d6327c46f2
237 changed files with 10838 additions and 2306 deletions

View File

@ -8,7 +8,12 @@ about-plugin 'Automatic completion of aliases'
# 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() {
function _bash-it-component-completion-callback-on-init-aliases()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
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
@ -27,7 +32,8 @@ function _bash-it-component-completion-callback-on-init-aliases() {
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
if [[ "${completion_loader#complete }" =~ '-F'[[:space:]]([[:alnum:]_]+)[[:space:]] ]]
then
completion_loader="${BASH_REMATCH[1]}"
else
completion_loader=""
@ -43,40 +49,46 @@ function _bash-it-component-completion-callback-on-init-aliases() {
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
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
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
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
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
if [[ "${compl_func#_"$namespace"::}" == "$compl_func" ]]
then
compl_wrapper="_${namespace}::${alias_name}"
echo "function $compl_wrapper {
local compl_word=\${2?}
@ -84,8 +96,9 @@ function _bash-it-component-completion-callback-on-init-aliases() {
# 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'
if [[ \$COMP{_LINE == \"\${prec_word} \${compl_word}\" ]]
then
prec_word='${alias_cmd} $alias_args'
prec_word=\${prec_word#* }
fi
(( COMP_CWORD += ${#alias_arg_words[@]} ))
@ -95,18 +108,23 @@ function _bash-it-component-completion-callback-on-init-aliases() {
(( COMP_POINT += \${#COMP_LINE} ))
\"$compl_func\" \"$alias_cmd\" \"\$compl_word\" \"\$prec_word\"
}" >> "$tmp_file"
new_completion="${new_completion/ -F $compl_func / -F $compl_wrapper }"
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"
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"
source "${tmp_file}" && command rm -f "${tmp_file}"
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
_bash-it-component-completion-callback-on-init-aliases

View File

@ -1,4 +1,4 @@
# shellcheck shell=bash
about-completion "apm completion"
# shellcheck disable=SC1090
source "${BASH_IT}"/vendor/github.com/vigo/apm-bash-completion/apm
source "${BASH_IT}/vendor/github.com/vigo/apm-bash-completion/apm"

View File

@ -1,5 +1,6 @@
# shellcheck shell=bash
if _command_exists awless; then
if _command_exists awless
then
# shellcheck disable=SC1090
source <(awless completion bash)
fi

View File

@ -1,5 +1,6 @@
# shellcheck shell=bash
if _command_exists aws_completer; then
if _command_exists aws_completer
then
complete -C "$(command -v aws_completer)" aws
fi

View File

@ -1,12 +1,28 @@
# shellcheck shell=bash
function _compreply_candidates() {
function _compreply_candidates()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
local IFS=$'\n'
read -d '' -ra COMPREPLY < <(compgen -W "${candidates[*]}" -- "${cur}")
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
function _bash-it() {
function _bash-it()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
local cur prev verb file_type candidates suffix
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
@ -20,7 +36,8 @@ function _bash-it() {
_compreply_candidates
;;
help)
if [[ "${prev}" == "aliases" ]]; then
if [[ "${prev}" == "aliases" ]]
then
candidates=('all' "$(_bash-it-component-list "${file_type}")")
_compreply_candidates
else
@ -31,7 +48,8 @@ function _bash-it() {
profile)
case "${file_type}" in
load | rm)
if [[ "${file_type}" == "$prev" ]]; then
if [[ "${file_type}" == "$prev" ]]
then
candidates=("${BASH_IT}/profiles"/*.bash_it)
candidates=("${candidates[@]##*/}")
candidates=("${candidates[@]%%.bash_it}")
@ -51,7 +69,8 @@ function _bash-it() {
_compreply_candidates
;;
update)
if [[ "${cur}" == -* ]]; then
if [[ "${cur}" == -* ]]
then
candidates=('-s' '--silent')
else
candidates=('stable' 'dev')
@ -64,7 +83,8 @@ function _bash-it() {
return 0
;;
enable | disable)
if [[ "${verb}" == "enable" ]]; then
if [[ "${verb}" == "enable" ]]
then
suffix="disabled"
else
suffix="enabled"
@ -84,6 +104,10 @@ function _bash-it() {
_compreply_candidates
;;
esac
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
# Activate completion for bash-it and its common misspellings

View File

@ -5,7 +5,8 @@ about-completion "brew completion"
# Load late to make sure `system` completion loads first
# BASH_IT_LOAD_PRIORITY: 375
if [[ "$OSTYPE" != 'darwin'* ]]; then
if [[ "${OSTYPE}" != 'darwin'* ]];
then
_log_warning "unsupported operating system - only 'Darwin' is supported"
return 0
fi
@ -13,18 +14,21 @@ fi
# Make sure brew is installed
_bash_it_homebrew_check || return 0
if [[ -r "$BASH_IT_HOMEBREW_PREFIX/etc/bash_completion.d/brew" ]]; then
if [[ -r "${BASH_IT_HOMEBREW_PREFIX}/etc/bash_completion.d/brew" ]]
then
# shellcheck disable=1090,1091
source "$BASH_IT_HOMEBREW_PREFIX/etc/bash_completion.d/brew"
source "${BASH_IT_HOMEBREW_PREFIX}/etc/bash_completion.d/brew"
elif [[ -r "$BASH_IT_HOMEBREW_PREFIX/Library/Contributions/brew_bash_completion.sh" ]]; then
elif [[ -r "${BASH_IT_HOMEBREW_PREFIX}/Library/Contributions/brew_bash_completion.sh" ]]
then
# shellcheck disable=1090,1091
source "$BASH_IT_HOMEBREW_PREFIX/Library/Contributions/brew_bash_completion.sh"
source "${BASH_IT_HOMEBREW_PREFIX}/Library/Contributions/brew_bash_completion.sh"
elif [[ -f "$BASH_IT_HOMEBREW_PREFIX/completions/bash/brew" ]]; then
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,1091
source "$BASH_IT_HOMEBREW_PREFIX/completions/bash/brew"
source "${BASH_IT_HOMEBREW_PREFIX}/completions/bash/brew"
fi

View File

@ -27,8 +27,13 @@
# To use, source this file on bash:
# . completion-bundle
__bundle() {
local bundle_bin=("${_RUBY_COMMAND_PREFIX[@]}" "$1")
function __bundle()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
local bundle_bin=("${_RUBY_COMMAND_PREFIX[@]}" "${1}")
local cur prev
_get_comp_words_by_ref -n : cur prev
local bundle_command
@ -37,45 +42,46 @@ __bundle() {
COMPREPLY=()
local options
if [[ $cur = -* && $bundle_command != exec ]]; then
if [[ $cur = -* && $bundle_command != exec ]]
then
options="-V --help --no-color --no-no-color --verbose --no-verbose"
case $bundle_command in
"")
options="$options --version";;
options="${options} --version";;
check)
options="$options --dry-run --gemfile --path -r --retry";;
options="${options} --dry-run --gemfile --path -r --retry";;
clean)
options="$options --dry-run --force";;
options="${options} --dry-run --force";;
config)
options="$options --local --global --delete";;
options="${options} --local --global --delete";;
doctor)
options="$options --gemfile --quiet --no-quiet";;
options="${options} --gemfile --quiet --no-quiet";;
gem)
options="$options -b -e -t --bin --coc --no-coc --edit --exe
options="${options} -b -e -t --bin --coc --no-coc --edit --exe
--no-exe --ext --no-ext --mit --no-mit --test";;
init)
options="$options --gemspec";;
options="${options} --gemspec";;
install)
options="$options --binstubs --clean --deployment --force --frozen
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
options="${options} --add-platform --conservative --full-index
--local --lockfile --major --minor --patch --print
--remove-platform --strict --update";;
package)
options="$options --all --all-platforms";;
options="${options} --all --all-platforms";;
platform)
options="$options --ruby";;
options="${options} --ruby";;
show)
options="$options --outdated --paths --no-paths";;
update)
options="$options --bundler --conservative --force --full-index
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
options="${options} -f -F -R -v -W --file --format --requirements
--no-requirements --version --no-version --without";;
esac
else
@ -86,7 +92,7 @@ __bundle() {
platform clean doctor"
;;
check | install)
case $prev in
case ${prev} in
--binstubs | --path)
_filedir -d
return;;
@ -99,7 +105,7 @@ __bundle() {
esac
;;
config)
case $prev in
case ${prev} in
config | --*)
case $cur in
local.*)
@ -140,13 +146,15 @@ __bundle() {
esac
;;
exec)
if [[ $COMP_CWORD -eq $bundle_command_index ]]; then
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 [[ -d ${bundler_bin} ]]
then
local binaries=("${bundler_bin}"/*)
# If there are binaries, strip directory name and use them
[[ -f "$binaries" ]] && options="${binaries[@]##*/}"
[[ -f "${binaries}" ]] && options="${binaries[@]##*/}"
else
# No binaries found; use full command completion
COMPREPLY=($(compgen -c -- "$cur"))
@ -168,7 +176,7 @@ __bundle() {
esac
;;
update)
case $prev in
case ${prev} in
--group)
__bundle_complete_groups
return;;
@ -177,7 +185,7 @@ __bundle() {
esac
;;
viz)
case $prev in
case ${prev} in
-F | --format)
options="dot jpg png svg";;
-W | --without)
@ -188,16 +196,26 @@ __bundle() {
esac
fi
COMPREPLY=($(compgen -W "${options[*]}" -- "$cur"))
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
__bundle_get_command() {
function __bundle_get_command()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
local i
for ((i=1; i < $COMP_CWORD; ++i)); do
for ((i=1; i < $COMP_CWORD; ++i))
do
local arg=${COMP_WORDS[$i]}
case $arg in
case ${arg} in
[^-]*)
bundle_command=$arg
bundle_command=${arg}
bundle_command_index=$((i + 1))
return;;
--version)
@ -210,19 +228,29 @@ __bundle_get_command() {
return;;
esac
done
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
# 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() {
function __bundle_complete_groups()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
# 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
if [[ ! ${groups} ]]
then
COMPREPLY=()
return
fi
@ -230,42 +258,56 @@ __bundle_complete_groups() {
# 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"))
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"
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
# __bundle_exec_ruby <script> [args...]
#
# Runs a Ruby script with Bundler loaded.
# Results may be cached.
__bundle_exec_ruby() {
function __bundle_exec_ruby()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
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 lockfile=${PWD}/Gemfile.lock
local cachedir=${XDG_CACHE_HOME:-~/.cache}/completion-ruby
local cachefile=$cachedir/bundle--exec-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"
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"
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
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}

View File

@ -3,12 +3,20 @@
export COMP_WORDBREAKS=${COMP_WORDBREAKS/\:/}
_capcomplete() {
if [ -f Capfile ]; then
function _capcomplete()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
if [ -f Capfile ]
then
recent=`ls -t .cap_tasks~ Capfile **/*.cap 2> /dev/null | head -n 1`
if [[ $recent != '.cap_tasks~' ]]; then
if [[ ${recent} != '.cap_tasks~' ]]
then
cap --version | grep 'Capistrano v2.' > /dev/null
if [ $? -eq 0 ]; then
if [ $? -eq 0 ]
then
# Capistrano 2.x
cap --tool --verbose --tasks | cut -d " " -f 2 > .cap_tasks~
else
@ -19,6 +27,10 @@ _capcomplete() {
COMPREPLY=($(compgen -W "`cat .cap_tasks~`" -- ${COMP_WORDS[COMP_CWORD]}))
return 0
fi
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
complete -o default -o nospace -F _capcomplete cap

View File

@ -1,6 +1,7 @@
# shellcheck shell=bash
# cargo (Rust package manager) completion
if _binary_exists rustup && _binary_exists cargo; then
if _binary_exists rustup && _binary_exists cargo
then
eval "$(rustup completions bash cargo)"
fi

View File

@ -2,21 +2,29 @@
cite "about-completion"
about-completion "composer completion"
function __composer_completion() {
function __composer_completion()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
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
if [[ "${word}" != -* ]]
then
com="${word}"
break
fi
done
# completing for an option
if [[ ${cur} == --* ]]; then
if [[ ${cur} == --* ]]
then
opts="--help --quiet --verbose --version --ansi --no-ansi --no-interaction --profile --no-plugins --working-dir"
case "${com}" in
@ -115,7 +123,8 @@ function __composer_completion() {
fi
# completing for a command
if [[ "${cur}" == "${com}" ]]; then
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
@ -124,6 +133,10 @@ function __composer_completion() {
return 0
fi
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
complete -o default -F __composer_completion composer

View File

@ -2,8 +2,10 @@
cite "about-completion"
about-completion "conda completion"
if _command_exists conda; then
if _command_exists register-python-argcomplete; then
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'"

View File

@ -2,6 +2,7 @@
cite "about-completion"
about-completion "Hashicorp consul completion"
if _command_exists consul; then
if _command_exists consul
then
complete -C "$(command -v consul)" consul
fi

View File

@ -1,6 +1,11 @@
# shellcheck shell=bash
__dart_completion() {
function __dart_completion()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
# shellcheck disable=SC2155
local prev=$(_get_pword)
# shellcheck disable=SC2155
@ -9,7 +14,7 @@ __dart_completion() {
local HELP="--help -h"
local VERBOSE="-v --verbose"
case $prev in
case ${prev} in
analyze)
# shellcheck disable=SC2207
COMPREPLY=($(compgen -W "$HELP --fatal-infos --no-fatal-warnings --fatal-warnings" -- "$curr"))
@ -43,6 +48,10 @@ __dart_completion() {
COMPREPLY=($(compgen -W "$HELP $VERBOSE --version --enable-analytics --disable-analytics help analyze compile create format pub run test" -- "$curr"))
;;
esac
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
complete -F __dart_completion dart

View File

@ -1,5 +1,6 @@
# shellcheck shell=bash
if test -s "${BASH_IT?}/vendor/github.com/gaelicWizard/bash-progcomp/defaults.completion.bash"; then
if test -s "${BASH_IT}/vendor/github.com/gaelicWizard/bash-progcomp/defaults.completion.bash"
then
source "$_"
fi

View File

@ -1,15 +1,25 @@
#!/usr/bin/env bash
# Bash completion support for the 'dirs' plugin (commands G, R).
_dirs-complete() {
function _dirs-complete()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
local CURRENT_PROMPT="${COMP_WORDS[COMP_CWORD]}"
# parse all defined shortcuts from ~/.dirs
if [ -r "$HOME/.dirs" ]; then
if [ -r "${HOME}/.dirs" ]
then
COMPREPLY=($(compgen -W "$(grep -v '^#' ~/.dirs | sed -e 's/\(.*\)=.*/\1/')" -- ${CURRENT_PROMPT}) )
fi
return 0
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
complete -o default -o nospace -F _dirs-complete G R

View File

@ -1,6 +1,11 @@
# shellcheck shell=bash
function __dmidecode_completion() {
function __dmidecode_completion()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
# shellcheck disable=SC2155
local prev=$(_get_pword)
# shellcheck disable=SC2155
@ -17,6 +22,10 @@ function __dmidecode_completion() {
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
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
complete -F __dmidecode_completion dmidecode

File diff suppressed because it is too large Load Diff

View File

@ -16,9 +16,10 @@ _docker_bash_completion_paths=(
)
for fn in "${_docker_bash_completion_paths[@]}"; do
if [ -r "$fn" ]; then
if [ -r "${fn}" ]
then
# shellcheck disable=SC1090
source "$fn"
source "${fn}"
break
fi
done

View File

@ -2,13 +2,23 @@
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() {
function _dotnet_bash_complete()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
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")
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
complete -f -F _dotnet_bash_complete dotnet

View File

@ -41,7 +41,7 @@ export FAB_COMPLETION_CACHED_TASKS_FILENAME=".fab_tasks~"
# Set command to get time of last file modification as seconds since Epoch
case "$OSTYPE" in
case "${OSTYPE}" in
'darwin'*|'freebsd'*)
__FAB_COMPLETION_MTIME_COMMAND="stat -f '%m'"
;;
@ -54,31 +54,58 @@ esac
#
# Get time of last fab cache file modification as seconds since Epoch
#
function __fab_chache_mtime() {
function __fab_chache_mtime()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
${__FAB_COMPLETION_MTIME_COMMAND} \
$FAB_COMPLETION_CACHED_TASKS_FILENAME | xargs -n 1 expr
${FAB_COMPLETION_CACHED_TASKS_FILENAME} | xargs -n 1 expr
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
#
# Get time of last fabfile file/module modification as seconds since Epoch
#
function __fab_fabfile_mtime() {
function __fab_fabfile_mtime()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
local f="fabfile"
if [[ -e "$f.py" ]]; then
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} {} + \
find ${f}/*.py -exec ${__FAB_COMPLETION_MTIME_COMMAND} {} + \
| xargs -n 1 expr | sort -n -r | head -1
fi
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
#
# Completion for "fab" command
#
function __fab_completion() {
function __fab_completion()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
# Return if "fab" command doesn't exists
[[ -e `which fab 2> /dev/null` ]] || return 0
@ -89,7 +116,8 @@ function __fab_completion() {
# Generate possible matches and store them in variable "opts"
case "${cur}" in
-*)
if [[ -z "${__FAB_COMPLETION_LONG_OPT}" ]]; then
if [[ -z "${__FAB_COMPLETION_LONG_OPT}" ]]
then
export __FAB_COMPLETION_LONG_OPT=$(
fab --help | grep -E -o "\-\-[A-Za-z_\-]+\=?" | sort -u)
fi
@ -99,7 +127,8 @@ function __fab_completion() {
# Completion for short options is not nessary.
# It's left here just for history.
# -*)
# if [[ -z "${__FAB_COMPLETION_SHORT_OPT}" ]]; then
# if [[ -z "${__FAB_COMPLETION_SHORT_OPT}" ]]
#then
# export __FAB_COMPLETION_SHORT_OPT=$(
# fab --help | grep -E -o "^ +\-[A-Za-z_\]" | sort -u)
# fi
@ -109,19 +138,22 @@ function __fab_completion() {
*)
# 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
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 ${FAB_COMPLETION_CACHE_TASKS}
then
# If use cache
if [[ ! -s ${FAB_COMPLETION_CACHED_TASKS_FILENAME} ||
$(__fab_fabfile_mtime) -gt $(__fab_chache_mtime) ]]; then
$(__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})
opts="$(cat ${FAB_COMPLETION_CACHED_TASKS_FILENAME})"
else
# Without cache
opts=$(fab --shortlist 2> /dev/null)
opts="$(fab --shortlist 2> /dev/null)"
fi
fi
;;
@ -129,5 +161,9 @@ function __fab_completion() {
# Set possible completions
COMPREPLY=($(compgen -W "${opts}" -- ${cur}))
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
complete -o default -o nospace -F __fab_completion fab

View File

@ -1,5 +1,6 @@
# shellcheck shell=bash
if _command_exists flutter; then
if _command_exists flutter
then
eval "$(flutter bash-completion)"
fi

View File

@ -2,13 +2,14 @@
cite "about-completion"
about-completion "Google Cloud SDK completion"
if _command_exists gcloud; then
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"
source "${i}"
done
fi

View File

@ -2,13 +2,19 @@
cite "about-completion"
about-completion "gem completion"
__gem_completion() {
function __gem_completion()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
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
if [ -z "${REMOTE_GEMS}" ]
then
read -r -a REMOTE_GEMS <<< "$(gem list --remote --no-versions | sed 's/\*\*\* REMOTE GEMS \*\*\*//' | tr '\n' ' ')"
fi
@ -23,13 +29,17 @@ __gem_completion() {
local cur=${COMP_WORDS[COMP_CWORD]}
# shellcheck disable=SC2207
COMPREPLY=($(compgen -W "${LOCAL_GEMS[*]}" -- "$cur"))
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"))
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
complete -F __gem_completion gem

View File

@ -6,13 +6,15 @@
_command_exists git || return
# Don't handle completion if it's already managed
if complete -p git &> /dev/null; then
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
if _command_exists xcrun
then
_git_bash_completion_xcrun_git="$(xcrun --find git)"
fi
_git_bash_completion_paths=(
@ -27,16 +29,18 @@ _git_bash_completion_paths=(
# 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
if [[ -r "${_comp_path}" ]]
then
_git_bash_completion_found=true
# shellcheck disable=SC1090 # don't follow
source "$_comp_path"
source "${_comp_path}"
break
fi
done
# Cleanup
if [[ "${_git_bash_completion_found}" == false ]]; then
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@}"

View File

@ -45,16 +45,21 @@
#
# Distributed under the [MIT License](http://creativecommons.org/licenses/MIT/)
_git_flow ()
function _git_flow ()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
local subcommands="init feature release hotfix"
local subcommand="$(__git_find_subcommand "$subcommands")"
if [ -z "$subcommand" ]; then
__gitcomp "$subcommands"
local subcommand="$(__git_find_subcommand "${subcommands}")"
if [ -z "${subcommand}" ]
then
__gitcomp "${subcommands}"
return
fi
case "$subcommand" in
case "${subcommand}" in
feature)
__git_flow_feature
return
@ -71,18 +76,27 @@ _git_flow ()
COMPREPLY=()
;;
esac
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
__git_flow_feature ()
function __git_flow_feature ()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
local subcommands="list start finish publish track diff rebase checkout pull"
local subcommand="$(__git_find_subcommand "$subcommands")"
if [ -z "$subcommand" ]; then
__gitcomp "$subcommands"
local subcommand="$(__git_find_subcommand "${subcommands}")"
if [ -z "${subcommand}" ]
then
__gitcomp "${subcommands}"
return
fi
case "$subcommand" in
case "${subcommand}" in
pull)
__gitcomp "$(__git_remotes)"
return
@ -103,33 +117,66 @@ __git_flow_feature ()
COMPREPLY=()
;;
esac
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
__git_flow_list_features ()
function __git_flow_list_features ()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
git flow feature list 2> /dev/null | tr -d ' |*'
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
__git_flow_list_remote_features ()
function __git_flow_list_remote_features ()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
git branch -r 2> /dev/null | grep "origin/$(__git_flow_feature_prefix)" | awk '{ sub(/^origin\/$(__git_flow_feature_prefix)/, "", $1); print }'
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
__git_flow_feature_prefix ()
function __git_flow_feature_prefix ()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
git config gitflow.prefix.feature 2> /dev/null || echo "feature/"
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
__git_flow_release ()
function __git_flow_release ()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
local subcommands="list start finish"
local subcommand="$(__git_find_subcommand "$subcommands")"
if [ -z "$subcommand" ]; then
__gitcomp "$subcommands"
local subcommand="$(__git_find_subcommand "${subcommands}")"
if [ -z "${subcommand}" ]
then
__gitcomp "${subcommands}"
return
fi
case "$subcommand" in
case "${subcommand}" in
finish)
__gitcomp "$(__git_flow_list_releases)"
return
@ -139,23 +186,40 @@ __git_flow_release ()
;;
esac
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
__git_flow_list_releases ()
function __git_flow_list_releases ()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
git flow release list 2> /dev/null
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
__git_flow_hotfix ()
function __git_flow_hotfix ()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
local subcommands="list start finish"
local subcommand="$(__git_find_subcommand "$subcommands")"
if [ -z "$subcommand" ]; then
__gitcomp "$subcommands"
local subcommand="$(__git_find_subcommand "${subcommands}")"
if [ -z "${subcommand}" ]
then
__gitcomp "${subcommands}"
return
fi
case "$subcommand" in
case "${subcommand}" in
finish)
__gitcomp "$(__git_flow_list_hotfixes)"
return
@ -164,11 +228,23 @@ __git_flow_hotfix ()
COMPREPLY=()
;;
esac
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
__git_flow_list_hotfixes ()
function __git_flow_list_hotfixes ()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
git flow hotfix list 2> /dev/null
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
# temporarily wrap __git_find_on_cmdline() for backwards compatibility

View File

@ -53,11 +53,16 @@ __git_flow_config_file_options="
--local --global --system --file=
"
_git_flow ()
function _git_flow ()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
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
if [ -z "$subcommand" ]
then
__gitcomp "$subcommands"
return
fi
@ -91,13 +96,22 @@ _git_flow ()
COMPREPLY=()
;;
esac
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
__git_flow_init ()
function __git_flow_init ()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
local subcommands="help"
local subcommand="$(__git_find_on_cmdline "$subcommands")"
if [ -z "$subcommand" ]; then
if [ -z "$subcommand" ]
then
__gitcomp "$subcommands"
fi
@ -111,14 +125,23 @@ __git_flow_init ()
return
;;
esac
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
__git_flow_feature ()
function __git_flow_feature ()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
local subcommands="list start finish publish track diff rebase checkout pull help delete"
local subcommand="$(__git_find_on_cmdline "$subcommands")"
if [ -z "$subcommand" ]; then
if [ -z "$subcommand" ]
then
__gitcomp "$subcommands"
return
fi
@ -194,13 +217,22 @@ __git_flow_feature ()
COMPREPLY=()
;;
esac
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
__git_flow_release ()
function __git_flow_release ()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
local subcommands="list start finish track publish help delete"
local subcommand="$(__git_find_on_cmdline "$subcommands")"
if [ -z "$subcommand" ]; then
if [ -z "$subcommand" ]
then
__gitcomp "$subcommands"
return
fi
@ -280,13 +312,22 @@ __git_flow_release ()
;;
esac
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
__git_flow_hotfix ()
function __git_flow_hotfix ()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
local subcommands="list start finish track publish help delete"
local subcommand="$(__git_find_on_cmdline "$subcommands")"
if [ -z "$subcommand" ]; then
if [ -z "$subcommand" ]
then
__gitcomp "$subcommands"
return
fi
@ -364,13 +405,22 @@ __git_flow_hotfix ()
COMPREPLY=()
;;
esac
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
__git_flow_support ()
function __git_flow_support ()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
local subcommands="list start help"
local subcommand="$(__git_find_on_cmdline "$subcommands")"
if [ -z "$subcommand" ]; then
if [ -z "$subcommand" ]
then
__gitcomp "$subcommands"
return
fi
@ -404,13 +454,22 @@ __git_flow_support ()
COMPREPLY=()
;;
esac
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
__git_flow_config ()
function __git_flow_config ()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
local subcommands="list set base"
local subcommand="$(__git_find_on_cmdline "$subcommands")"
if [ -z "$subcommand" ]; then
if [ -z "$subcommand" ]
then
__gitcomp "$subcommands"
return
fi
@ -448,21 +507,38 @@ __git_flow_config ()
COMPREPLY=()
;;
esac
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
__git_flow_prefix ()
function __git_flow_prefix ()
{
case "$1" in
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
case "${1}" in
feature|release|hotfix|support)
git config "gitflow.prefix.$1" 2> /dev/null || echo "$1/"
return
;;
esac
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
__git_flow_list_local_branches ()
function __git_flow_list_local_branches ()
{
if [ -n "$1" ]; then
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
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
@ -474,10 +550,18 @@ __git_flow_list_local_branches ()
git for-each-ref --format="ref=%(refname:short)" refs/heads/ | sort
fi
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
__git_flow_list_remote_branches ()
function __git_flow_list_remote_branches ()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
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 | \
@ -486,12 +570,21 @@ __git_flow_list_remote_branches ()
ref="${ref##$prefix}"
echo "$ref"
done | sort
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
__git_flow_list_branches ()
function __git_flow_list_branches ()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
local origin="$(git config gitflow.origin 2> /dev/null || echo "origin")"
if [ -n "$1" ]; then
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
@ -502,6 +595,10 @@ __git_flow_list_branches ()
else
git for-each-ref --format="%(refname:short)" refs/heads/ refs/remotes/$origin | sort
fi
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
# alias __git_find_on_cmdline for backwards compatibility

View File

@ -2,7 +2,8 @@
cite "about-completion"
about-completion "GitHub CLI completion"
if _binary_exists gh; then
if _binary_exists gh
then
# If gh already completed, stop
_completion_exists gh && return
eval "$(gh completion --shell=bash)"

View File

@ -6,9 +6,11 @@ about-completion "completion for go command using gocomplete"
# 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
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
if _command_exists gocomplete && gocomplete &> /dev/null
then
# finally, apply completion
complete -C gocomplete go
fi

View File

@ -24,56 +24,125 @@
# Avoid inaccurate completions for subproject tasks
COMP_WORDBREAKS=$(echo "$COMP_WORDBREAKS" | sed -e 's/://g')
function __gradle-set-project-root-dir() {
function __gradle-set-project-root-dir()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
project_root_dir="$(_bash-it-find-in-ancestor "settings.gradle" "gradlew")"
return "$?"
return "${?}"
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
__gradle-init-cache-dir() {
cache_dir="$HOME/.gradle/completion"
mkdir -p $cache_dir
function __gradle-init-cache-dir()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
cache_dir="${HOME}/.gradle/completion"
mkdir -p ${cache_dir}
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
__gradle-set-build-file() {
function __gradle-set-build-file()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
# 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}"
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
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
__gradle-set-cache-name() {
function __gradle-set-cache-name()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
# Cache name is constructed from the absolute path of the build file.
cache_name=$(echo $gradle_build_file | sed -e 's/\//_/g')
cache_name=$(echo ${gradle_build_file} | sed -e 's/\//_/g')
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
__gradle-set-files-checksum() {
function __gradle-set-files-checksum()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
# 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}')
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"
echo "Cannot generate completions as neither md5 nor md5sum exist on \${path}"
fi
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
__gradle-generate-script-cache() {
function __gradle-generate-script-cache()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
# 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
if [[ ! $(find ${cache_dir}/${cache_name} -mmin -${cache_ttl_mins} 2>/dev/null) ]]
then
# Cache all Gradle scripts
local gradle_build_scripts=$(find $project_root_dir -type f -name "*.gradle" -o -name "*.gradle.kts" 2>/dev/null | grep -E -v "$script_exclude_pattern")
printf "%s\n" "${gradle_build_scripts[@]}" > $cache_dir/$cache_name
local gradle_build_scripts=$(find ${project_root_dir} -type f -name "*.gradle" -o -name "*.gradle.kts" 2>/dev/null | grep -E -v "${script_exclude_pattern}")
printf "%s\n" "${gradle_build_scripts[@]}" > ${cache_dir}/${cache_name}
fi
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
__gradle-long-options() {
function __gradle-long-options()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
local args="--build-cache - Enables the Gradle build cache
--build-file - Specifies the build file
--configure-on-demand - Only relevant projects are configured
@ -116,9 +185,18 @@ __gradle-long-options() {
--version - Prints Gradle version info
--warn - Log warnings and errors only"
COMPREPLY=( $(compgen -W "$args" -- "${COMP_WORDS[COMP_CWORD]}") )
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
__gradle-properties() {
function __gradle-properties()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
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
@ -132,9 +210,18 @@ __gradle-properties() {
-Dorg.gradle.workers.max= - Set the number of workers Gradle is allowed to use"
COMPREPLY=( $(compgen -W "$args" -- "${COMP_WORDS[COMP_CWORD]}") )
return 0
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
__gradle-short-options() {
function __gradle-short-options()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
local args="-? - Shows a help message
-a - Do not rebuild project dependencies
-b - Specifies the build file
@ -157,45 +244,68 @@ __gradle-short-options() {
-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]}") )
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
__gradle-notify-tasks-cache-build() {
function __gradle-notify-tasks-cache-build()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
# 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"
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
__gradle-generate-tasks-cache() {
function __gradle-generate-tasks-cache()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
__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"
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)"
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)"
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
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
if [[ $task_name =~ ^([[:alnum:][:punct:]]+):([[:alnum:]]+) ]]
then
gradle_all_tasks+=( ":$task_name - $task_description" )
subproject_tasks+=( "${BASH_REMATCH[2]}" )
else
@ -205,28 +315,40 @@ __gradle-generate-tasks-cache() {
done
# subproject tasks can be referenced implicitly from root project
if [[ $GRADLE_COMPLETION_UNQUALIFIED_TASKS == "true" ]]; then
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
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
printf "%s\n" "${gradle_all_tasks[@]}" > ${cache_dir}/${gradle_files_checksum}
echo ${gradle_files_checksum} > ${cache_dir}/${cache_name}.md5
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
__gradle-completion-init() {
function __gradle-completion-init()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
local cache_dir cache_name gradle_build_file gradle_files_checksum project_root_dir
local OLDIFS="$IFS"
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
if [[ -f ${gradle_build_file} ]]
then
__gradle-set-cache-name
__gradle-generate-script-cache
__gradle-set-files-checksum
@ -236,47 +358,63 @@ __gradle-completion-init() {
IFS="$OLDIFS"
return 0
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
_gradle() {
function _gradle()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
local cache_dir cache_name gradle_build_file gradle_files_checksum project_root_dir
local cur=${COMP_WORDS[COMP_CWORD]}
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 OLDIFS="${IFS}"
local IFS=$'\n'
if [[ ${cur} == --* ]]; then
if [[ ${cur} == --* ]]
then
__gradle-long-options
elif [[ ${cur} == -D* ]]; then
elif [[ ${cur} == -D* ]]
then
__gradle-properties
elif [[ ${cur} == -* ]]; then
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
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)"
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) )
if [[ -z ${cur} ]]
then
cached_tasks=( $(cat ${cache_dir}/${cached_checksum}) )
else
cached_tasks=( $(grep "^$cur" $cache_dir/$cached_checksum) )
cached_tasks=( $(grep "^${cur}" ${cache_dir}/${cached_checksum}) )
fi
COMPREPLY=( $(compgen -W "${cached_tasks[*]}" -- "$cur") )
COMPREPLY=( $(compgen -W "${cached_tasks[*]}" -- "${cur}") )
else
__gradle-notify-tasks-cache-build
fi
# Regenerate tasks cache in the background
if [[ $gradle_files_checksum != "$(cat $cache_dir/$cache_name.md5)" || ! -f $cache_dir/$gradle_files_checksum ]]; then
if [[ ${gradle_files_checksum} != "$(cat ${cache_dir}/$cache_name.md5)" || ! -f ${cache_dir}/${gradle_files_checksum} ]]
then
$(__gradle-generate-tasks-cache 1>&2 2>/dev/null &)
fi
else
@ -300,12 +438,18 @@ wrapper - Generates Gradle wrapper files."
IFS="$OLDIFS"
# Remove description ("[:space:]" and after) if only one possibility
if [[ ${#COMPREPLY[*]} -eq 1 ]]; then
if [[ ${#COMPREPLY[*]} -eq 1 ]]
then
COMPREPLY=( ${COMPREPLY[0]%% *} )
fi
return 0
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
complete -F _gradle gradle
complete -F _gradle gradle.bat
complete -F _gradle gradlew
@ -313,6 +457,7 @@ 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
if hash gw 2>/dev/null || alias gw >/dev/null 2>&1
then
complete -F _gradle gw
fi

View File

@ -41,22 +41,37 @@
# eval "$(grunt --completion=bash)"
# Search the current directory and all parent directories for a gruntfile.
function _grunt_gruntfile() {
function _grunt_gruntfile()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
local curpath="$PWD"
while [[ "$curpath" ]]; do
for gruntfile in "$curpath/"{G,g}runtfile.{js,coffee}; do
if [[ -e "$gruntfile" ]]; then
echo "$gruntfile"
if [[ -e "${gruntfile}" ]]
then
echo "${gruntfile}"
return
fi
done
curpath="${curpath%/*}"
done
return 1
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
# Enable bash autocompletion.
function _grunt_completions() {
function _grunt_completions()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
# The currently-being-completed word.
local cur="${COMP_WORDS[COMP_CWORD]}"
# The current gruntfile, if it exists.
@ -64,12 +79,16 @@ function _grunt_completions() {
# 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}')"
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"
[[ "${cur}" == -* ]] && compls="${compls} ${opts}"
# Tell complete what stuff to show.
COMPREPLY=($(compgen -W "$compls" -- "$cur"))
COMPREPLY=($(compgen -W "${compls}" -- "${cur}"))
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
complete -o default -F _grunt_completions grunt

View File

@ -39,12 +39,21 @@
#
# 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"))
function _gulp_completions()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
# 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"))
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
complete -o default -F _gulp_completions gulp

View File

@ -2,6 +2,7 @@
cite "about-completion"
about-completion "helm (Kubernetes Package Manager) completion"
if _command_exists helm; then
if _command_exists helm
then
eval "$(helm completion bash)"
fi

View File

@ -23,18 +23,25 @@
# 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
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
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() {
__git_list_all_commands()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
cat <<-EOF
alias
pull-request
@ -50,7 +57,11 @@ ci-status
sync
EOF
__git_list_all_commands_without_hub
}
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
# Ensure cached commands are cleared
__git_all_commands=""
@ -60,17 +71,25 @@ EOF
##########################
# hub alias [-s] [SHELL]
_git_alias() {
function _git_alias()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
local i c=2 s=-s sh shells="bash zsh sh ksh csh fish"
while [ $c -lt $cword ]; do
while [ $c -lt ${cword} ]
do
i="${words[c]}"
case "$i" in
case "${i}" in
-s)
unset s
;;
*)
for sh in $shells; do
if [ "$sh" = "$i" ]; then
for sh in ${shells}
do
if [ "${sh}" = "${i}" ]
then
unset shells
break
fi
@ -79,35 +98,48 @@ EOF
esac
((c++))
done
__gitcomp "$s $shells"
}
__gitcomp "$s ${shells}"
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
# hub browse [-u] [--|[USER/]REPOSITORY] [SUBPAGE]
_git_browse() {
function _git_browse()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
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
while [ $c -lt $cword ]
do
i="${words[c]}"
case "$i" in
-u)
unset u
;;
*)
if [ -z "$repo" ]; then
repo=$i
if [ -z "${repo}" ]
then
repo=${i}
else
subpage=$i
subpage=${i}
fi
;;
esac
((c++))
done
if [ -z "$repo" ]; then
if [ -z "${repo}" ]
then
__gitcomp "$u -- $(__hub_github_repos '\p')"
elif [ -z "$subpage" ]; then
elif [ -z "${subpage}" ]
then
case "$cur" in
*/*)
local pfx="${cur%/*}" cur_="${cur#*/}"
@ -121,32 +153,45 @@ EOF
else
__gitcomp "$u"
fi
}
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
# hub compare [-u] [USER[/REPOSITORY]] [[START...]END]
_git_compare() {
function _git_compare()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
local i c=$((cword - 1)) u=-u user remote owner repo arg_repo rev
while [ $c -gt 1 ]; do
while [ $c -gt 1 ]
do
i="${words[c]}"
case "$i" in
-u)
unset u
;;
*)
if [ -z "$rev" ]; then
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
if __hub_github_repos '\p' | grep -Eqx "^$i(/[^/]+)?"
then
arg_repo=${i}
else
rev=$i
fi
elif [ -z "$arg_repo" ]; then
arg_repo=$i
elif [ -z "${arg_repo}" ]
then
arg_repo=${i}
fi
;;
esac
@ -155,78 +200,98 @@ EOF
# 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
if [ -z "$arg_repo" ]
then
user=$(__hub_github_user)
if [ -z "$user" ]; then
for i in $(__hub_github_repos); do
if [ -z "$user" ]
then
for i in $(__hub_github_repos)
do
remote=${i%%:*}
repo=${i#*:}
if [ "$remote" = origin ]; then
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
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")
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
local pfx cur_="${cur}"
case "${cur_}" in
*..*)
pfx="${cur_%%..*}..."
cur_="${cur_##*..}"
__gitcomp_nl "$(__hub_revlist $remote)" "$pfx" "$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)"
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"
__gitcomp "${u}"
fi
;;
esac
}
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
# hub create [NAME] [-p] [-d DESCRIPTION] [-h HOMEPAGE]
_git_create() {
function _git_create()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
local i c=2 name repo flags="-p -d -h"
while [ $c -lt $cword ]; do
while [ $c -lt ${cword} ]
do
i="${words[c]}"
case "$i" in
-d|-h)
((c++))
flags=${flags/$i/}
flags=${flags/${i}/}
;;
-p)
flags=${flags/$i/}
flags=${flags/${i}/}
;;
*)
name=$i
name=${i}
;;
esac
((c++))
done
if [ -z "$name" ]; then
if [ -z "${name}" ]
then
repo="$(basename "${PWD}")"
fi
case "$prev" in
@ -234,15 +299,25 @@ EOF
COMPREPLY=()
;;
-p|*)
__gitcomp "$repo $flags"
__gitcomp "${repo} ${flags}"
;;
esac
}
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
# hub fork [--no-remote] [--remote-name REMOTE] [--org ORGANIZATION]
_git_fork() {
function _git_fork()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
local i c=2 flags="--no-remote --remote-name --org"
while [ $c -lt $cword ]; do
while [ $c -lt ${cword} ]
do
i="${words[c]}"
case "$i" in
--org)
@ -261,20 +336,30 @@ EOF
esac
((c++))
done
case "$prev" in
case "${prev}" in
--remote-name|--org)
COMPREPLY=()
;;
*)
__gitcomp "$flags"
__gitcomp "${flags}"
;;
esac
}
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
# 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() {
fucntion _git_pull_request()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
local i c=2 flags="-f -m -F -i -b -h -a -M -l"
while [ $c -lt $cword ]; do
while [ $c -lt ${cword} ]
do
i="${words[c]}"
case "$i" in
-m|-F|-i|-b|-h|-a|-M|-l)
@ -299,13 +384,17 @@ EOF
# __ltrim_colon_completions "$cur"
;;
-F)
COMPREPLY=( "$cur"* )
COMPREPLY=( "${cur}"* )
;;
-f|*)
__gitcomp "$flags"
__gitcomp "${flags}"
;;
esac
}
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
###################
# Helper functions
@ -314,21 +403,32 @@ EOF
# __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
function __hub_github_user()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
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
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
if [ -z "$v" ]
then
if [ "$h" = "$host" ]
then
break
fi
h=$k
@ -336,13 +436,18 @@ EOF
fi
k=${k#* }
v=${v#* }
if [ "$h" = "$host" ] && [ "$k" = "user" ]; then
if [ "$h" = "$host" ] && [ "$k" = "user" ]
then
echo "$v"
break
fi
done < "$config"
done < "${config}"
fi
}
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
# __hub_github_repos [FORMAT]
# List all github hosted repository
@ -352,12 +457,19 @@ EOF
# \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
function __hub_github_repos()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
local f format="${1}"
if [ -z "$(__gitdir)" ]
then
return
fi
if [ -z "$format" ]; then
if [ -z "$format" ]
then
format='\1:\2'
else
format=${format//\m/\1}
@ -367,40 +479,67 @@ EOF
command git config --get-regexp 'remote\.[^.]*\.url' |
grep -E ' ((https?|git)://|git@)github\.com[:/][^:/]+/[^/]+$' |
sed -E 's#^remote\.([^.]+)\.url +.+[:/](([^/]+)/[^.]+)(\.git)?$#'"$format"'#'
}
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
# __hub_heads
# List all local "branch", and remote "owner/repo:branch"
__hub_heads() {
function __hub_heads()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
local i remote repo branch dir=$(__gitdir)
if [ -d "$dir" ]; then
if [ -d "$dir" ]
then
command git --git-dir="$dir" for-each-ref --format='%(refname:short)' \
"refs/heads/"
for i in $(__hub_github_repos); do
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
"refs/remotes/${remote}/" | while read branch
do
echo "${repo}:${branch#${remote}/}"
done
done
fi
}
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
# __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() {
function __hub_revlist()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
local i remote=${1:-origin} dir=$(__gitdir)
if [ -d "$dir" ]; then
if [ -d "$dir" ]
then
command git --git-dir="$dir" for-each-ref --format='%(refname:short)' \
"refs/remotes/${remote}/" | while read i; do
"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
}
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
# Enable completion for hub even when not using the alias
complete -o bashdefault -o default -o nospace -F _git hub 2>/dev/null \

View File

@ -25,7 +25,12 @@
# https://github.com/pyinvoke/invoke/blob/master/completion/bash
_complete_invoke() {
funciton _complete_invoke()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
local candidates
# COMP_WORDS contains the entire command string up til now (including
@ -44,6 +49,10 @@ _complete_invoke() {
#
# COMPREPLY is the list of valid completions handed back to `complete`.
COMPREPLY=( $(compgen -W "${candidates}" -- $2) )
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}

View File

@ -2,6 +2,7 @@
cite "about-completion"
about-completion "jungle(AWS cli tool) completion"
if _command_exists jungle; then
if _command_exists jungle
then
eval "$(_JUNGLE_COMPLETE=source jungle)"
fi

View File

@ -1,5 +1,6 @@
#!/usr/bin/env bash
if _command_exists kind; then
if _command_exists kind
then
eval "$(kind completion bash)"
fi

View File

@ -8,7 +8,7 @@
### 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"
_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
@ -33,34 +33,71 @@ stat -c %Y /dev/null > /dev/null 2>&1 && _KAC_STAT_COMMAND="stat -c %Y" || _KAC_
# 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
function _KAC_is_file_newer_than()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
[ -f "${1}" ] || return 1
[ $(($(date +%s) - $($_KAC_STAT_COMMAND "${1}"))) -gt "${2}" ] && return 1 || return 0
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
# 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"
function _KAC_regen_cache()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
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")
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
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
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
# cached files can't have spaces in their names
_KAC_get_cache_name_from_command() {
function _KAC_get_cache_name_from_command()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
echo "${@// /_SPACE_}"
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
# the reverse operation from the function above
_KAC_get_command_from_cache_name() {
function _KAC_get_command_from_cache_name()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
echo "${@//_SPACE_/ }"
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
# given a command as argument, it fetches the cache for that command if it can find it
@ -68,36 +105,57 @@ _KAC_get_command_from_cache_name() {
# 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() {
function _KAC_get_and_regen_cache()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
# 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"
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 &)
if [[ -f "${_KAC_CACHE_PATH}" ]]
then
(${REGEN_CMD} &)
else
$REGEN_CMD
${REGEN_CMD}
fi
}
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}}
# 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() {
function _KAC_clean_cache()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
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"
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
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
_KAC_get_and_regen_cache "${CMD}" > /dev/null
done
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
# perform a cache cleaning when loading this file
@ -109,48 +167,82 @@ _KAC_clean_cache() {
#####################################
# returns all the possible knife sub-commands
_KAC_knife_commands() {
function _KAC_knife_commands()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
knife --help | grep -E "^knife" | sed -E 's/ \(options\)//g'
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
# 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() {
function _KAC_get_current_base_command()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
local PREVIOUS="knife"
local I=1
local CURRENT
while [[ "${I}" -le "${COMP_CWORD}" ]]; do
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
CURRENT="${PREVIOUS} ${COMP_WORDS[$I]}"
grep -E "^${CURRENT}" "${_KAC_CACHE_PATH}" > /dev/null || break
PREVIOUS="${CURRENT}"
I=$((I + 1))
done
_KAC_CURRENT_COMMAND=$PREVIOUS
_KAC_CURRENT_COMMAND="${PREVIOUS}"
[[ "${I}" -le "${COMP_CWORD}" ]] && _KAC_CURRENT_COMMAND_NB_WORDS="${I}"
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
# 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() {
function _KAC_get_current_arg_position()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
local CURRENT_ARG_POS=$((_KAC_CURRENT_COMMAND_NB_WORDS + 1))
local COMPLETE_COMMAND=$(grep -E "^$_KAC_CURRENT_COMMAND" "$_KAC_CACHE_PATH")
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")
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
echo "${CURRENT_ARG}" | grep -E "^\\[[^]]+(\\.\\.\\.\\]|$)" > /dev/null && break
CURRENT_ARG_POS=$((CURRENT_ARG_POS + 1))
done
echo "$CURRENT_ARG_POS"
echo "${CURRENT_ARG_POS}"
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
# the actual auto-complete function
_knife() {
function _knife()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
_KAC_get_and_regen_cache _KAC_knife_commands
local RAW_LIST ITEM REGEN_CMD ARG_POSITION
# shellcheck disable=SC2034
@ -165,10 +257,11 @@ _knife() {
# 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
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
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"
@ -179,11 +272,11 @@ _knife() {
*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"
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"
LIST="${LIST} client environment node role"
REGEN_CMD="knife data bag list"
;;
*BAG*) REGEN_CMD="knife data bag list" ;;
@ -200,6 +293,10 @@ _knife() {
done
# shellcheck disable=SC2207,SC2086
COMPREPLY=($(compgen -W "${LIST}" -- ${COMP_WORDS[COMP_CWORD]}))
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
complete -F _knife knife

View File

@ -1,5 +1,6 @@
# shellcheck shell=bash
if _command_exists kontena; then
if _command_exists kontena
then
# shellcheck disable=SC1090
source "$(kontena whoami --bash-completion-path)"
fi

View File

@ -2,6 +2,7 @@
cite "about-completion"
about-completion "kubectl (Kubernetes CLI) completion"
if _binary_exists kubectl; then
if _binary_exists kubectl
then
eval "$(kubectl completion bash)"
fi

View File

@ -2,15 +2,26 @@
_command_exists laravel || return
function __laravel_completion() {
function __laravel_completion()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
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
for _opt_ in "${OPTS[@]}"
do
if [[ "${_opt_}" == "${2}"* ]]
then
COMPREPLY+=("$_opt_")
fi
done
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
complete -F __laravel_completion laravel

View File

@ -2,7 +2,12 @@
cite "about-completion"
about-completion "lerna(javascript project manager tool) completion"
function __lerna_completion() {
function __lerna_completion()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
local cur compls
# The currently-being-completed word.
@ -18,5 +23,9 @@ function __lerna_completion() {
# Tell complete what stuff to show.
# shellcheck disable=2207
COMPREPLY=($(compgen -W "$compls" -- "$cur"))
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
complete -o default -F __lerna_completion lerna

View File

@ -3,7 +3,12 @@
# Bash completion for Makefile
# Loosely adapted from http://stackoverflow.com/a/38415982/1472048
_makecomplete() {
function _makecomplete()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
COMPREPLY=()
# https://www.gnu.org/software/make/manual/html_node/Makefile-Names.html
@ -30,6 +35,10 @@ _makecomplete() {
done < <(compgen -W "$(tr ' ' '\n' <<<"${targets[@]}" | sort -u)" -- "${COMP_WORDS[COMP_CWORD]}")
return 0
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
complete -o nospace -F _makecomplete make

View File

@ -1,8 +1,12 @@
#!/usr/bin/env bash
# Bash Maven completion
_mvn()
function _mvn()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
local cmds cur colonprefixes
cmds="clean validate compile test package integration-test \
verify install deploy test-compile site generate-sources \
@ -32,5 +36,9 @@ _mvn()
done
return 0
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
} &&
complete -F _mvn mvn

View File

@ -1,6 +1,7 @@
# shellcheck shell=bash
# minikube (Local Kubernetes) completion
if _command_exists minikube; then
if _command_exists minikube
then
eval "$(minikube completion bash)"
fi

View File

@ -1,4 +1,5 @@
if _command_exists ng; then
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)

View File

@ -1,6 +1,11 @@
# shellcheck shell=bash
__ngrok_completion() {
function __ngrok_completion()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
# shellcheck disable=SC2155
local prev=$(_get_pword)
# shellcheck disable=SC2155
@ -42,6 +47,10 @@ __ngrok_completion() {
*) ;;
esac
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
complete -F __ngrok_completion ngrok

View File

@ -1,6 +1,11 @@
# shellcheck shell=bash
function __notify-send_completions() {
function __notify-send_completions()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
# shellcheck disable=SC2155
local curr=$(_get_cword)
# shellcheck disable=SC2155
@ -16,6 +21,10 @@ function __notify-send_completions() {
COMPREPLY=($(compgen -W "-? --help -u --urgency -t --expire-time -a --app-name -i --icon -c --category -h --hint -v --version" -- "$curr"))
;;
esac
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
complete -F __notify-send_completions notify-send

View File

@ -2,6 +2,7 @@
cite "about-completion"
about-completion "npm (Node Package Manager) completion"
if _command_exists npm; then
if _command_exists npm
then
eval "$(npm completion)"
fi

View File

@ -2,7 +2,7 @@
# nvm (Node Version Manager) completion
if [ "$NVM_DIR" ] && [ -r "$NVM_DIR"/bash_completion ];
if [ "${NVM_DIR}" ] && [ -r "${NVM_DIR}"/bash_completion ];
then
. "$NVM_DIR"/bash_completion
. "${NVM_DIR}"/bash_completion
fi

View File

@ -2,6 +2,7 @@
cite "about-completion"
about-completion "packer completion"
if _binary_exists packer; then
if _binary_exists packer
then
complete -C packer packer
fi

View File

@ -8,13 +8,24 @@
# So that pip is in the system's path.
_command_exists pip || return
function __bash_it_complete_pip() {
if _command_exists _pip_completion; then
function __bash_it_complete_pip()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
if _command_exists _pip_completion
then
complete -o default -F _pip_completion pip
_pip_completion "$@"
_pip_completion "${@}"
else
eval "$(pip completion --bash)"
_pip_completion "$@"
_pip_completion "${@}"
fi
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
complete -o default -F __bash_it_complete_pip pip

View File

@ -8,13 +8,23 @@
# So that pip3 is in the system's path.
_command_exists pip3 || return
function __bash_it_complete_pip3() {
if _command_exists _pip_completion; then
function __bash_it_complete_pip3()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
if _command_exists _pip_completion
then
complete -o default -F _pip_completion pip3
_pip_completion "$@"
_pip_completion "${@}"
else
eval "$(pip3 completion --bash)"
_pip_completion "$@"
_pip_completion "${@}"
fi
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
complete -o default -F __bash_it_complete_pip3 pip3

View File

@ -1,4 +1,5 @@
# shellcheck shell=bash
if _command_exists pipenv; then
if _command_exists pipenv
then
eval "$(_PIPENV_COMPLETE=bash_source pipenv)"
fi

View File

@ -1,6 +1,7 @@
# shellcheck shell=bash
# pipx completion
if _command_exists register-python-argcomplete && _command_exists pipx; then
if _command_exists register-python-argcomplete && _command_exists pipx
then
eval "$(register-python-argcomplete pipx)"
fi

View File

@ -4,12 +4,17 @@ _is_function _init_completion ||
_is_function _rl_enabled ||
_log_error '_rl_enabled not found. Ensure bash-completion 2.0 or newer is installed and configured properly.'
_pj() {
function _pj()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
_is_function _init_completion || return
_is_function _rl_enabled || return
[ -n "$BASH_IT_PROJECT_PATHS" ] || return
shift
[ "$1" == "open" ] && shift
[ "${1}" == "open" ] && shift
local cur prev words cword
_init_completion || return
@ -21,25 +26,34 @@ _pj() {
local -r mark_dirs=$(_rl_enabled mark-directories && echo y)
local -r mark_symdirs=$(_rl_enabled mark-symlinked-directories && echo y)
for i in ${BASH_IT_PROJECT_PATHS//:/$'\n'}; do
for i in ${BASH_IT_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
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
if [[ ${#COMPREPLY[@]} -eq 1 ]]
then
i=${COMPREPLY[0]}
if [[ "$i" == "$cur" && $i != "*/" ]]; then
if [[ "$i" == "$cur" && $i != "*/" ]]
then
COMPREPLY[0]="${i}/"
fi
fi
return 0
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
complete -F _pj -o nospace pj

View File

@ -3,15 +3,26 @@
export COMP_WORDBREAKS=${COMP_WORDBREAKS/\:/}
_rakecomplete() {
if [ -f Rakefile ]; then
function _rakecomplete()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
if [ -f Rakefile ]
then
recent=`ls -t .rake_tasks~ Rakefile **/*.rake 2> /dev/null | head -n 1`
if [[ $recent != '.rake_tasks~' ]]; then
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
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
complete -o default -o nospace -F _rakecomplete rake

View File

@ -2,6 +2,7 @@
# rustup (Rust toolchain installer) completion
if _binary_exists rustup; then
if _binary_exists rustup
then
eval "$(rustup completions bash)"
fi

View File

@ -2,4 +2,4 @@
# Bash completion support for RVM.
# Source: https://rvm.io/workflow/completion
[[ -r $rvm_path/scripts/completion ]] && . $rvm_path/scripts/completion
[[ -r ${rvm_path}/scripts/completion ]] && . ${rvm_path}/scripts/completion

View File

@ -27,32 +27,59 @@
# TODO: is it ok to use '--timeout 2' ?
_salt_get_grains(){
if [ "$1" = 'local' ] ; then
function _salt_get_grains()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
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
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
_salt_get_grain_values(){
if [ "$1" = 'local' ] ; then
function _salt_get_grain_values()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
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
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
_salt(){
function _salt()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
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
if [ ${COMP_CWORD} -gt 2 ]
then
pprev="${COMP_WORDS[COMP_CWORD-2]}"
fi
if [ ${COMP_CWORD} -gt 3 ]; then
if [ ${COMP_CWORD} -gt 3 ]
then
ppprev="${COMP_WORDS[COMP_CWORD-3]}"
fi
@ -64,7 +91,8 @@ _salt(){
--ipcidr --out=pprint --out=yaml --out=overstatestage --out=json \
--out=raw --out=highstate --out=key --out=txt --no-color --out-indent= "
if [[ "${cur}" == -* ]] ; then
if [[ "${cur}" == -* ]]
then
COMPREPLY=($(compgen -W "${opts}" -- ${cur}))
return 0
fi
@ -72,7 +100,8 @@ _salt(){
# 2 special cases for filling up grain values
case "${pprev}" in
-G|--grain|--grain-pcre)
if [ "${cur}" = ":" ]; then
if [ "${cur}" = ":" ]
then
COMPREPLY=($(compgen -W "`_salt_get_grain_values ${prev}`" ))
return 0
fi
@ -80,17 +109,20 @@ _salt(){
esac
case "${ppprev}" in
-G|--grain|--grain-pcre)
if [ "${prev}" = ":" ]; then
if [ "${prev}" = ":" ]
then
COMPREPLY=( $(compgen -W "`_salt_get_grain_values ${pprev}`" -- ${cur}) )
return 0
fi
;;
esac
if [ "${cur}" = "=" ] && [[ "${prev}" == --* ]]; then
if [ "${cur}" = "=" ] && [[ "${prev}" == --* ]]
then
cur=""
fi
if [ "${prev}" = "=" ] && [[ "${pprev}" == --* ]]; then
if [ "${prev}" = "=" ] && [[ "${pprev}" == --* ]]
then
prev="${pprev}"
fi
@ -136,12 +168,21 @@ _salt(){
COMPREPLY=( $(compgen -W "${all}" -- ${cur}) )
return 0
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
complete -F _salt salt
_saltkey(){
function _saltkey()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
local cur prev opts prev pprev
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
@ -153,21 +194,26 @@ _saltkey(){
-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
if [ ${COMP_CWORD} -gt 2 ]
then
pprev="${COMP_WORDS[COMP_CWORD-2]}"
fi
if [ ${COMP_CWORD} -gt 3 ]; then
if [ ${COMP_CWORD} -gt 3 ]
then
ppprev="${COMP_WORDS[COMP_CWORD-3]}"
fi
if [[ "${cur}" == -* ]] ; then
if [[ "${cur}" == -* ]]
then
COMPREPLY=($(compgen -W "${opts}" -- ${cur}))
return 0
fi
if [ "${cur}" = "=" ] && [[ "${prev}" == --* ]]; then
if [ "${cur}" = "=" ] && [[ "${prev}" == --* ]]
then
cur=""
fi
if [ "${prev}" = "=" ] && [[ "${pprev}" == --* ]]; then
if [ "${prev}" = "=" ] && [[ "${pprev}" == --* ]]
then
prev="${pprev}"
fi
@ -213,11 +259,20 @@ _saltkey(){
esac
COMPREPLY=($(compgen -W "${opts} " -- ${cur}))
return 0
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
complete -F _saltkey salt-key
_saltcall(){
function _saltcall()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
local cur prev opts _salt_coms pprev ppprev
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
@ -226,21 +281,26 @@ _saltcall(){
-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
if [ ${COMP_CWORD} -gt 2 ]
then
pprev="${COMP_WORDS[COMP_CWORD-2]}"
fi
if [ ${COMP_CWORD} -gt 3 ]; then
if [ ${COMP_CWORD} -gt 3 ]
then
ppprev="${COMP_WORDS[COMP_CWORD-3]}"
fi
if [[ "${cur}" == -* ]] ; then
if [[ "${cur}" == -* ]]
then
COMPREPLY=($(compgen -W "${opts}" -- ${cur}))
return 0
fi
if [ "${cur}" = "=" ] && [[ ${prev} == --* ]]; then
if [ "${cur}" = "=" ] && [[ ${prev} == --* ]]
then
cur=""
fi
if [ "${prev}" = "=" ] && [[ ${pprev} == --* ]]; then
if [ "${prev}" = "=" ] && [[ ${pprev} == --* ]]
then
prev="${pprev}"
fi
@ -265,12 +325,21 @@ _saltcall(){
_salt_coms="$(salt-call --out=txt -- sys.list_functions|sed 's/^.*\[//' | tr -d ",']" )"
COMPREPLY=( $(compgen -W "${opts} ${_salt_coms}" -- ${cur} ))
return 0
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
complete -F _saltcall salt-call
_saltcp(){
function _saltcp()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
local cur prev opts target prefpart postpart helper filt pprev ppprev
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
@ -281,15 +350,18 @@ _saltcp(){
-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
if [[ "${cur}" == -* ]]
then
COMPREPLY=($(compgen -W "${opts}" -- ${cur}))
return 0
fi
if [ "${cur}" = "=" ] && [[ "${prev}" == --* ]]; then
if [ "${cur}" = "=" ] && [[ "${prev}" == --* ]]
then
cur=""
fi
if [ "${prev}" = "=" ] && [[ "${pprev}" == --* ]]; then
if [ "${prev}" = "=" ] && [[ "${pprev}" == --* ]]
then
prev=${pprev}
fi
@ -338,6 +410,10 @@ _saltcp(){
# default is using opts:
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
complete -F _saltcp salt-cp

View File

@ -1,15 +1,22 @@
# shellcheck shell=bash
function _sdkman_complete() {
function _sdkman_complete()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
local CANDIDATES
local CANDIDATE_VERSIONS
local SDKMAN_CANDIDATES_CSV="${SDKMAN_CANDIDATES_CSV:-}"
COMPREPLY=()
if [ "$COMP_CWORD" -eq 1 ]; then
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
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}}"
@ -30,7 +37,8 @@ function _sdkman_complete() {
*) ;;
esac
elif [ "$COMP_CWORD" -eq 3 ]; then
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]}"
@ -46,24 +54,44 @@ function _sdkman_complete() {
fi
return 0
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
function _sdkman_candidate_local_versions() {
function _sdkman_candidate_local_versions()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
CANDIDATE_VERSIONS=$(__sdkman_cleanup_local_versions "$1")
CANDIDATE_VERSIONS=$(__sdkman_cleanup_local_versions "${1}")
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
function _sdkman_candidate_all_versions() {
function _sdkman_candidate_all_versions()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
candidate="$1"
candidate="${1}"
CANDIDATE_LOCAL_VERSIONS=$(__sdkman_cleanup_local_versions "$candidate")
if [[ "${SDKMAN_OFFLINE_MODE:-false}" == "true" ]]; then
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
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-)"
@ -75,12 +103,25 @@ function _sdkman_candidate_all_versions() {
CANDIDATE_VERSIONS="$(echo "$CANDIDATE_ONLINE_VERSIONS $CANDIDATE_LOCAL_VERSIONS" | tr ' ' '\n' | grep -v -e '^[[:space:]|\*|\>|\+]*$' | sort -u) "
fi
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
function __sdkman_cleanup_local_versions() {
function __sdkman_cleanup_local_versions()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
__sdkman_build_version_csv "$1" | tr ',' ' '
__sdkman_build_version_csv "${1}" | tr ',' ' '
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
complete -F _sdkman_complete sdk

View File

@ -12,6 +12,10 @@ then
function _sqlmap()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
local cur prev
COMPREPLY=()
@ -79,7 +83,8 @@ then
;;
esac
if [[ "$cur" == * ]]; then
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 \
@ -160,6 +165,10 @@ then
# else
# _filedir bat
fi
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}

View File

@ -3,38 +3,52 @@
export COMP_WORDBREAKS=${COMP_WORDBREAKS/\:/}
_sshcomplete() {
_sshcomplete()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
local CURRENT_PROMPT="${COMP_WORDS[COMP_CWORD]}"
if [[ ${CURRENT_PROMPT} == *@* ]] ; then
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" |
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
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}) )
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
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
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
complete -o default -o nospace -F _sshcomplete ssh scp slogin sftp

View File

@ -6,13 +6,15 @@
_command_exists svn || return
# Don't handle completion if it's already managed
if _completion_exists svn; then
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
if _command_exists xcrun
then
_svn_bash_completion_xcrun_svn="$(xcrun --find svn)"
fi
_svn_bash_completion_paths=(
@ -25,16 +27,18 @@ _svn_bash_completion_paths=(
# 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
if [[ -r "${_comp_path}" ]]
then
_svn_bash_completion_found=true
# shellcheck disable=SC1090 # don't follow
source "$_comp_path"
source "${_comp_path}"
break
fi
done
# Cleanup
if [[ "${_svn_bash_completion_found}" == false ]]; then
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@}"

View File

@ -7,7 +7,8 @@
# 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
if shopt -qo nounset
then
__bash_it_restore_nounset=true
shopt -uo nounset
else
@ -15,14 +16,18 @@ else
fi
# shellcheck disable=SC1090 disable=SC1091
if [[ -r "${BASH_COMPLETION:-}" ]]; then
if [[ -r "${BASH_COMPLETION:-}" ]]
then
source "${BASH_COMPLETION}"
elif [[ -r /etc/bash_completion ]]; then
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
elif [[ -r /etc/profile.d/bash_completion.sh ]]
then
source /etc/profile.d/bash_completion.sh
elif _bash_it_homebrew_check; then
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*)
@ -31,22 +36,25 @@ elif _bash_it_homebrew_check; then
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"
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
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
if [[ ${__bash_it_restore_nounset:-false} == "true" ]]
then
shopt -so nounset
fi
unset __bash_it_restore_nounset

View File

@ -1,13 +1,28 @@
__kitchen_instance_list () {
function __kitchen_instance_list ()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
# cache to .kitchen.list.yml
if [[ .kitchen.yml -nt .kitchen.list.yml || .kitchen.local.yml -nt .kitchen.list.yml ]]; then
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
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
__kitchen_options () {
function __kitchen_options ()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
COMPREPLY=()
@ -26,5 +41,9 @@ __kitchen_options () {
return 0
;;
esac
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
complete -F __kitchen_options kitchen

View File

@ -4,13 +4,19 @@
# 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 ()
function _tmux_expand ()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
[ "$cur" != "${cur%\\}" ] && cur="$cur"'\';
if [[ "$cur" == \~*/* ]]; then
if [[ "$cur" == \~*/* ]]
then
eval cur=$cur;
else
if [[ "$cur" == \~* ]]; then
if [[ "$cur" == \~* ]]
then
cur=${cur#\~};
COMPREPLY=($( compgen -P '~' -u $cur ));
return ${#COMPREPLY[@]};
@ -18,45 +24,89 @@ _tmux_expand ()
fi
}
_tmux_filedir ()
function _tmux_filedir ()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
local IFS='
';
_tmux_expand || return 0;
if [ "$1" = -d ]; then
if [ "${1}" = -d ]
then
COMPREPLY=(${COMPREPLY[@]} $( compgen -d -- $cur ));
return 0;
fi;
COMPREPLY=(${COMPREPLY[@]} $( eval compgen -f -- \"$cur\" ))
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
function _tmux_complete_client() {
function _tmux_complete_client()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
local IFS=$'\n'
local cur="${1}"
COMPREPLY=( ${COMPREPLY[@]:-} $(compgen -W "$(tmux -q list-clients 2>/dev/null | cut -f 1 -d ':')" -- "${cur}") )
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
function _tmux_complete_session() {
function _tmux_complete_session()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
local IFS=$'\n'
local cur="${1}"
COMPREPLY=( ${COMPREPLY[@]:-} $(compgen -W "$(tmux -q list-sessions 2>/dev/null | cut -f 1 -d ':')" -- "${cur}") )
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
function _tmux_complete_window() {
function _tmux_complete_window()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
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
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}") )
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
_tmux() {
function _tmux()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
local cur prev
local i cmd cmd_index option option_index
local opts=""
@ -64,20 +114,24 @@ _tmux() {
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
if [ ${prev} == -f ]; then
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
if [[ ${skip_next} -eq 1 ]]
then
#echo "Skipping"
skip_next=0;
elif [[ ${COMP_WORDS[i]} != -* ]]; then
elif [[ ${COMP_WORDS[i]} != -* ]]
then
cmd="${COMP_WORDS[i]}"
cmd_index=${i}
break
elif [[ ${COMP_WORDS[i]} == -f ]]; then
elif [[ ${COMP_WORDS[i]} == -f ]]
then
skip_next=1
fi
done
@ -85,21 +139,26 @@ _tmux() {
# Search for the last option command
skip_next=0
for ((i=1; $i<=$COMP_CWORD; i++)); do
if [[ ${skip_next} -eq 1 ]]; then
if [[ ${skip_next} -eq 1 ]]
then
#echo "Skipping"
skip_next=0;
elif [[ ${COMP_WORDS[i]} == -* ]]; then
elif [[ ${COMP_WORDS[i]} == -* ]]
then
option="${COMP_WORDS[i]}"
option_index=${i}
if [[ ${COMP_WORDS[i]} == -- ]]; then
if [[ ${COMP_WORDS[i]} == -- ]]
then
break;
fi
elif [[ ${COMP_WORDS[i]} == -f ]]; then
elif [[ ${COMP_WORDS[i]} == -f ]]
then
skip_next=1
fi
done
if [[ $COMP_CWORD -le $cmd_index ]]; then
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
@ -129,7 +188,8 @@ _tmux() {
-t) _tmux_complete_session "${cur}" ;;
-[n|d|s]) options="-d -n -s -t --" ;;
*)
if [[ ${COMP_WORDS[option_index]} == -- ]]; then
if [[ ${COMP_WORDS[option_index]} == -- ]]
then
_command_offset ${option_index}
else
options="-d -n -s -t --"
@ -174,12 +234,17 @@ _tmux() {
fi # command specified
fi # not -f
if [[ -n "${options}" ]]; then
if [[ -n "${options}" ]]
then
COMPREPLY=( ${COMPREPLY[@]:-} $(compgen -W "${options}" -- "${cur}") )
fi
return 0
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
complete -F _tmux tmux

View File

@ -23,7 +23,12 @@
# SOFTWARE.
__pwdln() {
function __pwdln()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
pwdmod="${PWD}/"
itr=0
until [[ -z "$pwdmod" ]];do
@ -31,9 +36,18 @@ __pwdln() {
pwdmod="${pwdmod#*/}"
done
echo -n $(($itr-1))
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
__vagrantinvestigate() {
function __vagrantinvestigate()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
if [ -f "${PWD}/.vagrant" -o -d "${PWD}/.vagrant" ];then
echo "${PWD}/.vagrant"
return 0
@ -48,9 +62,18 @@ __vagrantinvestigate() {
done
fi
return 1
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
_vagrant() {
function _vagrant()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
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"
@ -65,7 +88,7 @@ _vagrant() {
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-/\//')
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
;;
@ -119,7 +142,8 @@ _vagrant() {
action="${COMP_WORDS[COMP_CWORD-2]}"
case "$action" in
"up")
if [ "$prev" == "--no-provision" ]; then
if [ "$prev" == "--no-provision" ]
then
COMPREPLY=($(compgen -W "${vm_list}" -- ${cur}))
return 0
fi
@ -127,7 +151,7 @@ _vagrant() {
"box")
case "$prev" in
"remove"|"repackage")
local box_list=$(find "$HOME/.vagrant.d/boxes" -mindepth 1 -maxdepth 1 -type d -exec basename {} \;|sed -e 's/-VAGRANTSLASH-/\//')
local box_list=$(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
;;
@ -135,7 +159,8 @@ _vagrant() {
esac
;;
"snapshot")
if [ "$prev" == "restore" ]; then
if [ "$prev" == "restore" ]
then
COMPREPLY=($(compgen -W "${vm_list}" -- ${cur}))
return 0
fi
@ -149,7 +174,8 @@ _vagrant() {
prev="${COMP_WORDS[COMP_CWORD-2]}"
case "$action" in
"snapshot")
if [ "$prev" == "restore" ]; then
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
@ -159,5 +185,9 @@ _vagrant() {
;;
esac
fi
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
complete -F _vagrant vagrant

View File

@ -2,6 +2,7 @@
cite "about-completion"
about-completion "vault completion"
if _binary_exists vault; then
if _binary_exists vault
then
complete -C vault vault
fi

View File

@ -1,10 +1,24 @@
#!/usr/bin/bash
_vboxmanage_realopts() {
function _vboxmanage_realopts()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
echo $(vboxmanage|grep -i vboxmanage|cut -d' ' -f2|grep '\['|tr -s '[\[\|\]\n' ' ')
echo " "
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
__vboxmanage_startvm() {
function __vboxmanage_startvm()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
RUNNING=$(vboxmanage list runningvms | cut -d' ' -f1 | tr -d '"')
TOTAL=$(vboxmanage list vms | cut -d' ' -f1 | tr -d '"')
@ -12,20 +26,31 @@ __vboxmanage_startvm() {
for VM in $TOTAL; do
MATCH=0;
for RUN in $RUNNING "x"; do
if [ "$VM" == "$RUN" ]; then
if [ "$VM" == "$RUN" ]
then
MATCH=1
fi
done
(( $MATCH == 0 )) && AVAILABLE="$AVAILABLE $VM "
done
echo $AVAILABLE
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
__vboxmanage_list() {
function __vboxmanage_list()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
INPUT=$(vboxmanage list | tr -s '[\[\]\|\n]' ' ' | cut -d' ' -f4-)
PRUNED=""
if [ "$1" == "long" ]; then
if [ "${1}" == "long" ]
then
for WORD in $INPUT; do
[ "$WORD" == "-l" ] && continue;
[ "$WORD" == "--long" ] && continue;
@ -37,15 +62,25 @@ __vboxmanage_list() {
fi
echo $PRUNED
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
__vboxmanage_list_vms() {
function __vboxmanage_list_vms()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
VMS=""
if [ "x$1" == "x" ]; then
if [ "x$1" == "x" ]
then
SEPARATOR=" "
else
SEPARATOR=$1
SEPARATOR="${1}"
fi
for VM in $(vboxmanage list vms | cut -d' ' -f1 | tr -d '"'); do
@ -54,14 +89,24 @@ __vboxmanage_list_vms() {
done
echo $VMS
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
__vboxmanage_list_runningvms() {
function __vboxmanage_list_runningvms()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
VMS=""
if [ "$1" == "" ]; then
if [ "${1}" == "" ]
then
SEPARATOR=" "
else
SEPARATOR=$1
SEPARATOR="${1}"
fi
for VM in $(vboxmanage list runningvms | cut -d' ' -f1 | tr -d '"'); do
@ -71,9 +116,18 @@ __vboxmanage_list_runningvms() {
echo $VMS
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
__vboxmanage_controlvm() {
function __vboxmanage_controlvm()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
echo "pause resume reset poweroff savestate acpipowerbutton"
echo "acpisleepbutton keyboardputscancode guestmemoryballoon"
echo "gueststatisticsinterval usbattach usbdetach vrde vrdeport"
@ -91,9 +145,18 @@ __vboxmanage_controlvm() {
# <hostport>,[<guestip>],<guestport>
# natpf<1-N> delete <rulename>
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
__vboxmanage_default() {
function __vboxmanage_default()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
realopts=$(_vboxmanage_realopts)
opts=$realopts$(vboxmanage | grep -i vboxmanage | cut -d' ' -f2 | grep -v '\[' | sort | uniq)
pruned=""
@ -113,23 +176,28 @@ __vboxmanage_default() {
MATCH=0
for OPT in "${COMP_WORDS[@]}"; do
# opts=$(echo ${opts} | grep -v $OPT);
if [ "$OPT" == "$WORD" ]; then
if [ "$OPT" == "$WORD" ]
then
MATCH=1
break;
fi
if [ "$OPT" == "-v" ] && [ "$WORD" == "--version" ]; then
if [ "$OPT" == "-v" ] && [ "$WORD" == "--version" ]
then
MATCH=1
break;
fi
if [ "$OPT" == "--version" ] && [ "$WORD" == "-v" ]; then
if [ "$OPT" == "--version" ] && [ "$WORD" == "-v" ]
then
MATCH=1
break;
fi
if [ "$OPT" == "-q" ] && [ "$WORD" == "--nologo" ]; then
if [ "$OPT" == "-q" ] && [ "$WORD" == "--nologo" ]
then
MATCH=1
break;
fi
if [ "$OPT" == "--nologo" ] && [ "$WORD" == "-q" ]; then
if [ "$OPT" == "--nologo" ] && [ "$WORD" == "-q" ]
then
MATCH=1
break;
fi
@ -142,9 +210,18 @@ __vboxmanage_default() {
# COMPREPLY=($(compgen -W "${pruned}" -- ${cur}))
echo $pruned
return 0
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
_vboxmanage() {
function _vboxmanage()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
# vboxmanage | grep -i vboxmanage | cut -d' ' -f2 | sort | uniq
local cur p1 p2 p3 p4 opts
COMPREPLY=()
@ -199,7 +276,8 @@ _vboxmanage() {
esac
for VM in $(__vboxmanage_list_vms); do
if [ "$VM" == "$prev" ]; then
if [ "$VM" == "$prev" ]
then
pprev=${COMP_WORDS[COMP_CWORD-2]}
# echo "previous: $pprev"
case $pprev in
@ -218,5 +296,9 @@ _vboxmanage() {
done
# echo "Got to end withoug completion"
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
complete -F _vboxmanage vboxmanage

View File

@ -1,6 +1,11 @@
# shellcheck shell=bash
__vuejs_completion() {
__vuejs_completion()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
# shellcheck disable=SC2155
local prev=$(_get_pword)
# shellcheck disable=SC2155
@ -56,6 +61,10 @@ __vuejs_completion() {
COMPREPLY=($(compgen -W "-h --help -v --version create add invoke inspect serve build ui init config outdated upgrade migrate info" -- "$curr"))
;;
esac
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
complete -F __vuejs_completion vue

View File

@ -2,15 +2,24 @@
_command_exists wpscan || return
function __wpscan_completion() {
function __wpscan_completion()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
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
if [[ "$_opt_" == "${2}"* ]]
then
COMPREPLY+=("$_opt_")
fi
done
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
complete -F __wpscan_completion wpscan

View File

@ -7,12 +7,15 @@ export CLICOLOR
# Load the theme
# shellcheck disable=SC1090
if [[ -n "${BASH_IT_THEME:-}" ]]; then
if [[ -f "${BASH_IT_THEME}" ]]; then
if [[ -n "${BASH_IT_THEME:-}" ]]
then
if [[ -f "${BASH_IT_THEME}" ]]
then
source "${BASH_IT_THEME}"
elif [[ -f "$CUSTOM_THEME_DIR/$BASH_IT_THEME/$BASH_IT_THEME.theme.bash" ]]; then
source "$CUSTOM_THEME_DIR/$BASH_IT_THEME/$BASH_IT_THEME.theme.bash"
elif [[ -f "${CUSTOM_THEME_DIR}/${BASH_IT_THEME}/${BASH_IT_THEME}.theme.bash" ]]
then
source "${CUSTOM_THEME_DIR}/${BASH_IT_THEME}/${BASH_IT_THEME}.theme.bash"
else
source "$BASH_IT/themes/$BASH_IT_THEME/$BASH_IT_THEME.theme.bash"
source "${BASH_IT}/themes/${BASH_IT_THEME}/${BASH_IT_THEME}.theme.bash"
fi
fi

View File

@ -8,18 +8,40 @@ function _shell_duration_en() (
# DFARREL You would think LC_NUMERIC would do it, but not working in my local
LC_ALL='en_US.UTF-8'
printf "%s" "${EPOCHREALTIME:-$SECONDS}"
)
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
: "${COMMAND_DURATION_START_SECONDS:=$(_shell_duration_en)}"
: "${COMMAND_DURATION_ICON:=🕘}"
: "${COMMAND_DURATION_MIN_SECONDS:=1}"
function _command_duration_pre_exec() {
function _command_duration_pre_exec()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
COMMAND_DURATION_START_SECONDS="$(_shell_duration_en)"
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
function _command_duration_pre_cmd() {
function _command_duration_pre_cmd()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
COMMAND_DURATION_START_SECONDS=""
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
function _dynamic_clock_icon {
@ -28,9 +50,18 @@ function _dynamic_clock_icon {
# so between 144 and 155 in base 10.
printf -v clock_hand '%x' $(((${1:-${SECONDS}} % 12) + 144))
printf -v 'COMMAND_DURATION_ICON' '%b' "\xf0\x9f\x95\x$clock_hand"
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
function _command_duration() {
function _command_duration()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
[[ -n "${BASH_IT_COMMAND_DURATION:-}" ]] || return
[[ -n "${COMMAND_DURATION_START_SECONDS:-}" ]] || return
@ -45,11 +76,13 @@ function _command_duration() {
local -i current_time_deciseconds="$((10#${current_time##*.}))"
current_time_deciseconds="${current_time_deciseconds:0:1}"
if [[ "${command_start_seconds:-0}" -gt 0 ]]; then
if [[ "${command_start_seconds:-0}" -gt 0 ]]
then
# seconds
command_duration="$((current_time_seconds - command_start_seconds))"
if ((current_time_deciseconds >= command_start_deciseconds)); then
if ((current_time_deciseconds >= command_start_deciseconds))
then
deciseconds="$((current_time_deciseconds - command_start_deciseconds))"
else
((command_duration -= 1))
@ -59,17 +92,23 @@ function _command_duration() {
command_duration=0
fi
if ((command_duration >= COMMAND_DURATION_MIN_SECONDS)); then
if ((command_duration >= COMMAND_DURATION_MIN_SECONDS))
then
minutes=$((command_duration / 60))
seconds=$((command_duration % 60))
_dynamic_clock_icon "${command_duration}"
if ((minutes > 0)); then
if ((minutes > 0))
then
printf "%s %s%dm %ds" "${COMMAND_DURATION_ICON:-}" "${COMMAND_DURATION_COLOR:-}" "$minutes" "$seconds"
else
printf "%s %s%d.%01ds" "${COMMAND_DURATION_ICON:-}" "${COMMAND_DURATION_COLOR:-}" "$seconds" "$deciseconds"
fi
fi
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
_bash_it_library_finalize_hook+=("safe_append_preexec '_command_duration_pre_exec'")

File diff suppressed because it is too large Load Diff

View File

@ -2,12 +2,22 @@
#
# Functions for working with Bash's command history.
function _bash-it-history-init() {
function _bash-it-history-init()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
safe_append_preexec '_bash-it-history-auto-save'
safe_append_prompt_command '_bash-it-history-auto-load'
}
function _bash-it-history-auto-save() {
function _bash-it-history-auto-save()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
case $HISTCONTROL in
*'noauto'* | *'autoload'*)
: # Do nothing, as configured.
@ -21,9 +31,18 @@ function _bash-it-history-auto-save() {
shopt -q histappend && history -a && return
;;
esac
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
function _bash-it-history-auto-load() {
function _bash-it-history-auto-load()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
case $HISTCONTROL in
*'noauto'*)
: # Do nothing, as configured.
@ -44,6 +63,10 @@ function _bash-it-history-auto-load() {
: # Do nothing, default.
;;
esac
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
_bash_it_library_finalize_hook+=('_bash-it-history-init')

View File

@ -11,7 +11,8 @@
: "${BASH_IT_LOG_LEVEL_TRACE:=7}"
readonly "${!BASH_IT_LOG_LEVEL_@}"
function _bash-it-log-prefix-by-path() {
function _bash-it-log-prefix-by-path()
{
local component_path="${1?${FUNCNAME[0]}: path specification required}"
local without_extension component_directory
local component_filename component_type component_name
@ -31,8 +32,10 @@ function _bash-it-log-prefix-by-path() {
component_name="${component_name##[[:digit:]][[:digit:]][[:digit:]]"${BASH_IT_LOAD_PRIORITY_SEPARATOR:----}"}"
# best-guess for files without a type
if [[ "${component_type:-${component_name}}" == "${component_name}" ]]; then
if [[ "${component_directory}" == *'vendor'* ]]; then
if [[ "${component_type:-${component_name}}" == "${component_name}" ]]
then
if [[ "${component_directory}" == *'vendor'* ]]
then
component_type='vendor'
else
component_type="${component_directory##*/}"
@ -41,14 +44,26 @@ function _bash-it-log-prefix-by-path() {
# shellcheck disable=SC2034
BASH_IT_LOG_PREFIX="${component_type:-lib}: $component_name"
}
function _has_colors() {
function _has_colors()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
# Check that stdout is a terminal, and that it has at least 8 colors.
[[ -t 1 && "${CLICOLOR:=$(tput colors 2> /dev/null)}" -ge 8 ]]
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
function _bash-it-log-message() {
function _bash-it-log-message()
{
: _about 'Internal function used for logging, uses BASH_IT_LOG_PREFIX as a prefix'
: _param '1: color of the message'
: _param '2: log level to print before the prefix'
@ -59,42 +74,59 @@ function _bash-it-log-message() {
local color="${1-${echo_cyan:-}}"
local level="${2:-TRACE}"
local message="${level%: }: ${prefix%: }: ${3?}"
if _has_colors; then
if _has_colors
then
printf '%b%s%b\n' "${color}" "${message}" "${echo_normal:-}"
else
printf '%s\n' "${message}"
fi
}
function _log_debug() {
function _log_debug()
{
: _about 'log a debug message by echoing to the screen. needs BASH_IT_LOG_LEVEL >= BASH_IT_LOG_LEVEL_INFO'
: _param '1: message to log'
: _example '$ _log_debug "Loading plugin git..."'
: _group 'log'
if [[ "${BASH_IT_LOG_LEVEL:-0}" -ge "${BASH_IT_LOG_LEVEL_INFO?}" ]]; then
_bash-it-log-message "${echo_green:-}" "DEBUG: " "$1"
if [[ "${BASH_IT_LOG_LEVEL:-0}" -ge "${BASH_IT_LOG_LEVEL_INFO?}" ]]
then
_bash-it-log-message "${echo_green:-}" "DEBUG: " "${1}"
fi
}
function _log_warning() {
function _log_warning()
{
: _about 'log a message by echoing to the screen. needs BASH_IT_LOG_LEVEL >= BASH_IT_LOG_LEVEL_WARNING'
: _param '1: message to log'
: _example '$ _log_warning "git binary not found, disabling git plugin..."'
: _group 'log'
if [[ "${BASH_IT_LOG_LEVEL:-0}" -ge "${BASH_IT_LOG_LEVEL_WARNING?}" ]]; then
_bash-it-log-message "${echo_yellow:-}" " WARN: " "$1"
if [[ "${BASH_IT_LOG_LEVEL:-0}" -ge "${BASH_IT_LOG_LEVEL_WARNING?}" ]]
then
_bash-it-log-message "${echo_yellow:-}" " WARN: " "${1}"
fi
}
function _log_error() {
function _log_error()
{
: _about 'log a message by echoing to the screen. needs BASH_IT_LOG_LEVEL >= BASH_IT_LOG_LEVEL_ERROR'
: _param '1: message to log'
: _example '$ _log_error "Failed to load git plugin..."'
: _group 'log'
if [[ "${BASH_IT_LOG_LEVEL:-0}" -ge "${BASH_IT_LOG_LEVEL_ERROR?}" ]]; then
_bash-it-log-message "${echo_red:-}" "ERROR: " "$1"
if [[ "${BASH_IT_LOG_LEVEL:-0}" -ge "${BASH_IT_LOG_LEVEL_ERROR?}" ]]
then
_bash-it-log-message "${echo_red:-}" "ERROR: " "${1}"
fi
}

View File

@ -12,11 +12,9 @@ __bp_delay_install="delayed"
source "${BASH_IT?}/vendor/github.com/rcaloras/bash-preexec/bash-preexec.sh"
# Block damanaging user's `$HISTCONTROL`
function __bp_adjust_histcontrol() { :; }
__bp_adjust_histcontrol()
# Don't fail on readonly variables
function __bp_require_not_readonly() { :; }
__bp_require_not_readonly()
# For performance, testing, and to avoid unexpected behavior: disable DEBUG traps in subshells.
# See bash-it/bash-it#1040 and rcaloras/bash-preexec#26
: "${__bp_enable_subshells:=}" # blank
@ -25,51 +23,93 @@ function __bp_require_not_readonly() { :; }
_bash_it_library_finalize_hook+=('__bp_install_after_session_init')
## Helper functions
function __check_precmd_conflict() {
function __check_precmd_conflict()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
local f
__bp_trim_whitespace f "${1?}"
_bash-it-array-contains-element "${f}" "${precmd_functions[@]}"
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
function __check_preexec_conflict() {
function __check_preexec_conflict()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
local f
__bp_trim_whitespace f "${1?}"
_bash-it-array-contains-element "${f}" "${preexec_functions[@]}"
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
function safe_append_prompt_command() {
function safe_append_prompt_command()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
local prompt_re prompt_er f
if [[ "${bash_preexec_imported:-${__bp_imported:-missing}}" == "defined" ]]; then
if [[ "${bash_preexec_imported:-${__bp_imported:-missing}}" == "defined" ]]
then
# We are using bash-preexec
__bp_trim_whitespace f "${1?}"
if ! __check_precmd_conflict "${f}"; then
if ! __check_precmd_conflict "${f}"
then
precmd_functions+=("${f}")
fi
else
# Match on word-boundaries
prompt_re='(^|[^[:alnum:]_])'
prompt_er='([^[:alnum:]_]|$)'
if [[ ${PROMPT_COMMAND} =~ ${prompt_re}"${1}"${prompt_er} ]]; then
if [[ ${PROMPT_COMMAND} =~ ${prompt_re}"${1}"${prompt_er} ]]
then
return
elif [[ -z ${PROMPT_COMMAND} ]]; then
elif [[ -z ${PROMPT_COMMAND} ]]
then
PROMPT_COMMAND="${1}"
else
PROMPT_COMMAND="${1};${PROMPT_COMMAND}"
fi
fi
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
function safe_append_preexec() {
function safe_append_preexec()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
local prompt_re f
if [[ "${bash_preexec_imported:-${__bp_imported:-missing}}" == "defined" ]]; then
if [[ "${bash_preexec_imported:-${__bp_imported:-missing}}" == "defined" ]]
then
# We are using bash-preexec
__bp_trim_whitespace f "${1?}"
if ! __check_preexec_conflict "${f}"; then
if ! __check_preexec_conflict "${f}"
then
preexec_functions+=("${f}")
fi
else
_log_error "${FUNCNAME[0]}: can't append to preexec hook because _bash-preexec.sh_ hasn't been loaded"
fi
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}

View File

@ -2,19 +2,26 @@
#
# Displays the prompt from each _Bash It_ theme.
function _bash-it-preview() {
function _bash-it-preview()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
local BASH_IT_THEME BASH_IT_LOG_LEVEL
local themes IFS=$'\n' cur
if [[ $# -gt '0' ]]; then
themes=("$@")
if [[ $# -gt '0' ]]
then
themes=("${@}")
else
themes=("${BASH_IT?}/themes"/*/*.theme.bash)
themes=("${themes[@]##*/}")
themes=("${themes[@]%.theme.bash}")
fi
if [[ ${COMP_CWORD:-} -gt '0' ]]; then
if [[ ${COMP_CWORD:-} -gt '0' ]]
then
cur="${COMP_WORDS[COMP_CWORD]}"
read -d '' -ra COMPREPLY < <(compgen -W "all${IFS}${themes[*]}" -- "${cur}")
return
@ -26,9 +33,14 @@ function _bash-it-preview() {
BASH_IT_LOG_LEVEL=0
bash --init-file "${BASH_IT?}/bash_it.sh" -i <<< '_bash-it-flash-term "${#BASH_IT_THEME}" "${BASH_IT_THEME}"'
done
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
if [[ -n "${BASH_PREVIEW:-}" ]]; then
_bash-it-preview "${BASH_PREVIEW}" "$@"
if [[ -n "${BASH_PREVIEW:-}" ]]
then
_bash-it-preview "${BASH_PREVIEW}" "${@}"
unset BASH_PREVIEW #Prevent infinite looping
fi

View File

@ -47,7 +47,12 @@
# completions: git
#
function _bash-it-search() {
function _bash-it-search()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
_about 'searches for given terms amongst bash-it plugins, aliases and completions'
_param '1: term1'
_param '2: [ term2 ]...'
@ -57,13 +62,14 @@ function _bash-it-search() {
local BASH_IT_SEARCH_USE_COLOR="${BASH_IT_SEARCH_USE_COLOR:=true}"
local -a BASH_IT_COMPONENTS=('aliases' 'plugins' 'completions')
if [[ $# -eq 0 ]]; then
if [[ $# -eq 0 ]]
then
_bash-it-search-help
return 0
fi
local -a args=()
for word in "$@"; do
for word in "${@}"; do
case "${word}" in
'-h' | '--help')
_bash-it-search-help
@ -81,16 +87,26 @@ function _bash-it-search() {
esac
done
if [[ ${#args} -gt 0 ]]; then
if [[ ${#args} -gt 0 ]]
then
for component in "${BASH_IT_COMPONENTS[@]}"; do
_bash-it-search-component "${component}" "${args[@]}"
done
fi
return 0
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
function _bash-it-search-help() {
function _bash-it-search-help()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
printf '%b' "${echo_normal-}
${echo_underline_yellow-}USAGE${echo_normal-}
@ -165,26 +181,53 @@ ${echo_underline_yellow-}SUMMARY${echo_normal-}
each module.
"
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
function _bash-it-is-partial-match() {
function _bash-it-is-partial-match()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
local component="${1?${FUNCNAME[0]}: component type must be specified}"
local term="${2:-}"
_bash-it-component-help "${component}" | _bash-it-egrep -i -q -- "${term}"
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
function _bash-it-component-term-matches-negation() {
local match="$1"
function _bash-it-component-term-matches-negation()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
local match="${1}"
shift
local negative
for negative in "$@"; do
for negative in "${@}"; do
[[ "${match}" =~ ${negative} ]] && return 0
done
return 1
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
function _bash-it-search-component() {
function _bash-it-search-component()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
_about 'searches for given terms amongst a given component'
_param '1: component type, one of: [ aliases | plugins | completions ]'
_param '2: term1 term2 @term3'
@ -199,7 +242,8 @@ function _bash-it-search-component() {
local component_singular action action_func
local -a search_commands=('enable' 'disable')
for search_command in "${search_commands[@]}"; do
if _bash-it-array-contains-element "--${search_command}" "$@"; then
if _bash-it-array-contains-element "--${search_command}" "${@}"
then
component_singular="${component/es/}" # aliases -> alias
component_singular="${component_singular/ns/n}" # plugins -> plugin
@ -209,7 +253,7 @@ function _bash-it-search-component() {
fi
done
local -a terms=("$@") # passed on the command line
local -a terms=("${@}") # passed on the command line
local -a exact_terms=() # terms that should be included only if they match exactly
local -a partial_terms=() # terms that should be included if they match partially
@ -224,12 +268,16 @@ function _bash-it-search-component() {
for term in "${terms[@]}"; do
local search_term="${term:1}"
if [[ "${term:0:2}" == "--" ]]; then
if [[ "${term:0:2}" == "--" ]]
then
continue
elif [[ "${term:0:1}" == "-" ]]; then
elif [[ "${term:0:1}" == "-" ]]
then
negative_terms+=("${search_term}")
elif [[ "${term:0:1}" == "@" ]]; then
if _bash-it-array-contains-element "${search_term}" "${component_list[@]:-}"; then
elif [[ "${term:0:1}" == "@" ]]
then
if _bash-it-array-contains-element "${search_term}" "${component_list[@]:-}"
then
exact_terms+=("${search_term}")
fi
else
@ -248,16 +296,25 @@ function _bash-it-search-component() {
local -a matches=()
for match in "${total_matches[@]}"; do
local -i include_match=1
if [[ ${#negative_terms[@]} -gt 0 ]]; then
if [[ ${#negative_terms[@]} -gt 0 ]]
then
_bash-it-component-term-matches-negation "${match}" "${negative_terms[@]:-}" && include_match=0
fi
((include_match)) && matches+=("${match}")
done
_bash-it-search-result "${component}" "${action:-}" "${action_func:-}" "${matches[@]:-}"
}
function _bash-it-search-result() {
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
function _bash-it-search-result()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
local component="${1?${FUNCNAME[0]}: component type must be specified}"
shift
local action="${1:-}"
@ -276,7 +333,8 @@ function _bash-it-search-result() {
[[ -n "${line}" ]] && matches+=("$line")
done < <(_bash-it-array-dedup "${@}")
if [[ "${BASH_IT_SEARCH_USE_COLOR}" == "true" ]]; then
if [[ "${BASH_IT_SEARCH_USE_COLOR}" == "true" ]]
then
color_component='\e[1;34m'
color_enable='\e[1;32m'
suffix_enable=''
@ -292,14 +350,16 @@ function _bash-it-search-result() {
color_off=''
fi
if [[ "${#matches[@]}" -gt 0 ]]; then
if [[ "${#matches[@]}" -gt 0 ]]
then
printf "${color_component}%13s${color_sep}${color_off} " "${component}"
for match in "${matches[@]}"; do
enabled=0
_bash-it-component-item-is-enabled "${component}" "${match}" && enabled=1
if ((enabled)); then
if ((enabled))
then
match_color="${color_enable}"
suffix="${suffix_enable}"
opposite_suffix="${suffix_disable}"
@ -315,8 +375,10 @@ function _bash-it-search-result() {
len="${#matched}"
printf '%b' "${match_color}${matched}" # print current state
if [[ "${action}" == "${compatible_action}" ]]; then
if [[ "${action}" == "enable" && "${BASH_IT_SEARCH_USE_COLOR}" == "true" ]]; then
if [[ "${action}" == "${compatible_action}" ]]
then
if [[ "${action}" == "enable" && "${BASH_IT_SEARCH_USE_COLOR}" == "true" ]]
then
_bash-it-flash-term "${len}" "${matched}"
else
_bash-it-erase-term "${len}" "${matched}"
@ -336,14 +398,32 @@ function _bash-it-search-result() {
((modified)) && _bash-it-component-cache-clean "${component}"
printf "\n"
fi
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
function _bash-it-rewind() {
function _bash-it-rewind()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
local -i len="${1:-0}"
printf '%b' "\033[${len}D"
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
function _bash-it-flash-term() {
function _bash-it-flash-term()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
local -i len="${1:-0}" # redundant
local term="${2:-}"
# as currently implemented, `$match` has already been printed to screen the first time
@ -356,9 +436,18 @@ function _bash-it-flash-term() {
_bash-it-rewind "${len}"
printf '%b' "${color}${term}"
done
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
function _bash-it-erase-term() {
function _bash-it-erase-term()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
local -i len="${1:-0}" i
local delay=0.05
local term="${2:-}" # calculate length ourselves
@ -370,4 +459,8 @@ function _bash-it-erase-term() {
printf "%.*s" "$i" " "
sleep "${delay}"
done
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}

View File

@ -6,7 +6,12 @@
# Generic utilies
###########################################################################
function _bash-it-get-component-name-from-path() {
function _bash-it-get-component-name-from-path()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
local filename
# filename without path
filename="${1##*/}"
@ -14,9 +19,18 @@ function _bash-it-get-component-name-from-path() {
filename="${filename##*"${BASH_IT_LOAD_PRIORITY_SEPARATOR?}"}"
# filename without path, priority or extension
echo "${filename%.*.bash}"
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
function _bash-it-get-component-type-from-path() {
function _bash-it-get-component-type-from-path()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
local filename
# filename without path
filename="${1##*/}"
@ -25,6 +39,10 @@ function _bash-it-get-component-type-from-path() {
# extension without priority or name
filename="${filename##*.}"
echo "${filename}"
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
# This function searches an array for an exact match against the term passed
@ -40,42 +58,88 @@ function _bash-it-get-component-type-from-path() {
# $ _bash-it-array-contains-element apple "@{fruits[@]}" && echo 'contains apple'
# contains apple
#
# $ if _bash-it-array-contains-element pear "${fruits[@]}"; then
# $ if _bash-it-array-contains-element pear "${fruits[@]}"
then
# echo "contains pear!"
# fi
# contains pear!
#
#
function _bash-it-array-contains-element() {
function _bash-it-array-contains-element()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
local e element="${1?}"
shift
for e in "$@"; do
for e in "${@}"; do
[[ "$e" == "${element}" ]] && return 0
done
return 1
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
# Dedupe an array (without embedded newlines).
function _bash-it-array-dedup() {
printf '%s\n' "$@" | sort -u
function _bash-it-array-dedup()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
printf '%s\n' "${@}" | sort -u
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
# Runs `grep` with *just* the provided arguments
function _bash-it-grep() {
function _bash-it-grep()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
: "${BASH_IT_GREP:=$(type -P grep)}"
"${BASH_IT_GREP:-/usr/bin/grep}" "$@"
"${BASH_IT_GREP:-/usr/bin/grep}" "${@}"
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
# Runs `grep` with fixed-string expressions (-F)
function _bash-it-fgrep() {
function _bash-it-fgrep()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
: "${BASH_IT_GREP:=$(type -P grep)}"
"${BASH_IT_GREP:-/usr/bin/grep}" -F "$@"
"${BASH_IT_GREP:-/usr/bin/grep}" -F "${@}"
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
# Runs `grep` with extended regular expressions (-E)
function _bash-it-egrep() {
function _bash-it-egrep()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
: "${BASH_IT_GREP:=$(type -P grep)}"
"${BASH_IT_GREP:-/usr/bin/grep}" -E "$@"
"${BASH_IT_GREP:-/usr/bin/grep}" -E "${@}"
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
###########################################################################
@ -83,55 +147,102 @@ function _bash-it-egrep() {
# completion).
###########################################################################
function _bash-it-component-help() {
function _bash-it-component-help()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
local component file func
_bash-it-component-pluralize "${1}" component
_bash-it-component-cache-file "${component}" file
if [[ ! -s "${file?}" || -z "$(find "${file}" -mmin -300)" ]]; then
if [[ ! -s "${file?}" || -z "$(find "${file}" -mmin -300)" ]]
then
func="_bash-it-${component?}"
"${func}" | _bash-it-egrep '\[[x ]\]' >| "${file}"
fi
cat "${file}"
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
function _bash-it-component-cache-file() {
function _bash-it-component-cache-file()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
local _component_to_cache _file_path _result="${2:-${FUNCNAME[0]//-/_}}"
_bash-it-component-pluralize "${1?${FUNCNAME[0]}: component name required}" _component_to_cache
_file_path="${XDG_CACHE_HOME:-${HOME?}/.cache}/bash/${_component_to_cache?}"
[[ -f "${_file_path}" ]] || mkdir -p "${_file_path%/*}"
printf -v "${_result?}" '%s' "${_file_path}"
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
function _bash-it-component-singularize() {
function _bash-it-component-singularize()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
local _result="${2:-${FUNCNAME[0]//-/_}}"
local _component_to_single="${1?${FUNCNAME[0]}: component name required}"
local -i len="$((${#_component_to_single} - 2))"
if [[ "${_component_to_single:${len}:2}" == 'ns' ]]; then
if [[ "${_component_to_single:${len}:2}" == 'ns' ]]
then
_component_to_single="${_component_to_single%s}"
elif [[ "${_component_to_single}" == "aliases" ]]; then
elif [[ "${_component_to_single}" == "aliases" ]]
then
_component_to_single="${_component_to_single%es}"
fi
printf -v "${_result?}" '%s' "${_component_to_single}"
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
function _bash-it-component-pluralize() {
function _bash-it-component-pluralize()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
local _result="${2:-${FUNCNAME[0]//-/_}}"
local _component_to_plural="${1?${FUNCNAME[0]}: component name required}"
local -i len="$((${#_component_to_plural} - 1))"
# pluralize component name for consistency
if [[ "${_component_to_plural:${len}:1}" != 's' ]]; then
if [[ "${_component_to_plural:${len}:1}" != 's' ]]
then
_component_to_plural="${_component_to_plural}s"
elif [[ "${_component_to_plural}" == "alias" ]]; then
elif [[ "${_component_to_plural}" == "alias" ]]
then
_component_to_plural="${_component_to_plural}es"
fi
printf -v "${_result?}" '%s' "${_component_to_plural}"
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
function _bash-it-component-cache-clean() {
function _bash-it-component-cache-clean()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
local component="${1:-}"
local cache
local -a components=('aliases' 'plugins' 'completions')
if [[ -z "${component}" ]]; then
if [[ -z "${component}" ]]
then
for component in "${components[@]}"; do
_bash-it-component-cache-clean "${component}"
done
@ -139,29 +250,69 @@ function _bash-it-component-cache-clean() {
_bash-it-component-cache-file "${component}" cache
: >| "${cache:?}"
fi
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
# Returns an array of items within each compoenent.
function _bash-it-component-list() {
local IFS=$'\n' component="$1"
function _bash-it-component-list()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
local IFS=$'\n' component="${1}"
_bash-it-component-help "${component}" | awk '{print $1}' | sort -u
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
function _bash-it-component-list-matching() {
local component="$1"
function _bash-it-component-list-matching()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
local component="${1}"
shift
local term="$1"
local term="${1}"
_bash-it-component-help "${component}" | _bash-it-egrep -- "${term}" | awk '{print $1}' | sort -u
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
function _bash-it-component-list-enabled() {
local IFS=$'\n' component="$1"
function _bash-it-component-list-enabled()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
local IFS=$'\n' component="${1}"
_bash-it-component-help "${component}" | _bash-it-fgrep '[x]' | awk '{print $1}' | sort -u
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
function _bash-it-component-list-disabled() {
local IFS=$'\n' component="$1"
function _bash-it-component-list-disabled()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
local IFS=$'\n' component="${1}"
_bash-it-component-help "${component}" | _bash-it-fgrep -v '[x]' | awk '{print $1}' | sort -u
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
# Checks if a given item is enabled for a particular component/file-type.
@ -171,10 +322,16 @@ function _bash-it-component-list-disabled() {
#
# Examples:
# _bash-it-component-item-is-enabled alias git && echo "git alias is enabled"
function _bash-it-component-item-is-enabled() {
function _bash-it-component-item-is-enabled()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
local component_type item_name each_file
if [[ -f "${1?}" ]]; then
if [[ -f "${1?}" ]]
then
item_name="$(_bash-it-get-component-name-from-path "${1}")"
component_type="$(_bash-it-get-component-type-from-path "${1}")"
else
@ -184,12 +341,17 @@ function _bash-it-component-item-is-enabled() {
for each_file in "${BASH_IT}/enabled"/*"${BASH_IT_LOAD_PRIORITY_SEPARATOR?}${item_name}.${component_type}"*."bash" \
"${BASH_IT}/${component_type}"*/"enabled/${item_name}.${component_type}"*."bash" \
"${BASH_IT}/${component_type}"*/"enabled"/*"${BASH_IT_LOAD_PRIORITY_SEPARATOR?}${item_name}.${component_type}"*."bash"; do
if [[ -f "${each_file}" ]]; then
if [[ -f "${each_file}" ]]
then
return 0
fi
done
return 1
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
# Checks if a given item is disabled for a particular component/file-type.
@ -199,6 +361,15 @@ function _bash-it-component-item-is-enabled() {
#
# Examples:
# _bash-it-component-item-is-disabled alias git && echo "git aliases are disabled"
function _bash-it-component-item-is-disabled() {
! _bash-it-component-item-is-enabled "$@"
function _bash-it-component-item-is-disabled()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
! _bash-it-component-item-is-enabled "${@}"
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}

View File

@ -5,10 +5,13 @@ about-plugin 'Autojump configuration, see https://github.com/wting/autojump for
# Only supports the Homebrew variant, Debian and Arch at the moment.
# Feel free to provide a PR to support other install locations
# shellcheck disable=SC1090
if _bash_it_homebrew_check && [[ -s "${BASH_IT_HOMEBREW_PREFIX}/etc/profile.d/autojump.sh" ]]; then
if _bash_it_homebrew_check && [[ -s "${BASH_IT_HOMEBREW_PREFIX}/etc/profile.d/autojump.sh" ]]
then
source "${BASH_IT_HOMEBREW_PREFIX}/etc/profile.d/autojump.sh"
elif _command_exists dpkg && dpkg -s autojump &> /dev/null; then
elif _command_exists dpkg && dpkg -s autojump &> /dev/null
then
source "$(dpkg-query -S autojump.sh | cut -d' ' -f2)"
elif _command_exists pacman && pacman -Q autojump &> /dev/null; then
elif _command_exists pacman && pacman -Q autojump &> /dev/null
then
source "$(pacman -Ql autojump | grep autojump.sh | cut -d' ' -f2)"
fi

View File

@ -5,29 +5,47 @@ about-plugin 'AWS helper functions'
AWS_CONFIG_FILE="${AWS_CONFIG_FILE:-$HOME/.aws/config}"
AWS_SHARED_CREDENTIALS_FILE="${AWS_SHARED_CREDENTIALS_FILE:-$HOME/.aws/credentials}"
function awskeys {
function awskeys()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
about 'helper function for AWS credentials file'
group 'aws'
if [[ ! -f "${AWS_SHARED_CREDENTIALS_FILE}" ]]; then
if [[ ! -f "${AWS_SHARED_CREDENTIALS_FILE}" ]]
then
echo "AWS credentials file not found"
return 1
fi
if [[ $# -eq 1 ]] && [[ "$1" = "list" ]]; then
__awskeys_list "$2"
elif [[ $# -eq 1 ]] && [[ "$1" = "unset" ]]; then
__awskeys_unset "$2"
elif [[ $# -eq 2 ]] && [[ "$1" = "show" ]]; then
__awskeys_show "$2"
elif [[ $# -eq 2 ]] && [[ "$1" = "export" ]]; then
__awskeys_export "$2"
if [[ $# -eq 1 ]] && [[ "${1}" = "list" ]]
then
__awskeys_list "${2}"
elif [[ $# -eq 1 ]] && [[ "${1}" = "unset" ]]
then
__awskeys_unset "${2}"
elif [[ $# -eq 2 ]] && [[ "${1}" = "show" ]]
then
__awskeys_show "${2}"
elif [[ $# -eq 2 ]] && [[ "${1}" = "export" ]]
then
__awskeys_export "${2}"
else
__awskeys_help
fi
}
function __awskeys_help {
function __awskeys_help()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
echo -e "Usage: awskeys [COMMAND] [profile]\n"
echo -e "Helper to AWS credentials file.\n"
echo -e "Commands:\n"
@ -36,19 +54,41 @@ function __awskeys_help {
echo " show Show the AWS keys associated to a credentials profile"
echo " export Export an AWS credentials profile keys as environment variables"
echo " unset Unset the AWS keys variables from the environment"
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
function __awskeys_get {
function __awskeys_get()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
local ln=$(grep -n "\[ *$1 *\]" "${AWS_SHARED_CREDENTIALS_FILE}" | cut -d ":" -f 1)
if [[ -n "${ln}" ]]; then
if [[ -n "${ln}" ]]
then
tail -n +${ln} "${AWS_SHARED_CREDENTIALS_FILE}" | grep -F -m 2 -e "aws_access_key_id" -e "aws_secret_access_key"
tail -n +${ln} "${AWS_SHARED_CREDENTIALS_FILE}" | grep -F -m 1 "aws_session_token"
fi
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
function __awskeys_list {
function __awskeys_list()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
local credentials_list="$((grep -E '^\[ *[a-zA-Z0-9_-]+ *\]$' "${AWS_SHARED_CREDENTIALS_FILE}"; grep "\[profile" "${AWS_CONFIG_FILE}" | sed "s|\[profile |\[|g") | sort | uniq)"
if [[ -n $"{credentials_list}" ]]; then
if [[ -n $"{credentials_list}" ]]
then
echo -e "Available credentials profiles:\n"
for profile in ${credentials_list}; do
echo " $(echo ${profile} | tr -d "[]")"
@ -57,37 +97,80 @@ function __awskeys_list {
else
echo "No profiles found in credentials file"
fi
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
function __awskeys_show {
function __awskeys_show()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
local p_keys="$(__awskeys_get $1)"
if [[ -n "${p_keys}" ]]; then
if [[ -n "${p_keys}" ]]
then
echo "${p_keys}"
else
echo "Profile $1 not found in credentials file"
fi
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
function __awskeys_export {
if [[ $(__awskeys_list) == *"$1"* ]]; then
function __awskeys_export()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
if [[ $(__awskeys_list) == *"${1}"* ]]
then
local p_keys=( $(__awskeys_get $1 | tr -d " ") )
if [[ -n "${p_keys}" ]]; then
if [[ -n "${p_keys}" ]]
then
for p_key in ${p_keys[@]}; do
local key="${p_key%=*}"
export "$(echo ${key} | tr [:lower:] [:upper:])=${p_key#*=}"
done
fi
export AWS_PROFILE="$1"
export AWS_PROFILE="${1}"
else
echo "Profile $1 not found in credentials file"
fi
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
function __awskeys_unset {
function __awskeys_unset()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
unset AWS_PROFILE AWS_ACCESS_KEY_ID AWS_SECRET_ACCESS_KEY AWS_SESSION_TOKEN
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
function __awskeys_comp {
function __awskeys_comp()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
local cur prev opts prevprev
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
@ -109,6 +192,10 @@ function __awskeys_comp {
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
return 0
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
complete -F __awskeys_comp awskeys

View File

@ -2,55 +2,100 @@
cite about-plugin
about-plugin 'miscellaneous tools'
function ips() {
function ips()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
about 'display all ip addresses for this host'
group 'base'
if _command_exists ifconfig; then
if _command_exists ifconfig
then
ifconfig | awk '/inet /{ gsub(/addr:/, ""); print $2 }'
elif _command_exists ip; then
elif _command_exists ip
then
ip addr | grep -oP 'inet \K[\d.]+'
else
echo "You don't have ifconfig or ip command installed!"
fi
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
function down4me() {
function down4me()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
about 'checks whether a website is down for you, or everybody'
param '1: website url'
example '$ down4me http://www.google.com'
group 'base'
curl -Ls "http://downforeveryoneorjustme.com/$1" | sed '/just you/!d;s/<[^>]*>//g'
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
function myip() {
function myip()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
about 'displays your ip address, as seen by the Internet'
group 'base'
list=("http://myip.dnsomatic.com/" "http://checkip.dyndns.com/" "http://checkip.dyndns.org/")
for url in "${list[@]}"; do
if res="$(curl -fs "${url}")"; then
if res="$(curl -fs "${url}")"
then
break
fi
done
res="$(echo "$res" | grep -Eo '[0-9\.]+')"
echo -e "Your public IP is: ${echo_bold_green-} $res ${echo_normal-}"
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
function pickfrom() {
function pickfrom()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
about 'picks random line from file'
param '1: filename'
example '$ pickfrom /usr/share/dict/words'
group 'base'
local file=${1:-}
local -i n=0 length
if [[ ! -r "$file" ]]; then
if [[ ! -r "$file" ]]
then
reference "${FUNCNAME[0]}" && return
fi
length="$(wc -l < "$file")"
n=$((RANDOM * length / 32768 + 1))
head -n "$n" "$file" | tail -1
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
function passgen() {
function passgen()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
about 'generates random password from dictionary words'
param 'optional integer length'
param 'if unset, defaults to 4'
@ -63,16 +108,27 @@ function passgen() {
pass="$(for i in $(eval "echo {1..$length}"); do pickfrom /usr/share/dict/words; done)"
echo "With spaces (easier to memorize): ${pass//$'\n'/ }"
echo "Without spaces (easier to brute force): ${pass//$'\n'/}"
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
# Create alias pass to passgen when pass isn't installed or
# BASH_IT_LEGACY_PASS is true.
if ! _command_exists pass || [[ "${BASH_IT_LEGACY_PASS:-}" == true ]]; then
if ! _command_exists pass || [[ "${BASH_IT_LEGACY_PASS:-}" == true ]]
then
alias pass=passgen
fi
if _command_exists markdown && _command_exists browser; then
function pmdown() {
if _command_exists markdown && _command_exists browser
then
function pmdown()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
about 'preview markdown file in a browser'
param '1: markdown file'
example '$ pmdown README.md'
@ -82,7 +138,12 @@ if _command_exists markdown && _command_exists browser; then
}
fi
function mkcd() {
function mkcd()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
about 'make one or more directories and cd into the last one'
param 'one or more directories to create'
example '$ mkcd foo'
@ -90,96 +151,169 @@ function mkcd() {
example '$ mkcd foo foo1 foo2 fooN'
example '$ mkcd /tmp/img/photos/large /tmp/img/photos/self /tmp/img/photos/Beijing'
group 'base'
mkdir -p -- "$@" && cd -- "${!#}" || return
mkdir -p -- "${@}" && cd -- "${!#}" || return
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
# shellcheck disable=SC2010
function lsgrep() {
function lsgrep()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
about 'search through directory contents with grep'
group 'base'
ls | grep "$@"
ls | grep "${@}"
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
function quiet() {
function quiet()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
about 'what *does* this do?'
group 'base'
nohup "$@" &> /dev/null < /dev/null &
nohup "${@}" &> /dev/null < /dev/null &
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
function usage() {
function usage()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
about 'disk usage per directory, in Mac OS X and Linux'
param '1: directory name'
group 'base'
case $OSTYPE in
*'darwin'*)
du -hd 1 "$@"
du -hd 1 "${@}"
;;
*'linux'*)
du -h --max-depth=1 "$@"
du -h --max-depth=1 "${@}"
;;
esac
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
function t() {
function t()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
about 'todo.sh if available, otherwise one thing todo'
param 'if not set, display todo item'
param '1: todo text'
local todotxt="${XDG_STATE_HOME:-~/.local/state}/bash_it/todo.txt"
if _bash-it-component-item-is-enabled plugin todo; then
todo.sh "$@"
if _bash-it-component-item-is-enabled plugin todo
then
todo.sh "${@}"
return
elif [[ ! -f "${todotxt}" && -f ~/.t ]]; then
elif [[ ! -f "${todotxt}" && -f ~/.t ]]
then
mv -vn ~/.t "${todotxt}" # Verbose, so the user knows. Don't overwrite, just in case.
fi
if [[ "$#" -eq 0 ]]; then
if [[ "$#" -eq 0 ]]
then
cat "${todotxt}"
else
echo "$@" >| "${todotxt}"
echo "${@}" >| "${todotxt}"
fi
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
if _command_exists mkisofs; then
function mkiso() {
about 'creates iso from current dir in the parent dir (unless defined)'
param '1: ISO name'
param '2: dest/path'
param '3: src/path'
example 'mkiso'
example 'mkiso ISO-Name dest/path src/path'
group 'base'
if _command_exists mkisofs
then
function mkiso()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
about 'creates iso from current dir in the parent dir (unless defined)'
param '1: ISO name'
param '2: dest/path'
param '3: src/path'
example 'mkiso'
example 'mkiso ISO-Name dest/path src/path'
group 'base'
local isoname="${1:-${PWD##*/}}"
local destpath="${2:-../}"
local srcpath="${3:-${PWD}}"
local isoname="${1:-${PWD##*/}}"
local destpath="${2:-../}"
local srcpath="${3:-${PWD}}"
if [[ ! -f "${destpath%/}/${isoname}.iso" ]]; then
echo "writing ${isoname}.iso to ${destpath} from ${srcpath}"
mkisofs -V "${isoname}" -iso-level 3 -r -o "${destpath%/}/${isoname}.iso" "${srcpath}"
else
echo "${destpath%/}/${isoname}.iso already exists"
fi
}
if [[ ! -f "${destpath%/}/${isoname}.iso" ]]
then
echo "writing ${isoname}.iso to ${destpath} from ${srcpath}"
mkisofs -V "${isoname}" -iso-level 3 -r -o "${destpath%/}/${isoname}.iso" "${srcpath}"
else
echo "${destpath%/}/${isoname}.iso already exists"
fi
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
fi
# useful for administrators and configs
function buf() {
function buf()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
about 'back up file with timestamp'
param 'filename'
group 'base'
local filename="${1?}" filetime
filetime=$(date +%Y%m%d_%H%M%S)
cp -a "${filename}" "${filename}_${filetime}"
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
if ! _command_exists del; then
function del() {
about 'move files to hidden folder in tmp, that gets cleared on each reboot'
param 'file or folder to be deleted'
example 'del ./file.txt'
group 'base'
mkdir -p /tmp/.trash && mv "$@" /tmp/.trash
}
if ! _command_exists del
then
function del()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
about 'move files to hidden folder in tmp, that gets cleared on each reboot'
param 'file or folder to be deleted'
example 'del ./file.txt'
group 'base'
mkdir -p /tmp/.trash && mv "${@}" /tmp/.trash
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
fi

View File

@ -4,9 +4,11 @@ about-plugin 'initializes basher, the shell package manager'
# https://github.com/basherpm/basher
if ! _command_exists basher; then
if [[ -x "$HOME/.basher/bin/basher" ]]; then
pathmunge "$HOME/.basher/bin"
if ! _command_exists basher
then
if [[ -x "${HOME}/.basher/bin/basher" ]]
then
pathmunge "${HOME}/.basher/bin"
else
_log_warning 'basher not found'
return 0

View File

@ -1,67 +1,115 @@
# shellcheck shell=bash
about-plugin 'display info about your battery charge level'
function ac_adapter_connected() {
function ac_adapter_connected()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
local batteries
if _command_exists upower; then
if _command_exists upower
then
IFS=$'\n' read -d '' -ra batteries < <(upower -e | grep -i BAT)
upower -i "${batteries[0]:-}" | grep 'state' | grep -q 'charging\|fully-charged'
elif _command_exists acpi; then
elif _command_exists acpi
then
acpi -a | grep -q "on-line"
elif _command_exists pmset; then
elif _command_exists pmset
then
pmset -g batt | grep -q 'AC Power'
elif _command_exists ioreg; then
elif _command_exists ioreg
then
ioreg -n AppleSmartBattery -r | grep -q '"ExternalConnected" = Yes'
elif _command_exists WMIC; then
elif _command_exists WMIC
then
WMIC Path Win32_Battery Get BatteryStatus /Format:List | grep -q 'BatteryStatus=2'
fi
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
function ac_adapter_disconnected() {
function ac_adapter_disconnected()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
local batteries
if _command_exists upower; then
if _command_exists upower
then
IFS=$'\n' read -d '' -ra batteries < <(upower -e | grep -i BAT)
upower -i "${batteries[0]:-}" | grep 'state' | grep -q 'discharging'
elif _command_exists acpi; then
elif _command_exists acpi
then
acpi -a | grep -q "off-line"
elif _command_exists pmset; then
elif _command_exists pmset
then
pmset -g batt | grep -q 'Battery Power'
elif _command_exists ioreg; then
elif _command_exists ioreg
then
ioreg -n AppleSmartBattery -r | grep -q '"ExternalConnected" = No'
elif _command_exists WMIC; then
elif _command_exists WMIC
then
WMIC Path Win32_Battery Get BatteryStatus /Format:List | grep -q 'BatteryStatus=1'
fi
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
function battery_percentage() {
function battery_percentage()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
about 'displays battery charge as a percentage of full (100%)'
group 'battery'
local command_output batteries
if _command_exists upower; then
if _command_exists upower
then
IFS=$'\n' read -d '' -ra batteries < <(upower -e | grep -i BAT)
command_output="$(upower --show-info "${batteries[0]:-}" | grep percentage | grep -o '[0-9]\+' | head -1)"
elif _command_exists acpi; then
elif _command_exists acpi
then
command_output=$(acpi -b | awk -F, '/,/{gsub(/ /, "", $0); gsub(/%/,"", $0); print $2}')
elif _command_exists pmset; then
elif _command_exists pmset
then
command_output=$(pmset -g ps | sed -n 's/.*[[:blank:]]+*\(.*%\).*/\1/p' | grep -o '[0-9]\+' | head -1)
elif _command_exists ioreg; then
elif _command_exists ioreg
then
command_output=$(ioreg -n AppleSmartBattery -r | awk '$1~/Capacity/{c[$1]=$3} END{OFMT="%05.2f"; max=c["\"MaxCapacity\""]; print (max>0? 100*c["\"CurrentCapacity\""]/max: "?")}' | grep -o '[0-9]\+' | head -1)
elif _command_exists WMIC; then
elif _command_exists WMIC
then
command_output=$(WMIC PATH Win32_Battery Get EstimatedChargeRemaining /Format:List | grep -o '[0-9]\+' | head -1)
else
command_output="no"
fi
if [[ "${command_output}" != "no" ]]; then
if [[ "${command_output}" != "no" ]]
then
printf "%02d" "${command_output:--1}"
else
echo "${command_output}"
fi
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
function battery_charge() {
function battery_charge()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
about 'graphical display of your battery charge'
group 'battery'
@ -127,4 +175,8 @@ function battery_charge() {
echo "${danger_color}UNPLG${normal?}"
;;
esac
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}

View File

@ -2,13 +2,15 @@
cite about-plugin
about-plugin 'load ble.sh, the Bash line editor!'
if [[ ${BLE_VERSION-} ]]; then
if [[ ${BLE_VERSION-} ]]
then
_log_warning "ble.sh is already loaded!"
return
fi
_bash_it_ble_path=${XDG_DATA_HOME:-$HOME/.local/share}/blesh/ble.sh
if [[ -f $_bash_it_ble_path ]]; then
if [[ -f $_bash_it_ble_path ]]
then
# shellcheck disable=1090
source "$_bash_it_ble_path" --attach=prompt
else

View File

@ -3,7 +3,8 @@ about-plugin 'Helpers to get Docker setup correctly for boot2docker'
# Note, this might need to be different if you have an older version
# of boot2docker, or its configured for a different IP
if [[ "$OSTYPE" == 'darwin'* ]]; then
if [[ "$OSTYPE" == 'darwin'* ]]
then
export DOCKER_HOST="tcp://192.168.59.103:2376"
export DOCKER_CERT_PATH="~/.boot2docker/certs/boot2docker-vm"
export DOCKER_TLS_VERIFY=1

View File

@ -3,14 +3,21 @@
cite about-plugin
about-plugin 'render commandline output in your browser'
function browser() {
function browser()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
about 'pipe html to a browser'
example '$ echo "<h1>hi mom!</h1>" | browser'
example '$ ron -5 man/rip.5.ron | browser'
group 'browser'
if [ -t 0 ]; then
if [ -n "$1" ]; then
if [ -t 0 ]
then
if [ -n "${1}" ]
then
open $1
else
reference browser
@ -21,16 +28,27 @@ function browser() {
cat /dev/stdin > $f
open $f
fi
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
function wmate() {
function wmate()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
about 'pipe hot spicy interwebs into textmate and cleanup!'
example '$ wmate google.com'
group 'browser'
if [ -t 0 ]; then
if [ -n "$1" ]; then
if [ -t 0 ]
then
if [ -n "${1}" ]
then
wget -qO- $1 | /usr/bin/mate
TIDY=`/usr/bin/osascript << EOT
@ -59,18 +77,33 @@ EOT`
reference wmate
fi
fi
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
function raw() {
function raw()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
about 'write wget into a temp file and pump it into your browser'
example '$ raw google.com'
group 'browser'
if [ -t 0 ]; then
if [ -n "$1" ]; then
if [ -t 0 ]
then
if [ -n "${1}" ]
then
wget -qO- $1 | browser
else
reference raw
fi
fi
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}

View File

@ -2,20 +2,30 @@ cite about-plugin
about-plugin 'Simplify `curl cht.sh/<query>` to `cht.sh <query>`'
# Play nicely if user already installed cht.sh cli tool
if ! _command_exists cht.sh ; then
function cht.sh () {
about 'Executes a cht.sh curl query using the provided arguments'
param ' [ ( topic [sub-topic] ) | ~keyword ] [ :list | :help | :learn ]'
example '$ cht.sh :help'
example '$ cht.sh :list'
example '$ cht.sh tar'
example '$ cht.sh js "parse json"'
example '$ cht.sh python :learn'
example '$ cht.sh rust :list'
group 'cht-sh'
if ! _command_exists cht.sh
then
function cht.sh ()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
about 'Executes a cht.sh curl query using the provided arguments'
param ' [ ( topic [sub-topic] ) | ~keyword ] [ :list | :help | :learn ]'
example '$ cht.sh :help'
example '$ cht.sh :list'
example '$ cht.sh tar'
example '$ cht.sh js "parse json"'
example '$ cht.sh python :learn'
example '$ cht.sh rust :list'
group 'cht-sh'
# Separate arguments with '/', preserving spaces within them
local query=$(IFS=/ ; echo "$*")
curl "cht.sh/${query}"
}
# Separate arguments with '/', preserving spaces within them
local query=$(IFS=/ ; echo "$*")
curl "cht.sh/${query}"
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
fi

View File

@ -2,15 +2,25 @@
cite about-plugin
about-plugin 'Alert (BEL) when process ends after a threshold of seconds'
function precmd_return_notification() {
function precmd_return_notification()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
local command_start="${COMMAND_DURATION_START_SECONDS:=0}"
local current_time
current_time="$(_shell_duration_en)"
local -i command_duration="$((${current_time%.*} - ${command_start%.*}))"
if [[ "${command_duration}" -gt "${NOTIFY_IF_COMMAND_RETURNS_AFTER:-5}" ]]; then
if [[ "${command_duration}" -gt "${NOTIFY_IF_COMMAND_RETURNS_AFTER:-5}" ]]
then
printf '\a'
fi
return 0
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
safe_append_prompt_command 'precmd_return_notification'

View File

@ -1,138 +1,345 @@
# shellcheck shell=bash
# shellcheck disable=SC2005
function __() {
echo "$@"
function __()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
echo "${@}"
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
function __make_ansi() {
next=$1
function __make_ansi()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
next="${1}"
shift
echo -e "\[\e[$("__$next" "$@")m\]"
echo -e "\[\e[$("__$next" "${@}")m\]"
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
function __make_echo() {
next=$1
function __make_echo()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
next="${1}"
shift
echo -e "\033[$("__$next" "$@")m"
echo -e "\033[$("__$next" "${@}")m"
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
function __reset() {
next=$1
function __reset()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
next="${1}"
shift
out="$("__$next" "$@")"
out="$("__$next" "${@}")"
echo "0${out:+;${out}}"
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
function __bold() {
next=$1
function __bold()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
next="${1}"
shift
out="$("__$next" "$@")"
out="$("__$next" "${@}")"
echo "${out:+${out};}1"
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
function __faint() {
next=$1
function __faint()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
next="${1}"
shift
out="$("__$next" "$@")"
out="$("__$next" "${@}")"
echo "${out:+${out};}2"
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
function __italic() {
next=$1
function __italic()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
next="${1}"
shift
out="$("__$next" "$@")"
out="$("__$next" "${@}")"
echo "${out:+${out};}3"
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
function __underline() {
next=$1
function __underline()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
next="${1}"
shift
out="$("__$next" "$@")"
out="$("__$next" "${@}")"
echo "${out:+${out};}4"
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
function __negative() {
next=$1
function __negative()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
next="${1}"
shift
out="$("__$next" "$@")"
out="$("__$next" "${@}")"
echo "${out:+${out};}7"
}
function __crossed() {
next=$1
function __crossed()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
next="${1}"
shift
out="$("__$next" "$@")"
out="$("__$next" "${@}")"
echo "${out:+${out};}8"
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
function __color_normal_fg() {
function __color_normal_fg()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
echo "3$1"
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
function __color_normal_bg() {
function __color_normal_bg()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
echo "4$1"
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
function __color_bright_fg() {
function __color_bright_fg()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
echo "9$1"
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
function __color_bright_bg() {
function __color_bright_bg()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
echo "10$1"
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
function __color_black() {
function __color_black()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
echo "0"
}
function __color_red() {
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
function __color_red()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
echo "1"
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
function __color_green() {
function __color_green()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
echo "2"
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
function __color_yellow() {
function __color_yellow()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
echo "3"
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
function __color_blue() {
function __color_blue()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
echo "4"
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
function __color_magenta() {
function __color_magenta()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
echo "5"
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
function __color_cyan() {
function __color_cyan()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
echo "6"
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
function __color_white() {
function __color_white()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
echo "7"
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
function __color_rgb() {
r=$1 && g=$2 && b=$3
function __color_rgb()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
r="${1}" && g="${2}" && b=$3
[[ $r == "$g" && $g == "$b" ]] && echo $((r / 11 + 232)) && return # gray range above 232
echo "8;5;$(((r * 36 + b * 6 + g) / 51 + 16))"
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
function __color() {
color="$1"
function __color()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
color="${1}"
shift
case "$1" in
case "${1}" in
fg | bg)
side="$1"
side="${1}"
shift
;;
*) side="fg" ;;
esac
case "$1" in
case "${1}" in
normal | bright)
mode="$1"
mode="${1}"
shift
;;
*) mode=normal ;;
@ -140,58 +347,170 @@ function __color() {
[[ $color == "rgb" ]] && rgb="$1 $2 $3"
shift 3
next=$1
next="${1}"
shift
out="$("__$next" "$@")"
out="$("__$next" "${@}")"
echo "$("__color_${mode}_${side}" "$("__color_${color}" "$rgb")")${out:+;${out}}"
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
function __black() {
echo "$(__color black "$@")"
function __black()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
echo "$(__color black "${@}")"
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
function __red() {
echo "$(__color red "$@")"
function __red()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
echo "$(__color red "${@}")"
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
function __green() {
echo "$(__color green "$@")"
function __green()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
echo "$(__color green "${@}")"
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
function __yellow() {
echo "$(__color yellow "$@")"
function __yellow()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
echo "$(__color yellow "${@}")"
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
function __blue() {
echo "$(__color blue "$@")"
function __blue()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
echo "$(__color blue "${@}")"
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
function __magenta() {
echo "$(__color magenta "$@")"
function __magenta()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
echo "$(__color magenta "${@}")"
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
function __cyan() {
echo "$(__color cyan "$@")"
function __cyan()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
echo "$(__color cyan "${@}")"
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
function __white() {
echo "$(__color white "$@")"
function __white()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
echo "$(__color white "${@}")"
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
function __rgb() {
echo "$(__color rgb "$@")"
function __rgb()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
echo "$(__color rgb "${@}")"
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
function __color_parse() {
next=$1
function __color_parse()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
next="${1}"
shift
echo "$("__$next" "$@")"
echo "$("__$next" "${@}")"
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
function color() {
echo "$(__color_parse make_ansi "$@")"
function color()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
echo "$(__color_parse make_ansi "${@}")"
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
function echo_color() {
echo "$(__color_parse make_echo "$@")"
function echo_color()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
echo "$(__color_parse make_echo "${@}")"
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}

View File

@ -2,6 +2,7 @@
cite about-plugin
about-plugin 'load direnv, if you are using it: https://direnv.net/'
if _command_exists direnv; then
if _command_exists direnv
then
eval "$(direnv hook bash)"
fi

View File

@ -32,7 +32,12 @@ alias pu="pushd"
# Pop current location
alias po="popd"
function dirs-help() {
function dirs-help()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
about 'directory navigation alias usage'
group 'dirs'
@ -54,18 +59,24 @@ function dirs-help() {
echo "7 : Change to stack location 7."
echo "8 : Change to stack location 8."
echo "9 : Change to stack location 9."
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
# Add bookmarking functionality
# Usage:
: "${BASH_IT_DIRS_BKS:=${XDG_STATE_HOME:-${HOME}/.local/state}/bash_it/dirs}"
if [[ -f "${BASH_IT_DIRS_BKS?}" ]]; then
if [[ -f "${BASH_IT_DIRS_BKS?}" ]]
then
# shellcheck disable=SC1090
source "${BASH_IT_DIRS_BKS?}"
else
mkdir -p "${BASH_IT_DIRS_BKS%/*}"
if [[ -f ~/.dirs ]]; then
if [[ -f ~/.dirs ]]
then
mv -vn ~/.dirs "${BASH_IT_DIRS_BKS?}"
# shellcheck disable=SC1090
source "${BASH_IT_DIRS_BKS?}"
@ -77,16 +88,30 @@ fi
alias L='cat "${BASH_IT_DIRS_BKS?}"'
# Goes to destination dir, otherwise stay in the dir
function G() {
function G()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
about 'goes to destination dir'
param '1: directory'
example '$ G ..'
group 'dirs'
cd "${1:-${PWD}}" || return
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
function S() {
function S()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
about 'save a bookmark'
param '1: bookmark name'
example '$ S mybkmrk'
@ -99,12 +124,21 @@ function S() {
sed "/$1/d" "${BASH_IT_DIRS_BKS?}" > "${BASH_IT_DIRS_BKS?}.new"
command mv "${BASH_IT_DIRS_BKS?}.new" "${BASH_IT_DIRS_BKS?}"
echo "$1"=\""${PWD}"\" >> "${BASH_IT_DIRS_BKS?}"
echo "${1}"=\""${PWD}"\" >> "${BASH_IT_DIRS_BKS?}"
# shellcheck disable=SC1090
source "${BASH_IT_DIRS_BKS?}"
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
function R() {
function R()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
about 'remove a bookmark'
param '1: bookmark name'
example '$ R mybkmrk'
@ -117,6 +151,10 @@ function R() {
sed "/$1/d" "${BASH_IT_DIRS_BKS?}" > "${BASH_IT_DIRS_BKS?}.new"
command mv "${BASH_IT_DIRS_BKS?}.new" "${BASH_IT_DIRS_BKS?}"
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
alias U='source "${BASH_IT_DIRS_BKS?}"' # Update bookmark stack

View File

@ -1,14 +1,20 @@
cite about-plugin
about-plugin 'Helper functions for using docker-compose'
function docker-compose-fresh() {
function docker-compose-fresh()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
about 'Shut down, remove and start again the docker-compose setup, then tail the logs'
group 'docker-compose'
param '1: name of the docker-compose.yaml file to use (optional). Default: docker-compose.yaml'
example 'docker-compose-fresh docker-compose-foo.yaml'
local DCO_FILE_PARAM=""
if [ -n "$1" ]; then
if [ -n "${1}" ]
then
echo "Using docker-compose file: $1"
DCO_FILE_PARAM="--file $1"
fi
@ -17,4 +23,8 @@ function docker-compose-fresh() {
docker-compose $DCO_FILE_PARAM rm -f
docker-compose $DCO_FILE_PARAM up -d
docker-compose $DCO_FILE_PARAM logs -f --tail 100
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}

View File

@ -1,38 +1,80 @@
cite about-plugin
about-plugin 'Helpers to more easily work with Docker'
function docker-remove-most-recent-container() {
function docker-remove-most-recent-container()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
about 'attempt to remove the most recent container from docker ps -a'
group 'docker'
docker ps -ql | xargs docker rm
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
function docker-remove-most-recent-image() {
function docker-remove-most-recent-image()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
about 'attempt to remove the most recent image from docker images'
group 'docker'
docker images -q | head -1 | xargs docker rmi
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
function docker-remove-stale-assets() {
function docker-remove-stale-assets()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
about 'attempt to remove exited containers and dangling images'
group 'docker'
docker ps --filter status=exited -q | xargs docker rm --volumes
docker images --filter dangling=true -q | xargs docker rmi
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
function docker-enter() {
function docker-enter()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
about 'enter the specified docker container using bash'
group 'docker'
param '1: Name of the container to enter'
example 'docker-enter oracle-xe'
docker exec -it "$@" /bin/bash;
docker exec -it "${@}" /bin/bash;
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
function docker-remove-images() {
function docker-remove-images()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
about 'attempt to remove images with supplied tags or all if no tags are supplied'
group 'docker'
if [ -z "$1" ]; then
if [ -z "${1}" ]
then
docker rmi $(docker images -q)
else
DOCKER_IMAGES=""
@ -42,12 +84,22 @@ function docker-remove-images() {
# Strip out duplicate IDs before attempting to remove the image(s)
docker rmi $(echo ${ID_ARRAY[@]} | tr ' ' '\n' | sort -u | tr '\n' ' ')
fi
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
function docker-image-dependencies() {
function docker-image-dependencies()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
about 'attempt to create a Graphiz image of the supplied image ID dependencies'
group 'docker'
if hash dot 2>/dev/null; then
if hash dot 2>/dev/null
then
OUT=$(mktemp -t docker-viz-XXXX.png)
docker images -viz | dot -Tpng > $OUT
case $OSTYPE in
@ -61,21 +113,44 @@ function docker-image-dependencies() {
else
>&2 echo "Can't show dependencies; Graphiz is not installed"
fi
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
function docker-runtime-environment() {
function docker-runtime-environment()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
about 'attempt to list the environmental variables of the supplied image ID'
group 'docker'
docker run "$@" env
docker run "${@}" env
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
function docker-archive-content() {
function docker-archive-content()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
about 'show the content of the provided Docker image archive'
group 'docker'
param '1: image archive name'
example 'docker-archive-content images.tar.gz'
if [ -n "$1" ]; then
if [ -n "${1}" ]
then
tar -xzOf $1 manifest.json | jq '[.[] | .RepoTags] | add'
fi
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}

View File

@ -1,23 +1,35 @@
cite about-plugin
about-plugin 'mankier.com explain function to explain other commands'
explain () {
function explain ()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
about 'explain any bash command via mankier.com manpage API'
param '1: Name of the command to explain'
example '$ explain # interactive mode. Type commands to explain in REPL'
example '$ explain '"'"'cmd -o | ...'"'"' # one quoted command to explain it.'
group 'explain'
if [ "$#" -eq 0 ]; then
if [ "$#" -eq 0 ]
then
while read -p "Command: " cmd; do
curl -Gs "https://www.mankier.com/api/explain/?cols="$(tput cols) --data-urlencode "q=$cmd"
done
echo "Bye!"
elif [ "$#" -eq 1 ]; then
curl -Gs "https://www.mankier.com/api/explain/?cols="$(tput cols) --data-urlencode "q=$1"
elif [ "$#" -eq 1 ]
then
curl -Gs "https://www.mankier.com/api/explain/?cols="$(tput cols) --data-urlencode "q="${1}""
else
echo "Usage"
echo "explain interactive mode."
echo "explain 'cmd -o | ...' one quoted command to explain it."
fi
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}

View File

@ -2,7 +2,12 @@ cite about-plugin
about-plugin 'one command to extract them all...'
# extract file(s) from compressed status
extract() {
function extract()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
local opt
local OPTIND=1
while getopts "hv" opt; do
@ -29,7 +34,8 @@ End-Of-Usage
[ $# -eq 0 ] && extract -h && return 1
while [ $# -gt 0 ]; do
if [[ ! -f "$1" ]]; then
if [[ ! -f "${1}" ]]
then
echo "extract: '$1' is not a valid file" >&2
shift
continue
@ -38,36 +44,42 @@ End-Of-Usage
local -r filename=$(basename -- $1)
local -r filedirname=$(dirname -- $1)
local targetdirname=$(sed 's/\(\.tar\.bz2$\|\.tbz$\|\.tbz2$\|\.tar\.gz$\|\.tgz$\|\.tar$\|\.tar\.xz$\|\.txz$\|\.tar\.Z$\|\.7z$\|\.nupkg$\|\.zip$\|\.war$\|\.jar$\)//g' <<< $filename)
if [ "$filename" = "$targetdirname" ]; then
if [ "$filename" = "$targetdirname" ]
then
# archive type either not supported or it doesn't need dir creation
targetdirname=""
else
mkdir -v "$filedirname/$targetdirname"
fi
if [ -f "$1" ]; then
case "$1" in
*.tar.bz2|*.tbz|*.tbz2) tar "x${verbose}jf" "$1" -C "$filedirname/$targetdirname" ;;
*.tar.gz|*.tgz) tar "x${verbose}zf" "$1" -C "$filedirname/$targetdirname" ;;
*.tar.xz|*.txz) tar "x${verbose}Jf" "$1" -C "$filedirname/$targetdirname" ;;
*.tar.Z) tar "x${verbose}Zf" "$1" -C "$filedirname/$targetdirname" ;;
*.bz2) bunzip2 "$1" ;;
*.deb) dpkg-deb -x${verbose} "$1" "${1:0:-4}" ;;
*.pax.gz) gunzip "$1"; set -- "$@" "${1:0:-3}" ;;
*.gz) gunzip "$1" ;;
*.pax) pax -r -f "$1" ;;
*.pkg) pkgutil --expand "$1" "${1:0:-4}" ;;
*.rar) unrar x "$1" ;;
*.rpm) rpm2cpio "$1" | cpio -idm${verbose} ;;
*.tar) tar "x${verbose}f" "$1" -C "$filedirname/$targetdirname" ;;
*.xz) xz --decompress "$1" ;;
*.zip|*.war|*.jar|*.nupkg) unzip "$1" -d "$filedirname/$targetdirname" ;;
*.Z) uncompress "$1" ;;
*.7z) 7za x -o"$filedirname/$targetdirname" "$1" ;;
if [ -f "${1}" ]
then
case "${1}" in
*.tar.bz2|*.tbz|*.tbz2) tar "x${verbose}jf" "${1}" -C "$filedirname/$targetdirname" ;;
*.tar.gz|*.tgz) tar "x${verbose}zf" "${1}" -C "$filedirname/$targetdirname" ;;
*.tar.xz|*.txz) tar "x${verbose}Jf" "${1}" -C "$filedirname/$targetdirname" ;;
*.tar.Z) tar "x${verbose}Zf" "${1}" -C "$filedirname/$targetdirname" ;;
*.bz2) bunzip2 "${1}" ;;
*.deb) dpkg-deb -x${verbose} "${1}" "${1:0:-4}" ;;
*.pax.gz) gunzip "${1}"; set -- "${@}" "${1:0:-3}" ;;
*.gz) gunzip "${1}" ;;
*.pax) pax -r -f "${1}" ;;
*.pkg) pkgutil --expand "${1}" "${1:0:-4}" ;;
*.rar) unrar x "${1}" ;;
*.rpm) rpm2cpio "${1}" | cpio -idm${verbose} ;;
*.tar) tar "x${verbose}f" "${1}" -C "$filedirname/$targetdirname" ;;
*.xz) xz --decompress "${1}" ;;
*.zip|*.war|*.jar|*.nupkg) unzip "${1}" -d "$filedirname/$targetdirname" ;;
*.Z) uncompress "${1}" ;;
*.7z) 7za x -o"$filedirname/$targetdirname" "${1}" ;;
*) echo "'$1' cannot be extracted via extract" >&2;;
esac
fi
shift
done
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}

View File

@ -4,20 +4,28 @@
cite about-plugin
about-plugin 'load fzf, if you are using it'
if [ -r ~/.fzf.bash ] ; then
if [ -r ~/.fzf.bash ]
then
source ~/.fzf.bash
elif [ -r "${XDG_CONFIG_HOME:-$HOME/.config}"/fzf/fzf.bash ] ; then
elif [ -r "${XDG_CONFIG_HOME:-$HOME/.config}"/fzf/fzf.bash ]
then
source "${XDG_CONFIG_HOME:-$HOME/.config}"/fzf/fzf.bash
fi
# No need to continue if the command is not present
_command_exists fzf || return
if [ -z ${FZF_DEFAULT_COMMAND+x} ] && _command_exists fd ; then
if [ -z ${FZF_DEFAULT_COMMAND+x} ] && _command_exists fd
then
export FZF_DEFAULT_COMMAND='fd --type f'
fi
fe() {
function fe()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
about "Open the selected file in the default editor"
group "fzf"
param "1: Search term"
@ -25,11 +33,20 @@ fe() {
local IFS=$'\n'
local files
files=($(fzf-tmux --query="$1" --multi --select-1 --exit-0))
files=($(fzf-tmux --query="${1}" --multi --select-1 --exit-0))
[[ -n "$files" ]] && ${EDITOR:-vim} "${files[@]}"
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
fcd() {
function fcd()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
about "cd to the selected directory"
group "fzf"
param "1: Directory to browse, or . if omitted"
@ -39,4 +56,8 @@ fcd() {
dir=$(find ${1:-.} -path '*/\.*' -prune \
-o -type d -print 2> /dev/null | fzf +m) &&
cd "$dir"
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}

View File

@ -12,7 +12,12 @@ about-plugin 'video to gif, gif to WebM helper functions'
# Optional: if lossy is not important, Ubuntu has gifsicle packaged for apt-get, instead of giflossy
# Optional: gifski (from `brew install gifski` or github.com/ImageOptim/gifski)
# for high quality huge files.
function v2gif() {
function v2gif()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
about 'Converts a .mov/.avi/.mp4 file into an into an animated GIF.'
group 'gif'
param '1: MOV/AVI/MP4 file name(s)'
@ -54,7 +59,8 @@ function v2gif() {
}
getopt="$(type -p getopt)"
if [[ "$OSTYPE" == "darwin"* ]]; then
if [[ "$OSTYPE" == "darwin"* ]]
then
# Getopt on BSD is incompatible with GNU
getopt=/usr/local/opt/gnu-getopt/bin/getopt
[[ -x "$getopt" ]] || {
@ -64,7 +70,7 @@ function v2gif() {
fi
# Parse the options
args=$("$getopt" -l "alert:" -l "lossy:" -l "width:" -l del,delete -l high -l tag -l "fps:" -l webm -o "a:l:w:f:dhmt" -- "$@") || {
args=$("$getopt" -l "alert:" -l "lossy:" -l "width:" -l del,delete -l high -l tag -l "fps:" -l webm -o "a:l:w:f:dhmt" -- "${@}") || {
echo 'Terminating...' >&2
return 2
}
@ -83,7 +89,7 @@ function v2gif() {
local make_webm=""
local alert=5000
while [[ $# -ge 1 ]]; do
case "$1" in
case "${1}" in
--)
# No more options left.
shift
@ -106,7 +112,7 @@ function v2gif() {
shift
;;
-w | --width)
maxsize="-vf scale=$2:-1"
maxsize="-vf scale="${2}":-1"
maxwidthski="-W $2"
giftag="${giftag}-w$2"
shift 2
@ -118,19 +124,19 @@ function v2gif() {
;;
-l | --lossy)
# Use giflossy parameter
lossiness="--lossy=$2"
lossiness="--lossy="${2}""
giftag="${giftag}-l$2"
shift 2
;;
-f | --fps)
# select fps
infps="$2"
infps="${2}"
giftag="${giftag}-f$2"
shift 2
;;
-a | --alert)
# set size alert
alert="$2"
alert="${2}"
shift 2
;;
-m | --webm)
@ -141,7 +147,8 @@ function v2gif() {
esac
done
if [[ -z "$*" ]]; then
if [[ -z "$*" ]]
then
echo "$(tput setaf 1)No input files given. Example: v2gif file [file...] [-w <max width (pixels)>] [-l <lossy level>] $(tput sgr 0)"
echo "-d/--del/--delete Delete original vid if done suceessfully (and file not over the size limit)"
echo "-h/--high High Quality - use Gifski instead of gifsicle"
@ -163,18 +170,21 @@ function v2gif() {
local output_file="${file%.*}${giftag}.gif"
local del_after=$opt_del_after
if [[ -n "$make_webm" ]]; then
if [[ -n "$make_webm" ]]
then
$ffmpeg -loglevel panic -i "$file" \
-c:v libvpx -crf 4 -threads 0 -an -b:v 2M -auto-alt-ref 0 \
-quality best -loop 0 "${file%.*}.webm" || return 2
fi
# Set FPS to match the video if possible, otherwise fallback to default.
if [[ -n "$infps" ]]; then
if [[ -n "$infps" ]]
then
fps=$infps
else
fps=$defaultfps
if [[ -x "$mediainfo" ]]; then
if [[ -x "$mediainfo" ]]
then
fps=$($mediainfo "$file" | grep "Frame rate " | sed 's/.*: \([0-9.]\+\) .*/\1/' | head -1)
[[ -z "$fps" ]] && fps=$($mediainfo "$file" | grep "Minimum frame rate" | sed 's/.*: \([0-9.]\+\) .*/\1/' | head -1)
fi
@ -182,7 +192,8 @@ function v2gif() {
echo "$(tput setaf 2)Creating '$output_file' at $fps FPS ...$(tput sgr 0)"
if [[ "$use_gifski" = "true" ]]; then
if [[ "$use_gifski" = "true" ]]
then
# I trust @pornel to do his own resizing optimization choices
$ffmpeg -loglevel panic -i "$file" -r "$fps" -vcodec png v2gif-tmp-%05d.png \
&& $gifski v2gif-tmp-*.png "$maxwidthski" --fps "$(printf "%.0f" "$fps")" -o "$output_file" || return 2
@ -195,9 +206,11 @@ function v2gif() {
rm v2gif-tmp-*.png
# Checking if the file is bigger than Twitter likes and warn
if [[ $alert -gt 0 ]]; then
if [[ $alert -gt 0 ]]
then
out_size=$(wc --bytes < "$output_file")
if [[ $out_size -gt $((alert * 1000)) ]]; then
if [[ $out_size -gt $((alert * 1000)) ]]
then
echo "$(tput setaf 3)Warning: '$output_file' is $((out_size / 1000))kb.$(tput sgr 0)"
[[ "$del_after" == "true" ]] && echo "$(tput setaf 3)Warning: Keeping '$file' even though --del requested.$(tput sgr 0)"
del_after=""
@ -209,9 +222,18 @@ function v2gif() {
done
echo "$(tput setaf 2)Done.$(tput sgr 0)"
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}
function any2webm() {
function any2webm()
{
############ STACK_TRACE_BUILDER #####################
Function_Name="${FUNCNAME[0]}"
Function_PATH="${Function_PATH}/${Function_Name}"
######################################################
about 'Converts an movies and Animated GIF files into an into a modern quality WebM video.'
group 'gif'
param '1: GIF/video file name(s)'
@ -227,7 +249,7 @@ function any2webm() {
local args out_size
# Parse the options
args=$(getopt -l alert -l "bandwidth:" -l "width:" -l del,delete -l tag -l "fps:" -l webm -o "a:b:w:f:dt" -- "$@") || {
args=$(getopt -l alert -l "bandwidth:" -l "width:" -l del,delete -l tag -l "fps:" -l webm -o "a:b:w:f:dt" -- "${@}") || {
echo 'Terminating...' >&2
return 2
}
@ -242,7 +264,7 @@ function any2webm() {
local bandwidth="2M"
local alert=5000
while [[ $# -ge 1 ]]; do
case "$1" in
case "${1}" in
--)
# No more options left.
shift
@ -271,19 +293,20 @@ function any2webm() {
;;
-b | --bandwidth)
# select bandwidth
bandwidth="$2"
bandwidth="${2}"
webmtag="${webmtag}-b$2"
shift 2
;;
-a | --alert)
# set size alert
alert="$2"
alert="${2}"
shift 2
;;
esac
done
if [[ -z "$*" ]]; then
if [[ -z "$*" ]]
then
echo "$(tput setaf 1)No input files given. Example: any2webm file [file...] [-w <max width (pixels)>] < $(tput sgr 0)"
return 1
fi
@ -304,9 +327,11 @@ function any2webm() {
-quality best "$fps" "$size" -loop 0 -pix_fmt yuva420p "$output_file" || return 2
# Checking if the file is bigger than Twitter likes and warn
if [[ $alert -gt 0 ]]; then
if [[ $alert -gt 0 ]]
then
out_size=$(wc --bytes < "$output_file")
if [[ $out_size -gt $((alert * 1000)) ]]; then
if [[ $out_size -gt $((alert * 1000)) ]]
then
echo "$(tput setaf 3)Warning: '$output_file' is $((out_size / 1000))kb.$(tput sgr 0)"
[[ "$del_after" == "true" ]] && echo "$(tput setaf 3)Warning: Keeping '$file' even though --del requested.$(tput sgr 0)"
del_after=""
@ -318,4 +343,8 @@ function any2webm() {
done
echo "$(tput setaf 2)Done.$(tput sgr 0)"
############### Stack_TRACE_BUILDER ################
Function_PATH="$( dirname ${Function_PATH} )"
####################################################
}

View File

@ -1,7 +1,8 @@
# shellcheck shell=bash
about-plugin 'load git-subrepo if you are using it, and initialize completions'
if [[ -s "${GIT_SUBREPO_ROOT:=$HOME/.git-subrepo}/init" ]]; then
if [[ -s "${GIT_SUBREPO_ROOT:=$HOME/.git-subrepo}/init" ]]
then
# shellcheck disable=SC1091
source "$GIT_SUBREPO_ROOT/init"
fi

Some files were not shown because too many files have changed in this diff Show More