From d376c47bf3e8122b3a391b2be5bf843c524bf441 Mon Sep 17 00:00:00 2001 From: Ari Mourao Date: Wed, 19 Apr 2017 13:30:41 -0300 Subject: [PATCH 01/77] Added alias to 'git commit -a -m' --- aliases/available/git.aliases.bash | 1 + 1 file changed, 1 insertion(+) diff --git a/aliases/available/git.aliases.bash b/aliases/available/git.aliases.bash index eb3554be..2fe26b12 100644 --- a/aliases/available/git.aliases.bash +++ b/aliases/available/git.aliases.bash @@ -38,6 +38,7 @@ alias gc='git commit -v' alias gca='git commit -v -a' alias gcm='git commit -v -m' alias gci='git commit --interactive' +alias gcam='git commit -a -m' alias gb='git branch' alias gba='git branch -a' alias gbt='git branch --track' From db55c63c774674d794cf6b765dd6159b12e4d65b Mon Sep 17 00:00:00 2001 From: Ethan Edwards Date: Tue, 6 Feb 2018 11:08:44 -0600 Subject: [PATCH 02/77] GH-1142 add behavior to address using set -e --- themes/base.theme.bash | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/themes/base.theme.bash b/themes/base.theme.bash index a18c3729..e27cd5f1 100644 --- a/themes/base.theme.bash +++ b/themes/base.theme.bash @@ -125,8 +125,8 @@ function scm_prompt_info_common { fi # TODO: consider adding minimal status information for hg and svn - [[ ${SCM} == ${SCM_HG} ]] && hg_prompt_info && return - [[ ${SCM} == ${SCM_SVN} ]] && svn_prompt_info && return + { [[ ${SCM:-} == ${SCM_HG} ]] && hg_prompt_info && return; } || true + { [[ ${SCM:-} == ${SCM_SVN} ]] && svn_prompt_info && return; } || true } function git_prompt_minimal_info { From e5332cb25314751399db7c9949fe1f70e5cabebf Mon Sep 17 00:00:00 2001 From: Ethan Edwards Date: Tue, 6 Feb 2018 11:30:36 -0600 Subject: [PATCH 03/77] GH-1142 add additional set -e coverage --- themes/githelpers.theme.bash | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/themes/githelpers.theme.bash b/themes/githelpers.theme.bash index e6bda810..ca4f88cd 100644 --- a/themes/githelpers.theme.bash +++ b/themes/githelpers.theme.bash @@ -71,7 +71,7 @@ function _git-hide-status { } function _git-status { - [[ "${SCM_GIT_IGNORE_UNTRACKED}" = "true" ]] && local git_status_flags='-uno' + [[ "${SCM_GIT_IGNORE_UNTRACKED}" = "true" ]] && local git_status_flags='-uno' || true git status --porcelain ${git_status_flags} 2> /dev/null } @@ -100,9 +100,9 @@ function _git-status-counts { } function _git-remote-info { - [[ "$(_git-upstream)" == "" ]] && return + [[ "$(_git-upstream)" == "" ]] && return || true - [[ "$(_git-branch)" == "$(_git-upstream-branch)" ]] && local same_branch_name=true + [[ "$(_git-branch)" == "$(_git-upstream-branch)" ]] && local same_branch_name=true || true if ([[ "${SCM_GIT_SHOW_REMOTE_INFO}" = "auto" ]] && [[ "$(_git-num-remotes)" -ge 2 ]]) || [[ "${SCM_GIT_SHOW_REMOTE_INFO}" = "true" ]]; then if [[ "${same_branch_name}" != "true" ]]; then From e8c3237fb4c485139373ac3aeeb649522c0ba63c Mon Sep 17 00:00:00 2001 From: Adam Wallis Date: Tue, 17 Jul 2018 10:56:36 -0400 Subject: [PATCH 04/77] Use fd for fzf if available on system fd is orders of magnitude faster when searching for files. This patch will force fzf to use fd instead of find. This change is implemented per the recommendation: https://github.com/junegunn/fzf#environment-variables --- plugins/available/fzf.plugin.bash | 2 ++ 1 file changed, 2 insertions(+) diff --git a/plugins/available/fzf.plugin.bash b/plugins/available/fzf.plugin.bash index 69775c75..5aacc37d 100644 --- a/plugins/available/fzf.plugin.bash +++ b/plugins/available/fzf.plugin.bash @@ -6,6 +6,8 @@ about-plugin 'load fzf, if you are using it' [ -f ~/.fzf.bash ] && source ~/.fzf.bash +command -v fd &> /dev/null && export FZF_DEFAULT_COMMAND='fd --type f' + fe() { about "Open the selected file in the default editor" group "fzf" From dd081b6e5f62eb539fd637a956db7d7336d8e72d Mon Sep 17 00:00:00 2001 From: Adam Wallis Date: Tue, 17 Jul 2018 13:52:59 -0400 Subject: [PATCH 05/77] Add plugin for 'jump' Considering FASD has been deprecated, jump does the same thing but is actively maintained! https://github.com/gsamokovarov/jump --- plugins/available/jump.plugin.bash | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100755 plugins/available/jump.plugin.bash diff --git a/plugins/available/jump.plugin.bash b/plugins/available/jump.plugin.bash new file mode 100755 index 00000000..c7b38d28 --- /dev/null +++ b/plugins/available/jump.plugin.bash @@ -0,0 +1,14 @@ +cite about-plugin +about-plugin 'initialize jump (see https://github.com/gsamokovarov/jump)' + +__init_jump() { + command -v jump &> /dev/null + if [ $? -eq 1 ]; then + echo -e "You must install jump before you can use this plugin" + echo -e "See: https://github.com/gsamokovarov/jump" + else + eval "$(jump shell --bind=z)" + fi +} + +__init_jump From e23d26c8fe95911ec3b0c2ce1121ac3be6b02b4f Mon Sep 17 00:00:00 2001 From: con-f-use Date: Wed, 18 Jul 2018 14:52:01 +0200 Subject: [PATCH 06/77] Fix #1210 grep error on MacOS with ssh completion See #1210 --- completion/available/ssh.completion.bash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/completion/available/ssh.completion.bash b/completion/available/ssh.completion.bash index 234a6958..d5cd6e61 100644 --- a/completion/available/ssh.completion.bash +++ b/completion/available/ssh.completion.bash @@ -13,7 +13,7 @@ _sshcomplete() { # parse all defined hosts from .ssh/config and files included there for fl in "$HOME/.ssh/config" \ - $(grep -P "^\s*Include" "$HOME/.ssh/config" | + $(grep "^\s*Include" "$HOME/.ssh/config" | awk '{for (i=2; i<=NF; i++) print $i}' | sed "s|^~/|$HOME/|") do From ac42a6233c2e620e35090de53e000125be17264b Mon Sep 17 00:00:00 2001 From: Adam Wallis Date: Wed, 18 Jul 2018 09:52:52 -0400 Subject: [PATCH 07/77] Allow jump plugin to fail silently when jump not installed Per recommendations from @nwinkler, allow the jump test to fail silently. This helps in cases where users are SSH'ing in, or for some other reason are using bash-it environment on a foreign machine. --- plugins/available/jump.plugin.bash | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/plugins/available/jump.plugin.bash b/plugins/available/jump.plugin.bash index c7b38d28..bc6f85e1 100755 --- a/plugins/available/jump.plugin.bash +++ b/plugins/available/jump.plugin.bash @@ -2,13 +2,8 @@ cite about-plugin about-plugin 'initialize jump (see https://github.com/gsamokovarov/jump)' __init_jump() { - command -v jump &> /dev/null - if [ $? -eq 1 ]; then - echo -e "You must install jump before you can use this plugin" - echo -e "See: https://github.com/gsamokovarov/jump" - else - eval "$(jump shell --bind=z)" - fi + command -v jump &> /dev/null || return + eval "$(jump shell --bind=z)" } __init_jump From 03e26ef7a4211846a4bd74046b8657b06f3562a0 Mon Sep 17 00:00:00 2001 From: Adam Wallis Date: Wed, 18 Jul 2018 10:11:44 -0400 Subject: [PATCH 08/77] Only initialize FZF_DEFAULT_COMMAND if not already set --- plugins/available/fzf.plugin.bash | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/plugins/available/fzf.plugin.bash b/plugins/available/fzf.plugin.bash index 5aacc37d..f2eddeb1 100644 --- a/plugins/available/fzf.plugin.bash +++ b/plugins/available/fzf.plugin.bash @@ -6,7 +6,9 @@ about-plugin 'load fzf, if you are using it' [ -f ~/.fzf.bash ] && source ~/.fzf.bash -command -v fd &> /dev/null && export FZF_DEFAULT_COMMAND='fd --type f' +if [ -z ${FZF_DEFAULT_COMMAND+x} ]; then + command -v fd &> /dev/null && export FZF_DEFAULT_COMMAND='fd --type f' +fi fe() { about "Open the selected file in the default editor" From 4192d07f4f7fa9d56e02b83129f2ec4ce8cf8f6f Mon Sep 17 00:00:00 2001 From: Nils Winkler Date: Thu, 19 Jul 2018 08:58:05 +0200 Subject: [PATCH 09/77] Fixed indentation and a broken character --- lib/helpers.bash | 48 ++++++++++++++++++++++++------------------------ 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/lib/helpers.bash b/lib/helpers.bash index e8fc19ba..f67ebea9 100644 --- a/lib/helpers.bash +++ b/lib/helpers.bash @@ -61,7 +61,7 @@ function reload_plugins() { bash-it () { about 'Bash-it help and maintenance' - param '1: verb [one of: help | show | enable | disable | migrate | update | search | version | reload ] ' + param '1: verb [one of: help | show | enable | disable | migrate | update | search | version | reload ] ' param '2: component type [one of: alias(es) | completion(s) | plugin(s) ] or search term(s)' param '3: specific component [optional]' example '$ bash-it show plugins' @@ -79,28 +79,28 @@ bash-it () shift typeset func case $verb in - show) - func=_bash-it-$component;; - enable) - func=_enable-$component;; - disable) - func=_disable-$component;; - help) - func=_help-$component;; - search) - _bash-it-search $component "$@" - return;; - update) - func=_bash-it_update;; - migrate) - func=_bash-it-migrate;; - version) - func=_bash-it-version;; - reload) - func=_bash-it-reload;; - *) - reference bash-it - return;; + show) + func=_bash-it-$component;; + enable) + func=_enable-$component;; + disable) + func=_disable-$component;; + help) + func=_help-$component;; + search) + _bash-it-search $component "$@" + return;; + update) + func=_bash-it_update;; + migrate) + func=_bash-it-migrate;; + version) + func=_bash-it-version;; + reload) + func=_bash-it-reload;; + *) + reference bash-it + return;; esac # pluralize component if necessary @@ -270,7 +270,7 @@ _bash-it-reload() { source ~/.bashrc ;; esac - + cd - &> /dev/null || return } From f6e2fdd2cfd02931c9a4f491e710bced5e213912 Mon Sep 17 00:00:00 2001 From: Nils Winkler Date: Thu, 19 Jul 2018 09:00:02 +0200 Subject: [PATCH 10/77] Fixed reload command in the update function --- lib/helpers.bash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/helpers.bash b/lib/helpers.bash index f67ebea9..a2c0d3aa 100644 --- a/lib/helpers.bash +++ b/lib/helpers.bash @@ -187,7 +187,7 @@ _bash-it_update() { _bash-it-migrate echo "" echo "All done, enjoy!" - reload + bash-it reload else echo "Error updating Bash-it, please, check if your Bash-it installation folder (${BASH_IT}) is clean." fi From d00762d3cd63d41a0c7f4e978be62bf88dda3555 Mon Sep 17 00:00:00 2001 From: Raphael Parree Date: Thu, 26 Jul 2018 09:51:25 +0200 Subject: [PATCH 11/77] added minikube completion support --- completion/available/minikube.completion.bash | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 completion/available/minikube.completion.bash diff --git a/completion/available/minikube.completion.bash b/completion/available/minikube.completion.bash new file mode 100644 index 00000000..f1d19b87 --- /dev/null +++ b/completion/available/minikube.completion.bash @@ -0,0 +1,8 @@ +#!/usr/bin/env bash + +# minikube (Local Kubernetes) completion + +if command -v minikube &>/dev/null +then + eval "$(minikube completion bash)" +fi From f8473714472ba8c59e4e0b3e3d95bf78f31871c3 Mon Sep 17 00:00:00 2001 From: Enze Chi Date: Thu, 2 Aug 2018 21:46:20 +1000 Subject: [PATCH 12/77] Avoid double semicolon in the PROMPT_COMMAND The direnv bash hook already add a semicolon to the PROMPT_COMMAND and this plugin will add another one if direnv is installed. This commit will check if the PROMPT_COMMAND ends with semicolon to avoid have double ones. --- plugins/available/osx.plugin.bash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/available/osx.plugin.bash b/plugins/available/osx.plugin.bash index 2dba0279..0e74ab8d 100644 --- a/plugins/available/osx.plugin.bash +++ b/plugins/available/osx.plugin.bash @@ -5,7 +5,7 @@ about-plugin 'osx-specific functions' if [ $(uname) = "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" + PROMPT_COMMAND="${PROMPT_COMMAND%;};update_terminal_cwd" declared="$(declare -p PROMPT_COMMAND)" [[ "$declared" =~ \ -[aAilrtu]*x[aAilrtu]*\ ]] 2>/dev/null [[ $? -eq 0 ]] && export PROMPT_COMMAND From 0960c1b26c46631e7c83d06937aa66e375cd7cc8 Mon Sep 17 00:00:00 2001 From: Jeremy Mathevet Date: Sun, 5 Aug 2018 20:24:40 +0100 Subject: [PATCH 13/77] kubectl aliases --- aliases/available/kubectl.aliases.bash | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 aliases/available/kubectl.aliases.bash diff --git a/aliases/available/kubectl.aliases.bash b/aliases/available/kubectl.aliases.bash new file mode 100644 index 00000000..58670ce5 --- /dev/null +++ b/aliases/available/kubectl.aliases.bash @@ -0,0 +1,24 @@ +#!/bin/bash +# +# -binaryanomaly + +cite 'about-alias' +about-alias 'kubectl aliases' + +# set apt aliases +function _set_pkg_aliases() +{ + if [ -x $(which kubectl) ]; then + alias kc='kubectl' + alias kcgp='kubectl get pods' + alias kcgd='kubectl get deployments' + alias kcgn='kubectl get nodes' + alias kcdp='kubectl describe pod' + alias kcdd='kubectl describe deployment' + alias kcdn='kubectl describe node' + alias kcgpan='kubectl get pods --all-namespaces' + alias kcgdan='kubectl get deployments --all-namespaces' + fi +} + +_set_pkg_aliases From 681aa230d836c8a89fb2eec6c645f4f14cbdc42f Mon Sep 17 00:00:00 2001 From: Cody Horst Date: Tue, 14 Aug 2018 20:40:28 -0700 Subject: [PATCH 14/77] add support for conda --- themes/zork/zork.theme.bash | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/themes/zork/zork.theme.bash b/themes/zork/zork.theme.bash index 75bc17d6..07f30e12 100644 --- a/themes/zork/zork.theme.bash +++ b/themes/zork/zork.theme.bash @@ -57,7 +57,12 @@ chroot(){ # show virtualenvwrapper my_ve(){ - if [ -n "$VIRTUAL_ENV" ] + + if [ -n "$CONDA_DEFAULT_ENV" ] + then + my_ps_ve="${bold_purple}${CONDA_DEFAULT_ENV}${normal}"; + echo "($my_ps_ve)"; + elif [ -n "$VIRTUAL_ENV" ] then my_ps_ve="${bold_purple}$ve${normal}"; echo "($my_ps_ve)"; From 52945d37c2fae4761ee15036360a76101e44ebfd Mon Sep 17 00:00:00 2001 From: Semyon Gashchenko Date: Sun, 26 Aug 2018 00:11:23 +0300 Subject: [PATCH 15/77] Add mvn package aliases --- aliases/available/maven.aliases.bash | 3 +++ 1 file changed, 3 insertions(+) diff --git a/aliases/available/maven.aliases.bash b/aliases/available/maven.aliases.bash index 4cd89d27..f8a44a1c 100644 --- a/aliases/available/maven.aliases.bash +++ b/aliases/available/maven.aliases.bash @@ -3,9 +3,12 @@ about-alias 'maven abbreviations' alias mci='mvn clean install' alias mi='mvn install' +alias mcp='mvn clean package' +alias mp='mvn package' alias mrprep='mvn release:prepare' alias mrperf='mvn release:perform' alias mrrb='mvn release:rollback' alias mdep='mvn dependency:tree' alias mpom='mvn help:effective-pom' alias mcisk='mci -Dmaven.test.skip=true' +alias mcpsk='mcp -Dmaven.test.skip=true' From ac5a8aca47f42c6feab6bde3fb7e5a06d53f28ff Mon Sep 17 00:00:00 2001 From: Rutger Lubbers Date: Mon, 27 Aug 2018 12:32:12 +0200 Subject: [PATCH 16/77] Added completion of installable versions The versions that can be installed were not completed. The list of available versions showed the installed versions. The function retrieves the available versions and removes the already installed versions. --- completion/available/sdkman.completion.bash | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/completion/available/sdkman.completion.bash b/completion/available/sdkman.completion.bash index f5af6c6a..b4d62da1 100644 --- a/completion/available/sdkman.completion.bash +++ b/completion/available/sdkman.completion.bash @@ -27,10 +27,14 @@ _sdkman_complete() esac elif [ $COMP_CWORD -eq 3 ]; then case "${COMP_WORDS[COMP_CWORD-2]}" in - "install" | "uninstall" | "rm" | "use" | "default" ) + "uninstall" | "rm" | "use" | "default" ) _sdkman_candidate_versions ${COMP_WORDS[COMP_CWORD-1]} COMPREPLY=( $(compgen -W "$CANDIDATE_VERSIONS" -- ${COMP_WORDS[COMP_CWORD]}) ) ;; + "install") + _sdkman_candidate_not_installed_versions ${COMP_WORDS[COMP_CWORD-1]} + COMPREPLY=( $(compgen -W "$CANDIDATE_VERSIONS" -- ${COMP_WORDS[COMP_CWORD]}) ) + ;; *) ;; esac @@ -51,6 +55,14 @@ _sdkman_candidate_versions(){ } +_sdkman_candidate_not_installed_versions(){ + CANDIDATE_LOCAL_VERSIONS=$(__sdkman_cleanup_local_versions $1) + if [ "$SDKMAN_OFFLINE_MODE" = "false" ]; then + CANDIDATE_ONLINE_VERSIONS="$(__sdkman_list_versions $1 | grep " " | grep "\." | cut -c 6-)" + CANDIDATE_VERSIONS="$(echo $CANDIDATE_ONLINE_VERSIONS $CANDIDATE_LOCAL_VERSIONS | tr ' ' '\n' | sort | uniq -u) " + fi +} + __sdkman_cleanup_local_versions(){ __sdkman_build_version_csv $1 | tr ',' ' ' From c5e8349f698e36ed28265e9c4e6b485a0ed17322 Mon Sep 17 00:00:00 2001 From: Ahmad Assaf Date: Wed, 29 Aug 2018 15:00:46 +0100 Subject: [PATCH 17/77] Fixing Error when starting Terminal after installing Bash-IT --- completion/available/system.completion.bash | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/completion/available/system.completion.bash b/completion/available/system.completion.bash index b044627c..f9a3b29f 100644 --- a/completion/available/system.completion.bash +++ b/completion/available/system.completion.bash @@ -20,8 +20,8 @@ if [ $(uname) = "Darwin" ] && command -v brew &>/dev/null ; then . "$BREW_PREFIX"/etc/bash_completion fi - # homebrew/versions/bash-completion2 (required for projects.completion.bash) is installed to this path - if [ -f "$BREW_PREFIX"/share/bash-completion/bash_completion ]; then + # homebrew/versions/bash-completion2 (required for projects.completion.bash) is installed to this path + if [ "${BASH_VERSINFO}" -ge 4 ] && [ -f "$BREW_PREFIX"/share/bash-completion/bash_completion ]; then . "$BREW_PREFIX"/share/bash-completion/bash_completion fi fi From 76de592cafb021c3168d89b2dd5d4571eb0e895c Mon Sep 17 00:00:00 2001 From: Travis Swicegood Date: Thu, 30 Aug 2018 18:43:00 -0500 Subject: [PATCH 18/77] Add Crystal auto-completion on Mac --- completion/available/crystal.completion.bash | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 completion/available/crystal.completion.bash diff --git a/completion/available/crystal.completion.bash b/completion/available/crystal.completion.bash new file mode 100644 index 00000000..b83be253 --- /dev/null +++ b/completion/available/crystal.completion.bash @@ -0,0 +1,8 @@ +if which crystal >/dev/null 2>&1; then + BREW_PREFIX=$(brew --prefix) + + if [ -f "$BREW_PREFIX"/etc/bash_completion.d/crystal ]; then + . "$BREW_PREFIX"/etc/bash_completion.d/crystal + fi + +fi From bdc31aa55d9a4803fbf6d5efad27735a1f0da6ac Mon Sep 17 00:00:00 2001 From: Claudia Date: Tue, 4 Sep 2018 07:25:28 +0200 Subject: [PATCH 19/77] Remove alias for `brew cask search` In Homebrew (the upstream project), `brew cask search` was merged into `brew search` a few months ago [1]. On 2018-09-30, `brew cask search` will be disabled altogether [2]. Since the output of `brew cask search` used to be subject to change at any time and was never meant to be parsed, scripts should not rely on the `bcsr` alias. So I figure it may not hurt to remove the `bcsr` alias from Bash-it before that deadline. [1]: https://github.com/Homebrew/brew/pull/4316 [2]: https://github.com/Homebrew/brew/commit/990dd7de865ccbbc0d0ef5fb62256a86f1c92133 --- aliases/available/homebrew-cask.aliases.bash | 1 - 1 file changed, 1 deletion(-) diff --git a/aliases/available/homebrew-cask.aliases.bash b/aliases/available/homebrew-cask.aliases.bash index 090622b0..57d8161c 100644 --- a/aliases/available/homebrew-cask.aliases.bash +++ b/aliases/available/homebrew-cask.aliases.bash @@ -7,7 +7,6 @@ alias bcin='brew cask install' alias bcrm='brew cask uninstall' alias bczp='brew cask zap' alias bccl='brew cask cleanup' -alias bcsr='brew cask search' alias bcls='brew cask list' alias bcinf='brew cask info' alias bcdr='brew cask doctor' From e6d6b47abea489acc3fb658ff0d5f651cbe76039 Mon Sep 17 00:00:00 2001 From: penguin2048 Date: Mon, 10 Sep 2018 19:20:22 +0530 Subject: [PATCH 20/77] Add virtual env support for elixr theme --- themes/elixr/elixr.theme.bash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/themes/elixr/elixr.theme.bash b/themes/elixr/elixr.theme.bash index 0e37f94c..266abbad 100644 --- a/themes/elixr/elixr.theme.bash +++ b/themes/elixr/elixr.theme.bash @@ -17,7 +17,7 @@ RVM_THEME_PROMPT_SUFFIX=" d|" BOLD="\[\e[1m\]" function prompt_command() { - PS1="\n${bold_cyan}$(scm_prompt_char_info) ${bold_cyan}\w :${reset_color}${normal}${BOLD} " + PS1="\n${bold_cyan}$(scm_prompt_char_info)$(virtualenv_prompt) ${bold_cyan}\w :${reset_color}${normal}${BOLD} " } safe_append_prompt_command prompt_command From 28c55f86dbe8a3e2be2d95ec1022407893e8e486 Mon Sep 17 00:00:00 2001 From: Dinos Stamou Date: Tue, 25 Sep 2018 17:11:37 +0300 Subject: [PATCH 21/77] Fix Demula theme first line issue --- themes/demula/demula.theme.bash | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/themes/demula/demula.theme.bash b/themes/demula/demula.theme.bash index 515d096d..e85c18f7 100644 --- a/themes/demula/demula.theme.bash +++ b/themes/demula/demula.theme.bash @@ -100,8 +100,7 @@ prompt() { if [ $(uname) = "Linux" ]; then - PS1="${TITLEBAR} -${SAVE_CURSOR}${MOVE_CURSOR_RIGHTMOST}${MOVE_CURSOR_5_LEFT}\ + PS1="${TITLEBAR}${SAVE_CURSOR}${MOVE_CURSOR_RIGHTMOST}${MOVE_CURSOR_5_LEFT} $(safe_battery_charge)${RESTORE_CURSOR}\ ${D_USER_COLOR}\u ${D_INTERMEDIATE_COLOR}\ at ${D_MACHINE_COLOR}\h ${D_INTERMEDIATE_COLOR}\ @@ -113,7 +112,7 @@ ${D_INTERMEDIATE_COLOR}$ ${D_DEFAULT_COLOR}" else PS1="${TITLEBAR} ${D_USER_COLOR}\u ${D_INTERMEDIATE_COLOR}\ -at ${D_MACHINE_COLOR}\h ${D_INTERMEDIATE_COLOR}\ +at ${D_MACHINE_COLOR}\h ${D_INTERMEDIATE_COLOR}\ in ${D_DIR_COLOR}\w ${D_INTERMEDIATE_COLOR}\ ${LAST_COMMAND_FAILED}\ $(demula_vcprompt)\ From 14b2dbde858729feedc3142c0e5077948f8c4c9d Mon Sep 17 00:00:00 2001 From: Ari Mourao Date: Tue, 2 Oct 2018 15:18:54 -0300 Subject: [PATCH 22/77] docker-compose up and docker exec -it aliases --- aliases/available/docker-compose.aliases.bash | 1 + aliases/available/docker.aliases.bash | 1 + 2 files changed, 2 insertions(+) diff --git a/aliases/available/docker-compose.aliases.bash b/aliases/available/docker-compose.aliases.bash index 01eb62fb..f23c2689 100644 --- a/aliases/available/docker-compose.aliases.bash +++ b/aliases/available/docker-compose.aliases.bash @@ -4,3 +4,4 @@ about-alias 'docker-compose abbreviations' alias dco="docker-compose" alias dcofresh="docker-compose-fresh" alias dcol="docker-compose logs -f --tail 100" +alias dcou="docker-compose up" diff --git a/aliases/available/docker.aliases.bash b/aliases/available/docker.aliases.bash index e3601d6f..ee7a037f 100644 --- a/aliases/available/docker.aliases.bash +++ b/aliases/available/docker.aliases.bash @@ -25,3 +25,4 @@ alias dkrmi='docker-remove-images' # Delete images for supplied IDs or all if n alias dkideps='docker-image-dependencies' # Output a graph of image dependencies using Graphiz alias dkre='docker-runtime-environment' # List environmental variables of the supplied image ID alias dkelc='docker exec -it `dklcid` bash' # Enter last container (works with Docker 1.3 and above) +alias dkex='docker exec -it ' # Useful to run any commands into container without leaving host From e69d1b82d8b3762cb422fa6d70ad319d6737e438 Mon Sep 17 00:00:00 2001 From: Kelly Stannard Date: Wed, 3 Oct 2018 10:02:44 -0400 Subject: [PATCH 23/77] further bundle exec completion examples: `bundle exec rsp` + TAB => `bundle exec rspec` `bundle exec rspec --no` + TAB => `bundle exec rspec --no-color` --- completion/available/bundler.completion.bash | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/completion/available/bundler.completion.bash b/completion/available/bundler.completion.bash index 274a4a36..cdb7cf54 100644 --- a/completion/available/bundler.completion.bash +++ b/completion/available/bundler.completion.bash @@ -21,6 +21,9 @@ __bundle() { if [[ -z $bundle_command ]]; then options="$options --version --help" fi + elif [[ $bundle_command = "exec" ]]; then + _bundle_exec_completions + return else if [[ -z $bundle_command || $bundle_command = help ]]; then options="help install update package exec config check list show @@ -53,3 +56,10 @@ __bundle_get_command() { complete -F __bundle -o bashdefault -o default bundle # vim: ai ft=sh sw=4 sts=2 et + +_bundle_exec_completions() +{ + if [[ $COMP_CWORD = 2 ]]; then + COMPREPLY=($(compgen -c -- "$2")) + fi +} From 07a1499ec05a9527d7e1b50ee99b4332b67241e0 Mon Sep 17 00:00:00 2001 From: Ari Mourao Date: Wed, 3 Oct 2018 11:11:51 -0300 Subject: [PATCH 24/77] duplicated git commit -a -m entry removed --- aliases/available/git.aliases.bash | 1 - 1 file changed, 1 deletion(-) diff --git a/aliases/available/git.aliases.bash b/aliases/available/git.aliases.bash index fa411346..169fe7b8 100644 --- a/aliases/available/git.aliases.bash +++ b/aliases/available/git.aliases.bash @@ -42,7 +42,6 @@ alias gca='git commit -v -a' alias gcm='git commit -v -m' alias gcam="git commit -v -am" alias gci='git commit --interactive' -alias gcam='git commit -a -m' alias gb='git branch' alias gba='git branch -a' alias gbt='git branch --track' From 025554d79d9e67e6846095107a96f16cbe912ecf Mon Sep 17 00:00:00 2001 From: Saulius Gurklys Date: Sat, 6 Oct 2018 16:44:37 +0300 Subject: [PATCH 25/77] Add minimal HG prompt to powerline themes --- themes/powerline-multiline/powerline-multiline.theme.bash | 1 + themes/powerline-naked/powerline-naked.theme.bash | 1 + themes/powerline-plain/powerline-plain.theme.bash | 1 + themes/powerline/powerline.base.bash | 2 ++ themes/powerline/powerline.theme.bash | 1 + 5 files changed, 6 insertions(+) diff --git a/themes/powerline-multiline/powerline-multiline.theme.bash b/themes/powerline-multiline/powerline-multiline.theme.bash index a62a7060..5af4dba2 100644 --- a/themes/powerline-multiline/powerline-multiline.theme.bash +++ b/themes/powerline-multiline/powerline-multiline.theme.bash @@ -20,6 +20,7 @@ PYTHON_VENV_THEME_PROMPT_COLOR=35 SCM_NONE_CHAR="" SCM_GIT_CHAR=${POWERLINE_SCM_GIT_CHAR:=" "} +SCM_HG_CHAR=${POWERLINE_SCM_HG_CHAR:="☿ "} SCM_THEME_PROMPT_CLEAN="" SCM_THEME_PROMPT_DIRTY="" SCM_THEME_PROMPT_CLEAN_COLOR=25 diff --git a/themes/powerline-naked/powerline-naked.theme.bash b/themes/powerline-naked/powerline-naked.theme.bash index 1897a6ba..08e2a1f5 100644 --- a/themes/powerline-naked/powerline-naked.theme.bash +++ b/themes/powerline-naked/powerline-naked.theme.bash @@ -16,6 +16,7 @@ PYTHON_VENV_THEME_PROMPT_COLOR=35 SCM_NONE_CHAR="" SCM_GIT_CHAR=${POWERLINE_SCM_GIT_CHAR:=" "} +SCM_HG_CHAR=${POWERLINE_SCM_HG_CHAR:="☿ "} SCM_THEME_PROMPT_CLEAN="" SCM_THEME_PROMPT_DIRTY="" SCM_THEME_PROMPT_COLOR=238 diff --git a/themes/powerline-plain/powerline-plain.theme.bash b/themes/powerline-plain/powerline-plain.theme.bash index 53da88b4..cdcb3cc2 100644 --- a/themes/powerline-plain/powerline-plain.theme.bash +++ b/themes/powerline-plain/powerline-plain.theme.bash @@ -12,6 +12,7 @@ PYTHON_VENV_THEME_PROMPT_COLOR=35 SCM_NONE_CHAR="" SCM_GIT_CHAR=${POWERLINE_SCM_GIT_CHAR:="⎇ "} +SCM_HG_CHAR=${POWERLINE_SCM_HG_CHAR:="☿ "} SCM_THEME_PROMPT_CLEAN="" SCM_THEME_PROMPT_DIRTY="" SCM_THEME_PROMPT_CLEAN_COLOR=25 diff --git a/themes/powerline/powerline.base.bash b/themes/powerline/powerline.base.bash index ade246e9..78b6d710 100644 --- a/themes/powerline/powerline.base.bash +++ b/themes/powerline/powerline.base.bash @@ -86,6 +86,8 @@ function __powerline_scm_prompt { scm_prompt+="${SCM_CHAR}${SCM_BRANCH}${SCM_STATE}" elif [[ "${SCM_P4_CHAR}" == "${SCM_CHAR}" ]]; then scm_prompt+="${SCM_CHAR}${SCM_BRANCH}${SCM_STATE}" + elif [[ "${SCM_HG_CHAR}" == "${SCM_CHAR}" ]]; then + scm_prompt+="${SCM_CHAR}${SCM_BRANCH}${SCM_STATE}" fi echo "${scm_prompt}${scm}|${color}" fi diff --git a/themes/powerline/powerline.theme.bash b/themes/powerline/powerline.theme.bash index df72a73f..d3bb242a 100644 --- a/themes/powerline/powerline.theme.bash +++ b/themes/powerline/powerline.theme.bash @@ -15,6 +15,7 @@ PYTHON_VENV_THEME_PROMPT_COLOR=35 SCM_NONE_CHAR="" SCM_GIT_CHAR=${POWERLINE_SCM_GIT_CHAR:=" "} +SCM_HG_CHAR=${POWERLINE_SCM_HG_CHAR:="☿ "} SCM_THEME_PROMPT_CLEAN="" SCM_THEME_PROMPT_DIRTY="" SCM_THEME_PROMPT_CLEAN_COLOR=25 From d0f76548ce6af2b208dfb385ac79ef201b56f5d1 Mon Sep 17 00:00:00 2001 From: sharils Date: Tue, 16 Oct 2018 21:45:16 +0800 Subject: [PATCH 26/77] Add SCM_GIT_SHOW_STASH_INFO flag #914 In order to make `git_prompt_vars` run faster As a user with slow `git stash list` I want to be able to optionally disable running `git stash list` when `git_prompt_vars` is executed --- README.md | 13 +++++++++++++ themes/base.theme.bash | 9 ++++++--- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 022ce442..e73fc55d 100644 --- a/README.md +++ b/README.md @@ -312,6 +312,19 @@ Also, with this flag to false, Bash-it will not show the repository as dirty whe **NOTE:** If you set in git configuration file the option to ignore *untracked* files, this flag has no effect, and Bash-it will ignore *untracked* files always. +### Stash item count + +When `SCM_GIT_SHOW_DETAILS` is enabled, you can get the count of *stashed* items. This feature can be useful when a user has a lot of stash items. +This feature is controlled through the flag `SCM_GIT_SHOW_STASH_INFO` as follows: + +Set `SCM_GIT_SHOW_STASH_INFO` to 'true' (the default value) to **show** the count of stashed items: + +* `export SCM_GIT_SHOW_STASH_INFO=true` + +Set `SCM_GIT_SHOW_STASH_INFO` to 'false' to **don't show** it: + +* `export SCM_GIT_SHOW_STASH_INFO=false` + ### Git user In some environments, it is useful to know the value of the current git user, which is used to mark all new commits. diff --git a/themes/base.theme.bash b/themes/base.theme.bash index 7895e5cf..51d5f359 100644 --- a/themes/base.theme.bash +++ b/themes/base.theme.bash @@ -32,6 +32,7 @@ SCM_GIT_SHOW_REMOTE_INFO=${SCM_GIT_SHOW_REMOTE_INFO:=auto} SCM_GIT_IGNORE_UNTRACKED=${SCM_GIT_IGNORE_UNTRACKED:=false} SCM_GIT_SHOW_CURRENT_USER=${SCM_GIT_SHOW_CURRENT_USER:=false} SCM_GIT_SHOW_MINIMAL_INFO=${SCM_GIT_SHOW_MINIMAL_INFO:=false} +SCM_GIT_SHOW_STASH_INFO=${SCM_GIT_SHOW_STASH_INFO:=true} SCM_GIT='git' SCM_GIT_CHAR='±' @@ -181,9 +182,11 @@ function git_prompt_vars { [[ "${commits_ahead}" -gt 0 ]] && SCM_BRANCH+=" ${SCM_GIT_AHEAD_CHAR}${commits_ahead}" [[ "${commits_behind}" -gt 0 ]] && SCM_BRANCH+=" ${SCM_GIT_BEHIND_CHAR}${commits_behind}" - local stash_count - stash_count="$(git stash list 2> /dev/null | wc -l | tr -d ' ')" - [[ "${stash_count}" -gt 0 ]] && SCM_BRANCH+=" ${SCM_GIT_STASH_CHAR_PREFIX}${stash_count}${SCM_GIT_STASH_CHAR_SUFFIX}" + if [[ "${SCM_GIT_SHOW_STASH_INFO}" = "true" ]]; then + local stash_count + stash_count="$(git stash list 2> /dev/null | wc -l | tr -d ' ')" + [[ "${stash_count}" -gt 0 ]] && SCM_BRANCH+=" ${SCM_GIT_STASH_CHAR_PREFIX}${stash_count}${SCM_GIT_STASH_CHAR_SUFFIX}" + fi SCM_STATE=${GIT_THEME_PROMPT_CLEAN:-$SCM_THEME_PROMPT_CLEAN} if ! _git-hide-status; then From 502de11c2fa38d2a4ef86adf6ae1132d825e9400 Mon Sep 17 00:00:00 2001 From: Enze Chi Date: Thu, 18 Oct 2018 10:57:54 +1100 Subject: [PATCH 27/77] Use go binary to get default GOROOT and GOPATH --- plugins/available/go.plugin.bash | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) mode change 100644 => 100755 plugins/available/go.plugin.bash diff --git a/plugins/available/go.plugin.bash b/plugins/available/go.plugin.bash old mode 100644 new mode 100755 index c9fcdff8..827ac388 --- a/plugins/available/go.plugin.bash +++ b/plugins/available/go.plugin.bash @@ -5,7 +5,7 @@ about-plugin 'go environment variables & path configuration' [ ! command -v go &>/dev/null ] && return -export GOROOT=${GOROOT:-$(go env | grep GOROOT | cut -d'"' -f2)} +export GOROOT=${GOROOT:-$(go env GOROOT)} pathmunge "${GOROOT}/bin" -export GOPATH=${GOPATH:-"$HOME/go"} +export GOPATH=${GOPATH:-$(go env GOPATH)} pathmunge "${GOPATH}/bin" From 9040359f6c7d05b17b796c4cf64939d340e19029 Mon Sep 17 00:00:00 2001 From: "William A. O. Brown" Date: Thu, 25 Oct 2018 21:37:35 +0100 Subject: [PATCH 28/77] Add Lerna completion options --- completion/available/lerna.completion.bash | 25 ++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 completion/available/lerna.completion.bash diff --git a/completion/available/lerna.completion.bash b/completion/available/lerna.completion.bash new file mode 100644 index 00000000..f8439d3e --- /dev/null +++ b/completion/available/lerna.completion.bash @@ -0,0 +1,25 @@ +#!/bin/bash +# Usage: +# +# To enable bash completion for lerna, add the following line (minus the +# leading #, which is the bash comment character) to your ~/.bashrc file: +# +# eval "$(lerna --completion=bash)" +# Enable bash autocompletion. +function _lerna_completions() { + # The currently-being-completed word. + local cur compls + + cur="${COMP_WORDS[COMP_CWORD]}" + + # Options + compls="add bootstrap changed clean create diff exec \ + import init link list publish run version \ + --loglevel --concurrency --reject-cycles \ + --progress --sort --no-sort --help \ + --version" + + # Tell complete what stuff to show. + COMPREPLY=($(compgen -W "$compls" -- "$cur")) +} +complete -o default -F _lerna_completions lerna From b9c34cb9c297989581cf743cece984e8d4e34b05 Mon Sep 17 00:00:00 2001 From: "William A. O. Brown" Date: Thu, 25 Oct 2018 21:40:57 +0100 Subject: [PATCH 29/77] Remove some comments --- completion/available/lerna.completion.bash | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/completion/available/lerna.completion.bash b/completion/available/lerna.completion.bash index f8439d3e..792ea27b 100644 --- a/completion/available/lerna.completion.bash +++ b/completion/available/lerna.completion.bash @@ -1,15 +1,9 @@ #!/bin/bash -# Usage: -# -# To enable bash completion for lerna, add the following line (minus the -# leading #, which is the bash comment character) to your ~/.bashrc file: -# -# eval "$(lerna --completion=bash)" -# Enable bash autocompletion. +# Lerna autocompletion. function _lerna_completions() { - # The currently-being-completed word. local cur compls + # The currently-being-completed word. cur="${COMP_WORDS[COMP_CWORD]}" # Options From 7661b561bfe25911e57764a4b79ad778ad2ce063 Mon Sep 17 00:00:00 2001 From: Septian Dwic Date: Fri, 26 Oct 2018 17:33:53 +0700 Subject: [PATCH 30/77] Fix `fabric-completion.bash` to `fabric` When a `bash-it show completion` command is executed --- .../available/{fabric-completion.bash => fabric.completion.bash} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename completion/available/{fabric-completion.bash => fabric.completion.bash} (100%) diff --git a/completion/available/fabric-completion.bash b/completion/available/fabric.completion.bash similarity index 100% rename from completion/available/fabric-completion.bash rename to completion/available/fabric.completion.bash From 6cc7b9112e8dab0e48721282342e289b5add277e Mon Sep 17 00:00:00 2001 From: Septian Dwic Date: Fri, 26 Oct 2018 21:49:52 +0700 Subject: [PATCH 31/77] Don't export ruby-build/bin to PATH If ruby-build is installed as a rbenv plugin, ruby-build/bin directories automatically included. --- plugins/available/rbenv.plugin.bash | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/plugins/available/rbenv.plugin.bash b/plugins/available/rbenv.plugin.bash index b1388017..75d24154 100644 --- a/plugins/available/rbenv.plugin.bash +++ b/plugins/available/rbenv.plugin.bash @@ -1,9 +1,10 @@ -# Load rbebv, if you are using it - cite about-plugin about-plugin 'load rbenv, if you are using it' -pathmunge "$HOME"/.rbenv/bin -[ -x `which rbenv` ] && eval "$(rbenv init -)" +export RBENV_ROOT="$HOME/.rbenv" +pathmunge "$RBENV_ROOT/bin" -[ -d "$HOME"/.rbenv/plugins/ruby-build ] && pathmunge "$HOME"/.rbenv/plugins/ruby-build/bin +[[ `which rbenv` ]] && eval "$(rbenv init -)" + +# Load the auto-completion script if rbenv was loaded. +[[ -e $RBENV_ROOT/completions/rbenv.bash ]] && source $RBENV_ROOT/completions/rbenv.bash From 089b10b37cd9dcd6e157d5b1d4136ccfe7cbfabc Mon Sep 17 00:00:00 2001 From: Eduardo Bellido Bellido Date: Sat, 27 Oct 2018 23:01:35 +0200 Subject: [PATCH 32/77] Update AWS variable name AWS_DEFAULT_PROFILE is deprecated, AWS_PROFILE is the correct one now. +info: https://docs.aws.amazon.com/cli/latest/userguide/cli-environment.html --- plugins/available/aws.plugin.bash | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/available/aws.plugin.bash b/plugins/available/aws.plugin.bash index 1519f77b..a8941e07 100644 --- a/plugins/available/aws.plugin.bash +++ b/plugins/available/aws.plugin.bash @@ -72,14 +72,14 @@ function __awskeys_export { export "$(echo ${key} | tr [:lower:] [:upper:])=${p_key#*=}" done fi - export AWS_DEFAULT_PROFILE="$1" + export AWS_PROFILE="$1" else echo "Profile $1 not found in credentials file" fi } function __awskeys_unset { - unset AWS_DEFAULT_PROFILE AWS_ACCESS_KEY_ID AWS_SECRET_ACCESS_KEY + unset AWS_PROFILE AWS_ACCESS_KEY_ID AWS_SECRET_ACCESS_KEY } function __awskeys_comp { From 84b6fde653f2b6740bfa82eec788eaf43c145466 Mon Sep 17 00:00:00 2001 From: Robert Treat Date: Mon, 29 Oct 2018 18:34:28 -0500 Subject: [PATCH 33/77] Make Postgres name use consistent --- plugins/available/postgres.plugin.bash | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/plugins/available/postgres.plugin.bash b/plugins/available/postgres.plugin.bash index b90d8d76..e481d734 100644 --- a/plugins/available/postgres.plugin.bash +++ b/plugins/available/postgres.plugin.bash @@ -20,23 +20,23 @@ done function postgres_start { - about 'Starts PostgresSQL server' + about 'Starts PostgreSQL server' group 'postgres' - echo 'Starting PostgresSQL Server....'; + echo 'Starting Postgres....'; $POSTGRES_BIN/pg_ctl -D $PGDATA -l $PGDATA/logfile start } function postgres_stop { - about 'Steps PostgresSQL server' + about 'Stops PostgreSQL server' group 'postgres' - echo 'Stopping PostgresSQL Server....'; + echo 'Stopping Postgres....'; $POSTGRES_BIN/pg_ctl -D $PGDATA -l $PGDATA/logfile stop -s -m fast } function postgres_status { - about 'Returns status of PostgresSQL server' + about 'Returns status of PostgreSQL server' group 'postgres' # $POSTGRES_BIN/pg_ctl -D $PGDATA status @@ -55,7 +55,7 @@ function is_postgres_running { function postgres_restart { - about 'Restarts status of PostgresSQL server' + about 'Restarts status of PostgreSQL server' group 'postgres' echo 'Restarting Postgres....'; From 12ff176c5597f52d7417eb4a572e3a62075a527e Mon Sep 17 00:00:00 2001 From: Pablo Diaz Date: Tue, 30 Oct 2018 22:54:46 +0100 Subject: [PATCH 34/77] aws session token support --- plugins/available/aws.plugin.bash | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/available/aws.plugin.bash b/plugins/available/aws.plugin.bash index a8941e07..81d88f97 100644 --- a/plugins/available/aws.plugin.bash +++ b/plugins/available/aws.plugin.bash @@ -37,7 +37,7 @@ function __awskeys_help { function __awskeys_get { local ln=$(grep -n "\[ *$1 *\]" ~/.aws/credentials | cut -d ":" -f 1) if [[ -n "${ln}" ]]; then - tail -n +${ln} ~/.aws/credentials | egrep -m 2 "aws_access_key_id|aws_secret_access_key" + tail -n +${ln} ~/.aws/credentials | egrep -m 3 "aws_access_key_id|aws_secret_access_key|aws_session_token" fi } @@ -79,7 +79,7 @@ function __awskeys_export { } function __awskeys_unset { - unset AWS_PROFILE AWS_ACCESS_KEY_ID AWS_SECRET_ACCESS_KEY + unset AWS_PROFILE AWS_ACCESS_KEY_ID AWS_SECRET_ACCESS_KEY AWS_SESSION_TOKEN } function __awskeys_comp { From d41eac5db2e5e7e8a246de93054af9741f052ae5 Mon Sep 17 00:00:00 2001 From: Matthew Bates Date: Wed, 31 Oct 2018 07:42:45 +0000 Subject: [PATCH 35/77] Added puppet bolt aliases --- aliases/available/bolt.bash | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 aliases/available/bolt.bash diff --git a/aliases/available/bolt.bash b/aliases/available/bolt.bash new file mode 100644 index 00000000..8490f710 --- /dev/null +++ b/aliases/available/bolt.bash @@ -0,0 +1,8 @@ +cite 'about-alias' +about-alias 'puppet bolt aliases' + +# Aliases +alias bolt='bolt command run --tty --no-host-key-check' +alias boltas='bolt -p -u' +alias sudobolt='bolt --run-as root --sudo-password' +alias sudoboltas='sudobolt -p -u' From c96cda1ff5782f008d1630bef8311817ce155f26 Mon Sep 17 00:00:00 2001 From: Matthew Bates Date: Wed, 31 Oct 2018 07:54:22 +0000 Subject: [PATCH 36/77] Added puppet aliases --- aliases/available/puppet.aliases.bash | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 aliases/available/puppet.aliases.bash diff --git a/aliases/available/puppet.aliases.bash b/aliases/available/puppet.aliases.bash new file mode 100644 index 00000000..bb5b4a1a --- /dev/null +++ b/aliases/available/puppet.aliases.bash @@ -0,0 +1,10 @@ +cite 'about-alias' +about-alias 'puppet aliases' + +# Aliases +alias pupval="puppet parser validate *.pp" +alias puplint="puppet-lint *.pp" +alias pupagt="puppet agent -t" +alias pupagtd="puppet agent -t --debug" +alias pupapp="puppet apply" + From dd6d5ce6877ba0a697e1c8ed5eff0190a14e3fef Mon Sep 17 00:00:00 2001 From: Matthew Bates Date: Wed, 31 Oct 2018 07:55:40 +0000 Subject: [PATCH 37/77] Renamed to match convention --- aliases/available/{bolt.bash => bolt.aliases.bash} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename aliases/available/{bolt.bash => bolt.aliases.bash} (100%) diff --git a/aliases/available/bolt.bash b/aliases/available/bolt.aliases.bash similarity index 100% rename from aliases/available/bolt.bash rename to aliases/available/bolt.aliases.bash From f41324251fe7e46ea530a55febe5017700d44b3b Mon Sep 17 00:00:00 2001 From: Matthew Bates Date: Wed, 31 Oct 2018 08:07:57 +0000 Subject: [PATCH 38/77] Added more recently available docker cleanup commands --- aliases/available/docker.aliases.bash | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/aliases/available/docker.aliases.bash b/aliases/available/docker.aliases.bash index ee7a037f..418c6235 100644 --- a/aliases/available/docker.aliases.bash +++ b/aliases/available/docker.aliases.bash @@ -26,3 +26,8 @@ alias dkideps='docker-image-dependencies' # Output a graph of image dependencie alias dkre='docker-runtime-environment' # List environmental variables of the supplied image ID alias dkelc='docker exec -it `dklcid` bash' # Enter last container (works with Docker 1.3 and above) alias dkex='docker exec -it ' # Useful to run any commands into container without leaving host + +# Added more recent cleanup options from newer docker versions +alias dkip=`docker image prune -a -f` +alias dkvp=`docker volume prune -f` +alias dksp=`docker system prune -a -f` From 3c8dbf3cd489d6a0f6f2b2bfa5c49ee243219cd8 Mon Sep 17 00:00:00 2001 From: Eduardo Bellido Bellido Date: Wed, 31 Oct 2018 19:18:37 +0100 Subject: [PATCH 39/77] Allow custom aws config files path Honor the environment variables: AWS_CONFIG_FILE AWS_SHARED_CREDENTIALS_FILE in the aws plugin. +info: https://docs.aws.amazon.com/cli/latest/userguide/cli-environment.html --- plugins/available/aws.plugin.bash | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/plugins/available/aws.plugin.bash b/plugins/available/aws.plugin.bash index 81d88f97..66021267 100644 --- a/plugins/available/aws.plugin.bash +++ b/plugins/available/aws.plugin.bash @@ -1,11 +1,14 @@ cite about-plugin about-plugin 'AWS helper functions' +AWS_CONFIG_FILE="${AWS_CONFIG_FILE:-$HOME/.aws/config}" +AWS_SHARED_CREDENTIALS_FILE="${AWS_SHARED_CREDENTIALS_FILE:-$HOME/.aws/credentials}" + function awskeys { about 'helper function for AWS credentials file' group 'aws' - if [[ ! -f ~/.aws/credentials ]]; then + if [[ ! -f "${AWS_SHARED_CREDENTIALS_FILE}" ]]; then echo "AWS credentials file not found" return 1 fi @@ -35,14 +38,14 @@ function __awskeys_help { } function __awskeys_get { - local ln=$(grep -n "\[ *$1 *\]" ~/.aws/credentials | cut -d ":" -f 1) + local ln=$(grep -n "\[ *$1 *\]" "${AWS_SHARED_CREDENTIALS_FILE}" | cut -d ":" -f 1) if [[ -n "${ln}" ]]; then - tail -n +${ln} ~/.aws/credentials | egrep -m 3 "aws_access_key_id|aws_secret_access_key|aws_session_token" + tail -n +${ln} "${AWS_SHARED_CREDENTIALS_FILE}" | egrep -m 3 "aws_access_key_id|aws_secret_access_key|aws_session_token" fi } function __awskeys_list { - local credentials_list="$((egrep '^\[ *[a-zA-Z0-9_-]+ *\]$' ~/.aws/credentials; grep "\[profile" ~/.aws/config | sed "s|\[profile |\[|g") | sort | uniq)" + local credentials_list="$((egrep '^\[ *[a-zA-Z0-9_-]+ *\]$' "${AWS_SHARED_CREDENTIALS_FILE}"; grep "\[profile" "${AWS_CONFIG_FILE}" | sed "s|\[profile |\[|g") | sort | uniq)" if [[ -n $"{credentials_list}" ]]; then echo -e "Available credentials profiles:\n" for profile in ${credentials_list}; do From f757cad45af94879bf6dfceafd12d6f79a738ea5 Mon Sep 17 00:00:00 2001 From: Eduardo Bellido Bellido Date: Wed, 31 Oct 2018 20:09:28 +0100 Subject: [PATCH 40/77] Add new segment, aws_profile, to powerline themes --- themes/powerline-multiline/README.md | 1 + themes/powerline-multiline/powerline-multiline.theme.bash | 3 +++ themes/powerline-naked/README.md | 1 + themes/powerline-naked/powerline-naked.theme.bash | 3 +++ themes/powerline-plain/README.md | 1 + themes/powerline-plain/powerline-plain.theme.bash | 3 +++ themes/powerline/README.md | 1 + themes/powerline/powerline.base.bash | 6 ++++++ themes/powerline/powerline.theme.bash | 3 +++ 9 files changed, 22 insertions(+) diff --git a/themes/powerline-multiline/README.md b/themes/powerline-multiline/README.md index acc199ac..ee6095dd 100644 --- a/themes/powerline-multiline/README.md +++ b/themes/powerline-multiline/README.md @@ -46,6 +46,7 @@ The time/date is printed by the `date` command, so refer to its man page to chan The contents of both prompt sides can be "reordered", all the "segments" (every piece of information) can take any place. The currently available segments are: +* `aws_profile` - Show the current value of the `AWS_PROFILE` environment variable * `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`) diff --git a/themes/powerline-multiline/powerline-multiline.theme.bash b/themes/powerline-multiline/powerline-multiline.theme.bash index 5af4dba2..ad64fb18 100644 --- a/themes/powerline-multiline/powerline-multiline.theme.bash +++ b/themes/powerline-multiline/powerline-multiline.theme.bash @@ -36,6 +36,9 @@ RBENV_THEME_PROMPT_SUFFIX="" RUBY_THEME_PROMPT_COLOR=161 RUBY_CHAR=${POWERLINE_RUBY_CHAR:="❲r❳ "} +AWS_PROFILE_CHAR="${POWERLINE_AWS_PROFILE_CHAR:=❲aws❳ }" +AWS_PROFILE_PROMPT_COLOR=208 + CWD_THEME_PROMPT_COLOR=240 LAST_STATUS_THEME_PROMPT_COLOR=196 diff --git a/themes/powerline-naked/README.md b/themes/powerline-naked/README.md index 510e0301..62238bd5 100644 --- a/themes/powerline-naked/README.md +++ b/themes/powerline-naked/README.md @@ -42,6 +42,7 @@ The time/date is printed by the `date` command, so refer to its man page to chan The contents of the prompt can be "reordered", all the "segments" (every piece of information) can take any place. The currently available segments are: +* `aws_profile` - Show the current value of the `AWS_PROFILE` environment variable * `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`) diff --git a/themes/powerline-naked/powerline-naked.theme.bash b/themes/powerline-naked/powerline-naked.theme.bash index 08e2a1f5..4e06273c 100644 --- a/themes/powerline-naked/powerline-naked.theme.bash +++ b/themes/powerline-naked/powerline-naked.theme.bash @@ -33,6 +33,9 @@ RBENV_THEME_PROMPT_SUFFIX="" RUBY_THEME_PROMPT_COLOR=161 RUBY_CHAR=${POWERLINE_RUBY_CHAR:="❲r❳ "} +AWS_PROFILE_CHAR="${POWERLINE_AWS_PROFILE_CHAR:=❲aws❳ }" +AWS_PROFILE_PROMPT_COLOR=208 + CWD_THEME_PROMPT_COLOR=254 LAST_STATUS_THEME_PROMPT_COLOR=124 diff --git a/themes/powerline-plain/README.md b/themes/powerline-plain/README.md index 8c8647e3..ef773cd8 100644 --- a/themes/powerline-plain/README.md +++ b/themes/powerline-plain/README.md @@ -40,6 +40,7 @@ The time/date is printed by the `date` command, so refer to its man page to chan The contents of the prompt can be "reordered", all the "segments" (every piece of information) can take any place. The currently available segments are: +* `aws_profile` - Show the current value of the `AWS_PROFILE` environment variable * `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`) diff --git a/themes/powerline-plain/powerline-plain.theme.bash b/themes/powerline-plain/powerline-plain.theme.bash index cdcb3cc2..0757dc9e 100644 --- a/themes/powerline-plain/powerline-plain.theme.bash +++ b/themes/powerline-plain/powerline-plain.theme.bash @@ -28,6 +28,9 @@ RBENV_THEME_PROMPT_SUFFIX="" RUBY_THEME_PROMPT_COLOR=161 RUBY_CHAR=${POWERLINE_RUBY_CHAR:="💎 "} +AWS_PROFILE_CHAR="${POWERLINE_AWS_PROFILE_CHAR:=❲aws❳ }" +AWS_PROFILE_PROMPT_COLOR=208 + CWD_THEME_PROMPT_COLOR=240 LAST_STATUS_THEME_PROMPT_COLOR=52 diff --git a/themes/powerline/README.md b/themes/powerline/README.md index 7c1a135c..d3f7fbca 100644 --- a/themes/powerline/README.md +++ b/themes/powerline/README.md @@ -44,6 +44,7 @@ The time/date is printed by the `date` command, so refer to its man page to chan The contents of the prompt can be "reordered", all the "segments" (every piece of information) can take any place. The currently available segments are: +* `aws_profile` - Show the current value of the `AWS_PROFILE` environment variable * `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`) diff --git a/themes/powerline/powerline.base.bash b/themes/powerline/powerline.base.bash index 78b6d710..7dded057 100644 --- a/themes/powerline/powerline.base.bash +++ b/themes/powerline/powerline.base.bash @@ -136,6 +136,12 @@ function __powerline_in_vim_prompt { fi } +function __powerline_aws_profile_prompt { + if [[ -n "${AWS_PROFILE}" ]]; then + echo "${AWS_PROFILE_CHAR}${AWS_PROFILE}|${AWS_PROFILE_PROMPT_COLOR}" + fi +} + function __powerline_left_segment { local OLD_IFS="${IFS}"; IFS="|" local params=( $1 ) diff --git a/themes/powerline/powerline.theme.bash b/themes/powerline/powerline.theme.bash index d3bb242a..9f0e6f04 100644 --- a/themes/powerline/powerline.theme.bash +++ b/themes/powerline/powerline.theme.bash @@ -31,6 +31,9 @@ RBENV_THEME_PROMPT_SUFFIX="" RUBY_THEME_PROMPT_COLOR=161 RUBY_CHAR=${POWERLINE_RUBY_CHAR:="❲r❳ "} +AWS_PROFILE_CHAR="${POWERLINE_AWS_PROFILE_CHAR:=❲aws❳ }" +AWS_PROFILE_PROMPT_COLOR=208 + CWD_THEME_PROMPT_COLOR=240 LAST_STATUS_THEME_PROMPT_COLOR=52 From 74b1fb8185de9a6339fed7cde2e07c16b6c67ef6 Mon Sep 17 00:00:00 2001 From: Jason Al-Mansor Date: Thu, 1 Nov 2018 10:45:08 -0400 Subject: [PATCH 41/77] Fixing quotes around new docker aliases which cause them to execute --- aliases/available/docker.aliases.bash | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/aliases/available/docker.aliases.bash b/aliases/available/docker.aliases.bash index 418c6235..011135c6 100644 --- a/aliases/available/docker.aliases.bash +++ b/aliases/available/docker.aliases.bash @@ -28,6 +28,6 @@ alias dkelc='docker exec -it `dklcid` bash' # Enter last container (works with D alias dkex='docker exec -it ' # Useful to run any commands into container without leaving host # Added more recent cleanup options from newer docker versions -alias dkip=`docker image prune -a -f` -alias dkvp=`docker volume prune -f` -alias dksp=`docker system prune -a -f` +alias dkip='docker image prune -a -f' +alias dkvp='docker volume prune -f' +alias dksp='docker system prune -a -f' From b03a93cd2bf0c13bf2575ee104a0afa3080359ea Mon Sep 17 00:00:00 2001 From: "daniel.schroeder" Date: Fri, 2 Nov 2018 10:47:55 +0100 Subject: [PATCH 42/77] disable theming by checking theme var for value --- README.md | 20 ++++++++++++-------- bash_it.sh | 27 +++++++++++++++------------ template/bash_profile.template.bash | 3 ++- 3 files changed, 29 insertions(+), 21 deletions(-) diff --git a/README.md b/README.md index e73fc55d..13a991da 100644 --- a/README.md +++ b/README.md @@ -59,10 +59,10 @@ When you run without the `--no-modify-config` switch, the Bash-it installer auto Use the `--no-modify-config` switch to avoid unwanted modifications, e.g. if your Bash config file already contains the code that loads Bash-it. **NOTE**: Keep in mind how Bash load its configuration files, -`.bash_profile` for login shells (and in macOS in terminal emulators like [Terminal.app](http://www.apple.com/osx/apps/) or +`.bash_profile` for login shells (and in macOS in terminal emulators like [Terminal.app](http://www.apple.com/osx/apps/) or [iTerm2](https://www.iterm2.com/)) and `.bashrc` for interactive shells (default mode in most of the GNU/Linux terminal emulators), to ensure that Bash-it is loaded correctly. -A good "practice" is sourcing `.bashrc` into `.bash_profile` to keep things working in all the scenarios. +A good "practice" is sourcing `.bashrc` into `.bash_profile` to keep things working in all the scenarios. To achieve this, you can add this snippet in your `.bash_profile`: ``` @@ -76,8 +76,8 @@ Refer to the official [Bash documentation](https://www.gnu.org/software/bash/man ### Install using Docker -You can try Bash-it in an isolated environment without changing any local files via a [Docker](https://www.docker.com/) Container. -(Bash Shell v4.4 with Bash-it, [bats](https://github.com/sstephenson/bats) and bash-completion based on [Alpine Linux](https://alpinelinux.org/)). +You can try Bash-it in an isolated environment without changing any local files via a [Docker](https://www.docker.com/) Container. +(Bash Shell v4.4 with Bash-it, [bats](https://github.com/sstephenson/bats) and bash-completion based on [Alpine Linux](https://alpinelinux.org/)). `docker pull ellerbrock/bash-it` @@ -140,7 +140,7 @@ Currently enabled modules will be shown in green. ### Searching with Negations -You can prefix a search term with a "-" to exclude it from the results. +You can prefix a search term with a "-" to exclude it from the results. In the above example, if we wanted to hide `chruby` and `chruby-auto`, we could change the command as follows: @@ -189,6 +189,7 @@ There are over 50+ Bash-it themes to pick from in `$BASH_IT/themes`. The default theme is `bobby`. Set `BASH_IT_THEME` to the theme name you want, or if you've developed your own custom theme outside of `$BASH_IT/themes`, point the `BASH_IT_THEME` variable directly to the theme file. +To disable theming completely, leave the variable empty. Examples: @@ -198,6 +199,9 @@ export BASH_IT_THEME="powerline-multiline" # Use a theme outside of the Bash-it folder export BASH_IT_THEME="/home/foo/my_theme/my_theme.theme.bash" + +# Disable theming +export BASH_IT_THEME="" ``` You can easily preview the themes in your own shell using `BASH_PREVIEW=true bash-it reload`. @@ -294,8 +298,8 @@ Set `SCM_GIT_SHOW_REMOTE_INFO` to 'false' to **disable the feature**: ### Untracked files -By default, the `git status` command shows information about *untracked* files. -This behavior can be controlled through command-line flags or git configuration files. +By default, the `git status` command shows information about *untracked* files. +This behavior can be controlled through command-line flags or git configuration files. For big repositories, ignoring *untracked* files can make git faster. Bash-it uses `git status` to gather the repo information it shows in the prompt, so in some circumstances, it can be useful to instruct Bash-it to ignore these files. You can control this behavior with the flag `SCM_GIT_IGNORE_UNTRACKED`: @@ -346,7 +350,7 @@ You can control the prefix and the suffix of this component using the two variab And -* `export SCM_THEME_CURRENT_USER_SUFFIX=' ☺︎ '` +* `export SCM_THEME_CURRENT_USER_SUFFIX=' ☺︎ '` **NOTE:** If using `SCM_GIT_SHOW_MINIMAL_INFO=true`, then the value of `SCM_GIT_SHOW_CURRENT_USER` is ignored. diff --git a/bash_it.sh b/bash_it.sh index 8eea4c6a..e2b00de7 100755 --- a/bash_it.sh +++ b/bash_it.sh @@ -46,19 +46,22 @@ do _load_bash_it_files $file_type done -# Load colors and helpers first so they can be used in base theme -# shellcheck source=./themes/colors.theme.bash -source "${BASH_IT}/themes/colors.theme.bash" -# shellcheck source=./themes/githelpers.theme.bash -source "${BASH_IT}/themes/githelpers.theme.bash" -# shellcheck source=./themes/p4helpers.theme.bash -source "${BASH_IT}/themes/p4helpers.theme.bash" -# shellcheck source=./themes/base.theme.bash -source "${BASH_IT}/themes/base.theme.bash" +# Load theme, if a theme was set +if [[ ! -z "${BASH_IT_THEME}" ]]; then + # Load colors and helpers first so they can be used in base theme + # shellcheck source=./themes/colors.theme.bash + source "${BASH_IT}/themes/colors.theme.bash" + # shellcheck source=./themes/githelpers.theme.bash + source "${BASH_IT}/themes/githelpers.theme.bash" + # shellcheck source=./themes/p4helpers.theme.bash + source "${BASH_IT}/themes/p4helpers.theme.bash" + # shellcheck source=./themes/base.theme.bash + source "${BASH_IT}/themes/base.theme.bash" -# appearance (themes) now, after all dependencies -# shellcheck source=./lib/appearance.bash -source "$APPEARANCE_LIB" + # appearance (themes) now, after all dependencies + # shellcheck source=./lib/appearance.bash + source "$APPEARANCE_LIB" +fi # Load custom aliases, completion, plugins for file_type in "aliases" "completion" "plugins" diff --git a/template/bash_profile.template.bash b/template/bash_profile.template.bash index 01097960..5e877900 100755 --- a/template/bash_profile.template.bash +++ b/template/bash_profile.template.bash @@ -3,7 +3,8 @@ # Path to the bash it configuration export BASH_IT="{{BASH_IT}}" -# Lock and Load a custom theme file +# Lock and Load a custom theme file. +# Leave empty to disable theming. # location /.bash_it/themes/ export BASH_IT_THEME='bobby' From 4ff305c009c9fb74b66aece0c8e786dbcd3bd55c Mon Sep 17 00:00:00 2001 From: cornfeedhobo Date: Fri, 9 Nov 2018 18:55:19 -0500 Subject: [PATCH 43/77] add multiple path support to go plugin --- plugins/available/go.plugin.bash | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/plugins/available/go.plugin.bash b/plugins/available/go.plugin.bash index 827ac388..819ebc3a 100755 --- a/plugins/available/go.plugin.bash +++ b/plugins/available/go.plugin.bash @@ -5,7 +5,18 @@ about-plugin 'go environment variables & path configuration' [ ! command -v go &>/dev/null ] && return +function _split_path_reverse() { + local r= + for p in ${@//:/ } ; do + r="$p $r" + done + echo "$r" +} + export GOROOT=${GOROOT:-$(go env GOROOT)} pathmunge "${GOROOT}/bin" + export GOPATH=${GOPATH:-$(go env GOPATH)} -pathmunge "${GOPATH}/bin" +for p in $( _split_path_reverse ${GOPATH} ) ; do + pathmunge "${p}/bin" +done From b3f7de38937a12cfd0cef6eb40069dc7d91b529c Mon Sep 17 00:00:00 2001 From: Eduardo Bellido Bellido Date: Sun, 11 Nov 2018 14:14:02 +0100 Subject: [PATCH 44/77] Support XDG in fzf plugin --- plugins/available/fzf.plugin.bash | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/plugins/available/fzf.plugin.bash b/plugins/available/fzf.plugin.bash index f2eddeb1..def60825 100644 --- a/plugins/available/fzf.plugin.bash +++ b/plugins/available/fzf.plugin.bash @@ -4,7 +4,11 @@ cite about-plugin about-plugin 'load fzf, if you are using it' -[ -f ~/.fzf.bash ] && source ~/.fzf.bash +if [ -f ~/.fzf.bash ]; then + source ~/.fzf.bash +elif [ -f "${XDG_CONFIG_HOME:-$HOME/.config}"/fzf/fzf.bash ]; then + source "${XDG_CONFIG_HOME:-$HOME/.config}"/fzf/fzf.bash +fi if [ -z ${FZF_DEFAULT_COMMAND+x} ]; then command -v fd &> /dev/null && export FZF_DEFAULT_COMMAND='fd --type f' From 4df44b1fa998d44819a84477f8685f12ecab7e1d Mon Sep 17 00:00:00 2001 From: Eduardo Bellido Bellido Date: Mon, 12 Nov 2018 22:59:14 +0100 Subject: [PATCH 45/77] Bash-it don't returns to the previous path after update --- lib/helpers.bash | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/helpers.bash b/lib/helpers.bash index a2c0d3aa..565173ed 100644 --- a/lib/helpers.bash +++ b/lib/helpers.bash @@ -167,6 +167,8 @@ _bash-it_update() { _about 'updates Bash-it' _group 'lib' + local old_pwd="${PWD}" + cd "${BASH_IT}" || return if [ -z $BASH_IT_REMOTE ]; then @@ -194,7 +196,7 @@ _bash-it_update() { else echo "Bash-it is up to date, nothing to do!" fi - cd - &> /dev/null || return + cd "${old_pwd}" &> /dev/null || return } _bash-it-migrate() { From 7e26ae28bf2cf47ea62d3acf0bde5f8ca0ffad0a Mon Sep 17 00:00:00 2001 From: Jeremy Mathevet Date: Tue, 13 Nov 2018 11:25:59 +0000 Subject: [PATCH 46/77] Add kubernetes-context segment to powerline --- themes/base.theme.bash | 4 ++++ themes/powerline-naked/README.md | 4 +++- themes/powerline-naked/powerline-naked.theme.bash | 3 +++ themes/powerline-plain/README.md | 4 +++- themes/powerline-plain/powerline-plain.theme.bash | 3 +++ themes/powerline/README.md | 4 +++- themes/powerline/powerline.base.bash | 10 ++++++++++ themes/powerline/powerline.theme.bash | 3 +++ 8 files changed, 32 insertions(+), 3 deletions(-) diff --git a/themes/base.theme.bash b/themes/base.theme.bash index 51d5f359..e4879f3c 100644 --- a/themes/base.theme.bash +++ b/themes/base.theme.bash @@ -336,6 +336,10 @@ function ruby_version_prompt { echo -e "$(rbfu_version_prompt)$(rbenv_version_prompt)$(rvm_version_prompt)$(chruby_version_prompt)" } +function k8s_context_prompt { + echo -e "$(kubectl config current-context)" +} + function virtualenv_prompt { if [[ -n "$VIRTUAL_ENV" ]]; then virtualenv=`basename "$VIRTUAL_ENV"` diff --git a/themes/powerline-naked/README.md b/themes/powerline-naked/README.md index 62238bd5..da5e254b 100644 --- a/themes/powerline-naked/README.md +++ b/themes/powerline-naked/README.md @@ -14,6 +14,7 @@ A colorful theme, where shows a lot information about your shell session. * An indicator when the current shell is inside the Vim editor * Battery charging status (depends on the [../../plugins/available/battery.plugin.bash](battery plugin)) * SCM Repository status (e.g. Git, SVN) +* The current Kubernetes environment * The current Python environment (Virtualenv, venv, and Conda are supported) in use * The current Ruby environment (rvm and rbenv are supported) in use * Last command exit code (only shown when the exit code is greater than 0) @@ -48,11 +49,12 @@ The contents of the prompt can be "reordered", all the "segments" (every piece o * `cwd` - Current working directory including full folder hierarchy (c.f. `wd`) * `hostname` - Host name of machine * `in_vim` - Show identifier if running in `:terminal` from vim +* `k8s_context` - Show current kubernetes context * `last_status` - Exit status of last run command * `python_venv` - Python virtual environment information (`virtualenv`, `venv` and `conda` supported) * `ruby` - Current ruby version if using `rvm` -* `scm` - Version control information, `git` +* `scm` - Version control information, `git` * `user_info` - Current user * `wd` - Working directory, like `cwd` but doesn't show the full folder hierarchy, only the directory you're currently in. diff --git a/themes/powerline-naked/powerline-naked.theme.bash b/themes/powerline-naked/powerline-naked.theme.bash index 4e06273c..81025c84 100644 --- a/themes/powerline-naked/powerline-naked.theme.bash +++ b/themes/powerline-naked/powerline-naked.theme.bash @@ -33,6 +33,9 @@ RBENV_THEME_PROMPT_SUFFIX="" RUBY_THEME_PROMPT_COLOR=161 RUBY_CHAR=${POWERLINE_RUBY_CHAR:="❲r❳ "} +KUBERNETES_CONTEXT_THEME_CHAR=${POWERLINE_KUBERNETES_CONTEXT_CHAR:="⎈ "} +KUBERNETES_CONTEXT_THEME_PROMPT_COLOR=26 + AWS_PROFILE_CHAR="${POWERLINE_AWS_PROFILE_CHAR:=❲aws❳ }" AWS_PROFILE_PROMPT_COLOR=208 diff --git a/themes/powerline-plain/README.md b/themes/powerline-plain/README.md index ef773cd8..701b9fa1 100644 --- a/themes/powerline-plain/README.md +++ b/themes/powerline-plain/README.md @@ -12,6 +12,7 @@ A colorful theme, where shows a lot information about your shell session. * An indicator when the current shell is inside the Vim editor * Battery charging status (depends on the [../../plugins/available/battery.plugin.bash](battery plugin)) * SCM Repository status (e.g. Git, SVN) +* The current Kubernetes environment * The current Python environment (Virtualenv, venv, and Conda are supported) in use * The current Ruby environment (rvm and rbenv are supported) in use * Last command exit code (only shown when the exit code is greater than 0) @@ -46,11 +47,12 @@ The contents of the prompt can be "reordered", all the "segments" (every piece o * `cwd` - Current working directory including full folder hierarchy (c.f. `wd`) * `hostname` - Host name of machine * `in_vim` - Show identifier if running in `:terminal` from vim +* `k8s_context` - Show current kubernetes context * `last_status` - Exit status of last run command * `python_venv` - Python virtual environment information (`virtualenv`, `venv` and `conda` supported) * `ruby` - Current ruby version if using `rvm` -* `scm` - Version control information, `git` +* `scm` - Version control information, `git` * `user_info` - Current user * `wd` - Working directory, like `cwd` but doesn't show the full folder hierarchy, only the directory you're currently in. diff --git a/themes/powerline-plain/powerline-plain.theme.bash b/themes/powerline-plain/powerline-plain.theme.bash index 0757dc9e..bddb6450 100644 --- a/themes/powerline-plain/powerline-plain.theme.bash +++ b/themes/powerline-plain/powerline-plain.theme.bash @@ -28,6 +28,9 @@ RBENV_THEME_PROMPT_SUFFIX="" RUBY_THEME_PROMPT_COLOR=161 RUBY_CHAR=${POWERLINE_RUBY_CHAR:="💎 "} +KUBERNETES_CONTEXT_THEME_CHAR=${POWERLINE_KUBERNETES_CONTEXT_CHAR:="⎈ "} +KUBERNETES_CONTEXT_THEME_PROMPT_COLOR=26 + AWS_PROFILE_CHAR="${POWERLINE_AWS_PROFILE_CHAR:=❲aws❳ }" AWS_PROFILE_PROMPT_COLOR=208 diff --git a/themes/powerline/README.md b/themes/powerline/README.md index d3f7fbca..974bcbeb 100644 --- a/themes/powerline/README.md +++ b/themes/powerline/README.md @@ -16,6 +16,7 @@ A colorful theme, where shows a lot information about your shell session. * An indicator when the current shell is inside the Vim editor * Battery charging status (depends on the [../../plugins/available/battery.plugin.bash](battery plugin)) * SCM Repository status (e.g. Git, SVN) +* The current Kubernetes environment * The current Python environment (Virtualenv, venv, and Conda are supported) in use * The current Ruby environment (rvm and rbenv are supported) in use * Last command exit code (only shown when the exit code is greater than 0) @@ -50,11 +51,12 @@ The contents of the prompt can be "reordered", all the "segments" (every piece o * `cwd` - Current working directory including full folder hierarchy (c.f. `wd`) * `hostname` - Host name of machine * `in_vim` - Show identifier if running in `:terminal` from vim +* `k8s_context` - Show current kubernetes context * `last_status` - Exit status of last run command * `python_venv` - Python virtual environment information (`virtualenv`, `venv` and `conda` supported) * `ruby` - Current ruby version if using `rvm` -* `scm` - Version control information, `git` +* `scm` - Version control information, `git` * `user_info` - Current user * `wd` - Working directory, like `cwd` but doesn't show the full folder hierarchy, only the directory you're currently in. diff --git a/themes/powerline/powerline.base.bash b/themes/powerline/powerline.base.bash index 7dded057..08da5f7c 100644 --- a/themes/powerline/powerline.base.bash +++ b/themes/powerline/powerline.base.bash @@ -52,6 +52,16 @@ function __powerline_ruby_prompt { [[ -n "${ruby_version}" ]] && echo "${RUBY_CHAR}${ruby_version}|${RUBY_THEME_PROMPT_COLOR}" } +function __powerline_k8s_context_prompt { + local kubernetes_context="" + + if _command_exists kubectl; then + kubernetes_context="$(k8s_context_prompt)" + fi + + [[ -n "${kubernetes_context}" ]] && echo "${KUBERNETES_CONTEXT_THEME_CHAR}${kubernetes_context}|${KUBERNETES_CONTEXT_THEME_PROMPT_COLOR}" +} + function __powerline_python_venv_prompt { set +u local python_venv="" diff --git a/themes/powerline/powerline.theme.bash b/themes/powerline/powerline.theme.bash index 9f0e6f04..482b3464 100644 --- a/themes/powerline/powerline.theme.bash +++ b/themes/powerline/powerline.theme.bash @@ -31,6 +31,9 @@ RBENV_THEME_PROMPT_SUFFIX="" RUBY_THEME_PROMPT_COLOR=161 RUBY_CHAR=${POWERLINE_RUBY_CHAR:="❲r❳ "} +KUBERNETES_CONTEXT_THEME_CHAR=${POWERLINE_KUBERNETES_CONTEXT_CHAR:="⎈ "} +KUBERNETES_CONTEXT_THEME_PROMPT_COLOR=26 + AWS_PROFILE_CHAR="${POWERLINE_AWS_PROFILE_CHAR:=❲aws❳ }" AWS_PROFILE_PROMPT_COLOR=208 From 75564a050f5fb738cb35cdf03239418d9dbdfab8 Mon Sep 17 00:00:00 2001 From: Ira Abramov Date: Thu, 15 Nov 2018 10:35:17 +0200 Subject: [PATCH 47/77] Add completions for Opscode Chef's knife command --- completion/available/knife.completion.bash | 207 +++++++++++++++++++++ 1 file changed, 207 insertions(+) create mode 100644 completion/available/knife.completion.bash diff --git a/completion/available/knife.completion.bash b/completion/available/knife.completion.bash new file mode 100644 index 00000000..6316ce08 --- /dev/null +++ b/completion/available/knife.completion.bash @@ -0,0 +1,207 @@ +#!/usr/bin/env bash + +############## +### CONFIG ### +############## +### feel free to change those constants +# the dir where to store the cache (must be writable and readable by the current user) +# must be an absolute path +_KNIFE_AUTOCOMPLETE_CACHE_DIR="$HOME/.knife_autocomplete_cache" +# the maximum # of _seconds_ after which a cache will be considered stale +# (a cache is refreshed whenever it is used! this is only for caches that might not have been used for a long time) +# WARNING: keep that value > 100 +_KNIFE_AUTOCOMPLETE_MAX_CACHE_AGE=86400 + +############################################### +### END OF CONFIG - DON'T CHANGE CODE BELOW ### +############################################### + +### init +_KAC_CACHE_TMP_DIR="$_KNIFE_AUTOCOMPLETE_CACHE_DIR/tmp" +# make sure the cache dir exists +mkdir -p $_KAC_CACHE_TMP_DIR + +############################## +### Cache helper functions ### +############################## + +# GNU or BSD stat? +stat -c %Y /dev/null > /dev/null 2>&1 && _KAC_STAT_COMMAND="stat -c %Y" || _KAC_STAT_COMMAND="stat -f %m" + +# returns 0 iff the file whose path is given as 1st argument +# exists and has last been modified in the last $2 seconds +# returns 1 otherwise +_KAC_is_file_newer_than() +{ + [ -f "$1" ] || return 1 + [ $(( $(date +%s) - $($_KAC_STAT_COMMAND "$1") )) -gt $2 ] && return 1 || return 0 +} + +# helper function for _KAC_get_and_regen_cache, see doc below +_KAC_regen_cache() +{ + local CACHE_NAME=$1 + local CACHE_PATH="$_KNIFE_AUTOCOMPLETE_CACHE_DIR/$CACHE_NAME" + local TMP_FILE=$(mktemp "$_KAC_CACHE_TMP_DIR/$CACHE_NAME.XXXX") + shift 1 + "$@" > $TMP_FILE 2> /dev/null + # discard the temp file if it's empty AND the previous command didn't exit successfully, but still mark the cache as updated + [[ $? != 0 ]] && [[ $(cat $TMP_FILE | wc -l) == 0 ]] && rm -f $TMP_FILE && touch $CACHE_PATH && return 1 \ + || mv -f $TMP_FILE $CACHE_PATH +} + +# cached files can't have spaces in their names +_KAC_get_cache_name_from_command() +{ + echo "$@" | sed 's/ /_SPACE_/g' +} + +# the reverse operation from the function above +_KAC_get_command_from_cache_name() +{ + echo "$@" | sed 's/_SPACE_/ /g' +} + +# given a command as argument, it fetches the cache for that command if it can find it +# otherwise it waits for the cache to be generated +# in either case, it regenerates the cache, and sets the _KAC_CACHE_PATH env variable +# for obvious reason, do NOT call that in a sub-shell (in particular, no piping) +_KAC_get_and_regen_cache() +{ + # the cache name can't have space in it + local CACHE_NAME=$(_KAC_get_cache_name_from_command "$@") + local REGEN_CMD="_KAC_regen_cache $CACHE_NAME $@" + _KAC_CACHE_PATH="$_KNIFE_AUTOCOMPLETE_CACHE_DIR/$CACHE_NAME" + # no need to wait for the regen if the file already exists + [ -f $_KAC_CACHE_PATH ] && ($REGEN_CMD &) || $REGEN_CMD +} + +# performs two things: first, deletes all obsolete temp files +# then refreshes stale caches that haven't been called in a long time +_KAC_clean_cache() +{ + local FILE CMD + # delete all obsolete temp files, could be lingering there for any kind of crash in the caching process + for FILE in $(ls $_KAC_CACHE_TMP_DIR) + do + _KAC_is_file_newer_than $FILE $_KNIFE_AUTOCOMPLETE_MAX_CACHE_AGE || rm -f $FILE + done + # refresh really stale caches + for FILE in $(find $_KNIFE_AUTOCOMPLETE_CACHE_DIR -maxdepth 1 -type f -not -name '.*') + do + _KAC_is_file_newer_than $FILE $_KNIFE_AUTOCOMPLETE_MAX_CACHE_AGE && continue + # first let's get the original command + CMD=$(_KAC_get_command_from_cache_name $(basename "$FILE")) + # then regen the cache + _KAC_get_and_regen_cache "$CMD" > /dev/null + done +} + +# perform a cache cleaning when loading this file +_KAC_clean_cache + +##################################### +### End of cache helper functions ### +##################################### + + +# returns all the possible knife sub-commands +_KAC_knife_commands() +{ + knife --help | grep -E "^knife" | sed -E 's/ \(options\)//g' +} + +# rebuilds the knife base command currently being completed, and assigns it to $_KAC_CURRENT_COMMAND +# additionnally, returns 1 iff the current base command is not complete, 0 otherwise +# also sets $_KAC_CURRENT_COMMAND_NB_WORDS if the base command is complete +_KAC_get_current_base_command() +{ + local PREVIOUS="knife" + local I=1 + local CURRENT + while [ $I -le $COMP_CWORD ] + do + # command words are all lower-case + echo ${COMP_WORDS[$I]} | grep -E "^[a-z]+$" > /dev/null || break + CURRENT="$PREVIOUS ${COMP_WORDS[$I]}" + cat $_KAC_CACHE_PATH | grep -E "^$CURRENT" > /dev/null || break + PREVIOUS=$CURRENT + I=$(( $I + 1)) + done + _KAC_CURRENT_COMMAND=$PREVIOUS + [ $I -le $COMP_CWORD ] && _KAC_CURRENT_COMMAND_NB_WORDS=$I +} + +# searches the position of the currently completed argument in the current base command +# (i.e. handles "plural" arguments such as knife cookbook upload cookbook1 cookbook2 and so on...) +# assumes the current base command is complete +_KAC_get_current_arg_position() +{ + local CURRENT_ARG_POS=$(( $_KAC_CURRENT_COMMAND_NB_WORDS + 1 )) + local COMPLETE_COMMAND=$(cat $_KAC_CACHE_PATH | grep -E "^$_KAC_CURRENT_COMMAND") + local CURRENT_ARG + while [ $CURRENT_ARG_POS -le $COMP_CWORD ] + do + CURRENT_ARG=$(echo $COMPLETE_COMMAND | cut -d ' ' -f $CURRENT_ARG_POS) + # we break if the current arg is a "plural" arg + echo $CURRENT_ARG | grep -E "^\\[[^]]+(\\.\\.\\.\\]|$)" > /dev/null && break + CURRENT_ARG_POS=$(( $CURRENT_ARG_POS + 1 )) + done + echo $CURRENT_ARG_POS +} + +# the actual auto-complete function +_knife() +{ + _KAC_get_and_regen_cache _KAC_knife_commands + local RAW_LIST ITEM REGEN_CMD ARG_POSITION + 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=$(cat $_KAC_CACHE_PATH | grep -E "^$_KAC_CURRENT_COMMAND" | cut -d ' ' -f $ARG_POSITION | uniq) + + # we need to process that raw list a bit, most notably for placeholders + # NOTE: I chose to explicitely fetch & cache _certain_ informations for the server (cookbooks & node names, etc) + # as opposed to a generic approach by trying to find a 'list' knife command corresponding to the + # current base command - that might limit my script in some situation, but that way I'm sure it caches only + # not-sensitive stuff (a generic approach could be pretty bad e.g. with the knife-rackspace plugin) + LIST="" + for ITEM in $RAW_LIST + do + # always relevant if only lower-case chars : continuation of the base command + echo $ITEM | grep -E "^[a-z]+$" > /dev/null && LIST="$LIST $ITEM" && continue + case $ITEM in + *COOKBOOK*) + # special case for cookbooks : from site or local + [[ ${COMP_WORDS[2]} == 'site' ]] && REGEN_CMD="knife cookbook site list" || REGEN_CMD="knife cookbook list" + _KAC_get_and_regen_cache $REGEN_CMD + LIST="$LIST $(cat $_KAC_CACHE_PATH | cut -d ' ' -f 1)" + continue + ;; + *ITEM*) + # data bag item : another special case + local DATA_BAG_NAME=${COMP_WORDS[$(( COMP_CWORD-1 ))]} + REGEN_CMD="knife data bag show $DATA_BAG_NAME" + ;; + *INDEX*) + # see doc @ http://docs.opscode.com/knife_search.html + LIST="$LIST client environment node role" + REGEN_CMD="knife data bag list" + ;; + *BAG*) REGEN_CMD="knife data bag list";; + *CLIENT*) REGEN_CMD="knife client list";; + *NODE*) REGEN_CMD="knife node list";; + *ENVIRONMENT*) REGEN_CMD="knife environment list";; + *ROLE*) REGEN_CMD="knife role list";; + *USER*) REGEN_CMD="knife user list";; + # not a generic argument we support... + *) continue;; + esac + _KAC_get_and_regen_cache $REGEN_CMD + LIST="$LIST $(cat $_KAC_CACHE_PATH)" + done + COMPREPLY=( $(compgen -W "${LIST}" -- ${COMP_WORDS[COMP_CWORD]})) +} + +#complete -f -F _knife knife +complete -F _knife knife From 96819ba7f30e2a1f62c9518da9dbcd7f16396511 Mon Sep 17 00:00:00 2001 From: Tony Feng <337940626@qq.com> Date: Thu, 15 Nov 2018 16:57:08 +0800 Subject: [PATCH 48/77] fix the phoenix mix command -> 'phoenx' to 'phx'. --- aliases/available/phoenix.aliases.bash | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/aliases/available/phoenix.aliases.bash b/aliases/available/phoenix.aliases.bash index 2a4ec5e1..64728a2e 100644 --- a/aliases/available/phoenix.aliases.bash +++ b/aliases/available/phoenix.aliases.bash @@ -3,7 +3,7 @@ about-alias 'phoenix abbreviations' # Phoenix Commands alias i='iex' -alias ips='iex -S mix phoenix.server' +alias ips='iex -S mix phx.server' alias ism='iex -S mix' alias m='mix' alias mab='mix archive.build' @@ -32,14 +32,14 @@ alias mho='mix hex.outdated' alias mlh='mix local.hex' alias mn='mix new' alias mns='mix new --sup' -alias mpgc='mix phoenix.gen.channel' -alias mpgh='mix phoenix.gen.html' -alias mpgj='mix phoenix.gen.json' -alias mpgm='mix phoenix.gen.model' -alias mpgs='mix phoenix.gen.secret' -alias mpn='mix phoenix.new' -alias mpr='mix phoenix.routes' -alias mps='mix phoenix.server' +alias mpgc='mix phx.gen.channel' +alias mpgh='mix phx.gen.html' +alias mpgj='mix phx.gen.json' +alias mpgm='mix phx.gen.model' +alias mpgs='mix phx.gen.secret' +alias mpn='mix phx.new' +alias mpr='mix phx.routes' +alias mps='mix phx.server' alias mr='mix run' alias mrnh='mix run --no-halt' alias mrl='mix release' From 05529dbd6b29ee273900fa386ccfff7c9a159822 Mon Sep 17 00:00:00 2001 From: Matthew Adams Date: Tue, 20 Nov 2018 07:59:16 -0600 Subject: [PATCH 49/77] more docker aliases --- aliases/available/docker.aliases.bash | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/aliases/available/docker.aliases.bash b/aliases/available/docker.aliases.bash index 011135c6..e7738882 100644 --- a/aliases/available/docker.aliases.bash +++ b/aliases/available/docker.aliases.bash @@ -26,6 +26,10 @@ alias dkideps='docker-image-dependencies' # Output a graph of image dependencie alias dkre='docker-runtime-environment' # List environmental variables of the supplied image ID alias dkelc='docker exec -it `dklcid` bash' # Enter last container (works with Docker 1.3 and above) alias dkex='docker exec -it ' # Useful to run any commands into container without leaving host +alias dkri='docker run --rm -i ' +alias dkrit='docker run --rm -it ' +alias dkalp='docker run --rm -it alpine' +alias dkubu='docker run --rm -it ubuntu' # Added more recent cleanup options from newer docker versions alias dkip='docker image prune -a -f' From 1f80b1147683e91cbb3058986babee984567366b Mon Sep 17 00:00:00 2001 From: Matthew Adams Date: Tue, 20 Nov 2018 09:29:15 -0600 Subject: [PATCH 50/77] more aliases --- aliases/available/docker.aliases.bash | 2 ++ 1 file changed, 2 insertions(+) diff --git a/aliases/available/docker.aliases.bash b/aliases/available/docker.aliases.bash index e7738882..c002f17d 100644 --- a/aliases/available/docker.aliases.bash +++ b/aliases/available/docker.aliases.bash @@ -1,6 +1,8 @@ cite 'about-alias' about-alias 'docker abbreviations' +alias d='docker' +alias dk='docker' alias dklc='docker ps -l' # List last Docker container alias dklcid='docker ps -l -q' # List last Docker container ID alias dklcip='docker inspect -f "{{.NetworkSettings.IPAddress}}" $(docker ps -l -q)' # Get IP of last Docker container From 310ee837c9e2f635b0a36831cb7ab02c816be9ce Mon Sep 17 00:00:00 2001 From: Septian Dwic Date: Wed, 21 Nov 2018 02:05:19 +0700 Subject: [PATCH 51/77] init - bash its automatically load auto-completion --- plugins/available/jenv.plugin.bash | 4 +--- plugins/available/nodenv.plugin.bash | 5 +---- plugins/available/plenv.plugin.bash | 9 +++------ plugins/available/pyenv.plugin.bash | 7 ++----- plugins/available/rbenv.plugin.bash | 5 +---- 5 files changed, 8 insertions(+), 22 deletions(-) diff --git a/plugins/available/jenv.plugin.bash b/plugins/available/jenv.plugin.bash index 3cb2bcfc..08470688 100644 --- a/plugins/available/jenv.plugin.bash +++ b/plugins/available/jenv.plugin.bash @@ -4,6 +4,4 @@ about-plugin 'load jenv, if you are using it' export JENV_ROOT="$HOME/.jenv" pathmunge "$JENV_ROOT/bin" -if which jenv > /dev/null; then eval "$(jenv init -)"; fi - -[[ -e $JENV_ROOT/completions/jenv.bash ]] && source $JENV_ROOT/completions/jenv.bash +if which jenv > /dev/null; then eval "$(jenv init - bash)"; fi diff --git a/plugins/available/nodenv.plugin.bash b/plugins/available/nodenv.plugin.bash index f28e4045..1bbe7fbd 100644 --- a/plugins/available/nodenv.plugin.bash +++ b/plugins/available/nodenv.plugin.bash @@ -4,7 +4,4 @@ about-plugin 'load nodenv, if you are using it' export NODENV_ROOT="$HOME/.nodenv" pathmunge "$NODENV_ROOT/bin" -[[ `which nodenv` ]] && eval "$(nodenv init -)" - -# Load the auto-completion script if nodenv was loaded. -[[ -e $NODENV_ROOT/completions/nodenv.bash ]] && source $NODENV_ROOT/completions/nodenv.bash +[[ `which nodenv` ]] && eval "$(nodenv init - bash)" diff --git a/plugins/available/plenv.plugin.bash b/plugins/available/plenv.plugin.bash index 1e527b72..1da2d61b 100644 --- a/plugins/available/plenv.plugin.bash +++ b/plugins/available/plenv.plugin.bash @@ -4,18 +4,15 @@ 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" - + fi if [[ `which plenv` ]] ; then # init plenv - eval "$(plenv init -)" - - # Load the auto-completion script if it exists. - [[ -e "${HOME}/.plenv/completions/plenv.bash" ]] && source "${HOME}/.plenv/completions/plenv.bash" + eval "$(plenv init - bash)" fi diff --git a/plugins/available/pyenv.plugin.bash b/plugins/available/pyenv.plugin.bash index 0f6bffb8..dced31a8 100644 --- a/plugins/available/pyenv.plugin.bash +++ b/plugins/available/pyenv.plugin.bash @@ -4,12 +4,9 @@ about-plugin 'load pyenv, if you are using it' export PYENV_ROOT="$HOME/.pyenv" pathmunge "$PYENV_ROOT/bin" -[[ `which pyenv` ]] && eval "$(pyenv init -)" +[[ `which pyenv` ]] && eval "$(pyenv init - bash)" #Load pyenv virtualenv if the virtualenv plugin is installed. if pyenv virtualenv-init - &> /dev/null; then - eval "$(pyenv virtualenv-init -)" + eval "$(pyenv virtualenv-init - bash)" fi - -# Load the auto-completion script if pyenv was loaded. -[[ -e $PYENV_ROOT/completions/pyenv.bash ]] && source $PYENV_ROOT/completions/pyenv.bash diff --git a/plugins/available/rbenv.plugin.bash b/plugins/available/rbenv.plugin.bash index 75d24154..ecba0c89 100644 --- a/plugins/available/rbenv.plugin.bash +++ b/plugins/available/rbenv.plugin.bash @@ -4,7 +4,4 @@ about-plugin 'load rbenv, if you are using it' export RBENV_ROOT="$HOME/.rbenv" pathmunge "$RBENV_ROOT/bin" -[[ `which rbenv` ]] && eval "$(rbenv init -)" - -# Load the auto-completion script if rbenv was loaded. -[[ -e $RBENV_ROOT/completions/rbenv.bash ]] && source $RBENV_ROOT/completions/rbenv.bash +[[ `which rbenv` ]] && eval "$(rbenv init - bash)" From 1ba023c97a33c2ac87abb46ac75a9afdd585ba5b Mon Sep 17 00:00:00 2001 From: Christophe Aguettaz Date: Fri, 23 Nov 2018 22:25:14 +0100 Subject: [PATCH 52/77] [bugfix][wip] Fixed issue with Debian's bash-completion --- bash_it.sh | 10 +++++++++- lib/helpers.bash | 37 +++++++++++++++++++++---------------- 2 files changed, 30 insertions(+), 17 deletions(-) diff --git a/bash_it.sh b/bash_it.sh index e2b00de7..82b7e1b9 100755 --- a/bash_it.sh +++ b/bash_it.sh @@ -43,9 +43,17 @@ _load_global_bash_it_files # Load enabled aliases, completion, plugins for file_type in "aliases" "plugins" "completion" do - _load_bash_it_files $file_type + _bash_it_list_bash_it_files_return=() + _list_bash_it_files $file_type + + for config_file in "${_bash_it_list_bash_it_files_return[@]}" ; do + . "$config_file" + done done +unset _bash_it_list_bash_it_files_return +unset _bash_it_config_file + # Load theme, if a theme was set if [[ ! -z "${BASH_IT_THEME}" ]]; then # Load colors and helpers first so they can be used in base theme diff --git a/lib/helpers.bash b/lib/helpers.bash index 565173ed..bb592bab 100644 --- a/lib/helpers.bash +++ b/lib/helpers.bash @@ -14,16 +14,18 @@ function _command_exists () type "$1" &> /dev/null ; } -# Helper function loading various enable-able files -function _load_bash_it_files() { +# Helper function listing various enable-able files to be sourced +# The files need to be sourced in global scope to preserve scope of 'declare' +function _list_bash_it_files() { subdirectory="$1" if [ -d "${BASH_IT}/${subdirectory}/enabled" ] then FILES="${BASH_IT}/${subdirectory}/enabled/*.bash" - for config_file in $FILES + + for _bash_it_config_file in $FILES do - if [ -e "${config_file}" ]; then - source $config_file + if [ -e "${_bash_it_config_file}" ]; then + _bash_it_list_bash_it_files_return+=("$_bash_it_config_file") fi done fi @@ -43,20 +45,23 @@ function _load_global_bash_it_files() { fi } -# Function for reloading aliases -function reload_aliases() { - _load_bash_it_files "aliases" +function _make_reload_alias() { + printf %s '\ + _bash_it_list_bash_it_files_return=() ;\ + _list_bash_it_files '"$1"' ;\ + for _bash_it_config_file in "${_bash_it_list_bash_it_files_return[@]}"; do \ + . "$_bash_it_config_file" ;\ + done' } -# Function for reloading auto-completion -function reload_completion() { - _load_bash_it_files "completion" -} +# Alias for reloading aliases +alias reload_aliases="$(_make_reload_alias aliases)" -# Function for reloading plugins -function reload_plugins() { - _load_bash_it_files "plugins" -} +# Alias for reloading auto-completion +alias reload_completion="$(_make_reload_alias completion)" + +# Alias for reloading plugins +alias reload_plugins="$(_make_reload_alias plugins)" bash-it () { From 2f3d4bd1300960b47f44f4403e1cd390ed1cb2b1 Mon Sep 17 00:00:00 2001 From: Christophe Aguettaz Date: Fri, 23 Nov 2018 22:59:19 +0100 Subject: [PATCH 53/77] [cleanup] Added missing global variable cleanup --- lib/helpers.bash | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/helpers.bash b/lib/helpers.bash index bb592bab..9c3e53f7 100644 --- a/lib/helpers.bash +++ b/lib/helpers.bash @@ -51,7 +51,9 @@ function _make_reload_alias() { _list_bash_it_files '"$1"' ;\ for _bash_it_config_file in "${_bash_it_list_bash_it_files_return[@]}"; do \ . "$_bash_it_config_file" ;\ - done' + done ;\ + unset _bash_it_list_bash_it_files_return ;\ + unset _bash_it_config_file' } # Alias for reloading aliases From 6fcb32f85143d44236ce509012dab2982e7df564 Mon Sep 17 00:00:00 2001 From: Matthew Adams Date: Sat, 24 Nov 2018 08:44:46 -0600 Subject: [PATCH 54/77] rm d, dkalp & dkubu --- aliases/available/docker.aliases.bash | 3 --- 1 file changed, 3 deletions(-) diff --git a/aliases/available/docker.aliases.bash b/aliases/available/docker.aliases.bash index c002f17d..5606b619 100644 --- a/aliases/available/docker.aliases.bash +++ b/aliases/available/docker.aliases.bash @@ -1,7 +1,6 @@ cite 'about-alias' about-alias 'docker abbreviations' -alias d='docker' alias dk='docker' alias dklc='docker ps -l' # List last Docker container alias dklcid='docker ps -l -q' # List last Docker container ID @@ -30,8 +29,6 @@ alias dkelc='docker exec -it `dklcid` bash' # Enter last container (works with D alias dkex='docker exec -it ' # Useful to run any commands into container without leaving host alias dkri='docker run --rm -i ' alias dkrit='docker run --rm -it ' -alias dkalp='docker run --rm -it alpine' -alias dkubu='docker run --rm -it ubuntu' # Added more recent cleanup options from newer docker versions alias dkip='docker image prune -a -f' From bd0c1d92c508a1f6945f7822d0c36ee0ee2c78ef Mon Sep 17 00:00:00 2001 From: icanhazstring Date: Tue, 27 Nov 2018 12:07:40 +0100 Subject: [PATCH 55/77] Add support for composer aliases --- aliases/available/composer.aliases.bash | 40 +++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 aliases/available/composer.aliases.bash diff --git a/aliases/available/composer.aliases.bash b/aliases/available/composer.aliases.bash new file mode 100644 index 00000000..4820d017 --- /dev/null +++ b/aliases/available/composer.aliases.bash @@ -0,0 +1,40 @@ +cite 'about-alias' +about-alias 'common composer abbreviations' + +# Aliases +alias cab='composer about' +alias car='composer archive' +alias cb='composer browser' +alias ccpq='composer check-platform-reqs' +alias ccc='composer clear-cache' +alias cconf='composer config' +alias ccp='composer create-project' +alias cdep='composer depends' +alias cdiag='composer diagnose' +alias cdump='composer dump-autoload' +alias cdumpo='composer dump-autoload -o' +alias cex='composer exec' +alias cglob='composer global' +alias ch='composer help' +alias chome='composer home' +alias ci='composer install' +alias cinfo='composer info' +alias cinit='composer init' +alias clic='composer license' +alias clist='composer list' +alias cout='composer outdated' +alias cp='composer prohibits' +alias crem='composer remove' +alias creq='composer require' +alias creqd='composer require --dev' +alias crs='composer run-script' +alias cs='composer search' +alias csu='composer self-update' +alias cshow='composer show' +alias cstat='composer status' +alias csugg='composer suggest' +alias cupd='composer update' +alias cupg='composer upgrade' +alias cval='composer validate' +alias cwhy='composer why' +alias cwhyn='composer why-not' From dbe4cc690f5906f18dca636fe19d96fe6bad60f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20Fr=C3=B6mer?= Date: Wed, 28 Nov 2018 10:40:56 +0100 Subject: [PATCH 56/77] Change default prefix to 'co' Should resolve problem with accidental overriding global default commands like `cp` --- aliases/available/composer.aliases.bash | 71 ++++++++++++------------- 1 file changed, 35 insertions(+), 36 deletions(-) diff --git a/aliases/available/composer.aliases.bash b/aliases/available/composer.aliases.bash index 4820d017..5ccb2e24 100644 --- a/aliases/available/composer.aliases.bash +++ b/aliases/available/composer.aliases.bash @@ -2,39 +2,38 @@ cite 'about-alias' about-alias 'common composer abbreviations' # Aliases -alias cab='composer about' -alias car='composer archive' -alias cb='composer browser' -alias ccpq='composer check-platform-reqs' -alias ccc='composer clear-cache' -alias cconf='composer config' -alias ccp='composer create-project' -alias cdep='composer depends' -alias cdiag='composer diagnose' -alias cdump='composer dump-autoload' -alias cdumpo='composer dump-autoload -o' -alias cex='composer exec' -alias cglob='composer global' -alias ch='composer help' -alias chome='composer home' -alias ci='composer install' -alias cinfo='composer info' -alias cinit='composer init' -alias clic='composer license' -alias clist='composer list' -alias cout='composer outdated' -alias cp='composer prohibits' -alias crem='composer remove' -alias creq='composer require' -alias creqd='composer require --dev' -alias crs='composer run-script' -alias cs='composer search' -alias csu='composer self-update' -alias cshow='composer show' -alias cstat='composer status' -alias csugg='composer suggest' -alias cupd='composer update' -alias cupg='composer upgrade' -alias cval='composer validate' -alias cwhy='composer why' -alias cwhyn='composer why-not' +alias coab='composer about' +alias coar='composer archive' +alias cob='composer browser' +alias cocpr='composer check-platform-reqs' +alias cocc='composer clear-cache' +alias cocfg='composer config' +alias cocp='composer create-project' +alias codp='composer depends' +alias codiag='composer diagnose' +alias codmp='composer dump-autoload' +alias coex='composer exec' +alias coglob='composer global' +alias coh='composer help' +alias cohome='composer home' +alias coi='composer install' +alias coinf='composer info' +alias coini='composer init' +alias coli='composer license' +alias colis='composer list' +alias coout='composer outdated' +alias cop='composer prohibits' +alias corem='composer remove' +alias coreq='composer require' +alias coreqd='composer require --dev' +alias cors='composer run-script' +alias cos='composer search' +alias cosu='composer self-update' +alias coshow='composer show' +alias costat='composer status' +alias cosugg='composer suggest' +alias coup='composer update' +alias coupg='composer upgrade' +alias coval='composer validate' +alias cowhy='composer why' +alias cowhyn='composer why-not' From 8e7a566d96e59440dfc06f7568fbc9a0e1374567 Mon Sep 17 00:00:00 2001 From: Travis Swicegood Date: Sun, 2 Dec 2018 10:16:33 -0600 Subject: [PATCH 57/77] Show update prompt when running bash-it update This utilizes the body of the merged PR requests to show the commits that are included in this update. It gives the user a chance to decline the upgrades by pressing n or N. --- lib/helpers.bash | 37 +++++++++++++++++++++++++------------ 1 file changed, 25 insertions(+), 12 deletions(-) diff --git a/lib/helpers.bash b/lib/helpers.bash index 565173ed..5652a2b8 100644 --- a/lib/helpers.bash +++ b/lib/helpers.bash @@ -181,18 +181,31 @@ _bash-it_update() { status="$(git rev-list master..${BASH_IT_REMOTE}/master 2> /dev/null)" if [[ -n "${status}" ]]; then - git pull --rebase &> /dev/null - if [[ $? -eq 0 ]]; then - echo "Bash-it successfully updated." - echo "" - echo "Migrating your installation to the latest version now..." - _bash-it-migrate - echo "" - echo "All done, enjoy!" - bash-it reload - else - echo "Error updating Bash-it, please, check if your Bash-it installation folder (${BASH_IT}) is clean." - fi + git log --merges --format="%h: %b (%an)" master..${BASH_IT_REMOTE}/master + echo "" + read -e -n 1 -p "Would you like to update to $(git log -1 --format=%h origin/master)? [Y/n] " RESP + case $RESP in + [yY]|"") + git pull --rebase &> /dev/null + if [[ $? -eq 0 ]]; then + echo "Bash-it successfully updated." + echo "" + echo "Migrating your installation to the latest version now..." + _bash-it-migrate + echo "" + echo "All done, enjoy!" + bash-it reload + else + echo "Error updating Bash-it, please, check if your Bash-it installation folder (${BASH_IT}) is clean." + fi + ;; + [nN]) + echo "Not upgrading…" + ;; + *) + echo -e "\033[91mPlease choose y or n.\033[m" + ;; + esac else echo "Bash-it is up to date, nothing to do!" fi From 185c2879d56637babc4aae2eba8a20ecb9977752 Mon Sep 17 00:00:00 2001 From: Travis Swicegood Date: Sun, 2 Dec 2018 10:47:37 -0600 Subject: [PATCH 58/77] Update to show the subject if the body is empty --- lib/helpers.bash | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/helpers.bash b/lib/helpers.bash index 5652a2b8..4cc2d574 100644 --- a/lib/helpers.bash +++ b/lib/helpers.bash @@ -181,7 +181,16 @@ _bash-it_update() { status="$(git rev-list master..${BASH_IT_REMOTE}/master 2> /dev/null)" if [[ -n "${status}" ]]; then - git log --merges --format="%h: %b (%an)" master..${BASH_IT_REMOTE}/master + + for i in $(git rev-list --merges master..${BASH_IT_REMOTE}); do + num_of_lines=$(git log -1 --format=%B $i | awk 'NF' | wc -l) + if [ $num_of_lines -eq 1 ]; then + description="%s" + else + description="%b" + fi + git log --format="%h: $description (%an)" -1 $i + done echo "" read -e -n 1 -p "Would you like to update to $(git log -1 --format=%h origin/master)? [Y/n] " RESP case $RESP in From 6706814dbc36d9974e497d382a1bf57297235364 Mon Sep 17 00:00:00 2001 From: Travis Swicegood Date: Sun, 2 Dec 2018 20:44:00 -0600 Subject: [PATCH 59/77] Adjust so this only runs when Homebrew is installed (thanks @nwinkler) --- completion/available/crystal.completion.bash | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/completion/available/crystal.completion.bash b/completion/available/crystal.completion.bash index b83be253..cbc891d7 100644 --- a/completion/available/crystal.completion.bash +++ b/completion/available/crystal.completion.bash @@ -1,8 +1,11 @@ if which crystal >/dev/null 2>&1; then - BREW_PREFIX=$(brew --prefix) - if [ -f "$BREW_PREFIX"/etc/bash_completion.d/crystal ]; then - . "$BREW_PREFIX"/etc/bash_completion.d/crystal + if which brew >/dev/null 2>&1; then + BREW_PREFIX=$(brew --prefix) + + if [ -f "$BREW_PREFIX"/etc/bash_completion.d/crystal ]; then + . "$BREW_PREFIX"/etc/bash_completion.d/crystal + fi fi fi From babb1e667544281093bd292c186f0abcccd30b45 Mon Sep 17 00:00:00 2001 From: Travis Swicegood Date: Mon, 3 Dec 2018 21:17:49 -0600 Subject: [PATCH 60/77] Adjust to only show merges into master Adding `--first-parent` ensures that only commits from the master branch are used when showing the history. I've verified this change directly by comparing the `rev-list` output for `703105c..97df5c45`: ```console $ git rev-list --merges 703105c...97df5c4 97df5c4540534c57da2381b1675cd2461274b2a6 b5976ada25a351ee603fa6a2c4aee99d56f0cabe $ git rev-list --merges --first-parent 703105c...97df5c4 97df5c4540534c57da2381b1675cd2461274b2a6 ``` Note: I've created this branch from 703105c so that I can merge `master` into it and test `bash-it update` once merged. --- lib/helpers.bash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/helpers.bash b/lib/helpers.bash index 4cc2d574..b5172d02 100644 --- a/lib/helpers.bash +++ b/lib/helpers.bash @@ -182,7 +182,7 @@ _bash-it_update() { if [[ -n "${status}" ]]; then - for i in $(git rev-list --merges master..${BASH_IT_REMOTE}); do + for i in $(git rev-list --merges --first-parent master..${BASH_IT_REMOTE}); do num_of_lines=$(git log -1 --format=%B $i | awk 'NF' | wc -l) if [ $num_of_lines -eq 1 ]; then description="%s" From f06439edc354d354eb3c2573008b8e7d206e8cde Mon Sep 17 00:00:00 2001 From: caguettaz Date: Tue, 4 Dec 2018 14:30:11 +0100 Subject: [PATCH 61/77] [cleanup] Harmonized variable names, added support for global config files --- bash_it.sh | 29 +++++++++++++---------------- lib/helpers.bash | 46 +++++++++++++++++++++++++++++----------------- 2 files changed, 42 insertions(+), 33 deletions(-) diff --git a/bash_it.sh b/bash_it.sh index 82b7e1b9..1d34b407 100755 --- a/bash_it.sh +++ b/bash_it.sh @@ -29,31 +29,28 @@ cite _about _param _example _group _author _version # libraries, but skip appearance (themes) for now LIB="${BASH_IT}/lib/*.bash" APPEARANCE_LIB="${BASH_IT}/lib/appearance.bash" -for config_file in $LIB +for _bash_it_config_file in $LIB do - if [ "$config_file" != "$APPEARANCE_LIB" ]; then + if [ "$_bash_it_config_file" != "$APPEARANCE_LIB" ]; then # shellcheck disable=SC1090 - source "$config_file" + source "$_bash_it_config_file" fi done # Load the global "enabled" directory -_load_global_bash_it_files +# "family" param is empty so that files get sources in glob order +for _bash_it_config_file in $(_list_global_bash_it_files "") ; do + . "${BASH_IT}/$_bash_it_config_file" +done # Load enabled aliases, completion, plugins for file_type in "aliases" "plugins" "completion" do - _bash_it_list_bash_it_files_return=() - _list_bash_it_files $file_type - - for config_file in "${_bash_it_list_bash_it_files_return[@]}" ; do - . "$config_file" + for _bash_it_config_file in $(_list_bash_it_files "$file_type") ; do + . "${BASH_IT}/$_bash_it_config_file" done done -unset _bash_it_list_bash_it_files_return -unset _bash_it_config_file - # Load theme, if a theme was set if [[ ! -z "${BASH_IT_THEME}" ]]; then # Load colors and helpers first so they can be used in base theme @@ -83,15 +80,15 @@ done # Custom CUSTOM="${BASH_IT_CUSTOM:=${BASH_IT}/custom}/*.bash ${BASH_IT_CUSTOM:=${BASH_IT}/custom}/**/*.bash" -for config_file in $CUSTOM +for _bash_it_config_file in $CUSTOM do - if [ -e "${config_file}" ]; then + if [ -e "${_bash_it_config_file}" ]; then # shellcheck disable=SC1090 - source "$config_file" + source "$_bash_it_config_file" fi done -unset config_file +unset _bash_it_config_file if [[ $PROMPT ]]; then export PS1="\[""$PROMPT""\]" fi diff --git a/lib/helpers.bash b/lib/helpers.bash index 9c3e53f7..3474aece 100644 --- a/lib/helpers.bash +++ b/lib/helpers.bash @@ -17,42 +17,54 @@ function _command_exists () # Helper function listing various enable-able files to be sourced # The files need to be sourced in global scope to preserve scope of 'declare' function _list_bash_it_files() { - subdirectory="$1" - if [ -d "${BASH_IT}/${subdirectory}/enabled" ] + local subdirectory="$1" + pushd "${BASH_IT}" >/dev/null + + if [ -d "./${subdirectory}/enabled" ] then - FILES="${BASH_IT}/${subdirectory}/enabled/*.bash" + local FILES="./${subdirectory}/enabled/*.bash" + local _bash_it_config_file for _bash_it_config_file in $FILES do if [ -e "${_bash_it_config_file}" ]; then - _bash_it_list_bash_it_files_return+=("$_bash_it_config_file") + printf "$_bash_it_config_file\n" fi done fi + + popd >/dev/null } -function _load_global_bash_it_files() { +function _list_global_bash_it_files() { + local family="$1" + pushd "${BASH_IT}" >/dev/null + # In the new structure - if [ -d "${BASH_IT}/enabled" ] + if [ -d "./enabled" ] then - FILES="${BASH_IT}/enabled/*.bash" - for config_file in $FILES + local FILES="./enabled/*$family.bash" + local _bash_it_config_file + + for _bash_it_config_file in $FILES do - if [ -e "${config_file}" ]; then - source $config_file + if [ -e "${_bash_it_config_file}" ]; then + printf "$_bash_it_config_file\n" fi done fi } function _make_reload_alias() { - printf %s '\ - _bash_it_list_bash_it_files_return=() ;\ - _list_bash_it_files '"$1"' ;\ - for _bash_it_config_file in "${_bash_it_list_bash_it_files_return[@]}"; do \ - . "$_bash_it_config_file" ;\ - done ;\ - unset _bash_it_list_bash_it_files_return ;\ + printf %s ' + + for _bash_it_config_file in $(_list_global_bash_it_files '"$1"'); do \ + . "${BASH_IT}/$_bash_it_config_file" ; + done ; + + for _bash_it_config_file in $(_list_bash_it_files '"$1"'); do + . "${BASH_IT}/$_bash_it_config_file" ; + done ; unset _bash_it_config_file' } From 87d74c31d8c2ee09f05384993846ec1eccd56cec Mon Sep 17 00:00:00 2001 From: Travis Swicegood Date: Tue, 4 Dec 2018 07:49:32 -0600 Subject: [PATCH 62/77] Tweak the language around force pushes --- CONTRIBUTING.md | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 04451473..e62b2c47 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -19,9 +19,13 @@ Most of this is common sense, but please try to stick to the conventions listed Create a _Pull Request_ from your feature branch against Bash-it's _master_ branch. * Limit each Pull Request to one feature. Don't bundle multiple features/changes (e.g. a new _Theme_ and a fix to an existing plugin) into a single Pull Request - create one PR for the theme, and a separate PR for the fix. -* For complex changes, try to _squash_ your changes into a single commit. - Don't create a PR consisting of 20 commits that show your work in progress. - Before you create the PR, _squash_ your changes into a single commit. +* For complex changes, try to _squash_ your changes into a single commit before + pushing code. Once you've pushed your code and opened a PR, please refrain + from force-pushing changes to the PR branch – remember, bash-it is a + distributed project and your branch may be in use already. +* When in doubt, open a PR with too many commits. Bash-it is a learning project + for everyone involved. Showing your work provides a great history for folks + to learn what works and what didn't. ## Code Style From e198d8dc3da11ee5f3aed1ee1bcdf5390478f003 Mon Sep 17 00:00:00 2001 From: caguettaz Date: Tue, 4 Dec 2018 14:58:13 +0100 Subject: [PATCH 63/77] [bugfix] Fixed config family names for reload aliases --- lib/helpers.bash | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/lib/helpers.bash b/lib/helpers.bash index 3474aece..a6e4a6f1 100644 --- a/lib/helpers.bash +++ b/lib/helpers.bash @@ -56,26 +56,28 @@ function _list_global_bash_it_files() { } function _make_reload_alias() { - printf %s ' + local global_family="$1" + local subdirectory="$2" - for _bash_it_config_file in $(_list_global_bash_it_files '"$1"'); do \ + printf %s ' + for _bash_it_config_file in $(_list_global_bash_it_files '"$global_family"'); do \ . "${BASH_IT}/$_bash_it_config_file" ; done ; - for _bash_it_config_file in $(_list_bash_it_files '"$1"'); do + for _bash_it_config_file in $(_list_bash_it_files '"$subdirectory"'); do . "${BASH_IT}/$_bash_it_config_file" ; done ; unset _bash_it_config_file' } # Alias for reloading aliases -alias reload_aliases="$(_make_reload_alias aliases)" +alias reload_aliases="$(_make_reload_alias alias aliases)" # Alias for reloading auto-completion -alias reload_completion="$(_make_reload_alias completion)" +alias reload_completion="$(_make_reload_alias completion completion)" # Alias for reloading plugins -alias reload_plugins="$(_make_reload_alias plugins)" +alias reload_plugins="$(_make_reload_alias plugin plugins)" bash-it () { From a1bbecc4a5d48b92346fb16b5c248b703576f06d Mon Sep 17 00:00:00 2001 From: caguettaz Date: Tue, 4 Dec 2018 15:58:21 +0100 Subject: [PATCH 64/77] [bugfix] Fixed reload aliases --- lib/helpers.bash | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/lib/helpers.bash b/lib/helpers.bash index a6e4a6f1..38cc3ad8 100644 --- a/lib/helpers.bash +++ b/lib/helpers.bash @@ -53,6 +53,8 @@ function _list_global_bash_it_files() { fi done fi + + popd >/dev/null } function _make_reload_alias() { @@ -61,12 +63,13 @@ function _make_reload_alias() { printf %s ' for _bash_it_config_file in $(_list_global_bash_it_files '"$global_family"'); do \ - . "${BASH_IT}/$_bash_it_config_file" ; - done ; - - for _bash_it_config_file in $(_list_bash_it_files '"$subdirectory"'); do - . "${BASH_IT}/$_bash_it_config_file" ; - done ; + . "${BASH_IT}/$_bash_it_config_file" ;\ + done ;\ + \ + for _bash_it_config_file in $(_list_bash_it_files '"$subdirectory"'); do \ + . "${BASH_IT}/$_bash_it_config_file" ;\ + done ;\ + \ unset _bash_it_config_file' } From 13b6f3d870830aaeec8d2506d697484c1aaf446d Mon Sep 17 00:00:00 2001 From: caguettaz Date: Tue, 4 Dec 2018 16:31:03 +0100 Subject: [PATCH 65/77] [cleanup] Cleaned escaped newlines for alias reload --- lib/helpers.bash | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/lib/helpers.bash b/lib/helpers.bash index 38cc3ad8..beba262a 100644 --- a/lib/helpers.bash +++ b/lib/helpers.bash @@ -62,14 +62,12 @@ function _make_reload_alias() { local subdirectory="$2" printf %s ' - for _bash_it_config_file in $(_list_global_bash_it_files '"$global_family"'); do \ - . "${BASH_IT}/$_bash_it_config_file" ;\ + for _bash_it_config_file in $(_list_global_bash_it_files '"$global_family"'); do + . "${BASH_IT}/$_bash_it_config_file" done ;\ - \ - for _bash_it_config_file in $(_list_bash_it_files '"$subdirectory"'); do \ - . "${BASH_IT}/$_bash_it_config_file" ;\ + for _bash_it_config_file in $(_list_bash_it_files '"$subdirectory"'); do + . "${BASH_IT}/$_bash_it_config_file" done ;\ - \ unset _bash_it_config_file' } From e5b68695c0e77403e9ceda6e2707c1be326da81b Mon Sep 17 00:00:00 2001 From: Travis Swicegood Date: Tue, 4 Dec 2018 22:02:10 -0600 Subject: [PATCH 66/77] Attempt to simplify by not using aliases --- bash_it.sh | 8 ++------ lib/helpers.bash | 33 +-------------------------------- scripts/reloader.bash | 30 ++++++++++++++++++++++++++++++ 3 files changed, 33 insertions(+), 38 deletions(-) create mode 100644 scripts/reloader.bash diff --git a/bash_it.sh b/bash_it.sh index 1d34b407..8d26bc55 100755 --- a/bash_it.sh +++ b/bash_it.sh @@ -39,16 +39,12 @@ done # Load the global "enabled" directory # "family" param is empty so that files get sources in glob order -for _bash_it_config_file in $(_list_global_bash_it_files "") ; do - . "${BASH_IT}/$_bash_it_config_file" -done +source "${BASH_IT}/scripts/reloader.bash" # Load enabled aliases, completion, plugins for file_type in "aliases" "plugins" "completion" do - for _bash_it_config_file in $(_list_bash_it_files "$file_type") ; do - . "${BASH_IT}/$_bash_it_config_file" - done + source "${BASH_IT}/scripts/reloader.bash" "false" "$file_type" done # Load theme, if a theme was set diff --git a/lib/helpers.bash b/lib/helpers.bash index beba262a..fb5d9cc7 100644 --- a/lib/helpers.bash +++ b/lib/helpers.bash @@ -36,39 +36,8 @@ function _list_bash_it_files() { popd >/dev/null } -function _list_global_bash_it_files() { - local family="$1" - pushd "${BASH_IT}" >/dev/null - - # In the new structure - if [ -d "./enabled" ] - then - local FILES="./enabled/*$family.bash" - local _bash_it_config_file - - for _bash_it_config_file in $FILES - do - if [ -e "${_bash_it_config_file}" ]; then - printf "$_bash_it_config_file\n" - fi - done - fi - - popd >/dev/null -} - function _make_reload_alias() { - local global_family="$1" - local subdirectory="$2" - - printf %s ' - for _bash_it_config_file in $(_list_global_bash_it_files '"$global_family"'); do - . "${BASH_IT}/$_bash_it_config_file" - done ;\ - for _bash_it_config_file in $(_list_bash_it_files '"$subdirectory"'); do - . "${BASH_IT}/$_bash_it_config_file" - done ;\ - unset _bash_it_config_file' + echo "source \${BASH_IT}/scripts/reloader.bash ${1} ${2}" } # Alias for reloading aliases diff --git a/scripts/reloader.bash b/scripts/reloader.bash new file mode 100644 index 00000000..b208a98c --- /dev/null +++ b/scripts/reloader.bash @@ -0,0 +1,30 @@ +#!/bin/bash +pushd "${BASH_IT}" >/dev/null + +# TODO: Add debugging output + +if [ "$1" != "false" ] && [ -d "./enabled" ]; then + for _bash_it_config_file in $(ls ./enabled/*${1}.bash 2>/dev/null); do + if [ -e "${_bash_it_config_file}" ]; then + source $_bash_it_config_file + else + echo "Unable to read ${_bash_it_config_file}" > /dev/stderr + fi + done +fi + + +if [ ! -z "${2}" ] && [ -d "${2}/enabled" ]; then + # TODO: We should warn users they're using legacy enabling + for _bash_it_config_file in $(ls ./${2}/enabled/*.bash 2>/dev/null); do + if [ -e "$_bash_it_config_file" ]; then + source "$_bash_it_config_file" + else + # TODO Display an error? + echo "Unable to locate ${_bash_it_config_file}" > /dev/null + fi + done +fi + +unset _bash_it_config_file +popd >/dev/null From 3a7889e05b84dcb3686e57ff2f993de484990490 Mon Sep 17 00:00:00 2001 From: Nils Winkler Date: Wed, 5 Dec 2018 08:37:13 +0100 Subject: [PATCH 67/77] Update CONTRIBUTING.md Fixed capitalization of Bash-it. --- CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index e62b2c47..8c251c6c 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -21,7 +21,7 @@ Most of this is common sense, but please try to stick to the conventions listed Don't bundle multiple features/changes (e.g. a new _Theme_ and a fix to an existing plugin) into a single Pull Request - create one PR for the theme, and a separate PR for the fix. * For complex changes, try to _squash_ your changes into a single commit before pushing code. Once you've pushed your code and opened a PR, please refrain - from force-pushing changes to the PR branch – remember, bash-it is a + from force-pushing changes to the PR branch – remember, Bash-it is a distributed project and your branch may be in use already. * When in doubt, open a PR with too many commits. Bash-it is a learning project for everyone involved. Showing your work provides a great history for folks From 286e69591046d4a0395ebbf239e6c5aeb2c49500 Mon Sep 17 00:00:00 2001 From: Travis Swicegood Date: Wed, 5 Dec 2018 20:59:37 -0600 Subject: [PATCH 68/77] Ensure that shellcheck can find these files (SC1090) --- bash_it.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/bash_it.sh b/bash_it.sh index 8d26bc55..1b092cc9 100755 --- a/bash_it.sh +++ b/bash_it.sh @@ -39,11 +39,13 @@ done # Load the global "enabled" directory # "family" param is empty so that files get sources in glob order +# shellcheck source=./scripts/reloader.bash source "${BASH_IT}/scripts/reloader.bash" # Load enabled aliases, completion, plugins for file_type in "aliases" "plugins" "completion" do + # shellcheck source=./scripts/reloader.bash source "${BASH_IT}/scripts/reloader.bash" "false" "$file_type" done From 61380e686f33482a42776202dbef67b768393e19 Mon Sep 17 00:00:00 2001 From: Travis Swicegood Date: Wed, 5 Dec 2018 21:00:01 -0600 Subject: [PATCH 69/77] Remove unused function --- lib/helpers.bash | 22 ---------------------- 1 file changed, 22 deletions(-) diff --git a/lib/helpers.bash b/lib/helpers.bash index fb5d9cc7..ed229b3a 100644 --- a/lib/helpers.bash +++ b/lib/helpers.bash @@ -14,28 +14,6 @@ function _command_exists () type "$1" &> /dev/null ; } -# Helper function listing various enable-able files to be sourced -# The files need to be sourced in global scope to preserve scope of 'declare' -function _list_bash_it_files() { - local subdirectory="$1" - pushd "${BASH_IT}" >/dev/null - - if [ -d "./${subdirectory}/enabled" ] - then - local FILES="./${subdirectory}/enabled/*.bash" - local _bash_it_config_file - - for _bash_it_config_file in $FILES - do - if [ -e "${_bash_it_config_file}" ]; then - printf "$_bash_it_config_file\n" - fi - done - fi - - popd >/dev/null -} - function _make_reload_alias() { echo "source \${BASH_IT}/scripts/reloader.bash ${1} ${2}" } From 0793eb41a716ccb42ec0b23287394715a2430375 Mon Sep 17 00:00:00 2001 From: Travis Swicegood Date: Wed, 5 Dec 2018 21:00:41 -0600 Subject: [PATCH 70/77] =?UTF-8?q?Ignore=20SC2139=20=E2=80=93=20it's=20ok?= =?UTF-8?q?=20that=20these=20are=20expanded=20when=20evaluated?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/helpers.bash | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/helpers.bash b/lib/helpers.bash index ed229b3a..d71120b8 100644 --- a/lib/helpers.bash +++ b/lib/helpers.bash @@ -19,12 +19,15 @@ function _make_reload_alias() { } # Alias for reloading aliases +# shellcheck disable=SC2139 alias reload_aliases="$(_make_reload_alias alias aliases)" # Alias for reloading auto-completion +# shellcheck disable=SC2139 alias reload_completion="$(_make_reload_alias completion completion)" # Alias for reloading plugins +# shellcheck disable=SC2139 alias reload_plugins="$(_make_reload_alias plugin plugins)" bash-it () From 992b87b816c57e6ac2ea195d18cb1ba6888b5552 Mon Sep 17 00:00:00 2001 From: Travis Swicegood Date: Wed, 5 Dec 2018 21:00:59 -0600 Subject: [PATCH 71/77] Shellcheck clean up based on comments from @nwinkler --- scripts/reloader.bash | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/scripts/reloader.bash b/scripts/reloader.bash index b208a98c..cac77a21 100644 --- a/scripts/reloader.bash +++ b/scripts/reloader.bash @@ -1,11 +1,12 @@ #!/bin/bash -pushd "${BASH_IT}" >/dev/null +pushd "${BASH_IT}" >/dev/null || exit 1 # TODO: Add debugging output if [ "$1" != "false" ] && [ -d "./enabled" ]; then - for _bash_it_config_file in $(ls ./enabled/*${1}.bash 2>/dev/null); do + for _bash_it_config_file in $(sort <(compgen -G "./enabled/*${1}.bash")); do if [ -e "${_bash_it_config_file}" ]; then + # shellcheck source=/dev/null source $_bash_it_config_file else echo "Unable to read ${_bash_it_config_file}" > /dev/stderr @@ -16,8 +17,9 @@ fi if [ ! -z "${2}" ] && [ -d "${2}/enabled" ]; then # TODO: We should warn users they're using legacy enabling - for _bash_it_config_file in $(ls ./${2}/enabled/*.bash 2>/dev/null); do + for _bash_it_config_file in $(sort <(compgen -G "./${2}/enabled/*.bash")); do if [ -e "$_bash_it_config_file" ]; then + # shellcheck source=/dev/null source "$_bash_it_config_file" else # TODO Display an error? @@ -27,4 +29,4 @@ if [ ! -z "${2}" ] && [ -d "${2}/enabled" ]; then fi unset _bash_it_config_file -popd >/dev/null +popd >/dev/null || exit 1 From c76263dc47b008600602228c374d7ccb90e8cacd Mon Sep 17 00:00:00 2001 From: Travis Swicegood Date: Wed, 5 Dec 2018 21:04:55 -0600 Subject: [PATCH 72/77] Ensure this debugging output is generated (oops) --- scripts/reloader.bash | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/scripts/reloader.bash b/scripts/reloader.bash index cac77a21..66236042 100644 --- a/scripts/reloader.bash +++ b/scripts/reloader.bash @@ -22,8 +22,7 @@ if [ ! -z "${2}" ] && [ -d "${2}/enabled" ]; then # shellcheck source=/dev/null source "$_bash_it_config_file" else - # TODO Display an error? - echo "Unable to locate ${_bash_it_config_file}" > /dev/null + echo "Unable to locate ${_bash_it_config_file}" > /dev/stderr fi done fi From 5b8f8d874e21feb8323e6fc1c919edcafc2a8468 Mon Sep 17 00:00:00 2001 From: Travis Swicegood Date: Wed, 5 Dec 2018 21:53:39 -0600 Subject: [PATCH 73/77] Default to loading everything The tests are failing because $1 is being passed through from the initial loading. When this loads in the shell, $1 is empty though so the code works-for-me, but just not the tests. This filters the $1 input to ensure its one of the valid types expected inside the ./enabled directory. --- scripts/reloader.bash | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/scripts/reloader.bash b/scripts/reloader.bash index 66236042..e5cf178f 100644 --- a/scripts/reloader.bash +++ b/scripts/reloader.bash @@ -4,7 +4,11 @@ pushd "${BASH_IT}" >/dev/null || exit 1 # TODO: Add debugging output if [ "$1" != "false" ] && [ -d "./enabled" ]; then - for _bash_it_config_file in $(sort <(compgen -G "./enabled/*${1}.bash")); do + _bash_it_config_type="" + if [[ "${1}" =~ ^(alias|completion|plugin)$ ]]; then + _bash_it_config_type=$1 + fi + for _bash_it_config_file in $(sort <(compgen -G "./enabled/*${_bash_it_config_type}.bash")); do if [ -e "${_bash_it_config_file}" ]; then # shellcheck source=/dev/null source $_bash_it_config_file @@ -28,4 +32,5 @@ if [ ! -z "${2}" ] && [ -d "${2}/enabled" ]; then fi unset _bash_it_config_file +unset _bash_it_config_type popd >/dev/null || exit 1 From 7b32dd64241599200a67c38ba1241d926c555be7 Mon Sep 17 00:00:00 2001 From: Travis Swicegood Date: Wed, 5 Dec 2018 21:54:59 -0600 Subject: [PATCH 74/77] Add filtering to the $2 input in addition to $1 --- scripts/reloader.bash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/reloader.bash b/scripts/reloader.bash index e5cf178f..c26d3626 100644 --- a/scripts/reloader.bash +++ b/scripts/reloader.bash @@ -19,7 +19,7 @@ if [ "$1" != "false" ] && [ -d "./enabled" ]; then fi -if [ ! -z "${2}" ] && [ -d "${2}/enabled" ]; then +if [ ! -z "${2}" ] && [[ "${2}" =~ ^(aliases|completion|plugins)$ ]] && [ -d "${2}/enabled" ]; then # TODO: We should warn users they're using legacy enabling for _bash_it_config_file in $(sort <(compgen -G "./${2}/enabled/*.bash")); do if [ -e "$_bash_it_config_file" ]; then From 2d6085b033be1af89526a6c46c47d0dfc853051f Mon Sep 17 00:00:00 2001 From: Travis Swicegood Date: Wed, 5 Dec 2018 21:58:13 -0600 Subject: [PATCH 75/77] =?UTF-8?q?Switch=20from=20false=20to=20skip=20?= =?UTF-8?q?=E2=80=93=20I=20think=20that's=20more=20clear?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bash_it.sh | 2 +- scripts/reloader.bash | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bash_it.sh b/bash_it.sh index 1b092cc9..ab911019 100755 --- a/bash_it.sh +++ b/bash_it.sh @@ -46,7 +46,7 @@ source "${BASH_IT}/scripts/reloader.bash" for file_type in "aliases" "plugins" "completion" do # shellcheck source=./scripts/reloader.bash - source "${BASH_IT}/scripts/reloader.bash" "false" "$file_type" + source "${BASH_IT}/scripts/reloader.bash" "skip" "$file_type" done # Load theme, if a theme was set diff --git a/scripts/reloader.bash b/scripts/reloader.bash index c26d3626..b0fe7e41 100644 --- a/scripts/reloader.bash +++ b/scripts/reloader.bash @@ -3,7 +3,7 @@ pushd "${BASH_IT}" >/dev/null || exit 1 # TODO: Add debugging output -if [ "$1" != "false" ] && [ -d "./enabled" ]; then +if [ "$1" != "skip" ] && [ -d "./enabled" ]; then _bash_it_config_type="" if [[ "${1}" =~ ^(alias|completion|plugin)$ ]]; then _bash_it_config_type=$1 From 3645305644ff62f217c3a68713adba3dcddd3e45 Mon Sep 17 00:00:00 2001 From: cornfeedhobo Date: Thu, 6 Dec 2018 17:07:03 -0500 Subject: [PATCH 76/77] add go plugin tests and update list reversal logic --- plugins/available/go.plugin.bash | 11 ++++++++-- test/plugins/go.plugin.bats | 37 ++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+), 2 deletions(-) create mode 100644 test/plugins/go.plugin.bats diff --git a/plugins/available/go.plugin.bash b/plugins/available/go.plugin.bash index 819ebc3a..910194e5 100755 --- a/plugins/available/go.plugin.bash +++ b/plugins/available/go.plugin.bash @@ -6,9 +6,16 @@ about-plugin 'go environment variables & path configuration' [ ! command -v go &>/dev/null ] && return function _split_path_reverse() { + local a=( ${@//:/ } ) + local i=${#a[@]} local r= - for p in ${@//:/ } ; do - r="$p $r" + while [ $i -gt 0 ] ; do + i=$(( i - 1 )) + if [ $(( i + 1 )) -eq ${#a[@]} ] ; then + r="${a[i]}" + else + r="${r} ${a[i]}" + fi done echo "$r" } diff --git a/test/plugins/go.plugin.bats b/test/plugins/go.plugin.bats new file mode 100644 index 00000000..0cc257ed --- /dev/null +++ b/test/plugins/go.plugin.bats @@ -0,0 +1,37 @@ +#!/usr/bin/env bats + +#load ../test_helper +load ../../lib/helpers +load ../../lib/composure +load ../../plugins/available/go.plugin + +@test 'plugins go: reverse path: single entry' { + run _split_path_reverse '/foo' + echo "output = ${output}" + [ "$output" = "/foo" ] +} + +@test 'plugins go: reverse path: single entry, colon empty' { + run _split_path_reverse '/foo:' + echo "output = ${output}" + [ "$output" = "/foo" ] +} + +@test 'plugins go: reverse path: single entry, colon whitespace' { + run _split_path_reverse '/foo: ' + echo "output = ${output}" + [ "$output" = "/foo" ] +} + +@test 'plugins go: reverse path: multiple entries' { + run _split_path_reverse '/foo:/bar' + echo "output = ${output}" + [ "$output" = "/bar /foo" ] +} + +@test 'plugins go: multiple entries in GOPATH' { + export GOPATH="/foo:/bar" + load ../../plugins/available/go.plugin + echo "$(echo $PATH | cut -d':' -f1,2)" + [ "$(echo $PATH | cut -d':' -f1,2)" = "/foo/bin:/bar/bin" ] +} From 1030c0e9e1ccaddbeb21c9b12b60649921f64e61 Mon Sep 17 00:00:00 2001 From: cornfeedhobo Date: Thu, 6 Dec 2018 17:11:13 -0500 Subject: [PATCH 77/77] one more test ... why not --- test/plugins/go.plugin.bats | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/test/plugins/go.plugin.bats b/test/plugins/go.plugin.bats index 0cc257ed..e2b27e02 100644 --- a/test/plugins/go.plugin.bats +++ b/test/plugins/go.plugin.bats @@ -29,6 +29,13 @@ load ../../plugins/available/go.plugin [ "$output" = "/bar /foo" ] } +@test 'plugins go: single entry in GOPATH' { + export GOPATH="/foo" + load ../../plugins/available/go.plugin + echo "$(echo $PATH | cut -d':' -f1,2)" + [ "$(echo $PATH | cut -d':' -f1)" = "/foo/bin" ] +} + @test 'plugins go: multiple entries in GOPATH' { export GOPATH="/foo:/bar" load ../../plugins/available/go.plugin