Merge branch 'master' of https://github.com/bash-it/bash-it into ira/autosave-history-plml
* 'master' of https://github.com/bash-it/bash-it: (114 commits) ci: Bump go to 1.17 from 1.14 skip go tests when go is not available plugins: Add ble.sh plugin clean up pyenv plugin Lint: prepare `lib/utilities` for `shellcheck` (#1933) plugin/base: improvements (#1930) plugins/percol: `bind` completion/git: `shfmt` && `shellcheck` completion/git: expand search range plugin/percol: `shellcheck` & `shfmt` plugins/percol: use `_command_exists` completion/pip: simplify code flow plugin/less-pretty-cat: remove `|| cat` completion/wpscan: simplify code flow (whitespace) plugins/less-pretty-cat: simplify code flow plugins/less-pretty-cat: use `_command_exists` lib/helpers: cite `_bash-it-find-in-ancestor()` gradle: adopt `_bash_it_find_in_ancestor()` lib/helpers: new function `_bash-it-find-in-ancestor()` completion/laravel: simplify code flow ...pull/1883/head
commit
d6239cf190
|
|
@ -13,17 +13,18 @@ insert_final_newline = true
|
|||
trim_trailing_whitespace = false
|
||||
|
||||
[.git*]
|
||||
indent_size = tab
|
||||
indent_style = tab
|
||||
|
||||
[{**.*sh,test/run}]
|
||||
indent_size = tab
|
||||
indent_style = tab
|
||||
indent_size = 4
|
||||
|
||||
shell_variant = bash
|
||||
binary_next_line = true # like -bn
|
||||
switch_case_indent = true # like -ci
|
||||
space_redirects = true # like -sr
|
||||
keep_padding = false # like -kp
|
||||
keep_padding = false # like -kp
|
||||
end_of_line = lf
|
||||
charset = utf-8
|
||||
trim_trailing_whitespace = true
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ jobs:
|
|||
bats-test:
|
||||
strategy:
|
||||
matrix:
|
||||
os: [ubuntu-20.04, ubuntu-18.04, ubuntu-16.04, macos-10.15]
|
||||
os: [ubuntu-20.04, ubuntu-18.04, macos-10.15, macos-11.0]
|
||||
|
||||
runs-on: ${{ matrix.os }}
|
||||
|
||||
|
|
@ -45,7 +45,7 @@ jobs:
|
|||
- name: Set up Go
|
||||
uses: actions/setup-go@v2
|
||||
with:
|
||||
go-version: 1.14
|
||||
go-version: 1.17
|
||||
- name: Set up Python
|
||||
uses: actions/setup-python@v2
|
||||
with:
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ repos:
|
|||
- id: mixed-line-ending
|
||||
- id: check-added-large-files
|
||||
- repo: https://github.com/jumanjihouse/pre-commit-hooks
|
||||
rev: 2.1.4
|
||||
rev: 2.1.5
|
||||
hooks:
|
||||
- id: git-check # Configure in .gitattributes
|
||||
- id: shellcheck
|
||||
|
|
|
|||
|
|
@ -1,6 +0,0 @@
|
|||
# We use colors and not assigned
|
||||
disable=SC2154
|
||||
# Hard to fix
|
||||
disable=SC2155
|
||||
# shellcheck is wrong on some
|
||||
disable=SC2034
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
#!/bin/bash
|
||||
# shellcheck shell=bash
|
||||
#
|
||||
# -binaryanomaly
|
||||
|
||||
|
|
@ -8,7 +8,8 @@ about-alias 'Apt and dpkg aliases for Ubuntu and Debian distros.'
|
|||
# set apt aliases
|
||||
function _set_pkg_aliases()
|
||||
{
|
||||
if [ -x $(which apt) ]; then
|
||||
if _command_exists apt
|
||||
then
|
||||
alias apts='apt-cache search'
|
||||
alias aptshow='apt-cache show'
|
||||
alias aptinst='sudo apt-get install -V'
|
||||
|
|
|
|||
|
|
@ -6,7 +6,8 @@ about-alias 'Curl aliases for convenience.'
|
|||
# set apt aliases
|
||||
function _set_pkg_aliases()
|
||||
{
|
||||
if [ -x $(which curl) ]; then
|
||||
if _command_exists curl
|
||||
then
|
||||
# follow redirects
|
||||
alias cl='curl -L'
|
||||
# follow redirects, download as original name
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ then
|
|||
alias grep='grep --color=auto'
|
||||
fi
|
||||
|
||||
if which gshuf &> /dev/null
|
||||
if _command_exists gshuf
|
||||
then
|
||||
alias shuf=gshuf
|
||||
fi
|
||||
|
|
@ -65,7 +65,7 @@ alias -- -='cd -' # Go back
|
|||
alias h='history'
|
||||
|
||||
# Tree
|
||||
if [ ! -x "$(which tree 2>/dev/null)" ]
|
||||
if ! _command_exists tree
|
||||
then
|
||||
alias tree="find . -print | sed -e 's;[^/]*/;|____;g;s;____|; |;g'"
|
||||
fi
|
||||
|
|
|
|||
|
|
@ -37,8 +37,8 @@ alias gcb='git checkout -b'
|
|||
alias gco='git checkout'
|
||||
alias gcob='git checkout -b'
|
||||
alias gcobu='git checkout -b ${USER}/'
|
||||
alias gcom='git checkout master'
|
||||
alias gcpd='git checkout master; git pull; git branch -D'
|
||||
alias gcom='git checkout $(get_default_branch)'
|
||||
alias gcpd='git checkout $(get_default_branch); git pull; git branch -D'
|
||||
alias gct='git checkout --track'
|
||||
|
||||
# clone
|
||||
|
|
@ -64,13 +64,14 @@ alias gf='git fetch --all --prune'
|
|||
alias gft='git fetch --all --prune --tags'
|
||||
alias gftv='git fetch --all --prune --tags --verbose'
|
||||
alias gfv='git fetch --all --prune --verbose'
|
||||
alias gmu='git fetch origin -v; git fetch upstream -v; git merge upstream/master'
|
||||
alias gmu='git fetch origin -v; git fetch upstream -v; git merge upstream/$(get_default_branch)'
|
||||
alias gup='git fetch && git rebase'
|
||||
|
||||
# log
|
||||
alias gg='git log --graph --pretty=format:'\''%C(bold)%h%Creset%C(magenta)%d%Creset %s %C(yellow)<%an> %C(cyan)(%cr)%Creset'\'' --abbrev-commit --date=relative'
|
||||
alias ggf='git log --graph --date=short --pretty=format:'\''%C(auto)%h %Cgreen%an%Creset %Cblue%cd%Creset %C(auto)%d %s'\'''
|
||||
alias ggs='gg --stat'
|
||||
alias ggup='git log --branches --not --remotes --no-walk --decorate --oneline' # FROM https://stackoverflow.com/questions/39220870/in-git-list-names-of-branches-with-unpushed-commits
|
||||
alias gll='git log --graph --pretty=oneline --abbrev-commit'
|
||||
alias gnew='git log HEAD@{1}..HEAD@{0}' # Show commits since last pull, see http://blogs.atlassian.com/2014/10/advanced-git-aliases/
|
||||
alias gwc='git whatchanged'
|
||||
|
|
@ -104,7 +105,7 @@ alias gp='git push'
|
|||
alias gpd='git push --delete'
|
||||
alias gpf='git push --force'
|
||||
alias gpo='git push origin HEAD'
|
||||
alias gpom='git push origin master'
|
||||
alias gpom='git push origin $(get_default_branch)'
|
||||
alias gpu='git push --set-upstream'
|
||||
alias gpunch='git push --force-with-lease'
|
||||
alias gpuo='git push --set-upstream origin'
|
||||
|
|
@ -112,7 +113,7 @@ alias gpuoc='git push --set-upstream origin $(git symbolic-ref --short HEAD)'
|
|||
|
||||
# pull
|
||||
alias gl='git pull'
|
||||
alias glum='git pull upstream master'
|
||||
alias glum='git pull upstream $(get_default_branch)'
|
||||
alias gpl='git pull'
|
||||
alias gpp='git pull && git push'
|
||||
alias gpr='git pull --rebase'
|
||||
|
|
@ -128,9 +129,9 @@ alias grm='git rm'
|
|||
# rebase
|
||||
alias grb='git rebase'
|
||||
alias grbc='git rebase --continue'
|
||||
alias grm='git rebase master'
|
||||
alias grmi='git rebase master -i'
|
||||
alias gprom='git fetch origin master && git rebase origin/master && git update-ref refs/heads/master origin/master' # Rebase with latest remote master
|
||||
alias grm='git rebase $(get_default_branch)'
|
||||
alias grmi='git rebase $(get_default_branch) -i'
|
||||
alias gprom='git fetch origin $(get_default_branch) && git rebase origin/$(get_default_branch) && git update-ref refs/heads/$(get_default_branch) origin/$(get_default_branch)' # Rebase with latest remote
|
||||
|
||||
# reset
|
||||
alias gus='git reset HEAD'
|
||||
|
|
@ -174,7 +175,7 @@ alias gsu='git submodule update --init --recursive'
|
|||
# these aliases requires git v2.23+
|
||||
alias gsw='git switch'
|
||||
alias gswc='git switch --create'
|
||||
alias gswm='git switch master'
|
||||
alias gswm='git switch $(get_default_branch)'
|
||||
alias gswt='git switch --track'
|
||||
|
||||
# tag
|
||||
|
|
@ -196,3 +197,11 @@ esac
|
|||
function gdv() {
|
||||
git diff --ignore-all-space "$@" | vim -R -
|
||||
}
|
||||
|
||||
function get_default_branch() {
|
||||
if git branch | grep -q main; then
|
||||
echo main
|
||||
else
|
||||
echo master
|
||||
fi
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,24 +2,14 @@
|
|||
cite 'about-alias'
|
||||
about-alias 'vim abbreviations'
|
||||
|
||||
VIM=$(command -v vim)
|
||||
GVIM=$(command -v gvim)
|
||||
MVIM=$(command -v mvim)
|
||||
_command_exists vim || return
|
||||
|
||||
if [[ -n $VIM ]]; then
|
||||
alias v='$VIM'
|
||||
# open the vim help in fullscreen incorporated from
|
||||
# https://stackoverflow.com/a/4687513
|
||||
alias vimh='${VIM} -c ":h | only"'
|
||||
fi
|
||||
alias v='vim'
|
||||
# open the vim help in fullscreen incorporated from
|
||||
# https://stackoverflow.com/a/4687513
|
||||
alias vimh='vim -c ":h | only"'
|
||||
|
||||
# open vim in new tab is taken from
|
||||
# http://stackoverflow.com/questions/936501/let-gvim-always-run-a-single-instancek
|
||||
case $OSTYPE in
|
||||
darwin*)
|
||||
[[ -n $MVIM ]] && function mvimt { command mvim --remote-tab-silent "$@" || command mvim "$@"; }
|
||||
;;
|
||||
*)
|
||||
[[ -n $GVIM ]] && function gvimt { command gvim --remote-tab-silent "$@" || command gvim "$@"; }
|
||||
;;
|
||||
esac
|
||||
_command_exists mvim && function mvimt { command mvim --remote-tab-silent "$@" || command mvim "$@"; }
|
||||
_command_exists gvim && function gvimt { command gvim --remote-tab-silent "$@" || command gvim "$@"; }
|
||||
|
|
|
|||
13
bash_it.sh
13
bash_it.sh
|
|
@ -3,7 +3,7 @@
|
|||
BASH_IT_LOG_PREFIX="core: main: "
|
||||
|
||||
# Only set $BASH_IT if it's not already set
|
||||
if [ -z "$BASH_IT" ]; then
|
||||
if [ -z "${BASH_IT:-}" ]; then
|
||||
# Setting $BASH to maintain backwards compatibility
|
||||
export BASH_IT=$BASH
|
||||
BASH="$(bash -c 'echo $BASH')"
|
||||
|
|
@ -20,12 +20,12 @@ source "${BASH_IT}"/vendor/github.com/erichs/composure/composure.sh
|
|||
source "${BASH_IT}/lib/log.bash"
|
||||
|
||||
# We can only log it now
|
||||
[ -z "$BASH_IT_OLD_BASH_SETUP" ] || _log_warning "BASH_IT variable not initialized, please upgrade your bash-it version and reinstall it!"
|
||||
[ -z "${BASH_IT_OLD_BASH_SETUP:-}" ] || _log_warning "BASH_IT variable not initialized, please upgrade your bash-it version and reinstall it!"
|
||||
|
||||
# For backwards compatibility, look in old BASH_THEME location
|
||||
if [ -z "$BASH_IT_THEME" ]; then
|
||||
if [ -z "${BASH_IT_THEME:-}" ]; then
|
||||
_log_warning "BASH_IT_THEME variable not initialized, please upgrade your bash-it version and reinstall it!"
|
||||
export BASH_IT_THEME="$BASH_THEME"
|
||||
export BASH_IT_THEME="${BASH_THEME:-}"
|
||||
unset BASH_THEME
|
||||
fi
|
||||
|
||||
|
|
@ -114,6 +114,7 @@ for _bash_it_config_file in $CUSTOM; do
|
|||
if [ -e "${_bash_it_config_file}" ]; then
|
||||
filename=$(basename "${_bash_it_config_file}")
|
||||
filename=${filename%*.bash}
|
||||
# shellcheck disable=SC2034
|
||||
BASH_IT_LOG_PREFIX="custom: $filename: "
|
||||
_log_debug "Loading custom file..."
|
||||
# shellcheck disable=SC1090
|
||||
|
|
@ -122,7 +123,7 @@ for _bash_it_config_file in $CUSTOM; do
|
|||
done
|
||||
|
||||
unset _bash_it_config_file
|
||||
if [[ $PROMPT ]]; then
|
||||
if [[ -n "${PROMPT:-}" ]]; then
|
||||
export PS1="\[""$PROMPT""\]"
|
||||
fi
|
||||
|
||||
|
|
@ -144,7 +145,7 @@ if [ -e "$HOME/.jekyllconfig" ]; then
|
|||
fi
|
||||
|
||||
# BASH_IT_RELOAD_LEGACY is set.
|
||||
if ! command -v reload &> /dev/null && [ -n "$BASH_IT_RELOAD_LEGACY" ]; then
|
||||
if ! _command_exists reload && [[ -n "${BASH_IT_RELOAD_LEGACY:-}" ]]; then
|
||||
case $OSTYPE in
|
||||
darwin*)
|
||||
alias reload='source ~/.bash_profile'
|
||||
|
|
|
|||
|
|
@ -42,12 +42,14 @@ completion/available/cargo.completion.bash
|
|||
completion/available/composer.completion.bash
|
||||
completion/available/conda.completion.bash
|
||||
completion/available/consul.completion.bash
|
||||
completion/available/dart.completion.bash
|
||||
completion/available/django.completion.bash
|
||||
completion/available/dmidecode.completion.bash
|
||||
completion/available/docker-machine.completion.bash
|
||||
completion/available/docker.completion.bash
|
||||
completion/available/gcloud.completion.bash
|
||||
completion/available/gem.completion.bash
|
||||
completion/available/git.completion.bash
|
||||
completion/available/github-cli.completion.bash
|
||||
completion/available/go.completion.bash
|
||||
completion/available/helm.completion.bash
|
||||
|
|
@ -57,6 +59,7 @@ completion/available/jungle.completion.bash
|
|||
completion/available/knife.completion.bash
|
||||
completion/available/kontena.completion.bash
|
||||
completion/available/kubectl.completion.bash
|
||||
completion/available/laravel.completion.bash
|
||||
completion/available/lerna.completion.bash
|
||||
completion/available/minikube.completion.bash
|
||||
completion/available/ngrok.completion.bash
|
||||
|
|
@ -71,12 +74,20 @@ completion/available/rustup.completion.bash
|
|||
completion/available/sdkman.completion.bash
|
||||
completion/available/vault.completion.bash
|
||||
completion/available/vuejs.completion.bash
|
||||
completion/available/wpscan.completion.bash
|
||||
|
||||
# libraries
|
||||
lib/utilities.bash
|
||||
|
||||
# plugins
|
||||
#
|
||||
plugins/available/alias-completion.plugin.bash
|
||||
plugins/available/autojump.plugin.bash
|
||||
plugins/available/base.plugin.bash
|
||||
plugins/available/basher.plugin.bash
|
||||
plugins/available/blesh.plugin.bash
|
||||
plugins/available/cmd-returned-notify.plugin.bash
|
||||
plugins/available/direnv.plugin.bash
|
||||
plugins/available/docker-machine.plugin.bash
|
||||
plugins/available/git.plugin.bash
|
||||
plugins/available/go.plugin.bash
|
||||
|
|
@ -84,6 +95,17 @@ plugins/available/goenv.plugin.bash
|
|||
plugins/available/history-search.plugin.bash
|
||||
plugins/available/history-substring-search.plugin.bash
|
||||
plugins/available/history.plugin.bash
|
||||
plugins/available/hub.plugin.bash
|
||||
plugins/available/jump.plugin.bash
|
||||
plugins/available/less-pretty-cat.plugin.bash
|
||||
plugins/available/node.plugin.bash
|
||||
plugins/available/nodenv.plugin.bash
|
||||
plugins/available/percol.plugin.bash
|
||||
plugins/available/plenv.plugin.bash
|
||||
plugins/available/pyenv.plugin.bash
|
||||
plugins/available/rbenv.plugin.bash
|
||||
plugins/available/ruby.plugin.bash
|
||||
plugins/available/textmate.plugin.bash
|
||||
plugins/available/xterm.plugin.bash
|
||||
|
||||
# tests
|
||||
|
|
@ -111,6 +133,7 @@ themes/command_duration.theme.bash
|
|||
themes/easy
|
||||
themes/modern
|
||||
themes/powerline
|
||||
themes/pure
|
||||
themes/purity
|
||||
|
||||
# vendor init files
|
||||
|
|
|
|||
|
|
@ -1 +1,6 @@
|
|||
[[ -x "$(which aws_completer)" ]] && complete -C "$(which aws_completer)" aws
|
||||
# shellcheck shell=bash
|
||||
|
||||
if _command_exists aws_completer
|
||||
then
|
||||
complete -C "$(command -v aws_completer)" aws
|
||||
fi
|
||||
|
|
|
|||
|
|
@ -5,28 +5,26 @@ about-completion "brew completion"
|
|||
# Load late to make sure `system` completion loads first
|
||||
# BASH_IT_LOAD_PRIORITY: 375
|
||||
|
||||
if [[ "$(uname -s)" != 'Darwin' ]]; then
|
||||
if [[ "$OSTYPE" != 'darwin'* ]]; then
|
||||
_log_warning "unsupported operating system - only 'Darwin' is supported"
|
||||
return 0
|
||||
fi
|
||||
|
||||
# Make sure brew is installed
|
||||
_command_exists brew || return 0
|
||||
_bash_it_homebrew_check || return 0
|
||||
|
||||
BREW_PREFIX=${BREW_PREFIX:-$(brew --prefix)}
|
||||
|
||||
if [[ -r "$BREW_PREFIX"/etc/bash_completion.d/brew ]]; then
|
||||
if [[ -r "$BASH_IT_HOMEBREW_PREFIX/etc/bash_completion.d/brew" ]]; then
|
||||
# shellcheck disable=1090
|
||||
source "$BREW_PREFIX"/etc/bash_completion.d/brew
|
||||
source "$BASH_IT_HOMEBREW_PREFIX/etc/bash_completion.d/brew"
|
||||
|
||||
elif [[ -r "$BREW_PREFIX"/Library/Contributions/brew_bash_completion.sh ]]; then
|
||||
elif [[ -r "$BASH_IT_HOMEBREW_PREFIX/Library/Contributions/brew_bash_completion.sh" ]]; then
|
||||
# shellcheck disable=1090
|
||||
source "$BREW_PREFIX"/Library/Contributions/brew_bash_completion.sh
|
||||
source "$BASH_IT_HOMEBREW_PREFIX/Library/Contributions/brew_bash_completion.sh"
|
||||
|
||||
elif [[ -f "$BREW_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
|
||||
source "$BREW_PREFIX"/completions/bash/brew
|
||||
source "$BASH_IT_HOMEBREW_PREFIX/completions/bash/brew"
|
||||
fi
|
||||
|
|
|
|||
|
|
@ -3,14 +3,14 @@ cite "about-completion"
|
|||
about-completion "composer completion"
|
||||
|
||||
function __composer_completion() {
|
||||
local cur coms opts com
|
||||
local cur coms opts com words
|
||||
COMPREPLY=()
|
||||
_get_comp_words_by_ref -n : cur words
|
||||
|
||||
# lookup for command
|
||||
for word in "${words[@]:1}"; do
|
||||
if [[ $word != -* ]]; then
|
||||
com=$word
|
||||
if [[ "${word}" != -* ]]; then
|
||||
com="${word}"
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
|
@ -19,7 +19,7 @@ function __composer_completion() {
|
|||
if [[ ${cur} == --* ]]; then
|
||||
opts="--help --quiet --verbose --version --ansi --no-ansi --no-interaction --profile --no-plugins --working-dir"
|
||||
|
||||
case "$com" in
|
||||
case "${com}" in
|
||||
about)
|
||||
opts="${opts} "
|
||||
;;
|
||||
|
|
@ -109,18 +109,18 @@ function __composer_completion() {
|
|||
|
||||
# shellcheck disable=SC2207
|
||||
COMPREPLY=($(compgen -W "${opts}" -- "${cur}"))
|
||||
__ltrim_colon_completions "$cur"
|
||||
__ltrim_colon_completions "${cur}"
|
||||
|
||||
return 0
|
||||
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
|
||||
COMPREPLY=($(compgen -W "${coms}" -- "${cur}"))
|
||||
__ltrim_colon_completions "$cur"
|
||||
__ltrim_colon_completions "${cur}"
|
||||
|
||||
return 0
|
||||
fi
|
||||
|
|
|
|||
|
|
@ -3,5 +3,5 @@ cite "about-completion"
|
|||
about-completion "Hashicorp consul completion"
|
||||
|
||||
if _command_exists consul; then
|
||||
complete -C "$(which consul)" consul
|
||||
complete -C "$(command -v consul)" consul
|
||||
fi
|
||||
|
|
|
|||
|
|
@ -0,0 +1,48 @@
|
|||
# shellcheck shell=bash
|
||||
|
||||
__dart_completion() {
|
||||
# shellcheck disable=SC2155
|
||||
local prev=$(_get_pword)
|
||||
# shellcheck disable=SC2155
|
||||
local curr=$(_get_cword)
|
||||
|
||||
local HELP="--help -h"
|
||||
local VERBOSE="-v --verbose"
|
||||
|
||||
case $prev in
|
||||
analyze)
|
||||
# shellcheck disable=SC2207
|
||||
COMPREPLY=($(compgen -W "$HELP --fatal-infos --no-fatal-warnings --fatal-warnings" -- "$curr"))
|
||||
;;
|
||||
compile)
|
||||
# shellcheck disable=SC2207
|
||||
COMPREPLY=($(compgen -W "$HELP aot-snapshot exe js jit-snapshot kernel" -- "$curr"))
|
||||
;;
|
||||
create)
|
||||
# shellcheck disable=SC2207
|
||||
COMPREPLY=($(compgen -W "$HELP --template -t --no-pub --pub --force" -- "$curr"))
|
||||
;;
|
||||
-t | --template)
|
||||
# shellcheck disable=SC2207
|
||||
COMPREPLY=($(compgen -W "console-simple console-full package-simple web-simple" -- "$curr"))
|
||||
;;
|
||||
format)
|
||||
# shellcheck disable=SC2207
|
||||
COMPREPLY=($(compgen -W "$HELP $VERBOSE -o --output --fix -l --line-length" -- "$curr"))
|
||||
;;
|
||||
pub)
|
||||
# shellcheck disable=SC2207
|
||||
COMPREPLY=($(compgen -W "$HELP $VERBOSE --version --no-trace --trace --verbosity cache deps downgrade get global logout outdated publish run upgrade uploader version" -- "$curr"))
|
||||
;;
|
||||
run)
|
||||
# shellcheck disable=SC2207
|
||||
COMPREPLY=($(compgen -W "$HELP --observe --enable-vm-service --no-pause-isolates-on-exit --no-pause-isolates-on-unhandled-exceptions --no-warn-on-pause-with-no-debugger --pause-isolates-on-exit --pause-isolates-on-unhandled-exceptions --warn-on-pause-with-no-debugger" -- "$curr"))
|
||||
;;
|
||||
dart)
|
||||
# shellcheck disable=SC2207
|
||||
COMPREPLY=($(compgen -W "$HELP $VERBOSE --version --enable-analytics --disable-analytics help analyze compile create format pub run test" -- "$curr"))
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
complete -F __dart_completion dart
|
||||
|
|
@ -13,7 +13,7 @@ _defaults_domains()
|
|||
COMPREPLY=()
|
||||
cur=${COMP_WORDS[COMP_CWORD]}
|
||||
|
||||
local domains=$( defaults domains | sed -e 's/, /:/g' | tr : '\n' | sed -e 's/ /\\ /g' | grep -i "^$cur" )
|
||||
local domains=$( defaults domains | sed -e 's/, /:/g' | tr : '\n' | sed -e 's/ /\\ /g' | grep "^$cur" )
|
||||
local IFS=$'\n'
|
||||
COMPREPLY=( $domains )
|
||||
if [[ $( echo '-app' | grep "^$cur" ) ]]; then
|
||||
|
|
@ -41,8 +41,8 @@ _defaults()
|
|||
COMPREPLY=( $( compgen -W "$cmds" -- $cur ) )
|
||||
return 0
|
||||
elif [[ "$prev" == "-host" ]]; then
|
||||
return 0
|
||||
_known_hosts -a
|
||||
return 0
|
||||
else
|
||||
_defaults_domains
|
||||
return 0
|
||||
|
|
|
|||
|
|
@ -1,7 +1,9 @@
|
|||
# shellcheck shell=bash
|
||||
|
||||
function __dmidecode_completion() {
|
||||
# shellcheck disable=SC2155
|
||||
local prev=$(_get_pword)
|
||||
# shellcheck disable=SC2155
|
||||
local curr=$(_get_cword)
|
||||
|
||||
case $prev in
|
||||
|
|
|
|||
|
|
@ -676,7 +676,7 @@ _docker_compose() {
|
|||
done
|
||||
|
||||
local completions_func=_docker_compose_${command//-/_}
|
||||
declare -F $completions_func >/dev/null && $completions_func
|
||||
_is_function $completions_func && $completions_func
|
||||
|
||||
eval "$previous_extglob_setting"
|
||||
return 0
|
||||
|
|
|
|||
|
|
@ -41,8 +41,8 @@ export FAB_COMPLETION_CACHED_TASKS_FILENAME=".fab_tasks~"
|
|||
|
||||
|
||||
# Set command to get time of last file modification as seconds since Epoch
|
||||
case `uname` in
|
||||
Darwin|FreeBSD)
|
||||
case "$OSTYPE" in
|
||||
'darwin'*|'freebsd'*)
|
||||
__FAB_COMPLETION_MTIME_COMMAND="stat -f '%m'"
|
||||
;;
|
||||
*)
|
||||
|
|
|
|||
|
|
@ -1,39 +1,42 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
# Only operate on MacOS since there are no linux paths
|
||||
if [[ "$(uname -s)" != 'Darwin' ]] ; then
|
||||
_log_warning "unsupported operating system - only 'Darwin' is supported"
|
||||
return 0
|
||||
fi
|
||||
# shellcheck shell=bash
|
||||
#
|
||||
# Locate and load completions for `git`.
|
||||
|
||||
# Make sure git is installed
|
||||
_command_exists git || return 0
|
||||
_command_exists git || return
|
||||
|
||||
# Don't handle completion if it's already managed
|
||||
if complete -p git &>/dev/null ; then
|
||||
_log_warning "completion already loaded - this usually means it is safe to stop using this completion"
|
||||
return 0
|
||||
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_found=false
|
||||
_git_bash_completion_xcrun_git=
|
||||
if _command_exists xcrun; then
|
||||
_git_bash_completion_xcrun_git="$(xcrun --find git)"
|
||||
fi
|
||||
_git_bash_completion_paths=(
|
||||
# MacOS non-system locations
|
||||
'/Library/Developer/CommandLineTools/usr/share/git-core/git-completion.bash'
|
||||
'/Applications/Xcode.app/Contents/Developer/usr/share/git-core/git-completion.bash'
|
||||
# Standard locations
|
||||
"${GIT_EXE%/*}/../share/git-core/git-completion.bash"
|
||||
"${GIT_EXE%/*}/../share/git-core/contrib/completion/git-completion.bash"
|
||||
"${GIT_EXE%/*}/../etc/bash_completion.d/git-completion.bash"
|
||||
# MacOS non-system locations
|
||||
"${_git_bash_completion_xcrun_git%/bin/git}/share/git-core/git-completion.bash"
|
||||
)
|
||||
|
||||
# Load the first completion file found
|
||||
for _comp_path in "${_git_bash_completion_paths[@]}" ; do
|
||||
if [ -r "$_comp_path" ] ; then
|
||||
_git_bash_completion_found=true
|
||||
source "$_comp_path"
|
||||
break
|
||||
fi
|
||||
_git_bash_completion_found=false
|
||||
for _comp_path in "${_git_bash_completion_paths[@]}"; do
|
||||
if [[ -r "$_comp_path" ]]; then
|
||||
_git_bash_completion_found=true
|
||||
# shellcheck disable=SC1090 # don't follow
|
||||
source "$_comp_path"
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
# Cleanup
|
||||
if [[ "${_git_bash_completion_found}" == false ]]; then
|
||||
_log_warning "no completion files found - please try enabling the 'system' completion instead."
|
||||
_log_warning "no completion files found - please try enabling the 'system' completion instead."
|
||||
fi
|
||||
unset _git_bash_completion_paths
|
||||
unset _git_bash_completion_found
|
||||
unset "${!_git_bash_completion@}"
|
||||
|
|
|
|||
|
|
@ -172,6 +172,7 @@ __git_flow_list_hotfixes ()
|
|||
}
|
||||
|
||||
# temporarily wrap __git_find_on_cmdline() for backwards compatibility
|
||||
if [ -z "`type -t __git_find_subcommand`" ]; then
|
||||
if ! _command_exists __git_find_subcommand
|
||||
then
|
||||
alias __git_find_subcommand=__git_find_on_cmdline
|
||||
fi
|
||||
|
|
|
|||
|
|
@ -505,6 +505,7 @@ __git_flow_list_branches ()
|
|||
}
|
||||
|
||||
# alias __git_find_on_cmdline for backwards compatibility
|
||||
if [ -z "`type -t __git_find_on_cmdline`" ]; then
|
||||
if ! _command_exists __git_find_on_cmdline
|
||||
then
|
||||
alias __git_find_on_cmdline=__git_find_subcommand
|
||||
fi
|
||||
|
|
|
|||
|
|
@ -22,17 +22,9 @@
|
|||
# Avoid inaccurate completions for subproject tasks
|
||||
COMP_WORDBREAKS=$(echo "$COMP_WORDBREAKS" | sed -e 's/://g')
|
||||
|
||||
__gradle-set-project-root-dir() {
|
||||
local dir=`pwd`
|
||||
project_root_dir=`pwd`
|
||||
while [[ $dir != '/' ]]; do
|
||||
if [[ -f "$dir/settings.gradle" || -f "$dir/gradlew" ]]; then
|
||||
project_root_dir=$dir
|
||||
return 0
|
||||
fi
|
||||
dir="$(dirname "$dir")"
|
||||
done
|
||||
return 1
|
||||
function __gradle-set-project-root-dir() {
|
||||
project_root_dir="$(_bash-it-find-in-ancestor "settings.gradle" "gradlew")"
|
||||
return "$?"
|
||||
}
|
||||
|
||||
__gradle-init-cache-dir() {
|
||||
|
|
@ -58,9 +50,9 @@ __gradle-set-cache-name() {
|
|||
|
||||
__gradle-set-files-checksum() {
|
||||
# Cache MD5 sum of all Gradle scripts and modified timestamps
|
||||
if builtin command -v md5 > /dev/null; then
|
||||
if _command_exists md5; then
|
||||
gradle_files_checksum=$(md5 -q -s "$(cat "$cache_dir/$cache_name" | xargs ls -o 2>/dev/null)")
|
||||
elif builtin command -v md5sum > /dev/null; then
|
||||
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"
|
||||
|
|
|
|||
|
|
@ -23,12 +23,12 @@
|
|||
# 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 ! declare -F _git > /dev/null && declare -F _completion_loader > /dev/null; 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 declare -F _git > /dev/null && ! declare -F __git_list_all_commands_without_hub > /dev/null; 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/')"
|
||||
|
|
@ -227,7 +227,7 @@ EOF
|
|||
((c++))
|
||||
done
|
||||
if [ -z "$name" ]; then
|
||||
repo=$(basename "$(pwd)")
|
||||
repo="$(basename "${PWD}")"
|
||||
fi
|
||||
case "$prev" in
|
||||
-d|-h)
|
||||
|
|
|
|||
|
|
@ -42,6 +42,7 @@ _KAC_is_file_newer_than() {
|
|||
_KAC_regen_cache() {
|
||||
local CACHE_NAME=$1
|
||||
local CACHE_PATH="$_KNIFE_AUTOCOMPLETE_CACHE_DIR/$CACHE_NAME"
|
||||
# shellcheck disable=SC2155
|
||||
local TMP_FILE=$(mktemp "$_KAC_CACHE_TMP_DIR/$CACHE_NAME.XXXX")
|
||||
shift 1
|
||||
# discard the temp file if it's empty AND the previous command didn't exit successfully, but still mark the cache as updated
|
||||
|
|
@ -66,6 +67,7 @@ _KAC_get_command_from_cache_name() {
|
|||
# otherwise it waits for the cache to be generated
|
||||
# in either case, it regenerates the cache, and sets the _KAC_CACHE_PATH env variable
|
||||
# for obvious reason, do NOT call that in a sub-shell (in particular, no piping)
|
||||
# shellcheck disable=SC2155
|
||||
_KAC_get_and_regen_cache() {
|
||||
# the cache name can't have space in it
|
||||
local CACHE_NAME=$(_KAC_get_cache_name_from_command "$@")
|
||||
|
|
@ -100,7 +102,7 @@ _KAC_clean_cache() {
|
|||
|
||||
# perform a cache cleaning when loading this file
|
||||
# On big systems this could baloon up to a 30 second run or more, so not enabling by default.
|
||||
[[ "${KNIFE_CACHE_CLEAN}" ]] && _KAC_clean_cache
|
||||
[[ -n "${KNIFE_CACHE_CLEAN}" ]] && _KAC_clean_cache
|
||||
|
||||
#####################################
|
||||
### End of cache helper functions ###
|
||||
|
|
@ -118,7 +120,7 @@ _KAC_get_current_base_command() {
|
|||
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]}"
|
||||
|
|
@ -127,12 +129,13 @@ _KAC_get_current_base_command() {
|
|||
I=$((I + 1))
|
||||
done
|
||||
_KAC_CURRENT_COMMAND=$PREVIOUS
|
||||
[ $I -le "$COMP_CWORD" ] && _KAC_CURRENT_COMMAND_NB_WORDS=$I
|
||||
[[ "${I}" -le "${COMP_CWORD}" ]] && _KAC_CURRENT_COMMAND_NB_WORDS="${I}"
|
||||
}
|
||||
|
||||
# searches the position of the currently completed argument in the current base command
|
||||
# (i.e. handles "plural" arguments such as knife cookbook upload cookbook1 cookbook2 and so on...)
|
||||
# assumes the current base command is complete
|
||||
# shellcheck disable=SC2155
|
||||
_KAC_get_current_arg_position() {
|
||||
local CURRENT_ARG_POS=$((_KAC_CURRENT_COMMAND_NB_WORDS + 1))
|
||||
local COMPLETE_COMMAND=$(grep -E "^$_KAC_CURRENT_COMMAND" "$_KAC_CACHE_PATH")
|
||||
|
|
@ -150,10 +153,11 @@ _KAC_get_current_arg_position() {
|
|||
_knife() {
|
||||
_KAC_get_and_regen_cache _KAC_knife_commands
|
||||
local RAW_LIST ITEM REGEN_CMD ARG_POSITION
|
||||
# shellcheck disable=SC2034
|
||||
COMREPLY=()
|
||||
# get correct command & arg pos
|
||||
_KAC_get_current_base_command && ARG_POSITION=$(_KAC_get_current_arg_position) || ARG_POSITION=$((COMP_CWORD + 1))
|
||||
RAW_LIST=$(grep -E "^$_KAC_CURRENT_COMMAND" "$_KAC_CACHE_PATH" | cut -d ' ' -f $ARG_POSITION | uniq)
|
||||
RAW_LIST=$(grep -E "^${_KAC_CURRENT_COMMAND}" "${_KAC_CACHE_PATH}" | cut -d ' ' -f "${ARG_POSITION}" | uniq)
|
||||
|
||||
# we need to process that raw list a bit, most notably for placeholders
|
||||
# NOTE: I chose to explicitely fetch & cache _certain_ informations for the server (cookbooks & node names, etc)
|
||||
|
|
|
|||
|
|
@ -1,15 +1,16 @@
|
|||
#!/usr/bin/bash
|
||||
# shellcheck shell=bash
|
||||
|
||||
if command -v laravel > /dev/null; then
|
||||
__laravel_completion() {
|
||||
local OPTS=("-h --help -q --quiet --ansi --no-ansi -n --no-interaction -v -vv -vvv --verbose help list new")
|
||||
COMPREPLY=()
|
||||
for _opt_ in ${OPTS[@]}; do
|
||||
if [[ "$_opt_" == "$2"* ]]; then
|
||||
COMPREPLY+=("$_opt_")
|
||||
fi
|
||||
done
|
||||
}
|
||||
_command_exists laravel || return
|
||||
|
||||
complete -F __laravel_completion laravel
|
||||
fi
|
||||
function __laravel_completion() {
|
||||
local OPTS=('-h' '--help' '-q' '--quiet' '--ansi' '--no-ansi' '-n' '--no-interaction' '-v' '-vv' '-vvv' '--verbose' 'help' 'list' 'new')
|
||||
local _opt_
|
||||
COMPREPLY=()
|
||||
for _opt_ in "${OPTS[@]}"; do
|
||||
if [[ "$_opt_" == "$2"* ]]; then
|
||||
COMPREPLY+=("$_opt_")
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
complete -F __laravel_completion laravel
|
||||
|
|
|
|||
|
|
@ -1,7 +1,9 @@
|
|||
# shellcheck shell=bash
|
||||
|
||||
__ngrok_completion() {
|
||||
# shellcheck disable=SC2155
|
||||
local prev=$(_get_pword)
|
||||
# shellcheck disable=SC2155
|
||||
local curr=$(_get_cword)
|
||||
|
||||
local BASE_NO_CONF="--log --log-format --log-level --help"
|
||||
|
|
|
|||
|
|
@ -1,7 +1,9 @@
|
|||
# shellcheck shell=bash
|
||||
|
||||
function __notify-send_completions() {
|
||||
# shellcheck disable=SC2155
|
||||
local curr=$(_get_cword)
|
||||
# shellcheck disable=SC2155
|
||||
local prev=$(_get_pword)
|
||||
|
||||
case $prev in
|
||||
|
|
|
|||
|
|
@ -1 +1,6 @@
|
|||
[[ -x "$(which pew)" ]] && source "$(pew shell_config)"
|
||||
# shellcheck shell=bash
|
||||
|
||||
if _command_exists pew
|
||||
then
|
||||
source "$(pew shell_config)"
|
||||
fi
|
||||
|
|
|
|||
|
|
@ -6,6 +6,15 @@
|
|||
# If the pip package is installed within virtual environments, say, python managed by pyenv,
|
||||
# you should first initialize the corresponding environment.
|
||||
# So that pip is in the system's path.
|
||||
if _command_exists pip; then
|
||||
eval "$(pip completion --bash)"
|
||||
fi
|
||||
_command_exists pip || return
|
||||
|
||||
function __bash_it_complete_pip() {
|
||||
if _command_exists _pip_completion; then
|
||||
complete -o default -F _pip_completion pip
|
||||
_pip_completion "$@"
|
||||
else
|
||||
eval "$(pip completion --bash)"
|
||||
_pip_completion "$@"
|
||||
fi
|
||||
}
|
||||
complete -o default -F __bash_it_complete_pip pip
|
||||
|
|
|
|||
|
|
@ -6,6 +6,15 @@
|
|||
# If the pip package is installed within virtual environments, say, python managed by pyenv,
|
||||
# you should first initialize the corresponding environment.
|
||||
# So that pip3 is in the system's path.
|
||||
if _command_exists pip3; then
|
||||
eval "$(pip3 completion --bash)"
|
||||
fi
|
||||
_command_exists pip3 || return
|
||||
|
||||
function __bash_it_complete_pip3() {
|
||||
if _command_exists _pip_completion; then
|
||||
complete -o default -F _pip_completion pip3
|
||||
_pip_completion "$@"
|
||||
else
|
||||
eval "$(pip3 completion --bash)"
|
||||
_pip_completion "$@"
|
||||
fi
|
||||
}
|
||||
complete -o default -F __bash_it_complete_pip3 pip3
|
||||
|
|
|
|||
|
|
@ -1,7 +1,9 @@
|
|||
# shellcheck shell=bash
|
||||
_sdkman_complete() {
|
||||
|
||||
function _sdkman_complete() {
|
||||
local CANDIDATES
|
||||
local CANDIDATE_VERSIONS
|
||||
local SDKMAN_CANDIDATES_CSV="${SDKMAN_CANDIDATES_CSV:-}"
|
||||
|
||||
COMPREPLY=()
|
||||
|
||||
|
|
@ -10,7 +12,7 @@ _sdkman_complete() {
|
|||
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=$(echo "${SDKMAN_CANDIDATES_CSV}" | tr ',' ' ')
|
||||
CANDIDATES="${SDKMAN_CANDIDATES_CSV//,/${IFS:0:1}}"
|
||||
mapfile -t COMPREPLY < <(compgen -W "$CANDIDATES" -- "${COMP_WORDS[COMP_CWORD]}")
|
||||
;;
|
||||
"env")
|
||||
|
|
@ -46,17 +48,17 @@ _sdkman_complete() {
|
|||
return 0
|
||||
}
|
||||
|
||||
_sdkman_candidate_local_versions() {
|
||||
function _sdkman_candidate_local_versions() {
|
||||
|
||||
CANDIDATE_VERSIONS=$(__sdkman_cleanup_local_versions "$1")
|
||||
|
||||
}
|
||||
|
||||
_sdkman_candidate_all_versions() {
|
||||
function _sdkman_candidate_all_versions() {
|
||||
|
||||
candidate="$1"
|
||||
CANDIDATE_LOCAL_VERSIONS=$(__sdkman_cleanup_local_versions "$candidate")
|
||||
if [ "$SDKMAN_OFFLINE_MODE" = "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
|
||||
|
|
@ -70,12 +72,12 @@ _sdkman_candidate_all_versions() {
|
|||
# "+" - local version
|
||||
# "*" - installed
|
||||
# ">" - currently in use
|
||||
CANDIDATE_VERSIONS="$(echo "$CANDIDATE_ONLINE_VERSIONS $CANDIDATE_LOCAL_VERSIONS" | tr ' ' '\n' | grep -v -e '^[[:space:]|\*|\>|\+]*$' | sort | uniq -u) "
|
||||
CANDIDATE_VERSIONS="$(echo "$CANDIDATE_ONLINE_VERSIONS $CANDIDATE_LOCAL_VERSIONS" | tr ' ' '\n' | grep -v -e '^[[:space:]|\*|\>|\+]*$' | sort -u) "
|
||||
fi
|
||||
|
||||
}
|
||||
|
||||
__sdkman_cleanup_local_versions() {
|
||||
function __sdkman_cleanup_local_versions() {
|
||||
|
||||
__sdkman_build_version_csv "$1" | tr ',' ' '
|
||||
|
||||
|
|
|
|||
|
|
@ -1,21 +1,22 @@
|
|||
#!/bin/bash
|
||||
# shellcheck shell=bash
|
||||
|
||||
# ---------------------------------------------------------------------------+
|
||||
# |
|
||||
# Thanks to Alexander Korznikov |
|
||||
# Thanks to Alexander Korznikov |
|
||||
# http://www.korznikov.com/2014/12/bash-tab-completion-for-awesome-tool.html |
|
||||
# |
|
||||
# ---------------------------------------------------------------------------+
|
||||
|
||||
if command -v sqlmap > /dev/null; then
|
||||
if _command_exists sqlmap
|
||||
then
|
||||
|
||||
_sqlmap()
|
||||
function _sqlmap()
|
||||
{
|
||||
local cur prev
|
||||
|
||||
COMPREPLY=()
|
||||
cur=$(_get_cword)
|
||||
prev=$(_get_pword)
|
||||
cur="$(_get_cword)"
|
||||
prev="$(_get_pword)"
|
||||
|
||||
case $prev in
|
||||
|
||||
|
|
@ -143,7 +144,7 @@ if command -v sqlmap > /dev/null; then
|
|||
--mobile --page-rank --purge-output --smart \
|
||||
--sqlmap-shell --wizard '
|
||||
COMPREPLY=( $( \
|
||||
(while read -d ' ' i; do
|
||||
(while read -d ' ' i; do
|
||||
[[ -z "$i" || "${onlyonce/ ${i%% *} / }" == "$onlyonce" ]] &&
|
||||
continue
|
||||
# flatten array with spaces on either side,
|
||||
|
|
@ -152,7 +153,7 @@ if command -v sqlmap > /dev/null; then
|
|||
COMPREPLY=" ${COMPREPLY[@]} "
|
||||
# remove word from list of completions
|
||||
COMPREPLY=( ${COMPREPLY/ ${i%% *} / } )
|
||||
done
|
||||
done
|
||||
printf '%s ' "${COMPREPLY[@]}") <<<"${COMP_WORDS[@]}"
|
||||
) )
|
||||
|
||||
|
|
|
|||
|
|
@ -1,9 +1,21 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
#
|
||||
# Loads the system's Bash completion modules.
|
||||
# If Homebrew is installed (OS X), it's Bash completion modules are loaded.
|
||||
|
||||
if [[ -r /etc/bash_completion ]] ; then
|
||||
if shopt -qo nounset
|
||||
then # Bash-completion is too large and complex to expect to handle unbound variables throughout the whole codebase.
|
||||
__bash_it_restore_nounset=true
|
||||
shopt -uo nounset
|
||||
else
|
||||
__bash_it_restore_nounset=false
|
||||
fi
|
||||
|
||||
if [[ -r "${BASH_COMPLETION:-}" ]] ; then
|
||||
# shellcheck disable=SC1091
|
||||
source "${BASH_COMPLETION}"
|
||||
|
||||
elif [[ -r /etc/bash_completion ]] ; then
|
||||
# shellcheck disable=SC1091
|
||||
source /etc/bash_completion
|
||||
|
||||
|
|
@ -12,14 +24,36 @@ elif [[ -r /etc/profile.d/bash_completion.sh ]] ; then
|
|||
# shellcheck disable=SC1091
|
||||
source /etc/profile.d/bash_completion.sh
|
||||
|
||||
elif _bash_it_homebrew_check
|
||||
then
|
||||
: ${BASH_COMPLETION_COMPAT_DIR:=$BASH_IT_HOMEBREW_PREFIX/etc/bash_completion.d}
|
||||
|
||||
case "${BASH_VERSION}" in
|
||||
1*|2*|3.0*|3.1*)
|
||||
_log_warning "Cannot load completion due to version of shell. Are you using Bash 3.2+?"
|
||||
;;
|
||||
3.2*|4.0*|4.1*)
|
||||
# Import version 1.x of bash-completion, if installed.
|
||||
BASH_COMPLETION="$BASH_IT_HOMEBREW_PREFIX/opt/bash-completion@1/etc/bash_completion"
|
||||
if [[ -r "$BASH_COMPLETION" ]] ; then
|
||||
# shellcheck disable=SC1090
|
||||
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"/etc/profile.d/bash_completion.sh ]] ; then
|
||||
# shellcheck disable=SC1090
|
||||
source "$BASH_IT_HOMEBREW_PREFIX"/etc/profile.d/bash_completion.sh
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
if [[ "$(uname -s)" == 'Darwin' ]] && _command_exists brew ; then
|
||||
BREW_PREFIX=${BREW_PREFIX:-$(brew --prefix)}
|
||||
|
||||
# homebrew/versions/bash-completion2 (required for projects.completion.bash) is installed to this path
|
||||
if [[ -r "$BREW_PREFIX"/etc/profile.d/bash_completion.sh ]] ; then
|
||||
# shellcheck disable=SC1090
|
||||
source "$BREW_PREFIX"/etc/profile.d/bash_completion.sh
|
||||
fi
|
||||
if $__bash_it_restore_nounset
|
||||
then
|
||||
shopt -so nounset
|
||||
fi
|
||||
unset __bash_it_restore_nounset
|
||||
|
|
|
|||
|
|
@ -1,5 +1,10 @@
|
|||
if [[ -x "$(which travis)" ]]; then
|
||||
__TRAVIS_COMPLETION_SCRIPT="${TRAVIS_CONFIG_PATH:-${HOME}/.travis}/travis.sh"
|
||||
[[ -f "${__TRAVIS_COMPLETION_SCRIPT}" ]] && source "${__TRAVIS_COMPLETION_SCRIPT}"
|
||||
# shellcheck shell=bash
|
||||
|
||||
if _command_exists travis
|
||||
then
|
||||
if [[ -s "${__TRAVIS_COMPLETION_SCRIPT:=${TRAVIS_CONFIG_PATH:-${HOME}/.travis}/travis.sh}" ]]
|
||||
then
|
||||
source "${__TRAVIS_COMPLETION_SCRIPT}"
|
||||
fi
|
||||
unset __TRAVIS_COMPLETION_SCRIPT
|
||||
fi
|
||||
|
|
|
|||
|
|
@ -1,7 +1,9 @@
|
|||
# shellcheck shell=bash
|
||||
|
||||
__vuejs_completion() {
|
||||
# shellcheck disable=SC2155
|
||||
local prev=$(_get_pword)
|
||||
# shellcheck disable=SC2155
|
||||
local curr=$(_get_cword)
|
||||
|
||||
case $prev in
|
||||
|
|
|
|||
|
|
@ -1,15 +1,16 @@
|
|||
#!/usr/bin/bash
|
||||
# shellcheck shell=bash
|
||||
|
||||
if command -v wpscan > /dev/null; then
|
||||
__wpscan_completion() {
|
||||
local OPTS=("--help --hh --version --url --ignore-main-redirect --verbose --output --format --detection-mode --scope --headers --user-agent --vhost --random-user-agent --user-agents-list --http-auth --max-threads --throttle --request-timeout --connect-timeout --disable-tlc-checks --proxy --proxy-auth --cookie-string --cookie-jar --cache-ttl --clear-cache --server --cache-dir --update --no-update --wp-content-dir --wp-plugins-dir --wp-version-detection --main-theme-detection --enumerate --exclude-content-based --plugins-list --plugins-detection --plugins-version-all --plugins-version-detection --themes-list --themes-detection --themes-version-all --themes-version-detection --timthumbs-list --timthumbs-detection --config-backups-list --config-backups-detection --db-exports-list --db-exports-detection --medias-detection --users-list --users-detection --passwords --usernames --multicall-max-passwords --password-attack --stealthy")
|
||||
COMPREPLY=()
|
||||
for _opt_ in ${OPTS[@]}; do
|
||||
if [[ "$_opt_" == "$2"* ]]; then
|
||||
COMPREPLY+=("$_opt_")
|
||||
fi
|
||||
done
|
||||
}
|
||||
_command_exists wpscan || return
|
||||
|
||||
complete -F __wpscan_completion wpscan
|
||||
fi
|
||||
function __wpscan_completion() {
|
||||
local _opt_
|
||||
local OPTS=('--help' '--hh' '--version' '--url' '--ignore-main-redirect' '--verbose' '--output' '--format' '--detection-mode' '--scope' '--headers' '--user-agent' '--vhost' '--random-user-agent' '--user-agents-list' '--http-auth' '--max-threads' '--throttle' '--request-timeout' '--connect-timeout' '--disable-tlc-checks' '--proxy' '--proxy-auth' '--cookie-string' '--cookie-jar' '--cache-ttl' '--clear-cache' '--server' '--cache-dir' '--update' '--no-update' '--wp-content-dir' '--wp-plugins-dir' '--wp-version-detection' '--main-theme-detection' '--enumerate' '--exclude-content-based' '--plugins-list' '--plugins-detection' '--plugins-version-all' '--plugins-version-detection' '--themes-list' '--themes-detection' '--themes-version-all' '--themes-version-detection' '--timthumbs-list' '--timthumbs-detection' '--config-backups-list' '--config-backups-detection' '--db-exports-list' '--db-exports-detection' '--medias-detection' '--users-list' '--users-detection' '--passwords' '--usernames' '--multicall-max-passwords' '--password-attack' '--stealthy')
|
||||
COMPREPLY=()
|
||||
for _opt_ in "${OPTS[@]}"; do
|
||||
if [[ "$_opt_" == "$2"* ]]; then
|
||||
COMPREPLY+=("$_opt_")
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
complete -F __wpscan_completion wpscan
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||

|
||||

|
||||

|
||||
[](https://webchat.freenode.net/?channel=#bash-it)
|
||||
[](https://web.libera.chat/?channel=#bash-it)
|
||||
|
||||
**Bash-it** is a collection of community Bash commands and scripts for Bash 3.2+.
|
||||
(And a shameless ripoff of [oh-my-zsh](https://github.com/robbyrussell/oh-my-zsh) :smiley:)
|
||||
|
|
|
|||
|
|
@ -70,11 +70,13 @@ The contents of the prompt can be "reordered", all the "segments" (every piece o
|
|||
* ``battery`` - Battery information (you'll need to enable the ``battery`` plugin)
|
||||
* ``clock`` - Current time in ``HH:MM:SS`` format
|
||||
* ``cwd`` - Current working directory including full folder hierarchy (c.f. ``wd``\ )
|
||||
* ``duration`` - Duration of the last command. See :ref:`Command duration <command_duration>` for details.
|
||||
* ``gcloud`` - Current gcloud active account
|
||||
* ``hostname`` - Host name of machine
|
||||
* ``in_toolbox`` - Show identifier if running inside a `toolbox <https://github.com/containers/toolbox>`_
|
||||
* ``in_vim`` - Show identifier if running in ``:terminal`` from vim
|
||||
* ``k8s_context`` - Show current kubernetes context
|
||||
* ``k8s_namespace`` - Show current kubernetes namespace
|
||||
* ``last_status`` - Exit status of last run command
|
||||
* ``python_venv`` - Python virtual environment information (\ ``virtualenv``\ , ``venv``
|
||||
and ``conda`` supported)
|
||||
|
|
|
|||
|
|
@ -18,4 +18,4 @@ for file in "$@"; do
|
|||
fi
|
||||
done
|
||||
|
||||
exit $exit_code
|
||||
exit "${exit_code:-0}"
|
||||
|
|
|
|||
|
|
@ -18,4 +18,4 @@ for file in "$@"; do
|
|||
fi
|
||||
done
|
||||
|
||||
exit $exit_code
|
||||
exit "${exit_code:-0}"
|
||||
|
|
|
|||
30
install.sh
30
install.sh
|
|
@ -83,8 +83,8 @@ function _bash-it_check_for_backup() {
|
|||
fi
|
||||
echo -e "\033[0;33mBackup file already exists. Make sure to backup your .bashrc before running this installation.\033[0m" >&2
|
||||
|
||||
if ! [[ $overwrite_backup ]]; then
|
||||
while ! [[ $silent ]]; do
|
||||
if [[ -z "${overwrite_backup}" ]]; then
|
||||
while [[ -z "${silent}" ]]; do
|
||||
read -e -n 1 -r -p "Would you like to overwrite the existing backup? This will delete your existing backup file ($HOME/$BACKUP_FILE) [y/N] " RESP
|
||||
case $RESP in
|
||||
[yY])
|
||||
|
|
@ -100,9 +100,9 @@ function _bash-it_check_for_backup() {
|
|||
esac
|
||||
done
|
||||
fi
|
||||
if ! [[ $overwrite_backup ]]; then
|
||||
if [[ -z "${overwrite_backup}" ]]; then
|
||||
echo -e "\033[91mInstallation aborted. Please come back soon!\033[m"
|
||||
if [[ $silent ]]; then
|
||||
if [[ -n "${silent}" ]]; then
|
||||
echo -e "\033[91mUse \"-f\" flag to force overwrite of backup.\033[m"
|
||||
fi
|
||||
exit 1
|
||||
|
|
@ -114,8 +114,8 @@ function _bash-it_check_for_backup() {
|
|||
function _bash-it_modify_config_files() {
|
||||
_bash-it_check_for_backup
|
||||
|
||||
if ! [[ $silent ]]; then
|
||||
while ! [[ $append_to_config ]]; do
|
||||
if [[ -z "${silent}" ]]; then
|
||||
while [[ -z "${append_to_config}" ]]; do
|
||||
read -e -n 1 -r -p "Would you like to keep your $CONFIG_FILE and append bash-it templates at the end? [y/N] " choice
|
||||
case $choice in
|
||||
[yY])
|
||||
|
|
@ -131,7 +131,7 @@ function _bash-it_modify_config_files() {
|
|||
esac
|
||||
done
|
||||
fi
|
||||
if [[ $append_to_config ]]; then
|
||||
if [[ -n "${append_to_config}" ]]; then
|
||||
# backup/append
|
||||
_bash-it_backup_append
|
||||
else
|
||||
|
|
@ -174,17 +174,17 @@ done
|
|||
|
||||
shift $((OPTIND - 1))
|
||||
|
||||
if [[ $silent ]] && [[ $interactive ]]; then
|
||||
if [[ -n "${silent}" && -n "${interactive}" ]]; then
|
||||
echo -e "\033[91mOptions --silent and --interactive are mutually exclusive. Please choose one or the other.\033[m"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ $no_modify_config ]] && [[ $append_to_config ]]; then
|
||||
if [[ -n "${no_modify_config}" && -n "${append_to_config}" ]]; then
|
||||
echo -e "\033[91mOptions --no-modify-config and --append-to-config are mutually exclusive. Please choose one or the other.\033[m"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
BASH_IT="$(cd "$(dirname "$0")" && pwd)"
|
||||
BASH_IT="$(cd "${BASH_SOURCE%/*}" && pwd)"
|
||||
|
||||
case $OSTYPE in
|
||||
darwin*)
|
||||
|
|
@ -197,7 +197,7 @@ esac
|
|||
|
||||
BACKUP_FILE=$CONFIG_FILE.bak
|
||||
echo "Installing bash-it"
|
||||
if ! [[ $no_modify_config ]]; then
|
||||
if [[ -z "${no_modify_config}" ]]; then
|
||||
_bash-it_modify_config_files
|
||||
fi
|
||||
|
||||
|
|
@ -212,10 +212,10 @@ cite _about _param _example _group _author _version
|
|||
# shellcheck source=./lib/helpers.bash
|
||||
source "$BASH_IT/lib/helpers.bash"
|
||||
|
||||
if [[ $interactive ]] && ! [[ $silent ]]; then
|
||||
if [[ -n $interactive && -z "${silent}" ]]; then
|
||||
for type in "aliases" "plugins" "completion"; do
|
||||
echo -e "\033[0;32mEnabling $type\033[0m"
|
||||
_bash-it_load_some $type
|
||||
echo -e "\033[0;32mEnabling ${type}\033[0m"
|
||||
_bash-it_load_some "$type"
|
||||
done
|
||||
else
|
||||
echo ""
|
||||
|
|
@ -230,7 +230,7 @@ fi
|
|||
echo ""
|
||||
echo -e "\033[0;32mInstallation finished successfully! Enjoy bash-it!\033[0m"
|
||||
# shellcheck disable=SC2086
|
||||
echo -e "\033[0;32mTo start using it, open a new tab or 'source "$HOME/$CONFIG_FILE"'.\033[0m"
|
||||
echo -e "\033[0;32mTo start using it, open a new tab or 'source "~/$CONFIG_FILE"'.\033[0m"
|
||||
echo ""
|
||||
echo "To show the available aliases/completions/plugins, type one of the following:"
|
||||
echo " bash-it show aliases"
|
||||
|
|
|
|||
|
|
@ -11,8 +11,8 @@ BASH_IT_LOAD_PRIORITY_SEPARATOR="---"
|
|||
# To use this in Bash-it for inline replacements with `sed`, use the following syntax:
|
||||
# sed "${BASH_IT_SED_I_PARAMETERS[@]}" -e "..." file
|
||||
BASH_IT_SED_I_PARAMETERS=(-i)
|
||||
case "$(uname)" in
|
||||
Darwin*) BASH_IT_SED_I_PARAMETERS=(-i "")
|
||||
case "$OSTYPE" in
|
||||
'darwin'*) BASH_IT_SED_I_PARAMETERS=(-i "")
|
||||
esac
|
||||
|
||||
function _command_exists ()
|
||||
|
|
@ -23,7 +23,13 @@ function _command_exists ()
|
|||
_example '$ _command_exists ls && echo exists'
|
||||
_group 'lib'
|
||||
local msg="${2:-Command '$1' does not exist!}"
|
||||
type "$1" &> /dev/null || (_log_warning "$msg" && return 1) ;
|
||||
if type -t "$1" &> /dev/null
|
||||
then
|
||||
return 0
|
||||
else
|
||||
_log_warning "$msg"
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
function _binary_exists ()
|
||||
|
|
@ -34,7 +40,13 @@ function _binary_exists ()
|
|||
_example '$ _binary_exists ls && echo exists'
|
||||
_group 'lib'
|
||||
local msg="${2:-Binary '$1' does not exist!}"
|
||||
type -P "$1" &> /dev/null || (_log_warning "$msg" && return 1) ;
|
||||
if type -P "$1" &> /dev/null
|
||||
then
|
||||
return 0
|
||||
else
|
||||
_log_warning "$msg"
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
function _completion_exists ()
|
||||
|
|
@ -48,6 +60,22 @@ function _completion_exists ()
|
|||
complete -p "$1" &> /dev/null && _log_warning "$msg" ;
|
||||
}
|
||||
|
||||
function _bash_it_homebrew_check()
|
||||
{
|
||||
if _binary_exists 'brew'
|
||||
then # Homebrew is installed
|
||||
if [[ "${BASH_IT_HOMEBREW_PREFIX:-unset}" == 'unset' ]]
|
||||
then # variable isn't set
|
||||
BASH_IT_HOMEBREW_PREFIX="$(brew --prefix)"
|
||||
else
|
||||
true # Variable is set already, don't invoke `brew`.
|
||||
fi
|
||||
else # Homebrew is not installed.
|
||||
BASH_IT_HOMEBREW_PREFIX= # clear variable, if set to anything.
|
||||
false # return failure if brew not installed.
|
||||
fi
|
||||
}
|
||||
|
||||
function _make_reload_alias() {
|
||||
echo "source \${BASH_IT}/scripts/reloader.bash ${1} ${2}"
|
||||
}
|
||||
|
|
@ -140,7 +168,7 @@ bash-it ()
|
|||
$func $arg
|
||||
done
|
||||
|
||||
if [ -n "$BASH_IT_AUTOMATIC_RELOAD_AFTER_CONFIG_CHANGE" ]; then
|
||||
if [ -n "${BASH_IT_AUTOMATIC_RELOAD_AFTER_CONFIG_CHANGE:-}" ]; then
|
||||
_bash-it-reload
|
||||
fi
|
||||
else
|
||||
|
|
@ -194,7 +222,10 @@ _bash-it-update-stable() {
|
|||
_bash-it-update- stable "$@"
|
||||
}
|
||||
|
||||
_bash-it_pull_and_update_inner() {
|
||||
_bash-it_update_migrate_and_restart() {
|
||||
_about 'Checks out the wanted version, pops directory and restart. Does not return (because of the restart!)'
|
||||
_param '1: Which branch to checkout to'
|
||||
_param '2: Which type of version we are using'
|
||||
git checkout "$1" &> /dev/null
|
||||
if [[ $? -eq 0 ]]; then
|
||||
echo "Bash-it successfully updated."
|
||||
|
|
@ -203,7 +234,9 @@ _bash-it_pull_and_update_inner() {
|
|||
_bash-it-migrate
|
||||
echo ""
|
||||
echo "All done, enjoy!"
|
||||
bash-it reload
|
||||
# Don't forget to restore the original pwd!
|
||||
popd &> /dev/null
|
||||
_bash-it-restart
|
||||
else
|
||||
echo "Error updating Bash-it, please, check if your Bash-it installation folder (${BASH_IT}) is clean."
|
||||
fi
|
||||
|
|
@ -220,9 +253,11 @@ _bash-it-update-() {
|
|||
silent=true
|
||||
fi
|
||||
done
|
||||
local old_pwd="${PWD}"
|
||||
|
||||
cd "${BASH_IT}" || return
|
||||
pushd "${BASH_IT}" &> /dev/null || return
|
||||
|
||||
DIFF=$(git diff --name-status)
|
||||
[ -n "$DIFF" ] && echo -e "Local changes detected in bash-it directory. Clean '$BASH_IT' directory to proceed.\n$DIFF" && return 1
|
||||
|
||||
if [ -z "$BASH_IT_REMOTE" ]; then
|
||||
BASH_IT_REMOTE="origin"
|
||||
|
|
@ -240,6 +275,7 @@ _bash-it-update-() {
|
|||
|
||||
if [[ -z "$TARGET" ]]; then
|
||||
echo "Can not find tags, so can not update to latest stable version..."
|
||||
popd &> /dev/null
|
||||
return
|
||||
fi
|
||||
else
|
||||
|
|
@ -280,12 +316,12 @@ _bash-it-update-() {
|
|||
|
||||
if [[ $silent ]]; then
|
||||
echo "Updating to ${TARGET}($(git log -1 --format=%h "${TARGET}"))..."
|
||||
_bash-it_pull_and_update_inner $TARGET $version
|
||||
_bash-it_update_migrate_and_restart $TARGET $version
|
||||
else
|
||||
read -e -n 1 -p "Would you like to update to ${TARGET}($(git log -1 --format=%h "${TARGET}"))? [Y/n] " RESP
|
||||
case $RESP in
|
||||
[yY]|"")
|
||||
_bash-it_pull_and_update_inner $TARGET $version
|
||||
_bash-it_update_migrate_and_restart $TARGET $version
|
||||
;;
|
||||
[nN])
|
||||
echo "Not updating…"
|
||||
|
|
@ -302,7 +338,7 @@ _bash-it-update-() {
|
|||
echo "Bash-it is up to date, nothing to do!"
|
||||
fi
|
||||
fi
|
||||
cd "${old_pwd}" &> /dev/null || return
|
||||
popd &> /dev/null
|
||||
}
|
||||
|
||||
_bash-it-migrate() {
|
||||
|
|
@ -316,7 +352,7 @@ _bash-it-migrate() {
|
|||
do
|
||||
for f in `sort <(compgen -G "${BASH_IT}/$file_type/enabled/*.bash")`
|
||||
do
|
||||
typeset ff=$(basename $f)
|
||||
typeset ff="${f##*/}"
|
||||
|
||||
# Get the type of component from the extension
|
||||
typeset single_type=$(echo $ff | sed -e 's/.*\.\(.*\)\.bash/\1/g' | sed 's/aliases/alias/g')
|
||||
|
|
@ -330,8 +366,8 @@ _bash-it-migrate() {
|
|||
disable_func="_disable-$single_type"
|
||||
enable_func="_enable-$single_type"
|
||||
|
||||
$disable_func $component_name
|
||||
$enable_func $component_name
|
||||
$disable_func "$component_name"
|
||||
$enable_func "$component_name"
|
||||
done
|
||||
done
|
||||
|
||||
|
|
@ -351,7 +387,7 @@ _bash-it-version() {
|
|||
|
||||
cd "${BASH_IT}" || return
|
||||
|
||||
if [ -z $BASH_IT_REMOTE ]; then
|
||||
if [ -z "${BASH_IT_REMOTE:-}" ]; then
|
||||
BASH_IT_REMOTE="origin"
|
||||
fi
|
||||
|
||||
|
|
@ -425,7 +461,7 @@ _bash-it-restart() {
|
|||
_about 'restarts the shell in order to fully reload it'
|
||||
_group 'lib'
|
||||
|
||||
saved_pwd=$(pwd)
|
||||
saved_pwd="${PWD}"
|
||||
|
||||
case $OSTYPE in
|
||||
darwin*)
|
||||
|
|
@ -477,7 +513,7 @@ _bash-it-describe ()
|
|||
do
|
||||
# Check for both the old format without the load priority, and the extended format with the priority
|
||||
declare enabled_files enabled_file
|
||||
enabled_file=$(basename $f)
|
||||
enabled_file="${f##*/}"
|
||||
enabled_files=$(sort <(compgen -G "${BASH_IT}/enabled/*$BASH_IT_LOAD_PRIORITY_SEPARATOR${enabled_file}") <(compgen -G "${BASH_IT}/$subdirectory/enabled/${enabled_file}") <(compgen -G "${BASH_IT}/$subdirectory/enabled/*$BASH_IT_LOAD_PRIORITY_SEPARATOR${enabled_file}") | wc -l)
|
||||
|
||||
if [ $enabled_files -gt 0 ]; then
|
||||
|
|
@ -579,9 +615,9 @@ _disable-thing ()
|
|||
printf '%s\n' "sorry, $file_entity does not appear to be an enabled $file_type."
|
||||
return
|
||||
fi
|
||||
rm "${BASH_IT}/$subdirectory/enabled/$(basename $plugin)"
|
||||
rm "${BASH_IT}/$subdirectory/enabled/${plugin##*/}"
|
||||
else
|
||||
rm "${BASH_IT}/enabled/$(basename $plugin_global)"
|
||||
rm "${BASH_IT}/enabled/${plugin_global##*/}"
|
||||
fi
|
||||
fi
|
||||
|
||||
|
|
@ -657,7 +693,7 @@ _enable-thing ()
|
|||
return
|
||||
fi
|
||||
|
||||
to_enable=$(basename $to_enable)
|
||||
to_enable="${to_enable##*/}"
|
||||
# Check for existence of the file using a wildcard, since we don't know which priority might have been used when enabling it.
|
||||
typeset enabled_plugin=$(command ls "${BASH_IT}/$subdirectory/enabled/"{[0-9][0-9][0-9]$BASH_IT_LOAD_PRIORITY_SEPARATOR$to_enable,$to_enable} 2>/dev/null | head -1)
|
||||
if [ ! -z "$enabled_plugin" ] ; then
|
||||
|
|
@ -813,3 +849,30 @@ then
|
|||
fi
|
||||
}
|
||||
fi
|
||||
|
||||
# `_bash-it-find-in-ancestor` uses the shell's ability to run a function in
|
||||
# a subshell to simplify our search to a simple `cd ..` and `[[ -r $1 ]]`
|
||||
# without any external dependencies. Let the shell do what it's good at.
|
||||
function _bash-it-find-in-ancestor() (
|
||||
about 'searches parents of the current directory for any of the specified file names'
|
||||
group 'helpers'
|
||||
param '*: names of files or folders to search for'
|
||||
returns '0: prints path of closest matching ancestor directory to stdout'
|
||||
returns '1: no match found'
|
||||
returns '2: improper usage of shell builtin' # uncommon
|
||||
example '_bash-it-find-in-ancestor .git .hg'
|
||||
example '_bash-it-find-in-ancestor GNUmakefile Makefile makefile'
|
||||
|
||||
local kin
|
||||
# To keep things simple, we do not search the root dir.
|
||||
while [[ "${PWD}" != '/' ]]; do
|
||||
for kin in "$@"; do
|
||||
if [[ -r "${PWD}/${kin}" ]]; then
|
||||
printf '%s' "${PWD}"
|
||||
return "$?"
|
||||
fi
|
||||
done
|
||||
command cd .. || return "$?"
|
||||
done
|
||||
return 1
|
||||
)
|
||||
|
|
|
|||
16
lib/log.bash
16
lib/log.bash
|
|
@ -22,8 +22,8 @@ function _log_general()
|
|||
param '3: message to log'
|
||||
group 'log'
|
||||
|
||||
message=$2${BASH_IT_LOG_PREFIX}$3
|
||||
_has_colors && echo -e "$1${message}${echo_normal}" || echo -e "${message}"
|
||||
message=$2${BASH_IT_LOG_PREFIX:-default: }$3
|
||||
_has_colors && echo -e "$1${message}${echo_normal:-}" || echo -e "${message}"
|
||||
}
|
||||
|
||||
function _log_debug()
|
||||
|
|
@ -33,8 +33,8 @@ function _log_debug()
|
|||
example '$ _log_debug "Loading plugin git..."'
|
||||
group 'log'
|
||||
|
||||
[[ "$BASH_IT_LOG_LEVEL" -ge $BASH_IT_LOG_LEVEL_ALL ]] || return 0
|
||||
_log_general "${echo_green}" "DEBUG: " "$1"
|
||||
[[ "${BASH_IT_LOG_LEVEL:-0}" -ge $BASH_IT_LOG_LEVEL_ALL ]] || return 0
|
||||
_log_general "${echo_green:-}" "DEBUG: " "$1"
|
||||
}
|
||||
|
||||
function _log_warning()
|
||||
|
|
@ -44,8 +44,8 @@ function _log_warning()
|
|||
example '$ _log_warning "git binary not found, disabling git plugin..."'
|
||||
group 'log'
|
||||
|
||||
[[ "$BASH_IT_LOG_LEVEL" -ge $BASH_IT_LOG_LEVEL_WARNING ]] || return 0
|
||||
_log_general "${echo_yellow}" " WARN: " "$1"
|
||||
[[ "${BASH_IT_LOG_LEVEL:-0}" -ge $BASH_IT_LOG_LEVEL_WARNING ]] || return 0
|
||||
_log_general "${echo_yellow:-}" " WARN: " "$1"
|
||||
}
|
||||
|
||||
function _log_error()
|
||||
|
|
@ -55,6 +55,6 @@ function _log_error()
|
|||
example '$ _log_error "Failed to load git plugin..."'
|
||||
group 'log'
|
||||
|
||||
[[ "$BASH_IT_LOG_LEVEL" -ge $BASH_IT_LOG_LEVEL_ERROR ]] || return 0
|
||||
_log_general "${echo_red}" "ERROR: " "$1"
|
||||
[[ "${BASH_IT_LOG_LEVEL:-0}" -ge $BASH_IT_LOG_LEVEL_ERROR ]] || return 0
|
||||
_log_general "${echo_red:-}" "ERROR: " "$1"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
if [[ $BASH_PREVIEW ]];
|
||||
if [[ "${BASH_PREVIEW:-}" ]];
|
||||
then
|
||||
unset BASH_PREVIEW #Prevent infinite looping
|
||||
echo "
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#!/usr/bin/env bash
|
||||
# shellcheck shell=bash
|
||||
#
|
||||
# A collection of reusable functions.
|
||||
|
||||
|
|
@ -6,22 +6,25 @@
|
|||
# Generic utilies
|
||||
###########################################################################
|
||||
|
||||
_bash-it-get-component-name-from-path() {
|
||||
# filename without path
|
||||
filename=${1##*/}
|
||||
# filename without path or priority
|
||||
filename=${filename##*---}
|
||||
# filename without path, priority or extension
|
||||
echo ${filename%.*.bash}
|
||||
function _bash-it-get-component-name-from-path() {
|
||||
local filename
|
||||
# filename without path
|
||||
filename="${1##*/}"
|
||||
# filename without path or priority
|
||||
filename="${filename##*${BASH_IT_LOAD_PRIORITY_SEPARATOR?}}"
|
||||
# filename without path, priority or extension
|
||||
echo "${filename%.*.bash}"
|
||||
}
|
||||
|
||||
_bash-it-get-component-type-from-path() {
|
||||
# filename without path
|
||||
filename=${1##*/}
|
||||
# filename without path or priority
|
||||
filename=${filename##*---}
|
||||
# extension
|
||||
echo ${filename} | cut -d '.' -f 2
|
||||
function _bash-it-get-component-type-from-path() {
|
||||
local filename
|
||||
# filename without path
|
||||
filename="${1##*/}"
|
||||
# filename without extension
|
||||
filename="${filename%.bash}"
|
||||
# extension without priority or name
|
||||
filename="${filename##*.}"
|
||||
echo "${filename}"
|
||||
}
|
||||
|
||||
# This function searches an array for an exact match against the term passed
|
||||
|
|
@ -43,96 +46,97 @@ _bash-it-get-component-type-from-path() {
|
|||
# contains pear!
|
||||
#
|
||||
#
|
||||
_bash-it-array-contains-element() {
|
||||
local e
|
||||
for e in "${@:2}"; do
|
||||
[[ "$e" == "$1" ]] && return 0
|
||||
done
|
||||
return 1
|
||||
function _bash-it-array-contains-element() {
|
||||
local e
|
||||
for e in "${@:2}"; do
|
||||
[[ "$e" == "$1" ]] && return 0
|
||||
done
|
||||
return 1
|
||||
}
|
||||
|
||||
# Dedupe a simple array of words without spaces.
|
||||
_bash-it-array-dedup() {
|
||||
echo "$*" | tr ' ' '\n' | sort -u | tr '\n' ' '
|
||||
function _bash-it-array-dedup() {
|
||||
local IFS=$'\n'
|
||||
echo "$@" | tr ' ' '\n' | sort -u
|
||||
}
|
||||
|
||||
# Outputs a full path of the grep found on the filesystem
|
||||
_bash-it-grep() {
|
||||
if [[ -z "${BASH_IT_GREP}" ]] ; then
|
||||
export BASH_IT_GREP="$(which egrep || which grep || '/usr/bin/grep')"
|
||||
fi
|
||||
printf "%s " "${BASH_IT_GREP}"
|
||||
function _bash-it-grep() {
|
||||
: "${BASH_IT_GREP:=$(type -p egrep || type -p grep)}"
|
||||
printf "%s" "${BASH_IT_GREP:-'/usr/bin/grep'}"
|
||||
}
|
||||
|
||||
|
||||
###########################################################################
|
||||
# Component-specific functions (component is either an alias, a plugin, or a
|
||||
# completion).
|
||||
###########################################################################
|
||||
|
||||
_bash-it-component-help() {
|
||||
local component=$(_bash-it-pluralize-component "${1}")
|
||||
local file=$(_bash-it-component-cache-file ${component})
|
||||
if [[ ! -s "${file}" || -z $(find "${file}" -mmin -300) ]] ; then
|
||||
rm -f "${file}" 2>/dev/null
|
||||
local func="_bash-it-${component}"
|
||||
${func} | $(_bash-it-grep) -E ' \[' | cat > ${file}
|
||||
fi
|
||||
cat "${file}"
|
||||
function _bash-it-component-help() {
|
||||
local component file func
|
||||
component="$(_bash-it-pluralize-component "${1}")"
|
||||
file="$(_bash-it-component-cache-file "${component}")"
|
||||
if [[ ! -s "${file}" || -z "$(find "${file}" -mmin -300)" ]]; then
|
||||
rm -f "${file}" 2> /dev/null
|
||||
func="_bash-it-${component}"
|
||||
"${func}" | ${BASH_IT_GREP:-$(_bash-it-grep)} -E ' \[' > "${file}"
|
||||
fi
|
||||
cat "${file}"
|
||||
}
|
||||
|
||||
_bash-it-component-cache-file() {
|
||||
local component=$(_bash-it-pluralize-component "${1}")
|
||||
local file="${BASH_IT}/tmp/cache/${component}"
|
||||
[[ -f ${file} ]] || mkdir -p $(dirname ${file})
|
||||
printf "${file}"
|
||||
function _bash-it-component-cache-file() {
|
||||
local component file
|
||||
component="$(_bash-it-pluralize-component "${1}")"
|
||||
file="${BASH_IT?}/tmp/cache/${component}"
|
||||
[[ -f "${file}" ]] || mkdir -p "${file%/*}"
|
||||
printf '%s' "${file}"
|
||||
}
|
||||
|
||||
_bash-it-pluralize-component() {
|
||||
local component="${1}"
|
||||
local len=$(( ${#component} - 1 ))
|
||||
# pluralize component name for consistency
|
||||
[[ ${component:${len}:1} != 's' ]] && component="${component}s"
|
||||
[[ ${component} == "alias" ]] && component="aliases"
|
||||
printf ${component}
|
||||
function _bash-it-pluralize-component() {
|
||||
local component="${1}"
|
||||
local -i len=$((${#component} - 1))
|
||||
# pluralize component name for consistency
|
||||
[[ "${component:${len}:1}" != 's' ]] && component="${component}s"
|
||||
[[ "${component}" == "alias" ]] && component="aliases"
|
||||
printf '%s' "${component}"
|
||||
}
|
||||
|
||||
_bash-it-clean-component-cache() {
|
||||
local component="$1"
|
||||
local cache
|
||||
local -a BASH_IT_COMPONENTS=(aliases plugins completions)
|
||||
if [[ -z ${component} ]] ; then
|
||||
for component in "${BASH_IT_COMPONENTS[@]}" ; do
|
||||
_bash-it-clean-component-cache "${component}"
|
||||
done
|
||||
else
|
||||
cache="$(_bash-it-component-cache-file ${component})"
|
||||
if [[ -f "${cache}" ]] ; then
|
||||
rm -f "${cache}"
|
||||
fi
|
||||
fi
|
||||
function _bash-it-clean-component-cache() {
|
||||
local component="$1"
|
||||
local cache
|
||||
local -a BASH_IT_COMPONENTS=(aliases plugins completions)
|
||||
if [[ -z "${component}" ]]; then
|
||||
for component in "${BASH_IT_COMPONENTS[@]}"; do
|
||||
_bash-it-clean-component-cache "${component}"
|
||||
done
|
||||
else
|
||||
cache="$(_bash-it-component-cache-file "${component}")"
|
||||
if [[ -f "${cache}" ]]; then
|
||||
rm -f "${cache}"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
# Returns an array of items within each compoenent.
|
||||
_bash-it-component-list() {
|
||||
local component="$1"
|
||||
_bash-it-component-help "${component}" | awk '{print $1}' | uniq | sort | tr '\n' ' '
|
||||
function _bash-it-component-list() {
|
||||
local IFS=$'\n' component="$1"
|
||||
_bash-it-component-help "${component}" | awk '{print $1}' | sort -u
|
||||
}
|
||||
|
||||
_bash-it-component-list-matching() {
|
||||
local component="$1"; shift
|
||||
local term="$1"
|
||||
_bash-it-component-help "${component}" | $(_bash-it-grep) -E -- "${term}" | awk '{print $1}' | sort | uniq
|
||||
function _bash-it-component-list-matching() {
|
||||
local component="$1"
|
||||
shift
|
||||
local term="$1"
|
||||
_bash-it-component-help "${component}" | ${BASH_IT_GREP:-$(_bash-it-grep)} -E -- "${term}" | awk '{print $1}' | sort -u
|
||||
}
|
||||
|
||||
_bash-it-component-list-enabled() {
|
||||
local component="$1"
|
||||
_bash-it-component-help "${component}" | $(_bash-it-grep) -E '\[x\]' | awk '{print $1}' | uniq | sort | tr '\n' ' '
|
||||
function _bash-it-component-list-enabled() {
|
||||
local IFS=$'\n' component="$1"
|
||||
_bash-it-component-help "${component}" | ${BASH_IT_GREP:-$(_bash-it-grep)} -E '\[x\]' | awk '{print $1}' | sort -u
|
||||
}
|
||||
|
||||
_bash-it-component-list-disabled() {
|
||||
local component="$1"
|
||||
_bash-it-component-help "${component}" | $(_bash-it-grep) -E -v '\[x\]' | awk '{print $1}' | uniq | sort | tr '\n' ' '
|
||||
function _bash-it-component-list-disabled() {
|
||||
local IFS=$'\n' component="$1"
|
||||
_bash-it-component-help "${component}" | ${BASH_IT_GREP:-$(_bash-it-grep)} -E -v '\[x\]' | awk '{print $1}' | sort -u
|
||||
}
|
||||
|
||||
# Checks if a given item is enabled for a particular component/file-type.
|
||||
|
|
@ -143,10 +147,10 @@ _bash-it-component-list-disabled() {
|
|||
#
|
||||
# Examples:
|
||||
# _bash-it-component-item-is-enabled alias git && echo "git alias is enabled"
|
||||
_bash-it-component-item-is-enabled() {
|
||||
local component="$1"
|
||||
local item="$2"
|
||||
_bash-it-component-help "${component}" | $(_bash-it-grep) -E '\[x\]' | $(_bash-it-grep) -E -q -- "^${item}\s"
|
||||
function _bash-it-component-item-is-enabled() {
|
||||
local component="$1"
|
||||
local item="$2"
|
||||
_bash-it-component-help "${component}" | ${BASH_IT_GREP:-$(_bash-it-grep)} -E '\[x\]' | ${BASH_IT_GREP:-$(_bash-it-grep)} -E -q -- "^${item}\s"
|
||||
}
|
||||
|
||||
# Checks if a given item is disabled for a particular component/file-type.
|
||||
|
|
@ -157,8 +161,8 @@ _bash-it-component-item-is-enabled() {
|
|||
#
|
||||
# Examples:
|
||||
# _bash-it-component-item-is-disabled alias git && echo "git aliases are disabled"
|
||||
_bash-it-component-item-is-disabled() {
|
||||
local component="$1"
|
||||
local item="$2"
|
||||
_bash-it-component-help "${component}" | $(_bash-it-grep) -E -v '\[x\]' | $(_bash-it-grep) -E -q -- "^${item}\s"
|
||||
function _bash-it-component-item-is-disabled() {
|
||||
local component="$1"
|
||||
local item="$2"
|
||||
_bash-it-component-help "${component}" | ${BASH_IT_GREP:-$(_bash-it-grep)} -E -v '\[x\]' | ${BASH_IT_GREP:-$(_bash-it-grep)} -E -q -- "^${item}\s"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,6 +19,8 @@ about-plugin 'Automatic completion of aliases'
|
|||
# Automatically add completion for all aliases to commands having completion functions
|
||||
function alias_completion {
|
||||
local namespace="alias_completion"
|
||||
local tmp_file completion_loader alias_name alias_tokens line completions
|
||||
local alias_arg_words new_completion compl_func compl_wrapper
|
||||
|
||||
# parse function based completion definitions, where capture group 2 => function and 3 => trigger
|
||||
local compl_regex='complete( +[^ ]+)* -F ([^ ]+) ("[^"]+"|[^ ]+)'
|
||||
|
|
@ -26,28 +28,25 @@ function alias_completion {
|
|||
local alias_regex="alias( -- | )([^=]+)='(\"[^\"]+\"|[^ ]+)(( +[^ ]+)*)'"
|
||||
|
||||
# create array of function completion triggers, keeping multi-word triggers together
|
||||
eval "local completions=($(complete -p | sed -Ene "/$compl_regex/s//'\3'/p"))"
|
||||
eval "completions=($(complete -p | sed -Ene "/$compl_regex/s//'\3'/p"))"
|
||||
((${#completions[@]} == 0)) && return 0
|
||||
|
||||
# create temporary file for wrapper functions and completions
|
||||
local tmp_file
|
||||
tmp_file="$(mktemp -t "${namespace}-${RANDOM}XXXXXX")" || return 1
|
||||
|
||||
local completion_loader
|
||||
completion_loader="$(complete -p -D 2> /dev/null | sed -Ene 's/.* -F ([^ ]*).*/\1/p')"
|
||||
|
||||
# read in "<alias> '<aliased command>' '<command args>'" lines from defined aliases
|
||||
local line
|
||||
|
||||
# shellcheck disable=SC2162
|
||||
# some aliases do have backslashes that needs to be interpreted
|
||||
# shellcheck disable=SC2162
|
||||
while read line; do
|
||||
eval "local alias_tokens; alias_tokens=($line)" 2> /dev/null || continue # some alias arg patterns cause an eval parse error
|
||||
local alias_name="${alias_tokens[0]}" alias_cmd="${alias_tokens[1]}" alias_args="${alias_tokens[2]# }"
|
||||
eval "alias_tokens=($line)" 2> /dev/null || continue # some alias arg patterns cause an eval parse error
|
||||
# shellcheck disable=SC2154 # see `eval` above
|
||||
alias_name="${alias_tokens[0]}" alias_cmd="${alias_tokens[1]}" alias_args="${alias_tokens[2]# }"
|
||||
|
||||
# skip aliases to pipes, boolean control structures and other command lists
|
||||
# (leveraging that eval errs out if $alias_args contains unquoted shell metacharacters)
|
||||
eval "local alias_arg_words; alias_arg_words=($alias_args)" 2> /dev/null || continue
|
||||
eval "alias_arg_words=($alias_args)" 2> /dev/null || continue
|
||||
# avoid expanding wildcards
|
||||
read -a alias_arg_words <<< "$alias_args"
|
||||
|
||||
|
|
@ -63,15 +62,15 @@ function alias_completion {
|
|||
continue
|
||||
fi
|
||||
fi
|
||||
local new_completion="$(complete -p "$alias_cmd" 2> /dev/null)"
|
||||
new_completion="$(complete -p "$alias_cmd" 2> /dev/null)"
|
||||
|
||||
# create a wrapper inserting the alias arguments if any
|
||||
if [[ -n $alias_args ]]; then
|
||||
local compl_func="${new_completion/#* -F /}"
|
||||
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
|
||||
local compl_wrapper="_${namespace}::${alias_name}"
|
||||
if [[ "${compl_func#_"$namespace"::}" == "$compl_func" ]]; then
|
||||
compl_wrapper="_${namespace}::${alias_name}"
|
||||
echo "function $compl_wrapper {
|
||||
local compl_word=\$2
|
||||
local prec_word=\$3
|
||||
|
|
|
|||
|
|
@ -1,12 +1,15 @@
|
|||
# shellcheck shell=bash
|
||||
cite about-plugin
|
||||
about-plugin 'Autojump configuration, see https://github.com/wting/autojump for more details'
|
||||
|
||||
# Only supports the Homebrew variant, Debian and Arch at the moment.
|
||||
# Feel free to provide a PR to support other install locations
|
||||
if command -v brew &>/dev/null && [[ -s $(brew --prefix)/etc/profile.d/autojump.sh ]]; then
|
||||
. $(brew --prefix)/etc/profile.d/autojump.sh
|
||||
elif command -v dpkg &>/dev/null && dpkg -s autojump &>/dev/null ; then
|
||||
. "$(dpkg-query -S autojump.sh | cut -d' ' -f2)"
|
||||
elif command -v pacman &>/dev/null && pacman -Q autojump &>/dev/null ; then
|
||||
. "$(pacman -Ql autojump | grep autojump.sh | cut -d' ' -f2)"
|
||||
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
|
||||
# shellcheck disable=SC1090
|
||||
source "$(dpkg-query -S autojump.sh | cut -d' ' -f2)"
|
||||
elif _command_exists pacman && pacman -Q autojump &> /dev/null; then
|
||||
# shellcheck disable=SC1090
|
||||
source "$(pacman -Ql autojump | grep autojump.sh | cut -d' ' -f2)"
|
||||
fi
|
||||
|
|
|
|||
|
|
@ -1,215 +1,180 @@
|
|||
# shellcheck shell=bash
|
||||
cite about-plugin
|
||||
about-plugin 'miscellaneous tools'
|
||||
|
||||
function ips ()
|
||||
{
|
||||
about 'display all ip addresses for this host'
|
||||
group 'base'
|
||||
if command -v ifconfig &>/dev/null
|
||||
then
|
||||
ifconfig | awk '/inet /{ gsub(/addr:/, ""); print $2 }'
|
||||
elif command -v ip &>/dev/null
|
||||
then
|
||||
ip addr | grep -oP 'inet \K[\d.]+'
|
||||
else
|
||||
echo "You don't have ifconfig or ip command installed!"
|
||||
fi
|
||||
function ips() {
|
||||
about 'display all ip addresses for this host'
|
||||
group 'base'
|
||||
if _command_exists ifconfig; then
|
||||
ifconfig | awk '/inet /{ gsub(/addr:/, ""); print $2 }'
|
||||
elif _command_exists ip; then
|
||||
ip addr | grep -oP 'inet \K[\d.]+'
|
||||
else
|
||||
echo "You don't have ifconfig or ip command installed!"
|
||||
fi
|
||||
}
|
||||
|
||||
function down4me ()
|
||||
{
|
||||
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'
|
||||
function down4me() {
|
||||
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'
|
||||
}
|
||||
|
||||
function myip ()
|
||||
{
|
||||
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
|
||||
res=$(curl -fs "${url}")
|
||||
if [ $? -eq 0 ];then
|
||||
break;
|
||||
fi
|
||||
done
|
||||
res=$(echo "$res" | grep -Eo '[0-9\.]+')
|
||||
echo -e "Your public IP is: ${echo_bold_green} $res ${echo_normal}"
|
||||
function myip() {
|
||||
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
|
||||
break
|
||||
fi
|
||||
done
|
||||
res="$(echo "$res" | grep -Eo '[0-9\.]+')"
|
||||
echo -e "Your public IP is: ${echo_bold_green-} $res ${echo_normal-}"
|
||||
}
|
||||
|
||||
function pickfrom ()
|
||||
{
|
||||
about 'picks random line from file'
|
||||
param '1: filename'
|
||||
example '$ pickfrom /usr/share/dict/words'
|
||||
group 'base'
|
||||
local file=$1
|
||||
[ -z "$file" ] && reference $FUNCNAME && return
|
||||
length=$(cat $file | wc -l)
|
||||
n=$(expr $RANDOM \* $length \/ 32768 + 1)
|
||||
head -n $n $file | tail -1
|
||||
function pickfrom() {
|
||||
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
|
||||
reference "${FUNCNAME[0]}" && return
|
||||
fi
|
||||
length="$(wc -l < "$file")"
|
||||
n=$((RANDOM * length / 32768 + 1))
|
||||
head -n "$n" "$file" | tail -1
|
||||
}
|
||||
|
||||
function passgen ()
|
||||
{
|
||||
about 'generates random password from dictionary words'
|
||||
param 'optional integer length'
|
||||
param 'if unset, defaults to 4'
|
||||
example '$ passgen'
|
||||
example '$ passgen 6'
|
||||
group 'base'
|
||||
local i pass length=${1:-4}
|
||||
pass=$(echo $(for i in $(eval echo "{1..$length}"); do pickfrom /usr/share/dict/words; done))
|
||||
echo "With spaces (easier to memorize): $pass"
|
||||
echo "Without (use this as the password): $(echo $pass | tr -d ' ')"
|
||||
function passgen() {
|
||||
about 'generates random password from dictionary words'
|
||||
param 'optional integer length'
|
||||
param 'if unset, defaults to 4'
|
||||
example '$ passgen'
|
||||
example '$ passgen 6'
|
||||
group 'base'
|
||||
local -i i length=${1:-4}
|
||||
local pass
|
||||
# shellcheck disable=SC2034
|
||||
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'/}"
|
||||
}
|
||||
|
||||
# Create alias pass to passgen when pass isn't installed or
|
||||
# BASH_IT_LEGACY_PASS is true.
|
||||
if ! command -v pass &>/dev/null || [ "$BASH_IT_LEGACY_PASS" = true ]
|
||||
then
|
||||
alias pass=passgen
|
||||
if ! _command_exists pass || [[ "${BASH_IT_LEGACY_PASS:-}" = true ]]; then
|
||||
alias pass=passgen
|
||||
fi
|
||||
|
||||
function pmdown ()
|
||||
{
|
||||
about 'preview markdown file in a browser'
|
||||
param '1: markdown file'
|
||||
example '$ pmdown README.md'
|
||||
group 'base'
|
||||
if command -v markdown &>/dev/null
|
||||
then
|
||||
markdown $1 | browser
|
||||
else
|
||||
echo "You don't have a markdown command installed!"
|
||||
fi
|
||||
}
|
||||
if _command_exists markdown && _command_exists browser; then
|
||||
function pmdown() {
|
||||
about 'preview markdown file in a browser'
|
||||
param '1: markdown file'
|
||||
example '$ pmdown README.md'
|
||||
group 'base'
|
||||
|
||||
function mkcd ()
|
||||
{
|
||||
about 'make one or more directories and cd into the last one'
|
||||
param 'one or more directories to create'
|
||||
example '$ mkcd foo'
|
||||
example '$ mkcd /tmp/img/photos/large'
|
||||
example '$ mkcd foo foo1 foo2 fooN'
|
||||
example '$ mkcd /tmp/img/photos/large /tmp/img/photos/self /tmp/img/photos/Beijing'
|
||||
group 'base'
|
||||
mkdir -p -- "$@" && eval cd -- "\"\$$#\""
|
||||
}
|
||||
|
||||
function lsgrep ()
|
||||
{
|
||||
about 'search through directory contents with grep'
|
||||
group 'base'
|
||||
ls | grep "$*"
|
||||
}
|
||||
|
||||
function quiet ()
|
||||
{
|
||||
about 'what *does* this do?'
|
||||
group 'base'
|
||||
$* &> /dev/null &
|
||||
}
|
||||
|
||||
function banish-cookies ()
|
||||
{
|
||||
about 'redirect .adobe and .macromedia files to /dev/null'
|
||||
group 'base'
|
||||
rm -r ~/.macromedia ~/.adobe
|
||||
ln -s /dev/null ~/.adobe
|
||||
ln -s /dev/null ~/.macromedia
|
||||
}
|
||||
|
||||
function usage ()
|
||||
{
|
||||
about 'disk usage per directory, in Mac OS X and Linux'
|
||||
param '1: directory name'
|
||||
group 'base'
|
||||
if [ $(uname) = "Darwin" ]; then
|
||||
if [ -n "$1" ]; then
|
||||
du -hd 1 "$1"
|
||||
else
|
||||
du -hd 1
|
||||
fi
|
||||
|
||||
elif [ $(uname) = "Linux" ]; then
|
||||
if [ -n "$1" ]; then
|
||||
du -h --max-depth=1 "$1"
|
||||
else
|
||||
du -h --max-depth=1
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
if [ ! -e "${BASH_IT}/plugins/enabled/todo.plugin.bash" ] && [ ! -e "${BASH_IT}/plugins/enabled/*${BASH_IT_LOAD_PRIORITY_SEPARATOR}todo.plugin.bash" ]; then
|
||||
# if user has installed todo plugin, skip this...
|
||||
function t ()
|
||||
{
|
||||
about 'one thing todo'
|
||||
param 'if not set, display todo item'
|
||||
param '1: todo text'
|
||||
if [[ "$*" == "" ]] ; then
|
||||
cat ~/.t
|
||||
else
|
||||
echo "$*" > ~/.t
|
||||
fi
|
||||
}
|
||||
markdown "${1?}" | browser
|
||||
}
|
||||
fi
|
||||
|
||||
function command_exists ()
|
||||
{
|
||||
about 'checks for existence of a command'
|
||||
param '1: command to check'
|
||||
example '$ command_exists ls && echo exists'
|
||||
group 'base'
|
||||
type "$1" &> /dev/null ;
|
||||
function mkcd() {
|
||||
about 'make one or more directories and cd into the last one'
|
||||
param 'one or more directories to create'
|
||||
example '$ mkcd foo'
|
||||
example '$ mkcd /tmp/img/photos/large'
|
||||
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
|
||||
}
|
||||
|
||||
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 type "mkisofs" > /dev/null; then
|
||||
[ -z ${1+x} ] && local isoname=${PWD##*/} || local isoname=$1
|
||||
[ -z ${2+x} ] && local destpath=../ || local destpath=$2
|
||||
[ -z ${3+x} ] && local srcpath=${PWD} || local srcpath=$3
|
||||
|
||||
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
|
||||
else
|
||||
echo "mkisofs cmd does not exist, please install cdrtools"
|
||||
fi
|
||||
# shellcheck disable=SC2010
|
||||
function lsgrep() {
|
||||
about 'search through directory contents with grep'
|
||||
group 'base'
|
||||
ls | grep "$@"
|
||||
}
|
||||
|
||||
function quiet() {
|
||||
about 'what *does* this do?'
|
||||
group 'base'
|
||||
nohup "$@" &> /dev/null < /dev/null &
|
||||
}
|
||||
|
||||
function usage() {
|
||||
about 'disk usage per directory, in Mac OS X and Linux'
|
||||
param '1: directory name'
|
||||
group 'base'
|
||||
case $OSTYPE in
|
||||
*'darwin'*)
|
||||
du -hd 1 "$@"
|
||||
;;
|
||||
*'linux'*)
|
||||
du -h --max-depth=1 "$@"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
# shellcheck disable=SC2144 # the glob matches only one file
|
||||
if [[ ! -e "${BASH_IT?}/plugins/enabled/todo.plugin.bash" &&
|
||||
! -e "${BASH_IT?}/plugins/enabled"/*"${BASH_IT_LOAD_PRIORITY_SEPARATOR-}todo.plugin.bash" ]]; then
|
||||
# if user has installed todo plugin, skip this...
|
||||
function t() {
|
||||
about 'one thing todo'
|
||||
param 'if not set, display todo item'
|
||||
param '1: todo text'
|
||||
if [[ "$*" == "" ]]; then
|
||||
cat ~/.t
|
||||
else
|
||||
echo "$*" > ~/.t
|
||||
fi
|
||||
}
|
||||
fi
|
||||
|
||||
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'
|
||||
|
||||
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
|
||||
}
|
||||
fi
|
||||
|
||||
# useful for administrators and configs
|
||||
function buf ()
|
||||
{
|
||||
about 'back up file with timestamp'
|
||||
param 'filename'
|
||||
group 'base'
|
||||
local filename=$1
|
||||
local filetime=$(date +%Y%m%d_%H%M%S)
|
||||
cp -a "${filename}" "${filename}_${filetime}"
|
||||
function buf() {
|
||||
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}"
|
||||
}
|
||||
|
||||
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() {
|
||||
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
|
||||
}
|
||||
fi
|
||||
|
|
|
|||
|
|
@ -0,0 +1,19 @@
|
|||
# shellcheck shell=bash
|
||||
cite about-plugin
|
||||
about-plugin 'load ble.sh, the Bash line editor!'
|
||||
|
||||
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
|
||||
# shellcheck disable=1090
|
||||
source "$_bash_it_ble_path"
|
||||
else
|
||||
_log_error "Could not find ble.sh in $_bash_it_ble_path"
|
||||
_log_error "Please install using the following command:"
|
||||
_log_error "git clone https://github.com/akinomyoga/ble.sh && make -C ble.sh install"
|
||||
fi
|
||||
unset _bash_it_ble_path
|
||||
|
|
@ -3,7 +3,7 @@ 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 [[ `uname -s` == "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
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ precmd_return_notification() {
|
|||
}
|
||||
|
||||
preexec_return_notification() {
|
||||
[ -z "${LAST_COMMAND_TIME}" ] && export LAST_COMMAND_TIME=$(date +%s)
|
||||
[[ -z "${LAST_COMMAND_TIME}" ]] && LAST_COMMAND_TIME=$(date +%s)
|
||||
}
|
||||
|
||||
precmd_functions+=(precmd_return_notification)
|
||||
|
|
|
|||
|
|
@ -1,4 +1,7 @@
|
|||
# shellcheck shell=bash
|
||||
cite about-plugin
|
||||
about-plugin 'load direnv, if you are using it: https://direnv.net/'
|
||||
|
||||
[ -x "$(which direnv)" ] && eval "$(direnv hook bash)"
|
||||
if _command_exists direnv; then
|
||||
eval "$(direnv hook bash)"
|
||||
fi
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ alias 8="pushd +8"
|
|||
alias 9="pushd +9"
|
||||
|
||||
# Clone this location
|
||||
alias pc="pushd \$(pwd)"
|
||||
alias pc='pushd "${PWD}"'
|
||||
|
||||
# Push new location
|
||||
alias pu="pushd"
|
||||
|
|
@ -73,7 +73,7 @@ G () {
|
|||
example '$ G ..'
|
||||
group 'dirs'
|
||||
|
||||
cd "${1:-$(pwd)}" ;
|
||||
cd "${1:-${PWD}}" ;
|
||||
}
|
||||
|
||||
S () {
|
||||
|
|
@ -86,7 +86,7 @@ S () {
|
|||
|
||||
sed "/$@/d" ~/.dirs > ~/.dirs1;
|
||||
\mv ~/.dirs1 ~/.dirs;
|
||||
echo "$@"=\"`pwd`\" >> ~/.dirs;
|
||||
echo "$@"=\""${PWD}"\" >> ~/.dirs;
|
||||
source ~/.dirs ;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,12 +2,13 @@
|
|||
cite about-plugin
|
||||
about-plugin 'git helper functions'
|
||||
|
||||
# shellcheck disable=SC2016
|
||||
function git_remote {
|
||||
about "adds remote $GIT_HOSTING:$1 to current repo"
|
||||
about 'adds remote $GIT_HOSTING:$1 to current repo'
|
||||
group "git"
|
||||
|
||||
echo "Running: git remote add origin ${GIT_HOSTING}:$1.git"
|
||||
git remote add origin "$GIT_HOSTING:$1".git
|
||||
echo "Running: git remote add origin ${GIT_HOSTING:?}:$1.git"
|
||||
git remote add origin "${GIT_HOSTING}:${1}".git
|
||||
}
|
||||
|
||||
function git_first_push {
|
||||
|
|
@ -24,14 +25,14 @@ function git_pub() {
|
|||
BRANCH=$(git rev-parse --abbrev-ref HEAD)
|
||||
|
||||
echo "Publishing ${BRANCH} to remote origin"
|
||||
git push -u origin "$BRANCH"
|
||||
git push -u origin "${BRANCH}"
|
||||
}
|
||||
|
||||
function git_revert() {
|
||||
about 'applies changes to HEAD that revert all changes after this commit'
|
||||
group 'git'
|
||||
|
||||
git reset "$1"
|
||||
git reset "${1:?}"
|
||||
git reset --soft "HEAD@{1}"
|
||||
git commit -m "Revert to ${1}"
|
||||
git reset --hard
|
||||
|
|
@ -49,9 +50,7 @@ function git_rollback() {
|
|||
}
|
||||
|
||||
function commit_exists() {
|
||||
git rev-list --quiet "$1"
|
||||
status=$?
|
||||
if [ $status -ne 0 ]; then
|
||||
if git rev-list --quiet "${1:?}"; then
|
||||
echo "Commit ${1} does not exist"
|
||||
kill -INT $$
|
||||
fi
|
||||
|
|
@ -61,7 +60,7 @@ function git_rollback() {
|
|||
while true; do
|
||||
# shellcheck disable=SC2162
|
||||
read -p "Do you want to keep all changes from rolled back revisions in your working tree? [Y/N]" RESP
|
||||
case $RESP in
|
||||
case "${RESP}" in
|
||||
|
||||
[yY])
|
||||
echo "Rolling back to commit ${1} with unstaged changes"
|
||||
|
|
@ -87,7 +86,7 @@ function git_rollback() {
|
|||
while true; do
|
||||
# shellcheck disable=SC2162
|
||||
read -p "WARNING: This will change your history and move the current HEAD back to commit ${1}, continue? [Y/N]" RESP
|
||||
case $RESP in
|
||||
case "${RESP}" in
|
||||
|
||||
[yY])
|
||||
keep_changes "$1"
|
||||
|
|
@ -134,8 +133,8 @@ function git_info() {
|
|||
|
||||
# print all remotes and thier details
|
||||
for remote in $(git remote show); do
|
||||
echo "$remote":
|
||||
git remote show "$remote"
|
||||
echo "${remote}":
|
||||
git remote show "${remote}"
|
||||
echo
|
||||
done
|
||||
|
||||
|
|
@ -172,32 +171,32 @@ function git_stats {
|
|||
AUTHORS=$(git shortlog -sn --all | cut -f2 | cut -f1 -d' ')
|
||||
LOGOPTS=""
|
||||
if [ "$1" == '-w' ]; then
|
||||
LOGOPTS="$LOGOPTS -w"
|
||||
LOGOPTS="${LOGOPTS} -w"
|
||||
shift
|
||||
fi
|
||||
if [ "$1" == '-M' ]; then
|
||||
LOGOPTS="$LOGOPTS -M"
|
||||
LOGOPTS="${LOGOPTS} -M"
|
||||
shift
|
||||
fi
|
||||
if [ "$1" == '-C' ]; then
|
||||
LOGOPTS="$LOGOPTS -C --find-copies-harder"
|
||||
LOGOPTS="${LOGOPTS} -C --find-copies-harder"
|
||||
shift
|
||||
fi
|
||||
for a in $AUTHORS; do
|
||||
for a in ${AUTHORS}; do
|
||||
echo '-------------------'
|
||||
echo "Statistics for: $a"
|
||||
echo "Statistics for: ${a}"
|
||||
echo -n "Number of files changed: "
|
||||
# shellcheck disable=SC2086
|
||||
git log $LOGOPTS --all --numstat --format="%n" --author="$a" | cut -f3 | sort -iu | wc -l
|
||||
git log ${LOGOPTS} --all --numstat --format="%n" --author="${a}" | cut -f3 | sort -iu | wc -l
|
||||
echo -n "Number of lines added: "
|
||||
# shellcheck disable=SC2086
|
||||
git log $LOGOPTS --all --numstat --format="%n" --author="$a" | cut -f1 | awk '{s+=$1} END {print s}'
|
||||
git log ${LOGOPTS} --all --numstat --format="%n" --author="${a}" | cut -f1 | awk '{s+=$1} END {print s}'
|
||||
echo -n "Number of lines deleted: "
|
||||
# shellcheck disable=SC2086
|
||||
git log $LOGOPTS --all --numstat --format="%n" --author="$a" | cut -f2 | awk '{s+=$1} END {print s}'
|
||||
git log ${LOGOPTS} --all --numstat --format="%n" --author="${a}" | cut -f2 | awk '{s+=$1} END {print s}'
|
||||
echo -n "Number of merges: "
|
||||
# shellcheck disable=SC2086
|
||||
git log $LOGOPTS --all --merges --author="$a" | grep -c '^commit'
|
||||
git log ${LOGOPTS} --all --merges --author="${a}" | grep -c '^commit'
|
||||
done
|
||||
else
|
||||
echo "you're currently not in a git repository"
|
||||
|
|
@ -212,18 +211,16 @@ function gittowork() {
|
|||
|
||||
result=$(curl -L "https://www.gitignore.io/api/$1" 2> /dev/null)
|
||||
|
||||
if [[ $result =~ ERROR ]]; then
|
||||
if [[ "${result}" =~ ERROR ]]; then
|
||||
echo "Query '$1' has no match. See a list of possible queries with 'gittowork list'"
|
||||
elif [[ $1 = list ]]; then
|
||||
echo "$result"
|
||||
elif [[ $1 == list ]]; then
|
||||
echo "${result}"
|
||||
else
|
||||
if [[ -f .gitignore ]]; then
|
||||
result=$(echo "$result" | grep -v "# Created by http://www.gitignore.io")
|
||||
result=$(grep -v "# Created by http://www.gitignore.io" <<< "${result}")
|
||||
echo ".gitignore already exists, appending..."
|
||||
echo "$result" >> .gitignore
|
||||
else
|
||||
echo "$result" > .gitignore
|
||||
fi
|
||||
echo "${result}" >> .gitignore
|
||||
fi
|
||||
}
|
||||
|
||||
|
|
@ -257,7 +254,7 @@ function gitignore-reload() {
|
|||
fi
|
||||
|
||||
# Prompt user to commit or stash changes and exit
|
||||
if [ $err = 1 ]; then
|
||||
if [[ "${err}" == 1 ]]; then
|
||||
echo >&2 "Please commit or stash them."
|
||||
fi
|
||||
|
||||
|
|
@ -265,7 +262,7 @@ function gitignore-reload() {
|
|||
|
||||
# If we're here, then there are no uncommited or unstaged changes dangling around.
|
||||
# Proceed to reload .gitignore
|
||||
if [ $err = 0 ]; then
|
||||
if [[ "${err}" == 0 ]]; then
|
||||
# Remove all cached files
|
||||
git rm -r --cached .
|
||||
|
||||
|
|
@ -290,6 +287,7 @@ function git-changelog() {
|
|||
return 1
|
||||
fi
|
||||
|
||||
# shellcheck disable=SC2155
|
||||
local NEXT=$(date +%F)
|
||||
|
||||
if [[ "$2" == "md" ]]; then
|
||||
|
|
@ -298,9 +296,9 @@ function git-changelog() {
|
|||
# shellcheck disable=SC2162
|
||||
git log "$1" --no-merges --format="%cd" --date=short | sort -u -r | while read DATE; do
|
||||
echo
|
||||
echo "### $DATE"
|
||||
git log --no-merges --format=" * (%h) %s by [%an](mailto:%ae)" --since="$DATE 00:00:00" --until="$DATE 24:00:00"
|
||||
NEXT=$DATE
|
||||
echo "### ${DATE}"
|
||||
git log --no-merges --format=" * (%h) %s by [%an](mailto:%ae)" --since="${DATE} 00:00:00" --until="${DATE} 24:00:00"
|
||||
NEXT=${DATE}
|
||||
done
|
||||
else
|
||||
echo "CHANGELOG $1"
|
||||
|
|
@ -309,9 +307,10 @@ function git-changelog() {
|
|||
# shellcheck disable=SC2162
|
||||
git log "$1" --no-merges --format="%cd" --date=short | sort -u -r | while read DATE; do
|
||||
echo
|
||||
echo [$DATE]
|
||||
git log --no-merges --format=" * (%h) %s by %an <%ae>" --since="$DATE 00:00:00" --until="$DATE 24:00:00"
|
||||
NEXT=$DATE
|
||||
echo "[${DATE}]"
|
||||
git log --no-merges --format=" * (%h) %s by %an <%ae>" --since="${DATE} 00:00:00" --until="${DATE} 24:00:00"
|
||||
# shellcheck disable=SC2034
|
||||
NEXT=${DATE}
|
||||
done
|
||||
fi
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ eval "$(goenv init - bash)"
|
|||
# If moving to a directory with a goenv version set, reload the shell
|
||||
# to ensure the shell environment matches expectations.
|
||||
_bash-it-goenv-preexec() {
|
||||
export GOENV_OLD_VERSION="$(goenv version-name)"
|
||||
GOENV_OLD_VERSION="$(goenv version-name)"
|
||||
}
|
||||
_bash-it-goenv-precmd() {
|
||||
if [[ -n $GOENV_OLD_VERSION ]] && [[ "$GOENV_OLD_VERSION" != "$(goenv version-name)" ]]; then
|
||||
|
|
|
|||
|
|
@ -3,19 +3,10 @@ about-plugin 'Add a gw command to use gradle wrapper if present, else use system
|
|||
|
||||
function gw() {
|
||||
local file="gradlew"
|
||||
local curr_path="${PWD}"
|
||||
local result="gradle"
|
||||
local result
|
||||
|
||||
# Search recursively upwards for file.
|
||||
until [[ "${curr_path}" == "/" ]]; do
|
||||
if [[ -e "${curr_path}/${file}" ]]; then
|
||||
result="${curr_path}/${file}"
|
||||
break
|
||||
else
|
||||
curr_path=$(dirname "${curr_path}")
|
||||
fi
|
||||
done
|
||||
result="$(_bash-it-find-in-ancestor "${file}")"
|
||||
|
||||
# Call gradle
|
||||
"${result}" $*
|
||||
"${result:-gradle}" $*
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,7 @@
|
|||
# shellcheck shell=bash
|
||||
cite about-plugin
|
||||
about-plugin 'load hub, if you are using it'
|
||||
|
||||
command -v hub &> /dev/null && eval "$(hub alias -s)"
|
||||
if _command_exists hub; then
|
||||
eval "$(hub alias -s)"
|
||||
fi
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ editpost() {
|
|||
|
||||
for site in ${SITES[@]}
|
||||
do
|
||||
if [ "$(basename $site)" = "$1" ]
|
||||
if [ "${site##*/}" = "$1" ]
|
||||
then
|
||||
SITE=$site
|
||||
break
|
||||
|
|
@ -77,7 +77,7 @@ newpost() {
|
|||
|
||||
for site in ${SITES[@]}
|
||||
do
|
||||
if [ "$(basename $site)" = "$1" ]
|
||||
if [ "${site##*/}" = "$1" ]
|
||||
then
|
||||
SITE=$site
|
||||
JEKYLL_FORMATTING=${MARKUPS[$loc]}
|
||||
|
|
@ -280,7 +280,7 @@ function testsite() {
|
|||
|
||||
for site in ${SITES[@]}
|
||||
do
|
||||
if [ "$(basename $site)" = "$1" ]
|
||||
if [ "${site##*/}" = "$1" ]
|
||||
then
|
||||
SITE=$site
|
||||
break
|
||||
|
|
@ -312,7 +312,7 @@ function buildsite() {
|
|||
|
||||
for site in ${SITES[@]}
|
||||
do
|
||||
if [ "$(basename $site)" = "$1" ]
|
||||
if [ "${site##*/}" = "$1" ]
|
||||
then
|
||||
SITE=$site
|
||||
break
|
||||
|
|
@ -347,7 +347,7 @@ function deploysite() {
|
|||
|
||||
for site in ${SITES[@]}
|
||||
do
|
||||
if [ "$(basename $site)" = "$1" ]
|
||||
if [ "${site##*/}" = "$1" ]
|
||||
then
|
||||
SITE=$site
|
||||
REMOTE=${REMOTES[$loc]}
|
||||
|
|
|
|||
|
|
@ -1,9 +1,12 @@
|
|||
# shellcheck shell=bash
|
||||
# shellcheck disable=SC2016
|
||||
cite about-plugin
|
||||
about-plugin 'initialize jump (see https://github.com/gsamokovarov/jump). Add `export JUMP_OPTS=("--bind=z")` to change keybinding'
|
||||
|
||||
__init_jump() {
|
||||
command -v jump &> /dev/null || return
|
||||
eval "$(jump shell bash "${JUMP_OPTS[@]}")"
|
||||
function __init_jump() {
|
||||
if _command_exists jump; then
|
||||
eval "$(jump shell bash "${JUMP_OPTS[@]}")"
|
||||
fi
|
||||
}
|
||||
|
||||
__init_jump
|
||||
|
|
|
|||
|
|
@ -1,31 +1,23 @@
|
|||
# shellcheck shell=bash
|
||||
cite about-plugin
|
||||
about-plugin 'pygmentize instead of cat to terminal if possible'
|
||||
|
||||
if $(command -v pygmentize &> /dev/null) ; then
|
||||
# get the full paths to binaries
|
||||
CAT_BIN=$(which cat)
|
||||
LESS_BIN=$(which less)
|
||||
BASH_IT_CCAT_STYLE="${BASH_IT_CCAT_STYLE:=default}"
|
||||
BASH_IT_CLESS_STYLE="${BASH_IT_CLESS_STYLE:=default}"
|
||||
_command_exists pygmentize || return
|
||||
|
||||
# pigmentize cat and less outputs - call them ccat and cless to avoid that
|
||||
# especially cat'ed output in scripts gets mangled with pygemtized meta characters
|
||||
function ccat()
|
||||
{
|
||||
about 'runs either pygmentize or cat on each file passed in'
|
||||
param '*: files to concatenate (as normally passed to cat)'
|
||||
example 'cat mysite/manage.py dir/text-file.txt'
|
||||
for var;
|
||||
do
|
||||
pygmentize -f 256 -O style="$BASH_IT_CCAT_STYLE" -g "$var" 2>/dev/null || "$CAT_BIN" "$var";
|
||||
done
|
||||
}
|
||||
# pigmentize cat and less outputs - call them ccat and cless to avoid that
|
||||
# especially cat'ed output in scripts gets mangled with pygemtized meta characters
|
||||
function ccat() {
|
||||
about 'runs pygmentize on each file passed in'
|
||||
param '*: files to concatenate (as normally passed to cat)'
|
||||
example 'ccat mysite/manage.py dir/text-file.txt'
|
||||
|
||||
function cless()
|
||||
{
|
||||
about 'it pigments the file passed in and passes it to less for pagination'
|
||||
param '$1: the file to paginate with less'
|
||||
example 'less mysite/manage.py'
|
||||
pygmentize -f 256 -O style="$BASH_IT_CLESS_STYLE" -g $* | "$LESS_BIN" -R
|
||||
}
|
||||
fi
|
||||
pygmentize -f 256 -O style="${BASH_IT_CCAT_STYLE:-default}" -g "$@"
|
||||
}
|
||||
|
||||
function cless() {
|
||||
about 'pigments the files passed in and passes to less for pagination'
|
||||
param '*: the files to paginate with less'
|
||||
example 'cless mysite/manage.py'
|
||||
|
||||
pygmentize -f 256 -O style="${BASH_IT_CLESS_STYLE:-default}" -g "$@" | command less -R
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,13 +1,14 @@
|
|||
# shellcheck shell=bash
|
||||
cite about-plugin
|
||||
about-plugin 'Node.js helper functions'
|
||||
|
||||
# Check that we have npm
|
||||
_command_exists npm || return
|
||||
|
||||
# Ensure local modules are preferred in PATH
|
||||
pathmunge "./node_modules/.bin" "after"
|
||||
|
||||
# Check that we have npm
|
||||
out=$(command -v npm 2>&1) || return
|
||||
|
||||
# If not using nodenv, ensure global modules are in PATH
|
||||
if [[ ! $out == *"nodenv/shims"* ]] ; then
|
||||
pathmunge "$(npm config get prefix)/bin" "after"
|
||||
if [[ ! "$(type -p npm)" == *"nodenv/shims"* ]]; then
|
||||
pathmunge "$(npm config get prefix)/bin" "after"
|
||||
fi
|
||||
|
|
|
|||
|
|
@ -1,7 +1,10 @@
|
|||
# shellcheck shell=bash
|
||||
cite about-plugin
|
||||
about-plugin 'load nodenv, if you are using it'
|
||||
|
||||
export NODENV_ROOT="$HOME/.nodenv"
|
||||
pathmunge "$NODENV_ROOT/bin"
|
||||
|
||||
[[ `which nodenv` ]] && eval "$(nodenv init - bash)"
|
||||
if _command_exists nodenv; then
|
||||
eval "$(nodenv init - bash)"
|
||||
fi
|
||||
|
|
|
|||
|
|
@ -1,22 +1,23 @@
|
|||
# Bash-it no longer bundles nvm, as this was quickly becoming outdated.
|
||||
# shellcheck shell=bash
|
||||
#
|
||||
# BASH_IT_LOAD_PRIORITY: 225
|
||||
#
|
||||
# Bash-it no longer bundles nvm, as this was quickly becoming outdated.
|
||||
# Please install nvm from https://github.com/creationix/nvm.git if you want to use it.
|
||||
|
||||
cite about-plugin
|
||||
about-plugin 'node version manager configuration'
|
||||
|
||||
export NVM_DIR=${NVM_DIR:-$HOME/.nvm}
|
||||
export NVM_DIR="${NVM_DIR:-$HOME/.nvm}"
|
||||
# This loads nvm
|
||||
if command -v brew &>/dev/null && [ -s $(brew --prefix nvm)/nvm.sh ]
|
||||
if _bash_it_homebrew_check && [[ -s "${BASH_IT_HOMEBREW_PREFIX}/nvm.sh" ]]
|
||||
then
|
||||
. $(brew --prefix nvm)/nvm.sh
|
||||
source "${BASH_IT_HOMEBREW_PREFIX}/nvm.sh"
|
||||
else
|
||||
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"
|
||||
[[ -s "$NVM_DIR/nvm.sh" ]] && source "$NVM_DIR/nvm.sh"
|
||||
fi
|
||||
|
||||
if ! command -v nvm &>/dev/null
|
||||
if ! _command_exists nvm
|
||||
then
|
||||
function nvm() {
|
||||
echo "Bash-it no longer bundles the nvm script. Please install the latest version from"
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ function time-machine-list-machines() {
|
|||
local tmdest="$(time-machine-destination)/Backups.backupdb"
|
||||
|
||||
find "$tmdest" -maxdepth 1 -mindepth 1 -type d | grep -v "/\." | while read line ; do
|
||||
echo "$(basename "$line")"
|
||||
echo "${line##*/}"
|
||||
done
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ cite about-plugin
|
|||
about-plugin 'osx-specific functions'
|
||||
|
||||
# OS X: Open new tabs in same directory
|
||||
if [ $(uname) = "Darwin" ]; then
|
||||
if [[ $OSTYPE == 'darwin'* ]]; then
|
||||
if type update_terminal_cwd > /dev/null 2>&1 ; then
|
||||
if ! [[ $PROMPT_COMMAND =~ (^|;)update_terminal_cwd($|;) ]] ; then
|
||||
PROMPT_COMMAND="${PROMPT_COMMAND%;};update_terminal_cwd"
|
||||
|
|
@ -46,13 +46,13 @@ function dock-switch() {
|
|||
example '$ dock-switch 2d'
|
||||
group 'osx'
|
||||
|
||||
if [ $(uname) = "Darwin" ]; then
|
||||
if [[ "$OSTYPE" = 'darwin'* ]]; then
|
||||
|
||||
if [ $1 = 3d ] ; then
|
||||
if [[ $1 = 3d ]] ; then
|
||||
defaults write com.apple.dock no-glass -boolean NO
|
||||
killall Dock
|
||||
|
||||
elif [ $1 = 2d ] ; then
|
||||
elif [[ $1 = 2d ]] ; then
|
||||
defaults write com.apple.dock no-glass -boolean YES
|
||||
killall Dock
|
||||
|
||||
|
|
@ -90,7 +90,7 @@ function prevcurl() {
|
|||
param '1: url'
|
||||
group 'osx'
|
||||
|
||||
if [ ! $(uname) = "Darwin" ]
|
||||
if [[ ! $OSTYPE = 'darwin'* ]]
|
||||
then
|
||||
echo "This function only works with Mac OS X"
|
||||
return 1
|
||||
|
|
@ -103,7 +103,7 @@ function refresh-launchpad() {
|
|||
example '$ refresh-launchpad'
|
||||
group 'osx'
|
||||
|
||||
if [ $(uname) = "Darwin" ];then
|
||||
if [[ "$OSTYPE" = 'darwin'* ]];then
|
||||
defaults write com.apple.dock ResetLaunchPad -bool TRUE
|
||||
killall Dock
|
||||
else
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
# shellcheck shell=bash
|
||||
cite about-plugin
|
||||
about-plugin 'Search&Select history with percol'
|
||||
|
||||
|
|
@ -12,24 +13,20 @@ about-plugin 'Search&Select history with percol'
|
|||
# Usage
|
||||
## C-r to search&select from history
|
||||
|
||||
_replace_by_history() {
|
||||
if command -v tac>/dev/null; then
|
||||
alias _tac=tac
|
||||
else
|
||||
alias _tac="tail -r"
|
||||
fi
|
||||
local l=$(HISTTIMEFORMAT= history | _tac | sed -e 's/^\ *[0-9]*\ *//' | percol --query "$READLINE_LINE")
|
||||
READLINE_LINE="$l"
|
||||
READLINE_POINT=${#l}
|
||||
}
|
||||
_command_exists percol || return
|
||||
|
||||
|
||||
if command -v percol>/dev/null; then
|
||||
current_version=${BASH_VERSION%%[^0-9]*}
|
||||
if [ $current_version -lt 4 ]; then
|
||||
echo -e "\033[91mWarning: You have to upgrade Bash to Bash v4.x to use the 'percol' plugin.\033[m"
|
||||
echo -e "\033[91m Your current Bash version is $BASH_VERSION.\033[m"
|
||||
else
|
||||
bind -x '"\C-r": _replace_by_history'
|
||||
fi
|
||||
if [[ ${BASH_VERSINFO[0]} -lt 4 ]]; then
|
||||
_log_warning "You have to upgrade Bash to Bash v4.x to use the 'percol' plugin."
|
||||
_log_warning "Your current Bash version is $BASH_VERSION."
|
||||
return
|
||||
fi
|
||||
|
||||
function _replace_by_history() {
|
||||
local HISTTIMEFORMAT= # Ensure we can parse history properly
|
||||
#TODO: "${histlines[@]/*( )+([[:digit:]])*( )/}"
|
||||
local l
|
||||
l="$(history | tail -r | sed -e 's/^\ *[0-9]*\ *//' | percol --query "${READLINE_LINE:-}")"
|
||||
READLINE_LINE="${l}"
|
||||
READLINE_POINT=${#l}
|
||||
}
|
||||
bind -x '"\C-r": _replace_by_history'
|
||||
|
|
|
|||
|
|
@ -1,18 +1,16 @@
|
|||
# shellcheck shell=bash
|
||||
#
|
||||
# plugin for plenv
|
||||
|
||||
cite about-plugin
|
||||
about-plugin 'plenv plugin for Perl'
|
||||
|
||||
if [[ -e "${HOME}/.plenv/bin" ]] ; then
|
||||
|
||||
# load plenv bin dir into path if it exists
|
||||
pathmunge "${HOME}/.plenv/bin"
|
||||
|
||||
if [[ -d "${HOME}/.plenv/bin" ]]; then
|
||||
# load plenv bin dir into path if it exists
|
||||
pathmunge "${HOME}/.plenv/bin"
|
||||
fi
|
||||
|
||||
if [[ `which plenv` ]] ; then
|
||||
|
||||
# init plenv
|
||||
eval "$(plenv init - bash)"
|
||||
|
||||
if _command_exists plenv; then
|
||||
# init plenv
|
||||
eval "$(plenv init - bash)"
|
||||
fi
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
#!/usr/bin/env bash
|
||||
# shellcheck shell=bash
|
||||
|
||||
cite about-plugin
|
||||
about-plugin 'enables powerline daemon'
|
||||
|
||||
command -v powerline-daemon &>/dev/null || return
|
||||
_command_exists powerline-daemon || return
|
||||
powerline-daemon -q
|
||||
|
||||
#the following should not be executed if bashit powerline themes in use
|
||||
|
|
@ -14,13 +14,13 @@ case "$BASH_IT_THEME" in
|
|||
esac
|
||||
POWERLINE_BASH_CONTINUATION=1
|
||||
POWERLINE_BASH_SELECT=1
|
||||
bashPowerlineInit=$(python -c \
|
||||
bashPowerlineInit="$(python -c \
|
||||
"import os; \
|
||||
import powerline;\
|
||||
print(os.path.join(os.path.dirname(\
|
||||
powerline.__file__),\
|
||||
'bindings', \
|
||||
'bash', \
|
||||
'powerline.sh'))")
|
||||
'powerline.sh'))")"
|
||||
[ -e $bashPowerlineInit ] || return
|
||||
. $bashPowerlineInit
|
||||
source $bashPowerlineInit
|
||||
|
|
|
|||
|
|
@ -1,12 +1,34 @@
|
|||
# shellcheck shell=bash
|
||||
cite about-plugin
|
||||
about-plugin 'load pyenv, if you are using it'
|
||||
|
||||
export PYENV_ROOT="$HOME/.pyenv"
|
||||
pathmunge "$PYENV_ROOT/bin"
|
||||
# https://github.com/pyenv/pyenv
|
||||
|
||||
[[ `which pyenv 2>/dev/null` ]] && eval "$(pyenv init - bash)"
|
||||
# Load after basher
|
||||
# BASH_IT_LOAD_PRIORITY: 260
|
||||
|
||||
#Load pyenv virtualenv if the virtualenv plugin is installed.
|
||||
if pyenv virtualenv-init - &> /dev/null; then
|
||||
eval "$(pyenv virtualenv-init - bash)"
|
||||
# Don't modify the environment if we can't find the tool:
|
||||
# - Check if in $PATH already
|
||||
# - Check if installed manually to $PYENV_ROOT
|
||||
# - Check if installed manually to $HOME
|
||||
_command_exists pyenv \
|
||||
|| [[ -n "$PYENV_ROOT" && -x "$PYENV_ROOT/bin/pyenv" ]] \
|
||||
|| [[ -x "$HOME/.pyenv/bin/pyenv" ]] \
|
||||
|| return 0
|
||||
|
||||
# Set PYENV_ROOT, if not already set
|
||||
export PYENV_ROOT="${PYENV_ROOT:-$HOME/.pyenv}"
|
||||
|
||||
# Add PYENV_ROOT/bin to PATH, if that's where it's installed
|
||||
if ! _command_exists pyenv && [[ -x "$PYENV_ROOT/bin/pyenv" ]]; then
|
||||
pathmunge "$PYENV_ROOT/bin"
|
||||
fi
|
||||
|
||||
# Initialize pyenv
|
||||
pathmunge "$PYENV_ROOT/shims"
|
||||
eval "$(pyenv init - bash)"
|
||||
|
||||
# Load pyenv virtualenv if the virtualenv plugin is installed.
|
||||
if pyenv virtualenv-init - &> /dev/null; then
|
||||
eval "$(pyenv virtualenv-init - bash)"
|
||||
fi
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
cite about-plugin
|
||||
about-plugin 'alias "shttp" to SimpleHTTPServer'
|
||||
|
||||
if [ $(uname) = "Linux" ]
|
||||
if [[ "$OSTYPE" == 'linux'* ]]
|
||||
then
|
||||
alias shttp='python2 -m SimpleHTTPServer'
|
||||
else
|
||||
|
|
@ -16,7 +16,7 @@ function pyedit() {
|
|||
|
||||
xpyc=`python -c "import os, sys; f = open(os.devnull, 'w'); sys.stderr = f; module = __import__('$1'); sys.stdout.write(module.__file__)"`
|
||||
|
||||
if [ "$xpyc" == "" ]; then
|
||||
if [[ "$xpyc" == "" ]]; then
|
||||
echo "Python module $1 not found"
|
||||
return -1
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,10 @@
|
|||
# shellcheck shell=bash
|
||||
cite about-plugin
|
||||
about-plugin 'load rbenv, if you are using it'
|
||||
|
||||
export RBENV_ROOT="$HOME/.rbenv"
|
||||
pathmunge "$RBENV_ROOT/bin"
|
||||
|
||||
[[ `which rbenv 2>/dev/null` ]] && eval "$(rbenv init - bash)"
|
||||
if _command_exists rbenv; then
|
||||
eval "$(rbenv init - bash)"
|
||||
fi
|
||||
|
|
|
|||
|
|
@ -1,16 +1,17 @@
|
|||
# shellcheck shell=bash
|
||||
cite about-plugin
|
||||
about-plugin 'ruby and rubygems specific functions and settings'
|
||||
|
||||
# Make commands installed with 'gem install --user-install' available
|
||||
# ~/.gem/ruby/${RUBY_VERSION}/bin/
|
||||
if which ruby >/dev/null && which gem >/dev/null; then
|
||||
pathmunge "$(ruby -e 'print Gem.user_dir')/bin" after
|
||||
if _command_exists ruby && _command_exists gem; then
|
||||
pathmunge "$(ruby -e 'print Gem.user_dir')/bin" after
|
||||
fi
|
||||
|
||||
function remove_gem {
|
||||
about 'removes installed gem'
|
||||
param '1: installed gem name'
|
||||
group 'ruby'
|
||||
function remove_gem() {
|
||||
about 'removes installed gem'
|
||||
param '1: installed gem name'
|
||||
group 'ruby'
|
||||
|
||||
gem list | grep $1 | awk '{ print $1; }' | xargs sudo gem uninstall
|
||||
gem list | grep "${1:?${FUNCNAME[0]}: no gem name provided}" | awk '{ print $1; }' | xargs sudo gem uninstall
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,9 @@
|
|||
# shellcheck shell=bash
|
||||
cite about-plugin
|
||||
about-plugin 'set textmate as a default editor'
|
||||
|
||||
if $(command -v mate &> /dev/null) ; then
|
||||
export EDITOR="$(which mate) -w"
|
||||
export GIT_EDITOR=$EDITOR
|
||||
if _command_exists mate; then
|
||||
EDITOR="$(type -p mate) -w"
|
||||
GIT_EDITOR="$EDITOR"
|
||||
export EDITOR GIT_EDITOR
|
||||
fi
|
||||
|
|
|
|||
|
|
@ -1,12 +1,14 @@
|
|||
# shellcheck shell=bash
|
||||
#
|
||||
# make sure virtualenvwrapper is enabled if available
|
||||
|
||||
cite about-plugin
|
||||
about-plugin 'virtualenvwrapper and pyenv-virtualenvwrapper helper functions'
|
||||
|
||||
if _command_exists pyenv; then
|
||||
pyenv virtualenvwrapper
|
||||
else
|
||||
[[ `which virtualenvwrapper.sh` ]] && . virtualenvwrapper.sh
|
||||
pyenv virtualenvwrapper
|
||||
elif _command_exists virtualenvwrapper.sh; then
|
||||
source virtualenvwrapper.sh
|
||||
fi
|
||||
|
||||
|
||||
|
|
@ -14,8 +16,8 @@ function mkvenv {
|
|||
about 'create a new virtualenv for this directory'
|
||||
group 'virtualenv'
|
||||
|
||||
cwd=`basename \`pwd\``
|
||||
mkvirtualenv --distribute $cwd
|
||||
local cwd="${PWD##*/}"
|
||||
mkvirtualenv --distribute "$cwd"
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -23,19 +25,21 @@ function mkvbranch {
|
|||
about 'create a new virtualenv for the current branch'
|
||||
group 'virtualenv'
|
||||
|
||||
mkvirtualenv --distribute "$(basename `pwd`)@$SCM_BRANCH"
|
||||
local cwd="${PWD##*/}"
|
||||
mkvirtualenv --distribute "${cwd}@${SCM_BRANCH}"
|
||||
}
|
||||
|
||||
function wovbranch {
|
||||
about 'sets workon branch'
|
||||
group 'virtualenv'
|
||||
|
||||
workon "$(basename `pwd`)@$SCM_BRANCH"
|
||||
local cwd="${PWD##*/}"
|
||||
workon "${cwd}@${SCM_BRANCH}"
|
||||
}
|
||||
|
||||
function wovenv {
|
||||
about 'works on the virtualenv for this directory'
|
||||
group 'virtualenv'
|
||||
|
||||
workon "$(basename `pwd`)"
|
||||
workon "${PWD##*/}"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,29 +3,37 @@ cite about-plugin
|
|||
about-plugin 'automatically set your xterm title with host and location info'
|
||||
|
||||
_short-dirname() {
|
||||
local dir_name=$(dirs +0)
|
||||
[ "$SHORT_TERM_LINE" = true ] && [ "${#dir_name}" -gt 8 ] && echo "${dir_name##*/}" || echo "${dir_name}"
|
||||
local dir_name="${PWD/~/\~}"
|
||||
if [[ "${SHORT_TERM_LINE:-}" == true && "${#dir_name}" -gt 8 ]]; then
|
||||
echo "${dir_name##*/}"
|
||||
else
|
||||
echo "${dir_name}"
|
||||
fi
|
||||
}
|
||||
|
||||
_short-command() {
|
||||
local input_command="$*"
|
||||
[ "$SHORT_TERM_LINE" = true ] && [ "${#input_command}" -gt 8 ] && echo "${input_command%% *}" || echo "${input_command}"
|
||||
if [[ "${SHORT_TERM_LINE:-}" == true && "${#input_command}" -gt 8 ]]; then
|
||||
echo "${input_command%% *}"
|
||||
else
|
||||
echo "${input_command}"
|
||||
fi
|
||||
}
|
||||
|
||||
set_xterm_title() {
|
||||
local title="$1"
|
||||
echo -ne "\033]0;$title\007"
|
||||
local title="${1:-}"
|
||||
echo -ne "\033]0;${title}\007"
|
||||
}
|
||||
|
||||
precmd_xterm_title() {
|
||||
set_xterm_title "${SHORT_USER:-${USER}}@${SHORT_HOSTNAME:-${HOSTNAME}} $(_short-dirname) $PROMPT_CHAR"
|
||||
set_xterm_title "${SHORT_USER:-${USER}}@${SHORT_HOSTNAME:-${HOSTNAME}} $(_short-dirname) ${PROMPT_CHAR:-\$}"
|
||||
}
|
||||
|
||||
preexec_xterm_title() {
|
||||
set_xterm_title "$(_short-command "${1}") {$(_short-dirname)} (${SHORT_USER:-${USER}}@${SHORT_HOSTNAME:-${HOSTNAME}})"
|
||||
set_xterm_title "$(_short-command "${1:-}") {$(_short-dirname)} (${SHORT_USER:-${USER}}@${SHORT_HOSTNAME:-${HOSTNAME}})"
|
||||
}
|
||||
|
||||
case "$TERM" in
|
||||
case "${TERM:-dumb}" in
|
||||
xterm* | rxvt*)
|
||||
precmd_functions+=(precmd_xterm_title)
|
||||
preexec_functions+=(preexec_xterm_title)
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ autoenv_init()
|
|||
typeset target home _file
|
||||
typeset -a _files
|
||||
target=$1
|
||||
home="$(dirname "$HOME")"
|
||||
home="${HOME%/*}"
|
||||
|
||||
_files=( $(
|
||||
while [[ "$PWD" != "/" && "$PWD" != "$home" ]]
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ function _set-prefix-based-on-path()
|
|||
{
|
||||
filename=$(_bash-it-get-component-name-from-path "$1")
|
||||
extension=$(_bash-it-get-component-type-from-path "$1")
|
||||
# shellcheck disable=SC2034
|
||||
BASH_IT_LOG_PREFIX="$extension: $filename: "
|
||||
}
|
||||
|
||||
|
|
@ -15,7 +16,7 @@ if [[ "$1" != "skip" ]] && [[ -d "$BASH_IT/enabled" ]]; then
|
|||
alias|completion|plugin)
|
||||
_bash_it_config_type=$1
|
||||
_log_debug "Loading enabled $1 components..." ;;
|
||||
*|'')
|
||||
''|*)
|
||||
_log_debug "Loading all enabled components..." ;;
|
||||
esac
|
||||
|
||||
|
|
|
|||
|
|
@ -5,11 +5,11 @@ load "${BASH_IT}/vendor/github.com/erichs/composure/composure.sh"
|
|||
load ../../lib/log
|
||||
load ../../lib/utilities
|
||||
load ../../lib/search
|
||||
load ../../plugins/available/base.plugin
|
||||
|
||||
cite _about _param _example _group _author _version
|
||||
|
||||
load ../../lib/helpers
|
||||
load ../../plugins/available/base.plugin
|
||||
|
||||
function local_setup {
|
||||
setup_test_fixture
|
||||
|
|
|
|||
|
|
@ -3,27 +3,28 @@
|
|||
load ../test_helper
|
||||
load "${BASH_IT}/vendor/github.com/erichs/composure/composure.sh"
|
||||
load ../../lib/appearance
|
||||
load ../../plugins/available/base.plugin
|
||||
|
||||
cite _about _param _example _group _author _version
|
||||
load ../../lib/log
|
||||
load ../../lib/helpers
|
||||
load ../../plugins/available/base.plugin
|
||||
|
||||
@test "lib log: basic debug logging with BASH_IT_LOG_LEVEL_ALL" {
|
||||
BASH_IT_LOG_LEVEL=$BASH_IT_LOG_LEVEL_ALL
|
||||
run _log_debug "test test test"
|
||||
assert_output "DEBUG: test test test"
|
||||
assert_output "DEBUG: default: test test test"
|
||||
}
|
||||
|
||||
@test "lib log: basic warning logging with BASH_IT_LOG_LEVEL_ALL" {
|
||||
BASH_IT_LOG_LEVEL=$BASH_IT_LOG_LEVEL_ALL
|
||||
run _log_warning "test test test"
|
||||
assert_output " WARN: test test test"
|
||||
assert_output " WARN: default: test test test"
|
||||
}
|
||||
|
||||
@test "lib log: basic error logging with BASH_IT_LOG_LEVEL_ALL" {
|
||||
BASH_IT_LOG_LEVEL=$BASH_IT_LOG_LEVEL_ALL
|
||||
run _log_error "test test test"
|
||||
assert_output "ERROR: test test test"
|
||||
assert_output "ERROR: default: test test test"
|
||||
}
|
||||
|
||||
@test "lib log: basic debug logging with BASH_IT_LOG_LEVEL_WARNING" {
|
||||
|
|
@ -35,13 +36,13 @@ load ../../lib/log
|
|||
@test "lib log: basic warning logging with BASH_IT_LOG_LEVEL_WARNING" {
|
||||
BASH_IT_LOG_LEVEL=$BASH_IT_LOG_LEVEL_WARNING
|
||||
run _log_warning "test test test"
|
||||
assert_output " WARN: test test test"
|
||||
assert_output " WARN: default: test test test"
|
||||
}
|
||||
|
||||
@test "lib log: basic error logging with BASH_IT_LOG_LEVEL_WARNING" {
|
||||
BASH_IT_LOG_LEVEL=$BASH_IT_LOG_LEVEL_WARNING
|
||||
run _log_error "test test test"
|
||||
assert_output "ERROR: test test test"
|
||||
assert_output "ERROR: default: test test test"
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -60,7 +61,7 @@ load ../../lib/log
|
|||
@test "lib log: basic error logging with BASH_IT_LOG_LEVEL_ERROR" {
|
||||
BASH_IT_LOG_LEVEL=$BASH_IT_LOG_LEVEL_ERROR
|
||||
run _log_error "test test test"
|
||||
assert_output "ERROR: test test test"
|
||||
assert_output "ERROR: default: test test test"
|
||||
}
|
||||
|
||||
@test "lib log: basic debug silent logging" {
|
||||
|
|
|
|||
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
load ../test_helper
|
||||
load "${BASH_IT}/vendor/github.com/erichs/composure/composure.sh"
|
||||
load ../../lib/log
|
||||
load ../../lib/helpers
|
||||
load ../../plugins/available/base.plugin
|
||||
|
||||
@test 'plugins base: ips()' {
|
||||
|
|
@ -40,7 +42,7 @@ load ../../plugins/available/base.plugin
|
|||
mkcd "${dir_name}"
|
||||
assert_success
|
||||
assert_dir_exist "${BASH_IT_ROOT}/${dir_name}"
|
||||
assert_equal $(pwd) "${BASH_IT_ROOT}/${dir_name}"
|
||||
assert_equal "${PWD}" "${BASH_IT_ROOT}/${dir_name}"
|
||||
}
|
||||
|
||||
@test 'plugins base: lsgrep()' {
|
||||
|
|
|
|||
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
load ../test_helper
|
||||
load "${BASH_IT}/vendor/github.com/erichs/composure/composure.sh"
|
||||
load "${BASH_IT}/lib/log.bash"
|
||||
load "${BASH_IT}/lib/helpers.bash"
|
||||
|
||||
cite _about _param _example _group _author _version
|
||||
|
||||
|
|
|
|||
|
|
@ -4,50 +4,52 @@ load ../test_helper
|
|||
load ../../lib/helpers
|
||||
load "${BASH_IT}/vendor/github.com/erichs/composure/composure.sh"
|
||||
|
||||
# We test `go version` in each test to account for users with goenv and no system go.
|
||||
|
||||
@test 'ensure _bash-it-gopath-pathmunge is defined' {
|
||||
{ [[ $CI ]] || _command_exists go; } || skip 'golang not found'
|
||||
{ _command_exists go && go version &>/dev/null; } || skip 'golang not found'
|
||||
load ../../plugins/available/go.plugin
|
||||
run type -t _bash-it-gopath-pathmunge
|
||||
assert_line 'function'
|
||||
}
|
||||
|
||||
@test 'plugins go: single entry in GOPATH' {
|
||||
{ [[ $CI ]] || _command_exists go; } || skip 'golang not found'
|
||||
{ _command_exists go && go version &>/dev/null; } || skip 'golang not found'
|
||||
export GOPATH="/foo"
|
||||
load ../../plugins/available/go.plugin
|
||||
assert_equal "$(cut -d':' -f1 <<<$PATH)" "/foo/bin"
|
||||
}
|
||||
|
||||
@test 'plugins go: single entry in GOPATH, with space' {
|
||||
{ [[ $CI ]] || _command_exists go; } || skip 'golang not found'
|
||||
{ _command_exists go && go version &>/dev/null; } || skip 'golang not found'
|
||||
export GOPATH="/foo bar"
|
||||
load ../../plugins/available/go.plugin
|
||||
assert_equal "$(cut -d':' -f1 <<<$PATH)" "/foo bar/bin"
|
||||
}
|
||||
|
||||
@test 'plugins go: single entry in GOPATH, with escaped space' {
|
||||
{ [[ $CI ]] || _command_exists go; } || skip 'golang not found'
|
||||
{ _command_exists go && go version &>/dev/null; } || skip 'golang not found'
|
||||
export GOPATH="/foo\ bar"
|
||||
load ../../plugins/available/go.plugin
|
||||
assert_equal "$(cut -d':' -f1 <<<$PATH)" "/foo\ bar/bin"
|
||||
}
|
||||
|
||||
@test 'plugins go: multiple entries in GOPATH' {
|
||||
{ [[ $CI ]] || _command_exists go; } || skip 'golang not found'
|
||||
{ _command_exists go && go version &>/dev/null; } || skip 'golang not found'
|
||||
export GOPATH="/foo:/bar"
|
||||
load ../../plugins/available/go.plugin
|
||||
assert_equal "$(cut -d':' -f1,2 <<<$PATH)" "/foo/bin:/bar/bin"
|
||||
}
|
||||
|
||||
@test 'plugins go: multiple entries in GOPATH, with space' {
|
||||
{ [[ $CI ]] || _command_exists go; } || skip 'golang not found'
|
||||
{ _command_exists go && go version &>/dev/null; } || skip 'golang not found'
|
||||
export GOPATH="/foo:/foo bar"
|
||||
load ../../plugins/available/go.plugin
|
||||
assert_equal "$(cut -d':' -f1,2 <<<$PATH)" "/foo/bin:/foo bar/bin"
|
||||
}
|
||||
|
||||
@test 'plugins go: multiple entries in GOPATH, with escaped space' {
|
||||
{ [[ $CI ]] || _command_exists go; } || skip 'golang not found'
|
||||
{ _command_exists go && go version &>/dev/null; } || skip 'golang not found'
|
||||
export GOPATH="/foo:/foo\ bar"
|
||||
load ../../plugins/available/go.plugin
|
||||
assert_equal "$(cut -d':' -f1,2 <<<$PATH)" "/foo/bin:/foo\ bar/bin"
|
||||
|
|
|
|||
2
test/run
2
test/run
|
|
@ -6,7 +6,7 @@ git submodule init && git submodule update
|
|||
|
||||
if [ -z "${BASH_IT}" ]; then
|
||||
declare BASH_IT
|
||||
BASH_IT=$(cd ${test_directory} && dirname "$(pwd)")
|
||||
BASH_IT="$(cd "${test_directory}" && dirname "${PWD}")"
|
||||
export BASH_IT
|
||||
fi
|
||||
|
||||
|
|
|
|||
|
|
@ -7,7 +7,6 @@ load ../../lib/log
|
|||
cite _about _param _example _group _author _version
|
||||
|
||||
load ../../lib/helpers
|
||||
load ../../themes/base.theme
|
||||
|
||||
function local_setup {
|
||||
setup_test_fixture
|
||||
|
|
@ -23,6 +22,8 @@ function local_setup {
|
|||
fi
|
||||
|
||||
export OLD_PATH="$PATH"
|
||||
|
||||
load ../../themes/base.theme
|
||||
}
|
||||
|
||||
function local_teardown {
|
||||
|
|
@ -56,8 +57,8 @@ function setup_svn_path {
|
|||
|
||||
setup_svn_path "$BASH_IT/test/fixtures/svn/working"
|
||||
|
||||
# Load the base theme again so that the working SVN script is detected
|
||||
load ../../themes/base.theme
|
||||
# Init the base theme again so that the working SVN script is detected
|
||||
_bash_it_appearance_scm_init
|
||||
|
||||
scm
|
||||
# Make sure that the SVN command is used
|
||||
|
|
@ -73,8 +74,8 @@ function setup_svn_path {
|
|||
|
||||
setup_svn_path "$BASH_IT/test/fixtures/svn/working"
|
||||
|
||||
# Load the base theme again so that the working SVN script is detected
|
||||
load ../../themes/base.theme
|
||||
# init the base theme again so that the working SVN script is detected
|
||||
_bash_it_appearance_scm_init
|
||||
|
||||
scm
|
||||
# Make sure that the SVN command is used
|
||||
|
|
@ -89,8 +90,8 @@ function setup_svn_path {
|
|||
|
||||
setup_svn_path "$BASH_IT/test/fixtures/svn/working"
|
||||
|
||||
# Load the base theme again so that the working SVN script is detected
|
||||
load ../../themes/base.theme
|
||||
# Init the base theme again so that the working SVN script is detected
|
||||
_bash_it_appearance_scm_init
|
||||
|
||||
scm
|
||||
# Make sure that no SVN command is used
|
||||
|
|
@ -103,8 +104,8 @@ function setup_svn_path {
|
|||
|
||||
setup_svn_path "$BASH_IT/test/fixtures/svn/broken"
|
||||
|
||||
# Load the base theme again so that the broken SVN script is detected
|
||||
load ../../themes/base.theme
|
||||
# Init the base theme again so that the broken SVN script is detected
|
||||
_bash_it_appearance_scm_init
|
||||
|
||||
scm
|
||||
# Make sure that no SVN command is not used
|
||||
|
|
@ -120,8 +121,8 @@ function setup_svn_path {
|
|||
|
||||
setup_svn_path "$BASH_IT/test/fixtures/svn/broken"
|
||||
|
||||
# Load the base theme again so that the broken SVN script is detected
|
||||
load ../../themes/base.theme
|
||||
# Init the base theme again so that the broken SVN script is detected
|
||||
_bash_it_appearance_scm_init
|
||||
|
||||
scm
|
||||
# Make sure that no SVN command is used
|
||||
|
|
|
|||
|
|
@ -1,4 +1,7 @@
|
|||
# shellcheck shell=bash
|
||||
# shellcheck disable=SC2034 # Expected behavior for themes.
|
||||
# shellcheck disable=SC2154 #TODO: fix these all.
|
||||
|
||||
SCM_THEME_PROMPT_DIRTY=" ${red}✗"
|
||||
SCM_THEME_PROMPT_CLEAN=" ${bold_green}✓"
|
||||
SCM_THEME_PROMPT_PREFIX=" |"
|
||||
|
|
@ -11,7 +14,7 @@ GIT_THEME_PROMPT_SUFFIX="${green}|"
|
|||
|
||||
# Nicely formatted terminal prompt
|
||||
function prompt_command() {
|
||||
export PS1="\n${bold_black}[${blue}\@${bold_black}]-${bold_black}[${green}\u${yellow}@${green}\h${bold_black}]-${bold_black}[${purple}\w${bold_black}]-$(scm_prompt_info)\n${reset_color}\$ "
|
||||
PS1="\n${bold_black}[${blue}\@${bold_black}]-${bold_black}[${green}\u${yellow}@${green}\h${bold_black}]-${bold_black}[${purple}\w${bold_black}]-$(scm_prompt_info)\n${reset_color}\$ "
|
||||
}
|
||||
|
||||
safe_append_prompt_command prompt_command
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
# shellcheck shell=bash
|
||||
# shellcheck disable=SC2034 # Expected behavior for themes.
|
||||
# vim: ft=bash ts=2 sw=2 sts=2
|
||||
#
|
||||
# agnoster's Theme - https://gist.github.com/3712874
|
||||
|
|
@ -220,7 +221,7 @@ prompt_virtualenv() {
|
|||
|
||||
# Context: user@hostname (who am I and where am I)
|
||||
prompt_context() {
|
||||
local user=$(whoami)
|
||||
local user="${USER:-${LOGNAME:?}}"
|
||||
|
||||
if [[ $user != "$DEFAULT_USER" || -n $SSH_CLIENT ]]; then
|
||||
prompt_segment black default "$user@\h"
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
# shellcheck shell=bash
|
||||
# shellcheck disable=SC2034 # Expected behavior for themes.
|
||||
# shellcheck disable=SC2154 #TODO: fix these all.
|
||||
|
||||
# Atomic Bash Prompt for Bash-it
|
||||
# By lfelipe base on the theme brainy of MunifTanjim
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
# shellcheck shell=bash
|
||||
# shellcheck disable=SC2034 # Expected behavior for themes.
|
||||
# shellcheck disable=SC2154 #TODO: fix these all.
|
||||
|
||||
SCM_THEME_PROMPT_DIRTY=" ${red}✗"
|
||||
SCM_THEME_PROMPT_CLEAN=" ${bold_green}✓"
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
# shellcheck shell=bash
|
||||
# shellcheck disable=SC2034 # Expected behavior for themes.
|
||||
# shellcheck disable=SC2154 #TODO: fix these all.
|
||||
|
||||
# Theme custom glyphs
|
||||
SCM_GIT_CHAR_GITLAB=${BARBUK_GITLAB_CHAR:=' '}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
# shellcheck shell=bash
|
||||
# shellcheck disable=SC2034 # Expected behavior for themes.
|
||||
|
||||
CLOCK_CHAR_THEME_PROMPT_PREFIX=''
|
||||
CLOCK_CHAR_THEME_PROMPT_SUFFIX=''
|
||||
|
|
@ -85,42 +86,61 @@ RBENV_THEME_PROMPT_SUFFIX='|'
|
|||
RBFU_THEME_PROMPT_PREFIX=' |'
|
||||
RBFU_THEME_PROMPT_SUFFIX='|'
|
||||
|
||||
GIT_EXE=$(which git 2> /dev/null || true)
|
||||
P4_EXE=$(which p4 2> /dev/null || true)
|
||||
HG_EXE=$(which hg 2> /dev/null || true)
|
||||
SVN_EXE=$(which svn 2> /dev/null || true)
|
||||
: "${GIT_EXE:=$SCM_GIT}"
|
||||
: "${P4_EXE:=$SCM_P4}"
|
||||
: "${HG_EXE:=$SCM_HG}"
|
||||
: "${SVN_EXE:=$SCM_SVN}"
|
||||
|
||||
# Check for broken SVN exe that is caused by some versions of Xcode.
|
||||
# See https://github.com/Bash-it/bash-it/issues/1612 for more details.
|
||||
if [[ -x "$SVN_EXE" ]]; then
|
||||
if ! "$SVN_EXE" --version > /dev/null 2>&1; then
|
||||
# Unset the SVN exe variable so that SVN commands are avoided.
|
||||
SVN_EXE=""
|
||||
function _bash_it_appearance_scm_init() {
|
||||
GIT_EXE="$(type -P $SCM_GIT || true)"
|
||||
P4_EXE="$(type -P $SCM_P4 || true)"
|
||||
HG_EXE="$(type -P $SCM_HG || true)"
|
||||
SVN_EXE="$(type -P $SCM_SVN || true)"
|
||||
|
||||
# Check for broken SVN exe that is caused by some versions of Xcode.
|
||||
# See https://github.com/Bash-it/bash-it/issues/1612 for more details.
|
||||
if [[ -x "$SVN_EXE" && -x "${SVN_EXE%/*}/xcrun" ]]; then
|
||||
if ! "$SVN_EXE" --version > /dev/null 2>&1; then
|
||||
# Unset the SVN exe variable so that SVN commands are avoided.
|
||||
SVN_EXE=""
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
}
|
||||
_bash_it_appearance_scm_init
|
||||
|
||||
function scm {
|
||||
if [[ "$SCM_CHECK" = false ]]; then
|
||||
SCM=$SCM_NONE
|
||||
elif [[ -f .git/HEAD ]] && [[ -x "$GIT_EXE" ]]; then
|
||||
SCM=$SCM_GIT
|
||||
elif [[ -x "$GIT_EXE" ]] && [[ -n "$(git rev-parse --is-inside-work-tree 2> /dev/null)" ]]; then
|
||||
SCM=$SCM_GIT
|
||||
elif [[ -x "$P4_EXE" ]] && [[ -n "$(p4 set P4CLIENT 2> /dev/null)" ]]; then
|
||||
SCM=$SCM_P4
|
||||
elif [[ -d .hg ]] && [[ -x "$HG_EXE" ]]; then
|
||||
SCM=$SCM_HG
|
||||
elif [[ -x "$HG_EXE" ]] && [[ -n "$(hg root 2> /dev/null)" ]]; then
|
||||
SCM=$SCM_HG
|
||||
elif [[ -d .svn ]] && [[ -x "$SVN_EXE" ]]; then
|
||||
SCM=$SCM_SVN
|
||||
elif [[ -x "$GIT_EXE" ]] && [[ -n "$(git rev-parse --is-inside-work-tree 2> /dev/null)" ]]; then
|
||||
SCM=$SCM_GIT
|
||||
elif [[ -x "$HG_EXE" ]] && [[ -n "$(hg root 2> /dev/null)" ]]; then
|
||||
SCM=$SCM_HG
|
||||
elif [[ -x "$SVN_EXE" ]] && [[ -n "$(svn info --show-item wc-root 2> /dev/null)" ]]; then
|
||||
SCM=$SCM_SVN
|
||||
elif [[ -x "$P4_EXE" ]] && [[ -n "$(p4 set P4CLIENT 2> /dev/null)" ]]; then
|
||||
SCM=$SCM_P4
|
||||
else
|
||||
SCM=$SCM_NONE
|
||||
fi
|
||||
}
|
||||
|
||||
scm_prompt() {
|
||||
local CHAR
|
||||
CHAR="$(scm_char)"
|
||||
local format=${SCM_PROMPT_FORMAT:-'[%s%s]'}
|
||||
|
||||
if [[ "${CHAR}" != "$SCM_NONE_CHAR" ]]; then
|
||||
# shellcheck disable=2059
|
||||
printf "$format\n" "$CHAR" "$(scm_prompt_info)"
|
||||
fi
|
||||
}
|
||||
|
||||
function scm_prompt_char {
|
||||
if [[ -z $SCM ]]; then scm; fi
|
||||
if [[ $SCM == "$SCM_GIT" ]]; then
|
||||
|
|
@ -332,15 +352,15 @@ function svn_prompt_vars {
|
|||
# - .hg is located in ~/Projects/Foo/.hg
|
||||
# - get_hg_root starts at ~/Projects/Foo/Bar and sees that there is no .hg directory, so then it goes into ~/Projects/Foo
|
||||
function get_hg_root {
|
||||
local CURRENT_DIR=$(pwd)
|
||||
local CURRENT_DIR="${PWD}"
|
||||
|
||||
while [ "$CURRENT_DIR" != "/" ]; do
|
||||
if [ -d "$CURRENT_DIR/.hg" ]; then
|
||||
while [[ "${CURRENT_DIR:-/}" != "/" ]]; do
|
||||
if [[ -d "$CURRENT_DIR/.hg" ]]; then
|
||||
echo "$CURRENT_DIR/.hg"
|
||||
return
|
||||
fi
|
||||
|
||||
CURRENT_DIR=$(dirname "$CURRENT_DIR")
|
||||
CURRENT_DIR="${CURRENT_DIR%/*}"
|
||||
done
|
||||
}
|
||||
|
||||
|
|
@ -376,7 +396,7 @@ function hg_prompt_vars {
|
|||
|
||||
function nvm_version_prompt {
|
||||
local node
|
||||
if declare -f -F nvm &> /dev/null; then
|
||||
if _is_function nvm; then
|
||||
node=$(nvm current 2> /dev/null)
|
||||
[[ "${node}" == "system" ]] && return
|
||||
echo -e "${NVM_THEME_PROMPT_PREFIX}${node}${NVM_THEME_PROMPT_SUFFIX}"
|
||||
|
|
@ -413,8 +433,8 @@ function rbfu_version_prompt {
|
|||
}
|
||||
|
||||
function chruby_version_prompt {
|
||||
if declare -f -F chruby &> /dev/null; then
|
||||
if declare -f -F chruby_auto &> /dev/null; then
|
||||
if _is_function chruby; then
|
||||
if _is_function chruby_auto; then
|
||||
chruby_auto
|
||||
fi
|
||||
|
||||
|
|
@ -437,6 +457,10 @@ function k8s_context_prompt {
|
|||
echo -e "$(kubectl config current-context 2> /dev/null)"
|
||||
}
|
||||
|
||||
function k8s_namespace_prompt {
|
||||
echo -e "$(kubectl config view --minify --output 'jsonpath={..namespace}' 2> /dev/null)"
|
||||
}
|
||||
|
||||
function virtualenv_prompt {
|
||||
if [[ -n "$VIRTUAL_ENV" ]]; then
|
||||
virtualenv=$(basename "$VIRTUAL_ENV")
|
||||
|
|
@ -528,7 +552,7 @@ function prompt_char {
|
|||
|
||||
function battery_char {
|
||||
if [[ "${THEME_BATTERY_PERCENTAGE_CHECK}" = true ]]; then
|
||||
echo -e "${bold_red}$(battery_percentage)%"
|
||||
echo -e "${bold_red:-}$(battery_percentage)%"
|
||||
fi
|
||||
}
|
||||
|
||||
|
|
@ -570,7 +594,7 @@ function __check_precmd_conflict() {
|
|||
function safe_append_prompt_command {
|
||||
local prompt_re
|
||||
|
||||
if [ "${__bp_imported}" == "defined" ]; then
|
||||
if [ "${__bp_imported:-missing}" == "defined" ]; then
|
||||
# We are using bash-preexec
|
||||
if ! __check_precmd_conflict "${1}"; then
|
||||
precmd_functions+=("${1}")
|
||||
|
|
@ -585,7 +609,7 @@ function safe_append_prompt_command {
|
|||
prompt_re="\<${1}\>"
|
||||
fi
|
||||
|
||||
if [[ ${PROMPT_COMMAND} =~ ${prompt_re} ]]; then
|
||||
if [[ ${PROMPT_COMMAND[*]:-} =~ ${prompt_re} ]]; then
|
||||
return
|
||||
elif [[ -z ${PROMPT_COMMAND} ]]; then
|
||||
PROMPT_COMMAND="${1}"
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
# shellcheck shell=bash
|
||||
# shellcheck disable=SC2034 # Expected behavior for themes.
|
||||
# shellcheck disable=SC2154 #TODO: fix these all.
|
||||
|
||||
# Detect whether a reboot is required
|
||||
function show_reboot_required() {
|
||||
|
|
@ -31,15 +33,6 @@ function set_user_color() {
|
|||
esac
|
||||
}
|
||||
|
||||
scm_prompt() {
|
||||
CHAR=$(scm_char)
|
||||
if [ "$CHAR" = "$SCM_NONE_CHAR" ]; then
|
||||
return
|
||||
else
|
||||
echo "[$(scm_char)$(scm_prompt_info)]"
|
||||
fi
|
||||
}
|
||||
|
||||
# Define custom colors we need
|
||||
# non-printable bytes in PS1 need to be contained within \[ \].
|
||||
# Otherwise, bash will count them in the length of the prompt
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
# shellcheck shell=bash
|
||||
# shellcheck disable=SC2034 # Expected behavior for themes.
|
||||
# shellcheck disable=SC2154 #TODO: fix these all.
|
||||
|
||||
SCM_THEME_PROMPT_PREFIX=" ${yellow}‹"
|
||||
SCM_THEME_PROMPT_SUFFIX="›${reset_color}"
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
# shellcheck shell=bash
|
||||
# shellcheck disable=SC2034 # Expected behavior for themes.
|
||||
# shellcheck disable=SC2154 #TODO: fix these all.
|
||||
|
||||
SCM_THEME_PROMPT_DIRTY=" ${red}✗"
|
||||
SCM_THEME_PROMPT_CLEAN=" ${bold_green}✓"
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
# shellcheck shell=bash
|
||||
# shellcheck disable=SC2034 # Expected behavior for themes.
|
||||
# shellcheck disable=SC2154 #TODO: fix these all.
|
||||
|
||||
SCM_THEME_PROMPT_DIRTY=" ${red}✗"
|
||||
SCM_THEME_PROMPT_CLEAN=" ${bold_green}✓"
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue