From 55e698a73768128f5ad43eaec61bad0640bdecbc Mon Sep 17 00:00:00 2001 From: Gurkirat Singh Date: Sun, 6 Mar 2022 04:25:33 +0530 Subject: [PATCH 01/53] fix test file path from the 7fcad6ed0d9427e51b94cc721a846666cef8ea82 commit --- clean_files.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clean_files.txt b/clean_files.txt index e52d5a9f29..11a584c7de 100644 --- a/clean_files.txt +++ b/clean_files.txt @@ -136,7 +136,7 @@ plugins/available/zoxide.plugin.bash # tests # -test/plugins/alias-completion.plugin.bats +test/completion/aliases.completion.bats test/run test/test_helper.bash From 6ba527ff98de6a7fbaeba3914239580522a2dfa4 Mon Sep 17 00:00:00 2001 From: Gurkirat Singh Date: Sun, 6 Mar 2022 11:41:27 +0530 Subject: [PATCH 02/53] feature (alias): add terraform init alias --- aliases/available/terraform.aliases.bash | 1 + 1 file changed, 1 insertion(+) diff --git a/aliases/available/terraform.aliases.bash b/aliases/available/terraform.aliases.bash index baa9b0c7ce..fedd319899 100644 --- a/aliases/available/terraform.aliases.bash +++ b/aliases/available/terraform.aliases.bash @@ -2,6 +2,7 @@ about-alias 'Aliases for Terraform and Terragrunt' alias tf='terraform' +alias tfi='tf init' alias tfv='terraform validate' alias tfp='terraform plan' alias tfa='terraform apply' From f2b4d82527d1a402b10594fd7db3eaf3989cb97a Mon Sep 17 00:00:00 2001 From: Gurkirat Singh Date: Sun, 6 Mar 2022 12:00:23 +0530 Subject: [PATCH 03/53] feature (alias): add open brave browser --- aliases/available/osx.aliases.bash | 1 + 1 file changed, 1 insertion(+) diff --git a/aliases/available/osx.aliases.bash b/aliases/available/osx.aliases.bash index e99bcae6b3..0a16c06f61 100644 --- a/aliases/available/osx.aliases.bash +++ b/aliases/available/osx.aliases.bash @@ -11,6 +11,7 @@ alias safari='open -a safari' alias firefox='open -a firefox' alias chrome='open -a "Google Chrome"' alias chromium='open -a chromium' +alias brave='open -a "Brave Browser"' alias dashcode='open -a dashcode' alias f='open -a Finder ' alias fh='open -a Finder .' From ec6d371db87c2a601eecd9170a7ad74c15a57e68 Mon Sep 17 00:00:00 2001 From: Ira Abramov <44946400+ira-bv@users.noreply.github.com> Date: Mon, 7 Mar 2022 00:23:49 +0200 Subject: [PATCH 04/53] Add a 'theme' for OMP, so the internal themes don't clash with it. (#2100) * Add a 'theme' for OMP, so the internal themes don't clash with it. * Add theme to clean_files * Add screenshot to the docs * Correct the name of the default theme in the docs. * keeping it cleaner Co-authored-by: Ira Abramov --- clean_files.txt | 1 + docs/themes-list/index.rst | 13 +++++++++++++ docs/themes-list/oh-my-posh.rst | 15 +++++++++++++++ themes/oh-my-posh/oh-my-posh.theme.bash | 8 ++++++++ 4 files changed, 37 insertions(+) create mode 100644 docs/themes-list/oh-my-posh.rst create mode 100644 themes/oh-my-posh/oh-my-posh.theme.bash diff --git a/clean_files.txt b/clean_files.txt index 11a584c7de..3c76421b68 100644 --- a/clean_files.txt +++ b/clean_files.txt @@ -161,6 +161,7 @@ themes/essential themes/githelpers.theme.bash themes/modern themes/norbu +themes/oh-my-posh themes/p4helpers.theme.bash themes/pete themes/powerline diff --git a/docs/themes-list/index.rst b/docs/themes-list/index.rst index 49c5a6236c..0275001b38 100644 --- a/docs/themes-list/index.rst +++ b/docs/themes-list/index.rst @@ -346,6 +346,19 @@ NWinkler :alt: +---- + +.. _oh_my_posh_image: + +Oh-My-Posh +^^^^^^^^^^ + + +.. image:: https://bash-it.github.io/bash-it/docs/images/oh-my-posh.png + :target: https://bash-it.github.io/bash-it/docs/images/oh-my-posh.png + :alt: + + ---- Pete diff --git a/docs/themes-list/oh-my-posh.rst b/docs/themes-list/oh-my-posh.rst new file mode 100644 index 0000000000..974adc0f19 --- /dev/null +++ b/docs/themes-list/oh-my-posh.rst @@ -0,0 +1,15 @@ +.. _oh-my-posh: + +Oh-My-Posh Theme +================ + +The oh-my-posh ״theme״ is really a plug to a whole other system +of managing your prompt. To use it please start here: +`Oh-My-Posh homepage `_ + +It is beyond the scope of bash-it to install and manage oh-my-posh, +this theme is here just to make sure your OMP setup doesn't clash +with other bash-it themes. Once installed, OMP will load a default +OMP theme (jandedobbeleer), which you can then customize or override. + +Note: Nerd Fonts are highly recommended, as most of the themes are graphic candies. diff --git a/themes/oh-my-posh/oh-my-posh.theme.bash b/themes/oh-my-posh/oh-my-posh.theme.bash new file mode 100644 index 0000000000..ba3c77f1ef --- /dev/null +++ b/themes/oh-my-posh/oh-my-posh.theme.bash @@ -0,0 +1,8 @@ +# shellcheck shell=bash + +if _command_exists oh-my-posh; then + export POSH_THEME=${POSH_THEME:-https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/v$(oh-my-posh --version)/themes/jandedobbeleer.omp.json} + eval "$(oh-my-posh --init --shell bash --config "${POSH_THEME}")" +else + _log_warning "The oh-my-posh binary was not found on your PATH. Falling back to your existing PS1, please see the docs for more info." +fi From 77c135956d4fbb7328ebb76360be26d59960eb2e Mon Sep 17 00:00:00 2001 From: Noah Gorny Date: Tue, 8 Mar 2022 00:01:36 +0200 Subject: [PATCH 05/53] lib: preview: Load only bash-it.sh when previewing Otherwise you change your theme to your default... --- lib/preview.bash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/preview.bash b/lib/preview.bash index 96fafae7ab..46c1618ab4 100644 --- a/lib/preview.bash +++ b/lib/preview.bash @@ -24,7 +24,7 @@ function _bash-it-preview() { # shellcheck disable=SC2034 for BASH_IT_THEME in "${themes[@]}"; do BASH_IT_LOG_LEVEL=0 - bash --init-file "${BASH_IT_BASHRC:-${BASH_IT?}/bash_it.sh}" -i <<< '_bash-it-flash-term "${#BASH_IT_THEME}" "${BASH_IT_THEME}"' + bash --init-file "${BASH_IT?}/bash_it.sh" -i <<< '_bash-it-flash-term "${#BASH_IT_THEME}" "${BASH_IT_THEME}"' done } From 13531c95344cca0326b17eb454225c80841815ef Mon Sep 17 00:00:00 2001 From: Noah Gorny Date: Tue, 8 Mar 2022 00:02:23 +0200 Subject: [PATCH 06/53] lib: search: Increase delay in _bash-it-flash-term to 0.2 secs --- lib/search.bash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/search.bash b/lib/search.bash index 7073f8798b..247e6294ae 100644 --- a/lib/search.bash +++ b/lib/search.bash @@ -347,7 +347,7 @@ function _bash-it-flash-term() { local -i len="${1:-0}" # redundant local term="${2:-}" # as currently implemented, `$match` has already been printed to screen the first time - local delay=0.1 + local delay=0.2 local color [[ "${#term}" -gt 0 ]] && len="${#term}" From 4686ce1f129a68dd487527598bb6ba6a98c47368 Mon Sep 17 00:00:00 2001 From: BarbUk Date: Wed, 9 Mar 2022 09:38:16 +0100 Subject: [PATCH 07/53] Fix precision to use deciseconds instead of nanoseconds --- lib/command_duration.bash | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/command_duration.bash b/lib/command_duration.bash index bc0cca8e0a..8c190acf22 100644 --- a/lib/command_duration.bash +++ b/lib/command_duration.bash @@ -22,9 +22,11 @@ function _command_duration() { local -i minutes=0 seconds=0 deciseconds=0 local -i command_start_seconds="${command_start%.*}" local -i command_start_deciseconds=$((10#${command_start##*.})) + command_start_deciseconds="${command_start_deciseconds:0:1}" local current_time="${EPOCHREALTIME:-$SECONDS}" local -i current_time_seconds="${current_time%.*}" local -i current_time_deciseconds="$((10#${current_time##*.}))" + current_time_deciseconds="${current_time_deciseconds:0:1}" if [[ "${command_start_seconds:-0}" -gt 0 ]]; then # seconds From 634c1f8c182996af035e4ff025ba62d0794b344b Mon Sep 17 00:00:00 2001 From: BarbUk Date: Wed, 9 Mar 2022 09:38:42 +0100 Subject: [PATCH 08/53] Fix spacing in string output --- lib/command_duration.bash | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/command_duration.bash b/lib/command_duration.bash index 8c190acf22..9810ff43bc 100644 --- a/lib/command_duration.bash +++ b/lib/command_duration.bash @@ -49,9 +49,9 @@ function _command_duration() { _dynamic_clock_icon "${command_duration}" if ((minutes > 0)); then - printf "%s%s%dm %ds" "${COMMAND_DURATION_ICON:-}" "${COMMAND_DURATION_COLOR:-}" "$minutes" "$seconds" + printf "%s %s%dm %ds" "${COMMAND_DURATION_ICON:-}" "${COMMAND_DURATION_COLOR:-}" "$minutes" "$seconds" elif ((seconds >= COMMAND_DURATION_MIN_SECONDS)); then - printf "%s%s%d.%01ds" "${COMMAND_DURATION_ICON:-}" "${COMMAND_DURATION_COLOR:-}" "$seconds" "$deciseconds" + printf "%s %s%d.%01ds" "${COMMAND_DURATION_ICON:-}" "${COMMAND_DURATION_COLOR:-}" "$seconds" "$deciseconds" fi } From b839294827b97671218a583ef6e3c4d6a6e65b1f Mon Sep 17 00:00:00 2001 From: BarbUk Date: Wed, 9 Mar 2022 21:29:51 +0100 Subject: [PATCH 09/53] Complete rework --- themes/barbuk/barbuk.theme.bash | 224 ++++++++++++++++++++++---------- 1 file changed, 158 insertions(+), 66 deletions(-) diff --git a/themes/barbuk/barbuk.theme.bash b/themes/barbuk/barbuk.theme.bash index b614d148c1..9608666a19 100644 --- a/themes/barbuk/barbuk.theme.bash +++ b/themes/barbuk/barbuk.theme.bash @@ -1,8 +1,11 @@ # shellcheck shell=bash # shellcheck disable=SC2034 # Expected behavior for themes. -# shellcheck disable=SC2154 #TODO: fix these all. + +# Prompt defaut configuration +BARBUK_PROMPT=${BARBUK_PROMPT:="git-uptream-remote-logo ssh path scm python_venv ruby node terraform cloud duration exit"} # Theme custom glyphs +# SCM SCM_GIT_CHAR_GITLAB=${BARBUK_GITLAB_CHAR:=' '} SCM_GIT_CHAR_BITBUCKET=${BARBUK_BITBUCKET_CHAR:=' '} SCM_GIT_CHAR_GITHUB=${BARBUK_GITHUB_CHAR:=' '} @@ -10,13 +13,20 @@ 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:='⑆ '} +# Exit code EXIT_CODE_ICON=${BARBUK_EXIT_CODE_ICON:=' '} +# Programming and tools PYTHON_VENV_CHAR=${BARBUK_PYTHON_VENV_CHAR:=' '} -COMMAND_DURATION_ICON=${BARBUK_COMMAND_DURATION_ICON:-"$bold_blue  "} +RUBY_CHAR=${BARBUK_RUBY_CHAR:=' '} +NODE_CHAR=${BARBUK_NODE_CHAR:=' '} +TERRAFORM_CHAR=${BARBUK_TERRAFORM_CHAR:="❲t❳ "} +# Cloud +AWS_PROFILE_CHAR=${BARBUK_AWS_PROFILE_CHAR:=" aws "} +SCALEWAY_PROFILE_CHAR=${BARBUK_SCALEWAY_PROFILE_CHAR:=" scw "} +GCLOUD_CHAR=${BARBUK_GCLOUD_CHAR:=" google "} # Command duration COMMAND_DURATION_MIN_SECONDS=${COMMAND_DURATION_MIN_SECONDS:-1} -COMMAND_DURATION_COLOR="$normal" # Ssh user and hostname display SSH_INFO=${BARBUK_SSH_INFO:=true} @@ -24,89 +34,171 @@ HOST_INFO=${BARBUK_HOST_INFO:=long} # Bash-it default glyphs customization SCM_NONE_CHAR= -SCM_THEME_PROMPT_DIRTY=" ${bold_red}✗" -SCM_THEME_PROMPT_CLEAN=" ${bold_green}✓" +SCM_THEME_PROMPT_DIRTY=" ${bold_red?}✗" +SCM_THEME_PROMPT_CLEAN=" ${bold_green?}✓" SCM_THEME_PROMPT_PREFIX="|" -SCM_THEME_PROMPT_SUFFIX="${green}| " -SCM_GIT_BEHIND_CHAR="${bold_red}↓${normal}" -SCM_GIT_AHEAD_CHAR="${bold_green}↑${normal}" +SCM_THEME_PROMPT_SUFFIX="${green?}| " +SCM_GIT_BEHIND_CHAR="${bold_red?}↓${normal?}" +SCM_GIT_AHEAD_CHAR="${bold_green?}↑${normal?}" SCM_GIT_UNTRACKED_CHAR="⌀" -SCM_GIT_UNSTAGED_CHAR="${bold_yellow}•${normal}" -SCM_GIT_STAGED_CHAR="${bold_green}+${normal}" -GIT_THEME_PROMPT_DIRTY=" ${bold_red}✗" -GIT_THEME_PROMPT_CLEAN=" ${bold_green}✓" -GIT_THEME_PROMPT_PREFIX="${cyan}" -GIT_THEME_PROMPT_SUFFIX="${cyan}" -SCM_THEME_BRANCH_TRACK_PREFIX="${normal} ⤏ ${cyan}" +SCM_GIT_UNSTAGED_CHAR="${bold_yellow?}•${normal?}" +SCM_GIT_STAGED_CHAR="${bold_green?}+${normal?}" +GIT_THEME_PROMPT_DIRTY=" ${bold_red?}✗" +GIT_THEME_PROMPT_CLEAN=" ${bold_green?}✓" +GIT_THEME_PROMPT_PREFIX="${cyan?}" +GIT_THEME_PROMPT_SUFFIX="${cyan?}" +SCM_THEME_BRANCH_TRACK_PREFIX="${normal?} ⤏ ${cyan?}" SCM_THEME_CURRENT_USER_PREFFIX='  ' SCM_GIT_SHOW_CURRENT_USER=false +NVM_THEME_PROMPT_PREFIX='' +NVM_THEME_PROMPT_SUFFIX='' +RVM_THEME_PROMPT_PREFIX='' +RVM_THEME_PROMPT_SUFFIX='' +RBENV_THEME_PROMPT_PREFIX=' ' +RBENV_THEME_PROMPT_SUFFIX='' +RBFU_THEME_PROMPT_PREFIX='' +RBFU_THEME_PROMPT_SUFFIX='' + +function __git-uptream-remote-logo_prompt() { + [[ "$(_git-upstream)" == "" ]] && SCM_GIT_CHAR="$SCM_GIT_CHAR_DEFAULT" + + local remote remote_domain + remote=$(_git-upstream-remote) + remote_domain=$(git config --get remote."$remote".url | awk -F'[@:.]' '{print $2}') + + # remove // suffix for https:// url + remote_domain=${remote_domain//\//} + + case $remote_domain in + github) SCM_GIT_CHAR="$SCM_GIT_CHAR_GITHUB" ;; + gitlab) SCM_GIT_CHAR="$SCM_GIT_CHAR_GITLAB" ;; + bitbucket) SCM_GIT_CHAR="$SCM_GIT_CHAR_BITBUCKET" ;; + *) SCM_GIT_CHAR="$SCM_GIT_CHAR_DEFAULT" ;; + esac + + echo "${purple?}$(scm_char)" +} + +function git_prompt_info() { + git_prompt_vars + echo -e "on $SCM_GIT_CHAR_ICON_BRANCH $SCM_PREFIX$SCM_BRANCH$SCM_STATE$SCM_GIT_AHEAD$SCM_GIT_BEHIND$SCM_GIT_STASH$SCM_SUFFIX " +} + +function __exit_prompt() { + if [[ "$exit_code" -ne 0 ]]; then + echo "${purple?}${EXIT_CODE_ICON}${yellow?}${exit_code}${bold_orange?} " + else + echo "${bold_green}" + fi +} -function _git-uptream-remote-logo { - [[ "$(_git-upstream)" == "" ]] && SCM_GIT_CHAR="$SCM_GIT_CHAR_DEFAULT" +function __aws_profile_prompt() { + if [[ -n "${AWS_PROFILE}" ]]; then + echo -n "${bold_purple?}${AWS_PROFILE_CHAR}${normal?}${AWS_PROFILE} " + fi +} - local remote remote_domain - remote=$(_git-upstream-remote) - remote_domain=$(git config --get remote."$remote".url | awk -F'[@:.]' '{print $2}') +function __scaleway_profile_prompt() { + if [[ -n "${SCW_PROFILE}" ]]; then + echo -n "${bold_purple?}${SCALEWAY_PROFILE_CHAR}${normal?}${SCW_PROFILE} " + fi +} - # remove // suffix for https:// url - remote_domain=${remote_domain//\//} +function __gcloud_prompt() { + local active_gcloud_account="" + + active_gcloud_account="$(active_gcloud_account_prompt)" + [[ -n "${active_gcloud_account}" ]] && echo "${bold_purple?}${GCLOUD_CHAR}${normal?}${active_gcloud_account} " +} - case $remote_domain in - github) SCM_GIT_CHAR="$SCM_GIT_CHAR_GITHUB" ;; - gitlab) SCM_GIT_CHAR="$SCM_GIT_CHAR_GITLAB" ;; - bitbucket) SCM_GIT_CHAR="$SCM_GIT_CHAR_BITBUCKET" ;; - *) SCM_GIT_CHAR="$SCM_GIT_CHAR_DEFAULT" ;; - esac +function __cloud_prompt() { + __aws_profile_prompt + __scaleway_profile_prompt + __gcloud_prompt } -function git_prompt_info { - git_prompt_vars - echo -e " on $SCM_GIT_CHAR_ICON_BRANCH $SCM_PREFIX$SCM_BRANCH$SCM_STATE$SCM_GIT_AHEAD$SCM_GIT_BEHIND$SCM_GIT_STASH$SCM_SUFFIX" +function __terraform_prompt() { + local terraform_workspace="" + + if [ -d .terraform ]; then + terraform_workspace="$(terraform_workspace_prompt)" + [[ -n "${terraform_workspace}" ]] && echo "${bold_purple?}${TERRAFORM_CHAR}${normal?}${terraform_workspace} " + fi } -function _exit-code { - if [[ "$1" -ne 0 ]]; then - exit_code=" ${purple}${EXIT_CODE_ICON}${yellow}${exit_code}${bold_orange}" - else - exit_code="${bold_green}" - fi +function __node_prompt() { + local node_version="" + + node_version="$(node_version_prompt)" + [[ -n "${node_version}" ]] && echo "${bold_purple?}${NODE_CHAR}${normal?}${node_version} " } -function _prompt { - local exit_code="$?" wrap_char=' ' dir_color=$green ssh_info='' python_venv='' host command_duration= +function __ruby_prompt() { + local ruby_version="" - command_duration=$(_command_duration) + ruby_version="$(ruby_version_prompt)" + [[ -n "${ruby_version}" ]] && echo "${bold_purple?}${RUBY_CHAR}${normal?}${ruby_version} " +} + +function __ssh_prompt() { + # Detect ssh + if [[ -n "${SSH_CONNECTION}" ]] && [ "$SSH_INFO" = true ]; then + if [ "$HOST_INFO" = long ]; then + host="\H" + else + host="\h" + fi + echo "${bold_blue?}\u${bold_orange?}@${cyan?}$host ${bold_orange?}in " + fi +} - _exit-code exit_code - _git-uptream-remote-logo +function __python_venv_prompt() { + # Detect python venv + if [[ -n "${CONDA_DEFAULT_ENV}" ]]; then + echo "${bold_purple?}$PYTHON_VENV_CHAR${normal?}${CONDA_DEFAULT_ENV} " + elif [[ -n "${VIRTUAL_ENV}" ]]; then + echo "${bold_purple?}$PYTHON_VENV_CHAR${normal?}$(basename "${VIRTUAL_ENV}") " + fi +} - history -a +function __path_prompt() { + local dir_color=${green?} + # Detect root shell + if [ "$(whoami)" = root ]; then + dir_color=${red?} + fi - # Detect root shell - if [ "$(whoami)" = root ]; then - dir_color=$red - fi + echo "${dir_color}\w${normal} " +} - # Detect ssh - if [[ -n "${SSH_CONNECTION}" ]] && [ "$SSH_INFO" = true ]; then - if [ "$HOST_INFO" = long ]; then - host="\H" - else - host="\h" - fi - ssh_info="${bold_blue}\u${bold_orange}@${cyan}$host ${bold_orange}in" - fi +function __scm_prompt() { + scm_prompt_info +} - # Detect python venv - if [[ -n "${CONDA_DEFAULT_ENV}" ]]; then - python_venv="$PYTHON_VENV_CHAR${CONDA_DEFAULT_ENV} " - elif [[ -n "${VIRTUAL_ENV}" ]]; then - python_venv="$PYTHON_VENV_CHAR$(basename "${VIRTUAL_ENV}") " - fi +function __duration_prompt() { + [[ -n "$command_duration" ]] && echo "${command_duration} " +} - PS1="\\n${ssh_info} ${purple}$(scm_char)${python_venv}${dir_color}\\w${normal}$(scm_prompt_info)${command_duration}${exit_code}" - [[ ${#PS1} -gt $((COLUMNS * 2)) ]] && wrap_char="\\n" - PS1="${PS1}${wrap_char}❯${normal} " +function __prompt-command() { + exit_code="$?" + command_duration=$(_command_duration) + local wrap_char + + # Generate prompt + PS1="\n " + for segment in $BARBUK_PROMPT; do + local info + info="$(__"${segment}"_prompt)" + [[ -n "${info}" ]] && PS1+="${info}" + done + + # Cut prompt when it's too long + if [[ ${#PS1} -gt $((COLUMNS * 2)) ]]; then + wrap_char="\n" + fi + + PS1="${PS1}${wrap_char}❯${normal} " } -safe_append_prompt_command _prompt +safe_append_prompt_command __prompt-command + From 0068315c35cb7539addf5cf2abe10c67d6500297 Mon Sep 17 00:00:00 2001 From: BarbUk Date: Wed, 9 Mar 2022 21:38:03 +0100 Subject: [PATCH 10/53] Update documentation --- docs/themes-list/barbuk.rst | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/docs/themes-list/barbuk.rst b/docs/themes-list/barbuk.rst index 15fb0ef577..79477524b0 100644 --- a/docs/themes-list/barbuk.rst +++ b/docs/themes-list/barbuk.rst @@ -8,13 +8,35 @@ A minimal theme with a clean git prompt Provided Information -------------------- - * Current git remote tool logo (support: github, gitlab, bitbucket) * 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@hostname for ssh connection +Default configuration +^^^^^^^^^^^^^^^^^^^^^ + +.. code-block:: bash + + BARBUK_PROMPT="git-uptream-remote-logo ssh path scm python_venv ruby node terraform cloud duration exit" + +You can override BARBUK_PROMPT to display only the desired information. + +available block: + +* git-uptream-remote-logo +* ssh +* path +* scm +* python_venv +* ruby +* node +* terraform +* cloud +* duration +* exit + Fonts and glyphs ---------------- @@ -39,6 +61,12 @@ Default theme glyphs BARBUK_EXIT_CODE_ICON=' ' BARBUK_PYTHON_VENV_CHAR=' ' BARBUK_COMMAND_DURATION_ICON='  ' + BARBUK_RUBY_CHAR=' ' + BARBUK_NODE_CHAR=' ' + BARBUK_TERRAFORM_CHAR="❲t❳ " + BARBUK_AWS_PROFILE_CHAR=" aws " + BARBUK_SCALEWAY_PROFILE_CHAR=" scw " + BARBUK_GCLOUD_CHAR=" gcp " Customize glyphs ^^^^^^^^^^^^^^^^ From e1ddf6e311a60e6affa2485bef43e28a3819f963 Mon Sep 17 00:00:00 2001 From: BarbUk Date: Wed, 9 Mar 2022 21:59:48 +0100 Subject: [PATCH 11/53] Fix dynamic clock icon (#2120) * Fix dynamic clock icon * Use printf variable scope * shfmt do not like spaces --- lib/command_duration.bash | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/command_duration.bash b/lib/command_duration.bash index bc0cca8e0a..686267fb6d 100644 --- a/lib/command_duration.bash +++ b/lib/command_duration.bash @@ -11,7 +11,10 @@ function _command_duration_pre_exec() { } function _dynamic_clock_icon { - local -i clock_hand=$(((${1:-${SECONDS}} % 12) + 90)) + local clock_hand + # clock hand value is between 90 and 9b in hexadecimal. + # so between 144 and 155 in base 10. + printf -v clock_hand '%x' $(((${1:-${SECONDS}} % 12) + 144)) printf -v 'COMMAND_DURATION_ICON' '%b' "\xf0\x9f\x95\x$clock_hand" } From 9a71556b9980469f71e5cbcda6651e77fb44f3bc Mon Sep 17 00:00:00 2001 From: BarbUk Date: Wed, 9 Mar 2022 21:48:43 +0100 Subject: [PATCH 12/53] shfmt needs more spaces --- themes/barbuk/barbuk.theme.bash | 163 ++++++++++++++++---------------- 1 file changed, 81 insertions(+), 82 deletions(-) diff --git a/themes/barbuk/barbuk.theme.bash b/themes/barbuk/barbuk.theme.bash index 9608666a19..6e6eb88aaf 100644 --- a/themes/barbuk/barbuk.theme.bash +++ b/themes/barbuk/barbuk.theme.bash @@ -60,145 +60,144 @@ RBFU_THEME_PROMPT_PREFIX='' RBFU_THEME_PROMPT_SUFFIX='' function __git-uptream-remote-logo_prompt() { - [[ "$(_git-upstream)" == "" ]] && SCM_GIT_CHAR="$SCM_GIT_CHAR_DEFAULT" + [[ "$(_git-upstream)" == "" ]] && SCM_GIT_CHAR="$SCM_GIT_CHAR_DEFAULT" - local remote remote_domain - remote=$(_git-upstream-remote) - remote_domain=$(git config --get remote."$remote".url | awk -F'[@:.]' '{print $2}') + local remote remote_domain + remote=$(_git-upstream-remote) + remote_domain=$(git config --get remote."$remote".url | awk -F'[@:.]' '{print $2}') - # remove // suffix for https:// url - remote_domain=${remote_domain//\//} + # remove // suffix for https:// url + remote_domain=${remote_domain//\//} - case $remote_domain in - github) SCM_GIT_CHAR="$SCM_GIT_CHAR_GITHUB" ;; - gitlab) SCM_GIT_CHAR="$SCM_GIT_CHAR_GITLAB" ;; - bitbucket) SCM_GIT_CHAR="$SCM_GIT_CHAR_BITBUCKET" ;; - *) SCM_GIT_CHAR="$SCM_GIT_CHAR_DEFAULT" ;; - esac + case $remote_domain in + github) SCM_GIT_CHAR="$SCM_GIT_CHAR_GITHUB" ;; + gitlab) SCM_GIT_CHAR="$SCM_GIT_CHAR_GITLAB" ;; + bitbucket) SCM_GIT_CHAR="$SCM_GIT_CHAR_BITBUCKET" ;; + *) SCM_GIT_CHAR="$SCM_GIT_CHAR_DEFAULT" ;; + esac - echo "${purple?}$(scm_char)" + echo "${purple?}$(scm_char)" } function git_prompt_info() { - git_prompt_vars - echo -e "on $SCM_GIT_CHAR_ICON_BRANCH $SCM_PREFIX$SCM_BRANCH$SCM_STATE$SCM_GIT_AHEAD$SCM_GIT_BEHIND$SCM_GIT_STASH$SCM_SUFFIX " + git_prompt_vars + echo -e "on $SCM_GIT_CHAR_ICON_BRANCH $SCM_PREFIX$SCM_BRANCH$SCM_STATE$SCM_GIT_AHEAD$SCM_GIT_BEHIND$SCM_GIT_STASH$SCM_SUFFIX " } function __exit_prompt() { - if [[ "$exit_code" -ne 0 ]]; then - echo "${purple?}${EXIT_CODE_ICON}${yellow?}${exit_code}${bold_orange?} " - else - echo "${bold_green}" - fi + if [[ "$exit_code" -ne 0 ]]; then + echo "${purple?}${EXIT_CODE_ICON}${yellow?}${exit_code}${bold_orange?} " + else + echo "${bold_green}" + fi } function __aws_profile_prompt() { - if [[ -n "${AWS_PROFILE}" ]]; then - echo -n "${bold_purple?}${AWS_PROFILE_CHAR}${normal?}${AWS_PROFILE} " - fi + if [[ -n "${AWS_PROFILE}" ]]; then + echo -n "${bold_purple?}${AWS_PROFILE_CHAR}${normal?}${AWS_PROFILE} " + fi } function __scaleway_profile_prompt() { - if [[ -n "${SCW_PROFILE}" ]]; then - echo -n "${bold_purple?}${SCALEWAY_PROFILE_CHAR}${normal?}${SCW_PROFILE} " - fi + if [[ -n "${SCW_PROFILE}" ]]; then + echo -n "${bold_purple?}${SCALEWAY_PROFILE_CHAR}${normal?}${SCW_PROFILE} " + fi } function __gcloud_prompt() { - local active_gcloud_account="" + local active_gcloud_account="" - active_gcloud_account="$(active_gcloud_account_prompt)" - [[ -n "${active_gcloud_account}" ]] && echo "${bold_purple?}${GCLOUD_CHAR}${normal?}${active_gcloud_account} " + active_gcloud_account="$(active_gcloud_account_prompt)" + [[ -n "${active_gcloud_account}" ]] && echo "${bold_purple?}${GCLOUD_CHAR}${normal?}${active_gcloud_account} " } function __cloud_prompt() { - __aws_profile_prompt - __scaleway_profile_prompt - __gcloud_prompt + __aws_profile_prompt + __scaleway_profile_prompt + __gcloud_prompt } function __terraform_prompt() { - local terraform_workspace="" + local terraform_workspace="" - if [ -d .terraform ]; then - terraform_workspace="$(terraform_workspace_prompt)" - [[ -n "${terraform_workspace}" ]] && echo "${bold_purple?}${TERRAFORM_CHAR}${normal?}${terraform_workspace} " - fi + if [ -d .terraform ]; then + terraform_workspace="$(terraform_workspace_prompt)" + [[ -n "${terraform_workspace}" ]] && echo "${bold_purple?}${TERRAFORM_CHAR}${normal?}${terraform_workspace} " + fi } function __node_prompt() { - local node_version="" + local node_version="" - node_version="$(node_version_prompt)" - [[ -n "${node_version}" ]] && echo "${bold_purple?}${NODE_CHAR}${normal?}${node_version} " + node_version="$(node_version_prompt)" + [[ -n "${node_version}" ]] && echo "${bold_purple?}${NODE_CHAR}${normal?}${node_version} " } function __ruby_prompt() { - local ruby_version="" + local ruby_version="" - ruby_version="$(ruby_version_prompt)" - [[ -n "${ruby_version}" ]] && echo "${bold_purple?}${RUBY_CHAR}${normal?}${ruby_version} " + ruby_version="$(ruby_version_prompt)" + [[ -n "${ruby_version}" ]] && echo "${bold_purple?}${RUBY_CHAR}${normal?}${ruby_version} " } function __ssh_prompt() { - # Detect ssh - if [[ -n "${SSH_CONNECTION}" ]] && [ "$SSH_INFO" = true ]; then - if [ "$HOST_INFO" = long ]; then - host="\H" - else - host="\h" - fi - echo "${bold_blue?}\u${bold_orange?}@${cyan?}$host ${bold_orange?}in " - fi + # Detect ssh + if [[ -n "${SSH_CONNECTION}" ]] && [ "$SSH_INFO" = true ]; then + if [ "$HOST_INFO" = long ]; then + host="\H" + else + host="\h" + fi + echo "${bold_blue?}\u${bold_orange?}@${cyan?}$host ${bold_orange?}in " + fi } function __python_venv_prompt() { - # Detect python venv - if [[ -n "${CONDA_DEFAULT_ENV}" ]]; then - echo "${bold_purple?}$PYTHON_VENV_CHAR${normal?}${CONDA_DEFAULT_ENV} " - elif [[ -n "${VIRTUAL_ENV}" ]]; then - echo "${bold_purple?}$PYTHON_VENV_CHAR${normal?}$(basename "${VIRTUAL_ENV}") " - fi + # Detect python venv + if [[ -n "${CONDA_DEFAULT_ENV}" ]]; then + echo "${bold_purple?}$PYTHON_VENV_CHAR${normal?}${CONDA_DEFAULT_ENV} " + elif [[ -n "${VIRTUAL_ENV}" ]]; then + echo "${bold_purple?}$PYTHON_VENV_CHAR${normal?}$(basename "${VIRTUAL_ENV}") " + fi } function __path_prompt() { - local dir_color=${green?} - # Detect root shell - if [ "$(whoami)" = root ]; then - dir_color=${red?} - fi + local dir_color=${green?} + # Detect root shell + if [ "$(whoami)" = root ]; then + dir_color=${red?} + fi - echo "${dir_color}\w${normal} " + echo "${dir_color}\w${normal} " } function __scm_prompt() { - scm_prompt_info + scm_prompt_info } function __duration_prompt() { - [[ -n "$command_duration" ]] && echo "${command_duration} " + [[ -n "$command_duration" ]] && echo "${command_duration} " } function __prompt-command() { - exit_code="$?" - command_duration=$(_command_duration) - local wrap_char + exit_code="$?" + command_duration=$(_command_duration) + local wrap_char - # Generate prompt - PS1="\n " - for segment in $BARBUK_PROMPT; do - local info - info="$(__"${segment}"_prompt)" - [[ -n "${info}" ]] && PS1+="${info}" - done + # Generate prompt + PS1="\n " + for segment in $BARBUK_PROMPT; do + local info + info="$(__"${segment}"_prompt)" + [[ -n "${info}" ]] && PS1+="${info}" + done - # Cut prompt when it's too long - if [[ ${#PS1} -gt $((COLUMNS * 2)) ]]; then - wrap_char="\n" - fi + # Cut prompt when it's too long + if [[ ${#PS1} -gt $((COLUMNS * 2)) ]]; then + wrap_char="\n" + fi - PS1="${PS1}${wrap_char}❯${normal} " + PS1="${PS1}${wrap_char}❯${normal} " } safe_append_prompt_command __prompt-command - From 23efb39fb02d6d378f10f7519c6c2d30a71d68cf Mon Sep 17 00:00:00 2001 From: BarbUk Date: Fri, 11 Mar 2022 09:08:58 +0100 Subject: [PATCH 13/53] Fix grep path when a grep alias exists --- lib/utilities.bash | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/utilities.bash b/lib/utilities.bash index 8ea6b98c24..6d5fd5d493 100644 --- a/lib/utilities.bash +++ b/lib/utilities.bash @@ -62,13 +62,13 @@ function _bash-it-array-dedup() { # Outputs a full path of the grep found on the filesystem function _bash-it-grep() { - : "${BASH_IT_GREP:=$(type -p egrep || type -p grep)}" + : "${BASH_IT_GREP:=$(type -P egrep || type -P grep)}" printf "%s" "${BASH_IT_GREP:-/usr/bin/grep}" } # Runs `grep` with extended regular expressions function _bash-it-egrep() { - : "${BASH_IT_GREP:=$(type -p egrep || type -p grep)}" + : "${BASH_IT_GREP:=$(type -P egrep || type -P grep)}" "${BASH_IT_GREP:-/usr/bin/grep}" -E "$@" } From 6b0ca17df00eaef0cacada04b5d3fbc6be03bf70 Mon Sep 17 00:00:00 2001 From: Gurkirat Singh Date: Sun, 13 Mar 2022 05:20:57 +0530 Subject: [PATCH 14/53] improve (lint): add awscli.completion.bash in clean_files.txt --- clean_files.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/clean_files.txt b/clean_files.txt index 3c76421b68..de0f6c1e87 100644 --- a/clean_files.txt +++ b/clean_files.txt @@ -33,6 +33,7 @@ lint_clean_files.sh # completion/available/apm.completion.bash completion/available/awless.completion.bash +completion/available/awscli.completion.bash completion/available/bash-it.completion.bash completion/available/brew.completion.bash completion/available/cargo.completion.bash From 66fbed7f6f4256c1e361ee2be0486b581e853cf5 Mon Sep 17 00:00:00 2001 From: Gurkirat Singh Date: Sun, 13 Mar 2022 05:21:13 +0530 Subject: [PATCH 15/53] fix (completion): format awscli --- completion/available/awscli.completion.bash | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/completion/available/awscli.completion.bash b/completion/available/awscli.completion.bash index a30418373a..6b2c90ff5d 100644 --- a/completion/available/awscli.completion.bash +++ b/completion/available/awscli.completion.bash @@ -1,6 +1,5 @@ # shellcheck shell=bash -if _command_exists aws_completer -then +if _command_exists aws_completer; then complete -C "$(command -v aws_completer)" aws fi From a481ff41ab2a1f642e241a88340b350a4a0b2630 Mon Sep 17 00:00:00 2001 From: Noah Gorny Date: Mon, 14 Mar 2022 11:20:40 +0200 Subject: [PATCH 16/53] general: Add default nano editor for the edit alias --- aliases/available/general.aliases.bash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/aliases/available/general.aliases.bash b/aliases/available/general.aliases.bash index 42930ab4d2..b49344895b 100644 --- a/aliases/available/general.aliases.bash +++ b/aliases/available/general.aliases.bash @@ -34,7 +34,7 @@ fi alias c='clear' alias cls='clear' -alias edit='${EDITOR:-${ALTERNATE_EDITOR?}}' +alias edit='${EDITOR:-${ALTERNATE_EDITOR:-nano}}' alias pager='${PAGER:=less}' alias q='exit' From 088212fd32af77e66bdef1f0fe3e0c56b96e4770 Mon Sep 17 00:00:00 2001 From: Eric Villard Date: Wed, 16 Mar 2022 08:43:52 +0100 Subject: [PATCH 17/53] fix projects plugin regression This regression was introduced in ea2002a. Before this commit, when the provided project was unique under all the project paths, the command automatically change the directory to it. Currently this is no more the case. If there are many project paths set, then the project path menu is shown at every call. This PR solves this issue. Signed-off-by: Eric Villard --- plugins/available/projects.plugin.bash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/available/projects.plugin.bash b/plugins/available/projects.plugin.bash index 803864806a..34fa001e0e 100644 --- a/plugins/available/projects.plugin.bash +++ b/plugins/available/projects.plugin.bash @@ -21,7 +21,7 @@ function pj() { # with the same name in project directories IFS=':' read -ra dests <<< "${BASH_IT_PROJECT_PATHS?${FUNCNAME[0]}: project working folders must be configured}" for d in "${!dests[@]}"; do - if [[ ! -d "${dests[d]}" ]]; then + if [[ ! -d "${dests[d]}/${proj}" ]]; then unset 'dests[d]' fi done From 6ccd9f5adfde535341da8139a156ef05de6568c9 Mon Sep 17 00:00:00 2001 From: Gurkirat Singh Date: Mon, 21 Mar 2022 08:52:46 +0530 Subject: [PATCH 18/53] fix (helpers): bashit_update function return to source path and --no-merges in log --- lib/helpers.bash | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/helpers.bash b/lib/helpers.bash index c0ce2eb3e2..2ee43a17af 100644 --- a/lib/helpers.bash +++ b/lib/helpers.bash @@ -290,6 +290,7 @@ function _bash-it-update-() { DIFF=$(git diff --name-status) if [[ -n "$DIFF" ]]; then echo -e "Local changes detected in bash-it directory. Clean '$BASH_IT' directory to proceed.\n$DIFF" + popd > /dev/null || return return 1 fi @@ -334,7 +335,7 @@ function _bash-it-update-() { log_color="%Cred" fi - git log --format="${log_color}%h: %s (%an)" "${revision}" + git log --no-merges --format="${log_color}%h: %s (%an)" "${revision}" echo "" if [[ -n "${silent}" ]]; then From d7fb6b3235bfceeb36d4657631c6c3155cdfd4ff Mon Sep 17 00:00:00 2001 From: Gurkirat Singh Date: Tue, 15 Mar 2022 07:52:43 +0530 Subject: [PATCH 19/53] improve (lint): add completion/available/flutter.completion.bash entry --- clean_files.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/clean_files.txt b/clean_files.txt index de0f6c1e87..192fefa64f 100644 --- a/clean_files.txt +++ b/clean_files.txt @@ -46,6 +46,7 @@ completion/available/dmidecode.completion.bash completion/available/docker-machine.completion.bash completion/available/docker.completion.bash completion/available/dotnet.completion.bash +completion/available/flutter.completion.bash completion/available/gcloud.completion.bash completion/available/gem.completion.bash completion/available/git.completion.bash From e11576f260903ee2041e910b535f674dbe5c86a4 Mon Sep 17 00:00:00 2001 From: Gurkirat Singh Date: Tue, 15 Mar 2022 07:53:11 +0530 Subject: [PATCH 20/53] fix (completion): shfmt format flutter.completion.bash --- completion/available/flutter.completion.bash | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/completion/available/flutter.completion.bash b/completion/available/flutter.completion.bash index 62befc824d..7dde5a0709 100644 --- a/completion/available/flutter.completion.bash +++ b/completion/available/flutter.completion.bash @@ -1,5 +1,5 @@ -#!/usr/bin/bash +# shellcheck shell=bash if _command_exists flutter; then - eval "$(flutter bash-completion)" + eval "$(flutter bash-completion)" fi From 135d480c7da93443e6ac1354e6554e76e70a233b Mon Sep 17 00:00:00 2001 From: Gurkirat Singh Date: Sat, 7 May 2022 00:31:21 +0530 Subject: [PATCH 21/53] improve (docs): exclude venv pattern in build --- docs/conf.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/docs/conf.py b/docs/conf.py index cacc2d5022..f96485c616 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -14,7 +14,6 @@ # import sys # sys.path.insert(0, os.path.abspath('.')) - # -- Project information ----------------------------------------------------- project = 'Bash-it' @@ -24,7 +23,6 @@ # The full version, including alpha/beta/rc tags release = '' - # -- General configuration --------------------------------------------------- # Add any Sphinx extension module names here, as strings. They can be @@ -41,8 +39,7 @@ # List of patterns, relative to source directory, that match files and # directories to ignore when looking for source files. # This pattern also affects html_static_path and html_extra_path. -exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store'] - +exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store', "venv"] # -- Options for HTML output ------------------------------------------------- From c2698882e40f31725c1cebb7bd657e0dac2845fe Mon Sep 17 00:00:00 2001 From: Gurkirat Singh Date: Sat, 7 May 2022 00:32:15 +0530 Subject: [PATCH 22/53] fix (docs): ugraded sphinx version --- docs/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/requirements.txt b/docs/requirements.txt index b3015c81ce..7b7fcdd1ff 100644 --- a/docs/requirements.txt +++ b/docs/requirements.txt @@ -1,4 +1,4 @@ -sphinx==3.2.1 +sphinx==4.5.0 sphinx-rtd-theme==0.5.0 sphinxemoji==0.1.8 docutils==0.17.1 From f2bc6c4e6d421765741bafa2752367177eb7f3cb Mon Sep 17 00:00:00 2001 From: Dylan Tuttle Date: Sun, 8 May 2022 00:49:27 -0600 Subject: [PATCH 23/53] Added update-bash section in README --- docs/README.md | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/docs/README.md b/docs/README.md index f3d31a14fe..5d0da58343 100644 --- a/docs/README.md +++ b/docs/README.md @@ -42,6 +42,27 @@ Stop polluting your `~/bin` directory and your `.bashrc` file, fork/clone Bash-i ``git clone --depth=1 https://github.com/Bash-it/bash-it.git ~/.bash_it`` 2) Run ``~/.bash_it/install.sh`` +### Bash Dependency + +Bash-it requires Bash 4.?? or later to run correctly. Any reasonably current Linux distribution should have shipped with a compatible version of Bash. However, macOS users must upgrade from the included, obsolete Bash version 3. While some functionality might work with Bash 3, there is no guarantee that everything will work perfectly. Thus, we recommend using [Homebrew](https://brew.sh/) to ensure Bash is up to date: + +**x86 Mac** + +```bash +$ brew install bash +$ sudo sh -c 'echo /usr/local/bin/bash >> /etc/shells' +$ chsh -s /usr/local/bin/bash +``` + +**M1 Mac** +Homebrew's default installation location on M1 is ``/opt/homebrew/bin/``: + +```bash +$ brew install bash +$ sudo sh -c 'echo /opt/homebrew/bin/bash >> /etc/shells' +$ chsh -s /opt/homebrew/bin/bash +``` + That's it! :smiley: You can check out more components of Bash-it, and customize it to your desire. From c0dc83edfc4bfca914c8da3eda51f17e169e8cdf Mon Sep 17 00:00:00 2001 From: David Farrell Date: Mon, 9 May 2022 13:08:52 -0700 Subject: [PATCH 24/53] plugin(dirs): Create backup file parent directory --- plugins/available/dirs.plugin.bash | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/plugins/available/dirs.plugin.bash b/plugins/available/dirs.plugin.bash index 34468fa061..55d2e88a1f 100644 --- a/plugins/available/dirs.plugin.bash +++ b/plugins/available/dirs.plugin.bash @@ -63,12 +63,15 @@ function dirs-help() { if [[ -f "${BASH_IT_DIRS_BKS?}" ]]; then # shellcheck disable=SC1090 source "${BASH_IT_DIRS_BKS?}" -elif [[ -f ~/.dirs ]]; then - mv -vn ~/.dirs "${BASH_IT_DIRS_BKS?}" - # shellcheck disable=SC1090 - source "${BASH_IT_DIRS_BKS?}" else - touch "${BASH_IT_DIRS_BKS?}" + mkdir -p "${BASH_IT_DIRS_BKS%/*}" + if [[ -f ~/.dirs ]]; then + mv -vn ~/.dirs "${BASH_IT_DIRS_BKS?}" + # shellcheck disable=SC1090 + source "${BASH_IT_DIRS_BKS?}" + else + touch "${BASH_IT_DIRS_BKS?}" + fi fi alias L='cat "${BASH_IT_DIRS_BKS?}"' From 129340d24d8c75d1eb3e801487da35d56bb75ac2 Mon Sep 17 00:00:00 2001 From: Thomas Merz Date: Mon, 18 Jul 2022 14:30:59 +0200 Subject: [PATCH 25/53] =?UTF-8?q?Issue=202151=20=F0=9F=9B=82=20do=20not=20?= =?UTF-8?q?give=20users=20a=20root=20shell=20by=20executing=20arbitrary=20?= =?UTF-8?q?shell=20commands=20by=20'vim'=20=20=20=20=20=20=20=20=20=20=20?= =?UTF-8?q?=20=20=20=20also=20by=20removing=20'sudo'=20aliases=20because?= =?UTF-8?q?=20bash-it=20should=20not=20be=20=20=20=20=20=20=20=20=20=20=20?= =?UTF-8?q?=20=20=20=20the=20business=20of=20mucking=20about=20with=20sudo?= =?UTF-8?q?=20at=20all?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- aliases/available/general.aliases.bash | 4 ---- 1 file changed, 4 deletions(-) diff --git a/aliases/available/general.aliases.bash b/aliases/available/general.aliases.bash index b49344895b..2511aab8a9 100644 --- a/aliases/available/general.aliases.bash +++ b/aliases/available/general.aliases.bash @@ -71,10 +71,6 @@ alias rd='rmdir' # Shorten extract alias xt='extract' -# sudo editors -alias svim='sudo ${VISUAL:-vim}' -alias snano='sudo nano' - # Display whatever file is regular file or folder function catt() { for i in "$@"; do From 407f2f5b5f4a2fa9e7361a4385b02b64e29cef13 Mon Sep 17 00:00:00 2001 From: Jake Boeckerman Date: Fri, 12 Aug 2022 11:02:56 -0600 Subject: [PATCH 26/53] Update github runner images Github deprecated and will remove two runner images macos-10.15 will be removed on 2022-08-30 macos-12 is available https://github.blog/changelog/2022-07-20-github-actions-the-macos-10-15-actions-runner-image-is-being-deprecated-and-will-be-removed-by-8-30-22/ ubuntu-18.04 will be removed on 2022-12-01 ubuntu-22.04 is available https://github.blog/changelog/2022-08-09-github-actions-the-ubuntu-18-04-actions-runner-image-is-being-deprecated-and-will-be-removed-by-12-1-22/ --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0eee145cd8..1d1c0ecae6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -7,7 +7,7 @@ jobs: bats-test: strategy: matrix: - os: [ubuntu-20.04, ubuntu-18.04, macos-10.15, macos-11] + os: [ubuntu-20.04, ubuntu-22.04, macos-12, macos-11] runs-on: ${{ matrix.os }} From 3294df5d3e929179ec25cc6b39118a09b021dd6e Mon Sep 17 00:00:00 2001 From: Peter Bittner Date: Fri, 26 Aug 2022 07:04:07 +0200 Subject: [PATCH 27/53] Verbose version of `git add` (gav) --- aliases/available/git.aliases.bash | 1 + 1 file changed, 1 insertion(+) diff --git a/aliases/available/git.aliases.bash b/aliases/available/git.aliases.bash index 507037e1d0..535665b14d 100644 --- a/aliases/available/git.aliases.bash +++ b/aliases/available/git.aliases.bash @@ -8,6 +8,7 @@ alias get='git' alias ga='git add' alias gall='git add -A' alias gap='git add -p' +alias gav='git add -v' # branch alias gb='git branch' From e5e7785c9697d2808459f9d6d7a6d8652db74d88 Mon Sep 17 00:00:00 2001 From: Brian Phillips <28457+brianphillips@users.noreply.github.com> Date: Tue, 30 Aug 2022 13:21:03 -0500 Subject: [PATCH 28/53] Update variable name to match projects.plugin.bash The projects plugin was changed to reference `BASH_IT_PROJECT_PATHS` but the completion was still using `PROJECT_PATHS` --- completion/available/projects.completion.bash | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/completion/available/projects.completion.bash b/completion/available/projects.completion.bash index 90735ee130..df4f5754dd 100644 --- a/completion/available/projects.completion.bash +++ b/completion/available/projects.completion.bash @@ -7,7 +7,7 @@ _is_function _rl_enabled || _pj() { _is_function _init_completion || return _is_function _rl_enabled || return - [ -n "$PROJECT_PATHS" ] || return + [ -n "$BASH_IT_PROJECT_PATHS" ] || return shift [ "$1" == "open" ] && shift @@ -21,7 +21,7 @@ _pj() { local -r mark_dirs=$(_rl_enabled mark-directories && echo y) local -r mark_symdirs=$(_rl_enabled mark-symlinked-directories && echo y) - for i in ${PROJECT_PATHS//:/$'\n'}; do + for i in ${BASH_IT_PROJECT_PATHS//:/$'\n'}; do # create an array of matched subdirs k="${#COMPREPLY[@]}" for j in $( compgen -d $i/$cur ); do From 0ab80429cea4edf6216e0bb539295460ae6706fd Mon Sep 17 00:00:00 2001 From: Dylan Tuttle Date: Thu, 22 Sep 2022 16:27:52 -0600 Subject: [PATCH 29/53] Removed Bash Dependency section from README and added it to troubleshooting.rst --- docs/README.md | 21 --------------------- docs/troubleshooting.rst | 21 +++++++++++++++++++++ 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/docs/README.md b/docs/README.md index 5d0da58343..f3d31a14fe 100644 --- a/docs/README.md +++ b/docs/README.md @@ -42,27 +42,6 @@ Stop polluting your `~/bin` directory and your `.bashrc` file, fork/clone Bash-i ``git clone --depth=1 https://github.com/Bash-it/bash-it.git ~/.bash_it`` 2) Run ``~/.bash_it/install.sh`` -### Bash Dependency - -Bash-it requires Bash 4.?? or later to run correctly. Any reasonably current Linux distribution should have shipped with a compatible version of Bash. However, macOS users must upgrade from the included, obsolete Bash version 3. While some functionality might work with Bash 3, there is no guarantee that everything will work perfectly. Thus, we recommend using [Homebrew](https://brew.sh/) to ensure Bash is up to date: - -**x86 Mac** - -```bash -$ brew install bash -$ sudo sh -c 'echo /usr/local/bin/bash >> /etc/shells' -$ chsh -s /usr/local/bin/bash -``` - -**M1 Mac** -Homebrew's default installation location on M1 is ``/opt/homebrew/bin/``: - -```bash -$ brew install bash -$ sudo sh -c 'echo /opt/homebrew/bin/bash >> /etc/shells' -$ chsh -s /opt/homebrew/bin/bash -``` - That's it! :smiley: You can check out more components of Bash-it, and customize it to your desire. diff --git a/docs/troubleshooting.rst b/docs/troubleshooting.rst index 6503699a98..953a129aaa 100644 --- a/docs/troubleshooting.rst +++ b/docs/troubleshooting.rst @@ -8,9 +8,30 @@ Table of Contents * `I'm stuck in the LightDM login screen after setting up bash-it. `_ +* `I'm getting strange line break and wrapping behaviour on macOS. `_ + I'm stuck in the LightDM login screen after setting up bash-it ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ **Possible issue**\ : `#672 `_ **Solution**\ : Check `this comment `_ for detailed information about the cause and solution for this issue. + +I'm getting strange line break and wrapping behaviour on macOS +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +**Possible issue**\ : `#1614 `_ + +**Solution**\ : Bash-it requires Bash 4.?? or later to run correctly. Any reasonably current Linux distribution should have shipped with a compatible version of Bash. However, macOS users must upgrade from the included, obsolete Bash version 3. While some functionality might work with Bash 3, there is no guarantee that everything will work perfectly. Thus, we recommend using `Homebrew `_ to ensure Bash is up to date: + +**x86 Mac:**\ +.. code-block:: console + $ brew install bash + $ sudo sh -c 'echo /usr/local/bin/bash >> /etc/shells' + $ chsh -s /usr/local/bin/bash + +**M1 Mac:**\ Homebrew's default installation location on M1 is ``/opt/homebrew/bin/``: +.. code-block:: console + $ brew install bash + $ sudo sh -c 'echo /opt/homebrew/bin/bash >> /etc/shells' + $ chsh -s /opt/homebrew/bin/bash From 606272ac23992283beffc6b9530581e7236eafcf Mon Sep 17 00:00:00 2001 From: Dylan Tuttle Date: Thu, 22 Sep 2022 16:49:26 -0600 Subject: [PATCH 30/53] Fixed broken code blocks in troubleshooting.rst --- docs/troubleshooting.rst | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/docs/troubleshooting.rst b/docs/troubleshooting.rst index 953a129aaa..93d9113ab3 100644 --- a/docs/troubleshooting.rst +++ b/docs/troubleshooting.rst @@ -24,14 +24,22 @@ I'm getting strange line break and wrapping behaviour on macOS **Solution**\ : Bash-it requires Bash 4.?? or later to run correctly. Any reasonably current Linux distribution should have shipped with a compatible version of Bash. However, macOS users must upgrade from the included, obsolete Bash version 3. While some functionality might work with Bash 3, there is no guarantee that everything will work perfectly. Thus, we recommend using `Homebrew `_ to ensure Bash is up to date: -**x86 Mac:**\ -.. code-block:: console - $ brew install bash - $ sudo sh -c 'echo /usr/local/bin/bash >> /etc/shells' - $ chsh -s /usr/local/bin/bash - -**M1 Mac:**\ Homebrew's default installation location on M1 is ``/opt/homebrew/bin/``: -.. code-block:: console - $ brew install bash - $ sudo sh -c 'echo /opt/homebrew/bin/bash >> /etc/shells' - $ chsh -s /opt/homebrew/bin/bash +x86 Mac +^^^^^^^ + + .. code-block:: bash + + brew install bash + sudo sh -c 'echo /usr/local/bin/bash >> /etc/shells' + chsh -s /usr/local/bin/bash + +M1 Mac +^^^^^^ + +Homebrew's default installation location on M1 is ``/opt/homebrew/bin/``: + + .. code-block:: bash + + brew install bash + sudo sh -c 'echo /opt/homebrew/bin/bash >> /etc/shells' + chsh -s /opt/homebrew/bin/bash From 00062bfcb6c6a68cd2c9d2c76ed764e01e930e87 Mon Sep 17 00:00:00 2001 From: David Farrell Date: Thu, 13 Oct 2022 10:34:57 -0700 Subject: [PATCH 31/53] chore: Use grep -E / grep -F instead of egrep / fgrep (#2164) Ensures that the -E or -F option, when used, is the first option * i.e. grep -oE => grep -E -o Updates _bash-it-grep to invoke grep with just the provided arguments * This function was (and still is) unused, but decided this new functionality was actually more useful Introduces _bash-it-fgrep to invoke grep -F Removes type -P egrep from the _bash-it-*grep functions For usages that were already going to be modified, use -F if appropriate * Does not touch grep usages that may have benefited from -F, but were not otherwise considered for this PR Adds shellcheck header to modified .bash files that didn't already have it --- completion/available/fabric.completion.bash | 6 +++--- completion/available/gradle.completion.bash | 4 +++- completion/available/makefile.completion.bash | 4 +++- lib/helpers.bash | 2 +- lib/utilities.bash | 20 ++++++++++++------- lint_clean_files.sh | 4 ++-- plugins/available/aws.plugin.bash | 7 ++++--- plugins/available/jekyll.plugin.bash | 4 ++-- plugins/available/postgres.plugin.bash | 3 ++- themes/rjorgenson/rjorgenson.theme.bash | 4 +++- 10 files changed, 36 insertions(+), 22 deletions(-) diff --git a/completion/available/fabric.completion.bash b/completion/available/fabric.completion.bash index 6f746454dc..a8984d9cc3 100644 --- a/completion/available/fabric.completion.bash +++ b/completion/available/fabric.completion.bash @@ -1,4 +1,4 @@ -#!/usr/bin/env bash +# shellcheck shell=bash # # Bash completion support for Fabric (http://fabfile.org/) # @@ -91,7 +91,7 @@ function __fab_completion() { -*) if [[ -z "${__FAB_COMPLETION_LONG_OPT}" ]]; then export __FAB_COMPLETION_LONG_OPT=$( - fab --help | egrep -o "\-\-[A-Za-z_\-]+\=?" | sort -u) + fab --help | grep -E -o "\-\-[A-Za-z_\-]+\=?" | sort -u) fi opts="${__FAB_COMPLETION_LONG_OPT}" ;; @@ -101,7 +101,7 @@ function __fab_completion() { # -*) # if [[ -z "${__FAB_COMPLETION_SHORT_OPT}" ]]; then # export __FAB_COMPLETION_SHORT_OPT=$( - # fab --help | egrep -o "^ +\-[A-Za-z_\]" | sort -u) + # fab --help | grep -E -o "^ +\-[A-Za-z_\]" | sort -u) # fi # opts="${__FAB_COMPLETION_SHORT_OPT}" # ;; diff --git a/completion/available/gradle.completion.bash b/completion/available/gradle.completion.bash index 35971d5075..ef9677c6de 100644 --- a/completion/available/gradle.completion.bash +++ b/completion/available/gradle.completion.bash @@ -1,3 +1,5 @@ +# shellcheck shell=bash + # Copyright (c) 2017 Eric Wendelin # Permission is hereby granted, free of charge, to any person obtaining a copy of @@ -66,7 +68,7 @@ __gradle-generate-script-cache() { if [[ ! $(find $cache_dir/$cache_name -mmin -$cache_ttl_mins 2>/dev/null) ]]; then # Cache all Gradle scripts - local gradle_build_scripts=$(find $project_root_dir -type f -name "*.gradle" -o -name "*.gradle.kts" 2>/dev/null | egrep -v "$script_exclude_pattern") + local gradle_build_scripts=$(find $project_root_dir -type f -name "*.gradle" -o -name "*.gradle.kts" 2>/dev/null | grep -E -v "$script_exclude_pattern") printf "%s\n" "${gradle_build_scripts[@]}" > $cache_dir/$cache_name fi } diff --git a/completion/available/makefile.completion.bash b/completion/available/makefile.completion.bash index e72ba6fd3b..018586cacf 100644 --- a/completion/available/makefile.completion.bash +++ b/completion/available/makefile.completion.bash @@ -1,3 +1,5 @@ +# shellcheck shell=bash + # Bash completion for Makefile # Loosely adapted from http://stackoverflow.com/a/38415982/1472048 @@ -17,7 +19,7 @@ _makecomplete() { for f in "${files[@]}" ; do while IFS='' read -r line ; do targets+=("$line") - done < <(grep -oE '^[a-zA-Z0-9_-]+:([^=]|$)' "$f" | cut -d':' -f1) + done < <(grep -E -o '^[a-zA-Z0-9_-]+:([^=]|$)' "$f" | cut -d':' -f1) done [ "${#targets[@]}" -eq 0 ] && return 0 diff --git a/lib/helpers.bash b/lib/helpers.bash index 2ee43a17af..3675b0f259 100644 --- a/lib/helpers.bash +++ b/lib/helpers.bash @@ -211,7 +211,7 @@ function _is_function() { _example '$ _is_function ls && echo exists' _group 'lib' local msg="${2:-Function '$1' does not exist}" - if LC_ALL=C type -t "$1" | _bash-it-egrep -q 'function'; then + if LC_ALL=C type -t "$1" | _bash-it-fgrep -q 'function'; then return 0 else _log_debug "$msg" diff --git a/lib/utilities.bash b/lib/utilities.bash index 6d5fd5d493..75e914b8c6 100644 --- a/lib/utilities.bash +++ b/lib/utilities.bash @@ -60,15 +60,21 @@ function _bash-it-array-dedup() { printf '%s\n' "$@" | sort -u } -# Outputs a full path of the grep found on the filesystem +# Runs `grep` with *just* the provided arguments function _bash-it-grep() { - : "${BASH_IT_GREP:=$(type -P egrep || type -P grep)}" - printf "%s" "${BASH_IT_GREP:-/usr/bin/grep}" + : "${BASH_IT_GREP:=$(type -P grep)}" + "${BASH_IT_GREP:-/usr/bin/grep}" "$@" } -# Runs `grep` with extended regular expressions +# Runs `grep` with fixed-string expressions (-F) +function _bash-it-fgrep() { + : "${BASH_IT_GREP:=$(type -P grep)}" + "${BASH_IT_GREP:-/usr/bin/grep}" -F "$@" +} + +# Runs `grep` with extended regular expressions (-E) function _bash-it-egrep() { - : "${BASH_IT_GREP:=$(type -P egrep || type -P grep)}" + : "${BASH_IT_GREP:=$(type -P grep)}" "${BASH_IT_GREP:-/usr/bin/grep}" -E "$@" } @@ -150,12 +156,12 @@ function _bash-it-component-list-matching() { function _bash-it-component-list-enabled() { local IFS=$'\n' component="$1" - _bash-it-component-help "${component}" | _bash-it-egrep '\[x\]' | awk '{print $1}' | sort -u + _bash-it-component-help "${component}" | _bash-it-fgrep '[x]' | awk '{print $1}' | sort -u } function _bash-it-component-list-disabled() { local IFS=$'\n' component="$1" - _bash-it-component-help "${component}" | _bash-it-egrep -v '\[x\]' | awk '{print $1}' | sort -u + _bash-it-component-help "${component}" | _bash-it-fgrep -v '[x]' | awk '{print $1}' | sort -u } # Checks if a given item is enabled for a particular component/file-type. diff --git a/lint_clean_files.sh b/lint_clean_files.sh index 26650b16de..cc2686042f 100755 --- a/lint_clean_files.sh +++ b/lint_clean_files.sh @@ -8,8 +8,8 @@ # shellcheck disable=SC2002 # Prefer 'cat' for cleaner script mapfile -t FILES < <( cat clean_files.txt \ - | grep -v -E '^\s*$' \ - | grep -v -E '^\s*#' \ + | grep -E -v '^\s*$' \ + | grep -E -v '^\s*#' \ | xargs -n1 -I{} find "{}" -type f ) diff --git a/plugins/available/aws.plugin.bash b/plugins/available/aws.plugin.bash index 54a8669171..14d26caefb 100644 --- a/plugins/available/aws.plugin.bash +++ b/plugins/available/aws.plugin.bash @@ -1,3 +1,4 @@ +# shellcheck shell=bash cite about-plugin about-plugin 'AWS helper functions' @@ -40,13 +41,13 @@ function __awskeys_help { function __awskeys_get { local ln=$(grep -n "\[ *$1 *\]" "${AWS_SHARED_CREDENTIALS_FILE}" | cut -d ":" -f 1) if [[ -n "${ln}" ]]; then - tail -n +${ln} "${AWS_SHARED_CREDENTIALS_FILE}" | egrep -m 2 "aws_access_key_id|aws_secret_access_key" - tail -n +${ln} "${AWS_SHARED_CREDENTIALS_FILE}" | egrep -m 1 "aws_session_token" + tail -n +${ln} "${AWS_SHARED_CREDENTIALS_FILE}" | grep -F -m 2 -e "aws_access_key_id" -e "aws_secret_access_key" + tail -n +${ln} "${AWS_SHARED_CREDENTIALS_FILE}" | grep -F -m 1 "aws_session_token" fi } function __awskeys_list { - local credentials_list="$((egrep '^\[ *[a-zA-Z0-9_-]+ *\]$' "${AWS_SHARED_CREDENTIALS_FILE}"; grep "\[profile" "${AWS_CONFIG_FILE}" | sed "s|\[profile |\[|g") | sort | uniq)" + local credentials_list="$((grep -E '^\[ *[a-zA-Z0-9_-]+ *\]$' "${AWS_SHARED_CREDENTIALS_FILE}"; grep "\[profile" "${AWS_CONFIG_FILE}" | sed "s|\[profile |\[|g") | sort | uniq)" if [[ -n $"{credentials_list}" ]]; then echo -e "Available credentials profiles:\n" for profile in ${credentials_list}; do diff --git a/plugins/available/jekyll.plugin.bash b/plugins/available/jekyll.plugin.bash index d818b07628..3c12d82662 100644 --- a/plugins/available/jekyll.plugin.bash +++ b/plugins/available/jekyll.plugin.bash @@ -30,8 +30,8 @@ function editpost() { pushd "${SITE}/_posts" > /dev/null || return for POST in *; do - DATE="$(echo "${POST}" | grep -oE "[0-9]{4}-[0-9]{1,2}-[0-9]{1,2}")" - TITLE="$(grep -oE "title: (.+)" < "${POST}")" + DATE="$(echo "${POST}" | grep -E -o "[0-9]{4}-[0-9]{1,2}-[0-9]{1,2}")" + TITLE="$(grep -E -o "title: (.+)" < "${POST}")" TITLE="${TITLE/title: /}" echo "${COUNTER}) ${DATE} ${TITLE}" POSTS[COUNTER]="$POST" diff --git a/plugins/available/postgres.plugin.bash b/plugins/available/postgres.plugin.bash index 8f239985e0..9f66152b5c 100644 --- a/plugins/available/postgres.plugin.bash +++ b/plugins/available/postgres.plugin.bash @@ -1,3 +1,4 @@ +# shellcheck shell=bash cite about-plugin about-plugin 'postgres helper functions' @@ -50,7 +51,7 @@ function postgres_status { function is_postgres_running { - $POSTGRES_BIN/pg_ctl -D $PGDATA status | egrep -o "no server running" + $POSTGRES_BIN/pg_ctl -D $PGDATA status | grep -F -o "no server running" } diff --git a/themes/rjorgenson/rjorgenson.theme.bash b/themes/rjorgenson/rjorgenson.theme.bash index 71d29e7866..6e73c4a28c 100644 --- a/themes/rjorgenson/rjorgenson.theme.bash +++ b/themes/rjorgenson/rjorgenson.theme.bash @@ -1,3 +1,5 @@ +# shellcheck shell=bash + # port of zork theme # set colors for use throughout the prompt @@ -50,7 +52,7 @@ function is_integer() { # helper function for todo-txt-count todo_txt_count() { if `hash todo.sh 2>&-`; then # is todo.sh installed - count=`todo.sh ls | egrep "TODO: [0-9]+ of ([0-9]+) tasks shown" | awk '{ print $4 }'` + count=`todo.sh ls | grep -E "TODO: [0-9]+ of ([0-9]+) tasks shown" | awk '{ print $4 }'` if is_integer $count; then # did we get a sane answer back echo "${BRACKET_COLOR}[${STRING_COLOR}T:$count${BRACKET_COLOR}]$normal" fi From 7c77223b154bf8d0f7d6d879bebbb7efb91ca548 Mon Sep 17 00:00:00 2001 From: gmajkic Date: Thu, 13 Oct 2022 17:02:14 +0200 Subject: [PATCH 32/53] fix(theme): use correct escape sequence to avoid weird text overwriting --- themes/parrot/parrot.theme.bash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/themes/parrot/parrot.theme.bash b/themes/parrot/parrot.theme.bash index a0d259dd62..251eb942f7 100644 --- a/themes/parrot/parrot.theme.bash +++ b/themes/parrot/parrot.theme.bash @@ -2,7 +2,7 @@ # git branch parser function parse_git_branch() { - echo -e "\033[1;34m$(git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/')\033[0m" + echo -e "\[\033[1;34m\]$(git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/')\[\033[0m\]" } function parse_git_branch_no_color() { From 1c9cfd056bab4244cdc1b9dc3082da8e2cda7f9e Mon Sep 17 00:00:00 2001 From: David Farrell Date: Sun, 30 Oct 2022 15:15:28 -0700 Subject: [PATCH 33/53] bug:Install shellcheck wget (#2173) Installs shellcheck via wget of github release for 'stable' linux version --- .github/workflows/ci.yml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1d1c0ecae6..8e772ec5e8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -49,10 +49,17 @@ jobs: uses: actions/setup-python@v2 with: python-version: 3.8 + # - name: Update APT Package Lists + # run: sudo apt-get update - name: Install shfmt run: GO111MODULE=on go get mvdan.cc/sh/v3/cmd/shfmt - name: Install shellcheck - run: brew install shellcheck + env: + scversion: stable # Or latest, vxx, etc + run: | + wget -qO- "https://github.com/koalaman/shellcheck/releases/download/${scversion?}/shellcheck-${scversion?}.linux.x86_64.tar.xz" | tar -xJv "shellcheck-${scversion}/shellcheck" + sudo cp "shellcheck-${scversion}/shellcheck" /usr/bin/ + shellcheck --version - name: Install pre-commit run: python3 -m pip install -r test/lint-requirements.txt - name: Run lint From 7c7e4f90ec937fb6ea4acf83698a28a86ef3b875 Mon Sep 17 00:00:00 2001 From: David Farrell Date: Wed, 26 Oct 2022 15:23:11 -0700 Subject: [PATCH 34/53] bug: Use en_US when fetching EPOCHREALTIME Isolates fetching of EPOCHREALTIME to a function which sets LC_ALL=en_US.UTF-8. This ensures that the value is in decimal format, regardless of runtime locale. bug: Hide duration when no command executed --- lib/command_duration.bash | 21 ++++++++++++++++--- .../available/cmd-returned-notify.plugin.bash | 3 ++- test/plugins/cmd-returned-notify.plugin.bats | 6 +++--- 3 files changed, 23 insertions(+), 7 deletions(-) diff --git a/lib/command_duration.bash b/lib/command_duration.bash index cd1d6636db..ec4d828d0c 100644 --- a/lib/command_duration.bash +++ b/lib/command_duration.bash @@ -2,12 +2,24 @@ # # Functions for measuring and reporting how long a command takes to run. -: "${COMMAND_DURATION_START_SECONDS:=${EPOCHREALTIME:-$SECONDS}}" +# Get shell duration in decimal format regardless of runtime locale. +# Notice: This function runs as a sub-shell - notice '(' vs '{'. +function _shell_duration_en() ( + # DFARREL You would think LC_NUMERIC would do it, but not working in my local + LC_ALL='en_US.UTF-8' + printf "%s" "${EPOCHREALTIME:-$SECONDS}" +) + +: "${COMMAND_DURATION_START_SECONDS:=$(_shell_duration_en)}" : "${COMMAND_DURATION_ICON:=🕘}" : "${COMMAND_DURATION_MIN_SECONDS:=1}" function _command_duration_pre_exec() { - COMMAND_DURATION_START_SECONDS="${EPOCHREALTIME:-$SECONDS}" + COMMAND_DURATION_START_SECONDS="$(_shell_duration_en)" +} + +function _command_duration_pre_cmd() { + COMMAND_DURATION_START_SECONDS="" } function _dynamic_clock_icon { @@ -20,13 +32,15 @@ function _dynamic_clock_icon { function _command_duration() { [[ -n "${BASH_IT_COMMAND_DURATION:-}" ]] || return + [[ -n "${COMMAND_DURATION_START_SECONDS:-}" ]] || return local command_duration=0 command_start="${COMMAND_DURATION_START_SECONDS:-0}" local -i minutes=0 seconds=0 deciseconds=0 local -i command_start_seconds="${command_start%.*}" local -i command_start_deciseconds=$((10#${command_start##*.})) command_start_deciseconds="${command_start_deciseconds:0:1}" - local current_time="${EPOCHREALTIME:-$SECONDS}" + local current_time + current_time="$(_shell_duration_en)" local -i current_time_seconds="${current_time%.*}" local -i current_time_deciseconds="$((10#${current_time##*.}))" current_time_deciseconds="${current_time_deciseconds:0:1}" @@ -59,3 +73,4 @@ function _command_duration() { } _bash_it_library_finalize_hook+=("safe_append_preexec '_command_duration_pre_exec'") +_bash_it_library_finalize_hook+=("safe_append_prompt_command '_command_duration_pre_cmd'") diff --git a/plugins/available/cmd-returned-notify.plugin.bash b/plugins/available/cmd-returned-notify.plugin.bash index 88c07722df..e6d221faac 100644 --- a/plugins/available/cmd-returned-notify.plugin.bash +++ b/plugins/available/cmd-returned-notify.plugin.bash @@ -4,7 +4,8 @@ about-plugin 'Alert (BEL) when process ends after a threshold of seconds' function precmd_return_notification() { local command_start="${COMMAND_DURATION_START_SECONDS:=0}" - local current_time="${EPOCHREALTIME:-$SECONDS}" + local current_time + current_time="$(_shell_duration_en)" local -i command_duration="$((${current_time%.*} - ${command_start%.*}))" if [[ "${command_duration}" -gt "${NOTIFY_IF_COMMAND_RETURNS_AFTER:-5}" ]]; then printf '\a' diff --git a/test/plugins/cmd-returned-notify.plugin.bats b/test/plugins/cmd-returned-notify.plugin.bats index 04edad9582..a5ae591a51 100644 --- a/test/plugins/cmd-returned-notify.plugin.bats +++ b/test/plugins/cmd-returned-notify.plugin.bats @@ -9,7 +9,7 @@ function local_setup_file() { @test "plugins cmd-returned-notify: notify after elapsed time" { export NOTIFY_IF_COMMAND_RETURNS_AFTER=0 - export COMMAND_DURATION_START_SECONDS="${EPOCHREALTIME:-$SECONDS}" + export COMMAND_DURATION_START_SECONDS="$(_shell_duration_en)" sleep 1 run precmd_return_notification assert_success @@ -18,7 +18,7 @@ function local_setup_file() { @test "plugins cmd-returned-notify: do not notify before elapsed time" { export NOTIFY_IF_COMMAND_RETURNS_AFTER=10 - export COMMAND_DURATION_START_SECONDS="${EPOCHREALTIME:-$SECONDS}" + export COMMAND_DURATION_START_SECONDS="$(_shell_duration_en)" sleep 1 run precmd_return_notification assert_success @@ -34,7 +34,7 @@ function local_setup_file() { @test "lib command_duration: preexec set COMMAND_DURATION_START_SECONDS" { export COMMAND_DURATION_START_SECONDS= assert_equal "${COMMAND_DURATION_START_SECONDS}" "" - NOW="${EPOCHREALTIME:-$SECONDS}" + NOW="$(_shell_duration_en)" _command_duration_pre_exec # We need to make sure to account for nanoseconds... assert_equal "${COMMAND_DURATION_START_SECONDS%.*}" "${NOW%.*}" From 5f59cb54383e912e001a7c2ad64b655cadae100f Mon Sep 17 00:00:00 2001 From: cornfeedhobo Date: Fri, 30 Sep 2022 11:29:35 -0500 Subject: [PATCH 35/53] remove function wrapper around kubectl alias registration --- aliases/available/kubectl.aliases.bash | 30 +++++++++++--------------- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/aliases/available/kubectl.aliases.bash b/aliases/available/kubectl.aliases.bash index aaca4ca259..ce01bdafcf 100644 --- a/aliases/available/kubectl.aliases.bash +++ b/aliases/available/kubectl.aliases.bash @@ -1,20 +1,16 @@ # shellcheck shell=bash about-alias 'kubectl aliases' -function _set_pkg_aliases() { - 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' - alias kcdd='kubectl describe deployment' - 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 netshoot-$(date +%s) --rm -i --tty --image nicolaka/netshoot -- /bin/bash' - fi -} - -_set_pkg_aliases +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' + alias kcdd='kubectl describe deployment' + 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 netshoot-$(date +%s) --rm -i --tty --image nicolaka/netshoot -- /bin/bash' +fi From f0941e9ba213e87a26172e31ceb4c3b629d8e580 Mon Sep 17 00:00:00 2001 From: Peter Bittner Date: Fri, 26 Aug 2022 10:07:21 +0200 Subject: [PATCH 36/53] Add more aliases for `git branch`, use long form Git can list local branches, remote branches, and both of them together. Let's use the long form of the options to make the aliases quicker to understand. As agreed in PR #2159, we introduce gbl and replace gba/gbr by gbla/gblr. gbl/gbla/gblr allow wildcard arguments for filtering branch names. --- aliases/available/git.aliases.bash | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/aliases/available/git.aliases.bash b/aliases/available/git.aliases.bash index 535665b14d..5572c9322c 100644 --- a/aliases/available/git.aliases.bash +++ b/aliases/available/git.aliases.bash @@ -12,10 +12,14 @@ alias gav='git add -v' # branch alias gb='git branch' -alias gbD='git branch -D' -alias gba='git branch -a' +alias gba='git branch --all' alias gbd='git branch -d' -alias gbm='git branch -m' +alias gbD='git branch -D' +alias gbl='git branch --list' +alias gbla='git branch --list --all' +alias gblr='git branch --list --remotes' +alias gbm='git branch --move' +alias gbr='git branch --remotes' alias gbt='git branch --track' alias gdel='git branch -D' From 66ae9b0de8ca313fb208be75296af2c90b024740 Mon Sep 17 00:00:00 2001 From: Noah Gorny Date: Tue, 6 Dec 2022 00:22:27 +0200 Subject: [PATCH 37/53] Remove libra chat reference We will try to use Github Discussions now. --- docs/README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/docs/README.md b/docs/README.md index f3d31a14fe..b307a7abfd 100644 --- a/docs/README.md +++ b/docs/README.md @@ -4,7 +4,6 @@ ![Docs Status](https://readthedocs.org/projects/bash-it/badge/) ![License](https://img.shields.io/github/license/Bash-it/bash-it) ![shell](https://img.shields.io/badge/Shell-Bash-blue) -[![Join the chat at https://web.libera.chat/?channel=#bash-it](https://img.shields.io/badge/chat-on%20Libera.Chat-brightgreen.svg)](https://web.libera.chat/?channel=#bash-it) **Bash-it** is a collection of community Bash commands and scripts for Bash 3.2+. (And a shameless ripoff of [oh-my-zsh](https://github.com/robbyrussell/oh-my-zsh) :smiley:) From feb468b517e1393a46eec020a07ab81d739b2a2b Mon Sep 17 00:00:00 2001 From: BF <38326544+convergedtarkus@users.noreply.github.com> Date: Wed, 25 Jan 2023 17:56:14 -0600 Subject: [PATCH 38/53] bug: Use C style strings when checking for invalid alias characters (#2188) * Use C style strings when checking for invalid alias characters Before, the '\n' would be interpreted as 'n' meaning that any alias who's command contained the letter 'n' would incorrect be skipped. * No need to escape characters in this context Escaping was just adding \ to the list multiple times Co-authored-by: David Farrell --- completion/available/aliases.completion.bash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/completion/available/aliases.completion.bash b/completion/available/aliases.completion.bash index f9cc1ed181..3e45e960cf 100644 --- a/completion/available/aliases.completion.bash +++ b/completion/available/aliases.completion.bash @@ -50,7 +50,7 @@ function _bash-it-component-completion-callback-on-init-aliases() { fi # skip aliases to pipes, boolean control structures and other command lists - chars='\|\&\;\)\(\n\<\>' + chars=$'|&;()<>\n' if [[ "${alias_defn}" =~ [$chars] ]]; then continue fi From 78f88406cf9d6756b50ed2d3711334d4020fd913 Mon Sep 17 00:00:00 2001 From: Gurkirat Singh Date: Wed, 22 Feb 2023 21:49:12 +0530 Subject: [PATCH 39/53] Fix lint errors in multiple files (#2192) * fix (plugins): enable interpretation of backslash escapes in colors * fix (lint): disable SC2317 in install.sh * fix (lint): SC2086 in agnoster theme * fix (lint): remove exit from install.sh as it is already implemented in the calling function --- install.sh | 1 - plugins/available/colors.plugin.bash | 4 ++-- themes/agnoster/agnoster.theme.bash | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/install.sh b/install.sh index 2bb78a3f64..58c25537b6 100755 --- a/install.sh +++ b/install.sh @@ -12,7 +12,6 @@ function _bash-it_show_usage() { echo "--no-modify-config (-n): Do not modify existing config file" echo "--append-to-config (-a): Keep existing config file and append bash-it templates at the end" echo "--overwrite-backup (-f): Overwrite existing backup" - exit 0 } # enable a thing diff --git a/plugins/available/colors.plugin.bash b/plugins/available/colors.plugin.bash index 47f55609af..73c144b88e 100644 --- a/plugins/available/colors.plugin.bash +++ b/plugins/available/colors.plugin.bash @@ -8,13 +8,13 @@ function __() { function __make_ansi() { next=$1 shift - echo "\[\e[$("__$next" "$@")m\]" + echo -e "\[\e[$("__$next" "$@")m\]" } function __make_echo() { next=$1 shift - echo "\033[$("__$next" "$@")m" + echo -e "\033[$("__$next" "$@")m" } function __reset() { diff --git a/themes/agnoster/agnoster.theme.bash b/themes/agnoster/agnoster.theme.bash index 20c184f382..d5bac5ca69 100644 --- a/themes/agnoster/agnoster.theme.bash +++ b/themes/agnoster/agnoster.theme.bash @@ -182,7 +182,7 @@ prompt_segment() { # declare -p codes if [[ $CURRENT_BG != NONE && $1 != "$CURRENT_BG" ]]; then - declare -a intermediate=("$(fg_color $CURRENT_BG)" "$(bg_color "$1")") + declare -a intermediate=("$(fg_color "$CURRENT_BG")" "$(bg_color "$1")") debug "pre prompt " "$(ansi intermediate[@])" PR="$PR $(ansi intermediate[@])$SEGMENT_SEPARATOR" debug "post prompt " "$(ansi codes[@])" From 05ef68acbcfbba15ad261e2632b670671c87f644 Mon Sep 17 00:00:00 2001 From: Gurkirat Singh Date: Wed, 22 Feb 2023 21:50:45 +0530 Subject: [PATCH 40/53] Implement yarn completion (#2190) * feat (completion): add yarn completion --- clean_files.txt | 1 + completion/available/yarn.completion.bash | 5 + .../github.com/dsifford/yarn-completion/yarn | 1208 +++++++++++++++++ 3 files changed, 1214 insertions(+) create mode 100644 completion/available/yarn.completion.bash create mode 100644 vendor/github.com/dsifford/yarn-completion/yarn diff --git a/clean_files.txt b/clean_files.txt index 192fefa64f..758e3b80a7 100644 --- a/clean_files.txt +++ b/clean_files.txt @@ -76,6 +76,7 @@ completion/available/system.completion.bash completion/available/vault.completion.bash completion/available/vuejs.completion.bash completion/available/wpscan.completion.bash +completion/available/yarn.completion.bash # libraries lib/appearance.bash diff --git a/completion/available/yarn.completion.bash b/completion/available/yarn.completion.bash new file mode 100644 index 0000000000..de1240851b --- /dev/null +++ b/completion/available/yarn.completion.bash @@ -0,0 +1,5 @@ +# shellcheck shell=bash +about-completion "yarn cli completions" + +# shellcheck disable=SC1090 source=../../vendor/github.com/dsifford/yarn-completion/yarn +source "${BASH_IT}/vendor/github.com/dsifford/yarn-completion/yarn" diff --git a/vendor/github.com/dsifford/yarn-completion/yarn b/vendor/github.com/dsifford/yarn-completion/yarn new file mode 100644 index 0000000000..ff78e47137 --- /dev/null +++ b/vendor/github.com/dsifford/yarn-completion/yarn @@ -0,0 +1,1208 @@ +# shellcheck shell=bash disable=2207 +# vim: set fdm=syntax fdl=0: +# +# Version: 0.17.0 +# Yarn Version: 1.22.11 +# +# bash completion for Yarn (https://github.com/yarnpkg/yarn) +# +# To enable on-demand completion loading, copy this file to one of the following locations: +# - $BASH_COMPLETION_USER_DIR/completions/yarn +# or +# - $XDG_DATA_HOME/bash-completion/completions/yarn +# or +# - ~/.local/share/bash-completion/completions/yarn +# + +### +# Parses and extracts data from package.json files. +# +# Usage: +# __yarn_get_package_fields [-g] [-t FIELDTYPE] +# +# Options: +# -g Parse global package.json file, if available +# -t FIELDTYPE The field type being parsed (array|boolean|number|object|string) [default: object] +# +# Notes: +# If FIELDTYPE is object, then the object keys are returned. +# If FIELDTYPE is array, boolean, number, or string, then the field values are returned. +# must be a first-level field in the json file. +## +__yarn_get_package_fields() { + declare cwd=$PWD field_type=object field_key opt package_dot_json OPTIND OPTARG + + while [[ -n $cwd ]]; do + if [[ -f "$cwd/package.json" ]]; then + package_dot_json="$cwd/package.json" + break + fi + cwd="${cwd%/*}" + done + + while getopts ":gt:" opt; do + case $opt in + g) + if [[ -f $HOME/.config/yarn/global/package.json ]]; then + package_dot_json="$HOME/.config/yarn/global/package.json" + elif [[ -f $HOME/.local/share/yarn/global/package.json ]]; then + package_dot_json="$HOME/.local/share/yarn/global/package.json" + elif [[ -f $HOME/.yarn/global/package.json ]]; then + package_dot_json="$HOME/.yarn/global/package.json" + else + package_dot_json="" + fi + ;; + t) + case "$OPTARG" in + array | boolean | number | object | string) + field_type="$OPTARG" + ;; + esac + ;; + *) ;; + + esac + done + shift $((OPTIND - 1)) + + field_key='"'$1'"' + + [[ ! -f $package_dot_json || ! $field_key ]] && return + + case "$field_type" in + object) + sed -n '/'"$field_key"':[[:space:]]*{/,/^[[:space:]]*}/{ + # exclude start and end patterns + //!{ + # extract the text between the first pair of double quotes + s/^[[:space:]]*"\([^"]*\).*/\1/p + } + }' "$package_dot_json" + ;; + array) + sed -n '/'"$field_key"':[[:space:]]*\[/,/^[[:space:]]*]/{ + # exclude start and end patterns + //!{ + # extract the text between the first pair of double quotes + s/^[[:space:]]*"\([^"]*\).*/\1/p + } + }' "$package_dot_json" + ;; + boolean | number) + sed -n 's/[[:space:]]*'"$field_key"':[[:space:]]*\([a-z0-9]*\)/\1/p' "$package_dot_json" + ;; + string) + sed -n 's/[[:space:]]*'"$field_key"':[[:space:]]*"\(.*\)".*/\1/p' "$package_dot_json" + ;; + esac +} + +### +# Count all command arguments starting at a given depth, excluding flags and +# flag arguments. +# +# Usage: +# __yarn_count_args [-d INT] +# +# Options: +# -d INT The start depth to begin counting [default: 0] +# +# Globals: +# *args +# cword +## +__yarn_count_args() { + args=0 + declare -i counter=0 depth=0 + declare arg_flag_pattern opt OPTIND + arg_flag_pattern="@($(tr ' ' '|' <<< "${arg_flags[*]}"))" + + while getopts ":d:" opt; do + case $opt in + d) + depth=$OPTARG + ;; + *) ;; + esac + done + shift $((OPTIND - 1)) + + while ((counter < cword)); do + case ${words[counter]} in + -* | =) ;; + *) + # shellcheck disable=SC2053 + if [[ ${words[counter - 1]} != $arg_flag_pattern ]]; then + if ((depth-- <= 0)); then + ((args++)) + fi + fi + ;; + esac + ((counter++)) + done +} + +### +# Retrieves the command or subcommand at a given depth, or the last occurring +# command or subcommand before the cursor location if no depth is given, or if +# depth exceeds cursor location. +# +# Usage: +# __yarn_get_command [-d INT] +# +# Options: +# -d INT Depth of command to retrieve. +# +# Globals: +# *cmd +# commands +# cword +# subcommands +# words +## +__yarn_get_command() { + declare -i counter=0 cmd_depth=0 OPTIND + declare cmdlist word opt + + while getopts ":d:" opt; do + case $opt in + d) + cmd_depth="$OPTARG" + ;; + *) ;; + esac + done + shift $((OPTIND - 1)) + + cmdlist="@($(tr ' ' '|' <<< "${commands[*]} ${subcommands[*]}"))" + cmd=yarn + + while ((counter < cword)); do + word="${words[counter]}" + case "$word" in + $cmdlist) + cmd="$word" + ((--cmd_depth == 0)) && break + ;; + esac + ((counter++)) + done +} + +### +# Global fallback completion generator if all else fails. +# +# Usage: +# __yarn_fallback +# +# Globals: +# cur +## +__yarn_fallback() { + case "$cur" in + -*) + COMPREPLY=($(compgen -W "$(__yarn_flags)" -- "$cur")) + ;; + *) + COMPREPLY=($(compgen -o plusdirs -f -- "$cur")) + ;; + esac +} + +### +# Process and merge local and global flags after removing the flags that +# have already been used. +# +# Usage: +# __yarn_flags +# +# Globals: +# flags +# global_flags +# words +## +__yarn_flags() { + declare word + declare -a existing_flags=() + + for word in "${words[@]}"; do + case "$word" in + -*) + existing_flags+=("$word") + ;; + esac + done + + LC_ALL=C comm -23 \ + <(echo "${flags[@]}" "${global_flags[@]}" | tr ' ' '\n' | LC_ALL=C sort -u) \ + <(echo "${existing_flags[@]}" | tr ' ' '\n' | LC_ALL=C sort -u) +} + +### +# Handles completions for flags that require, or optionally take, arguments. +# +# Usage: +# __yarn_flag_args +# +# Globals: +# cur +# prev +## +__yarn_flag_args() { + declare {arg,bool,dir,file,int,special}_flag_pattern + arg_flag_pattern="@($(tr ' ' '|' <<< "${arg_flags[*]}"))" + + # shellcheck disable=SC2053 + if [[ $prev != $arg_flag_pattern ]]; then + return 1 + fi + + bool_flag_pattern="@($(tr ' ' '|' <<< "${bool_arg_flags[*]}"))" + dir_flag_pattern="@($(tr ' ' '|' <<< "${dir_arg_flags[*]}"))" + file_flag_pattern="@($(tr ' ' '|' <<< "${file_arg_flags[*]}"))" + int_flag_pattern="@($(tr ' ' '|' <<< "${int_arg_flags[*]}"))" + special_flag_pattern="@($(tr ' ' '|' <<< "${special_arg_flags[*]}"))" + + case "$prev" in + $bool_flag_pattern) + COMPREPLY=($(compgen -W 'true false' -- "$cur")) + ;; + $dir_flag_pattern) + compopt -o dirnames + ;; + $file_flag_pattern) + compopt -o default -o filenames + ;; + $int_flag_pattern) + compopt -o nospace + COMPREPLY=($(compgen -W '{0..9}' -- "$cur")) + ;; + $special_flag_pattern) + case "$prev" in + --access) + COMPREPLY=($(compgen -W 'public restricted' -- "$cur")) + ;; + --groups) + COMPREPLY=($(compgen -W 'dependencies devDependencies optionalDependencies' -- "$cur")) + ;; + --level) + COMPREPLY=($(compgen -W 'info low moderate high critical' -- "$cur")) + ;; + --network-timeout) + compopt -o nospace + COMPREPLY=($(compgen -W '{1000..10000..1000}' -- "$cur")) + ;; + esac + ;; + esac + return 0 +} + +_yarn_add() { + ((depth++)) + flags=( + --audit -A + --dev -D + --exact -E + --optional -O + --peer -P + --tilde -T + --ignore-workspace-root-check -W + ) + return 1 +} + +_yarn_audit() { + ((depth++)) + flags=( + --groups + --level + --summary + ) + return 1 +} + +_yarn_autoclean() { + ((depth++)) + flags=( + --force -F + --init -I + ) + return 1 +} + +_yarn_cache() { + ((depth++)) + declare cmd + flags=( + --pattern + ) + subcommands=( + clean + dir + list + ) + __yarn_get_command + + case "$cmd" in + cache) + case "$cur" in + -*) + return 1 + ;; + *) + COMPREPLY=($(compgen -W "${subcommands[*]}" -- "$cur")) + return 0 + ;; + esac + ;; + *) + return 1 + ;; + esac +} + +_yarn_check() { + ((depth++)) + flags=( + --integrity + --verify-tree + ) + return 1 +} + +_yarn_config() { + ((depth++)) + declare cmd + declare subcommands=( + delete + get + list + set + ) + declare known_keys=( + ignore-optional + ignore-platform + ignore-scripts + init-author-email + init-author-name + init-author-url + init-license + init-version + no-progress + prefix + registry + save-prefix + user-agent + version-git-message + version-git-sign + version-git-tag + version-tag-prefix + ) + __yarn_get_command + + case "$cmd" in + get | delete) + case "$cur" in + -*) ;; + *) + if [[ $prev == @(get|delete) ]]; then + COMPREPLY=($(compgen -W "${known_keys[*]}" -- "$cur")) + return 0 + fi + ;; + esac + ;; + set) + case "$cur" in + -*) + flags=( + --global + ) + ;; + *) + if [[ $prev == set ]]; then + COMPREPLY=($(compgen -W "${known_keys[*]}" -- "$cur")) + return 0 + fi + ;; + esac + ;; + config) + case "$cur" in + -*) ;; + *) + COMPREPLY=($(compgen -W "${subcommands[*]}" -- "$cur")) + return 0 + ;; + esac + ;; + esac + return 1 +} + +_yarn_create() { + ((depth++)) + declare -i args + case "$cur" in + -*) ;; + *) + __yarn_count_args -d $depth + ((args == 0)) && return 0 + ;; + esac + return 1 +} + +_yarn_generate_lock_entry() { + ((depth++)) + flags=( + --resolved + --use-manifest + ) + return 1 +} + +_yarn_global() { + ((depth++)) + declare cmd cmdlist + flags=( + --latest + --prefix + ) + subcommands=( + add + bin + list + remove + upgrade + upgrade-interactive + ) + cmdlist="@($(tr ' ' '|' <<< "${subcommands[*]}"))" + + __yarn_get_command -d 3 + + case "$cur" in + -*) ;; + *) + case "$cmd" in + $cmdlist) + "_yarn_${cmd//-/_}" 2> /dev/null + return $? + ;; + global) + COMPREPLY=($(compgen -W "${subcommands[*]}" -- "$cur")) + return 0 + ;; + esac + ;; + esac + + return 1 +} + +_yarn_help() { + ((depth++)) + declare -i args + case "$cur" in + -*) ;; + *) + __yarn_count_args -d $depth + if ((args == 0)); then + COMPREPLY=($(compgen -W "${commands[*]}" -- "$cur")) + return 0 + fi + ;; + esac + return 1 +} + +_yarn_info() { + ((depth++)) + flags=( + --json + ) + declare standard_fields=( + author + bin + bugs + contributors + dependencies + description + devDependencies + dist-tags + engines + files + homepage + keywords + license + main + maintainers + name + optionalDependencies + peerDependencies + repository + version + versions + ) + + declare -i args + __yarn_count_args -d $depth + + case "$cur" in + -*) ;; + *) + case "$args" in + 0) + COMPREPLY=( + $(compgen -W " + $(__yarn_get_package_fields dependencies) + $(__yarn_get_package_fields devDependencies) + " -- "$cur") + ) + return 0 + ;; + 1) + COMPREPLY=($(compgen -W "${standard_fields[*]}" -- "$cur")) + return 0 + ;; + esac + ;; + esac + return 1 +} + +_yarn_init() { + ((depth++)) + flags=( + --yes -y + --private -p + --install -i + ) + return 1 +} + +_yarn_install() { + ((depth++)) + flags=( + --audit -A + ) + return 1 +} + +_yarn_licenses() { + ((depth++)) + declare cmd + subcommands=( + list + generate-disclaimer + ) + case "$cur" in + -*) ;; + *) + __yarn_get_command + case "$cmd" in + licenses) + COMPREPLY=($(compgen -W "${subcommands[*]}" -- "$cur")) + return 0 + ;; + esac + ;; + esac + return 1 +} + +_yarn_list() { + ((depth++)) + flags=( + --depth + --pattern + ) + return 1 +} + +_yarn_node() { + ((depth++)) + flags=( + --into + ) + return 1 +} + +_yarn_outdated() { + ((depth++)) + case "$cur" in + -*) ;; + *) + COMPREPLY=( + $(compgen -W " + $(__yarn_get_package_fields dependencies) + $(__yarn_get_package_fields devDependencies) + " -- "$cur") + ) + return 0 + ;; + esac + return 1 +} + +_yarn_owner() { + ((depth++)) + declare cmd + subcommands=( + add + list + remove + ) + __yarn_get_command + if [[ $cmd == owner ]]; then + case "$cur" in + -*) ;; + *) + COMPREPLY=($(compgen -W "${subcommands[*]}" -- "$cur")) + return 0 + ;; + esac + fi + return 1 +} + +_yarn_pack() { + ((depth++)) + flags=( + --filename -f + ) + return 1 +} + +_yarn_policies() { + ((depth++)) + declare standard_policies=( + latest + nightly + rc + ) + + declare -i args + __yarn_count_args -d $depth + + case "$cur" in + -*) ;; + *) + case "$args" in + 0) + COMPREPLY=($(compgen -W "${standard_policies[*]}" -- "$cur")) + return 0 + ;; + esac + ;; + esac + return 1 +} + +_yarn_publish() { + ((depth++)) + flags=( + --access + --major + --message + --minor + --new-version + --no-commit-hooks + --no-git-tag-version + --patch + --preid + --premajor + --preminor + --prepatch + --prerelease + --tag + ) + return 1 +} + +_yarn_remove() { + ((depth++)) + declare cmd dependencies devDependencies + flags=( + --ignore-workspace-root-check -W + ) + __yarn_get_command -d 1 + case "$cmd" in + global) + dependencies=$(__yarn_get_package_fields -g dependencies) + devDependencies='' + ;; + remove) + dependencies=$(__yarn_get_package_fields dependencies) + devDependencies=$(__yarn_get_package_fields devDependencies) + ;; + *) + return 1 + ;; + esac + case "$cur" in + -*) ;; + *) + COMPREPLY=($(compgen -W "$dependencies $devDependencies" -- "$cur")) + return 0 + ;; + esac + return 1 +} + +_yarn_run() { + ((depth++)) + declare cmd + subcommands=( + env + $(__yarn_get_package_fields scripts) + ) + __yarn_get_command + if [[ $cmd == run ]]; then + case "$cur" in + -*) ;; + *) + COMPREPLY=($(compgen -W "${subcommands[*]}" -- "$cur")) + return 0 + ;; + esac + fi + return 1 +} + +_yarn_tag() { + ((depth++)) + declare cmd + subcommands=( + add + list + remove + ) + __yarn_get_command + case "$cmd" in + tag) + case "$cur" in + -*) ;; + *) + COMPREPLY=($(compgen -W "${subcommands[*]}" -- "$cur")) + return 0 + ;; + esac + ;; + esac + return 1 +} + +_yarn_team() { + ((depth++)) + declare cmd + subcommands=( + add + create + destroy + list + remove + ) + __yarn_get_command + case "$cmd" in + team) + case "$cur" in + -*) ;; + *) + COMPREPLY=($(compgen -W "${subcommands[*]}" -- "$cur")) + return 0 + ;; + esac + ;; + esac + return 1 +} + +_yarn_unplug() { + ((depth++)) + flags=( + --clear + --clear-all + ) + case "$cur" in + -*) ;; + *) + COMPREPLY=( + $(compgen -W " + $(__yarn_get_package_fields dependencies) + $(__yarn_get_package_fields devDependencies) + " -- "$cur") + ) + return 0 + ;; + + esac + return 1 +} + +_yarn_upgrade() { + ((depth++)) + declare cmd dependencies devDependencies + flags=( + --audit -A + --caret -C + --exact -E + --latest -L + --pattern -P + --scope -S + --tilde -T + ) + __yarn_get_command -d 1 + case "$cmd" in + global) + dependencies=$(__yarn_get_package_fields -g dependencies) + devDependencies='' + ;; + upgrade) + dependencies=$(__yarn_get_package_fields dependencies) + devDependencies=$(__yarn_get_package_fields devDependencies) + ;; + *) + return 1 + ;; + esac + case "$cur" in + -*) ;; + *) + COMPREPLY=($(compgen -W "$dependencies $devDependencies" -- "$cur")) + return 0 + ;; + esac + return 1 +} + +_yarn_upgrade_interactive() { + ((depth++)) + flags=( + --caret -C + --exact -E + --latest + --scope -S + --tilde -T + ) + return 1 +} + +_yarn_version() { + ((depth++)) + flags=( + --major + --message + --minor + --new-version + --no-commit-hooks + --no-git-tag-version + --patch + --preid + --premajor + --preminor + --prepatch + --prerelease + ) + return 1 +} + +_yarn_workspace() { + ((depth++)) + declare -i args + declare workspaces_info + + case "$cur" in + -*) ;; + *) + __yarn_count_args + case "$args" in + [0-2]) + workspaces_info=$(yarn workspaces info -s 2> /dev/null) + if [[ -n $workspaces_info ]]; then + mapfile -t < <( + sed -n 's/^ \{2\}"\([^"]*\)": {$/\1/p' <<< "$workspaces_info" + ) + COMPREPLY=($(compgen -W "${MAPFILE[*]}" -- "$cur")) + fi + return 0 + ;; + 3) + COMPREPLY=($(compgen -W "${commands[*]}" -- "$cur")) + return 0 + ;; + *) + declare cmd + workspaces_info=$(yarn workspaces info -s 2> /dev/null) + + if [[ -n $workspaces_info ]]; then + PWD=$( + sed -n '/^ \{2\}"'"${COMP_WORDS[2]}"'": {$/,/^ \{2\}},\{0,1\}$/{ + s/^ \{4\}"location": "\([^"]*\)",$/\1/p + }' <<< "$workspaces_info" + ) + fi + + __yarn_get_command -d 3 + "_yarn_${cmd//-/_}" 2> /dev/null + return $? + ;; + esac + ;; + esac + return 1 +} + +_yarn_workspaces() { + ((depth++)) + declare cmd + subcommands=( + info + run + ) + __yarn_get_command -d 4 + case "$cmd" in + workspaces) + case "$cur" in + -*) ;; + *) + COMPREPLY=($(compgen -W "${subcommands[*]}" -- "$cur")) + return 0 + ;; + esac + ;; + info) + return 0 + ;; + run) + __yarn_run + return 0 + ;; + esac + return 1 +} + +_yarn_why() { + ((depth++)) + case "$cur" in + -*) ;; + ./*) + compopt -o filenames + ;; + *) + declare modules + modules=$(yarn list --depth 0 | sed -n 's/.* \([a-zA-Z0-9@].*\)@.*/\1/p') || return 1 + COMPREPLY=($(compgen -W "$modules" -- "$cur")) + return 0 + ;; + esac + return 1 +} + +_yarn_yarn() { + ((depth++)) + case "$cur" in + -*) ;; + *) + COMPREPLY=($(compgen -W "${commands[*]}" -- "$cur")) + return 0 + ;; + esac + return 1 +} + +_yarn() { + # shellcheck disable=SC2064 + trap " + PWD=$PWD + $(shopt -p extglob) + set +o pipefail + " RETURN + + shopt -s extglob + set -o pipefail + + declare cur cmd prev + declare -a words + declare -i cword counter=1 depth=1 + declare -ar commands=( + access + add + audit + autoclean + bin + cache + check + config + create + exec + generate-lock-entry + global + help + import + info + init + install + licenses + link + list + login + logout + node + outdated + owner + pack + policies + publish + remove + run + tag + team + unlink + unplug + upgrade + upgrade-interactive + version + versions + why + workspace + workspaces + $(__yarn_get_package_fields scripts) + ) + declare -a subcommands=() + + declare -ar bool_arg_flags=( + --emoji + --production --prod + --scripts-prepend-node-path + ) + declare -ar dir_arg_flags=( + --cache-folder + --cwd + --global-folder + --into + --link-folder + --modules-folder + --preferred-cache-folder + --prefix + ) + declare -ar file_arg_flags=( + --filename -f + --use-manifest + --use-yarnrc + ) + declare -ar int_arg_flags=( + --depth + --network-concurrency + ) + declare -ar special_arg_flags=( + --access + --groups + --level + --network-timeout + ) + declare -ar optional_arg_flags=( + --emoji + --prod + --production + --scripts-prepend-node-path + ) + declare -ar skipped_arg_flags=( + --https-proxy + --message + --mutex + --new-version + --otp + --pattern -P + --proxy + --registry + --resolved + --scope -S + --tag + ) + declare -ar arg_flags=( + "${bool_arg_flags[@]}" + "${dir_arg_flags[@]}" + "${file_arg_flags[@]}" + "${int_arg_flags[@]}" + "${special_arg_flags[@]}" + "${optional_arg_flags[@]}" + "${skipped_arg_flags[@]}" + ) + + declare -ar global_flags=( + --cache-folder + --check-files + --cwd + --disable-pnp + --emoji + --enable-pnp --pnp + --flat + --focus + --force + --frozen-lockfile + --global-folder + --har + --help -h + --https-proxy + --ignore-engines + --ignore-optional + --ignore-platform + --ignore-scripts + --json + --link-duplicates + --link-folder + --modules-folder + --mutex + --network-concurrency + --network-timeout + --no-bin-links + --no-default-rc + --no-lockfile + --non-interactive + --no-node-version-check + --no-progress + --offline + --otp + --prefer-offline + --preferred-cache-folder + --prod + --production + --proxy + --pure-lockfile + --registry + --scripts-prepend-node-path + --silent -s + --skip-integrity-check + --strict-semver + --update-checksums + --use-yarnrc + --verbose + --version -v + ) + declare -a flags=() + + COMPREPLY=() + if command -v _get_comp_words_by_ref > /dev/null; then + _get_comp_words_by_ref -n = -n @ -n : cur prev words cword + elif command -v _init_completion > /dev/null; then + _init_completion + fi + + __yarn_get_command -d 1 + + __yarn_flag_args || "_yarn_${cmd//-/_}" 2> /dev/null || __yarn_fallback + + if command -v __ltrim_colon_completions > /dev/null; then + __ltrim_colon_completions "$cur" + fi +} + +if [[ ${BASH_VERSINFO[0]} -ge 4 && ${BASH_VERSINFO[1]} -ge 4 ]]; then + complete -o nosort -F _yarn yarn +else + complete -F _yarn yarn +fi \ No newline at end of file From af11a50854b7af3f9a4b1c7f4f51dafe8b89f243 Mon Sep 17 00:00:00 2001 From: OMEGA_RAZER <869111+OMEGARAZER@users.noreply.github.com> Date: Wed, 22 Feb 2023 11:24:30 -0500 Subject: [PATCH 41/53] Allow for longer command min duration (#2198) Allows for setting "COMMAND_DURATION_MIN_SECONDS" to more than 60 seconds without adding to prompt. Previously always showed with lengths over 60 seconds regardless of setting. --- lib/command_duration.bash | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/command_duration.bash b/lib/command_duration.bash index ec4d828d0c..2b5e1b4bda 100644 --- a/lib/command_duration.bash +++ b/lib/command_duration.bash @@ -59,16 +59,16 @@ function _command_duration() { command_duration=0 fi - if ((command_duration > 0)); then + if ((command_duration >= COMMAND_DURATION_MIN_SECONDS)); then minutes=$((command_duration / 60)) seconds=$((command_duration % 60)) - fi - _dynamic_clock_icon "${command_duration}" - if ((minutes > 0)); then - printf "%s %s%dm %ds" "${COMMAND_DURATION_ICON:-}" "${COMMAND_DURATION_COLOR:-}" "$minutes" "$seconds" - elif ((seconds >= COMMAND_DURATION_MIN_SECONDS)); then - printf "%s %s%d.%01ds" "${COMMAND_DURATION_ICON:-}" "${COMMAND_DURATION_COLOR:-}" "$seconds" "$deciseconds" + _dynamic_clock_icon "${command_duration}" + if ((minutes > 0)); then + printf "%s %s%dm %ds" "${COMMAND_DURATION_ICON:-}" "${COMMAND_DURATION_COLOR:-}" "$minutes" "$seconds" + else + printf "%s %s%d.%01ds" "${COMMAND_DURATION_ICON:-}" "${COMMAND_DURATION_COLOR:-}" "$seconds" "$deciseconds" + fi fi } From e38696a0acfdb6e4fbeb6963801c417d6ca7e9a7 Mon Sep 17 00:00:00 2001 From: Gurkirat Singh Date: Fri, 24 Feb 2023 00:08:04 +0530 Subject: [PATCH 42/53] fix (completion): suppress 1091 in brew (#2130) --- completion/available/brew.completion.bash | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/completion/available/brew.completion.bash b/completion/available/brew.completion.bash index 61998f8a71..01e5d533a7 100644 --- a/completion/available/brew.completion.bash +++ b/completion/available/brew.completion.bash @@ -14,17 +14,17 @@ fi _bash_it_homebrew_check || return 0 if [[ -r "$BASH_IT_HOMEBREW_PREFIX/etc/bash_completion.d/brew" ]]; then - # shellcheck disable=1090 + # shellcheck disable=1090,1091 source "$BASH_IT_HOMEBREW_PREFIX/etc/bash_completion.d/brew" elif [[ -r "$BASH_IT_HOMEBREW_PREFIX/Library/Contributions/brew_bash_completion.sh" ]]; then - # shellcheck disable=1090 + # shellcheck disable=1090,1091 source "$BASH_IT_HOMEBREW_PREFIX/Library/Contributions/brew_bash_completion.sh" elif [[ -f "$BASH_IT_HOMEBREW_PREFIX/completions/bash/brew" ]]; then # For the git-clone based installation, see here for more info: # https://github.com/Bash-it/bash-it/issues/1458 # https://docs.brew.sh/Shell-Completion - # shellcheck disable=1090 + # shellcheck disable=1090,1091 source "$BASH_IT_HOMEBREW_PREFIX/completions/bash/brew" fi From c06350908b4899554c47b55389cd1abc38d4f4d2 Mon Sep 17 00:00:00 2001 From: Edwin Rolle Date: Wed, 10 May 2023 13:49:42 +0200 Subject: [PATCH 43/53] [terraform] add alias for terraform workspace --- aliases/available/terraform.aliases.bash | 1 + 1 file changed, 1 insertion(+) diff --git a/aliases/available/terraform.aliases.bash b/aliases/available/terraform.aliases.bash index fedd319899..b236b5fd9f 100644 --- a/aliases/available/terraform.aliases.bash +++ b/aliases/available/terraform.aliases.bash @@ -7,3 +7,4 @@ alias tfv='terraform validate' alias tfp='terraform plan' alias tfa='terraform apply' alias tfd='terraform destroy' +alias tfw='terraform workspace' From df0e0af1fb54808cf5757b68d93e05eeb153ff00 Mon Sep 17 00:00:00 2001 From: Roberto Schiavone Date: Tue, 3 Oct 2023 01:27:14 +0200 Subject: [PATCH 44/53] fix: bumps go version to 1.21.0 and changes go get to go install --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8e772ec5e8..eb92444edd 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -44,7 +44,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v2 with: - go-version: 1.17 + go-version: 1.21.0 - name: Set up Python uses: actions/setup-python@v2 with: @@ -52,7 +52,7 @@ jobs: # - name: Update APT Package Lists # run: sudo apt-get update - name: Install shfmt - run: GO111MODULE=on go get mvdan.cc/sh/v3/cmd/shfmt + run: go install mvdan.cc/sh/v3/cmd/shfmt@latest - name: Install shellcheck env: scversion: stable # Or latest, vxx, etc From 93b58eeda97b50a58d31bd61a5a5004c0d41d2f3 Mon Sep 17 00:00:00 2001 From: Edwin Kofler Date: Mon, 2 Oct 2023 17:35:12 -0700 Subject: [PATCH 45/53] docs: Update Bats libraries links (#2225) --- docs/contributing.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/contributing.rst b/docs/contributing.rst index 79d8ed1c7b..2ba3ce7faf 100644 --- a/docs/contributing.rst +++ b/docs/contributing.rst @@ -79,9 +79,9 @@ The following libraries are used to help with the tests: * Test Framework: https://github.com/bats-core/bats-core -* Support library for Bats-Assert: https://github.com/ztombol/bats-support -* General ``assert`` functions: https://github.com/ztombol/bats-assert -* File ``assert`` functions: https://github.com/ztombol/bats-file +* Support library for Bats-Assert: https://github.com/bats-core/bats-support +* General ``assert`` functions: https://github.com/bats-core/bats-assert +* File ``assert`` functions: https://github.com/bats-core/bats-file When verifying test results, please try to use the ``assert`` functions found in these libraries. From 4339ee95b9aba2c25f3cb0447d10dbdbd60887e7 Mon Sep 17 00:00:00 2001 From: Edwin Kofler Date: Tue, 3 Oct 2023 10:12:58 -0700 Subject: [PATCH 46/53] ci: Update GitHub actions v2 => v4 (#2224) --- .github/workflows/ci.yml | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index eb92444edd..75fb9d848e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -12,7 +12,7 @@ jobs: runs-on: ${{ matrix.os }} steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Install greadlink if: startsWith(runner.os, 'macOS') run: brew install coreutils @@ -26,9 +26,9 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Set up Python - uses: actions/setup-python@v2 + uses: actions/setup-python@v4 with: python-version: 3.8 - name: Install docs dependencies @@ -40,17 +40,15 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Set up Go - uses: actions/setup-go@v2 + uses: actions/setup-go@v4 with: go-version: 1.21.0 - name: Set up Python - uses: actions/setup-python@v2 + uses: actions/setup-python@v4 with: python-version: 3.8 - # - name: Update APT Package Lists - # run: sudo apt-get update - name: Install shfmt run: go install mvdan.cc/sh/v3/cmd/shfmt@latest - name: Install shellcheck From 5690939f058bc9328d6cbc18968d50751baca48f Mon Sep 17 00:00:00 2001 From: Peter Bittner Date: Sat, 30 Sep 2023 18:41:13 +0200 Subject: [PATCH 47/53] Add git alias `gshn` (`git show --name-only`) Adds a short Git alias for `git show --name-only`, which list the files affected by the changes only (instead of the full diff). --- aliases/available/git.aliases.bash | 2 ++ 1 file changed, 2 insertions(+) diff --git a/aliases/available/git.aliases.bash b/aliases/available/git.aliases.bash index 5572c9322c..1c34f1d8bb 100644 --- a/aliases/available/git.aliases.bash +++ b/aliases/available/git.aliases.bash @@ -152,6 +152,8 @@ alias gsl='git shortlog -sn' # show alias gsh='git show' +alias gshn='git show --name-only' +alias gshns='git show --name-status' # svn alias gsd='git svn dcommit' From db3eb76645218c5e078ebc5b4ba5d8d31be02a01 Mon Sep 17 00:00:00 2001 From: Peter Bittner Date: Sun, 1 Oct 2023 15:09:59 +0200 Subject: [PATCH 48/53] Add more aliases for `git merge` and `git rebase` --- 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 5572c9322c..3227cd2d5a 100644 --- a/aliases/available/git.aliases.bash +++ b/aliases/available/git.aliases.bash @@ -97,6 +97,9 @@ fi # merge alias gm='git merge' +alias gma='git merge --abort' +alias gmc='git merge --continue' +alias gms='git merge --squash' # mv alias gmv='git mv' @@ -132,7 +135,9 @@ alias grm='git rm' # rebase alias grb='git rebase' +alias grba='git rebase --abort' alias grbc='git rebase --continue' +alias grbi='git rebase --interactive' alias grm='git rebase $(get_default_branch)' alias grmi='git rebase $(get_default_branch) -i' alias grma='GIT_SEQUENCE_EDITOR=: git rebase $(get_default_branch) -i --autosquash' From d985e4c96b1eb4e7374b3ab53eea3513fc9f50ce Mon Sep 17 00:00:00 2001 From: Kal McFate Date: Sat, 18 Nov 2023 14:42:33 -0700 Subject: [PATCH 49/53] Add support to powerline themes to override foreground color (#2231) --- themes/powerline-multiline/powerline-multiline.base.bash | 2 +- themes/powerline-multiline/powerline-multiline.theme.bash | 2 ++ themes/powerline-naked/powerline-naked.theme.bash | 2 ++ themes/powerline-plain/powerline-plain.theme.bash | 2 ++ themes/powerline/powerline.base.bash | 2 +- themes/powerline/powerline.theme.bash | 2 ++ 6 files changed, 10 insertions(+), 2 deletions(-) diff --git a/themes/powerline-multiline/powerline-multiline.base.bash b/themes/powerline-multiline/powerline-multiline.base.bash index f752bd7516..0269c58c39 100644 --- a/themes/powerline-multiline/powerline-multiline.base.bash +++ b/themes/powerline-multiline/powerline-multiline.base.bash @@ -35,7 +35,7 @@ function __powerline_right_segment { (( padding += 1 )) fi - RIGHT_PROMPT+="$(set_color - ${params[1]})${pad_before_segment}${params[0]}${normal}" + RIGHT_PROMPT+="$(set_color "${POWERLINE_PROMPT_FOREGROUND_COLOR}" ${params[1]})${pad_before_segment}${params[0]}${normal}" (( padding += ${#pad_before_segment} )) (( padding += ${#params[0]} )) diff --git a/themes/powerline-multiline/powerline-multiline.theme.bash b/themes/powerline-multiline/powerline-multiline.theme.bash index 48a1243e03..d6d57e9862 100644 --- a/themes/powerline-multiline/powerline-multiline.theme.bash +++ b/themes/powerline-multiline/powerline-multiline.theme.bash @@ -18,6 +18,8 @@ POWERLINE_COMPACT_BEFOR_FIRST_SEGMENT=${POWERLINE_COMPACT_BEFORE_FIRST_SEGMENT:= POWERLINE_COMPACT_AFTER_LAST_SEGMENT=${POWERLINE_COMPACT_AFTER_LAST_SEGMENT:=${POWERLINE_COMPACT}} POWERLINE_COMPACT_PROMPT=${POWERLINE_COMPACT_PROMPT:=${POWERLINE_COMPACT}} +POWERLINE_PROMPT_FOREGROUND_COLOR=${POWERLINE_PROMPT_FOREGROUND_COLOR:=-} + USER_INFO_SSH_CHAR=${POWERLINE_USER_INFO_SSH_CHAR:=" "} USER_INFO_THEME_PROMPT_COLOR=${POWERLINE_USER_INFO_COLOR:=32} USER_INFO_THEME_PROMPT_COLOR_SUDO=${POWERLINE_USER_INFO_COLOR_SUDO:=202} diff --git a/themes/powerline-naked/powerline-naked.theme.bash b/themes/powerline-naked/powerline-naked.theme.bash index 2fb4137ef0..cc00b3b956 100644 --- a/themes/powerline-naked/powerline-naked.theme.bash +++ b/themes/powerline-naked/powerline-naked.theme.bash @@ -13,6 +13,8 @@ POWERLINE_COMPACT_BEFOR_FIRST_SEGMENT=${POWERLINE_COMPACT_BEFORE_FIRST_SEGMENT:= POWERLINE_COMPACT_AFTER_LAST_SEGMENT=${POWERLINE_COMPACT_AFTER_LAST_SEGMENT:=${POWERLINE_COMPACT}} POWERLINE_COMPACT_PROMPT=${POWERLINE_COMPACT_PROMPT:=${POWERLINE_COMPACT}} +POWERLINE_PROMPT_FOREGROUND_COLOR=${POWERLINE_PROMPT_FOREGROUND_COLOR:=-} + USER_INFO_SSH_CHAR=${POWERLINE_USER_INFO_SSH_CHAR:=" "} USER_INFO_THEME_PROMPT_COLOR=${POWERLINE_USER_INFO_COLOR:=240} USER_INFO_THEME_PROMPT_COLOR_SUDO=${POWERLINE_USER_INFO_COLOR_SUDO:=202} diff --git a/themes/powerline-plain/powerline-plain.theme.bash b/themes/powerline-plain/powerline-plain.theme.bash index 6ff68e8fae..4b7aa857f7 100644 --- a/themes/powerline-plain/powerline-plain.theme.bash +++ b/themes/powerline-plain/powerline-plain.theme.bash @@ -14,6 +14,8 @@ POWERLINE_COMPACT_AFTER_LAST_SEGMENT=${POWERLINE_COMPACT_AFTER_LAST_SEGMENT:=${P POWERLINE_COMPACT_PROMPT=${POWERLINE_COMPACT_PROMPT:=${POWERLINE_COMPACT}} POWERLINE_PROMPT_AFTER=${POWERLINE_PROMPT_AFTER:-""} +POWERLINE_PROMPT_FOREGROUND_COLOR=${POWERLINE_PROMPT_FOREGROUND_COLOR:=-} + PYTHON_VENV_CHAR=${POWERLINE_PYTHON_VENV_CHAR:="ⓔ "} CONDA_PYTHON_VENV_CHAR=${POWERLINE_CONDA_PYTHON_VENV_CHAR:="ⓔ "} PYTHON_VENV_THEME_PROMPT_COLOR=${POWERLINE_PYTHON_VENV_COLOR:=35} diff --git a/themes/powerline/powerline.base.bash b/themes/powerline/powerline.base.bash index 84469e877f..b7c9a80c08 100644 --- a/themes/powerline/powerline.base.bash +++ b/themes/powerline/powerline.base.bash @@ -247,7 +247,7 @@ function __powerline_left_segment() { fi fi - LEFT_PROMPT+="$(set_color - "${params[1]}")${pad_before_segment}${params[0]}${normal}" + LEFT_PROMPT+="$(set_color "${POWERLINE_PROMPT_FOREGROUND_COLOR}" "${params[1]}")${pad_before_segment}${params[0]}${normal}" LAST_SEGMENT_COLOR=${params[1]} ((SEGMENTS_AT_LEFT += 1)) } diff --git a/themes/powerline/powerline.theme.bash b/themes/powerline/powerline.theme.bash index 49b397aa1d..cb5c4814f9 100644 --- a/themes/powerline/powerline.theme.bash +++ b/themes/powerline/powerline.theme.bash @@ -16,6 +16,8 @@ POWERLINE_COMPACT_BEFOR_FIRST_SEGMENT=${POWERLINE_COMPACT_BEFORE_FIRST_SEGMENT:= POWERLINE_COMPACT_AFTER_LAST_SEGMENT=${POWERLINE_COMPACT_AFTER_LAST_SEGMENT:=${POWERLINE_COMPACT}} POWERLINE_COMPACT_PROMPT=${POWERLINE_COMPACT_PROMPT:=${POWERLINE_COMPACT}} +POWERLINE_PROMPT_FOREGROUND_COLOR=${POWERLINE_PROMPT_FOREGROUND_COLOR:=-} + USER_INFO_SSH_CHAR=${POWERLINE_USER_INFO_SSH_CHAR:=" "} USER_INFO_THEME_PROMPT_COLOR=${POWERLINE_USER_INFO_COLOR:=32} USER_INFO_THEME_PROMPT_COLOR_SUDO=${POWERLINE_USER_INFO_COLOR_SUDO:=202} From 81bbf4408e633640f7aa176bff62f4d65732bbd0 Mon Sep 17 00:00:00 2001 From: Blackteahamburger Date: Tue, 27 Aug 2024 15:32:22 +0800 Subject: [PATCH 50/53] bash_profile.template.bash: fix theme location --- template/bash_profile.template.bash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/template/bash_profile.template.bash b/template/bash_profile.template.bash index 3def286612..4b90990489 100755 --- a/template/bash_profile.template.bash +++ b/template/bash_profile.template.bash @@ -11,7 +11,7 @@ export BASH_IT="{{BASH_IT}}" # Lock and Load a custom theme file. # Leave empty to disable theming. -# location /.bash_it/themes/ +# location "$BASH_IT"/themes/ export BASH_IT_THEME='bobby' # Some themes can show whether `sudo` has a current token or not. From 345d0081b98f805f4368746f346b5d6eb0a218d6 Mon Sep 17 00:00:00 2001 From: Ira Abramov Date: Mon, 17 Apr 2023 20:05:48 +0300 Subject: [PATCH 51/53] Fix commandline options for the current versions of gifski and gifsicle --- plugins/available/gif.plugin.bash | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/plugins/available/gif.plugin.bash b/plugins/available/gif.plugin.bash index a04ff5c7d1..1f47f1f013 100644 --- a/plugins/available/gif.plugin.bash +++ b/plugins/available/gif.plugin.bash @@ -72,9 +72,9 @@ function v2gif() { eval set -- "$args" local use_gifski="" local opt_del_after="" - local maxsize="" - local lossiness="" - local maxwidthski="" + local maxsize=() + local lossiness=() + local maxwidthski=() local giftagopt="" local giftag="" local defaultfps=10 @@ -106,8 +106,8 @@ function v2gif() { shift ;; -w | --width) - maxsize="-vf scale=$2:-1" - maxwidthski="-W $2" + maxsize=(-vf "scale=$2:-1") + maxwidthski=(-W "$2") giftag="${giftag}-w$2" shift 2 ;; @@ -118,7 +118,7 @@ function v2gif() { ;; -l | --lossy) # Use giflossy parameter - lossiness="--lossy=$2" + lossiness=("--lossy=$2") giftag="${giftag}-l$2" shift 2 ;; @@ -164,7 +164,7 @@ function v2gif() { local del_after=$opt_del_after if [[ -n "$make_webm" ]]; then - $ffmpeg -loglevel panic -i "$file" \ + $ffmpeg -loglevel warning -i "$file" \ -c:v libvpx -crf 4 -threads 0 -an -b:v 2M -auto-alt-ref 0 \ -quality best -loop 0 "${file%.*}.webm" || return 2 fi @@ -184,12 +184,12 @@ function v2gif() { if [[ "$use_gifski" = "true" ]]; then # I trust @pornel to do his own resizing optimization choices - $ffmpeg -loglevel panic -i "$file" -r "$fps" -vcodec png v2gif-tmp-%05d.png \ - && $gifski v2gif-tmp-*.png "$maxwidthski" --fps "$(printf "%.0f" "$fps")" -o "$output_file" || return 2 + $ffmpeg -loglevel warning -i "$file" -r "$fps" -vcodec png v2gif-tmp-%05d.png \ + && $gifski "${maxwidthski[@]}" --fps "$(printf "%.0f" "$fps")" -o "$output_file" v2gif-tmp-*.png || return 2 else - $ffmpeg -loglevel panic -i "$file" "$maxsize" -r "$fps" -vcodec png v2gif-tmp-%05d.png \ + $ffmpeg -loglevel warning -i "$file" "${maxsize[@]}" -r "$fps" -vcodec png v2gif-tmp-%05d.png \ && $convert +dither -layers Optimize v2gif-tmp-*.png GIF:- \ - | $gifsicle "$lossiness" --no-warnings --colors 256 --delay="$(echo "100/$fps" | bc)" --loop --optimize=3 --multifile - > "$output_file" || return 2 + | $gifsicle "${lossiness[@]}" --no-warnings --colors 256 --delay="$(echo "100/$fps" | bc)" --loop --optimize=3 --multifile - > "$output_file" || return 2 fi rm v2gif-tmp-*.png @@ -299,7 +299,7 @@ function any2webm() { echo "$(tput setaf 2)Creating '$output_file' ...$(tput sgr 0)" - $ffmpeg -loglevel panic -i "$file" \ + $ffmpeg -loglevel warning -i "$file" \ -c:v libvpx -crf 4 -threads 0 -an -b:v "$bandwidth" -auto-alt-ref 0 \ -quality best "$fps" "$size" -loop 0 -pix_fmt yuva420p "$output_file" || return 2 From d60d806ab4fe5c37a86e4c6849498fdf964e49fa Mon Sep 17 00:00:00 2001 From: Ira Abramov Date: Tue, 5 Nov 2024 11:13:13 +0200 Subject: [PATCH 52/53] new version of oh-my-posh breaks the init commandline, fixing to the new syntax of v24 --- themes/oh-my-posh/oh-my-posh.theme.bash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/themes/oh-my-posh/oh-my-posh.theme.bash b/themes/oh-my-posh/oh-my-posh.theme.bash index ba3c77f1ef..430c8acb4c 100644 --- a/themes/oh-my-posh/oh-my-posh.theme.bash +++ b/themes/oh-my-posh/oh-my-posh.theme.bash @@ -2,7 +2,7 @@ if _command_exists oh-my-posh; then export POSH_THEME=${POSH_THEME:-https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/v$(oh-my-posh --version)/themes/jandedobbeleer.omp.json} - eval "$(oh-my-posh --init --shell bash --config "${POSH_THEME}")" + eval "$(oh-my-posh init bash --config "${POSH_THEME}")" else _log_warning "The oh-my-posh binary was not found on your PATH. Falling back to your existing PS1, please see the docs for more info." fi From fa6b4921cee361b31567d9ef9bccde3673325a4f Mon Sep 17 00:00:00 2001 From: Ira Abramov Date: Tue, 5 Nov 2024 11:27:18 +0200 Subject: [PATCH 53/53] Pass the shellcheck lint test --- 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 e1c3617531..b93c768f56 100644 --- a/themes/brainy/brainy.theme.bash +++ b/themes/brainy/brainy.theme.bash @@ -168,7 +168,7 @@ ___brainy_prompt_battery() { box="[|]" ac_adapter_connected && charging="+" ac_adapter_disconnected && charging="-" - info+=$charging + info+="$charging" [ "$info" == "100+" ] && info="AC" printf "%s|%s|%s|%s" "${color}" "${info}" "${bold_white}" "${box}" }