Compare commits

...

59 Commits

Author SHA1 Message Date
Gurkirat Singh e38696a0ac
fix (completion): suppress 1091 in brew (#2130) 2023-02-23 10:38:04 -08:00
OMEGA_RAZER af11a50854
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.
2023-02-22 08:24:30 -08:00
Gurkirat Singh 05ef68acbc
Implement yarn completion (#2190)
* feat (completion): add yarn completion
2023-02-22 08:20:45 -08:00
Gurkirat Singh 78f88406cf
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
2023-02-22 08:19:12 -08:00
BF feb468b517
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 <davidpfarrell+github@gmail.com>
2023-01-25 15:56:14 -08:00
Noah Gorny 66ae9b0de8
Remove libra chat reference
We will try to use Github Discussions now.
2022-12-06 00:22:27 +02:00
Noah Gorny 2e52d2a77c
Merge pull request #2109 from tbhaxor/feature/terraform-alias
Add terraform init alias
2022-12-06 00:15:40 +02:00
Noah Gorny 4c2e644db1
Merge pull request #2159 from bittner/patch-3
Add more aliases for `git branch`, use long form
2022-12-05 23:15:13 +02:00
Peter Bittner f0941e9ba2 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.
2022-12-05 11:01:57 +01:00
Noah Gorny ad2b55804e
Merge pull request #2172 from davidpfarrell/bug/duration_locale
bug: Use en_US when fetching EPOCHREALTIME
2022-12-04 00:42:05 +02:00
Noah Gorny ec3c06fa33
Merge pull request #2166 from cornfeedhobo/rename-kubectl-alias-func
remove function wrapper around kubectl aliases
2022-12-04 00:39:49 +02:00
Noah Gorny 686a5e45cb
Merge pull request #2146 from dylanjtuttle/update_bash_branch
Added update-bash section in README
2022-12-04 00:39:17 +02:00
Noah Gorny cfe46e3d36
Merge pull request #2170 from Royalsspirit/fix/parrot-theme-escape-sequence
fix(theme): use correct escape sequence to avoid weird text overwriting
2022-12-04 00:37:47 +02:00
cornfeedhobo 5f59cb5438
remove function wrapper around kubectl alias registration 2022-10-31 08:08:10 -05:00
David Farrell 7c7e4f90ec
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
2022-10-30 15:18:09 -07:00
David Farrell 1c9cfd056b
bug:Install shellcheck wget (#2173)
Installs shellcheck via wget of github release for 'stable' linux version
2022-10-30 15:15:28 -07:00
gmajkic 7c77223b15 fix(theme): use correct escape sequence to avoid weird text overwriting 2022-10-14 09:43:51 +02:00
David Farrell 00062bfcb6
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
2022-10-13 10:34:57 -07:00
Noah Gorny bf2034d13d
Merge pull request #2158 from bittner/patch-2
Verbose version of `git add` (gav)
2022-09-28 12:04:38 +03:00
Dylan Tuttle c222e5001c Merge branch 'update_bash_branch' of github.com:dylanjtuttle/bash-it into update_bash_branch 2022-09-22 16:52:05 -06:00
Dylan Tuttle 606272ac23 Fixed broken code blocks in troubleshooting.rst 2022-09-22 16:49:26 -06:00
Dylan Tuttle d237ab9aa4
Merge branch 'master' into update_bash_branch 2022-09-22 16:30:51 -06:00
Dylan Tuttle 0ab80429ce Removed Bash Dependency section from README and added it to troubleshooting.rst 2022-09-22 16:27:52 -06:00
Noah Gorny 8bedbe47a7
Merge pull request #2161 from brianphillips/patch-2
Update variable name to match projects.plugin.bash
2022-09-13 20:08:18 +03:00
Brian Phillips e5e7785c96
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`
2022-08-30 13:21:03 -05:00
Peter Bittner 3294df5d3e
Verbose version of `git add` (gav) 2022-08-26 07:04:07 +02:00
Noah Gorny d770030513
Merge pull request #2154 from jakebman/gitlab-runner-deprecation
Update Gitlab Runner images
2022-08-17 07:17:42 +03:00
Jake Boeckerman 407f2f5b5f 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/
2022-08-12 11:39:22 -06:00
John D Pell 5a62acd253
Merge pull request #2152 from thomasmerz/issue_2151 2022-08-11 09:08:37 -07:00
Thomas Merz 129340d24d
Issue 2151 🛂 do not give users a root shell by executing arbitrary shell commands by 'vim'
also by removing 'sudo' aliases because bash-it should not be
              the business of mucking about with sudo at all
2022-08-11 17:22:57 +02:00
Noah Gorny 2ef5d483e3
Merge pull request #2135 from tbhaxor/improve/flutter-completion
Clean flutter completions
2022-05-19 00:11:54 +03:00
Noah Gorny 03b3a977aa
Merge pull request #2147 from davidpfarrell/dirs-bks
plugin(dirs): Create backup file parent directory
2022-05-19 00:01:58 +03:00
David Farrell c0dc83edfc
plugin(dirs): Create backup file parent directory 2022-05-09 13:08:52 -07:00
Dylan Tuttle f2bc6c4e6d Added update-bash section in README 2022-05-08 00:49:27 -06:00
Noah Gorny 4dddba3bc6
Merge pull request #2145 from tbhaxor/bugfix/docs
Upgrade the sphinx version
2022-05-07 23:29:43 +03:00
Gurkirat Singh c2698882e4
fix (docs): ugraded sphinx version 2022-05-07 00:32:15 +05:30
Gurkirat Singh 135d480c7d
improve (docs): exclude venv pattern in build 2022-05-07 00:31:21 +05:30
Gurkirat Singh e11576f260
fix (completion): shfmt format flutter.completion.bash 2022-05-06 23:32:47 +05:30
Gurkirat Singh d7fb6b3235
improve (lint): add completion/available/flutter.completion.bash entry 2022-05-06 23:32:45 +05:30
Noah Gorny 35334cdcb0
Merge pull request #2121 from BarbUk/update/theme_barbuk
Update of barbuk theme (add modular blocks)
2022-04-13 00:22:04 +03:00
Noah Gorny b95094153f
Merge pull request #2139 from tbhaxor/patch-3
Improve bashit upgrade function git log and add missing popd
2022-04-06 23:06:52 +03:00
Gurkirat Singh 6ccd9f5adf
fix (helpers): bashit_update function return to source path and --no-merges in log 2022-03-21 08:52:46 +05:30
Noah Gorny 1ffbc85a62
Merge pull request #2138 from eviweb/fix-projects-plugin-regression
fix projects plugin regression
2022-03-16 21:54:51 +02:00
Noah Gorny 60c4c0b598
Merge pull request #2132 from NoahGorny/add-default-editor-nano
general: Add default nano editor for the edit alias
2022-03-16 21:47:02 +02:00
Eric Villard 088212fd32 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 <dev@eviweb.fr>
2022-03-16 08:43:52 +01:00
Noah Gorny d1b831a92d
Merge pull request #2119 from BarbUk/fix/command_duration_precision
Fix/command duration precision
2022-03-14 11:59:27 +02:00
Noah Gorny 69407018a7
Merge pull request #2129 from tbhaxor/fix/awscli-completion
Clean awscli completion
2022-03-14 11:55:44 +02:00
Noah Gorny a481ff41ab general: Add default nano editor for the edit alias 2022-03-14 11:20:40 +02:00
Noah Gorny 7cc2ced3b9
Merge pull request #2122 from BarbUk/fix/grep_path
Fix grep path when a grep alias exists
2022-03-14 10:58:48 +02:00
Gurkirat Singh 66fbed7f6f
fix (completion): format awscli 2022-03-13 05:21:13 +05:30
Gurkirat Singh 6b0ca17df0
improve (lint): add awscli.completion.bash in clean_files.txt 2022-03-13 05:20:57 +05:30
BarbUk 23efb39fb0
Fix grep path when a grep alias exists 2022-03-11 09:08:58 +01:00
BarbUk 9a71556b99
shfmt needs more spaces 2022-03-09 22:04:18 +01:00
BarbUk e1ddf6e311
Fix dynamic clock icon (#2120)
* Fix dynamic clock icon

* Use printf variable scope

* shfmt do not like spaces
2022-03-09 22:59:48 +02:00
BarbUk 0068315c35
Update documentation 2022-03-09 21:38:03 +01:00
BarbUk b839294827
Complete rework 2022-03-09 21:29:51 +01:00
BarbUk 634c1f8c18
Fix spacing in string output 2022-03-09 11:01:53 +01:00
BarbUk 4686ce1f12
Fix precision to use deciseconds instead of nanoseconds 2022-03-09 09:38:16 +01:00
Gurkirat Singh 6ba527ff98 feature (alias): add terraform init alias 2022-03-06 11:41:27 +05:30
38 changed files with 1536 additions and 134 deletions

View File

@ -7,7 +7,7 @@ jobs:
bats-test: bats-test:
strategy: strategy:
matrix: 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 }} runs-on: ${{ matrix.os }}
@ -49,10 +49,17 @@ jobs:
uses: actions/setup-python@v2 uses: actions/setup-python@v2
with: with:
python-version: 3.8 python-version: 3.8
# - name: Update APT Package Lists
# run: sudo apt-get update
- name: Install shfmt - name: Install shfmt
run: GO111MODULE=on go get mvdan.cc/sh/v3/cmd/shfmt run: GO111MODULE=on go get mvdan.cc/sh/v3/cmd/shfmt
- name: Install shellcheck - 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 - name: Install pre-commit
run: python3 -m pip install -r test/lint-requirements.txt run: python3 -m pip install -r test/lint-requirements.txt
- name: Run lint - name: Run lint

View File

@ -34,7 +34,7 @@ fi
alias c='clear' alias c='clear'
alias cls='clear' alias cls='clear'
alias edit='${EDITOR:-${ALTERNATE_EDITOR?}}' alias edit='${EDITOR:-${ALTERNATE_EDITOR:-nano}}'
alias pager='${PAGER:=less}' alias pager='${PAGER:=less}'
alias q='exit' alias q='exit'
@ -71,10 +71,6 @@ alias rd='rmdir'
# Shorten extract # Shorten extract
alias xt='extract' alias xt='extract'
# sudo editors
alias svim='sudo ${VISUAL:-vim}'
alias snano='sudo nano'
# Display whatever file is regular file or folder # Display whatever file is regular file or folder
function catt() { function catt() {
for i in "$@"; do for i in "$@"; do

View File

@ -8,13 +8,18 @@ alias get='git'
alias ga='git add' alias ga='git add'
alias gall='git add -A' alias gall='git add -A'
alias gap='git add -p' alias gap='git add -p'
alias gav='git add -v'
# branch # branch
alias gb='git branch' alias gb='git branch'
alias gbD='git branch -D' alias gba='git branch --all'
alias gba='git branch -a'
alias gbd='git branch -d' 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 gbt='git branch --track'
alias gdel='git branch -D' alias gdel='git branch -D'

View File

@ -1,8 +1,7 @@
# shellcheck shell=bash # shellcheck shell=bash
about-alias 'kubectl aliases' about-alias 'kubectl aliases'
function _set_pkg_aliases() { if _command_exists kubectl; then
if _command_exists kubectl; then
alias kc='kubectl' alias kc='kubectl'
alias kcgp='kubectl get pods' alias kcgp='kubectl get pods'
alias kcgd='kubectl get deployments' alias kcgd='kubectl get deployments'
@ -14,7 +13,4 @@ function _set_pkg_aliases() {
alias kcgdan='kubectl get deployments --all-namespaces' alias kcgdan='kubectl get deployments --all-namespaces'
# launches a disposable netshoot pod in the k8s cluster # launches a disposable netshoot pod in the k8s cluster
alias kcnetshoot='kubectl run netshoot-$(date +%s) --rm -i --tty --image nicolaka/netshoot -- /bin/bash' alias kcnetshoot='kubectl run netshoot-$(date +%s) --rm -i --tty --image nicolaka/netshoot -- /bin/bash'
fi fi
}
_set_pkg_aliases

View File

@ -2,6 +2,7 @@
about-alias 'Aliases for Terraform and Terragrunt' about-alias 'Aliases for Terraform and Terragrunt'
alias tf='terraform' alias tf='terraform'
alias tfi='tf init'
alias tfv='terraform validate' alias tfv='terraform validate'
alias tfp='terraform plan' alias tfp='terraform plan'
alias tfa='terraform apply' alias tfa='terraform apply'

View File

@ -33,6 +33,7 @@ lint_clean_files.sh
# #
completion/available/apm.completion.bash completion/available/apm.completion.bash
completion/available/awless.completion.bash completion/available/awless.completion.bash
completion/available/awscli.completion.bash
completion/available/bash-it.completion.bash completion/available/bash-it.completion.bash
completion/available/brew.completion.bash completion/available/brew.completion.bash
completion/available/cargo.completion.bash completion/available/cargo.completion.bash
@ -45,6 +46,7 @@ completion/available/dmidecode.completion.bash
completion/available/docker-machine.completion.bash completion/available/docker-machine.completion.bash
completion/available/docker.completion.bash completion/available/docker.completion.bash
completion/available/dotnet.completion.bash completion/available/dotnet.completion.bash
completion/available/flutter.completion.bash
completion/available/gcloud.completion.bash completion/available/gcloud.completion.bash
completion/available/gem.completion.bash completion/available/gem.completion.bash
completion/available/git.completion.bash completion/available/git.completion.bash
@ -74,6 +76,7 @@ completion/available/system.completion.bash
completion/available/vault.completion.bash completion/available/vault.completion.bash
completion/available/vuejs.completion.bash completion/available/vuejs.completion.bash
completion/available/wpscan.completion.bash completion/available/wpscan.completion.bash
completion/available/yarn.completion.bash
# libraries # libraries
lib/appearance.bash lib/appearance.bash

View File

@ -50,7 +50,7 @@ function _bash-it-component-completion-callback-on-init-aliases() {
fi fi
# skip aliases to pipes, boolean control structures and other command lists # skip aliases to pipes, boolean control structures and other command lists
chars='\|\&\;\)\(\n\<\>' chars=$'|&;()<>\n'
if [[ "${alias_defn}" =~ [$chars] ]]; then if [[ "${alias_defn}" =~ [$chars] ]]; then
continue continue
fi fi

View File

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

View File

@ -14,17 +14,17 @@ fi
_bash_it_homebrew_check || return 0 _bash_it_homebrew_check || return 0
if [[ -r "$BASH_IT_HOMEBREW_PREFIX/etc/bash_completion.d/brew" ]]; then if [[ -r "$BASH_IT_HOMEBREW_PREFIX/etc/bash_completion.d/brew" ]]; then
# shellcheck disable=1090 # shellcheck disable=1090,1091
source "$BASH_IT_HOMEBREW_PREFIX/etc/bash_completion.d/brew" source "$BASH_IT_HOMEBREW_PREFIX/etc/bash_completion.d/brew"
elif [[ -r "$BASH_IT_HOMEBREW_PREFIX/Library/Contributions/brew_bash_completion.sh" ]]; then elif [[ -r "$BASH_IT_HOMEBREW_PREFIX/Library/Contributions/brew_bash_completion.sh" ]]; then
# shellcheck disable=1090 # shellcheck disable=1090,1091
source "$BASH_IT_HOMEBREW_PREFIX/Library/Contributions/brew_bash_completion.sh" source "$BASH_IT_HOMEBREW_PREFIX/Library/Contributions/brew_bash_completion.sh"
elif [[ -f "$BASH_IT_HOMEBREW_PREFIX/completions/bash/brew" ]]; then elif [[ -f "$BASH_IT_HOMEBREW_PREFIX/completions/bash/brew" ]]; then
# For the git-clone based installation, see here for more info: # For the git-clone based installation, see here for more info:
# https://github.com/Bash-it/bash-it/issues/1458 # https://github.com/Bash-it/bash-it/issues/1458
# https://docs.brew.sh/Shell-Completion # https://docs.brew.sh/Shell-Completion
# shellcheck disable=1090 # shellcheck disable=1090,1091
source "$BASH_IT_HOMEBREW_PREFIX/completions/bash/brew" source "$BASH_IT_HOMEBREW_PREFIX/completions/bash/brew"
fi fi

View File

@ -1,4 +1,4 @@
#!/usr/bin/env bash # shellcheck shell=bash
# #
# Bash completion support for Fabric (http://fabfile.org/) # Bash completion support for Fabric (http://fabfile.org/)
# #
@ -91,7 +91,7 @@ function __fab_completion() {
-*) -*)
if [[ -z "${__FAB_COMPLETION_LONG_OPT}" ]]; then if [[ -z "${__FAB_COMPLETION_LONG_OPT}" ]]; then
export __FAB_COMPLETION_LONG_OPT=$( 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 fi
opts="${__FAB_COMPLETION_LONG_OPT}" opts="${__FAB_COMPLETION_LONG_OPT}"
;; ;;
@ -101,7 +101,7 @@ function __fab_completion() {
# -*) # -*)
# if [[ -z "${__FAB_COMPLETION_SHORT_OPT}" ]]; then # if [[ -z "${__FAB_COMPLETION_SHORT_OPT}" ]]; then
# export __FAB_COMPLETION_SHORT_OPT=$( # 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 # fi
# opts="${__FAB_COMPLETION_SHORT_OPT}" # opts="${__FAB_COMPLETION_SHORT_OPT}"
# ;; # ;;

View File

@ -1,4 +1,4 @@
#!/usr/bin/bash # shellcheck shell=bash
if _command_exists flutter; then if _command_exists flutter; then
eval "$(flutter bash-completion)" eval "$(flutter bash-completion)"

View File

@ -1,3 +1,5 @@
# shellcheck shell=bash
# Copyright (c) 2017 Eric Wendelin # Copyright (c) 2017 Eric Wendelin
# Permission is hereby granted, free of charge, to any person obtaining a copy of # 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 if [[ ! $(find $cache_dir/$cache_name -mmin -$cache_ttl_mins 2>/dev/null) ]]; then
# Cache all Gradle scripts # 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 printf "%s\n" "${gradle_build_scripts[@]}" > $cache_dir/$cache_name
fi fi
} }

View File

@ -1,3 +1,5 @@
# shellcheck shell=bash
# Bash completion for Makefile # Bash completion for Makefile
# Loosely adapted from http://stackoverflow.com/a/38415982/1472048 # Loosely adapted from http://stackoverflow.com/a/38415982/1472048
@ -17,7 +19,7 @@ _makecomplete() {
for f in "${files[@]}" ; do for f in "${files[@]}" ; do
while IFS='' read -r line ; do while IFS='' read -r line ; do
targets+=("$line") 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 done
[ "${#targets[@]}" -eq 0 ] && return 0 [ "${#targets[@]}" -eq 0 ] && return 0

View File

@ -7,7 +7,7 @@ _is_function _rl_enabled ||
_pj() { _pj() {
_is_function _init_completion || return _is_function _init_completion || return
_is_function _rl_enabled || return _is_function _rl_enabled || return
[ -n "$PROJECT_PATHS" ] || return [ -n "$BASH_IT_PROJECT_PATHS" ] || return
shift shift
[ "$1" == "open" ] && shift [ "$1" == "open" ] && shift
@ -21,7 +21,7 @@ _pj() {
local -r mark_dirs=$(_rl_enabled mark-directories && echo y) local -r mark_dirs=$(_rl_enabled mark-directories && echo y)
local -r mark_symdirs=$(_rl_enabled mark-symlinked-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 # create an array of matched subdirs
k="${#COMPREPLY[@]}" k="${#COMPREPLY[@]}"
for j in $( compgen -d $i/$cur ); do for j in $( compgen -d $i/$cur ); do

View File

@ -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"

View File

@ -4,7 +4,6 @@
![Docs Status](https://readthedocs.org/projects/bash-it/badge/) ![Docs Status](https://readthedocs.org/projects/bash-it/badge/)
![License](https://img.shields.io/github/license/Bash-it/bash-it) ![License](https://img.shields.io/github/license/Bash-it/bash-it)
![shell](https://img.shields.io/badge/Shell-Bash-blue) ![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+. **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:) (And a shameless ripoff of [oh-my-zsh](https://github.com/robbyrussell/oh-my-zsh) :smiley:)

View File

@ -14,7 +14,6 @@
# import sys # import sys
# sys.path.insert(0, os.path.abspath('.')) # sys.path.insert(0, os.path.abspath('.'))
# -- Project information ----------------------------------------------------- # -- Project information -----------------------------------------------------
project = 'Bash-it' project = 'Bash-it'
@ -24,7 +23,6 @@ author = 'Bash-it Team'
# The full version, including alpha/beta/rc tags # The full version, including alpha/beta/rc tags
release = '' release = ''
# -- General configuration --------------------------------------------------- # -- General configuration ---------------------------------------------------
# Add any Sphinx extension module names here, as strings. They can be # Add any Sphinx extension module names here, as strings. They can be
@ -41,8 +39,7 @@ templates_path = ['_templates']
# List of patterns, relative to source directory, that match files and # List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files. # directories to ignore when looking for source files.
# This pattern also affects html_static_path and html_extra_path. # 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 ------------------------------------------------- # -- Options for HTML output -------------------------------------------------

View File

@ -1,4 +1,4 @@
sphinx==3.2.1 sphinx==4.5.0
sphinx-rtd-theme==0.5.0 sphinx-rtd-theme==0.5.0
sphinxemoji==0.1.8 sphinxemoji==0.1.8
docutils==0.17.1 docutils==0.17.1

View File

@ -8,13 +8,35 @@ A minimal theme with a clean git prompt
Provided Information Provided Information
-------------------- --------------------
* Current git remote tool logo (support: github, gitlab, bitbucket) * Current git remote tool logo (support: github, gitlab, bitbucket)
* Current path (red when user is root) * Current path (red when user is root)
* Current git info * Current git info
* Last command exit code (only shown when the exit code is greater than 0) * Last command exit code (only shown when the exit code is greater than 0)
* user@hostname for ssh connection * 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 Fonts and glyphs
---------------- ----------------
@ -39,6 +61,12 @@ Default theme glyphs
BARBUK_EXIT_CODE_ICON=' ' BARBUK_EXIT_CODE_ICON=' '
BARBUK_PYTHON_VENV_CHAR=' ' BARBUK_PYTHON_VENV_CHAR=' '
BARBUK_COMMAND_DURATION_ICON='  ' 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 Customize glyphs
^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^

View File

@ -8,9 +8,38 @@ Table of Contents
* `I'm stuck in the LightDM login screen after setting up bash-it. <im-stuck-in-the-lightdm-login-screen-after-setting-up-bash-it>`_ * `I'm stuck in the LightDM login screen after setting up bash-it. <im-stuck-in-the-lightdm-login-screen-after-setting-up-bash-it>`_
* `I'm getting strange line break and wrapping behaviour on macOS. <im-getting-strange-line-break-and-wrapping-behaviour-on-macos>`_
I'm stuck in the LightDM login screen after setting up bash-it I'm stuck in the LightDM login screen after setting up bash-it
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
**Possible issue**\ : `#672 <https://github.com/Bash-it/bash-it/issues/672>`_ **Possible issue**\ : `#672 <https://github.com/Bash-it/bash-it/issues/672>`_
**Solution**\ : Check `this comment <https://github.com/Bash-it/bash-it/issues/672#issuecomment-257870653>`_ for detailed information about the cause and solution for this issue. **Solution**\ : Check `this comment <https://github.com/Bash-it/bash-it/issues/672#issuecomment-257870653>`_ 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 <https://github.com/Bash-it/bash-it/issues/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 <https://brew.sh/>`_ to ensure Bash is up to date:
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

View File

@ -12,7 +12,6 @@ function _bash-it_show_usage() {
echo "--no-modify-config (-n): Do not modify existing config file" 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 "--append-to-config (-a): Keep existing config file and append bash-it templates at the end"
echo "--overwrite-backup (-f): Overwrite existing backup" echo "--overwrite-backup (-f): Overwrite existing backup"
exit 0
} }
# enable a thing # enable a thing

View File

@ -2,29 +2,48 @@
# #
# Functions for measuring and reporting how long a command takes to run. # 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_ICON:=🕘}"
: "${COMMAND_DURATION_MIN_SECONDS:=1}" : "${COMMAND_DURATION_MIN_SECONDS:=1}"
function _command_duration_pre_exec() { 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 { 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" printf -v 'COMMAND_DURATION_ICON' '%b' "\xf0\x9f\x95\x$clock_hand"
} }
function _command_duration() { function _command_duration() {
[[ -n "${BASH_IT_COMMAND_DURATION:-}" ]] || return [[ -n "${BASH_IT_COMMAND_DURATION:-}" ]] || return
[[ -n "${COMMAND_DURATION_START_SECONDS:-}" ]] || return
local command_duration=0 command_start="${COMMAND_DURATION_START_SECONDS:-0}" local command_duration=0 command_start="${COMMAND_DURATION_START_SECONDS:-0}"
local -i minutes=0 seconds=0 deciseconds=0 local -i minutes=0 seconds=0 deciseconds=0
local -i command_start_seconds="${command_start%.*}" local -i command_start_seconds="${command_start%.*}"
local -i command_start_deciseconds=$((10#${command_start##*.})) local -i command_start_deciseconds=$((10#${command_start##*.}))
local current_time="${EPOCHREALTIME:-$SECONDS}" command_start_deciseconds="${command_start_deciseconds:0:1}"
local current_time
current_time="$(_shell_duration_en)"
local -i current_time_seconds="${current_time%.*}" local -i current_time_seconds="${current_time%.*}"
local -i current_time_deciseconds="$((10#${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 if [[ "${command_start_seconds:-0}" -gt 0 ]]; then
# seconds # seconds
@ -40,17 +59,18 @@ function _command_duration() {
command_duration=0 command_duration=0
fi fi
if ((command_duration > 0)); then if ((command_duration >= COMMAND_DURATION_MIN_SECONDS)); then
minutes=$((command_duration / 60)) minutes=$((command_duration / 60))
seconds=$((command_duration % 60)) seconds=$((command_duration % 60))
fi
_dynamic_clock_icon "${command_duration}" _dynamic_clock_icon "${command_duration}"
if ((minutes > 0)); then if ((minutes > 0)); then
printf "%s%s%dm %ds" "${COMMAND_DURATION_ICON:-}" "${COMMAND_DURATION_COLOR:-}" "$minutes" "$seconds" printf "%s %s%dm %ds" "${COMMAND_DURATION_ICON:-}" "${COMMAND_DURATION_COLOR:-}" "$minutes" "$seconds"
elif ((seconds >= COMMAND_DURATION_MIN_SECONDS)); then else
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
fi fi
} }
_bash_it_library_finalize_hook+=("safe_append_preexec '_command_duration_pre_exec'") _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'")

View File

@ -211,7 +211,7 @@ function _is_function() {
_example '$ _is_function ls && echo exists' _example '$ _is_function ls && echo exists'
_group 'lib' _group 'lib'
local msg="${2:-Function '$1' does not exist}" 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 return 0
else else
_log_debug "$msg" _log_debug "$msg"
@ -290,6 +290,7 @@ function _bash-it-update-() {
DIFF=$(git diff --name-status) DIFF=$(git diff --name-status)
if [[ -n "$DIFF" ]]; then if [[ -n "$DIFF" ]]; then
echo -e "Local changes detected in bash-it directory. Clean '$BASH_IT' directory to proceed.\n$DIFF" echo -e "Local changes detected in bash-it directory. Clean '$BASH_IT' directory to proceed.\n$DIFF"
popd > /dev/null || return
return 1 return 1
fi fi
@ -334,7 +335,7 @@ function _bash-it-update-() {
log_color="%Cred" log_color="%Cred"
fi fi
git log --format="${log_color}%h: %s (%an)" "${revision}" git log --no-merges --format="${log_color}%h: %s (%an)" "${revision}"
echo "" echo ""
if [[ -n "${silent}" ]]; then if [[ -n "${silent}" ]]; then

View File

@ -60,15 +60,21 @@ function _bash-it-array-dedup() {
printf '%s\n' "$@" | sort -u 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() { function _bash-it-grep() {
: "${BASH_IT_GREP:=$(type -p egrep || type -p grep)}" : "${BASH_IT_GREP:=$(type -P grep)}"
printf "%s" "${BASH_IT_GREP:-/usr/bin/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() { 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 "$@" "${BASH_IT_GREP:-/usr/bin/grep}" -E "$@"
} }
@ -150,12 +156,12 @@ function _bash-it-component-list-matching() {
function _bash-it-component-list-enabled() { function _bash-it-component-list-enabled() {
local IFS=$'\n' component="$1" 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() { function _bash-it-component-list-disabled() {
local IFS=$'\n' component="$1" 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. # Checks if a given item is enabled for a particular component/file-type.

View File

@ -8,8 +8,8 @@
# shellcheck disable=SC2002 # Prefer 'cat' for cleaner script # shellcheck disable=SC2002 # Prefer 'cat' for cleaner script
mapfile -t FILES < <( mapfile -t FILES < <(
cat clean_files.txt \ cat clean_files.txt \
| grep -v -E '^\s*$' \ | grep -E -v '^\s*$' \
| grep -v -E '^\s*#' \ | grep -E -v '^\s*#' \
| xargs -n1 -I{} find "{}" -type f | xargs -n1 -I{} find "{}" -type f
) )

View File

@ -1,3 +1,4 @@
# shellcheck shell=bash
cite about-plugin cite about-plugin
about-plugin 'AWS helper functions' about-plugin 'AWS helper functions'
@ -40,13 +41,13 @@ function __awskeys_help {
function __awskeys_get { function __awskeys_get {
local ln=$(grep -n "\[ *$1 *\]" "${AWS_SHARED_CREDENTIALS_FILE}" | cut -d ":" -f 1) local ln=$(grep -n "\[ *$1 *\]" "${AWS_SHARED_CREDENTIALS_FILE}" | cut -d ":" -f 1)
if [[ -n "${ln}" ]]; then if [[ -n "${ln}" ]]; then
tail -n +${ln} "${AWS_SHARED_CREDENTIALS_FILE}" | egrep -m 2 "aws_access_key_id|aws_secret_access_key" 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}" | egrep -m 1 "aws_session_token" tail -n +${ln} "${AWS_SHARED_CREDENTIALS_FILE}" | grep -F -m 1 "aws_session_token"
fi fi
} }
function __awskeys_list { 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 if [[ -n $"{credentials_list}" ]]; then
echo -e "Available credentials profiles:\n" echo -e "Available credentials profiles:\n"
for profile in ${credentials_list}; do for profile in ${credentials_list}; do

View File

@ -4,7 +4,8 @@ about-plugin 'Alert (BEL) when process ends after a threshold of seconds'
function precmd_return_notification() { function precmd_return_notification() {
local command_start="${COMMAND_DURATION_START_SECONDS:=0}" 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%.*}))" local -i command_duration="$((${current_time%.*} - ${command_start%.*}))"
if [[ "${command_duration}" -gt "${NOTIFY_IF_COMMAND_RETURNS_AFTER:-5}" ]]; then if [[ "${command_duration}" -gt "${NOTIFY_IF_COMMAND_RETURNS_AFTER:-5}" ]]; then
printf '\a' printf '\a'

View File

@ -8,13 +8,13 @@ function __() {
function __make_ansi() { function __make_ansi() {
next=$1 next=$1
shift shift
echo "\[\e[$("__$next" "$@")m\]" echo -e "\[\e[$("__$next" "$@")m\]"
} }
function __make_echo() { function __make_echo() {
next=$1 next=$1
shift shift
echo "\033[$("__$next" "$@")m" echo -e "\033[$("__$next" "$@")m"
} }
function __reset() { function __reset() {

View File

@ -63,12 +63,15 @@ function dirs-help() {
if [[ -f "${BASH_IT_DIRS_BKS?}" ]]; then if [[ -f "${BASH_IT_DIRS_BKS?}" ]]; then
# shellcheck disable=SC1090 # shellcheck disable=SC1090
source "${BASH_IT_DIRS_BKS?}" source "${BASH_IT_DIRS_BKS?}"
elif [[ -f ~/.dirs ]]; then else
mkdir -p "${BASH_IT_DIRS_BKS%/*}"
if [[ -f ~/.dirs ]]; then
mv -vn ~/.dirs "${BASH_IT_DIRS_BKS?}" mv -vn ~/.dirs "${BASH_IT_DIRS_BKS?}"
# shellcheck disable=SC1090 # shellcheck disable=SC1090
source "${BASH_IT_DIRS_BKS?}" source "${BASH_IT_DIRS_BKS?}"
else else
touch "${BASH_IT_DIRS_BKS?}" touch "${BASH_IT_DIRS_BKS?}"
fi
fi fi
alias L='cat "${BASH_IT_DIRS_BKS?}"' alias L='cat "${BASH_IT_DIRS_BKS?}"'

View File

@ -30,8 +30,8 @@ function editpost() {
pushd "${SITE}/_posts" > /dev/null || return pushd "${SITE}/_posts" > /dev/null || return
for POST in *; do for POST in *; do
DATE="$(echo "${POST}" | grep -oE "[0-9]{4}-[0-9]{1,2}-[0-9]{1,2}")" DATE="$(echo "${POST}" | grep -E -o "[0-9]{4}-[0-9]{1,2}-[0-9]{1,2}")"
TITLE="$(grep -oE "title: (.+)" < "${POST}")" TITLE="$(grep -E -o "title: (.+)" < "${POST}")"
TITLE="${TITLE/title: /}" TITLE="${TITLE/title: /}"
echo "${COUNTER}) ${DATE} ${TITLE}" echo "${COUNTER}) ${DATE} ${TITLE}"
POSTS[COUNTER]="$POST" POSTS[COUNTER]="$POST"

View File

@ -1,3 +1,4 @@
# shellcheck shell=bash
cite about-plugin cite about-plugin
about-plugin 'postgres helper functions' about-plugin 'postgres helper functions'
@ -50,7 +51,7 @@ function postgres_status {
function is_postgres_running { 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"
} }

View File

@ -21,7 +21,7 @@ function pj() {
# with the same name in project directories # with the same name in project directories
IFS=':' read -ra dests <<< "${BASH_IT_PROJECT_PATHS?${FUNCNAME[0]}: project working folders must be configured}" IFS=':' read -ra dests <<< "${BASH_IT_PROJECT_PATHS?${FUNCNAME[0]}: project working folders must be configured}"
for d in "${!dests[@]}"; do for d in "${!dests[@]}"; do
if [[ ! -d "${dests[d]}" ]]; then if [[ ! -d "${dests[d]}/${proj}" ]]; then
unset 'dests[d]' unset 'dests[d]'
fi fi
done done

View File

@ -9,7 +9,7 @@ function local_setup_file() {
@test "plugins cmd-returned-notify: notify after elapsed time" { @test "plugins cmd-returned-notify: notify after elapsed time" {
export NOTIFY_IF_COMMAND_RETURNS_AFTER=0 export NOTIFY_IF_COMMAND_RETURNS_AFTER=0
export COMMAND_DURATION_START_SECONDS="${EPOCHREALTIME:-$SECONDS}" export COMMAND_DURATION_START_SECONDS="$(_shell_duration_en)"
sleep 1 sleep 1
run precmd_return_notification run precmd_return_notification
assert_success assert_success
@ -18,7 +18,7 @@ function local_setup_file() {
@test "plugins cmd-returned-notify: do not notify before elapsed time" { @test "plugins cmd-returned-notify: do not notify before elapsed time" {
export NOTIFY_IF_COMMAND_RETURNS_AFTER=10 export NOTIFY_IF_COMMAND_RETURNS_AFTER=10
export COMMAND_DURATION_START_SECONDS="${EPOCHREALTIME:-$SECONDS}" export COMMAND_DURATION_START_SECONDS="$(_shell_duration_en)"
sleep 1 sleep 1
run precmd_return_notification run precmd_return_notification
assert_success assert_success
@ -34,7 +34,7 @@ function local_setup_file() {
@test "lib command_duration: preexec set COMMAND_DURATION_START_SECONDS" { @test "lib command_duration: preexec set COMMAND_DURATION_START_SECONDS" {
export COMMAND_DURATION_START_SECONDS= export COMMAND_DURATION_START_SECONDS=
assert_equal "${COMMAND_DURATION_START_SECONDS}" "" assert_equal "${COMMAND_DURATION_START_SECONDS}" ""
NOW="${EPOCHREALTIME:-$SECONDS}" NOW="$(_shell_duration_en)"
_command_duration_pre_exec _command_duration_pre_exec
# We need to make sure to account for nanoseconds... # We need to make sure to account for nanoseconds...
assert_equal "${COMMAND_DURATION_START_SECONDS%.*}" "${NOW%.*}" assert_equal "${COMMAND_DURATION_START_SECONDS%.*}" "${NOW%.*}"

View File

@ -182,7 +182,7 @@ prompt_segment() {
# declare -p codes # declare -p codes
if [[ $CURRENT_BG != NONE && $1 != "$CURRENT_BG" ]]; then 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[@])" debug "pre prompt " "$(ansi intermediate[@])"
PR="$PR $(ansi intermediate[@])$SEGMENT_SEPARATOR" PR="$PR $(ansi intermediate[@])$SEGMENT_SEPARATOR"
debug "post prompt " "$(ansi codes[@])" debug "post prompt " "$(ansi codes[@])"

View File

@ -1,8 +1,11 @@
# shellcheck shell=bash # shellcheck shell=bash
# shellcheck disable=SC2034 # Expected behavior for themes. # 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 # Theme custom glyphs
# SCM
SCM_GIT_CHAR_GITLAB=${BARBUK_GITLAB_CHAR:=' '} SCM_GIT_CHAR_GITLAB=${BARBUK_GITLAB_CHAR:=' '}
SCM_GIT_CHAR_BITBUCKET=${BARBUK_BITBUCKET_CHAR:=' '} SCM_GIT_CHAR_BITBUCKET=${BARBUK_BITBUCKET_CHAR:=' '}
SCM_GIT_CHAR_GITHUB=${BARBUK_GITHUB_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_GIT_CHAR_ICON_BRANCH=${BARBUK_GIT_BRANCH_ICON:=''}
SCM_HG_CHAR=${BARBUK_HG_CHAR:='☿ '} SCM_HG_CHAR=${BARBUK_HG_CHAR:='☿ '}
SCM_SVN_CHAR=${BARBUK_SVN_CHAR:='⑆ '} SCM_SVN_CHAR=${BARBUK_SVN_CHAR:='⑆ '}
# Exit code
EXIT_CODE_ICON=${BARBUK_EXIT_CODE_ICON:=' '} EXIT_CODE_ICON=${BARBUK_EXIT_CODE_ICON:=' '}
# Programming and tools
PYTHON_VENV_CHAR=${BARBUK_PYTHON_VENV_CHAR:=' '} 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
COMMAND_DURATION_MIN_SECONDS=${COMMAND_DURATION_MIN_SECONDS:-1} COMMAND_DURATION_MIN_SECONDS=${COMMAND_DURATION_MIN_SECONDS:-1}
COMMAND_DURATION_COLOR="$normal"
# Ssh user and hostname display # Ssh user and hostname display
SSH_INFO=${BARBUK_SSH_INFO:=true} SSH_INFO=${BARBUK_SSH_INFO:=true}
@ -24,24 +34,32 @@ HOST_INFO=${BARBUK_HOST_INFO:=long}
# Bash-it default glyphs customization # Bash-it default glyphs customization
SCM_NONE_CHAR= SCM_NONE_CHAR=
SCM_THEME_PROMPT_DIRTY=" ${bold_red}" SCM_THEME_PROMPT_DIRTY=" ${bold_red?}"
SCM_THEME_PROMPT_CLEAN=" ${bold_green}" SCM_THEME_PROMPT_CLEAN=" ${bold_green?}"
SCM_THEME_PROMPT_PREFIX="|" SCM_THEME_PROMPT_PREFIX="|"
SCM_THEME_PROMPT_SUFFIX="${green}| " SCM_THEME_PROMPT_SUFFIX="${green?}| "
SCM_GIT_BEHIND_CHAR="${bold_red}${normal}" SCM_GIT_BEHIND_CHAR="${bold_red?}${normal?}"
SCM_GIT_AHEAD_CHAR="${bold_green}${normal}" SCM_GIT_AHEAD_CHAR="${bold_green?}${normal?}"
SCM_GIT_UNTRACKED_CHAR="⌀" SCM_GIT_UNTRACKED_CHAR="⌀"
SCM_GIT_UNSTAGED_CHAR="${bold_yellow}${normal}" SCM_GIT_UNSTAGED_CHAR="${bold_yellow?}${normal?}"
SCM_GIT_STAGED_CHAR="${bold_green}+${normal}" SCM_GIT_STAGED_CHAR="${bold_green?}+${normal?}"
GIT_THEME_PROMPT_DIRTY=" ${bold_red}" GIT_THEME_PROMPT_DIRTY=" ${bold_red?}"
GIT_THEME_PROMPT_CLEAN=" ${bold_green}" GIT_THEME_PROMPT_CLEAN=" ${bold_green?}"
GIT_THEME_PROMPT_PREFIX="${cyan}" GIT_THEME_PROMPT_PREFIX="${cyan?}"
GIT_THEME_PROMPT_SUFFIX="${cyan}" GIT_THEME_PROMPT_SUFFIX="${cyan?}"
SCM_THEME_BRANCH_TRACK_PREFIX="${normal}${cyan}" SCM_THEME_BRANCH_TRACK_PREFIX="${normal?}${cyan?}"
SCM_THEME_CURRENT_USER_PREFFIX='  ' SCM_THEME_CURRENT_USER_PREFFIX='  '
SCM_GIT_SHOW_CURRENT_USER=false 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 { 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 local remote remote_domain
@ -57,36 +75,72 @@ function _git-uptream-remote-logo {
bitbucket) SCM_GIT_CHAR="$SCM_GIT_CHAR_BITBUCKET" ;; bitbucket) SCM_GIT_CHAR="$SCM_GIT_CHAR_BITBUCKET" ;;
*) SCM_GIT_CHAR="$SCM_GIT_CHAR_DEFAULT" ;; *) SCM_GIT_CHAR="$SCM_GIT_CHAR_DEFAULT" ;;
esac esac
echo "${purple?}$(scm_char)"
} }
function git_prompt_info { function git_prompt_info() {
git_prompt_vars 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" 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-code { function __exit_prompt() {
if [[ "$1" -ne 0 ]]; then if [[ "$exit_code" -ne 0 ]]; then
exit_code=" ${purple}${EXIT_CODE_ICON}${yellow}${exit_code}${bold_orange}" echo "${purple?}${EXIT_CODE_ICON}${yellow?}${exit_code}${bold_orange?} "
else else
exit_code="${bold_green}" echo "${bold_green}"
fi fi
} }
function _prompt { function __aws_profile_prompt() {
local exit_code="$?" wrap_char=' ' dir_color=$green ssh_info='' python_venv='' host command_duration= if [[ -n "${AWS_PROFILE}" ]]; then
echo -n "${bold_purple?}${AWS_PROFILE_CHAR}${normal?}${AWS_PROFILE} "
command_duration=$(_command_duration)
_exit-code exit_code
_git-uptream-remote-logo
history -a
# Detect root shell
if [ "$(whoami)" = root ]; then
dir_color=$red
fi fi
}
function __scaleway_profile_prompt() {
if [[ -n "${SCW_PROFILE}" ]]; then
echo -n "${bold_purple?}${SCALEWAY_PROFILE_CHAR}${normal?}${SCW_PROFILE} "
fi
}
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} "
}
function __cloud_prompt() {
__aws_profile_prompt
__scaleway_profile_prompt
__gcloud_prompt
}
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 __node_prompt() {
local node_version=""
node_version="$(node_version_prompt)"
[[ -n "${node_version}" ]] && echo "${bold_purple?}${NODE_CHAR}${normal?}${node_version} "
}
function __ruby_prompt() {
local ruby_version=""
ruby_version="$(ruby_version_prompt)"
[[ -n "${ruby_version}" ]] && echo "${bold_purple?}${RUBY_CHAR}${normal?}${ruby_version} "
}
function __ssh_prompt() {
# Detect ssh # Detect ssh
if [[ -n "${SSH_CONNECTION}" ]] && [ "$SSH_INFO" = true ]; then if [[ -n "${SSH_CONNECTION}" ]] && [ "$SSH_INFO" = true ]; then
if [ "$HOST_INFO" = long ]; then if [ "$HOST_INFO" = long ]; then
@ -94,19 +148,56 @@ function _prompt {
else else
host="\h" host="\h"
fi fi
ssh_info="${bold_blue}\u${bold_orange}@${cyan}$host ${bold_orange}in" echo "${bold_blue?}\u${bold_orange?}@${cyan?}$host ${bold_orange?}in "
fi fi
}
function __python_venv_prompt() {
# Detect python venv # Detect python venv
if [[ -n "${CONDA_DEFAULT_ENV}" ]]; then if [[ -n "${CONDA_DEFAULT_ENV}" ]]; then
python_venv="$PYTHON_VENV_CHAR${CONDA_DEFAULT_ENV} " echo "${bold_purple?}$PYTHON_VENV_CHAR${normal?}${CONDA_DEFAULT_ENV} "
elif [[ -n "${VIRTUAL_ENV}" ]]; then elif [[ -n "${VIRTUAL_ENV}" ]]; then
python_venv="$PYTHON_VENV_CHAR$(basename "${VIRTUAL_ENV}") " 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
echo "${dir_color}\w${normal} "
}
function __scm_prompt() {
scm_prompt_info
}
function __duration_prompt() {
[[ -n "$command_duration" ]] && echo "${command_duration} "
}
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 fi
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} " PS1="${PS1}${wrap_char}${normal} "
} }
safe_append_prompt_command _prompt safe_append_prompt_command __prompt-command

View File

@ -2,7 +2,7 @@
# git branch parser # git branch parser
function parse_git_branch() { 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() { function parse_git_branch_no_color() {

View File

@ -1,3 +1,5 @@
# shellcheck shell=bash
# port of zork theme # port of zork theme
# set colors for use throughout the prompt # set colors for use throughout the prompt
@ -50,7 +52,7 @@ function is_integer() { # helper function for todo-txt-count
todo_txt_count() { todo_txt_count() {
if `hash todo.sh 2>&-`; then # is todo.sh installed 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 if is_integer $count; then # did we get a sane answer back
echo "${BRACKET_COLOR}[${STRING_COLOR}T:$count${BRACKET_COLOR}]$normal" echo "${BRACKET_COLOR}[${STRING_COLOR}T:$count${BRACKET_COLOR}]$normal"
fi fi

1208
vendor/github.com/dsifford/yarn-completion/yarn generated vendored 100644

File diff suppressed because it is too large Load Diff