From 30ae4d9e5f822494b704f6780e05cc1bd41dddb0 Mon Sep 17 00:00:00 2001 From: David Farrell Date: Wed, 25 Mar 2020 09:49:51 -0700 Subject: [PATCH 01/89] Add git switch aliases (gsw*) --- aliases/available/git.aliases.bash | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/aliases/available/git.aliases.bash b/aliases/available/git.aliases.bash index e784dade..6da2450f 100644 --- a/aliases/available/git.aliases.bash +++ b/aliases/available/git.aliases.bash @@ -87,6 +87,11 @@ alias gstb="git stash branch" alias gstd="git stash drop" alias gstl="git stash list" alias gstp="git stash pop" +# Switch aliases - Requires git v2.23+ +alias gsw="git switch" +alias gswm="git switch master" +alias gswc="git switch -c" +alias gswt="git switch -t" alias gh='cd "$(git rev-parse --show-toplevel)"' # Show untracked files alias gu='git ls-files . --exclude-standard --others' From 0274d36cd78d78f3e1f21c4299f2ac1c6b8967e8 Mon Sep 17 00:00:00 2001 From: David Farrell Date: Wed, 25 Mar 2020 10:04:27 -0700 Subject: [PATCH 02/89] Use long option values --- aliases/available/git.aliases.bash | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/aliases/available/git.aliases.bash b/aliases/available/git.aliases.bash index 6da2450f..270211ac 100644 --- a/aliases/available/git.aliases.bash +++ b/aliases/available/git.aliases.bash @@ -90,8 +90,8 @@ alias gstp="git stash pop" # Switch aliases - Requires git v2.23+ alias gsw="git switch" alias gswm="git switch master" -alias gswc="git switch -c" -alias gswt="git switch -t" +alias gswc="git switch --create" +alias gswt="git switch --track" alias gh='cd "$(git rev-parse --show-toplevel)"' # Show untracked files alias gu='git ls-files . --exclude-standard --others' From f52453c643be2e0b796e9b5e3faf892875ec294c Mon Sep 17 00:00:00 2001 From: David Farrell Date: Wed, 25 Mar 2020 11:29:12 -0700 Subject: [PATCH 03/89] Fix goenv plugin --- plugins/available/goenv.plugin.bash | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/plugins/available/goenv.plugin.bash b/plugins/available/goenv.plugin.bash index 584365b7..ecc1b1c2 100644 --- a/plugins/available/goenv.plugin.bash +++ b/plugins/available/goenv.plugin.bash @@ -3,8 +3,10 @@ about-plugin 'load goenv, if you are using it' # Don't modify the environment if we can't find the tool: # - Check if in $PATH already +# - Check if installed manually to $GOENV_ROOT # - Check if installed manually to $HOME _command_exists goenv || + [[ -n "$GOENV_ROOT" && -x "$GOENV_ROOT/bin/goenv" ]] || [[ -x "$HOME/.goenv/bin/goenv" ]] || return @@ -12,7 +14,7 @@ _command_exists goenv || export GOENV_ROOT="${GOENV_ROOT:-$HOME/.goenv}" # Add GOENV_ROOT/bin to PATH, if that's where it's installed -[[ -x "$HOME/.goenv/bin/goenv" ]] && pathmunge "$GOENV_ROOT/bin" +! _command_exists goenv && [[ -x "$GOENV_ROOT/bin/goenv" ]] && pathmunge "$GOENV_ROOT/bin" # Initialize goenv eval "$(goenv init - bash)" From 5654874aee78d20aea796af9a235c72c81fd3172 Mon Sep 17 00:00:00 2001 From: BarbUk Date: Mon, 30 Mar 2020 01:36:58 +0400 Subject: [PATCH 04/89] Documentation: font usage for theme barbuk --- themes/barbuk/README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/themes/barbuk/README.md b/themes/barbuk/README.md index 614940b4..d24ced21 100644 --- a/themes/barbuk/README.md +++ b/themes/barbuk/README.md @@ -9,6 +9,12 @@ A minimal theme with a clean git prompt * Current git info * Last command exit code (only shown when the exit code is greater than 0) +## Font + +A font with SCM glyph is required to display git remote tool logo. +You can use a font from https://www.nerdfonts.com/ or patch your own font with the tool +provided by https://github.com/ryanoasis/nerd-fonts + ## Examples ### Clean From 611d4f234f455294bfe4b6c540ad3aca4825060d Mon Sep 17 00:00:00 2001 From: BarbUk Date: Mon, 30 Mar 2020 02:11:30 +0400 Subject: [PATCH 05/89] Update font documentation --- themes/barbuk/README.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/themes/barbuk/README.md b/themes/barbuk/README.md index d24ced21..de218b30 100644 --- a/themes/barbuk/README.md +++ b/themes/barbuk/README.md @@ -11,9 +11,11 @@ A minimal theme with a clean git prompt ## Font -A font with SCM glyph is required to display git remote tool logo. +A font with SCM glyphs is required to display the default tool/host logos. You can use a font from https://www.nerdfonts.com/ or patch your own font with the tool -provided by https://github.com/ryanoasis/nerd-fonts +provided by https://github.com/ryanoasis/nerd-fonts. + +You can also override the default variables if you want to use different glyphs or standard ASCII characters. ## Examples From f4cc8ddb77d21f968bbc60cdab62a6ddb8c5b2ed Mon Sep 17 00:00:00 2001 From: BarbUk Date: Mon, 30 Mar 2020 14:23:58 +0400 Subject: [PATCH 06/89] Allow git glyphs customization --- themes/barbuk/README.md | 23 ++++++++++++++++++++++- themes/barbuk/barbuk.theme.bash | 15 +++++++++------ 2 files changed, 31 insertions(+), 7 deletions(-) diff --git a/themes/barbuk/README.md b/themes/barbuk/README.md index de218b30..cc188190 100644 --- a/themes/barbuk/README.md +++ b/themes/barbuk/README.md @@ -9,7 +9,7 @@ A minimal theme with a clean git prompt * Current git info * Last command exit code (only shown when the exit code is greater than 0) -## Font +## Fonts and glyphs A font with SCM glyphs is required to display the default tool/host logos. You can use a font from https://www.nerdfonts.com/ or patch your own font with the tool @@ -17,6 +17,26 @@ provided by https://github.com/ryanoasis/nerd-fonts. You can also override the default variables if you want to use different glyphs or standard ASCII characters. +### Default theme glyphs + +```bash +SCM_GIT_CHAR_GITLAB=' ' +SCM_GIT_CHAR_BITBUCKET=' ' +SCM_GIT_CHAR_GITHUB=' ' +SCM_GIT_CHAR_DEFAULT=' ' +SCM_GIT_CHAR_ICON_BRANCH='' +EXIT_CODE_ICON=' ' +``` + +### Customize glyphs + +Define your custom glyphs before sourcing bash-it: + +```bash +SCM_GIT_CHAR_GITHUB='•' +source "$BASH_IT"/bash_it.sh +``` + ## Examples ### Clean @@ -30,3 +50,4 @@ You can also override the default variables if you want to use different glyphs ```bash  ~/.dotfiles on  master ⤏ origin ↑2 •7 ✗ ❯ ``` + diff --git a/themes/barbuk/barbuk.theme.bash b/themes/barbuk/barbuk.theme.bash index 971cdd91..39d4995e 100644 --- a/themes/barbuk/barbuk.theme.bash +++ b/themes/barbuk/barbuk.theme.bash @@ -1,11 +1,15 @@ #!/usr/bin/env bash # shellcheck disable=2034,2154 -SCM_GIT_CHAR_GITLAB=' ' -SCM_GIT_CHAR_BITBUCKET=' ' -SCM_GIT_CHAR_GITHUB=' ' -SCM_GIT_CHAR_DEFAULT=' ' -SCM_GIT_CHAR_ICON_BRANCH='' +# Theme custom glyphs +SCM_GIT_CHAR_GITLAB=${SCM_GITLAB_CHAR:=' '} +SCM_GIT_CHAR_BITBUCKET=${SCM_GIT_CHAR_BITBUCKET:=' '} +SCM_GIT_CHAR_GITHUB=${SCM_GIT_CHAR_GITHUB:=' '} +SCM_GIT_CHAR_DEFAULT=${SCM_GIT_CHAR_DEFAULT:=' '} +SCM_GIT_CHAR_ICON_BRANCH=${SCM_GIT_CHAR_ICON_BRANCH:=''} +EXIT_CODE_ICON=${EXIT_CODE_ICON:=' '} + +# Bash-it default glyphs customization SCM_HG_CHAR='☿ ' SCM_SVN_CHAR='⑆ ' SCM_NONE_CHAR= @@ -25,7 +29,6 @@ GIT_THEME_PROMPT_SUFFIX="${cyan}" SCM_THEME_BRANCH_TRACK_PREFIX="${normal} ⤏ ${cyan}" SCM_THEME_CURRENT_USER_PREFFIX='  ' SCM_GIT_SHOW_CURRENT_USER=false -EXIT_CODE_ICON=' ' function _git-uptream-remote-logo { [[ "$(_git-upstream)" == "" ]] && return From 303e0a937e33634cb46d965134cf74b7c6cd530f Mon Sep 17 00:00:00 2001 From: buhl <221842+buhl@users.noreply.github.com> Date: Mon, 30 Mar 2020 21:46:46 +0200 Subject: [PATCH 07/89] Simplified-sudo-check --- themes/powerline/powerline.base.bash | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/themes/powerline/powerline.base.bash b/themes/powerline/powerline.base.bash index 969b210d..8c983a7b 100644 --- a/themes/powerline/powerline.base.bash +++ b/themes/powerline/powerline.base.bash @@ -18,9 +18,7 @@ function __powerline_user_info_prompt { local color=${USER_INFO_THEME_PROMPT_COLOR} if [[ "${THEME_CHECK_SUDO}" = true ]]; then - if sudo -n uptime 2>&1 | grep -q "load"; then - color=${USER_INFO_THEME_PROMPT_COLOR_SUDO} - fi + sudo -vn 1>/dev/null 2>&1 && color=${USER_INFO_THEME_PROMPT_COLOR_SUDO} fi case "${POWERLINE_PROMPT_USER_INFO_MODE}" in From 81c4ed70ea1d36a2f8677865bd6f73041d11c032 Mon Sep 17 00:00:00 2001 From: BarbUk Date: Tue, 31 Mar 2020 12:15:28 +0400 Subject: [PATCH 08/89] Add user@host information for ssh session --- themes/barbuk/barbuk.theme.bash | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/themes/barbuk/barbuk.theme.bash b/themes/barbuk/barbuk.theme.bash index 39d4995e..372b8a0d 100644 --- a/themes/barbuk/barbuk.theme.bash +++ b/themes/barbuk/barbuk.theme.bash @@ -31,7 +31,7 @@ SCM_THEME_CURRENT_USER_PREFFIX='  ' SCM_GIT_SHOW_CURRENT_USER=false function _git-uptream-remote-logo { - [[ "$(_git-upstream)" == "" ]] && return + [[ "$(_git-upstream)" == "" ]] && SCM_GIT_CHAR="$SCM_GIT_CHAR_DEFAULT" local remote remote_domain remote=$(_git-upstream-remote) @@ -62,7 +62,7 @@ function _exit-code { } function _prompt { - local exit_code="$?" wrap_char=' ' dir_color=$green + local exit_code="$?" wrap_char=' ' dir_color=$green ssh_info='' _exit-code exit_code _git-uptream-remote-logo @@ -74,7 +74,12 @@ function _prompt { dir_color=$red fi - PS1="\\n ${purple}$(scm_char)${dir_color}\\w${normal}$(scm_prompt_info)${exit_code}" + # Detect ssh + if [[ -n "${SSH_CLIENT}" ]] || [[ -n "${SSH_CONNECTION}" ]]; then + ssh_info="${bold_blue}\u${bold_orange}@${cyan}\H ${bold_orange}in" + fi + + PS1="\\n${ssh_info} ${purple}$(scm_char)${dir_color}\\w${normal}$(scm_prompt_info)${exit_code}" [[ ${#PS1} -gt $((COLUMNS*3)) ]] && wrap_char="\\n" PS1="${PS1}${wrap_char}❯${normal} " From 337ed0de9aea4eb4c5bc07a2194bcebc06f537de Mon Sep 17 00:00:00 2001 From: BarbUk Date: Tue, 31 Mar 2020 12:16:06 +0400 Subject: [PATCH 09/89] Documentation for ssh and sudoer configuration --- themes/barbuk/README.md | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/themes/barbuk/README.md b/themes/barbuk/README.md index cc188190..372560e4 100644 --- a/themes/barbuk/README.md +++ b/themes/barbuk/README.md @@ -8,6 +8,7 @@ A minimal theme with a clean git prompt * Current path (red when user is root) * Current git info * Last command exit code (only shown when the exit code is greater than 0) +* user@host for ssh connection ## Fonts and glyphs @@ -37,6 +38,26 @@ SCM_GIT_CHAR_GITHUB='•' source "$BASH_IT"/bash_it.sh ``` +## SSH prompt and sudoers + +If you want the theme to persist using `sudo -s` in a ssh session, you need to configure sudo to keep the `HOME` and `SSH_CONNECTION` environment variables. + +`HOME` contains the path to the home directory of the current user. Keeping it will allow to use your user dotfiles when elevating privileges. + +Keeping `SSH_CONNECTION` env is necessary for ssh detection in the theme. + +Please refer to the following documentation for more information: + - [sudo manual](https://www.sudo.ws/man/1.8.13/sudoers.man.html) for `env_keep` configuration + - [openssh manual](https://linux.die.net/man/1/ssh) for information about `SSH_CONNECTION` environment + +```bash +cat << EOF > /etc/sudoers.d/keepenv +Defaults env_keep += HOME +Defaults env_keep += SSH_CONNECTION +EOF +chmod 400 /etc/sudoers.d/keepenv +``` + ## Examples ### Clean @@ -49,5 +70,10 @@ source "$BASH_IT"/bash_it.sh ```bash  ~/.dotfiles on  master ⤏ origin ↑2 •7 ✗ ❯ - ``` +``` +### Ssh + +```bash +user@fqdn in  ~/bash-it on  master ✓ ❯ +``` From 8c44bae797760f697df8d821f56b217acb4d4878 Mon Sep 17 00:00:00 2001 From: David Farrell Date: Tue, 31 Mar 2020 10:12:19 -0700 Subject: [PATCH 10/89] theme/barbuk: Update prefix for overrides --- themes/barbuk/README.md | 15 +++++++++------ themes/barbuk/barbuk.theme.bash | 18 +++++++++--------- 2 files changed, 18 insertions(+), 15 deletions(-) diff --git a/themes/barbuk/README.md b/themes/barbuk/README.md index cc188190..52727e04 100644 --- a/themes/barbuk/README.md +++ b/themes/barbuk/README.md @@ -20,12 +20,15 @@ You can also override the default variables if you want to use different glyphs ### Default theme glyphs ```bash -SCM_GIT_CHAR_GITLAB=' ' -SCM_GIT_CHAR_BITBUCKET=' ' -SCM_GIT_CHAR_GITHUB=' ' -SCM_GIT_CHAR_DEFAULT=' ' -SCM_GIT_CHAR_ICON_BRANCH='' -EXIT_CODE_ICON=' ' +BARBUK_GITLAB_CHAR=' ' +BARBUK_BITBUCKET_CHAR=' ' +BARBUK_GITHUB_CHAR=' ' +BARBUK_GIT_DEFAULT_CHAR=' ' +BARBUK_GIT_BRANCH_ICON='' +BARBUK_HG_CHAR='☿ ' +BARBUK_SVN_CHAR='⑆ ' +BARBUK_NO_SCM_CHAR='' +BARBUK_EXIT_CODE_ICON=' ' ``` ### Customize glyphs diff --git a/themes/barbuk/barbuk.theme.bash b/themes/barbuk/barbuk.theme.bash index 39d4995e..ec2ac7b8 100644 --- a/themes/barbuk/barbuk.theme.bash +++ b/themes/barbuk/barbuk.theme.bash @@ -2,17 +2,17 @@ # shellcheck disable=2034,2154 # Theme custom glyphs -SCM_GIT_CHAR_GITLAB=${SCM_GITLAB_CHAR:=' '} -SCM_GIT_CHAR_BITBUCKET=${SCM_GIT_CHAR_BITBUCKET:=' '} -SCM_GIT_CHAR_GITHUB=${SCM_GIT_CHAR_GITHUB:=' '} -SCM_GIT_CHAR_DEFAULT=${SCM_GIT_CHAR_DEFAULT:=' '} -SCM_GIT_CHAR_ICON_BRANCH=${SCM_GIT_CHAR_ICON_BRANCH:=''} -EXIT_CODE_ICON=${EXIT_CODE_ICON:=' '} +SCM_GIT_CHAR_GITLAB=${BARBUK_GITLAB_CHAR:=' '} +SCM_GIT_CHAR_BITBUCKET=${BARBUK_BITBUCKET_CHAR:=' '} +SCM_GIT_CHAR_GITHUB=${BARBUK_GITHUB_CHAR:=' '} +SCM_GIT_CHAR_DEFAULT=${BARBUK_GIT_DEFAULT_CHAR:=' '} +SCM_GIT_CHAR_ICON_BRANCH=${BARBUK_GIT_BRANCH_ICON:=''} +SCM_HG_CHAR=${BARBUK_HG_CHAR:='☿ '} +SCM_SVN_CHAR=${BARBUK_SVN_CHAR:='⑆ '} +SCM_NONE_CHAR=${BARBUK_NO_SCM_CHAR:=''} +EXIT_CODE_ICON=${BARBUK_EXIT_CODE_ICON:=' '} # Bash-it default glyphs customization -SCM_HG_CHAR='☿ ' -SCM_SVN_CHAR='⑆ ' -SCM_NONE_CHAR= SCM_THEME_PROMPT_DIRTY=" ${bold_red}✗" SCM_THEME_PROMPT_CLEAN=" ${bold_green}✓" SCM_THEME_PROMPT_PREFIX="|" From 9e443009ac7d7c2a95df2f629afb21edd835ef31 Mon Sep 17 00:00:00 2001 From: David Farrell Date: Tue, 31 Mar 2020 10:15:22 -0700 Subject: [PATCH 11/89] theme/barbuk: Update prefix for overrides --- themes/barbuk/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/themes/barbuk/README.md b/themes/barbuk/README.md index 52727e04..8cf4be76 100644 --- a/themes/barbuk/README.md +++ b/themes/barbuk/README.md @@ -36,7 +36,7 @@ BARBUK_EXIT_CODE_ICON=' ' Define your custom glyphs before sourcing bash-it: ```bash -SCM_GIT_CHAR_GITHUB='•' +export BARBUK_GITHUB_CHAR='•' source "$BASH_IT"/bash_it.sh ``` From 6943996f0b2cdcaf972b3ec324631435fdf63fd9 Mon Sep 17 00:00:00 2001 From: David Farrell Date: Tue, 31 Mar 2020 10:21:02 -0700 Subject: [PATCH 12/89] Revert the NONE_CHAR override --- themes/barbuk/README.md | 1 - themes/barbuk/barbuk.theme.bash | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/themes/barbuk/README.md b/themes/barbuk/README.md index 8cf4be76..4646a49a 100644 --- a/themes/barbuk/README.md +++ b/themes/barbuk/README.md @@ -27,7 +27,6 @@ BARBUK_GIT_DEFAULT_CHAR=' ' BARBUK_GIT_BRANCH_ICON='' BARBUK_HG_CHAR='☿ ' BARBUK_SVN_CHAR='⑆ ' -BARBUK_NO_SCM_CHAR='' BARBUK_EXIT_CODE_ICON=' ' ``` diff --git a/themes/barbuk/barbuk.theme.bash b/themes/barbuk/barbuk.theme.bash index ec2ac7b8..44b5237a 100644 --- a/themes/barbuk/barbuk.theme.bash +++ b/themes/barbuk/barbuk.theme.bash @@ -9,10 +9,10 @@ SCM_GIT_CHAR_DEFAULT=${BARBUK_GIT_DEFAULT_CHAR:=' '} SCM_GIT_CHAR_ICON_BRANCH=${BARBUK_GIT_BRANCH_ICON:=''} SCM_HG_CHAR=${BARBUK_HG_CHAR:='☿ '} SCM_SVN_CHAR=${BARBUK_SVN_CHAR:='⑆ '} -SCM_NONE_CHAR=${BARBUK_NO_SCM_CHAR:=''} EXIT_CODE_ICON=${BARBUK_EXIT_CODE_ICON:=' '} # Bash-it default glyphs customization +SCM_NONE_CHAR= SCM_THEME_PROMPT_DIRTY=" ${bold_red}✗" SCM_THEME_PROMPT_CLEAN=" ${bold_green}✓" SCM_THEME_PROMPT_PREFIX="|" From d39eb053cfd40fa6c5a6aad9c8eb5208e922496b Mon Sep 17 00:00:00 2001 From: BarbUk Date: Wed, 1 Apr 2020 00:46:58 +0400 Subject: [PATCH 13/89] Allow to disable ssh info --- themes/barbuk/barbuk.theme.bash | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/themes/barbuk/barbuk.theme.bash b/themes/barbuk/barbuk.theme.bash index 372b8a0d..ead0940a 100644 --- a/themes/barbuk/barbuk.theme.bash +++ b/themes/barbuk/barbuk.theme.bash @@ -9,6 +9,9 @@ SCM_GIT_CHAR_DEFAULT=${SCM_GIT_CHAR_DEFAULT:=' '} SCM_GIT_CHAR_ICON_BRANCH=${SCM_GIT_CHAR_ICON_BRANCH:=''} EXIT_CODE_ICON=${EXIT_CODE_ICON:=' '} +# Ssh user and fqdn display +SSH_INFO=${BARBUK_SSH_INFO:=true} + # Bash-it default glyphs customization SCM_HG_CHAR='☿ ' SCM_SVN_CHAR='⑆ ' @@ -75,7 +78,7 @@ function _prompt { fi # Detect ssh - if [[ -n "${SSH_CLIENT}" ]] || [[ -n "${SSH_CONNECTION}" ]]; then + if [[ -n "${SSH_CONNECTION}" ]] && [ "$SSH_INFO" = true ]; then ssh_info="${bold_blue}\u${bold_orange}@${cyan}\H ${bold_orange}in" fi From 6d0744a9288ed8b29d6fbf2e4886cbe2ec1f7180 Mon Sep 17 00:00:00 2001 From: BarbUk Date: Wed, 1 Apr 2020 00:48:11 +0400 Subject: [PATCH 14/89] Update documentation --- themes/barbuk/README.md | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/themes/barbuk/README.md b/themes/barbuk/README.md index 372560e4..736fd0ba 100644 --- a/themes/barbuk/README.md +++ b/themes/barbuk/README.md @@ -38,7 +38,19 @@ SCM_GIT_CHAR_GITHUB='•' source "$BASH_IT"/bash_it.sh ``` -## SSH prompt and sudoers +## SSH prompt + +### Usage + +When using a ssh session, the theme will display `user@fqdn`. +You can disable this information before sourcing bsah-it: + +```bash +export BARBUK_SSH_INFO=false +source "$BASH_IT"/bash_it.sh +``` + +### Keep theme with sudoer If you want the theme to persist using `sudo -s` in a ssh session, you need to configure sudo to keep the `HOME` and `SSH_CONNECTION` environment variables. From 347995d33e172faea431fc9fa72e40bf5e5f3b88 Mon Sep 17 00:00:00 2001 From: BarbUk Date: Wed, 1 Apr 2020 01:02:01 +0400 Subject: [PATCH 15/89] Allow to customize hostname format --- themes/barbuk/barbuk.theme.bash | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/themes/barbuk/barbuk.theme.bash b/themes/barbuk/barbuk.theme.bash index ead0940a..2cba4df7 100644 --- a/themes/barbuk/barbuk.theme.bash +++ b/themes/barbuk/barbuk.theme.bash @@ -11,6 +11,7 @@ EXIT_CODE_ICON=${EXIT_CODE_ICON:=' '} # Ssh user and fqdn display SSH_INFO=${BARBUK_SSH_INFO:=true} +HOST_INFO=${BARBUK_HOST_INFO:=long} # Bash-it default glyphs customization SCM_HG_CHAR='☿ ' @@ -65,7 +66,7 @@ function _exit-code { } function _prompt { - local exit_code="$?" wrap_char=' ' dir_color=$green ssh_info='' + local exit_code="$?" wrap_char=' ' dir_color=$green ssh_info='' host _exit-code exit_code _git-uptream-remote-logo @@ -79,7 +80,12 @@ function _prompt { # Detect ssh if [[ -n "${SSH_CONNECTION}" ]] && [ "$SSH_INFO" = true ]; then - ssh_info="${bold_blue}\u${bold_orange}@${cyan}\H ${bold_orange}in" + if [ "$HOST_INFO" = long ]; then + host="\H" + else + host="\h" + fi + ssh_info="${bold_blue}\u${bold_orange}@${cyan}$host ${bold_orange}in" fi PS1="\\n${ssh_info} ${purple}$(scm_char)${dir_color}\\w${normal}$(scm_prompt_info)${exit_code}" From d79fc5027bb8358e2d70a77c1f0dad96b07d41e6 Mon Sep 17 00:00:00 2001 From: David Farrell Date: Tue, 31 Mar 2020 14:02:22 -0700 Subject: [PATCH 16/89] theme/atomic: update sudo check method --- themes/atomic/atomic.theme.bash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/themes/atomic/atomic.theme.bash b/themes/atomic/atomic.theme.bash index a89aeea3..5f44b34b 100644 --- a/themes/atomic/atomic.theme.bash +++ b/themes/atomic/atomic.theme.bash @@ -194,7 +194,7 @@ ___atomic_prompt_char() { color=$white prompt_char="${__ATOMIC_PROMPT_CHAR_PS1}" if [ "${THEME_SHOW_SUDO}" == "true" ]; then - if [ $(sudo -n id -u 2>&1 | grep 0) ]; then + if sudo -vn 1>/dev/null 2>&1; then prompt_char="${__ATOMIC_PROMPT_CHAR_PS1_SUDO}" fi fi From 78db4d56f082b9dc9458db915e66904affe3b272 Mon Sep 17 00:00:00 2001 From: BarbUk Date: Wed, 1 Apr 2020 01:02:24 +0400 Subject: [PATCH 17/89] Update documentation to explain new BARBUK_HOST_INFO configuration --- themes/barbuk/README.md | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/themes/barbuk/README.md b/themes/barbuk/README.md index 736fd0ba..06cce8de 100644 --- a/themes/barbuk/README.md +++ b/themes/barbuk/README.md @@ -42,10 +42,16 @@ source "$BASH_IT"/bash_it.sh ### Usage -When using a ssh session, the theme will display `user@fqdn`. -You can disable this information before sourcing bsah-it: +When using a ssh session, the theme will display `user@hostname`. +You can disable this information with `BARBUK_SSH_INFO`. + +The hostname is display in the FQDN format by default. You +can use the short hostname format with `BARBUK_HOST_INFO`. ```bash +# short or long +export BARBUK_HOST_INFO=short +# true or false export BARBUK_SSH_INFO=false source "$BASH_IT"/bash_it.sh ``` @@ -87,5 +93,5 @@ chmod 400 /etc/sudoers.d/keepenv ### Ssh ```bash -user@fqdn in  ~/bash-it on  master ✓ ❯ +user@hostname in  ~/bash-it on  master ✓ ❯ ``` From d6d4e4bc7d9f0ea0adf0675510e582593f097f56 Mon Sep 17 00:00:00 2001 From: BarbUk Date: Wed, 1 Apr 2020 01:05:15 +0400 Subject: [PATCH 18/89] Fix typo --- themes/barbuk/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/themes/barbuk/README.md b/themes/barbuk/README.md index 06cce8de..c3101734 100644 --- a/themes/barbuk/README.md +++ b/themes/barbuk/README.md @@ -45,7 +45,7 @@ source "$BASH_IT"/bash_it.sh When using a ssh session, the theme will display `user@hostname`. You can disable this information with `BARBUK_SSH_INFO`. -The hostname is display in the FQDN format by default. You +The hostname is displayed in the FQDN format by default. You can use the short hostname format with `BARBUK_HOST_INFO`. ```bash From 0896ff2fb3d245ff39eb7fb91917e26e6c9a3768 Mon Sep 17 00:00:00 2001 From: BarbUk Date: Wed, 1 Apr 2020 01:06:33 +0400 Subject: [PATCH 19/89] Use same notation for user@hostname --- themes/barbuk/README.md | 2 +- themes/barbuk/barbuk.theme.bash | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/themes/barbuk/README.md b/themes/barbuk/README.md index c3101734..dad6e140 100644 --- a/themes/barbuk/README.md +++ b/themes/barbuk/README.md @@ -8,7 +8,7 @@ A minimal theme with a clean git prompt * Current path (red when user is root) * Current git info * Last command exit code (only shown when the exit code is greater than 0) -* user@host for ssh connection +* user@hostname for ssh connection ## Fonts and glyphs diff --git a/themes/barbuk/barbuk.theme.bash b/themes/barbuk/barbuk.theme.bash index 2cba4df7..7990ca91 100644 --- a/themes/barbuk/barbuk.theme.bash +++ b/themes/barbuk/barbuk.theme.bash @@ -9,7 +9,7 @@ SCM_GIT_CHAR_DEFAULT=${SCM_GIT_CHAR_DEFAULT:=' '} SCM_GIT_CHAR_ICON_BRANCH=${SCM_GIT_CHAR_ICON_BRANCH:=''} EXIT_CODE_ICON=${EXIT_CODE_ICON:=' '} -# Ssh user and fqdn display +# Ssh user and hostname display SSH_INFO=${BARBUK_SSH_INFO:=true} HOST_INFO=${BARBUK_HOST_INFO:=long} From 1d6b01018d5227ea52a86c1d29767f139efd781c Mon Sep 17 00:00:00 2001 From: David Farrell Date: Tue, 31 Mar 2020 14:11:05 -0700 Subject: [PATCH 20/89] theme/brainy: Update sudo check method --- themes/brainy/brainy.theme.bash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/themes/brainy/brainy.theme.bash b/themes/brainy/brainy.theme.bash index e78128aa..e27d9d80 100644 --- a/themes/brainy/brainy.theme.bash +++ b/themes/brainy/brainy.theme.bash @@ -90,7 +90,7 @@ ____brainy_bottom() { ___brainy_prompt_user_info() { color=$bold_blue if [ "${THEME_SHOW_SUDO}" == "true" ]; then - if [ $(sudo -n id -u 2>&1 | grep 0) ]; then + if sudo -vn 1>/dev/null 2>&1; then color=$bold_red fi fi From 3c6ffeb44fd50bdc5d9b07be89293139a6976ca4 Mon Sep 17 00:00:00 2001 From: BarbUk Date: Wed, 1 Apr 2020 12:09:54 +0400 Subject: [PATCH 21/89] Update theme var prefix --- themes/barbuk/README.md | 8 ++++---- themes/barbuk/barbuk.theme.bash | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/themes/barbuk/README.md b/themes/barbuk/README.md index dad6e140..4fe752b4 100644 --- a/themes/barbuk/README.md +++ b/themes/barbuk/README.md @@ -43,16 +43,16 @@ source "$BASH_IT"/bash_it.sh ### Usage When using a ssh session, the theme will display `user@hostname`. -You can disable this information with `BARBUK_SSH_INFO`. +You can disable this information with `BASH_IT_THEME_BARBUK_SSH_INFO`. The hostname is displayed in the FQDN format by default. You -can use the short hostname format with `BARBUK_HOST_INFO`. +can use the short hostname format with `BASH_IT_THEME_BARBUK_HOST_INFO`. ```bash # short or long -export BARBUK_HOST_INFO=short +export BASH_IT_THEME_BARBUK_HOST_INFO=short # true or false -export BARBUK_SSH_INFO=false +export BASH_IT_THEME_BARBUK_SSH_INFO=false source "$BASH_IT"/bash_it.sh ``` diff --git a/themes/barbuk/barbuk.theme.bash b/themes/barbuk/barbuk.theme.bash index 7990ca91..011fec32 100644 --- a/themes/barbuk/barbuk.theme.bash +++ b/themes/barbuk/barbuk.theme.bash @@ -10,8 +10,8 @@ SCM_GIT_CHAR_ICON_BRANCH=${SCM_GIT_CHAR_ICON_BRANCH:=''} EXIT_CODE_ICON=${EXIT_CODE_ICON:=' '} # Ssh user and hostname display -SSH_INFO=${BARBUK_SSH_INFO:=true} -HOST_INFO=${BARBUK_HOST_INFO:=long} +SSH_INFO=${BASH_IT_THEME_BARBUK_SSH_INFO:=true} +HOST_INFO=${BASH_IT_THEME_BARBUK_HOST_INFO:=long} # Bash-it default glyphs customization SCM_HG_CHAR='☿ ' From 5ad244da873b3f6756253ea57ceea6bb45f211b6 Mon Sep 17 00:00:00 2001 From: Gurkirat Singh Date: Thu, 2 Apr 2020 18:59:10 +0530 Subject: [PATCH 22/89] Update ng.completion.bash --- completion/available/ng.completion.bash | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/completion/available/ng.completion.bash b/completion/available/ng.completion.bash index cd191bb2..53361f7a 100644 --- a/completion/available/ng.completion.bash +++ b/completion/available/ng.completion.bash @@ -1,3 +1,5 @@ -. <(ng completion --bash) +# . <(ng completion --bash) obselete +NG_COMMANDS="add build config doc e2e generate help lint new run serve test update version xi18n" +complete -W "$NG_COMMANDS" ng From 6b4970136bb3d71c33262feeb47d8347e669f5f4 Mon Sep 17 00:00:00 2001 From: Nils Winkler Date: Mon, 6 Apr 2020 16:08:50 +0200 Subject: [PATCH 23/89] Added a check for the ng command in ng completion See #1542, #1543 --- completion/available/ng.completion.bash | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/completion/available/ng.completion.bash b/completion/available/ng.completion.bash index 53361f7a..827bc22d 100644 --- a/completion/available/ng.completion.bash +++ b/completion/available/ng.completion.bash @@ -1,5 +1,9 @@ -# . <(ng completion --bash) obselete +if _command_exists ng; then + # No longer supported, please see https://github.com/angular/angular-cli/issues/11043 + # Fix courtesy of https://stackoverflow.com/questions/50194674/ng-completion-no-longer-exists + # . <(ng completion --bash) -NG_COMMANDS="add build config doc e2e generate help lint new run serve test update version xi18n" -complete -W "$NG_COMMANDS" ng + NG_COMMANDS="add build config doc e2e generate help lint new run serve test update version xi18n" + complete -W "$NG_COMMANDS" ng +fi From 7fe7fc020e76968e8be6bb781db907060d818304 Mon Sep 17 00:00:00 2001 From: David Farrell Date: Mon, 6 Apr 2020 10:16:11 -0700 Subject: [PATCH 24/89] aliases/git: Add alises fo git stash push/pop --- aliases/available/git.aliases.bash | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/aliases/available/git.aliases.bash b/aliases/available/git.aliases.bash index 270211ac..b9565eaf 100644 --- a/aliases/available/git.aliases.bash +++ b/aliases/available/git.aliases.bash @@ -82,10 +82,21 @@ alias gprom="git fetch origin master && git rebase origin/master && git update-r alias gpunch="git push --force-with-lease" alias ggui="git gui" alias gcsam="git commit -S -am" +# Stash aliases alias gst="git stash" alias gstb="git stash branch" alias gstd="git stash drop" alias gstl="git stash list" +# Push introduced in git v2.13.2 +alias gstpu="git stash push" +alias gstpum="git stash push -m" +# Save deprecated since git v2.16.0 +# - aliases now resolve to push +alias gsts="git stash push" +alias gstsm="git stash push -m" +# Alias gstpo added for symmetry with gstpu (push) +# - gstp remains as alias for pop due to long-standing usage +alias gstpo="git stash pop" alias gstp="git stash pop" # Switch aliases - Requires git v2.23+ alias gsw="git switch" From 7a83c56d3a3dba8152e83af3ef5ec55b6cb4336a Mon Sep 17 00:00:00 2001 From: Alex Thiessen Date: Tue, 7 Apr 2020 00:01:09 +0200 Subject: [PATCH 25/89] plugins/base: Detect HTTP errors in `myip()` Out of the box, `curl` reports success (via exit code) even if the server returns an error, e.g. _429 Too Many Requests_ which was sometimes the case with `http://myip.dnsomatic.com`. So, errors went undetected. There is the `--fail` switch which enables us to use the exit code the way we need: > -f, --fail > (HTTP) Fail silently (no output at all) on server > errors. This is mostly done to better enable scripts etc > to better deal with failed attempts. In normal cases > when an HTTP server fails to deliver a document, it > returns an HTML document stating so (which often also > describes why and more). This flag will prevent curl > from outputting that and return error 22. Use it to make the `myip()` deliver results reliably. --- plugins/available/base.plugin.bash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/available/base.plugin.bash b/plugins/available/base.plugin.bash index 297bf0ff..6da1384e 100755 --- a/plugins/available/base.plugin.bash +++ b/plugins/available/base.plugin.bash @@ -32,7 +32,7 @@ function myip () list=("http://myip.dnsomatic.com/" "http://checkip.dyndns.com/" "http://checkip.dyndns.org/") for url in ${list[*]} do - res=$(curl -s "${url}") + res=$(curl -fs "${url}") if [ $? -eq 0 ];then break; fi From b968ecac8057ecdd8adb55cccdc4ddb6f2547adf Mon Sep 17 00:00:00 2001 From: BarbUk Date: Wed, 8 Apr 2020 11:06:26 +0400 Subject: [PATCH 26/89] Update custom var naming --- themes/barbuk/barbuk.theme.bash | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/themes/barbuk/barbuk.theme.bash b/themes/barbuk/barbuk.theme.bash index fe687555..5c5fdf1d 100644 --- a/themes/barbuk/barbuk.theme.bash +++ b/themes/barbuk/barbuk.theme.bash @@ -12,8 +12,8 @@ SCM_SVN_CHAR=${BARBUK_SVN_CHAR:='⑆ '} EXIT_CODE_ICON=${BARBUK_EXIT_CODE_ICON:=' '} # Ssh user and hostname display -SSH_INFO=${BASH_IT_THEME_BARBUK_SSH_INFO:=true} -HOST_INFO=${BASH_IT_THEME_BARBUK_HOST_INFO:=long} +SSH_INFO=${BARBUK_SSH_INFO:=true} +HOST_INFO=${BARBUK_HOST_INFO:=long} # Bash-it default glyphs customization SCM_NONE_CHAR= From c4b8d4cf2e6f13dd13f1128f87d33b6157d990da Mon Sep 17 00:00:00 2001 From: BarbUk Date: Wed, 8 Apr 2020 11:06:44 +0400 Subject: [PATCH 27/89] Update documentation --- themes/barbuk/README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/themes/barbuk/README.md b/themes/barbuk/README.md index aebe20d4..87d23bad 100644 --- a/themes/barbuk/README.md +++ b/themes/barbuk/README.md @@ -45,16 +45,16 @@ source "$BASH_IT"/bash_it.sh ### Usage When using a ssh session, the theme will display `user@hostname`. -You can disable this information with `BASH_IT_THEME_BARBUK_SSH_INFO`. +You can disable this information with `BARBUK_SSH_INFO`. The hostname is displayed in the FQDN format by default. You -can use the short hostname format with `BASH_IT_THEME_BARBUK_HOST_INFO`. +can use the short hostname format with `BARBUK_HOST_INFO`. ```bash # short or long -export BASH_IT_THEME_BARBUK_HOST_INFO=short +export BARBUK_HOST_INFO=short # true or false -export BASH_IT_THEME_BARBUK_SSH_INFO=false +export BARBUK_SSH_INFO=false source "$BASH_IT"/bash_it.sh ``` From 668306cae71d97d9c07ae171929aa64ef1c4d022 Mon Sep 17 00:00:00 2001 From: Alex Thiessen Date: Sun, 5 Apr 2020 21:27:46 +0200 Subject: [PATCH 28/89] test/plugins/base: Run `myip` test Test of `myip` was skipped, allegedly for it being slow. It's fast for me (~400 ms), so enable it unconditionally. --- test/plugins/base.plugin.bats | 4 ---- 1 file changed, 4 deletions(-) diff --git a/test/plugins/base.plugin.bats b/test/plugins/base.plugin.bats index 3988831f..cca47497 100755 --- a/test/plugins/base.plugin.bats +++ b/test/plugins/base.plugin.bats @@ -16,10 +16,6 @@ load ../../plugins/available/base.plugin } @test 'plugins base: myip()' { - if [[ ! $SLOW_TESTS ]]; then - skip 'myip is slow - run only with SLOW_TESTS=true' - fi - run myip assert_success declare -r mask_ip=$(echo $output | tr -s '[0-9]' '?') From 3d45f01728497c2ac88d740b65837c1a823d950a Mon Sep 17 00:00:00 2001 From: Alex Thiessen Date: Sun, 5 Apr 2020 13:17:10 +0200 Subject: [PATCH 29/89] test/test_helper: Don't use system/user `git` config Git uses system-wide and user-wide configurations per default and these can interfere with our tests. Keep `git` from using them by setting the according environment variables. This might also help with other tools which access user's home directory. --- test/test_helper.bash | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/test/test_helper.bash b/test/test_helper.bash index 9784cdf8..cd75f05a 100644 --- a/test/test_helper.bash +++ b/test/test_helper.bash @@ -17,6 +17,23 @@ fi export TEST_MAIN_DIR="${BATS_TEST_DIRNAME}/.." export TEST_DEPS_DIR="${TEST_DEPS_DIR-${TEST_MAIN_DIR}/../test_lib}" +# be independent of git's system configuration +export GIT_CONFIG_NOSYSTEM + +# Some tools, e.g. `git` use configuration files from the $HOME directory, +# which interferes with our tests. The only way to keep `git` from doing this +# seems to set HOME explicitly to a separate location. +# Refer to https://git-scm.com/docs/git-config#FILES. +unset XDG_CONFIG_HOME +export HOME="${BATS_TMPDIR}/home" +mkdir -p "${HOME}" + +# For `git` tests to run well, user name and email need to be set. +# Refer to https://git-scm.com/docs/git-commit#_commit_information. +# This goes to the test-specific config, due to the $HOME overridden above. +git config --global user.name "John Doe" +git config --global user.email "johndoe@example.com" + load "${TEST_DEPS_DIR}/bats-support/load.bash" load "${TEST_DEPS_DIR}/bats-assert/load.bash" load "${TEST_DEPS_DIR}/bats-file/load.bash" From f0af4fd6018d09aa73bf33e2e415d1d6e515a8cc Mon Sep 17 00:00:00 2001 From: Jeremy Mathevet Date: Thu, 9 Apr 2020 11:06:24 +0800 Subject: [PATCH 30/89] Check gh command exists before setting git gh alias --- aliases/available/git.aliases.bash | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/aliases/available/git.aliases.bash b/aliases/available/git.aliases.bash index b9565eaf..cae55f21 100644 --- a/aliases/available/git.aliases.bash +++ b/aliases/available/git.aliases.bash @@ -103,7 +103,11 @@ alias gsw="git switch" alias gswm="git switch master" alias gswc="git switch --create" alias gswt="git switch --track" -alias gh='cd "$(git rev-parse --show-toplevel)"' +# Git home +alias ghm='cd "$(git rev-parse --show-toplevel)"' +if ! _command_exists gh; then + alias gh='cd "$(git rev-parse --show-toplevel)"' +fi # Show untracked files alias gu='git ls-files . --exclude-standard --others' From c003f0f34234db0a9f0119610a62c4cd7db6ef7e Mon Sep 17 00:00:00 2001 From: Alex Thiessen Date: Thu, 9 Apr 2020 23:40:59 +0000 Subject: [PATCH 31/89] test/plugins/go: Skip tests in absence of `go` In case `go` is not installed, tests of the according plugin fail. It's better to just skip them since `golang` isn't commonly installed on `bash-it` developers' machines. In CI environment, no tests should be skipped, so run them anyway. --- 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 02806205..d511bd24 100644 --- a/test/plugins/go.plugin.bats +++ b/test/plugins/go.plugin.bats @@ -5,12 +5,14 @@ load ../../lib/helpers load ../../lib/composure @test 'ensure _go_pathmunge_wrap is defined' { + { [[ $CI ]] || _command_exists go; } || skip 'golang not found' load ../../plugins/available/go.plugin run type -t _go_pathmunge_wrap assert_line 'function' } @test 'plugins go: single entry in GOPATH' { + { [[ $CI ]] || _command_exists go; } || skip 'golang not found' export GOPATH="/foo" export GOROOT="/baz" load ../../plugins/available/go.plugin @@ -18,6 +20,7 @@ load ../../lib/composure } @test 'plugins go: single entry in GOPATH, with space' { + { [[ $CI ]] || _command_exists go; } || skip 'golang not found' export GOPATH="/foo bar" export GOROOT="/baz" load ../../plugins/available/go.plugin @@ -25,6 +28,7 @@ load ../../lib/composure } @test 'plugins go: single entry in GOPATH, with escaped space' { + { [[ $CI ]] || _command_exists go; } || skip 'golang not found' export GOPATH="/foo\ bar" export GOROOT="/baz" load ../../plugins/available/go.plugin @@ -32,6 +36,7 @@ load ../../lib/composure } @test 'plugins go: multiple entries in GOPATH' { + { [[ $CI ]] || _command_exists go; } || skip 'golang not found' export GOPATH="/foo:/bar" export GOROOT="/baz" load ../../plugins/available/go.plugin @@ -39,6 +44,7 @@ load ../../lib/composure } @test 'plugins go: multiple entries in GOPATH, with space' { + { [[ $CI ]] || _command_exists go; } || skip 'golang not found' export GOPATH="/foo:/foo bar" export GOROOT="/baz" load ../../plugins/available/go.plugin @@ -46,6 +52,7 @@ load ../../lib/composure } @test 'plugins go: multiple entries in GOPATH, with escaped space' { + { [[ $CI ]] || _command_exists go; } || skip 'golang not found' export GOPATH="/foo:/foo\ bar" export GOROOT="/baz" load ../../plugins/available/go.plugin From 5faeb6dc5c80946c31d046bd1d03782d0c8cdd58 Mon Sep 17 00:00:00 2001 From: cornfeedhobo Date: Sat, 11 Apr 2020 16:27:17 -0500 Subject: [PATCH 32/89] add simple fasd plugin --- plugins/available/fasd.plugin.bash | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 plugins/available/fasd.plugin.bash diff --git a/plugins/available/fasd.plugin.bash b/plugins/available/fasd.plugin.bash new file mode 100644 index 00000000..0a1ae918 --- /dev/null +++ b/plugins/available/fasd.plugin.bash @@ -0,0 +1,4 @@ +cite about-plugin +about-plugin 'load fasd, if you are using it' + +_command_exists fasd && eval $(fasd --init auto) From de307f43cc47052da97d31a4565643a7d366b819 Mon Sep 17 00:00:00 2001 From: Matthew Adams Date: Sun, 12 Apr 2020 11:19:35 -0500 Subject: [PATCH 33/89] fix uuid behavior for linux --- aliases/available/kubectl.aliases.bash | 2 +- aliases/available/uuidgen.aliases.bash | 15 ++++++++++----- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/aliases/available/kubectl.aliases.bash b/aliases/available/kubectl.aliases.bash index 0322c931..7022820f 100644 --- a/aliases/available/kubectl.aliases.bash +++ b/aliases/available/kubectl.aliases.bash @@ -18,7 +18,7 @@ function _set_pkg_aliases() alias kcdn='kubectl describe node' alias kcgpan='kubectl get pods --all-namespaces' alias kcgdan='kubectl get deployments --all-namespaces' - alias kcnetshoot='kubectl run --generator=run-pod/v1 netshoot-$(uuidgen | tr A-Z a-z | sed 's/-//g') --rm -i --tty --image nicolaka/netshoot -- /bin/bash' + alias kcnetshoot='kubectl run --generator=run-pod/v1 netshoot-$(date +%s) --rm -i --tty --image nicolaka/netshoot -- /bin/bash' fi } diff --git a/aliases/available/uuidgen.aliases.bash b/aliases/available/uuidgen.aliases.bash index fec5a2b8..a427a4eb 100644 --- a/aliases/available/uuidgen.aliases.bash +++ b/aliases/available/uuidgen.aliases.bash @@ -1,6 +1,11 @@ -cite 'uuid-alias' -about-alias 'uuidgen aliases' +# cite 'uuid-alias' +# about-alias 'uuidgen aliases' -alias uuidu="uuidgen" -alias uuidl="uuidgen | tr '[:upper:]' '[:lower:]'" -alias uuid=uuidl # because upper case is like YELLING +if [ "$(uuid 2>/dev/null)" != "" ]; then # Linux + alias uuidu="uuid | tr '[:lower:]' '[:upper:]'" + alias uuidl=uuid +elif [ "$(uuidgen 2>/dev/null)" != "" ]; then # macOS/BSD + alias uuidu="uuidgen" + alias uuid="uuidgen | tr '[:upper:]' '[:lower:]'" # because upper case is like YELLING + alias uuidl=uuid +fi From b220c0e7441ab4e55c514b9d2348c103de0c4cd7 Mon Sep 17 00:00:00 2001 From: Uco Mesdag Date: Mon, 13 Apr 2020 02:30:28 +0200 Subject: [PATCH 34/89] Plugin to toggle sudo before your current or last command --- plugins/available/sudo.plugin.bash | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 plugins/available/sudo.plugin.bash diff --git a/plugins/available/sudo.plugin.bash b/plugins/available/sudo.plugin.bash new file mode 100644 index 00000000..f18219b5 --- /dev/null +++ b/plugins/available/sudo.plugin.bash @@ -0,0 +1,15 @@ +cite about-plugin +about-plugin 'Toggle sudo before your current or last command' + +function sudo-command-line() { + [[ ${#READLINE_LINE} -eq 0 ]] && READLINE_LINE=$(fc -l -n -1 | xargs) + if [[ $READLINE_LINE == sudo\ * ]]; then + READLINE_LINE="${READLINE_LINE#sudo }" + else + READLINE_LINE="sudo $READLINE_LINE" + fi + READLINE_POINT=${#READLINE_LINE} +} + +# Define shortcut keys: [Esc] [Esc] +bind -x '"\e\e": sudo-command-line' From e73f6dbc620dfae27d186a98caa8f066df06ebe8 Mon Sep 17 00:00:00 2001 From: Uco Mesdag Date: Mon, 13 Apr 2020 02:37:24 +0200 Subject: [PATCH 35/89] Reworded the about --- plugins/available/sudo.plugin.bash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/available/sudo.plugin.bash b/plugins/available/sudo.plugin.bash index f18219b5..26c53853 100644 --- a/plugins/available/sudo.plugin.bash +++ b/plugins/available/sudo.plugin.bash @@ -1,5 +1,5 @@ cite about-plugin -about-plugin 'Toggle sudo before your current or last command' +about-plugin 'Toggle sudo at the beginning of the current or the previous command' function sudo-command-line() { [[ ${#READLINE_LINE} -eq 0 ]] && READLINE_LINE=$(fc -l -n -1 | xargs) From 860f9b83e62acb1a2da5f67fc81803287824df14 Mon Sep 17 00:00:00 2001 From: Wabri Date: Mon, 13 Apr 2020 12:48:29 +0200 Subject: [PATCH 36/89] Add (alias): create bashit to separate from general Instead of put all together in one alias source, it's better to create two different files and separate different features. --- aliases/available/bashit.aliases.bash | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 aliases/available/bashit.aliases.bash diff --git a/aliases/available/bashit.aliases.bash b/aliases/available/bashit.aliases.bash new file mode 100644 index 00000000..b11074be --- /dev/null +++ b/aliases/available/bashit.aliases.bash @@ -0,0 +1,24 @@ +cite about-alias +about-alias 'bashit aliases' + +# Common misspellings of bash-it +alias shit='bash-it' +alias batshit='bash-it' +alias bashit='bash-it' +alias batbsh='bash-it' +alias babsh='bash-it' +alias bash_it='bash-it' +alias bash_ti='bash-it' + +# Additional bash-it aliases for help/show +alias bshsa='bash-it show aliases' +alias bshsc='bash-it show completions' +alias bshsp='bash-it show plugins' +alias bshha='bash-it help aliases' +alias bshhc='bash-it help completions' +alias bshhp='bash-it help plugins' +alias bshsch="bash-it search" +alias bshenp="bash-it enable plugin" +alias bshena="bash-it enable alias" +alias bshenc="bash-it enable completion" + From 74f053db9d0d9dfa307290dcd3b812e1f2793c75 Mon Sep 17 00:00:00 2001 From: Wabri Date: Mon, 13 Apr 2020 12:51:20 +0200 Subject: [PATCH 37/89] Remove (alias): bash_it alias is no more required in general The bash_it alias are exported to the relative source, so is no more required in the general alias. --- aliases/available/general.aliases.bash | 21 --------------------- 1 file changed, 21 deletions(-) diff --git a/aliases/available/general.aliases.bash b/aliases/available/general.aliases.bash index 542b76cd..1b35a1ab 100644 --- a/aliases/available/general.aliases.bash +++ b/aliases/available/general.aliases.bash @@ -75,27 +75,6 @@ fi alias md='mkdir -p' alias rd='rmdir' -# Common misspellings of bash-it -alias shit='bash-it' -alias batshit='bash-it' -alias bashit='bash-it' -alias batbsh='bash-it' -alias babsh='bash-it' -alias bash_it='bash-it' -alias bash_ti='bash-it' - -# Additional bash-it aliases for help/show -alias bshsa='bash-it show aliases' -alias bshsc='bash-it show completions' -alias bshsp='bash-it show plugins' -alias bshha='bash-it help aliases' -alias bshhc='bash-it help completions' -alias bshhp='bash-it help plugins' -alias bshsch="bash-it search" -alias bshenp="bash-it enable plugin" -alias bshena="bash-it enable alias" -alias bshenc="bash-it enable completion" - # Shorten extract alias xt="extract" From 023b4c3c3ba121ba00cff8f41c5358abc216211e Mon Sep 17 00:00:00 2001 From: Nils Winkler Date: Mon, 13 Apr 2020 12:08:33 +0200 Subject: [PATCH 38/89] Migrated bats-support to bats-core project repo, v0.3.0 --- .gitmodules | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitmodules b/.gitmodules index 095a6a5e..f805758f 100644 --- a/.gitmodules +++ b/.gitmodules @@ -3,7 +3,8 @@ url = https://github.com/bats-core/bats-core [submodule "test_lib/bats-support"] path = test_lib/bats-support - url = https://github.com/ztombol/bats-support + url = https://github.com/bats-core/bats-support + branch = tags/v0.3.0 [submodule "test_lib/bats-assert"] path = test_lib/bats-assert url = https://github.com/ztombol/bats-assert From 1dfaf47040f4d8a9a2448675fa3db60c2f5dd6ab Mon Sep 17 00:00:00 2001 From: Nils Winkler Date: Mon, 13 Apr 2020 12:38:57 +0200 Subject: [PATCH 39/89] Updated bats-support library to v0.3.0 commit --- test_lib/bats-support | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test_lib/bats-support b/test_lib/bats-support index 004e7076..24a72e14 160000 --- a/test_lib/bats-support +++ b/test_lib/bats-support @@ -1 +1 @@ -Subproject commit 004e707638eedd62e0481e8cdc9223ad471f12ee +Subproject commit 24a72e14349690bcbf7c151b9d2d1cdd32d36eb1 From 9f5f762869c07f583365297b4ee607900b4c27e4 Mon Sep 17 00:00:00 2001 From: Nils Winkler Date: Mon, 13 Apr 2020 12:42:18 +0200 Subject: [PATCH 40/89] Updated bats-assert to v2.0.0 --- .gitmodules | 3 ++- test_lib/bats-assert | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.gitmodules b/.gitmodules index f805758f..34ffd55d 100644 --- a/.gitmodules +++ b/.gitmodules @@ -7,7 +7,8 @@ branch = tags/v0.3.0 [submodule "test_lib/bats-assert"] path = test_lib/bats-assert - url = https://github.com/ztombol/bats-assert + url = https://github.com/bats-core/bats-assert + branch = tags/v2.0.0 [submodule "test_lib/bats-file"] path = test_lib/bats-file url = https://github.com/ztombol/bats-file diff --git a/test_lib/bats-assert b/test_lib/bats-assert index 9f88b420..d750c5a1 160000 --- a/test_lib/bats-assert +++ b/test_lib/bats-assert @@ -1 +1 @@ -Subproject commit 9f88b4207da750093baabc4e3f41bf68f0dd3630 +Subproject commit d750c5a1b44bf6fc96726aea76f4621db5fd602f From dfeb72d6aa5f3b72f5d8ccecaf2748b17d220e4e Mon Sep 17 00:00:00 2001 From: Uco Mesdag Date: Mon, 13 Apr 2020 13:35:52 +0200 Subject: [PATCH 41/89] Added function metadata and bash version check --- plugins/available/sudo.plugin.bash | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/plugins/available/sudo.plugin.bash b/plugins/available/sudo.plugin.bash index 26c53853..eb155daa 100644 --- a/plugins/available/sudo.plugin.bash +++ b/plugins/available/sudo.plugin.bash @@ -1,7 +1,10 @@ cite about-plugin -about-plugin 'Toggle sudo at the beginning of the current or the previous command' +about-plugin 'Toggle sudo at the beginning of the current or the previous command by hitting the ESC key twice' function sudo-command-line() { + about "toggle sudo at the beginning of the current or the previous command by hitting the ESC key twice" + group "sudo" + [[ ${#READLINE_LINE} -eq 0 ]] && READLINE_LINE=$(fc -l -n -1 | xargs) if [[ $READLINE_LINE == sudo\ * ]]; then READLINE_LINE="${READLINE_LINE#sudo }" @@ -12,4 +15,8 @@ function sudo-command-line() { } # Define shortcut keys: [Esc] [Esc] -bind -x '"\e\e": sudo-command-line' + +# Readline library requires bash version 4 or later +if [ "${BASH_VERSINFO}" -ge 4 ]; then + bind -x '"\e\e": sudo-command-line' +fi From c6e76fe4ee4630e132008e4bbe85791b5b056888 Mon Sep 17 00:00:00 2001 From: Matthew Adams Date: Mon, 13 Apr 2020 07:50:12 -0500 Subject: [PATCH 42/89] address review comments --- aliases/available/kubectl.aliases.bash | 10 +++++----- aliases/available/uuidgen.aliases.bash | 8 ++++---- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/aliases/available/kubectl.aliases.bash b/aliases/available/kubectl.aliases.bash index 7022820f..9ce923a0 100644 --- a/aliases/available/kubectl.aliases.bash +++ b/aliases/available/kubectl.aliases.bash @@ -5,12 +5,11 @@ 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' + if _command_exists 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' @@ -18,8 +17,9 @@ function _set_pkg_aliases() alias kcdn='kubectl describe node' alias kcgpan='kubectl get pods --all-namespaces' alias kcgdan='kubectl get deployments --all-namespaces' + # launches a disposable netshoot pod in the k8s cluster alias kcnetshoot='kubectl run --generator=run-pod/v1 netshoot-$(date +%s) --rm -i --tty --image nicolaka/netshoot -- /bin/bash' - fi + fi } _set_pkg_aliases diff --git a/aliases/available/uuidgen.aliases.bash b/aliases/available/uuidgen.aliases.bash index a427a4eb..aada05fb 100644 --- a/aliases/available/uuidgen.aliases.bash +++ b/aliases/available/uuidgen.aliases.bash @@ -1,10 +1,10 @@ -# cite 'uuid-alias' -# about-alias 'uuidgen aliases' +cite 'uuid-alias' +about-alias 'uuidgen aliases' -if [ "$(uuid 2>/dev/null)" != "" ]; then # Linux +if _command_exists uuid; then # Linux alias uuidu="uuid | tr '[:lower:]' '[:upper:]'" alias uuidl=uuid -elif [ "$(uuidgen 2>/dev/null)" != "" ]; then # macOS/BSD +elif _command_exists uuidgen; then # macOS/BSD alias uuidu="uuidgen" alias uuid="uuidgen | tr '[:upper:]' '[:lower:]'" # because upper case is like YELLING alias uuidl=uuid From 9ccee2878cf0c3633318dddd95ca0bc5894a956a Mon Sep 17 00:00:00 2001 From: Wabri Date: Wed, 15 Apr 2020 09:18:13 +0200 Subject: [PATCH 43/89] Fix (aliases): source bash-it alias in general This can let separate the bash-it alias from the system general one --- aliases/available/{bashit.aliases.bash => bash_it.aliases.bash} | 2 +- aliases/available/general.aliases.bash | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) rename aliases/available/{bashit.aliases.bash => bash_it.aliases.bash} (95%) diff --git a/aliases/available/bashit.aliases.bash b/aliases/available/bash_it.aliases.bash similarity index 95% rename from aliases/available/bashit.aliases.bash rename to aliases/available/bash_it.aliases.bash index b11074be..e26abd5a 100644 --- a/aliases/available/bashit.aliases.bash +++ b/aliases/available/bash_it.aliases.bash @@ -1,5 +1,5 @@ cite about-alias -about-alias 'bashit aliases' +about-alias 'Bash-it aliases' # Common misspellings of bash-it alias shit='bash-it' diff --git a/aliases/available/general.aliases.bash b/aliases/available/general.aliases.bash index 1b35a1ab..2ab1c77a 100644 --- a/aliases/available/general.aliases.bash +++ b/aliases/available/general.aliases.bash @@ -92,3 +92,5 @@ catt() { fi done } + +source "$BASH_IT/aliases/available/bash-it.aliases.bash" From 4b2a0513f2dd4e14b23f8e9c082ced44637681a4 Mon Sep 17 00:00:00 2001 From: Wabri Date: Thu, 16 Apr 2020 12:30:52 +0200 Subject: [PATCH 44/89] Update (alias): change the about-alias description The bash-it alias description is now more clear --- .../available/{bash_it.aliases.bash => bash-it.aliases.bash} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename aliases/available/{bash_it.aliases.bash => bash-it.aliases.bash} (85%) diff --git a/aliases/available/bash_it.aliases.bash b/aliases/available/bash-it.aliases.bash similarity index 85% rename from aliases/available/bash_it.aliases.bash rename to aliases/available/bash-it.aliases.bash index e26abd5a..2461e830 100644 --- a/aliases/available/bash_it.aliases.bash +++ b/aliases/available/bash-it.aliases.bash @@ -1,5 +1,5 @@ cite about-alias -about-alias 'Bash-it aliases' +about-alias 'Aliases for the bash-it command (those aliases are also included with general aliases)' # Common misspellings of bash-it alias shit='bash-it' From 0b9c37f5d1e5c4b78981d9e4db63fe55bfcaf338 Mon Sep 17 00:00:00 2001 From: Wabri Date: Thu, 16 Apr 2020 12:32:52 +0200 Subject: [PATCH 45/89] Add (alias): create a comment above the source of bash-it To be more clear it was necessary to add a comment above source bash-it to explain what is the pourpose of doing that. --- aliases/available/general.aliases.bash | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/aliases/available/general.aliases.bash b/aliases/available/general.aliases.bash index 2ab1c77a..d628e71d 100644 --- a/aliases/available/general.aliases.bash +++ b/aliases/available/general.aliases.bash @@ -93,4 +93,8 @@ catt() { done } +# The bash-it aliases was move to bash-it.aliases.bash file. The intent of this +# is to maintain the script readable and less bloated. If you don't need to use +# those aliases, but you want the bash-it shortcuts, you can disable this +# script and enable the bash-it. source "$BASH_IT/aliases/available/bash-it.aliases.bash" From 83fbfcf88a692fd3b578b7907f7b6f863a5d29ee Mon Sep 17 00:00:00 2001 From: Alex Thiessen Date: Sat, 18 Apr 2020 18:39:29 +0200 Subject: [PATCH 46/89] travis: Remove obsolete `sudo` `sudo` key is deprecated, refer to https://docs.travis-ci.com/user/reference/overview/#deprecated-virtualization-environments. --- .travis.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index b3fa2728..d10607db 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,4 +1,3 @@ -sudo: false script: test/run language: c os: From 44ddc583340abe8429d07438795539311eb70feb Mon Sep 17 00:00:00 2001 From: Alex Thiessen Date: Sat, 18 Apr 2020 18:39:35 +0200 Subject: [PATCH 47/89] travis: Update language from `c` to `shell` Be more precise as to what language is used; full list is found here: https://config.travis-ci.com/ref/language. --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index d10607db..198a72c0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,5 @@ script: test/run -language: c +language: shell os: - linux - osx From 576f2b37acf290ff44c034fd3c7f6fa3971e3b86 Mon Sep 17 00:00:00 2001 From: Alex Thiessen Date: Sat, 18 Apr 2020 18:39:36 +0200 Subject: [PATCH 48/89] travis: Switch build matrix from `os` to `jobs` There are a couple ways to declare a build matrix in Travis CI, refer to https://docs.travis-ci.com/user/build-matrix. Since upcoming commits will add more ways to run tests, switch the build matrix from simple OS variation to a more powerful list of jobs. --- .travis.yml | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 198a72c0..a5d5806f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,7 @@ -script: test/run language: shell -os: - - linux - - osx + +jobs: + - script: test/run + os: linux + - script: test/run + os: osx From b75b7697198b4eaa02c44d6290cb3f1aa1c046e1 Mon Sep 17 00:00:00 2001 From: Alex Thiessen Date: Sat, 18 Apr 2020 18:43:10 +0200 Subject: [PATCH 49/89] travis: Refactor jobs to use inheritance Since the existing jobs are similar (currently, the `script` keys are same), move the equal parts to a new shared key to have them in one place. The new map will receive more content in upcoming commits. --- .travis.yml | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index a5d5806f..a35f07a0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,15 @@ +# YAML anchors need to appear first. +# Keys starting with an underscore are the custom ones, refer to +# https://docs.travis-ci.com/user/build-config-yaml#private-keys-as-yaml-anchors-and-aliases-and-external-tooling + +_native_job: &native_job + script: | + test/run + language: shell jobs: - - script: test/run + - <<: *native_job os: linux - - script: test/run + - <<: *native_job os: osx From f698261487f02ae6a6f51303a68a74e17ffaa460 Mon Sep 17 00:00:00 2001 From: Nils Winkler Date: Sun, 19 Apr 2020 17:39:50 +0200 Subject: [PATCH 50/89] Updated to https://github.com/tralston/bats-file v0.3.0 --- .gitmodules | 3 ++- test/plugins/base.plugin.bats | 2 +- test_lib/bats-file | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.gitmodules b/.gitmodules index 34ffd55d..13532af5 100644 --- a/.gitmodules +++ b/.gitmodules @@ -11,4 +11,5 @@ branch = tags/v2.0.0 [submodule "test_lib/bats-file"] path = test_lib/bats-file - url = https://github.com/ztombol/bats-file + url = https://github.com/tralston/bats-file + branch = tags/v0.3.0 diff --git a/test/plugins/base.plugin.bats b/test/plugins/base.plugin.bats index cca47497..731dc227 100755 --- a/test/plugins/base.plugin.bats +++ b/test/plugins/base.plugin.bats @@ -39,7 +39,7 @@ load ../../plugins/available/base.plugin mkcd "${dir_name}" assert_success - assert_file_exist "${BASH_IT_ROOT}/${dir_name}" + assert_dir_exist "${BASH_IT_ROOT}/${dir_name}" assert_equal $(pwd) "${BASH_IT_ROOT}/${dir_name}" } diff --git a/test_lib/bats-file b/test_lib/bats-file index 2fddb2b8..c128a1de 160000 --- a/test_lib/bats-file +++ b/test_lib/bats-file @@ -1 +1 @@ -Subproject commit 2fddb2b831d65cdf2e411f3b47f4677fbb15729c +Subproject commit c128a1de53ba4a811835af410ce427f1049e2d7f From 4ad790aa478ee8c7b7b36b11080e774cd13c3546 Mon Sep 17 00:00:00 2001 From: Alex Thiessen Date: Mon, 20 Apr 2020 21:01:49 +0200 Subject: [PATCH 51/89] editorconfig: Add `.git*` section Configuration files of `git` are managed by the tool and thus are tab-indented. If a developer happens to edit such a file manually, the indentation would become inconsistent. Add an explicit section for such files and set the indentation to tabs. --- .editorconfig | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.editorconfig b/.editorconfig index 87e50155..e302645a 100755 --- a/.editorconfig +++ b/.editorconfig @@ -10,3 +10,6 @@ insert_final_newline = true [*.md] trim_trailing_whitespace = false + +[.git*] +indent_style = tab From c53cc9f1433df5f52e58b0c47ca4d716d2159e34 Mon Sep 17 00:00:00 2001 From: Nils Winkler Date: Mon, 13 Apr 2020 12:58:44 +0200 Subject: [PATCH 52/89] Updated bats-core to latest version --- test_lib/bats-core | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test_lib/bats-core b/test_lib/bats-core index 85388685..da4cefe3 160000 --- a/test_lib/bats-core +++ b/test_lib/bats-core @@ -1 +1 @@ -Subproject commit 85388685632f85d5a1c32e6bca2deec401964cf7 +Subproject commit da4cefe3010145d2eb699125a4b1efdff4409f3b From 3093273425893b76c17a0b90dffe5d2c428bb67d Mon Sep 17 00:00:00 2001 From: Nils Winkler Date: Mon, 13 Apr 2020 13:08:50 +0200 Subject: [PATCH 53/89] Updated rsync command to work with latest version of bats-core --- test/bash_it/bash_it.bats | 2 +- test/completion/bash-it.completion.bats | 2 +- test/install/install.bats | 2 +- test/install/uninstall.bats | 2 +- test/lib/helpers.bats | 2 +- test/lib/search.bats | 2 +- test/lib/utilities.bats | 2 +- test/plugins/ruby.plugin.bats | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/test/bash_it/bash_it.bats b/test/bash_it/bash_it.bats index 886453dd..721e8b99 100644 --- a/test/bash_it/bash_it.bats +++ b/test/bash_it/bash_it.bats @@ -10,7 +10,7 @@ function local_setup { echo "Lib: $lib_directory" # Use rsync to copy Bash-it to the temp folder # rsync is faster than cp, since we can exclude the large ".git" folder - rsync -qavrKL -d --delete-excluded --exclude=.git $lib_directory/../../.. "$BASH_IT" + rsync -qavrKL -d --delete-excluded --exclude=.git $lib_directory/../../../.. "$BASH_IT" rm -rf "$BASH_IT"/enabled rm -rf "$BASH_IT"/aliases/enabled diff --git a/test/completion/bash-it.completion.bats b/test/completion/bash-it.completion.bats index f35b180b..e08ec55d 100644 --- a/test/completion/bash-it.completion.bats +++ b/test/completion/bash-it.completion.bats @@ -9,7 +9,7 @@ function local_setup { lib_directory="$(cd "$(dirname "$0")" && pwd)" # Use rsync to copy Bash-it to the temp folder # rsync is faster than cp, since we can exclude the large ".git" folder - rsync -qavrKL -d --delete-excluded --exclude=.git $lib_directory/../../.. "$BASH_IT" + rsync -qavrKL -d --delete-excluded --exclude=.git $lib_directory/../../../.. "$BASH_IT" rm -rf "$BASH_IT"/enabled rm -rf "$BASH_IT"/aliases/enabled diff --git a/test/install/install.bats b/test/install/install.bats index 7e971d1f..7ee91a65 100644 --- a/test/install/install.bats +++ b/test/install/install.bats @@ -18,7 +18,7 @@ function local_setup { lib_directory="$(cd "$(dirname "$0")" && pwd)" # Use rsync to copy Bash-it to the temp folder # rsync is faster than cp, since we can exclude the large ".git" folder - rsync -qavrKL -d --delete-excluded --exclude=.git $lib_directory/../../.. "$BASH_IT" + rsync -qavrKL -d --delete-excluded --exclude=.git $lib_directory/../../../.. "$BASH_IT" rm -rf "$BASH_IT"/enabled rm -rf "$BASH_IT"/aliases/enabled diff --git a/test/install/uninstall.bats b/test/install/uninstall.bats index d71ac06a..a65588df 100644 --- a/test/install/uninstall.bats +++ b/test/install/uninstall.bats @@ -18,7 +18,7 @@ function local_setup { lib_directory="$(cd "$(dirname "$0")" && pwd)" # Use rsync to copy Bash-it to the temp folder # rsync is faster than cp, since we can exclude the large ".git" folder - rsync -qavrKL -d --delete-excluded --exclude=.git $lib_directory/../../.. "$BASH_IT" + rsync -qavrKL -d --delete-excluded --exclude=.git $lib_directory/../../../.. "$BASH_IT" rm -rf "$BASH_IT"/enabled rm -rf "$BASH_IT"/aliases/enabled diff --git a/test/lib/helpers.bats b/test/lib/helpers.bats index 6c4f706a..bb5846e8 100644 --- a/test/lib/helpers.bats +++ b/test/lib/helpers.bats @@ -15,7 +15,7 @@ function local_setup { lib_directory="$(cd "$(dirname "$0")" && pwd)" # Use rsync to copy Bash-it to the temp folder # rsync is faster than cp, since we can exclude the large ".git" folder - rsync -qavrKL -d --delete-excluded --exclude=.git $lib_directory/../../.. "$BASH_IT" + rsync -qavrKL -d --delete-excluded --exclude=.git $lib_directory/../../../.. "$BASH_IT" rm -rf "$BASH_IT"/enabled rm -rf "$BASH_IT"/aliases/enabled diff --git a/test/lib/search.bats b/test/lib/search.bats index 5bbc8207..4bc8c6a2 100644 --- a/test/lib/search.bats +++ b/test/lib/search.bats @@ -22,7 +22,7 @@ function local_setup { lib_directory="$(cd "$(dirname "$0")" && pwd)" # Use rsync to copy Bash-it to the temp folder # rsync is faster than cp, since we can exclude the large ".git" folder - rsync -qavrKL -d --delete-excluded --exclude=.git $lib_directory/../../.. "$BASH_IT" + rsync -qavrKL -d --delete-excluded --exclude=.git $lib_directory/../../../.. "$BASH_IT" rm -rf "$BASH_IT"/enabled rm -rf "$BASH_IT"/aliases/enabled diff --git a/test/lib/utilities.bats b/test/lib/utilities.bats index be21fa40..aeb74275 100644 --- a/test/lib/utilities.bats +++ b/test/lib/utilities.bats @@ -13,7 +13,7 @@ function local_setup { lib_directory="$(cd "$(dirname "$0")" && pwd)" # Use rsync to copy Bash-it to the temp folder # rsync is faster than cp, since we can exclude the large ".git" folder - rsync -qavrKL -d --delete-excluded --exclude=.git $lib_directory/../../.. "$BASH_IT" + rsync -qavrKL -d --delete-excluded --exclude=.git $lib_directory/../../../.. "$BASH_IT" rm -rf "$BASH_IT"/enabled rm -rf "$BASH_IT"/aliases/enabled diff --git a/test/plugins/ruby.plugin.bats b/test/plugins/ruby.plugin.bats index ab11bda1..d42d0a13 100755 --- a/test/plugins/ruby.plugin.bats +++ b/test/plugins/ruby.plugin.bats @@ -10,7 +10,7 @@ function local_setup { lib_directory="$(cd "$(dirname "$0")" && pwd)" # Use rsync to copy Bash-it to the temp folder # rsync is faster than cp, since we can exclude the large ".git" folder - rsync -qavrKL -d --delete-excluded --exclude=.git $lib_directory/../../.. "$BASH_IT" + rsync -qavrKL -d --delete-excluded --exclude=.git $lib_directory/../../../.. "$BASH_IT" rm -rf "$BASH_IT"/enabled rm -rf "$BASH_IT"/aliases/enabled From 34993f5da3230f5fe8658a70e9f0757491c7093c Mon Sep 17 00:00:00 2001 From: Nils Winkler Date: Mon, 13 Apr 2020 20:20:33 +0200 Subject: [PATCH 54/89] Excluding enabled directory when setting up test fixtures --- test/bash_it/bash_it.bats | 2 +- test/completion/bash-it.completion.bats | 2 +- test/install/install.bats | 2 +- test/install/uninstall.bats | 2 +- test/lib/helpers.bats | 2 +- test/lib/search.bats | 2 +- test/lib/utilities.bats | 2 +- test/plugins/ruby.plugin.bats | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/test/bash_it/bash_it.bats b/test/bash_it/bash_it.bats index 721e8b99..95bad253 100644 --- a/test/bash_it/bash_it.bats +++ b/test/bash_it/bash_it.bats @@ -10,7 +10,7 @@ function local_setup { echo "Lib: $lib_directory" # Use rsync to copy Bash-it to the temp folder # rsync is faster than cp, since we can exclude the large ".git" folder - rsync -qavrKL -d --delete-excluded --exclude=.git $lib_directory/../../../.. "$BASH_IT" + rsync -qavrKL -d --delete-excluded --exclude=.git --exclude=enabled $lib_directory/../../../.. "$BASH_IT" rm -rf "$BASH_IT"/enabled rm -rf "$BASH_IT"/aliases/enabled diff --git a/test/completion/bash-it.completion.bats b/test/completion/bash-it.completion.bats index e08ec55d..9b111512 100644 --- a/test/completion/bash-it.completion.bats +++ b/test/completion/bash-it.completion.bats @@ -9,7 +9,7 @@ function local_setup { lib_directory="$(cd "$(dirname "$0")" && pwd)" # Use rsync to copy Bash-it to the temp folder # rsync is faster than cp, since we can exclude the large ".git" folder - rsync -qavrKL -d --delete-excluded --exclude=.git $lib_directory/../../../.. "$BASH_IT" + rsync -qavrKL -d --delete-excluded --exclude=.git --exclude=enabled $lib_directory/../../../.. "$BASH_IT" rm -rf "$BASH_IT"/enabled rm -rf "$BASH_IT"/aliases/enabled diff --git a/test/install/install.bats b/test/install/install.bats index 7ee91a65..2a754e42 100644 --- a/test/install/install.bats +++ b/test/install/install.bats @@ -18,7 +18,7 @@ function local_setup { lib_directory="$(cd "$(dirname "$0")" && pwd)" # Use rsync to copy Bash-it to the temp folder # rsync is faster than cp, since we can exclude the large ".git" folder - rsync -qavrKL -d --delete-excluded --exclude=.git $lib_directory/../../../.. "$BASH_IT" + rsync -qavrKL -d --delete-excluded --exclude=.git --exclude=enabled $lib_directory/../../../.. "$BASH_IT" rm -rf "$BASH_IT"/enabled rm -rf "$BASH_IT"/aliases/enabled diff --git a/test/install/uninstall.bats b/test/install/uninstall.bats index a65588df..315c8209 100644 --- a/test/install/uninstall.bats +++ b/test/install/uninstall.bats @@ -18,7 +18,7 @@ function local_setup { lib_directory="$(cd "$(dirname "$0")" && pwd)" # Use rsync to copy Bash-it to the temp folder # rsync is faster than cp, since we can exclude the large ".git" folder - rsync -qavrKL -d --delete-excluded --exclude=.git $lib_directory/../../../.. "$BASH_IT" + rsync -qavrKL -d --delete-excluded --exclude=.git --exclude=enabled $lib_directory/../../../.. "$BASH_IT" rm -rf "$BASH_IT"/enabled rm -rf "$BASH_IT"/aliases/enabled diff --git a/test/lib/helpers.bats b/test/lib/helpers.bats index bb5846e8..ef5ed182 100644 --- a/test/lib/helpers.bats +++ b/test/lib/helpers.bats @@ -15,7 +15,7 @@ function local_setup { lib_directory="$(cd "$(dirname "$0")" && pwd)" # Use rsync to copy Bash-it to the temp folder # rsync is faster than cp, since we can exclude the large ".git" folder - rsync -qavrKL -d --delete-excluded --exclude=.git $lib_directory/../../../.. "$BASH_IT" + rsync -qavrKL -d --delete-excluded --exclude=.git --exclude=enabled $lib_directory/../../../.. "$BASH_IT" rm -rf "$BASH_IT"/enabled rm -rf "$BASH_IT"/aliases/enabled diff --git a/test/lib/search.bats b/test/lib/search.bats index 4bc8c6a2..e7e8b4a8 100644 --- a/test/lib/search.bats +++ b/test/lib/search.bats @@ -22,7 +22,7 @@ function local_setup { lib_directory="$(cd "$(dirname "$0")" && pwd)" # Use rsync to copy Bash-it to the temp folder # rsync is faster than cp, since we can exclude the large ".git" folder - rsync -qavrKL -d --delete-excluded --exclude=.git $lib_directory/../../../.. "$BASH_IT" + rsync -qavrKL -d --delete-excluded --exclude=.git --exclude=enabled $lib_directory/../../../.. "$BASH_IT" rm -rf "$BASH_IT"/enabled rm -rf "$BASH_IT"/aliases/enabled diff --git a/test/lib/utilities.bats b/test/lib/utilities.bats index aeb74275..2bf415fb 100644 --- a/test/lib/utilities.bats +++ b/test/lib/utilities.bats @@ -13,7 +13,7 @@ function local_setup { lib_directory="$(cd "$(dirname "$0")" && pwd)" # Use rsync to copy Bash-it to the temp folder # rsync is faster than cp, since we can exclude the large ".git" folder - rsync -qavrKL -d --delete-excluded --exclude=.git $lib_directory/../../../.. "$BASH_IT" + rsync -qavrKL -d --delete-excluded --exclude=.git --exclude=enabled $lib_directory/../../../.. "$BASH_IT" rm -rf "$BASH_IT"/enabled rm -rf "$BASH_IT"/aliases/enabled diff --git a/test/plugins/ruby.plugin.bats b/test/plugins/ruby.plugin.bats index d42d0a13..62d0e938 100755 --- a/test/plugins/ruby.plugin.bats +++ b/test/plugins/ruby.plugin.bats @@ -10,7 +10,7 @@ function local_setup { lib_directory="$(cd "$(dirname "$0")" && pwd)" # Use rsync to copy Bash-it to the temp folder # rsync is faster than cp, since we can exclude the large ".git" folder - rsync -qavrKL -d --delete-excluded --exclude=.git $lib_directory/../../../.. "$BASH_IT" + rsync -qavrKL -d --delete-excluded --exclude=.git --exclude=enabled $lib_directory/../../../.. "$BASH_IT" rm -rf "$BASH_IT"/enabled rm -rf "$BASH_IT"/aliases/enabled From 818a95d79ca42dd3496d3aa669f98d2e85c12d56 Mon Sep 17 00:00:00 2001 From: Nils Winkler Date: Mon, 13 Apr 2020 21:10:50 +0200 Subject: [PATCH 55/89] Refactored test setup code Removed the copy/paste code, moved it into a reusable function that can be called from the `local_setup` function as needed. Also simplified the handling of the $HOME variable since @rico-chet provided a better way of doing this. --- test/bash_it/bash_it.bats | 28 +--------- test/completion/bash-it.completion.bats | 31 +---------- test/install/install.bats | 26 +-------- test/install/uninstall.bats | 26 +-------- test/lib/helpers.bats | 16 +----- test/lib/search.bats | 17 +----- test/lib/utilities.bats | 17 +----- test/plugins/ruby.plugin.bats | 16 +----- test/test_helper.bash | 70 +++++++++++++++++-------- 9 files changed, 56 insertions(+), 191 deletions(-) diff --git a/test/bash_it/bash_it.bats b/test/bash_it/bash_it.bats index 95bad253..af2f15e9 100644 --- a/test/bash_it/bash_it.bats +++ b/test/bash_it/bash_it.bats @@ -4,36 +4,10 @@ load ../test_helper load ../../lib/composure function local_setup { - mkdir -p "$BASH_IT" - lib_directory="$(cd "$(dirname "$0")" && pwd)" - echo "Bi : $BASH_IT" - echo "Lib: $lib_directory" - # Use rsync to copy Bash-it to the temp folder - # rsync is faster than cp, since we can exclude the large ".git" folder - rsync -qavrKL -d --delete-excluded --exclude=.git --exclude=enabled $lib_directory/../../../.. "$BASH_IT" - - rm -rf "$BASH_IT"/enabled - rm -rf "$BASH_IT"/aliases/enabled - rm -rf "$BASH_IT"/completion/enabled - rm -rf "$BASH_IT"/plugins/enabled + setup_test_fixture # Copy the test fixture to the Bash-it folder rsync -a "$BASH_IT/test/fixtures/bash_it/" "$BASH_IT/" - - # Don't pollute the user's actual $HOME directory - # Use a test home directory instead - export BASH_IT_TEST_CURRENT_HOME="${HOME}" - export BASH_IT_TEST_HOME="$(cd "${BASH_IT}/.." && pwd)/BASH_IT_TEST_HOME" - mkdir -p "${BASH_IT_TEST_HOME}" - export HOME="${BASH_IT_TEST_HOME}" -} - -function local_teardown { - export HOME="${BASH_IT_TEST_CURRENT_HOME}" - - rm -rf "${BASH_IT_TEST_HOME}" - - assert_equal "${BASH_IT_TEST_CURRENT_HOME}" "${HOME}" } @test "bash-it: verify that the test fixture is available" { diff --git a/test/completion/bash-it.completion.bats b/test/completion/bash-it.completion.bats index 9b111512..87c697e4 100644 --- a/test/completion/bash-it.completion.bats +++ b/test/completion/bash-it.completion.bats @@ -5,36 +5,7 @@ load ../../lib/composure load ../../completion/available/bash-it.completion function local_setup { - mkdir -p "$BASH_IT" - lib_directory="$(cd "$(dirname "$0")" && pwd)" - # Use rsync to copy Bash-it to the temp folder - # rsync is faster than cp, since we can exclude the large ".git" folder - rsync -qavrKL -d --delete-excluded --exclude=.git --exclude=enabled $lib_directory/../../../.. "$BASH_IT" - - rm -rf "$BASH_IT"/enabled - rm -rf "$BASH_IT"/aliases/enabled - rm -rf "$BASH_IT"/completion/enabled - rm -rf "$BASH_IT"/plugins/enabled - - mkdir -p "$BASH_IT"/enabled - mkdir -p "$BASH_IT"/aliases/enabled - mkdir -p "$BASH_IT"/completion/enabled - mkdir -p "$BASH_IT"/plugins/enabled - - # Don't pollute the user's actual $HOME directory - # Use a test home directory instead - export BASH_IT_TEST_CURRENT_HOME="${HOME}" - export BASH_IT_TEST_HOME="$(cd "${BASH_IT}/.." && pwd)/BASH_IT_TEST_HOME" - mkdir -p "${BASH_IT_TEST_HOME}" - export HOME="${BASH_IT_TEST_HOME}" -} - -function local_teardown { - export HOME="${BASH_IT_TEST_CURRENT_HOME}" - - rm -rf "${BASH_IT_TEST_HOME}" - - assert_equal "${BASH_IT_TEST_CURRENT_HOME}" "${HOME}" + setup_test_fixture } @test "completion bash-it: ensure that the _bash-it-comp function is available" { diff --git a/test/install/install.bats b/test/install/install.bats index 2a754e42..01776f25 100644 --- a/test/install/install.bats +++ b/test/install/install.bats @@ -14,31 +14,7 @@ case $OSTYPE in esac function local_setup { - mkdir -p "$BASH_IT" - lib_directory="$(cd "$(dirname "$0")" && pwd)" - # Use rsync to copy Bash-it to the temp folder - # rsync is faster than cp, since we can exclude the large ".git" folder - rsync -qavrKL -d --delete-excluded --exclude=.git --exclude=enabled $lib_directory/../../../.. "$BASH_IT" - - rm -rf "$BASH_IT"/enabled - rm -rf "$BASH_IT"/aliases/enabled - rm -rf "$BASH_IT"/completion/enabled - rm -rf "$BASH_IT"/plugins/enabled - - # Don't pollute the user's actual $HOME directory - # Use a test home directory instead - export BASH_IT_TEST_CURRENT_HOME="${HOME}" - export BASH_IT_TEST_HOME="$(cd "${BASH_IT}/.." && pwd)/BASH_IT_TEST_HOME" - mkdir -p "${BASH_IT_TEST_HOME}" - export HOME="${BASH_IT_TEST_HOME}" -} - -function local_teardown { - export HOME="${BASH_IT_TEST_CURRENT_HOME}" - - rm -rf "${BASH_IT_TEST_HOME}" - - assert_equal "${BASH_IT_TEST_CURRENT_HOME}" "${HOME}" + setup_test_fixture } @test "install: verify that the install script exists" { diff --git a/test/install/uninstall.bats b/test/install/uninstall.bats index 315c8209..b2439b9d 100644 --- a/test/install/uninstall.bats +++ b/test/install/uninstall.bats @@ -14,31 +14,7 @@ case $OSTYPE in esac function local_setup { - mkdir -p "$BASH_IT" - lib_directory="$(cd "$(dirname "$0")" && pwd)" - # Use rsync to copy Bash-it to the temp folder - # rsync is faster than cp, since we can exclude the large ".git" folder - rsync -qavrKL -d --delete-excluded --exclude=.git --exclude=enabled $lib_directory/../../../.. "$BASH_IT" - - rm -rf "$BASH_IT"/enabled - rm -rf "$BASH_IT"/aliases/enabled - rm -rf "$BASH_IT"/completion/enabled - rm -rf "$BASH_IT"/plugins/enabled - - # Don't pollute the user's actual $HOME directory - # Use a test home directory instead - export BASH_IT_TEST_CURRENT_HOME="${HOME}" - export BASH_IT_TEST_HOME="$(cd "${BASH_IT}/.." && pwd)/BASH_IT_TEST_HOME" - mkdir -p "${BASH_IT_TEST_HOME}" - export HOME="${BASH_IT_TEST_HOME}" -} - -function local_teardown { - export HOME="${BASH_IT_TEST_CURRENT_HOME}" - - rm -rf "${BASH_IT_TEST_HOME}" - - assert_equal "${BASH_IT_TEST_CURRENT_HOME}" "${HOME}" + setup_test_fixture } @test "uninstall: verify that the uninstall script exists" { diff --git a/test/lib/helpers.bats b/test/lib/helpers.bats index ef5ed182..c3f905e7 100644 --- a/test/lib/helpers.bats +++ b/test/lib/helpers.bats @@ -11,21 +11,7 @@ cite _about _param _example _group _author _version load ../../lib/helpers function local_setup { - mkdir -p "$BASH_IT" - lib_directory="$(cd "$(dirname "$0")" && pwd)" - # Use rsync to copy Bash-it to the temp folder - # rsync is faster than cp, since we can exclude the large ".git" folder - rsync -qavrKL -d --delete-excluded --exclude=.git --exclude=enabled $lib_directory/../../../.. "$BASH_IT" - - rm -rf "$BASH_IT"/enabled - rm -rf "$BASH_IT"/aliases/enabled - rm -rf "$BASH_IT"/completion/enabled - rm -rf "$BASH_IT"/plugins/enabled - - mkdir -p "$BASH_IT"/enabled - mkdir -p "$BASH_IT"/aliases/enabled - mkdir -p "$BASH_IT"/completion/enabled - mkdir -p "$BASH_IT"/plugins/enabled + setup_test_fixture } # TODO Create global __is_enabled function diff --git a/test/lib/search.bats b/test/lib/search.bats index e7e8b4a8..da448acc 100644 --- a/test/lib/search.bats +++ b/test/lib/search.bats @@ -18,22 +18,7 @@ cite _about _param _example _group _author _version load ../../lib/helpers function local_setup { - mkdir -p "$BASH_IT" - lib_directory="$(cd "$(dirname "$0")" && pwd)" - # Use rsync to copy Bash-it to the temp folder - # rsync is faster than cp, since we can exclude the large ".git" folder - rsync -qavrKL -d --delete-excluded --exclude=.git --exclude=enabled $lib_directory/../../../.. "$BASH_IT" - - rm -rf "$BASH_IT"/enabled - rm -rf "$BASH_IT"/aliases/enabled - rm -rf "$BASH_IT"/completion/enabled - rm -rf "$BASH_IT"/plugins/enabled - rm -rf "$BASH_IT"/tmp/cache - - mkdir -p "$BASH_IT"/enabled - mkdir -p "$BASH_IT"/aliases/enabled - mkdir -p "$BASH_IT"/completion/enabled - mkdir -p "$BASH_IT"/plugins/enabled + setup_test_fixture export OLD_PATH="$PATH" export PATH="/usr/bin:/bin:/usr/sbin" diff --git a/test/lib/utilities.bats b/test/lib/utilities.bats index 2bf415fb..6e0f4ac7 100644 --- a/test/lib/utilities.bats +++ b/test/lib/utilities.bats @@ -9,22 +9,7 @@ load ../../lib/search cite _about _param _example _group _author _version function local_setup { - mkdir -p "$BASH_IT" - lib_directory="$(cd "$(dirname "$0")" && pwd)" - # Use rsync to copy Bash-it to the temp folder - # rsync is faster than cp, since we can exclude the large ".git" folder - rsync -qavrKL -d --delete-excluded --exclude=.git --exclude=enabled $lib_directory/../../../.. "$BASH_IT" - - rm -rf "$BASH_IT"/enabled - rm -rf "$BASH_IT"/aliases/enabled - rm -rf "$BASH_IT"/completion/enabled - rm -rf "$BASH_IT"/plugins/enabled - rm -rf "$BASH_IT"/tmp/cache - - mkdir -p "$BASH_IT"/enabled - mkdir -p "$BASH_IT"/aliases/enabled - mkdir -p "$BASH_IT"/completion/enabled - mkdir -p "$BASH_IT"/plugins/enabled + setup_test_fixture } function has_match() { diff --git a/test/plugins/ruby.plugin.bats b/test/plugins/ruby.plugin.bats index 62d0e938..a45411e2 100755 --- a/test/plugins/ruby.plugin.bats +++ b/test/plugins/ruby.plugin.bats @@ -6,21 +6,7 @@ load ../../lib/composure load ../../plugins/available/ruby.plugin function local_setup { - mkdir -p "$BASH_IT" - lib_directory="$(cd "$(dirname "$0")" && pwd)" - # Use rsync to copy Bash-it to the temp folder - # rsync is faster than cp, since we can exclude the large ".git" folder - rsync -qavrKL -d --delete-excluded --exclude=.git --exclude=enabled $lib_directory/../../../.. "$BASH_IT" - - rm -rf "$BASH_IT"/enabled - rm -rf "$BASH_IT"/aliases/enabled - rm -rf "$BASH_IT"/completion/enabled - rm -rf "$BASH_IT"/plugins/enabled - - mkdir -p "$BASH_IT"/enabled - mkdir -p "$BASH_IT"/aliases/enabled - mkdir -p "$BASH_IT"/completion/enabled - mkdir -p "$BASH_IT"/plugins/enabled + setup_test_fixture export OLD_PATH="$PATH" export PATH="/usr/bin:/bin:/usr/sbin" diff --git a/test/test_helper.bash b/test/test_helper.bash index cd75f05a..c51e2b53 100644 --- a/test/test_helper.bash +++ b/test/test_helper.bash @@ -6,34 +6,12 @@ unset TODO unset SCM_CHECK unset BASH_IT_AUTOMATIC_RELOAD_AFTER_CONFIG_CHANGE -BASH_IT_TEST_DIR="${BATS_TMPDIR}/.bash_it" - -# guard against executing this block twice due to bats internals -if [ "$BASH_IT_ROOT" != "${BASH_IT_TEST_DIR}/root" ]; then - export BASH_IT_ROOT="${BASH_IT_TEST_DIR}/root" - export BASH_IT=$BASH_IT_TEST_DIR -fi - export TEST_MAIN_DIR="${BATS_TEST_DIRNAME}/.." export TEST_DEPS_DIR="${TEST_DEPS_DIR-${TEST_MAIN_DIR}/../test_lib}" # be independent of git's system configuration export GIT_CONFIG_NOSYSTEM -# Some tools, e.g. `git` use configuration files from the $HOME directory, -# which interferes with our tests. The only way to keep `git` from doing this -# seems to set HOME explicitly to a separate location. -# Refer to https://git-scm.com/docs/git-config#FILES. -unset XDG_CONFIG_HOME -export HOME="${BATS_TMPDIR}/home" -mkdir -p "${HOME}" - -# For `git` tests to run well, user name and email need to be set. -# Refer to https://git-scm.com/docs/git-commit#_commit_information. -# This goes to the test-specific config, due to the $HOME overridden above. -git config --global user.name "John Doe" -git config --global user.email "johndoe@example.com" - load "${TEST_DEPS_DIR}/bats-support/load.bash" load "${TEST_DEPS_DIR}/bats-assert/load.bash" load "${TEST_DEPS_DIR}/bats-file/load.bash" @@ -46,9 +24,56 @@ local_teardown() { true } +# This function sets up a local test fixture, i.e. a completely +# fresh and isolated Bash-it directory. This is done to avoid +# messing with your own Bash-it source directory. +# If you need this, call it in your .bats file's `local_setup` function. +setup_test_fixture() { + mkdir -p "$BASH_IT" + lib_directory="$(cd "$(dirname "$0")" && pwd)" + # Use rsync to copy Bash-it to the temp folder + # rsync is faster than cp, since we can exclude the large ".git" folder + rsync -qavrKL -d --delete-excluded --exclude=.git --exclude=enabled $lib_directory/../../../.. "$BASH_IT" + + rm -rf "$BASH_IT"/enabled + rm -rf "$BASH_IT"/aliases/enabled + rm -rf "$BASH_IT"/completion/enabled + rm -rf "$BASH_IT"/plugins/enabled + + mkdir -p "$BASH_IT"/enabled + mkdir -p "$BASH_IT"/aliases/enabled + mkdir -p "$BASH_IT"/completion/enabled + mkdir -p "$BASH_IT"/plugins/enabled + + # Some tests use the BASH_IT_TEST_HOME variable, e.g. install/uninstall + export BASH_IT_TEST_HOME="$TEST_TEMP_DIR" +} + setup() { + TEST_TEMP_DIR="$(mktemp -d -t 'bash-it-test')" + export TEST_TEMP_DIR + + export BASH_IT_TEST_DIR="${TEST_TEMP_DIR}/.bash_it" + + export BASH_IT_ROOT="${BASH_IT_TEST_DIR}/root" + export BASH_IT=$BASH_IT_TEST_DIR + mkdir -p -- "${BASH_IT_ROOT}" + # Some tools, e.g. `git` use configuration files from the $HOME directory, + # which interferes with our tests. The only way to keep `git` from doing this + # seems to set HOME explicitly to a separate location. + # Refer to https://git-scm.com/docs/git-config#FILES. + unset XDG_CONFIG_HOME + export HOME="${TEST_TEMP_DIR}" + mkdir -p "${HOME}" + + # For `git` tests to run well, user name and email need to be set. + # Refer to https://git-scm.com/docs/git-commit#_commit_information. + # This goes to the test-specific config, due to the $HOME overridden above. + git config --global user.name "John Doe" + git config --global user.email "johndoe@example.com" + local_setup } @@ -56,6 +81,7 @@ teardown() { local_teardown rm -rf "${BASH_IT_TEST_DIR}" + temp_del "${TEST_TEMP_DIR}" } # Fail and display path of the link if it does not exist. Also fails From bc433cd9999cce63bb69ff03e941836a1521a2cd Mon Sep 17 00:00:00 2001 From: Nils Winkler Date: Mon, 13 Apr 2020 21:29:18 +0200 Subject: [PATCH 56/89] Fixing the mktemp function on Linux --- test/test_helper.bash | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/test/test_helper.bash b/test/test_helper.bash index c51e2b53..ece4bd92 100644 --- a/test/test_helper.bash +++ b/test/test_helper.bash @@ -50,7 +50,9 @@ setup_test_fixture() { } setup() { - TEST_TEMP_DIR="$(mktemp -d -t 'bash-it-test')" + # Temporarily using `mktemp` directly, since the bats-file function + # `temp_make` does not run on macOS + TEST_TEMP_DIR="$(mktemp -d -t 'bash-it-test.XXXX')" export TEST_TEMP_DIR export BASH_IT_TEST_DIR="${TEST_TEMP_DIR}/.bash_it" From eb6469096af8d114e53b17b609ecb63e3eba96db Mon Sep 17 00:00:00 2001 From: Nils Winkler Date: Mon, 13 Apr 2020 21:53:10 +0200 Subject: [PATCH 57/89] Added the parallel test execution code from @rico-chet See here: https://github.com/rico-chet/bash-it/blob/cd4a039215ae1f1495d72f5a1cbff504f5598efe/test/run#L22 --- test/run | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/test/run b/test/run index da1aa061..cf71259b 100755 --- a/test/run +++ b/test/run @@ -16,4 +16,26 @@ else test_dirs=( "$1" ) fi -exec $bats_executable ${CI:+--tap} "${test_dirs[@]}" +if command -v parallel &> /dev/null +then + # Expect to run at least on a dual-core CPU; slightly degraded performance + # shouldn't matter otherwise. + declare -i -r test_jobs_default=2 + declare -i -r test_jobs_effective="$( + if [ "${TEST_JOBS:-detect}" = "detect" ] \ + && command -v nproc &> /dev/null + then + nproc + elif [ -n "${TEST_JOBS}" ] \ + && [ "${TEST_JOBS}" != "detect" ] + then + echo "${TEST_JOBS}" + else + echo ${test_jobs_default} + fi + )" + exec "$bats_executable" ${CI:+--tap} --jobs ${test_jobs_effective} \ + "${test_dirs[@]}" +else + exec "$bats_executable" ${CI:+--tap} "${test_dirs[@]}" +fi From 9269c4445dba8e396dd6a91cb7d346185e8ca4ad Mon Sep 17 00:00:00 2001 From: Nils Winkler Date: Mon, 20 Apr 2020 08:53:28 +0200 Subject: [PATCH 58/89] Went back to the bats-file temp_make function Switching to tralston/bats-file allowed to use temp_make on macOS. --- test/test_helper.bash | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/test_helper.bash b/test/test_helper.bash index ece4bd92..ef46cc4e 100644 --- a/test/test_helper.bash +++ b/test/test_helper.bash @@ -50,9 +50,9 @@ setup_test_fixture() { } setup() { - # Temporarily using `mktemp` directly, since the bats-file function - # `temp_make` does not run on macOS - TEST_TEMP_DIR="$(mktemp -d -t 'bash-it-test.XXXX')" + # The `temp_make` function from "bats-file" requires the tralston/bats-file fork, + # since the original ztombol/bats-file's `temp_make` does not work on macOS. + TEST_TEMP_DIR="$(temp_make --prefix 'bash-it-test-')" export TEST_TEMP_DIR export BASH_IT_TEST_DIR="${TEST_TEMP_DIR}/.bash_it" From 543e49b759fcec4d0283ca56bf8462499fba083a Mon Sep 17 00:00:00 2001 From: Nils Winkler Date: Mon, 20 Apr 2020 08:59:06 +0200 Subject: [PATCH 59/89] Updated GNU parallel detection Thanks to @rico-chet for the detection code! --- test/run | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/test/run b/test/run index cf71259b..88202916 100755 --- a/test/run +++ b/test/run @@ -16,7 +16,13 @@ else test_dirs=( "$1" ) fi -if command -v parallel &> /dev/null +# Make sure that the `parallel` command is installed, +# AND that it is the GNU version of `parallel`. +# If that is the case, try to guess the number of CPU cores, +# so we can run `bats` in parallel processing mode, which is a lot faster. +if command -v parallel &> /dev/null \ + && parallel -V &> /dev/null \ + && { parallel -V 2> /dev/null | grep -q '^GNU\>'; } then # Expect to run at least on a dual-core CPU; slightly degraded performance # shouldn't matter otherwise. @@ -37,5 +43,6 @@ then exec "$bats_executable" ${CI:+--tap} --jobs ${test_jobs_effective} \ "${test_dirs[@]}" else + # Run `bats` in single-threaded mode. exec "$bats_executable" ${CI:+--tap} "${test_dirs[@]}" fi From d6e559f4247e57ab43431e00ffa84cbb2401243e Mon Sep 17 00:00:00 2001 From: Nils Winkler Date: Tue, 21 Apr 2020 08:22:51 +0200 Subject: [PATCH 60/89] Fixed indentation --- .gitmodules | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitmodules b/.gitmodules index 13532af5..c337c96c 100644 --- a/.gitmodules +++ b/.gitmodules @@ -12,4 +12,4 @@ [submodule "test_lib/bats-file"] path = test_lib/bats-file url = https://github.com/tralston/bats-file - branch = tags/v0.3.0 + branch = tags/v0.3.0 From 06cc400229ac0e748490c1eba9d0812244fb9d44 Mon Sep 17 00:00:00 2001 From: All Your Code Date: Tue, 21 Apr 2020 08:30:26 +0200 Subject: [PATCH 61/89] Added OC completion (#1567) * Added OC completion * Instead of copy pasting the output, using the output directly * Replaced which command with _command_exists --- completion/available/oc.completion.bash | 1 + 1 file changed, 1 insertion(+) create mode 100644 completion/available/oc.completion.bash diff --git a/completion/available/oc.completion.bash b/completion/available/oc.completion.bash new file mode 100644 index 00000000..1e7b6815 --- /dev/null +++ b/completion/available/oc.completion.bash @@ -0,0 +1 @@ +_command_exists oc && source <(oc completion bash) From 313e9bd51bdda8b127c7163276e3e1e4ab52efad Mon Sep 17 00:00:00 2001 From: All Your Code Date: Tue, 21 Apr 2020 08:32:20 +0200 Subject: [PATCH 62/89] Added Minishift completion (#1566) * Added Minishift completion * Instead of copy pasting the output, using the output directly * Replaced which command with _command_exists --- completion/available/minishift.completion.bash | 1 + 1 file changed, 1 insertion(+) create mode 100644 completion/available/minishift.completion.bash diff --git a/completion/available/minishift.completion.bash b/completion/available/minishift.completion.bash new file mode 100644 index 00000000..5679eae8 --- /dev/null +++ b/completion/available/minishift.completion.bash @@ -0,0 +1 @@ +_command_exists minishift && source <(minishift completion bash) From 862b99896daefa715d7ef4e658121dd5a6440c1b Mon Sep 17 00:00:00 2001 From: Uco Mesdag Date: Tue, 21 Apr 2020 15:00:14 +0200 Subject: [PATCH 63/89] Updated openshift completion to use _command_exists and removed duplicate oc completion --- completion/available/oc.completion.bash | 1 - completion/available/openshift.completion.bash | 4 +--- 2 files changed, 1 insertion(+), 4 deletions(-) delete mode 100644 completion/available/oc.completion.bash diff --git a/completion/available/oc.completion.bash b/completion/available/oc.completion.bash deleted file mode 100644 index 1e7b6815..00000000 --- a/completion/available/oc.completion.bash +++ /dev/null @@ -1 +0,0 @@ -_command_exists oc && source <(oc completion bash) diff --git a/completion/available/openshift.completion.bash b/completion/available/openshift.completion.bash index 8e7a4633..1e7b6815 100644 --- a/completion/available/openshift.completion.bash +++ b/completion/available/openshift.completion.bash @@ -1,3 +1 @@ -#!/usr/bin/env bash - -[ -x "$(which oc)" ] && eval "$(oc completion bash)" +_command_exists oc && source <(oc completion bash) From ce160ff314d5bbd6cbe9f07c0a1acfb073ab92b2 Mon Sep 17 00:00:00 2001 From: Ralph Gutmann Date: Tue, 21 Apr 2020 18:11:15 +0200 Subject: [PATCH 64/89] added tar extract-directory creation and usage (also removal of unnecessary recursion where appropriate) --- plugins/available/extract.plugin.bash | 40 ++++++++++++++++++--------- 1 file changed, 27 insertions(+), 13 deletions(-) diff --git a/plugins/available/extract.plugin.bash b/plugins/available/extract.plugin.bash index e357814a..d431e711 100644 --- a/plugins/available/extract.plugin.bash +++ b/plugins/available/extract.plugin.bash @@ -5,7 +5,7 @@ about-plugin 'one command to extract them all...' extract() { local opt local OPTIND=1 - while getopts "hv" opt; do + while getopts "hdv" opt; do case "$opt" in h) cat <&2 + shift + continue + fi + + local -r filename=$(basename -- $1) + local -r filedirname=$(dirname -- $1) + local targetdirname=$(sed 's/\(\.tar\.bz2$\|\.tbz$\|\.tbz2$\|\.tar\.gz$\|\.tgz$\|\.tar$\|\.tar\.xz$\|\.txz$\|\.tar\.Z$\|\.7z$\)//g' <<< $filename) + if [ "$filename" = "$targetdirname" ]; then + # archive type either not supported or it doesn't need dir creation + targetdirname="" + else + mkdir -v "$filedirname/$targetdirname" + fi + + if [ -f "$1" ]; then + case "$1" in + *.tar.bz2|*.tbz|*.tbz2) tar "x${verbose}jf" "$1" -C "$filedirname/$targetdirname" ;; + *.tar.gz|*.tgz) tar "x${verbose}zf" "$1" -C "$filedirname/$targetdirname" ;; + *.tar.xz|*.txz) tar "x${verbose}Jf" "$1" -C "$filedirname/$targetdirname" ;; + *.tar.Z) tar "x${verbose}Zf" "$1" -C "$filedirname/$targetdirname" ;; *.bz2) bunzip2 "$1" ;; *.deb) dpkg-deb -x${verbose} "$1" "${1:0:-4}" ;; *.pax.gz) gunzip "$1"; set -- "$@" "${1:0:-3}" ;; @@ -43,17 +59,15 @@ End-Of-Usage *.pkg) pkgutil --expand "$1" "${1:0:-4}" ;; *.rar) unrar x "$1" ;; *.rpm) rpm2cpio "$1" | cpio -idm${verbose} ;; - *.tar) tar "x${verbose}f" "$1" ;; - *.txz) mv "$1" "${1:0:-4}.tar.xz"; set -- "$@" "${1:0:-4}.tar.xz" ;; + *.tar) tar "x${verbose}f" "$1" -C "$filedirname/$targetdirname" ;; *.xz) xz --decompress "$1" ;; *.zip|*.war|*.jar) unzip "$1" ;; *.Z) uncompress "$1" ;; *.7z) 7za x "$1" ;; *) echo "'$1' cannot be extracted via extract" >&2;; - esac - else - echo "extract: '$1' is not a valid file" >&2 - fi + esac + fi + shift done } From 306be4dd4f4622ab92f8f70c2f1dc00ed42de91b Mon Sep 17 00:00:00 2001 From: Ralph Gutmann Date: Tue, 21 Apr 2020 18:34:28 +0200 Subject: [PATCH 65/89] (minor) options fix --- plugins/available/extract.plugin.bash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/available/extract.plugin.bash b/plugins/available/extract.plugin.bash index d431e711..719808e5 100644 --- a/plugins/available/extract.plugin.bash +++ b/plugins/available/extract.plugin.bash @@ -5,7 +5,7 @@ about-plugin 'one command to extract them all...' extract() { local opt local OPTIND=1 - while getopts "hdv" opt; do + while getopts "hv" opt; do case "$opt" in h) cat < Date: Tue, 21 Apr 2020 11:25:37 -0700 Subject: [PATCH 66/89] completion/git: Updates completion script to v2.26.2 --- completion/available/git.completion.bash | 585 ++++++++++++++++++----- 1 file changed, 458 insertions(+), 127 deletions(-) diff --git a/completion/available/git.completion.bash b/completion/available/git.completion.bash index 1e3fdcac..3f75364e 100644 --- a/completion/available/git.completion.bash +++ b/completion/available/git.completion.bash @@ -1,3 +1,8 @@ +# git bash completions v2.26.2 +# Completion file copied as-is from git contrib: +# - https://github.com/git/git/releases/tag/v2.26.2 +# - git-2.26.2/contrib/completion/git-completion.bash +# ------------------------------------------------------------------- # bash/zsh completion support for core Git. # # Copyright (C) 2006,2007 Shawn O. Pearce @@ -37,7 +42,8 @@ # GIT_COMPLETION_CHECKOUT_NO_GUESS # # When set to "1", do not include "DWIM" suggestions in git-checkout -# completion (e.g., completing "foo" when "origin/foo" exists). +# and git-switch completion (e.g., completing "foo" when "origin/foo" +# exists). case "$COMP_WORDBREAKS" in *:*) : great ;; @@ -339,7 +345,7 @@ __gitcomp () c="$c${4-}" if [[ $c == "$cur_"* ]]; then case $c in - --*=*|*.) ;; + --*=|*.) ;; *) c="$c " ;; esac COMPREPLY[i++]="${2-}$c" @@ -359,7 +365,7 @@ __gitcomp () c="$c${4-}" if [[ $c == "$cur_"* ]]; then case $c in - --*=*|*.) ;; + *=|*.) ;; *) c="$c " ;; esac COMPREPLY[i++]="${2-}$c" @@ -400,7 +406,8 @@ __gitcomp_builtin () if [ -z "$options" ]; then # leading and trailing spaces are significant to make # option removal work correctly. - options=" $incl $(__git ${cmd/_/ } --git-completion-helper) " + options=" $incl $(__git ${cmd/_/ } --git-completion-helper) " || return + for i in $excl; do options="${options/ $i / }" done @@ -522,7 +529,7 @@ __git_index_files () # Even when a directory name itself does not contain # any special characters, it will still be quoted if # any of its (stripped) trailing path components do. - # Because of this we may have seen the same direcory + # Because of this we may have seen the same directory # both quoted and unquoted. if (p in paths) # We have seen the same directory unquoted, @@ -548,7 +555,7 @@ __git_index_files () esc_idx, 1) } else if (esc == "n") { # Uh-oh, a newline character. - # We cant reliably put a pathname + # We cannot reliably put a pathname # containing a newline into COMPREPLY, # and the newline would create a mess. # Skip this path. @@ -563,7 +570,7 @@ __git_index_files () } } # Drop closing double quote, if there is one. - # (There isnt any if this is a directory, as it was + # (There is not any if this is a directory, as it was # already stripped with the trailing path components.) if (substr(p, length(p), 1) == "\"") out = out substr(p, 1, length(p) - 1) @@ -853,6 +860,11 @@ __git_compute_merge_strategies () __git_merge_strategies=$(__git_list_merge_strategies) } +__git_merge_strategy_options="ours theirs subtree subtree= patience + histogram diff-algorithm= ignore-space-change ignore-all-space + ignore-space-at-eol renormalize no-renormalize no-renames + find-renames find-renames= rename-threshold=" + __git_complete_revlist_file () { local dequoted_word pfx ls ref cur_="$cur" @@ -996,12 +1008,21 @@ __git_complete_strategy () -s|--strategy) __gitcomp "$__git_merge_strategies" return 0 + ;; + -X) + __gitcomp "$__git_merge_strategy_options" + return 0 + ;; esac case "$cur" in --strategy=*) __gitcomp "$__git_merge_strategies" "" "${cur##--strategy=}" return 0 ;; + --strategy-option=*) + __gitcomp "$__git_merge_strategy_options" "" "${cur##--strategy-option=}" + return 0 + ;; esac return 1 } @@ -1010,7 +1031,7 @@ __git_all_commands= __git_compute_all_commands () { test -n "$__git_all_commands" || - __git_all_commands=$(git --list-cmds=main,others,alias,nohelpers) + __git_all_commands=$(__git --list-cmds=main,others,alias,nohelpers) } # Lists all set config variables starting with the given section prefix, @@ -1053,15 +1074,32 @@ __git_aliased_command () done } -# __git_find_on_cmdline requires 1 argument +# Check whether one of the given words is present on the command line, +# and print the first word found. +# +# Usage: __git_find_on_cmdline [