From 1d2687f1f44d9b5424adad3e550335c8bf2e7d9e Mon Sep 17 00:00:00 2001 From: Arnaud Crampet Date: Tue, 18 Jul 2023 15:54:14 +0200 Subject: [PATCH] Add function tag on functions Add var protection ( starting ) Add stack trace builder start --- .ackrc | 2 +- .editorconfig | 72 +- .gitattributes | 18 +- .github/ISSUE_TEMPLATE/bug_report.yml | 170 +- .github/ISSUE_TEMPLATE/config.yml | 10 +- .github/ISSUE_TEMPLATE/feature_request.yml | 68 +- .github/PULL_REQUEST_TEMPLATE.md | 60 +- .github/no-response.yml | 22 +- .github/workflows/ci.yml | 132 +- .gitignore | 48 +- .gitmodules | 32 +- .pre-commit-config.yaml | 100 +- .readthedocs.yml | 20 +- LICENSE | 42 +- aliases/available/apt.aliases.bash | 11 +- aliases/available/curl.aliases.bash | 11 +- aliases/available/docker.aliases.bash | 3 +- aliases/available/fuck.aliases.bash | 3 +- aliases/available/general.aliases.bash | 23 +- aliases/available/git.aliases.bash | 22 +- aliases/available/kubectl.aliases.bash | 3 +- aliases/available/osx.aliases.bash | 3 +- aliases/available/uuidgen.aliases.bash | 6 +- bash_it.sh | 21 +- clean_files.txt | 352 +-- completion/available/aliases.completion.bash | 34 +- completion/available/awless.completion.bash | 3 +- completion/available/awscli.completion.bash | 3 +- completion/available/bash-it.completion.bash | 28 +- completion/available/brew.completion.bash | 12 +- completion/available/bundler.completion.bash | 28 +- .../available/capistrano.completion.bash | 11 +- completion/available/cargo.completion.bash | 3 +- completion/available/composer.completion.bash | 17 +- completion/available/conda.completion.bash | 6 +- completion/available/consul.completion.bash | 3 +- completion/available/dart.completion.bash | 2 +- completion/available/defaults.completion.bash | 3 +- completion/available/dirs.completion.bash | 5 +- .../available/docker-compose.completion.bash | 98 +- completion/available/docker.completion.bash | 3 +- completion/available/dotnet.completion.bash | 8 +- completion/available/fabric.completion.bash | 42 +- completion/available/flutter.completion.bash | 3 +- completion/available/gcloud.completion.bash | 3 +- completion/available/gem.completion.bash | 3 +- completion/available/git.completion.bash | 12 +- completion/available/git_flow.completion.bash | 30 +- .../available/git_flow_avh.completion.bash | 51 +- .../available/github-cli.completion.bash | 3 +- completion/available/go.completion.bash | 6 +- completion/available/gradle.completion.bash | 187 +- completion/available/grunt.completion.bash | 3 +- completion/available/helm.completion.bash | 3 +- completion/available/hub.completion.bash | 222 +- completion/available/invoke.completion.bash | 7 +- completion/available/jungle.completion.bash | 3 +- completion/available/kind.completion.bash | 3 +- completion/available/knife.completion.bash | 137 +- completion/available/kontena.completion.bash | 3 +- completion/available/kubectl.completion.bash | 3 +- completion/available/laravel.completion.bash | 13 +- completion/available/lerna.completion.bash | 7 +- completion/available/makefile.completion.bash | 3 +- completion/available/maven.completion.bash | 2 +- completion/available/minikube.completion.bash | 3 +- completion/available/ng.completion.bash | 3 +- completion/available/ngrok.completion.bash | 3 +- .../available/notify-send.completion.bash | 7 +- completion/available/npm.completion.bash | 3 +- completion/available/packer.completion.bash | 3 +- completion/available/pip.completion.bash | 11 +- completion/available/pip3.completion.bash | 10 +- completion/available/pipenv.completion.bash | 3 +- completion/available/pipx.completion.bash | 3 +- completion/available/projects.completion.bash | 24 +- completion/available/rake.completion.bash | 8 +- completion/available/rustup.completion.bash | 3 +- completion/available/salt.completion.bash | 104 +- completion/available/sdkman.completion.bash | 21 +- completion/available/sqlmap.completion.bash | 3 +- completion/available/ssh.completion.bash | 15 +- completion/available/svn.completion.bash | 12 +- completion/available/system.completion.bash | 24 +- .../available/test_kitchen.completion.bash | 7 +- completion/available/tmux.completion.bash | 51 +- completion/available/vagrant.completion.bash | 15 +- completion/available/vault.completion.bash | 3 +- .../available/virtualbox.completion.bash | 46 +- completion/available/wpscan.completion.bash | 10 +- docs/Makefile | 40 +- docs/README.md | 126 +- docs/commands/doctor.rst | 40 +- docs/commands/index.rst | 32 +- docs/commands/profile.rst | 62 +- docs/commands/reload.rst | 46 +- docs/commands/search.rst | 118 +- docs/commands/update.rst | 76 +- docs/conf.py | 108 +- docs/contributing.rst | 230 +- docs/custom.rst | 36 +- docs/development.rst | 360 +-- docs/help_screens.rst | 26 +- docs/index.rst | 88 +- docs/installation.rst | 117 +- docs/misc.rst | 20 +- docs/proxy_support.rst | 86 +- docs/requirements.txt | 8 +- docs/test.rst | 92 +- docs/themes-list/atomic.rst | 400 +-- docs/themes-list/barbuk.rst | 332 +-- docs/themes-list/bira.rst | 24 +- docs/themes-list/brainy.rst | 290 +- docs/themes-list/codeword.rst | 56 +- docs/themes-list/easy.rst | 28 +- docs/themes-list/index.rst | 1198 ++++---- docs/themes-list/nwinkler_random_colors.rst | 78 +- docs/themes-list/oh-my-posh.rst | 30 +- docs/themes-list/powerline-base.rst | 260 +- docs/themes-list/powerline-multiline.rst | 72 +- docs/themes-list/powerline-naked.rst | 18 +- docs/themes-list/powerline-plain.rst | 28 +- docs/themes-list/powerline.rst | 26 +- docs/themes-list/radek.rst | 50 +- docs/themes-list/redline.rst | 112 +- docs/themes.rst | 186 +- docs/troubleshooting.rst | 90 +- docs/uninstalling.rst | 28 +- docs/vcs_user.rst | 400 +-- hooks/check-clean-files-txt.sh | 8 +- hooks/dot-bash.sh | 6 +- hooks/dot-sh.sh | 6 +- install.sh | 95 +- lib/appearance.bash | 9 +- lib/command_duration.bash | 12 +- lib/helpers.bash | 248 +- lib/log.bash | 24 +- lib/preexec.bash | 18 +- lib/preview.bash | 9 +- lib/search.bash | 41 +- lib/utilities.bash | 37 +- plugins/available/autojump.plugin.bash | 9 +- plugins/available/aws.plugin.bash | 40 +- plugins/available/base.plugin.bash | 36 +- plugins/available/basher.plugin.bash | 6 +- plugins/available/battery.plugin.bash | 48 +- plugins/available/blesh.plugin.bash | 6 +- plugins/available/boot2docker.plugin.bash | 3 +- plugins/available/browser.plugin.bash | 18 +- plugins/available/cht-sh.plugin.bash | 3 +- .../available/cmd-returned-notify.plugin.bash | 3 +- plugins/available/colors.plugin.bash | 10 +- plugins/available/direnv.plugin.bash | 3 +- plugins/available/dirs.plugin.bash | 8 +- plugins/available/docker-compose.plugin.bash | 3 +- plugins/available/docker.plugin.bash | 9 +- plugins/available/explain.plugin.bash | 6 +- plugins/available/extract.plugin.bash | 45 +- plugins/available/fzf.plugin.bash | 11 +- plugins/available/gif.plugin.bash | 45 +- plugins/available/git-subrepo.plugin.bash | 3 +- plugins/available/git.plugin.bash | 68 +- plugins/available/gitstatus.plugin.bash | 3 +- plugins/available/go.plugin.bash | 6 +- plugins/available/goenv.plugin.bash | 6 +- plugins/available/hg.plugin.bash | 6 +- plugins/available/history-eternal.plugin.bash | 3 +- plugins/available/history-search.plugin.bash | 3 +- .../history-substring-search.plugin.bash | 3 +- plugins/available/hub.plugin.bash | 3 +- plugins/available/javascript.plugin.bash | 8 +- plugins/available/jekyll.plugin.bash | 57 +- plugins/available/jump.plugin.bash | 3 +- plugins/available/latex.plugin.bash | 3 +- plugins/available/nginx.plugin.bash | 9 +- plugins/available/node.plugin.bash | 3 +- plugins/available/nodenv.plugin.bash | 3 +- plugins/available/osx-timemachine.plugin.bash | 3 +- plugins/available/osx.plugin.bash | 21 +- plugins/available/pack.plugin.bash | 112 +- plugins/available/percol.plugin.bash | 3 +- plugins/available/plenv.plugin.bash | 6 +- plugins/available/projects.plugin.bash | 6 +- plugins/available/proxy.plugin.bash | 45 +- plugins/available/pyenv.plugin.bash | 6 +- plugins/available/python.plugin.bash | 12 +- plugins/available/rails.plugin.bash | 3 +- plugins/available/rbenv.plugin.bash | 3 +- plugins/available/ruby.plugin.bash | 3 +- plugins/available/sshagent.plugin.bash | 21 +- plugins/available/subversion.plugin.bash | 3 +- plugins/available/sudo.plugin.bash | 6 +- plugins/available/textmate.plugin.bash | 3 +- plugins/available/thefuck.plugin.bash | 3 +- plugins/available/virtualenv.plugin.bash | 6 +- plugins/available/xterm.plugin.bash | 16 +- plugins/available/zoxide.plugin.bash | 3 +- profiles/default.bash_it | 24 +- scripts/reloader.bash | 12 +- test/bash_it/bash_it.bats | 686 ++--- test/completion/aliases.completion.bats | 60 +- test/completion/bash-it.completion.bats | 719 ++--- .../profiles/test-bad-component.bash_it | 24 +- .../bash_it/profiles/test-bad-type.bash_it | 24 +- test/fixtures/svn/broken/svn | 8 +- test/fixtures/svn/working/svn | 21 +- test/install/install.bats | 176 +- test/install/uninstall.bats | 122 +- test/lib/composure.bats | 26 +- test/lib/helpers.bats | 1465 +++++----- test/lib/log.bats | 168 +- test/lib/preexec.bats | 328 +-- test/lib/search.bats | 136 +- test/lib/utilities.bats | 166 +- test/lint-requirements.txt | 2 +- test/plugins/base.plugin.bats | 152 +- test/plugins/battery.plugin.bats | 768 +++--- test/plugins/cmd-returned-notify.plugin.bats | 82 +- test/plugins/go.plugin.bats | 148 +- test/plugins/ruby.plugin.bats | 63 +- test/plugins/xterm.plugin.bats | 84 +- test/run | 107 +- test/themes/base.theme.bats | 146 +- test/themes/base.theme.git.bats | 774 +++--- test/themes/base.theme.svn.bats | 212 +- themes/agnoster/agnoster.theme.bash | 115 +- themes/atomic/atomic.theme.bash | 27 +- themes/axin/axin.theme.bash | 6 +- themes/barbuk/barbuk.theme.bash | 30 +- themes/base.theme.bash | 147 +- themes/binaryanomaly/binaryanomaly.theme.bash | 9 +- themes/bira/bira.theme.bash | 3 +- themes/bobby/bobby.theme.bash | 3 +- themes/brainy/brainy.theme.bash | 71 +- themes/brunton/brunton.theme.bash | 3 +- themes/clean/clean.theme.bash | 3 +- themes/cooperkid/cooperkid.theme.bash | 6 +- themes/cupcake/cupcake.theme.bash | 3 +- themes/doubletime/doubletime.theme.bash | 9 +- themes/dulcie/dulcie.theme.bash | 21 +- themes/easy/easy.theme.bash | 3 +- themes/emperor/emperor.theme.bash | 9 +- themes/essential/essential.theme.bash | 15 +- themes/font/font.theme.bash | 3 +- themes/githelpers.theme.bash | 51 +- themes/gitline/powerline.base.bash | 80 +- themes/hawaii50/hawaii50.theme.bash | 15 +- themes/iterate/iterate.theme.bash | 6 +- themes/liquidprompt/.gitignore | 2 +- themes/liquidprompt/liquidprompt.theme.bash | 9 +- themes/mairan/mairan.theme.bash | 6 +- themes/metal/metal.theme.bash | 3 +- themes/minimal/minimal.theme.bash | 2 +- themes/modern-t/modern-t.theme.bash | 4 +- themes/modern-time/modern-time.theme.bash | 6 +- themes/modern/modern.theme.bash | 18 +- themes/newin/newin.theme.bash | 5 +- themes/norbu/norbu.theme.bash | 6 +- themes/nwinkler/nwinkler.theme.bash | 5 +- .../nwinkler_random_colors.theme.bash | 5 +- themes/oh-my-posh/oh-my-posh.theme.bash | 3 +- themes/parrot/parrot.theme.bash | 12 +- .../powerline-multiline.base.bash | 29 +- .../powerline-naked/powerline-naked.base.bash | 12 +- .../powerline-plain/powerline-plain.base.bash | 18 +- themes/powerline/powerline.base.bash | 116 +- themes/powerturk/powerturk.theme.bash | 42 +- themes/purity/purity.theme.bash | 6 +- themes/rainbowbrite/rainbowbrite.theme.bash | 2 +- themes/ramses/ramses.theme.bash | 10 +- themes/rana/rana.theme.bash | 30 +- themes/rjorgenson/rjorgenson.theme.bash | 21 +- themes/roderik/roderik.theme.bash | 3 +- themes/sexy/sexy.theme.bash | 15 +- themes/slick/slick.theme.bash | 8 +- themes/tonka/tonka.theme.bash | 11 +- themes/wanelo/wanelo.theme.bash | 3 +- themes/zork/zork.theme.bash | 10 +- uninstall.sh | 3 +- vendor/.gitattributes | 4 +- vendor/github.com/django/django/AUTHORS | 1964 ++++++------- vendor/github.com/django/django/LICENSE | 54 +- .../github.com/django/django/LICENSE.python | 530 ++-- .../github.com/django/django/extras/Makefile | 18 +- .../django/django/extras/README.TXT | 2 +- .../django/extras/django_bash_completion | 146 +- .../github.com/dsifford/yarn-completion/yarn | 2432 +++++++++-------- vendor/github.com/erichs/composure/.gitignore | 2 +- .../github.com/erichs/composure/.travis.yml | 18 +- vendor/github.com/erichs/composure/History.md | 180 +- vendor/github.com/erichs/composure/LICENSE | 32 +- vendor/github.com/erichs/composure/Makefile | 20 +- vendor/github.com/erichs/composure/README.md | 484 ++-- .../github.com/erichs/composure/c_extras.sh | 25 +- .../erichs/composure/composure.plugin.zsh | 4 +- .../github.com/erichs/composure/composure.sh | 157 +- .../github.com/erichs/composure/test/Makefile | 36 +- .../erichs/composure/test/runshellcheck.sh | 6 +- .../erichs/composure/test/wvtestrun | 378 +-- .../gaelicWizard/bash-progcomp/.editorconfig | 80 +- .../gaelicWizard/bash-progcomp/LICENSE | 60 +- .../bash-progcomp/defaults.completion.bats | 369 +-- .../rcaloras/bash-preexec/.travis.yml | 40 +- .../rcaloras/bash-preexec/LICENSE.md | 42 +- .../rcaloras/bash-preexec/README.md | 214 +- .../rcaloras/bash-preexec/bash-preexec.sh | 88 +- .../rcaloras/bash-preexec/test/README.md | 44 +- .../bash-preexec/test/bash-preexec.bats | 728 ++--- .../bash-preexec/test/include-test.bats | 40 +- .../rparree/jboss-bash-completion/LICENSE | 42 +- .../rparree/jboss-bash-completion/README.md | 74 +- .../rparree/jboss-bash-completion/jboss5 | 190 +- .../rparree/jboss-bash-completion/jboss7 | 283 +- .../apm-bash-completion/CODE_OF_CONDUCT.md | 150 +- .../vigo/apm-bash-completion/LICENSE | 42 +- .../vigo/apm-bash-completion/README.md | 140 +- .../github.com/vigo/apm-bash-completion/apm | 132 +- 317 files changed, 13872 insertions(+), 12525 deletions(-) diff --git a/.ackrc b/.ackrc index 876f1317..c9e10018 100644 --- a/.ackrc +++ b/.ackrc @@ -1 +1 @@ ---ignore-dir=enabled/ +--ignore-dir=enabled/ diff --git a/.editorconfig b/.editorconfig index f67aa2df..607b7c6a 100644 --- a/.editorconfig +++ b/.editorconfig @@ -1,36 +1,36 @@ -# EditorConfig is awesome: http://EditorConfig.org - -[*] -indent_style = space -indent_size = 2 -end_of_line = lf -charset = utf-8 - -trim_trailing_whitespace = true -insert_final_newline = true - -[**.{md,rst}] -trim_trailing_whitespace = false - -[.git*] -indent_size = tab -indent_style = tab - -[{**.*sh,test/run,**.bats}] -indent_size = tab -indent_style = tab - -shell_variant = bash -binary_next_line = true # like -bn -switch_case_indent = true # like -ci -space_redirects = true # like -sr -keep_padding = false # like -kp -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -[**.bats] -indent_size = tab -indent_style = tab -shell_variant = bats +# EditorConfig is awesome: http://EditorConfig.org + +[*] +indent_style = space +indent_size = 2 +end_of_line = lf +charset = utf-8 + +trim_trailing_whitespace = true +insert_final_newline = true + +[**.{md,rst}] +trim_trailing_whitespace = false + +[.git*] +indent_size = tab +indent_style = tab + +[{**.*sh,test/run,**.bats}] +indent_size = tab +indent_style = tab + +shell_variant = bash +binary_next_line = true # like -bn +switch_case_indent = true # like -ci +space_redirects = true # like -sr +keep_padding = false # like -kp +end_of_line = lf +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true + +[**.bats] +indent_size = tab +indent_style = tab +shell_variant = bats diff --git a/.gitattributes b/.gitattributes index de622e06..64c63117 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,9 +1,9 @@ -*.sh text eol=lf -*.bash text eol=lf - -# Docs allow trailing whitespaces -*.md whitespace=-blank-at-eol -*.rst whitespace=-blank-at-eol - -# Windows files -*.bat text eol=crlf +*.sh text eol=lf +*.bash text eol=lf + +# Docs allow trailing whitespaces +*.md whitespace=-blank-at-eol +*.rst whitespace=-blank-at-eol + +# Windows files +*.bat text eol=crlf diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml index a187422e..e016375f 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.yml +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -1,85 +1,85 @@ -name: 🐛 Bug report -title: "[Bug]: " -description: Create a bug report to help us improve -labels: "bug:general" -body: - - type: textarea - attributes: - label: Expected behavior - description: Tell us what should happen. - validations: - required: true - - type: textarea - attributes: - label: Current behavior - description: Tell us what happens instead of the expected behavior. - validations: - required: true - - type: textarea - attributes: - label: Possible solution - description: Tell us how it could be fixed at your glance. - validations: - required: false - - type: textarea - attributes: - label: Context - description: > - How has this issue affected you? What are you trying to accomplish? - Providing context helps us come up with a solution that is most useful in the real world. - validations: - required: false - - type: textarea - attributes: - label: Steps to reproduce - description: > - Provide a link to a live example, or an unambiguous set of steps to reproduce this bug. Include code to reproduce, if relevant. - validations: - required: true - - type: input - attributes: - label: Bash-it version - placeholder: "How to get: bash-it version" - validations: - required: true - - type: input - attributes: - label: List of enabled plugins, themes and aliases - placeholder: "How to get: bash-it show plugins|themes|aliases (it is not a pipe)" - validations: - required: true - - type: input - attributes: - label: Bash version - placeholder: "How to get: bash --version" - validations: - required: true - - type: input - attributes: - label: Operating system and version - placeholder: "How to get: neofetch (or another command)" - validations: - required: true - - type: textarea - attributes: - label: "bash-it doctor output" - value: | - ``` - # How to get: bash-it doctor - ``` - validations: - required: false - - type: textarea - attributes: - label: Your ~/.bashrc - value: | - ```bash - # How to get: cat ~/.bashrc - ``` - validations: - required: true - - type: textarea - attributes: - label: Notes - description: > - Provide any extra details here. +name: 🐛 Bug report +title: "[Bug]: " +description: Create a bug report to help us improve +labels: "bug:general" +body: + - type: textarea + attributes: + label: Expected behavior + description: Tell us what should happen. + validations: + required: true + - type: textarea + attributes: + label: Current behavior + description: Tell us what happens instead of the expected behavior. + validations: + required: true + - type: textarea + attributes: + label: Possible solution + description: Tell us how it could be fixed at your glance. + validations: + required: false + - type: textarea + attributes: + label: Context + description: > + How has this issue affected you? What are you trying to accomplish? + Providing context helps us come up with a solution that is most useful in the real world. + validations: + required: false + - type: textarea + attributes: + label: Steps to reproduce + description: > + Provide a link to a live example, or an unambiguous set of steps to reproduce this bug. Include code to reproduce, if relevant. + validations: + required: true + - type: input + attributes: + label: Bash-it version + placeholder: "How to get: bash-it version" + validations: + required: true + - type: input + attributes: + label: List of enabled plugins, themes and aliases + placeholder: "How to get: bash-it show plugins|themes|aliases (it is not a pipe)" + validations: + required: true + - type: input + attributes: + label: Bash version + placeholder: "How to get: bash --version" + validations: + required: true + - type: input + attributes: + label: Operating system and version + placeholder: "How to get: neofetch (or another command)" + validations: + required: true + - type: textarea + attributes: + label: "bash-it doctor output" + value: | + ``` + # How to get: bash-it doctor + ``` + validations: + required: false + - type: textarea + attributes: + label: Your ~/.bashrc + value: | + ```bash + # How to get: cat ~/.bashrc + ``` + validations: + required: true + - type: textarea + attributes: + label: Notes + description: > + Provide any extra details here. diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml index f33f8a3f..95fabb40 100644 --- a/.github/ISSUE_TEMPLATE/config.yml +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -1,5 +1,5 @@ -blank_issues_enabled: true -contact_links: - - name: Libera chat - url: https://web.libera.chat/?channel=#bash-it - about: You can ask and answer questions here +blank_issues_enabled: true +contact_links: + - name: Libera chat + url: https://web.libera.chat/?channel=#bash-it + about: You can ask and answer questions here diff --git a/.github/ISSUE_TEMPLATE/feature_request.yml b/.github/ISSUE_TEMPLATE/feature_request.yml index 670aef64..c841fb1d 100644 --- a/.github/ISSUE_TEMPLATE/feature_request.yml +++ b/.github/ISSUE_TEMPLATE/feature_request.yml @@ -1,34 +1,34 @@ -name: 💡 Feature request -title: "[Feature]: " -description: Suggest an idea for this project -labels: "feature request" -body: - - type: textarea - attributes: - label: Expected behavior - description: Tell us how your feature should work. - validations: - required: true - - type: textarea - attributes: - label: Current behavior - description: Explain the difference your feature will have from current behavior. - validations: - required: true - - type: textarea - attributes: - label: Possible solution - description: Tell us how it could be fixed at your glance. - validations: - required: false - - type: textarea - attributes: - label: Context - description: > - How has this issue affected you? What are you trying to accomplish? - Providing context helps us come up with a solution that is most useful in the real world. - - type: textarea - attributes: - label: Notes - description: > - Provide any extra details here. +name: 💡 Feature request +title: "[Feature]: " +description: Suggest an idea for this project +labels: "feature request" +body: + - type: textarea + attributes: + label: Expected behavior + description: Tell us how your feature should work. + validations: + required: true + - type: textarea + attributes: + label: Current behavior + description: Explain the difference your feature will have from current behavior. + validations: + required: true + - type: textarea + attributes: + label: Possible solution + description: Tell us how it could be fixed at your glance. + validations: + required: false + - type: textarea + attributes: + label: Context + description: > + How has this issue affected you? What are you trying to accomplish? + Providing context helps us come up with a solution that is most useful in the real world. + - type: textarea + attributes: + label: Notes + description: > + Provide any extra details here. diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index fd9bceb8..c4082581 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -1,30 +1,30 @@ - - -## Description - - -## Motivation and Context - - - -## How Has This Been Tested? - - - - -## Screenshots (if appropriate): - -## Types of changes - -- [ ] Bug fix (non-breaking change which fixes an issue) -- [ ] New feature (non-breaking change which adds functionality) -- [ ] Breaking change (fix or feature that would cause existing functionality to change) - -## Checklist: - - -- [ ] My code follows the code style of this project. -- [ ] If my change requires a change to the documentation, I have updated the documentation accordingly. -- [ ] I have read the **CONTRIBUTING** document. -- [ ] If I have added a new file, I also added it to ``clean_files.txt`` and formatted it using ``lint_clean_files.sh``. -- [ ] I have added tests to cover my changes, and all the new and existing tests pass. + + +## Description + + +## Motivation and Context + + + +## How Has This Been Tested? + + + + +## Screenshots (if appropriate): + +## Types of changes + +- [ ] Bug fix (non-breaking change which fixes an issue) +- [ ] New feature (non-breaking change which adds functionality) +- [ ] Breaking change (fix or feature that would cause existing functionality to change) + +## Checklist: + + +- [ ] My code follows the code style of this project. +- [ ] If my change requires a change to the documentation, I have updated the documentation accordingly. +- [ ] I have read the **CONTRIBUTING** document. +- [ ] If I have added a new file, I also added it to ``clean_files.txt`` and formatted it using ``lint_clean_files.sh``. +- [ ] I have added tests to cover my changes, and all the new and existing tests pass. diff --git a/.github/no-response.yml b/.github/no-response.yml index e80a98be..0fe8eb5c 100644 --- a/.github/no-response.yml +++ b/.github/no-response.yml @@ -1,11 +1,11 @@ -# Configuration for probot-no-response - https://github.com/probot/no-response - -# Number of days of inactivity before an Issue is closed for lack of response -daysUntilClose: 14 -# Label requiring a response -responseRequiredLabel: waiting-for-response -# Comment to post when closing an Issue for lack of response. Set to `false` to disable -closeComment: > - This issue has been automatically closed because there has been no response - to our request for more information from the original author. - You can always reopen the issue if needed. +# Configuration for probot-no-response - https://github.com/probot/no-response + +# Number of days of inactivity before an Issue is closed for lack of response +daysUntilClose: 14 +# Label requiring a response +responseRequiredLabel: waiting-for-response +# Comment to post when closing an Issue for lack of response. Set to `false` to disable +closeComment: > + This issue has been automatically closed because there has been no response + to our request for more information from the original author. + You can always reopen the issue if needed. diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8e772ec5..0bcc26dc 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,66 +1,66 @@ -name: CI - -# Triggers the workflow on push or pull request events -on: [push, pull_request] - -jobs: - bats-test: - strategy: - matrix: - os: [ubuntu-20.04, ubuntu-22.04, macos-12, macos-11] - - runs-on: ${{ matrix.os }} - - steps: - - uses: actions/checkout@v2 - - name: Install greadlink - if: startsWith(runner.os, 'macOS') - run: brew install coreutils - - name: Install parallel - if: startsWith(runner.os, 'macOS') - run: brew install parallel - - name: Test code - run: test/run - - build-docs: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v2 - - name: Set up Python - uses: actions/setup-python@v2 - with: - python-version: 3.8 - - name: Install docs dependencies - run: python3 -m pip install -r docs/requirements.txt - - name: Build the docs - run: sphinx-build -W -b html docs docs/_build/html - - lint: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v2 - - name: Set up Go - uses: actions/setup-go@v2 - with: - go-version: 1.17 - - name: Set up Python - 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 - 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 - run: ./lint_clean_files.sh +name: CI + +# Triggers the workflow on push or pull request events +on: [push, pull_request] + +jobs: + bats-test: + strategy: + matrix: + os: [ubuntu-20.04, ubuntu-22.04, macos-12, macos-11] + + runs-on: ${{ matrix.os }} + + steps: + - uses: actions/checkout@v2 + - name: Install greadlink + if: startsWith(runner.os, 'macOS') + run: brew install coreutils + - name: Install parallel + if: startsWith(runner.os, 'macOS') + run: brew install parallel + - name: Test code + run: test/run + + build-docs: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: 3.8 + - name: Install docs dependencies + run: python3 -m pip install -r docs/requirements.txt + - name: Build the docs + run: sphinx-build -W -b html docs docs/_build/html + + lint: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + - name: Set up Go + uses: actions/setup-go@v2 + with: + go-version: 1.17 + - name: Set up Python + 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 + 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 + run: ./lint_clean_files.sh diff --git a/.gitignore b/.gitignore index 8e6f12a1..b302a3eb 100644 --- a/.gitignore +++ b/.gitignore @@ -1,24 +1,24 @@ -.atom-build.json -*/enabled/* -.DS_Store -custom/* -!custom/example.bash -.rvmrc -aliases/custom.aliases.bash -completion/custom.completion.bash -lib/custom.bash -plugins/custom.plugins.bash -*.swp -.*.un~ -bats -.idea -*.sublime-workspace -*.sublime-project -enabled/* -/enabled -tmp/ - -# Do not save profiles -profiles/* -# apart from the default one -!profiles/default.bash_it +.atom-build.json +*/enabled/* +.DS_Store +custom/* +!custom/example.bash +.rvmrc +aliases/custom.aliases.bash +completion/custom.completion.bash +lib/custom.bash +plugins/custom.plugins.bash +*.swp +.*.un~ +bats +.idea +*.sublime-workspace +*.sublime-project +enabled/* +/enabled +tmp/ + +# Do not save profiles +profiles/* +# apart from the default one +!profiles/default.bash_it diff --git a/.gitmodules b/.gitmodules index 57b46adc..a3020b40 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,16 +1,16 @@ -[submodule "test_lib/bats-core"] - path = test_lib/bats-core - url = https://github.com/bats-core/bats-core - branch = tags/v1.2.0 -[submodule "test_lib/bats-support"] - path = test_lib/bats-support - url = https://github.com/bats-core/bats-support - branch = tags/v0.3.0 -[submodule "test_lib/bats-assert"] - path = test_lib/bats-assert - url = https://github.com/bats-core/bats-assert - branch = tags/v2.0.0 -[submodule "test_lib/bats-file"] - path = test_lib/bats-file - url = https://github.com/bats-core/bats-file - branch = tags/v0.3.0 +[submodule "test_lib/bats-core"] + path = test_lib/bats-core + url = https://github.com/bats-core/bats-core + branch = tags/v1.2.0 +[submodule "test_lib/bats-support"] + path = test_lib/bats-support + url = https://github.com/bats-core/bats-support + branch = tags/v0.3.0 +[submodule "test_lib/bats-assert"] + path = test_lib/bats-assert + url = https://github.com/bats-core/bats-assert + branch = tags/v2.0.0 +[submodule "test_lib/bats-file"] + path = test_lib/bats-file + url = https://github.com/bats-core/bats-file + branch = tags/v0.3.0 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index af5f30af..49b7899e 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,50 +1,50 @@ -# See https://pre-commit.com for more information -# See https://pre-commit.com/hooks.html for more hooks ---- -# fail_fast: true -minimum_pre_commit_version: 1.18.1 -exclude: "docs/_build/" -repos: - - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v2.3.0 - hooks: - - id: trailing-whitespace - exclude: ".(md|rst)$" - - id: end-of-file-fixer - - id: check-merge-conflict - - id: mixed-line-ending - - id: check-added-large-files - - repo: https://github.com/jumanjihouse/pre-commit-hooks - rev: 2.1.5 - hooks: - - id: git-check # Configure in .gitattributes - - id: shellcheck - exclude: ".bats$" - - id: shfmt - exclude: ".bats$" - - repo: https://github.com/Lucas-C/pre-commit-hooks - rev: v1.1.7 - hooks: - # - id: forbid-crlf - - id: remove-crlf - exclude: ".bat$" - - repo: local - hooks: - - id: dot-sh - name: Check .sh files against bash-it requirements - entry: ./hooks/dot-sh.sh - language: system - files: "\\.sh$" - types: [file] - - id: dot-bash - name: Check .bash files against bash-it requirements - exclude: "test/test_helper.bash" - entry: ./hooks/dot-bash.sh - language: system - files: "\\.bash$" - types: [file] - - id: clean-files-txt - name: Check that clean_files.txt is sorted alphabetically. - entry: ./hooks/check-clean-files-txt.sh - language: system - files: clean_files.txt +# See https://pre-commit.com for more information +# See https://pre-commit.com/hooks.html for more hooks +--- +# fail_fast: true +minimum_pre_commit_version: 1.18.1 +exclude: "docs/_build/" +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v2.3.0 + hooks: + - id: trailing-whitespace + exclude: ".(md|rst)$" + - id: end-of-file-fixer + - id: check-merge-conflict + - id: mixed-line-ending + - id: check-added-large-files + - repo: https://github.com/jumanjihouse/pre-commit-hooks + rev: 2.1.5 + hooks: + - id: git-check # Configure in .gitattributes + - id: shellcheck + exclude: ".bats$" + - id: shfmt + exclude: ".bats$" + - repo: https://github.com/Lucas-C/pre-commit-hooks + rev: v1.1.7 + hooks: + # - id: forbid-crlf + - id: remove-crlf + exclude: ".bat$" + - repo: local + hooks: + - id: dot-sh + name: Check .sh files against bash-it requirements + entry: ./hooks/dot-sh.sh + language: system + files: "\\.sh$" + types: [file] + - id: dot-bash + name: Check .bash files against bash-it requirements + exclude: "test/test_helper.bash" + entry: ./hooks/dot-bash.sh + language: system + files: "\\.bash$" + types: [file] + - id: clean-files-txt + name: Check that clean_files.txt is sorted alphabetically. + entry: ./hooks/check-clean-files-txt.sh + language: system + files: clean_files.txt diff --git a/.readthedocs.yml b/.readthedocs.yml index 751f3175..1c52ac52 100644 --- a/.readthedocs.yml +++ b/.readthedocs.yml @@ -1,10 +1,10 @@ -version: 2 - -sphinx: - builder: htmldir - configuration: docs/conf.py - -python: - version: 3.7 - install: - - requirements: docs/requirements.txt +version: 2 + +sphinx: + builder: htmldir + configuration: docs/conf.py + +python: + version: 3.7 + install: + - requirements: docs/requirements.txt diff --git a/LICENSE b/LICENSE index 25b6d7fb..b69ad668 100644 --- a/LICENSE +++ b/LICENSE @@ -1,21 +1,21 @@ -MIT License - -Copyright (c) 2020-2021 Bash-it - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. +MIT License + +Copyright (c) 2020-2021 Bash-it + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/aliases/available/apt.aliases.bash b/aliases/available/apt.aliases.bash index 1d43ffac..994a1277 100644 --- a/aliases/available/apt.aliases.bash +++ b/aliases/available/apt.aliases.bash @@ -6,8 +6,15 @@ cite 'about-alias' about-alias 'Apt and dpkg aliases for Ubuntu and Debian distros.' # set apt aliases -function _set_pkg_aliases() { - if _command_exists apt; then +function _set_pkg_aliases() +{ + ############ STACK_TRACE_BUILDER ##################### + Function_Name="${FUNCNAME[0]}" + Function_PATH="${Function_PATH}/${Function_Name}" + ###################################################### + + if _command_exists apt + then alias apts='apt-cache search' alias aptshow='apt-cache show' alias aptinst='sudo apt-get install -V' diff --git a/aliases/available/curl.aliases.bash b/aliases/available/curl.aliases.bash index a270e416..0ce2e499 100644 --- a/aliases/available/curl.aliases.bash +++ b/aliases/available/curl.aliases.bash @@ -2,8 +2,15 @@ about-alias 'Curl aliases for convenience.' # set apt aliases -function _set_pkg_aliases() { - if _command_exists curl; then +function _set_pkg_aliases() +{ + ############ STACK_TRACE_BUILDER ##################### + Function_Name="${FUNCNAME[0]}" + Function_PATH="${Function_PATH}/${Function_Name}" + ###################################################### + + if _command_exists curl + then # follow redirects alias cl='curl -L' # follow redirects, download as original name diff --git a/aliases/available/docker.aliases.bash b/aliases/available/docker.aliases.bash index 1c49207f..a854423a 100644 --- a/aliases/available/docker.aliases.bash +++ b/aliases/available/docker.aliases.bash @@ -19,7 +19,8 @@ case $OSTYPE in ;; esac -if _bash-it-component-item-is-enabled plugin docker; then +if _bash-it-component-item-is-enabled plugin docker + then # Function aliases from docker plugin: alias dkrmlc='docker-remove-most-recent-container' # Delete most recent (i.e., last) Docker container alias dkrmall='docker-remove-stale-assets' # Delete all untagged images and exited containers diff --git a/aliases/available/fuck.aliases.bash b/aliases/available/fuck.aliases.bash index 4cfa52d8..76d9697e 100644 --- a/aliases/available/fuck.aliases.bash +++ b/aliases/available/fuck.aliases.bash @@ -2,7 +2,8 @@ about-alias 'fuck/please to retry last command with sudo' # Play nicely with 'thefuck' plugin -if ! _command_exists fuck; then +if ! _command_exists fuck + then alias fuck='sudo $(fc -ln -1)' fi alias please=fuck diff --git a/aliases/available/general.aliases.bash b/aliases/available/general.aliases.bash index 2511aab8..c3c952ac 100644 --- a/aliases/available/general.aliases.bash +++ b/aliases/available/general.aliases.bash @@ -1,7 +1,8 @@ # shellcheck shell=bash about-alias 'general aliases' -if command ls --color -d . &> /dev/null; then +if command ls --color -d . &> /dev/null + then alias ls='ls --color=auto' # BSD `ls` doesn't need an argument (`-G`) when `$CLICOLOR` is set. fi @@ -23,11 +24,13 @@ alias vbpf='${VISUAL:-vim} ~/.bash_profile' # colored grep # Need to check an existing file for a pattern that will be found to ensure # that the check works when on an OS that supports the color option -if command grep --color=auto "a" "${BASH_IT?}"/*.md &> /dev/null; then +if command grep --color=auto "a" "${BASH_IT?}"/*.md &> /dev/null + then alias grep='grep --color=auto' fi -if _command_exists gshuf; then +if _command_exists gshuf + then alias shuf=gshuf fi @@ -60,7 +63,8 @@ alias -- -='cd -' # Go back alias h='history' # Tree -if ! _command_exists tree; then +if ! _command_exists tree + then alias tree="find . -print | sed -e 's;[^/]*/;|____;g;s;____|; |;g'" fi @@ -72,9 +76,16 @@ alias rd='rmdir' alias xt='extract' # Display whatever file is regular file or folder -function catt() { +function catt() +{ + ############ STACK_TRACE_BUILDER ##################### + Function_Name="${FUNCNAME[0]}" + Function_PATH="${Function_PATH}/${Function_Name}" + ###################################################### + for i in "$@"; do - if [[ -d "$i" ]]; then + if [[ -d "$i" ]] + then ls "$i" else cat "$i" diff --git a/aliases/available/git.aliases.bash b/aliases/available/git.aliases.bash index 5572c932..647fab10 100644 --- a/aliases/available/git.aliases.bash +++ b/aliases/available/git.aliases.bash @@ -91,7 +91,8 @@ alias ggui='git gui' # home alias ghm='cd "$(git rev-parse --show-toplevel)"' # Git home # appendage to ghm -if ! _command_exists gh; then +if ! _command_exists gh + then alias gh='ghm' fi @@ -199,12 +200,25 @@ case $OSTYPE in esac # functions -function gdv() { +function gdv() +{ + ############ STACK_TRACE_BUILDER ##################### + Function_Name="${FUNCNAME[0]}" + Function_PATH="${Function_PATH}/${Function_Name}" + ###################################################### + git diff --ignore-all-space "$@" | vim -R - } -function get_default_branch() { - if git branch | grep -q '^. main\s*$'; then +function get_default_branch() +{ + ############ STACK_TRACE_BUILDER ##################### + Function_Name="${FUNCNAME[0]}" + Function_PATH="${Function_PATH}/${Function_Name}" + ###################################################### + + if git branch | grep -q '^. main\s*$' + then echo main else echo master diff --git a/aliases/available/kubectl.aliases.bash b/aliases/available/kubectl.aliases.bash index ce01bdaf..6fd04209 100644 --- a/aliases/available/kubectl.aliases.bash +++ b/aliases/available/kubectl.aliases.bash @@ -1,7 +1,8 @@ # shellcheck shell=bash about-alias 'kubectl aliases' -if _command_exists kubectl; then +if _command_exists kubectl + then alias kc='kubectl' alias kcgp='kubectl get pods' alias kcgd='kubectl get deployments' diff --git a/aliases/available/osx.aliases.bash b/aliases/available/osx.aliases.bash index 0a16c06f..e38ff712 100644 --- a/aliases/available/osx.aliases.bash +++ b/aliases/available/osx.aliases.bash @@ -21,7 +21,8 @@ alias skype='open -a Skype' alias mou='open -a Mou' alias subl='open -a "Sublime Text"' -if [[ -s /usr/bin/firefox ]]; then +if [[ -s /usr/bin/firefox ]] + then unalias firefox fi diff --git a/aliases/available/uuidgen.aliases.bash b/aliases/available/uuidgen.aliases.bash index 45c36820..7772a149 100644 --- a/aliases/available/uuidgen.aliases.bash +++ b/aliases/available/uuidgen.aliases.bash @@ -1,10 +1,12 @@ # shellcheck shell=bash about-alias 'uuidgen aliases' -if _command_exists uuid; then # Linux +if _command_exists uuid + then # Linux alias uuidu="uuid | tr '[:lower:]' '[:upper:]'" alias uuidl=uuid -elif _command_exists uuidgen; then # macOS/BSD +elif _command_exists uuidgen + then # macOS/BSD alias uuidu="uuidgen" alias uuid="uuidgen | tr '[:upper:]' '[:lower:]'" # because upper case is like YELLING alias uuidl=uuid diff --git a/bash_it.sh b/bash_it.sh index ddc02b70..ca49b3b2 100755 --- a/bash_it.sh +++ b/bash_it.sh @@ -45,7 +45,8 @@ done # Load theme, if a theme was set # shellcheck source-path=SCRIPTDIR/themes -if [[ -n "${BASH_IT_THEME:-}" ]]; then +if [[ -n "${BASH_IT_THEME:-}" ]] + then _log_debug "Loading theme '${BASH_IT_THEME}'." BASH_IT_LOG_PREFIX="themes: githelpers: " source "${BASH_IT}/themes/githelpers.theme.bash" @@ -64,7 +65,8 @@ fi _log_debug "Loading custom aliases, completion, plugins..." for _bash_it_main_file_type in "aliases" "completion" "plugins"; do _bash_it_main_file_custom="${BASH_IT}/${_bash_it_main_file_type}/custom.${_bash_it_main_file_type}.bash" - if [[ -s "${_bash_it_main_file_custom}" ]]; then + if [[ -s "${_bash_it_main_file_custom}" ]] + then _bash-it-log-prefix-by-path "${_bash_it_main_file_custom}" _log_debug "Loading component..." # shellcheck disable=SC1090 @@ -76,7 +78,8 @@ done # Custom _log_debug "Loading general custom files..." for _bash_it_main_file_custom in "${BASH_IT_CUSTOM}"/*.bash "${BASH_IT_CUSTOM}"/*/*.bash; do - if [[ -s "${_bash_it_main_file_custom}" ]]; then + if [[ -s "${_bash_it_main_file_custom}" ]] + then _bash-it-log-prefix-by-path "${_bash_it_main_file_custom}" _log_debug "Loading custom file..." # shellcheck disable=SC1090 @@ -85,21 +88,25 @@ for _bash_it_main_file_custom in "${BASH_IT_CUSTOM}"/*.bash "${BASH_IT_CUSTOM}"/ BASH_IT_LOG_PREFIX="core: main: " done -if [[ -n "${PROMPT:-}" ]]; then +if [[ -n "${PROMPT:-}" ]] + then PS1="${PROMPT}" fi # Adding Support for other OSes -if _command_exists gloobus-preview; then +if _command_exists gloobus-preview + then PREVIEW="gloobus-preview" -elif [[ -d /Applications/Preview.app ]]; then +elif [[ -d /Applications/Preview.app ]] + then PREVIEW="/Applications/Preview.app" else PREVIEW="less" fi # BASH_IT_RELOAD_LEGACY is set. -if [[ -n "${BASH_IT_RELOAD_LEGACY:-}" ]] && ! _command_exists reload; then +if [[ -n "${BASH_IT_RELOAD_LEGACY:-}" ]] && ! _command_exists reload + then # shellcheck disable=SC2139 alias reload="builtin source '${BASH_IT_BASHRC?}'" fi diff --git a/clean_files.txt b/clean_files.txt index 758e3b80..81d10fb6 100644 --- a/clean_files.txt +++ b/clean_files.txt @@ -1,176 +1,176 @@ -####################################################################### -# Allow-list of files to be lint-checked by CI -# -# Directory Support -# Directory references are allowed within the file, ie: -# -# themes/powerline -# -# All files under the referenced directory will be checked -# -# Checking Files Locally -# You can manually invoke the check via: -# -# lint_clean_files.sh -# - -# root directories -# -aliases/ -docs/ -hooks/ -scripts/ - -# root files -# -.gitattributes -bash_it.sh -clean_files.txt -install.sh -lint_clean_files.sh - -# completions -# -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 -completion/available/composer.completion.bash -completion/available/conda.completion.bash -completion/available/consul.completion.bash -completion/available/dart.completion.bash -completion/available/django.completion.bash -completion/available/dmidecode.completion.bash -completion/available/docker-machine.completion.bash -completion/available/docker.completion.bash -completion/available/dotnet.completion.bash -completion/available/flutter.completion.bash -completion/available/gcloud.completion.bash -completion/available/gem.completion.bash -completion/available/git.completion.bash -completion/available/github-cli.completion.bash -completion/available/go.completion.bash -completion/available/helm.completion.bash -completion/available/jboss5.completion.bash -completion/available/jboss7.completion.bash -completion/available/jungle.completion.bash -completion/available/knife.completion.bash -completion/available/kontena.completion.bash -completion/available/kubectl.completion.bash -completion/available/laravel.completion.bash -completion/available/lerna.completion.bash -completion/available/minikube.completion.bash -completion/available/ngrok.completion.bash -completion/available/notify-send.completion.bash -completion/available/npm.completion.bash -completion/available/packer.completion.bash -completion/available/pip.completion.bash -completion/available/pip3.completion.bash -completion/available/pipenv.completion.bash -completion/available/pipx.completion.bash -completion/available/rustup.completion.bash -completion/available/sdkman.completion.bash -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 -lib/colors.bash -lib/command_duration.bash -lib/helpers.bash -lib/history.bash -lib/log.bash -lib/preexec.bash -lib/preview.bash -lib/search.bash -lib/utilities.bash - -# plugins -# -plugins/available/alias-completion.plugin.bash -plugins/available/autojump.plugin.bash -plugins/available/base.plugin.bash -plugins/available/basher.plugin.bash -plugins/available/battery.plugin.bash -plugins/available/blesh.plugin.bash -plugins/available/cmd-returned-notify.plugin.bash -plugins/available/colors.plugin.bash -plugins/available/direnv.plugin.bash -plugins/available/dirs.plugin.bash -plugins/available/docker-machine.plugin.bash -plugins/available/gif.plugin.bash -plugins/available/git-subrepo.plugin.bash -plugins/available/git.plugin.bash -plugins/available/go.plugin.bash -plugins/available/goenv.plugin.bash -plugins/available/history-eternal.plugin.bash -plugins/available/history-search.plugin.bash -plugins/available/history-substring-search.plugin.bash -plugins/available/history.plugin.bash -plugins/available/hub.plugin.bash -plugins/available/java.plugin.bash -plugins/available/jekyll.plugin.bash -plugins/available/jump.plugin.bash -plugins/available/latex.plugin.bash -plugins/available/less-pretty-cat.plugin.bash -plugins/available/man.plugin.bash -plugins/available/nginx.plugin.bash -plugins/available/node.plugin.bash -plugins/available/nodenv.plugin.bash -plugins/available/osx-timemachine.plugin.bash -plugins/available/osx.plugin.bash -plugins/available/percol.plugin.bash -plugins/available/plenv.plugin.bash -plugins/available/projects.plugin.bash -plugins/available/proxy.plugin.bash -plugins/available/pyenv.plugin.bash -plugins/available/python.plugin.bash -plugins/available/rbenv.plugin.bash -plugins/available/ruby.plugin.bash -plugins/available/textmate.plugin.bash -plugins/available/todo.plugin.bash -plugins/available/xterm.plugin.bash -plugins/available/zoxide.plugin.bash - -# tests -# -test/completion/aliases.completion.bats -test/run -test/test_helper.bash - -# themes -# -themes/90210 -themes/agnoster -themes/atomic -themes/axin -themes/bakke -themes/barbuk -themes/base.theme.bash -themes/binaryanomaly -themes/bira -themes/bobby -themes/bobby-python -themes/brainy -themes/brunton -themes/candy -themes/easy -themes/essential -themes/githelpers.theme.bash -themes/modern -themes/norbu -themes/oh-my-posh -themes/p4helpers.theme.bash -themes/pete -themes/powerline -themes/pure -themes/purity - -# vendor init files -# -vendor/.gitattributes +####################################################################### +# Allow-list of files to be lint-checked by CI +# +# Directory Support +# Directory references are allowed within the file, ie: +# +# themes/powerline +# +# All files under the referenced directory will be checked +# +# Checking Files Locally +# You can manually invoke the check via: +# +# lint_clean_files.sh +# + +# root directories +# +aliases/ +docs/ +hooks/ +scripts/ + +# root files +# +.gitattributes +bash_it.sh +clean_files.txt +install.sh +lint_clean_files.sh + +# completions +# +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 +completion/available/composer.completion.bash +completion/available/conda.completion.bash +completion/available/consul.completion.bash +completion/available/dart.completion.bash +completion/available/django.completion.bash +completion/available/dmidecode.completion.bash +completion/available/docker-machine.completion.bash +completion/available/docker.completion.bash +completion/available/dotnet.completion.bash +completion/available/flutter.completion.bash +completion/available/gcloud.completion.bash +completion/available/gem.completion.bash +completion/available/git.completion.bash +completion/available/github-cli.completion.bash +completion/available/go.completion.bash +completion/available/helm.completion.bash +completion/available/jboss5.completion.bash +completion/available/jboss7.completion.bash +completion/available/jungle.completion.bash +completion/available/knife.completion.bash +completion/available/kontena.completion.bash +completion/available/kubectl.completion.bash +completion/available/laravel.completion.bash +completion/available/lerna.completion.bash +completion/available/minikube.completion.bash +completion/available/ngrok.completion.bash +completion/available/notify-send.completion.bash +completion/available/npm.completion.bash +completion/available/packer.completion.bash +completion/available/pip.completion.bash +completion/available/pip3.completion.bash +completion/available/pipenv.completion.bash +completion/available/pipx.completion.bash +completion/available/rustup.completion.bash +completion/available/sdkman.completion.bash +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 +lib/colors.bash +lib/command_duration.bash +lib/helpers.bash +lib/history.bash +lib/log.bash +lib/preexec.bash +lib/preview.bash +lib/search.bash +lib/utilities.bash + +# plugins +# +plugins/available/alias-completion.plugin.bash +plugins/available/autojump.plugin.bash +plugins/available/base.plugin.bash +plugins/available/basher.plugin.bash +plugins/available/battery.plugin.bash +plugins/available/blesh.plugin.bash +plugins/available/cmd-returned-notify.plugin.bash +plugins/available/colors.plugin.bash +plugins/available/direnv.plugin.bash +plugins/available/dirs.plugin.bash +plugins/available/docker-machine.plugin.bash +plugins/available/gif.plugin.bash +plugins/available/git-subrepo.plugin.bash +plugins/available/git.plugin.bash +plugins/available/go.plugin.bash +plugins/available/goenv.plugin.bash +plugins/available/history-eternal.plugin.bash +plugins/available/history-search.plugin.bash +plugins/available/history-substring-search.plugin.bash +plugins/available/history.plugin.bash +plugins/available/hub.plugin.bash +plugins/available/java.plugin.bash +plugins/available/jekyll.plugin.bash +plugins/available/jump.plugin.bash +plugins/available/latex.plugin.bash +plugins/available/less-pretty-cat.plugin.bash +plugins/available/man.plugin.bash +plugins/available/nginx.plugin.bash +plugins/available/node.plugin.bash +plugins/available/nodenv.plugin.bash +plugins/available/osx-timemachine.plugin.bash +plugins/available/osx.plugin.bash +plugins/available/percol.plugin.bash +plugins/available/plenv.plugin.bash +plugins/available/projects.plugin.bash +plugins/available/proxy.plugin.bash +plugins/available/pyenv.plugin.bash +plugins/available/python.plugin.bash +plugins/available/rbenv.plugin.bash +plugins/available/ruby.plugin.bash +plugins/available/textmate.plugin.bash +plugins/available/todo.plugin.bash +plugins/available/xterm.plugin.bash +plugins/available/zoxide.plugin.bash + +# tests +# +test/completion/aliases.completion.bats +test/run +test/test_helper.bash + +# themes +# +themes/90210 +themes/agnoster +themes/atomic +themes/axin +themes/bakke +themes/barbuk +themes/base.theme.bash +themes/binaryanomaly +themes/bira +themes/bobby +themes/bobby-python +themes/brainy +themes/brunton +themes/candy +themes/easy +themes/essential +themes/githelpers.theme.bash +themes/modern +themes/norbu +themes/oh-my-posh +themes/p4helpers.theme.bash +themes/pete +themes/powerline +themes/pure +themes/purity + +# vendor init files +# +vendor/.gitattributes diff --git a/completion/available/aliases.completion.bash b/completion/available/aliases.completion.bash index 3e45e960..e7585717 100644 --- a/completion/available/aliases.completion.bash +++ b/completion/available/aliases.completion.bash @@ -8,7 +8,12 @@ about-plugin 'Automatic completion of aliases' # http://stackoverflow.com/a/1793178/1228454 # Automatically add completion for all aliases to commands having completion functions -function _bash-it-component-completion-callback-on-init-aliases() { +function _bash-it-component-completion-callback-on-init-aliases() +{ + ############ STACK_TRACE_BUILDER ##################### + Function_Name="${FUNCNAME[0]}" + Function_PATH="${Function_PATH}/${Function_Name}" + ###################################################### local namespace="alias_completion" local tmp_file completion_loader alias_name line completions chars local alias_arg_words new_completion compl_func compl_wrapper alias_defn @@ -27,7 +32,8 @@ function _bash-it-component-completion-callback-on-init-aliases() { tmp_file="$(mktemp -t "${namespace}-${RANDOM}XXXXXX")" || return 1 IFS=$'\n' read -r completion_loader < <(complete -p -D 2> /dev/null) - if [[ "${completion_loader#complete }" =~ '-F'[[:space:]]([[:alnum:]_]+)[[:space:]] ]]; then + if [[ "${completion_loader#complete }" =~ '-F'[[:space:]]([[:alnum:]_]+)[[:space:]] ]] + then completion_loader="${BASH_REMATCH[1]}" else completion_loader="" @@ -43,7 +49,8 @@ function _bash-it-component-completion-callback-on-init-aliases() { alias_defn="${line#*=\'}" # alias definition alias_defn="${alias_defn%\'}" alias_cmd="${alias_defn%%[[:space:]]*}" # first word of alias - if [[ ${alias_defn} == ${alias_cmd} ]]; then + if [[ ${alias_defn} == ${alias_cmd} ]] + then alias_args='' else alias_args="${alias_defn#*[[:space:]]}" # everything after first word @@ -51,15 +58,18 @@ function _bash-it-component-completion-callback-on-init-aliases() { # skip aliases to pipes, boolean control structures and other command lists chars=$'|&;()<>\n' - if [[ "${alias_defn}" =~ [$chars] ]]; then + if [[ "${alias_defn}" =~ [$chars] ]] + then continue fi # avoid expanding wildcards read -ra alias_arg_words <<< "$alias_args" # skip alias if there is no completion function triggered by the aliased command - if ! _bash-it-array-contains-element "$alias_cmd" "${completions[@]}"; then - if [[ -n "$completion_loader" ]]; then + if ! _bash-it-array-contains-element "$alias_cmd" "${completions[@]}" + then + if [[ -n "$completion_loader" ]] + then # force loading of completions for the aliased command "${completion_loader:?}" "${alias_cmd}" # 124 means completion loader was successful @@ -72,11 +82,13 @@ function _bash-it-component-completion-callback-on-init-aliases() { new_completion="$(complete -p "$alias_cmd" 2> /dev/null)" # create a wrapper inserting the alias arguments if any - if [[ -n $alias_args ]]; then + if [[ -n $alias_args ]] + then compl_func="${new_completion/#* -F /}" compl_func="${compl_func%% *}" # avoid recursive call loops by ignoring our own functions - if [[ "${compl_func#_"$namespace"::}" == "$compl_func" ]]; then + if [[ "${compl_func#_"$namespace"::}" == "$compl_func" ]] + then compl_wrapper="_${namespace}::${alias_name}" echo "function $compl_wrapper { local compl_word=\${2?} @@ -84,7 +96,8 @@ function _bash-it-component-completion-callback-on-init-aliases() { # check if prec_word is the alias itself. if so, replace it # with the last word in the unaliased form, i.e., # alias_cmd + ' ' + alias_args. - if [[ \$COMP_LINE == \"\$prec_word \$compl_word\" ]]; then + if [[ \$COMP_LINE == \"\$prec_word \$compl_word\" ]] + then prec_word='$alias_cmd $alias_args' prec_word=\${prec_word#* } fi @@ -100,7 +113,8 @@ function _bash-it-component-completion-callback-on-init-aliases() { fi # replace completion trigger by alias - if [[ -n $new_completion ]]; then + if [[ -n $new_completion ]] + then new_completion="${new_completion% *} $alias_name" echo "$new_completion" >> "$tmp_file" fi diff --git a/completion/available/awless.completion.bash b/completion/available/awless.completion.bash index 98a5d388..f180ddc5 100644 --- a/completion/available/awless.completion.bash +++ b/completion/available/awless.completion.bash @@ -1,5 +1,6 @@ # shellcheck shell=bash -if _command_exists awless; then +if _command_exists awless + then # shellcheck disable=SC1090 source <(awless completion bash) fi diff --git a/completion/available/awscli.completion.bash b/completion/available/awscli.completion.bash index 6b2c90ff..b0be9cf8 100644 --- a/completion/available/awscli.completion.bash +++ b/completion/available/awscli.completion.bash @@ -1,5 +1,6 @@ # shellcheck shell=bash -if _command_exists aws_completer; then +if _command_exists aws_completer + then complete -C "$(command -v aws_completer)" aws fi diff --git a/completion/available/bash-it.completion.bash b/completion/available/bash-it.completion.bash index 2259e37b..80f3de44 100644 --- a/completion/available/bash-it.completion.bash +++ b/completion/available/bash-it.completion.bash @@ -1,12 +1,24 @@ # shellcheck shell=bash -function _compreply_candidates() { +function _compreply_candidates() +{ + ############ STACK_TRACE_BUILDER ##################### + Function_Name="${FUNCNAME[0]}" + Function_PATH="${Function_PATH}/${Function_Name}" + ###################################################### + local IFS=$'\n' read -d '' -ra COMPREPLY < <(compgen -W "${candidates[*]}" -- "${cur}") } -function _bash-it() { +function _bash-it() +{ + ############ STACK_TRACE_BUILDER ##################### + Function_Name="${FUNCNAME[0]}" + Function_PATH="${Function_PATH}/${Function_Name}" + ###################################################### + local cur prev verb file_type candidates suffix COMPREPLY=() cur="${COMP_WORDS[COMP_CWORD]}" @@ -20,7 +32,8 @@ function _bash-it() { _compreply_candidates ;; help) - if [[ "${prev}" == "aliases" ]]; then + if [[ "${prev}" == "aliases" ]] + then candidates=('all' "$(_bash-it-component-list "${file_type}")") _compreply_candidates else @@ -31,7 +44,8 @@ function _bash-it() { profile) case "${file_type}" in load | rm) - if [[ "${file_type}" == "$prev" ]]; then + if [[ "${file_type}" == "$prev" ]] + then candidates=("${BASH_IT}/profiles"/*.bash_it) candidates=("${candidates[@]##*/}") candidates=("${candidates[@]%%.bash_it}") @@ -51,7 +65,8 @@ function _bash-it() { _compreply_candidates ;; update) - if [[ "${cur}" == -* ]]; then + if [[ "${cur}" == -* ]] + then candidates=('-s' '--silent') else candidates=('stable' 'dev') @@ -64,7 +79,8 @@ function _bash-it() { return 0 ;; enable | disable) - if [[ "${verb}" == "enable" ]]; then + if [[ "${verb}" == "enable" ]] + then suffix="disabled" else suffix="enabled" diff --git a/completion/available/brew.completion.bash b/completion/available/brew.completion.bash index 01e5d533..af933cb6 100644 --- a/completion/available/brew.completion.bash +++ b/completion/available/brew.completion.bash @@ -5,7 +5,8 @@ about-completion "brew completion" # Load late to make sure `system` completion loads first # BASH_IT_LOAD_PRIORITY: 375 -if [[ "$OSTYPE" != 'darwin'* ]]; then +if [[ "$OSTYPE" != 'darwin'* ]]; +then _log_warning "unsupported operating system - only 'Darwin' is supported" return 0 fi @@ -13,15 +14,18 @@ fi # Make sure brew is installed _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,1091 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,1091 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: # https://github.com/Bash-it/bash-it/issues/1458 # https://docs.brew.sh/Shell-Completion diff --git a/completion/available/bundler.completion.bash b/completion/available/bundler.completion.bash index 663a26d2..47a294ea 100644 --- a/completion/available/bundler.completion.bash +++ b/completion/available/bundler.completion.bash @@ -27,8 +27,8 @@ # To use, source this file on bash: # . completion-bundle -__bundle() { - local bundle_bin=("${_RUBY_COMMAND_PREFIX[@]}" "$1") +function __bundle() { + local bundle_bin=("${_RUBY_COMMAND_PREFIX[@]}" "${1}") local cur prev _get_comp_words_by_ref -n : cur prev local bundle_command @@ -37,7 +37,8 @@ __bundle() { COMPREPLY=() local options - if [[ $cur = -* && $bundle_command != exec ]]; then + if [[ $cur = -* && $bundle_command != exec ]] + then options="-V --help --no-color --no-no-color --verbose --no-verbose" case $bundle_command in "") @@ -140,10 +141,12 @@ __bundle() { esac ;; exec) - if [[ $COMP_CWORD -eq $bundle_command_index ]]; then + if [[ $COMP_CWORD -eq $bundle_command_index ]] + then # Figure out Bundler's binaries dir local bundler_bin=$(__bundle_exec_ruby 'puts Bundler.bundle_path + "bin"') - if [[ -d $bundler_bin ]]; then + if [[ -d $bundler_bin ]] + then local binaries=("$bundler_bin"/*) # If there are binaries, strip directory name and use them [[ -f "$binaries" ]] && options="${binaries[@]##*/}" @@ -190,7 +193,7 @@ __bundle() { COMPREPLY=($(compgen -W "${options[*]}" -- "$cur")) } -__bundle_get_command() { +function __bundle_get_command() { local i for ((i=1; i < $COMP_CWORD; ++i)); do local arg=${COMP_WORDS[$i]} @@ -216,13 +219,14 @@ __bundle_get_command() { # # Multiple groups can be entered, separated either by spaces or by colons. # Input is read from $cur, and the result is directly written to $COMPREPLY. -__bundle_complete_groups() { +function __bundle_complete_groups() { # Group being currently written local cur_group=${cur##*[ :]} # All groups written before local prefix=${cur%"$cur_group"} local groups=$(__bundle_exec_ruby 'puts Bundler.definition.dependencies.map(&:groups).reduce(:|).map(&:to_s)') - if [[ ! $groups ]]; then + if [[ ! $groups ]] + then COMPREPLY=() return fi @@ -241,7 +245,7 @@ __bundle_complete_groups() { # # Runs a Ruby script with Bundler loaded. # Results may be cached. -__bundle_exec_ruby() { +function __bundle_exec_ruby() { local bundle_bin=(${bundle_bin[@]:-bundle}) # Lockfile is inferred here, and might not be correct (for example, when # running on a subdirectory). However, a wrong file path won't be a @@ -256,11 +260,13 @@ __bundle_exec_ruby() { local cache_id_line="${bundle_bin[*]} @ $lockfile: ${*//$'\n'/ }" if [[ (! -f $lockfile || $cachefile -nt $lockfile) && - $(head -n 1 -- "$cachefile" 2>/dev/null) = "$cache_id_line" ]]; then + $(head -n 1 -- "$cachefile" 2>/dev/null) = "$cache_id_line" ]] + then tail -n +2 -- "$cachefile" else local output=$("${bundle_bin[@]}" exec ruby -e "$@" 2>/dev/null) - if [[ $? -eq 0 ]]; then + if [[ $? -eq 0 ]] + then (mkdir -p -- "$cachedir" && echo "$cache_id_line"$'\n'"$output" >$cachefile) 2>/dev/null echo "$output" diff --git a/completion/available/capistrano.completion.bash b/completion/available/capistrano.completion.bash index d5fda06f..d0d7b6f5 100644 --- a/completion/available/capistrano.completion.bash +++ b/completion/available/capistrano.completion.bash @@ -3,12 +3,15 @@ export COMP_WORDBREAKS=${COMP_WORDBREAKS/\:/} -_capcomplete() { - if [ -f Capfile ]; then +function _capcomplete() { + if [ -f Capfile ] + then recent=`ls -t .cap_tasks~ Capfile **/*.cap 2> /dev/null | head -n 1` - if [[ $recent != '.cap_tasks~' ]]; then + if [[ $recent != '.cap_tasks~' ]] + then cap --version | grep 'Capistrano v2.' > /dev/null - if [ $? -eq 0 ]; then + if [ $? -eq 0 ] + then # Capistrano 2.x cap --tool --verbose --tasks | cut -d " " -f 2 > .cap_tasks~ else diff --git a/completion/available/cargo.completion.bash b/completion/available/cargo.completion.bash index d276ee72..7315161b 100644 --- a/completion/available/cargo.completion.bash +++ b/completion/available/cargo.completion.bash @@ -1,6 +1,7 @@ # shellcheck shell=bash # cargo (Rust package manager) completion -if _binary_exists rustup && _binary_exists cargo; then +if _binary_exists rustup && _binary_exists cargo + then eval "$(rustup completions bash cargo)" fi diff --git a/completion/available/composer.completion.bash b/completion/available/composer.completion.bash index 176f0832..020b9062 100644 --- a/completion/available/composer.completion.bash +++ b/completion/available/composer.completion.bash @@ -2,21 +2,29 @@ cite "about-completion" about-completion "composer completion" -function __composer_completion() { +function __composer_completion() +{ + ############ STACK_TRACE_BUILDER ##################### + Function_Name="${FUNCNAME[0]}" + Function_PATH="${Function_PATH}/${Function_Name}" + ###################################################### + local cur coms opts com words COMPREPLY=() _get_comp_words_by_ref -n : cur words # lookup for command for word in "${words[@]:1}"; do - if [[ "${word}" != -* ]]; then + if [[ "${word}" != -* ]] + then com="${word}" break fi done # completing for an option - if [[ ${cur} == --* ]]; then + if [[ ${cur} == --* ]] + then opts="--help --quiet --verbose --version --ansi --no-ansi --no-interaction --profile --no-plugins --working-dir" case "${com}" in @@ -115,7 +123,8 @@ function __composer_completion() { fi # completing for a command - if [[ "${cur}" == "${com}" ]]; then + if [[ "${cur}" == "${com}" ]] + then coms="about archive browse clear-cache config create-project depends diagnose dump-autoload exec global help init install licenses list outdated prohibits remove require run-script search self-update show status suggests update validate" # shellcheck disable=SC2207 diff --git a/completion/available/conda.completion.bash b/completion/available/conda.completion.bash index f5a61e59..9812284b 100644 --- a/completion/available/conda.completion.bash +++ b/completion/available/conda.completion.bash @@ -2,8 +2,10 @@ cite "about-completion" about-completion "conda completion" -if _command_exists conda; then - if _command_exists register-python-argcomplete; then +if _command_exists conda + then + if _command_exists register-python-argcomplete + then eval "$(register-python-argcomplete conda)" else _log_warning "Argcomplete not found. Please run 'conda install argcomplete'" diff --git a/completion/available/consul.completion.bash b/completion/available/consul.completion.bash index 511cf372..91d396ea 100644 --- a/completion/available/consul.completion.bash +++ b/completion/available/consul.completion.bash @@ -2,6 +2,7 @@ cite "about-completion" about-completion "Hashicorp consul completion" -if _command_exists consul; then +if _command_exists consul + then complete -C "$(command -v consul)" consul fi diff --git a/completion/available/dart.completion.bash b/completion/available/dart.completion.bash index b7563443..ba3b9245 100644 --- a/completion/available/dart.completion.bash +++ b/completion/available/dart.completion.bash @@ -1,6 +1,6 @@ # shellcheck shell=bash -__dart_completion() { +function __dart_completion() { # shellcheck disable=SC2155 local prev=$(_get_pword) # shellcheck disable=SC2155 diff --git a/completion/available/defaults.completion.bash b/completion/available/defaults.completion.bash index 39d7ea95..6adb803e 100644 --- a/completion/available/defaults.completion.bash +++ b/completion/available/defaults.completion.bash @@ -1,5 +1,6 @@ # shellcheck shell=bash -if test -s "${BASH_IT?}/vendor/github.com/gaelicWizard/bash-progcomp/defaults.completion.bash"; then +if test -s "${BASH_IT?}/vendor/github.com/gaelicWizard/bash-progcomp/defaults.completion.bash" + then source "$_" fi diff --git a/completion/available/dirs.completion.bash b/completion/available/dirs.completion.bash index ba18db32..b7b9e54c 100644 --- a/completion/available/dirs.completion.bash +++ b/completion/available/dirs.completion.bash @@ -1,11 +1,12 @@ #!/usr/bin/env bash # Bash completion support for the 'dirs' plugin (commands G, R). -_dirs-complete() { +function _dirs-complete() { local CURRENT_PROMPT="${COMP_WORDS[COMP_CWORD]}" # parse all defined shortcuts from ~/.dirs - if [ -r "$HOME/.dirs" ]; then + if [ -r "$HOME/.dirs" ] + then COMPREPLY=($(compgen -W "$(grep -v '^#' ~/.dirs | sed -e 's/\(.*\)=.*/\1/')" -- ${CURRENT_PROMPT}) ) fi diff --git a/completion/available/docker-compose.completion.bash b/completion/available/docker-compose.completion.bash index 1102f5d9..de8ee10d 100755 --- a/completion/available/docker-compose.completion.bash +++ b/completion/available/docker-compose.completion.bash @@ -34,13 +34,13 @@ __docker_compose_previous_extglob_setting=$(shopt -p extglob) shopt -s extglob -__docker_compose_q() { +function __docker_compose_q() { docker-compose 2>/dev/null "${top_level_options[@]}" "$@" } # Transforms a multiline list of strings into a single line string # with the words separated by "|". -__docker_compose_to_alternatives() { +function __docker_compose_to_alternatives() { local parts=( $1 ) local IFS='|' echo "${parts[*]}" @@ -48,17 +48,18 @@ __docker_compose_to_alternatives() { # Transforms a multiline list of options into an extglob pattern # suitable for use in case statements. -__docker_compose_to_extglob() { - local extglob=$( __docker_compose_to_alternatives "$1" ) +function __docker_compose_to_extglob() { + local extglob=$( __docker_compose_to_alternatives "${1}" ) echo "@($extglob)" } # Determines whether the option passed as the first argument exist on # the commandline. The option may be a pattern, e.g. `--force|-f`. -__docker_compose_has_option() { - local pattern="$1" +function __docker_compose_has_option() { + local pattern="${1}" for (( i=2; i < $cword; ++i)); do - if [[ ${words[$i]} =~ ^($pattern)$ ]] ; then + if [[ ${words[$i]} =~ ^($pattern)$ ]] + then return 0 fi done @@ -68,17 +69,20 @@ __docker_compose_has_option() { # Returns `key` if we are currently completing the value of a map option (`key=value`) # which matches the extglob passed in as an argument. # This function is needed for key-specific completions. -__docker_compose_map_key_of_current_option() { - local glob="$1" +function __docker_compose_map_key_of_current_option() { + local glob="${1}" local key glob_pos - if [ "$cur" = "=" ] ; then # key= case + if [ "$cur" = "=" ] + then # key= case key="$prev" glob_pos=$((cword - 2)) - elif [[ $cur == *=* ]] ; then # key=value case (OSX) + elif [[ $cur == *=* ]] + then # key=value case (OSX) key=${cur%=*} glob_pos=$((cword - 1)) - elif [ "$prev" = "=" ] ; then + elif [ "$prev" = "=" ] + then key=${words[$cword - 2]} # key=value case glob_pos=$((cword - 3)) else @@ -91,7 +95,7 @@ __docker_compose_map_key_of_current_option() { } # suppress trailing whitespace -__docker_compose_nospace() { +function __docker_compose_nospace() { # compopt is not available in ancient bash versions type compopt &>/dev/null && compopt -o nospace } @@ -100,25 +104,25 @@ __docker_compose_nospace() { # Outputs a list of all defined services, regardless of their running state. # Arguments for `docker-compose ps` may be passed in order to filter the service list, # e.g. `status=running`. -__docker_compose_services() { +function __docker_compose_services() { __docker_compose_q ps --services "$@" } # Applies completion of services based on the current value of `$cur`. # Arguments for `docker-compose ps` may be passed in order to filter the service list, # see `__docker_compose_services`. -__docker_compose_complete_services() { +function __docker_compose_complete_services() { COMPREPLY=( $(compgen -W "$(__docker_compose_services "$@")" -- "$cur") ) } # The services for which at least one running container exists -__docker_compose_complete_running_services() { +function __docker_compose_complete_running_services() { local names=$(__docker_compose_services --filter status=running) COMPREPLY=( $(compgen -W "$names" -- "$cur") ) } -_docker_compose_build() { +function _docker_compose_build() { case "$prev" in --build-arg) COMPREPLY=( $( compgen -e -- "$cur" ) ) @@ -141,7 +145,7 @@ _docker_compose_build() { } -_docker_compose_bundle() { +function _docker_compose_bundle() { case "$prev" in --output|-o) _filedir @@ -153,10 +157,11 @@ _docker_compose_bundle() { } -_docker_compose_config() { +function _docker_compose_config() { case "$prev" in --hash) - if [[ $cur == \\* ]] ; then + if [[ $cur == \\* ]] + then COMPREPLY=( '\*' ) else COMPREPLY=( $(compgen -W "$(__docker_compose_services) \\\* " -- "$cur") ) @@ -169,7 +174,7 @@ _docker_compose_config() { } -_docker_compose_create() { +function _docker_compose_create() { case "$cur" in -*) COMPREPLY=( $( compgen -W "--build --force-recreate --help --no-build --no-recreate" -- "$cur" ) ) @@ -181,7 +186,7 @@ _docker_compose_create() { } -_docker_compose_docker_compose() { +function _docker_compose_docker_compose() { case "$prev" in --tlscacert|--tlscert|--tlskey) _filedir @@ -215,7 +220,7 @@ _docker_compose_docker_compose() { } -_docker_compose_down() { +function _docker_compose_down() { case "$prev" in --rmi) COMPREPLY=( $( compgen -W "all local" -- "$cur" ) ) @@ -234,7 +239,7 @@ _docker_compose_down() { } -_docker_compose_events() { +function _docker_compose_events() { case "$prev" in --json) return @@ -252,7 +257,7 @@ _docker_compose_events() { } -_docker_compose_exec() { +function _docker_compose_exec() { case "$prev" in --index|--user|-u|--workdir|-w) return @@ -270,11 +275,11 @@ _docker_compose_exec() { } -_docker_compose_help() { +function _docker_compose_help() { COMPREPLY=( $( compgen -W "${commands[*]}" -- "$cur" ) ) } -_docker_compose_images() { +function _docker_compose_images() { case "$cur" in -*) COMPREPLY=( $( compgen -W "--help --quiet -q" -- "$cur" ) ) @@ -285,7 +290,7 @@ _docker_compose_images() { esac } -_docker_compose_kill() { +function _docker_compose_kill() { case "$prev" in -s) COMPREPLY=( $( compgen -W "SIGHUP SIGINT SIGKILL SIGUSR1 SIGUSR2" -- "$(echo $cur | tr '[:lower:]' '[:upper:]')" ) ) @@ -304,7 +309,7 @@ _docker_compose_kill() { } -_docker_compose_logs() { +function _docker_compose_logs() { case "$prev" in --tail) return @@ -322,7 +327,7 @@ _docker_compose_logs() { } -_docker_compose_pause() { +function _docker_compose_pause() { case "$cur" in -*) COMPREPLY=( $( compgen -W "--help" -- "$cur" ) ) @@ -334,7 +339,7 @@ _docker_compose_pause() { } -_docker_compose_port() { +function _docker_compose_port() { case "$prev" in --protocol) COMPREPLY=( $( compgen -W "tcp udp" -- "$cur" ) ) @@ -356,7 +361,7 @@ _docker_compose_port() { } -_docker_compose_ps() { +function _docker_compose_ps() { local key=$(__docker_compose_map_key_of_current_option '--filter') case "$key" in source) @@ -388,7 +393,7 @@ _docker_compose_ps() { } -_docker_compose_pull() { +function _docker_compose_pull() { case "$cur" in -*) COMPREPLY=( $( compgen -W "--help --ignore-pull-failures --include-deps --no-parallel --quiet -q" -- "$cur" ) ) @@ -400,7 +405,7 @@ _docker_compose_pull() { } -_docker_compose_push() { +function _docker_compose_push() { case "$cur" in -*) COMPREPLY=( $( compgen -W "--help --ignore-push-failures" -- "$cur" ) ) @@ -412,7 +417,7 @@ _docker_compose_push() { } -_docker_compose_restart() { +function _docker_compose_restart() { case "$prev" in --timeout|-t) return @@ -430,13 +435,14 @@ _docker_compose_restart() { } -_docker_compose_rm() { +function _docker_compose_rm() { case "$cur" in -*) COMPREPLY=( $( compgen -W "--force -f --help --stop -s -v" -- "$cur" ) ) ;; *) - if __docker_compose_has_option "--stop|-s" ; then + if __docker_compose_has_option "--stop|-s" + then __docker_compose_complete_services else __docker_compose_complete_services --filter status=stopped @@ -446,7 +452,7 @@ _docker_compose_rm() { } -_docker_compose_run() { +function _docker_compose_run() { case "$prev" in -e) COMPREPLY=( $( compgen -e -- "$cur" ) ) @@ -469,7 +475,7 @@ _docker_compose_run() { } -_docker_compose_scale() { +function _docker_compose_scale() { case "$prev" in =) COMPREPLY=("$cur") @@ -492,7 +498,7 @@ _docker_compose_scale() { } -_docker_compose_start() { +function _docker_compose_start() { case "$cur" in -*) COMPREPLY=( $( compgen -W "--help" -- "$cur" ) ) @@ -504,7 +510,7 @@ _docker_compose_start() { } -_docker_compose_stop() { +function _docker_compose_stop() { case "$prev" in --timeout|-t) return @@ -522,7 +528,7 @@ _docker_compose_stop() { } -_docker_compose_top() { +function _docker_compose_top() { case "$cur" in -*) COMPREPLY=( $( compgen -W "--help" -- "$cur" ) ) @@ -534,7 +540,7 @@ _docker_compose_top() { } -_docker_compose_unpause() { +function _docker_compose_unpause() { case "$cur" in -*) COMPREPLY=( $( compgen -W "--help" -- "$cur" ) ) @@ -546,7 +552,7 @@ _docker_compose_unpause() { } -_docker_compose_up() { +function _docker_compose_up() { case "$prev" in =) COMPREPLY=("$cur") @@ -577,7 +583,7 @@ _docker_compose_up() { } -_docker_compose_version() { +function _docker_compose_version() { case "$cur" in -*) COMPREPLY=( $( compgen -W "--short" -- "$cur" ) ) @@ -586,7 +592,7 @@ _docker_compose_version() { } -_docker_compose() { +function _docker_compose() { local previous_extglob_setting=$(shopt -p extglob) shopt -s extglob diff --git a/completion/available/docker.completion.bash b/completion/available/docker.completion.bash index 3f83a874..652a0616 100644 --- a/completion/available/docker.completion.bash +++ b/completion/available/docker.completion.bash @@ -16,7 +16,8 @@ _docker_bash_completion_paths=( ) for fn in "${_docker_bash_completion_paths[@]}"; do - if [ -r "$fn" ]; then + if [ -r "$fn" ] + then # shellcheck disable=SC1090 source "$fn" break diff --git a/completion/available/dotnet.completion.bash b/completion/available/dotnet.completion.bash index 362cfc92..0c6ebbe7 100644 --- a/completion/available/dotnet.completion.bash +++ b/completion/available/dotnet.completion.bash @@ -2,7 +2,13 @@ about-completion "bash parameter completion for the dotnet CLI" # see https://docs.microsoft.com/en-us/dotnet/core/tools/enable-tab-autocomplete#bash -function _dotnet_bash_complete() { +function _dotnet_bash_complete() +{ + ############ STACK_TRACE_BUILDER ##################### + Function_Name="${FUNCNAME[0]}" + Function_PATH="${Function_PATH}/${Function_Name}" + ###################################################### + local cur="${COMP_WORDS[COMP_CWORD]}" IFS=$'\n' local candidates diff --git a/completion/available/fabric.completion.bash b/completion/available/fabric.completion.bash index a8984d9c..0e51f8b6 100644 --- a/completion/available/fabric.completion.bash +++ b/completion/available/fabric.completion.bash @@ -54,7 +54,13 @@ esac # # Get time of last fab cache file modification as seconds since Epoch # -function __fab_chache_mtime() { +function __fab_chache_mtime() +{ + ############ STACK_TRACE_BUILDER ##################### + Function_Name="${FUNCNAME[0]}" + Function_PATH="${Function_PATH}/${Function_Name}" + ###################################################### + ${__FAB_COMPLETION_MTIME_COMMAND} \ $FAB_COMPLETION_CACHED_TASKS_FILENAME | xargs -n 1 expr } @@ -63,9 +69,16 @@ function __fab_chache_mtime() { # # Get time of last fabfile file/module modification as seconds since Epoch # -function __fab_fabfile_mtime() { +function __fab_fabfile_mtime() +{ + ############ STACK_TRACE_BUILDER ##################### + Function_Name="${FUNCNAME[0]}" + Function_PATH="${Function_PATH}/${Function_Name}" + ###################################################### + local f="fabfile" - if [[ -e "$f.py" ]]; then + if [[ -e "$f.py" ]] + then ${__FAB_COMPLETION_MTIME_COMMAND} "$f.py" | xargs -n 1 expr else # Suppose that it's a fabfile dir @@ -78,7 +91,13 @@ function __fab_fabfile_mtime() { # # Completion for "fab" command # -function __fab_completion() { +function __fab_completion() +{ + ############ STACK_TRACE_BUILDER ##################### + Function_Name="${FUNCNAME[0]}" + Function_PATH="${Function_PATH}/${Function_Name}" + ###################################################### + # Return if "fab" command doesn't exists [[ -e `which fab 2> /dev/null` ]] || return 0 @@ -89,7 +108,8 @@ function __fab_completion() { # Generate possible matches and store them in variable "opts" case "${cur}" in -*) - if [[ -z "${__FAB_COMPLETION_LONG_OPT}" ]]; then + if [[ -z "${__FAB_COMPLETION_LONG_OPT}" ]] + then export __FAB_COMPLETION_LONG_OPT=$( fab --help | grep -E -o "\-\-[A-Za-z_\-]+\=?" | sort -u) fi @@ -99,7 +119,8 @@ function __fab_completion() { # Completion for short options is not nessary. # It's left here just for history. # -*) - # if [[ -z "${__FAB_COMPLETION_SHORT_OPT}" ]]; then + # if [[ -z "${__FAB_COMPLETION_SHORT_OPT}" ]] + then # export __FAB_COMPLETION_SHORT_OPT=$( # fab --help | grep -E -o "^ +\-[A-Za-z_\]" | sort -u) # fi @@ -109,12 +130,15 @@ function __fab_completion() { *) # If "fabfile.py" or "fabfile" dir with "__init__.py" file exists local f="fabfile" - if [[ -e "$f.py" || (-d "$f" && -e "$f/__init__.py") ]]; then + if [[ -e "$f.py" || (-d "$f" && -e "$f/__init__.py") ]] + then # Build a list of the available tasks - if $FAB_COMPLETION_CACHE_TASKS; then + if $FAB_COMPLETION_CACHE_TASKS + then # If use cache if [[ ! -s ${FAB_COMPLETION_CACHED_TASKS_FILENAME} || - $(__fab_fabfile_mtime) -gt $(__fab_chache_mtime) ]]; then + $(__fab_fabfile_mtime) -gt $(__fab_chache_mtime) ]] + then fab --shortlist > ${FAB_COMPLETION_CACHED_TASKS_FILENAME} \ 2> /dev/null fi diff --git a/completion/available/flutter.completion.bash b/completion/available/flutter.completion.bash index 7dde5a07..3f08bd18 100644 --- a/completion/available/flutter.completion.bash +++ b/completion/available/flutter.completion.bash @@ -1,5 +1,6 @@ # shellcheck shell=bash -if _command_exists flutter; then +if _command_exists flutter + then eval "$(flutter bash-completion)" fi diff --git a/completion/available/gcloud.completion.bash b/completion/available/gcloud.completion.bash index 63073e8e..14cd6c55 100644 --- a/completion/available/gcloud.completion.bash +++ b/completion/available/gcloud.completion.bash @@ -2,7 +2,8 @@ cite "about-completion" about-completion "Google Cloud SDK completion" -if _command_exists gcloud; then +if _command_exists gcloud + then # get install path GOOGLE_SDK_ROOT=${GOOGLE_SDK_ROOT:-$(gcloud info --format="value(installation.sdk_root)")} diff --git a/completion/available/gem.completion.bash b/completion/available/gem.completion.bash index ab07a133..6dae0b60 100644 --- a/completion/available/gem.completion.bash +++ b/completion/available/gem.completion.bash @@ -8,7 +8,8 @@ __gem_completion() { case $prev in install) # list the remote gems and add to completion - if [ -z "$REMOTE_GEMS" ]; then + if [ -z "$REMOTE_GEMS" ] + then read -r -a REMOTE_GEMS <<< "$(gem list --remote --no-versions | sed 's/\*\*\* REMOTE GEMS \*\*\*//' | tr '\n' ' ')" fi diff --git a/completion/available/git.completion.bash b/completion/available/git.completion.bash index 31b77fa3..f011a21f 100644 --- a/completion/available/git.completion.bash +++ b/completion/available/git.completion.bash @@ -6,13 +6,15 @@ _command_exists git || return # Don't handle completion if it's already managed -if complete -p git &> /dev/null; then +if complete -p git &> /dev/null + then _log_warning "completion already loaded - this usually means it is safe to stop using this completion" return 0 fi _git_bash_completion_xcrun_git= -if _command_exists xcrun; then +if _command_exists xcrun + then _git_bash_completion_xcrun_git="$(xcrun --find git)" fi _git_bash_completion_paths=( @@ -27,7 +29,8 @@ _git_bash_completion_paths=( # Load the first completion file found _git_bash_completion_found=false for _comp_path in "${_git_bash_completion_paths[@]}"; do - if [[ -r "$_comp_path" ]]; then + if [[ -r "$_comp_path" ]] + then _git_bash_completion_found=true # shellcheck disable=SC1090 # don't follow source "$_comp_path" @@ -36,7 +39,8 @@ for _comp_path in "${_git_bash_completion_paths[@]}"; do done # Cleanup -if [[ "${_git_bash_completion_found}" == false ]]; then +if [[ "${_git_bash_completion_found}" == false ]] + then _log_warning "no completion files found - please try enabling the 'system' completion instead." fi unset "${!_git_bash_completion@}" diff --git a/completion/available/git_flow.completion.bash b/completion/available/git_flow.completion.bash index 7bfc9ef4..55c9519c 100644 --- a/completion/available/git_flow.completion.bash +++ b/completion/available/git_flow.completion.bash @@ -45,11 +45,12 @@ # # Distributed under the [MIT License](http://creativecommons.org/licenses/MIT/) -_git_flow () +function _git_flow () { local subcommands="init feature release hotfix" local subcommand="$(__git_find_subcommand "$subcommands")" - if [ -z "$subcommand" ]; then + if [ -z "$subcommand" ] + then __gitcomp "$subcommands" return fi @@ -73,11 +74,12 @@ _git_flow () esac } -__git_flow_feature () +function __git_flow_feature () { local subcommands="list start finish publish track diff rebase checkout pull" local subcommand="$(__git_find_subcommand "$subcommands")" - if [ -z "$subcommand" ]; then + if [ -z "$subcommand" ] + then __gitcomp "$subcommands" return fi @@ -105,26 +107,27 @@ __git_flow_feature () esac } -__git_flow_list_features () +function __git_flow_list_features () { git flow feature list 2> /dev/null | tr -d ' |*' } -__git_flow_list_remote_features () +function __git_flow_list_remote_features () { git branch -r 2> /dev/null | grep "origin/$(__git_flow_feature_prefix)" | awk '{ sub(/^origin\/$(__git_flow_feature_prefix)/, "", $1); print }' } -__git_flow_feature_prefix () +function __git_flow_feature_prefix () { git config gitflow.prefix.feature 2> /dev/null || echo "feature/" } -__git_flow_release () +function __git_flow_release () { local subcommands="list start finish" local subcommand="$(__git_find_subcommand "$subcommands")" - if [ -z "$subcommand" ]; then + if [ -z "$subcommand" ] + then __gitcomp "$subcommands" return fi @@ -141,16 +144,17 @@ __git_flow_release () } -__git_flow_list_releases () +function __git_flow_list_releases () { git flow release list 2> /dev/null } -__git_flow_hotfix () +function __git_flow_hotfix () { local subcommands="list start finish" local subcommand="$(__git_find_subcommand "$subcommands")" - if [ -z "$subcommand" ]; then + if [ -z "$subcommand" ] + then __gitcomp "$subcommands" return fi @@ -166,7 +170,7 @@ __git_flow_hotfix () esac } -__git_flow_list_hotfixes () +function __git_flow_list_hotfixes () { git flow hotfix list 2> /dev/null } diff --git a/completion/available/git_flow_avh.completion.bash b/completion/available/git_flow_avh.completion.bash index abb51bf8..d62be1e3 100644 --- a/completion/available/git_flow_avh.completion.bash +++ b/completion/available/git_flow_avh.completion.bash @@ -53,11 +53,12 @@ __git_flow_config_file_options=" --local --global --system --file= " -_git_flow () +function _git_flow () { local subcommands="init feature release hotfix support help version config finish delete publish rebase" local subcommand="$(__git_find_on_cmdline "$subcommands")" - if [ -z "$subcommand" ]; then + if [ -z "$subcommand" ] + then __gitcomp "$subcommands" return fi @@ -93,11 +94,12 @@ _git_flow () esac } -__git_flow_init () +function __git_flow_init () { local subcommands="help" local subcommand="$(__git_find_on_cmdline "$subcommands")" - if [ -z "$subcommand" ]; then + if [ -z "$subcommand" ] + then __gitcomp "$subcommands" fi @@ -113,12 +115,13 @@ __git_flow_init () esac } -__git_flow_feature () +function __git_flow_feature () { local subcommands="list start finish publish track diff rebase checkout pull help delete" local subcommand="$(__git_find_on_cmdline "$subcommands")" - if [ -z "$subcommand" ]; then + if [ -z "$subcommand" ] + then __gitcomp "$subcommands" return fi @@ -196,11 +199,12 @@ __git_flow_feature () esac } -__git_flow_release () +function __git_flow_release () { local subcommands="list start finish track publish help delete" local subcommand="$(__git_find_on_cmdline "$subcommands")" - if [ -z "$subcommand" ]; then + if [ -z "$subcommand" ] + then __gitcomp "$subcommands" return fi @@ -282,11 +286,12 @@ __git_flow_release () } -__git_flow_hotfix () +function __git_flow_hotfix () { local subcommands="list start finish track publish help delete" local subcommand="$(__git_find_on_cmdline "$subcommands")" - if [ -z "$subcommand" ]; then + if [ -z "$subcommand" ] + then __gitcomp "$subcommands" return fi @@ -366,11 +371,12 @@ __git_flow_hotfix () esac } -__git_flow_support () +function __git_flow_support () { local subcommands="list start help" local subcommand="$(__git_find_on_cmdline "$subcommands")" - if [ -z "$subcommand" ]; then + if [ -z "$subcommand" ] + then __gitcomp "$subcommands" return fi @@ -406,11 +412,12 @@ __git_flow_support () esac } -__git_flow_config () +function __git_flow_config () { local subcommands="list set base" local subcommand="$(__git_find_on_cmdline "$subcommands")" - if [ -z "$subcommand" ]; then + if [ -z "$subcommand" ] + then __gitcomp "$subcommands" return fi @@ -450,9 +457,9 @@ __git_flow_config () esac } -__git_flow_prefix () +function __git_flow_prefix () { - case "$1" in + case "${1}" in feature|release|hotfix|support) git config "gitflow.prefix.$1" 2> /dev/null || echo "$1/" return @@ -460,9 +467,10 @@ __git_flow_prefix () esac } -__git_flow_list_local_branches () +function __git_flow_list_local_branches () { - if [ -n "$1" ]; then + if [ -n "${1}" ] + then local prefix="$(__git_flow_prefix $1)" git for-each-ref --shell --format="ref=%(refname:short)" refs/heads/$prefix | \ while read -r entry; do @@ -476,7 +484,7 @@ __git_flow_list_local_branches () fi } -__git_flow_list_remote_branches () +function __git_flow_list_remote_branches () { local prefix="$(__git_flow_prefix $1)" local origin="$(git config gitflow.origin 2> /dev/null || echo "origin")" @@ -488,10 +496,11 @@ __git_flow_list_remote_branches () done | sort } -__git_flow_list_branches () +function __git_flow_list_branches () { local origin="$(git config gitflow.origin 2> /dev/null || echo "origin")" - if [ -n "$1" ]; then + if [ -n "${1}" ] + then local prefix="$(__git_flow_prefix $1)" git for-each-ref --shell --format="ref=%(refname:short)" refs/heads/$prefix refs/remotes/$origin/$prefix | \ while read -r entry; do diff --git a/completion/available/github-cli.completion.bash b/completion/available/github-cli.completion.bash index 4a611394..5d1db94c 100644 --- a/completion/available/github-cli.completion.bash +++ b/completion/available/github-cli.completion.bash @@ -2,7 +2,8 @@ cite "about-completion" about-completion "GitHub CLI completion" -if _binary_exists gh; then +if _binary_exists gh + then # If gh already completed, stop _completion_exists gh && return eval "$(gh completion --shell=bash)" diff --git a/completion/available/go.completion.bash b/completion/available/go.completion.bash index 9f77a135..c2e9d6ec 100644 --- a/completion/available/go.completion.bash +++ b/completion/available/go.completion.bash @@ -6,9 +6,11 @@ about-completion "completion for go command using gocomplete" # Test `go version` because goenv creates shim scripts that will be found in PATH # but do not always resolve to a working install. -if _command_exists go && go version &> /dev/null; then +if _command_exists go && go version &> /dev/null + then # Same idea here, but no need to test a subcommand - if _command_exists gocomplete && gocomplete &> /dev/null; then + if _command_exists gocomplete && gocomplete &> /dev/null + then # finally, apply completion complete -C gocomplete go fi diff --git a/completion/available/gradle.completion.bash b/completion/available/gradle.completion.bash index ef9677c6..b4d6bf10 100644 --- a/completion/available/gradle.completion.bash +++ b/completion/available/gradle.completion.bash @@ -24,56 +24,102 @@ # Avoid inaccurate completions for subproject tasks COMP_WORDBREAKS=$(echo "$COMP_WORDBREAKS" | sed -e 's/://g') -function __gradle-set-project-root-dir() { +function __gradle-set-project-root-dir() +{ + ############ STACK_TRACE_BUILDER ##################### + Function_Name="${FUNCNAME[0]}" + Function_PATH="${Function_PATH}/${Function_Name}" + ###################################################### + project_root_dir="$(_bash-it-find-in-ancestor "settings.gradle" "gradlew")" - return "$?" + return "${?}" } -__gradle-init-cache-dir() { +function __gradle-init-cache-dir() +{ + ############ STACK_TRACE_BUILDER ##################### + Function_Name="${FUNCNAME[0]}" + Function_PATH="${Function_PATH}/${Function_Name}" + ###################################################### + cache_dir="$HOME/.gradle/completion" - mkdir -p $cache_dir + mkdir -p ${cache_dir} } -__gradle-set-build-file() { +function __gradle-set-build-file() +{ + ############ STACK_TRACE_BUILDER ##################### + Function_Name="${FUNCNAME[0]}" + Function_PATH="${Function_PATH}/${Function_Name}" + ###################################################### + # Look for default build script in the settings file (settings.gradle by default) # Otherwise, default is the file 'build.gradle' in the current directory. gradle_build_file="$project_root_dir/build.gradle" - if [[ -f "$project_root_dir/settings.gradle" ]]; then + if [[ -f "$project_root_dir/settings.gradle" ]] + then local build_file_name=$(grep "^rootProject\.buildFileName" "$project_root_dir/settings.gradle" | \ sed -n -e "s/rootProject\.buildFileName = [\'\"]\(.*\)[\'\"]/\1/p") gradle_build_file="$project_root_dir/${build_file_name:-build.gradle}" fi } -__gradle-set-cache-name() { +function __gradle-set-cache-name() +{ + ############ STACK_TRACE_BUILDER ##################### + Function_Name="${FUNCNAME[0]}" + Function_PATH="${Function_PATH}/${Function_Name}" + ###################################################### + # Cache name is constructed from the absolute path of the build file. cache_name=$(echo $gradle_build_file | sed -e 's/\//_/g') } -__gradle-set-files-checksum() { +function __gradle-set-files-checksum() +{ + ############ STACK_TRACE_BUILDER ##################### + Function_Name="${FUNCNAME[0]}" + Function_PATH="${Function_PATH}/${Function_Name}" + ###################################################### + # Cache MD5 sum of all Gradle scripts and modified timestamps - if _command_exists md5; then + if _command_exists md5 + then gradle_files_checksum=$(md5 -q -s "$(cat "$cache_dir/$cache_name" | xargs ls -o 2>/dev/null)") - elif _command_exists md5sum; then + elif _command_exists md5sum + then gradle_files_checksum=$(cat "$cache_dir/$cache_name" | xargs ls -o 2>/dev/null | md5sum | awk '{print $1}') else echo "Cannot generate completions as neither md5 nor md5sum exist on \$PATH" fi } -__gradle-generate-script-cache() { +function __gradle-generate-script-cache() +{ + ############ STACK_TRACE_BUILDER ##################### + Function_Name="${FUNCNAME[0]}" + Function_PATH="${Function_PATH}/${Function_Name}" + ###################################################### + # Invalidate cache after 3 weeks by default local cache_ttl_mins=${GRADLE_CACHE_TTL_MINUTES:-30240} local script_exclude_pattern=${GRADLE_COMPLETION_EXCLUDE_PATTERN:-"/(build|integTest|out)/"} - 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 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 } -__gradle-long-options() { +function __gradle-long-options() +{ + ############ STACK_TRACE_BUILDER ##################### + Function_Name="${FUNCNAME[0]}" + Function_PATH="${Function_PATH}/${Function_Name}" + ###################################################### + local args="--build-cache - Enables the Gradle build cache --build-file - Specifies the build file --configure-on-demand - Only relevant projects are configured @@ -118,7 +164,12 @@ __gradle-long-options() { COMPREPLY=( $(compgen -W "$args" -- "${COMP_WORDS[COMP_CWORD]}") ) } -__gradle-properties() { +function __gradle-properties() +{ + ############ STACK_TRACE_BUILDER ##################### + Function_Name="${FUNCNAME[0]}" + Function_PATH="${Function_PATH}/${Function_Name}" + ###################################################### local args="-Dorg.gradle.cache.reserved.mb= - Reserve Gradle Daemon memory for operations -Dorg.gradle.caching= - Set true to enable Gradle build cache -Dorg.gradle.daemon.debug= - Set true to debug Gradle Daemon @@ -134,7 +185,12 @@ __gradle-properties() { return 0 } -__gradle-short-options() { +function __gradle-short-options() +{ + ############ STACK_TRACE_BUILDER ##################### + Function_Name="${FUNCNAME[0]}" + Function_PATH="${Function_PATH}/${Function_Name}" + ###################################################### local args="-? - Shows a help message -a - Do not rebuild project dependencies -b - Specifies the build file @@ -159,7 +215,12 @@ __gradle-short-options() { COMPREPLY=( $(compgen -W "$args" -- "${COMP_WORDS[COMP_CWORD]}") ) } -__gradle-notify-tasks-cache-build() { +function __gradle-notify-tasks-cache-build() +{ + ############ STACK_TRACE_BUILDER ##################### + Function_Name="${FUNCNAME[0]}" + Function_PATH="${Function_PATH}/${Function_Name}" + ###################################################### # Notify user of cache rebuild echo -e " (Building completion cache. Please wait)\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\c" __gradle-generate-tasks-cache @@ -167,22 +228,29 @@ __gradle-notify-tasks-cache-build() { echo -e " \b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\c" } -__gradle-generate-tasks-cache() { +function __gradle-generate-tasks-cache() +{ + ############ STACK_TRACE_BUILDER ##################### + Function_Name="${FUNCNAME[0]}" + Function_PATH="${Function_PATH}/${Function_Name}" + ###################################################### __gradle-set-files-checksum # Use Gradle wrapper when it exists. local gradle_cmd="gradle" - if [[ -x "$project_root_dir/gradlew" ]]; then - gradle_cmd="$project_root_dir/gradlew" + if [[ -x "${project_root_dir}/gradlew" ]] + then + gradle_cmd="${project_root_dir}/gradlew" fi # Run gradle to retrieve possible tasks and cache. # Reuse Gradle Daemon if IDLE but don't start a new one. local gradle_tasks_output - if [[ ! -z "$($gradle_cmd --status 2>/dev/null | grep IDLE)" ]]; then - gradle_tasks_output="$($gradle_cmd -b $gradle_build_file --daemon -q tasks --all)" + if [[ ! -z "$($gradle_cmd --status 2>/dev/null | grep IDLE)" ]] + then + gradle_tasks_output="$(${gradle_cmd} -b ${gradle_build_file} --daemon -q tasks --all)" else - gradle_tasks_output="$($gradle_cmd -b $gradle_build_file --no-daemon -q tasks --all)" + gradle_tasks_output="$(${gradle_cmd} -b ${gradle_build_file} --no-daemon -q tasks --all)" fi local output_line local task_description @@ -190,12 +258,14 @@ __gradle-generate-tasks-cache() { local -a root_tasks=() local -a subproject_tasks=() for output_line in $gradle_tasks_output; do - if [[ $output_line =~ ^([[:lower:]][[:alnum:][:punct:]]*)([[:space:]]-[[:space:]]([[:print:]]*))? ]]; then + if [[ $output_line =~ ^([[:lower:]][[:alnum:][:punct:]]*)([[:space:]]-[[:space:]]([[:print:]]*))? ]] + then task_name="${BASH_REMATCH[1]}" task_description="${BASH_REMATCH[3]}" gradle_all_tasks+=( "$task_name - $task_description" ) # Completion for subproject tasks with ':' prefix - if [[ $task_name =~ ^([[:alnum:][:punct:]]+):([[:alnum:]]+) ]]; then + if [[ $task_name =~ ^([[:alnum:][:punct:]]+):([[:alnum:]]+) ]] + then gradle_all_tasks+=( ":$task_name - $task_description" ) subproject_tasks+=( "${BASH_REMATCH[2]}" ) else @@ -205,28 +275,36 @@ __gradle-generate-tasks-cache() { done # subproject tasks can be referenced implicitly from root project - if [[ $GRADLE_COMPLETION_UNQUALIFIED_TASKS == "true" ]]; then + if [[ $GRADLE_COMPLETION_UNQUALIFIED_TASKS == "true" ]] + then local -a implicit_tasks=() implicit_tasks=( $(comm -23 <(printf "%s\n" "${subproject_tasks[@]}" | sort) <(printf "%s\n" "${root_tasks[@]}" | sort)) ) - for task in $(printf "%s\n" "${implicit_tasks[@]}"); do + for task in $(printf "%s\n" "${implicit_tasks[@]}") + do gradle_all_tasks+=( $task ) done fi - printf "%s\n" "${gradle_all_tasks[@]}" > $cache_dir/$gradle_files_checksum - echo $gradle_files_checksum > $cache_dir/$cache_name.md5 + printf "%s\n" "${gradle_all_tasks[@]}" > ${cache_dir}/${gradle_files_checksum} + echo ${gradle_files_checksum} > ${cache_dir}/${cache_name}.md5 } -__gradle-completion-init() { +function __gradle-completion-init() +{ + ############ STACK_TRACE_BUILDER ##################### + Function_Name="${FUNCNAME[0]}" + Function_PATH="${Function_PATH}/${Function_Name}" + ###################################################### local cache_dir cache_name gradle_build_file gradle_files_checksum project_root_dir - local OLDIFS="$IFS" + local OLDIFS="${IFS}" local IFS=$'\n' __gradle-init-cache-dir __gradle-set-project-root-dir __gradle-set-build-file - if [[ -f $gradle_build_file ]]; then + if [[ -f ${gradle_build_file} ]] + then __gradle-set-cache-name __gradle-generate-script-cache __gradle-set-files-checksum @@ -238,45 +316,57 @@ __gradle-completion-init() { return 0 } -_gradle() { +function _gradle() +{ + ############ STACK_TRACE_BUILDER ##################### + Function_Name="${FUNCNAME[0]}" + Function_PATH="${Function_PATH}/${Function_Name}" + ###################################################### local cache_dir cache_name gradle_build_file gradle_files_checksum project_root_dir - local cur=${COMP_WORDS[COMP_CWORD]} + local cur="${COMP_WORDS[COMP_CWORD]}" # Set bash internal field separator to '\n' # This allows us to provide descriptions for options and tasks - local OLDIFS="$IFS" + local OLDIFS="${IFS}" local IFS=$'\n' - if [[ ${cur} == --* ]]; then + if [[ ${cur} == --* ]] + then __gradle-long-options - elif [[ ${cur} == -D* ]]; then + elif [[ ${cur} == -D* ]] + then __gradle-properties - elif [[ ${cur} == -* ]]; then + elif [[ ${cur} == -* ]] + then __gradle-short-options else __gradle-init-cache-dir __gradle-set-project-root-dir __gradle-set-build-file - if [[ -f $gradle_build_file ]]; then + if [[ -f ${gradle_build_file} ]] + then __gradle-set-cache-name __gradle-generate-script-cache __gradle-set-files-checksum # The cache key is md5 sum of all gradle scripts, so it's valid if it exists. - if [[ -f $cache_dir/$cache_name.md5 ]]; then - local cached_checksum="$(cat $cache_dir/$cache_name.md5)" + if [[ -f ${cache_dir}/${cache_name}.md5 ]] + then + local cached_checksum="$(cat ${cache_dir}/${cache_name}.md5)" local -a cached_tasks - if [[ -z $cur ]]; then - cached_tasks=( $(cat $cache_dir/$cached_checksum) ) + if [[ -z ${cur} ]] + then + cached_tasks=( $(cat ${cache_dir}/${cached_checksum}) ) else - cached_tasks=( $(grep "^$cur" $cache_dir/$cached_checksum) ) + cached_tasks=( $(grep "^${cur}" ${cache_dir}/${cached_checksum}) ) fi - COMPREPLY=( $(compgen -W "${cached_tasks[*]}" -- "$cur") ) + COMPREPLY=( $(compgen -W "${cached_tasks[*]}" -- "${cur}") ) else __gradle-notify-tasks-cache-build fi # Regenerate tasks cache in the background - if [[ $gradle_files_checksum != "$(cat $cache_dir/$cache_name.md5)" || ! -f $cache_dir/$gradle_files_checksum ]]; then + if [[ ${gradle_files_checksum} != "$(cat ${cache_dir}/$cache_name.md5)" || ! -f ${cache_dir}/${gradle_files_checksum} ]] + then $(__gradle-generate-tasks-cache 1>&2 2>/dev/null &) fi else @@ -300,12 +390,14 @@ wrapper - Generates Gradle wrapper files." IFS="$OLDIFS" # Remove description ("[:space:]" and after) if only one possibility - if [[ ${#COMPREPLY[*]} -eq 1 ]]; then + if [[ ${#COMPREPLY[*]} -eq 1 ]] + then COMPREPLY=( ${COMPREPLY[0]%% *} ) fi return 0 } + complete -F _gradle gradle complete -F _gradle gradle.bat complete -F _gradle gradlew @@ -313,6 +405,7 @@ complete -F _gradle gradlew.bat complete -F _gradle ./gradlew complete -F _gradle ./gradlew.bat -if hash gw 2>/dev/null || alias gw >/dev/null 2>&1; then +if hash gw 2>/dev/null || alias gw >/dev/null 2>&1 + then complete -F _gradle gw fi diff --git a/completion/available/grunt.completion.bash b/completion/available/grunt.completion.bash index e655c4ee..63184922 100644 --- a/completion/available/grunt.completion.bash +++ b/completion/available/grunt.completion.bash @@ -45,7 +45,8 @@ function _grunt_gruntfile() { local curpath="$PWD" while [[ "$curpath" ]]; do for gruntfile in "$curpath/"{G,g}runtfile.{js,coffee}; do - if [[ -e "$gruntfile" ]]; then + if [[ -e "$gruntfile" ]] + then echo "$gruntfile" return fi diff --git a/completion/available/helm.completion.bash b/completion/available/helm.completion.bash index 0dae7af4..83a1a0fd 100644 --- a/completion/available/helm.completion.bash +++ b/completion/available/helm.completion.bash @@ -2,6 +2,7 @@ cite "about-completion" about-completion "helm (Kubernetes Package Manager) completion" -if _command_exists helm; then +if _command_exists helm + then eval "$(helm completion bash)" fi diff --git a/completion/available/hub.completion.bash b/completion/available/hub.completion.bash index 67a5e29b..4aecb271 100644 --- a/completion/available/hub.completion.bash +++ b/completion/available/hub.completion.bash @@ -23,12 +23,14 @@ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # If there is no git tab completion, but we have the _completion loader try to load it -if ! _is_function _git && _is_function _completion_loader; then +if ! _is_function _git && _is_function _completion_loader + then _completion_loader git fi # Check that git tab completion is available and we haven't already set up completion -if _is_function _git && ! _is_function __git_list_all_commands_without_hub; then +if _is_function _git && ! _is_function __git_list_all_commands_without_hub + then # Duplicate and rename the 'list_all_commands' function eval "$(declare -f __git_list_all_commands | \ sed 's/__git_list_all_commands/__git_list_all_commands_without_hub/')" @@ -60,17 +62,25 @@ EOF ########################## # hub alias [-s] [SHELL] - _git_alias() { + function _git_alias() + { + ############ STACK_TRACE_BUILDER ##################### + Function_Name="${FUNCNAME[0]}" + Function_PATH="${Function_PATH}/${Function_Name}" + ###################################################### local i c=2 s=-s sh shells="bash zsh sh ksh csh fish" - while [ $c -lt $cword ]; do + while [ $c -lt $cword ] + do i="${words[c]}" case "$i" in -s) unset s ;; *) - for sh in $shells; do - if [ "$sh" = "$i" ]; then + for sh in ${shells} + do + if [ "$sh" = "$i" ] + then unset shells break fi @@ -79,35 +89,44 @@ EOF esac ((c++)) done - __gitcomp "$s $shells" + __gitcomp "$s ${shells}" } # hub browse [-u] [--|[USER/]REPOSITORY] [SUBPAGE] - _git_browse() { + function _git_browse() + { + ############ STACK_TRACE_BUILDER ##################### + Function_Name="${FUNCNAME[0]}" + Function_PATH="${Function_PATH}/${Function_Name}" + ###################################################### local i c=2 u=-u repo subpage local subpages_="commits issues tree wiki pulls branches stargazers contributors network network/ graphs graphs/" local subpages_network="members" local subpages_graphs="commit-activity code-frequency punch-card" - while [ $c -lt $cword ]; do + while [ $c -lt $cword ] + do i="${words[c]}" case "$i" in -u) unset u ;; *) - if [ -z "$repo" ]; then - repo=$i + if [ -z "${repo}" ] + then + repo=${i} else - subpage=$i + subpage=${i} fi ;; esac ((c++)) done - if [ -z "$repo" ]; then + if [ -z "${repo}" ] + then __gitcomp "$u -- $(__hub_github_repos '\p')" - elif [ -z "$subpage" ]; then + elif [ -z "${subpage}" ] + then case "$cur" in */*) local pfx="${cur%/*}" cur_="${cur#*/}" @@ -124,29 +143,38 @@ EOF } # hub compare [-u] [USER[/REPOSITORY]] [[START...]END] - _git_compare() { + function _git_compare() + { + ############ STACK_TRACE_BUILDER ##################### + Function_Name="${FUNCNAME[0]}" + Function_PATH="${Function_PATH}/${Function_Name}" + ###################################################### local i c=$((cword - 1)) u=-u user remote owner repo arg_repo rev - while [ $c -gt 1 ]; do + while [ $c -gt 1 ] + do i="${words[c]}" case "$i" in -u) unset u ;; *) - if [ -z "$rev" ]; then + if [ -z "$rev" ] + then # Even though the logic below is able to complete both user/repo # and revision in the right place, when there is only one argument # (other than -u) in the command, that argument will be taken as # revision. For example: # $ hub compare -u upstream # > https://github.com/USER/REPO/compare/upstream - if __hub_github_repos '\p' | grep -Eqx "^$i(/[^/]+)?"; then - arg_repo=$i + if __hub_github_repos '\p' | grep -Eqx "^$i(/[^/]+)?" + then + arg_repo=${i} else rev=$i fi - elif [ -z "$arg_repo" ]; then - arg_repo=$i + elif [ -z "${arg_repo}" ] + then + arg_repo=${i} fi ;; esac @@ -155,28 +183,35 @@ EOF # Here we want to find out the git remote name of user/repo, in order to # generate an appropriate revision list - if [ -z "$arg_repo" ]; then + if [ -z "$arg_repo" ] + then user=$(__hub_github_user) - if [ -z "$user" ]; then - for i in $(__hub_github_repos); do + if [ -z "$user" ] + then + for i in $(__hub_github_repos) + do remote=${i%%:*} repo=${i#*:} - if [ "$remote" = origin ]; then + if [ "$remote" = origin ] + then break fi done else - for i in $(__hub_github_repos); do + for i in $(__hub_github_repos) + do remote=${i%%:*} repo=${i#*:} owner=${repo%%/*} - if [ "$user" = "$owner" ]; then + if [ "$user" = "$owner" ] + then break fi done fi else - for i in $(__hub_github_repos); do + for i in $(__hub_github_repos) + do remote=${i%%:*} repo=${i#*:} owner=${repo%%/*} @@ -188,18 +223,20 @@ EOF done fi - local pfx cur_="$cur" - case "$cur_" in + local pfx cur_="${cur}" + case "${cur_}" in *..*) pfx="${cur_%%..*}..." cur_="${cur_##*..}" - __gitcomp_nl "$(__hub_revlist $remote)" "$pfx" "$cur_" + __gitcomp_nl "$(__hub_revlist ${remote})" "${pfx}" "${cur_}" ;; *) - if [ -z "${arg_repo}${rev}" ]; then - __gitcomp "$u $(__hub_github_repos '\o\n\p') $(__hub_revlist $remote)" - elif [ -z "$rev" ]; then - __gitcomp "$u $(__hub_revlist $remote)" + if [ -z "${arg_repo}${rev}" ] + then + __gitcomp "$u $(__hub_github_repos '\o\n\p') $(__hub_revlist ${remote})" + elif [ -z "$rev" ] + then + __gitcomp "$u $(__hub_revlist ${remote})" else __gitcomp "$u" fi @@ -208,9 +245,15 @@ EOF } # hub create [NAME] [-p] [-d DESCRIPTION] [-h HOMEPAGE] - _git_create() { + function _git_create() + { + ############ STACK_TRACE_BUILDER ##################### + Function_Name="${FUNCNAME[0]}" + Function_PATH="${Function_PATH}/${Function_Name}" + ###################################################### local i c=2 name repo flags="-p -d -h" - while [ $c -lt $cword ]; do + while [ $c -lt $cword ] + do i="${words[c]}" case "$i" in -d|-h) @@ -226,7 +269,8 @@ EOF esac ((c++)) done - if [ -z "$name" ]; then + if [ -z "$name" ] + then repo="$(basename "${PWD}")" fi case "$prev" in @@ -234,15 +278,21 @@ EOF COMPREPLY=() ;; -p|*) - __gitcomp "$repo $flags" + __gitcomp "${repo} ${flags}" ;; esac } # hub fork [--no-remote] [--remote-name REMOTE] [--org ORGANIZATION] - _git_fork() { + function _git_fork() + { + ############ STACK_TRACE_BUILDER ##################### + Function_Name="${FUNCNAME[0]}" + Function_PATH="${Function_PATH}/${Function_Name}" + ###################################################### local i c=2 flags="--no-remote --remote-name --org" - while [ $c -lt $cword ]; do + while [ $c -lt ${cword} ] + do i="${words[c]}" case "$i" in --org) @@ -261,20 +311,26 @@ EOF esac ((c++)) done - case "$prev" in + case "${prev}" in --remote-name|--org) COMPREPLY=() ;; *) - __gitcomp "$flags" + __gitcomp "${flags}" ;; esac } # hub pull-request [-f] [-m |-F |-i |] [-b ] [-h ] [-a ] [-M ] [-l ] - _git_pull_request() { + fucntion _git_pull_request() + { + ############ STACK_TRACE_BUILDER ##################### + Function_Name="${FUNCNAME[0]}" + Function_PATH="${Function_PATH}/${Function_Name}" + ###################################################### local i c=2 flags="-f -m -F -i -b -h -a -M -l" - while [ $c -lt $cword ]; do + while [ $c -lt ${cword} ] + do i="${words[c]}" case "$i" in -m|-F|-i|-b|-h|-a|-M|-l) @@ -299,10 +355,10 @@ EOF # __ltrim_colon_completions "$cur" ;; -F) - COMPREPLY=( "$cur"* ) + COMPREPLY=( "${cur}"* ) ;; -f|*) - __gitcomp "$flags" + __gitcomp "${flags}" ;; esac } @@ -314,21 +370,32 @@ EOF # __hub_github_user [HOST] # Return $GITHUB_USER or the default github user defined in hub config # HOST - Host to be looked-up in hub config. Default is "github.com" - __hub_github_user() { - if [ -n "$GITHUB_USER" ]; then + function __hub_github_user() + { + ############ STACK_TRACE_BUILDER ##################### + Function_Name="${FUNCNAME[0]}" + Function_PATH="${Function_PATH}/${Function_Name}" + ###################################################### + if [ -n "$GITHUB_USER" ] + then echo $GITHUB_USER return fi local line h k v host=${1:-github.com} config=${HUB_CONFIG:-~/.config/hub} - if [ -f "$config" ]; then - while read line; do - if [ "$line" = "---" ]; then + if [ -f "$config" ] + then + while read line + do + if [ "$line" = "---" ] + then continue fi k=${line%%:*} v=${line#*:} - if [ -z "$v" ]; then - if [ "$h" = "$host" ]; then + if [ -z "$v" ] + then + if [ "$h" = "$host" ] + then break fi h=$k @@ -336,11 +403,12 @@ EOF fi k=${k#* } v=${v#* } - if [ "$h" = "$host" ] && [ "$k" = "user" ]; then + if [ "$h" = "$host" ] && [ "$k" = "user" ] + then echo "$v" break fi - done < "$config" + done < "${config}" fi } @@ -352,12 +420,19 @@ EOF # \o owner # escaped characters (\n, \t ...etc) work # If omitted, prints all github repos in the format of "remote:owner/repo" - __hub_github_repos() { + function __hub_github_repos() + { + ############ STACK_TRACE_BUILDER ##################### + Function_Name="${FUNCNAME[0]}" + Function_PATH="${Function_PATH}/${Function_Name}" + ###################################################### local f format=$1 - if [ -z "$(__gitdir)" ]; then + if [ -z "$(__gitdir)" ] + then return fi - if [ -z "$format" ]; then + if [ -z "$format" ] + then format='\1:\2' else format=${format//\m/\1} @@ -371,16 +446,24 @@ EOF # __hub_heads # List all local "branch", and remote "owner/repo:branch" - __hub_heads() { + function __hub_heads() + { + ############ STACK_TRACE_BUILDER ##################### + Function_Name="${FUNCNAME[0]}" + Function_PATH="${Function_PATH}/${Function_Name}" + ###################################################### local i remote repo branch dir=$(__gitdir) - if [ -d "$dir" ]; then + if [ -d "$dir" ] + then command git --git-dir="$dir" for-each-ref --format='%(refname:short)' \ "refs/heads/" - for i in $(__hub_github_repos); do + for i in $(__hub_github_repos) + do remote=${i%%:*} repo=${i#*:} command git --git-dir="$dir" for-each-ref --format='%(refname:short)' \ - "refs/remotes/${remote}/" | while read branch; do + "refs/remotes/${remote}/" | while read branch + do echo "${repo}:${branch#${remote}/}" done done @@ -390,11 +473,18 @@ EOF # __hub_revlist [REMOTE] # List all tags, and branches under REMOTE, without the "remote/" prefix # REMOTE - Remote name to search branches from. Default is "origin" - __hub_revlist() { + function __hub_revlist() + { + ############ STACK_TRACE_BUILDER ##################### + Function_Name="${FUNCNAME[0]}" + Function_PATH="${Function_PATH}/${Function_Name}" + ###################################################### local i remote=${1:-origin} dir=$(__gitdir) - if [ -d "$dir" ]; then + if [ -d "$dir" ] + then command git --git-dir="$dir" for-each-ref --format='%(refname:short)' \ - "refs/remotes/${remote}/" | while read i; do + "refs/remotes/${remote}/" | while read i + do echo "${i#${remote}/}" done command git --git-dir="$dir" for-each-ref --format='%(refname:short)' \ diff --git a/completion/available/invoke.completion.bash b/completion/available/invoke.completion.bash index 708596b4..c8d6ebd7 100644 --- a/completion/available/invoke.completion.bash +++ b/completion/available/invoke.completion.bash @@ -25,7 +25,12 @@ # https://github.com/pyinvoke/invoke/blob/master/completion/bash -_complete_invoke() { +funciton _complete_invoke() +{ + ############ STACK_TRACE_BUILDER ##################### + Function_Name="${FUNCNAME[0]}" + Function_PATH="${Function_PATH}/${Function_Name}" + ###################################################### local candidates # COMP_WORDS contains the entire command string up til now (including diff --git a/completion/available/jungle.completion.bash b/completion/available/jungle.completion.bash index e190d143..13ba1f84 100644 --- a/completion/available/jungle.completion.bash +++ b/completion/available/jungle.completion.bash @@ -2,6 +2,7 @@ cite "about-completion" about-completion "jungle(AWS cli tool) completion" -if _command_exists jungle; then +if _command_exists jungle + then eval "$(_JUNGLE_COMPLETE=source jungle)" fi diff --git a/completion/available/kind.completion.bash b/completion/available/kind.completion.bash index be12a2d2..ee1d548f 100644 --- a/completion/available/kind.completion.bash +++ b/completion/available/kind.completion.bash @@ -1,5 +1,6 @@ #!/usr/bin/env bash -if _command_exists kind; then +if _command_exists kind + then eval "$(kind completion bash)" fi diff --git a/completion/available/knife.completion.bash b/completion/available/knife.completion.bash index c0fb6a99..92ece16d 100644 --- a/completion/available/knife.completion.bash +++ b/completion/available/knife.completion.bash @@ -33,20 +33,27 @@ stat -c %Y /dev/null > /dev/null 2>&1 && _KAC_STAT_COMMAND="stat -c %Y" || _KAC_ # returns 0 iff the file whose path is given as 1st argument # exists and has last been modified in the last $2 seconds # returns 1 otherwise -_KAC_is_file_newer_than() { - [ -f "$1" ] || return 1 - [ $(($(date +%s) - $($_KAC_STAT_COMMAND "$1"))) -gt "$2" ] && return 1 || return 0 +function _KAC_is_file_newer_than() +{ + [ -f "${1}" ] || return 1 + [ $(($(date +%s) - $($_KAC_STAT_COMMAND "${1}"))) -gt "${2}" ] && return 1 || return 0 } # helper function for _KAC_get_and_regen_cache, see doc below -_KAC_regen_cache() { - local CACHE_NAME=$1 - local CACHE_PATH="$_KNIFE_AUTOCOMPLETE_CACHE_DIR/$CACHE_NAME" +function _KAC_regen_cache() +{ + ############ STACK_TRACE_BUILDER ##################### + Function_Name="${FUNCNAME[0]}" + Function_PATH="${Function_PATH}/${Function_Name}" + ###################################################### + local CACHE_NAME="${1}" + local CACHE_PATH="${_KNIFE_AUTOCOMPLETE_CACHE_DIR}/${CACHE_NAME}" # shellcheck disable=SC2155 - local TMP_FILE=$(mktemp "$_KAC_CACHE_TMP_DIR/$CACHE_NAME.XXXX") + local TMP_FILE="$(mktemp "${_KAC_CACHE_TMP_DIR}/${CACHE_NAME}.XXXX")" shift 1 # discard the temp file if it's empty AND the previous command didn't exit successfully, but still mark the cache as updated - if ! "$@" > "$TMP_FILE" 2> /dev/null; then + if ! "$@" > "$TMP_FILE" 2> /dev/null + then [[ $(wc -l "$TMP_FILE") == 0 ]] && rm -f "$TMP_FILE" && touch "$CACHE_PATH" && return 1 else mv -f "$TMP_FILE" "$CACHE_PATH" @@ -54,12 +61,22 @@ _KAC_regen_cache() { } # cached files can't have spaces in their names -_KAC_get_cache_name_from_command() { +function _KAC_get_cache_name_from_command() +{ + ############ STACK_TRACE_BUILDER ##################### + Function_Name="${FUNCNAME[0]}" + Function_PATH="${Function_PATH}/${Function_Name}" + ###################################################### echo "${@// /_SPACE_}" } # the reverse operation from the function above -_KAC_get_command_from_cache_name() { +function _KAC_get_command_from_cache_name() +{ + ############ STACK_TRACE_BUILDER ##################### + Function_Name="${FUNCNAME[0]}" + Function_PATH="${Function_PATH}/${Function_Name}" + ###################################################### echo "${@//_SPACE_/ }" } @@ -68,35 +85,48 @@ _KAC_get_command_from_cache_name() { # in either case, it regenerates the cache, and sets the _KAC_CACHE_PATH env variable # for obvious reason, do NOT call that in a sub-shell (in particular, no piping) # shellcheck disable=SC2155 -_KAC_get_and_regen_cache() { +function _KAC_get_and_regen_cache() +{ + ############ STACK_TRACE_BUILDER ##################### + Function_Name="${FUNCNAME[0]}" + Function_PATH="${Function_PATH}/${Function_Name}" + ###################################################### # the cache name can't have space in it local CACHE_NAME=$(_KAC_get_cache_name_from_command "$@") - local REGEN_CMD="_KAC_regen_cache $CACHE_NAME $*" - _KAC_CACHE_PATH="$_KNIFE_AUTOCOMPLETE_CACHE_DIR/$CACHE_NAME" + local REGEN_CMD="_KAC_regen_cache ${CACHE_NAME} $*" + _KAC_CACHE_PATH="${_KNIFE_AUTOCOMPLETE_CACHE_DIR}/${CACHE_NAME}" # no need to wait for the regen if the file already exists - if [[ -f "$_KAC_CACHE_PATH" ]]; then - ($REGEN_CMD &) + if [[ -f "${_KAC_CACHE_PATH}" ]] + then + (${REGEN_CMD} &) else - $REGEN_CMD + ${REGEN_CMD} fi } # performs two things: first, deletes all obsolete temp files # then refreshes stale caches that haven't been called in a long time -_KAC_clean_cache() { +function _KAC_clean_cache() +{ + ############ STACK_TRACE_BUILDER ##################### + Function_Name="${FUNCNAME[0]}" + Function_PATH="${Function_PATH}/${Function_Name}" + ###################################################### local FILE CMD # delete all obsolete temp files, could be lingering there for any kind of crash in the caching process - for FILE in "$_KAC_CACHE_TMP_DIR"/*; do - _KAC_is_file_newer_than "$FILE" "$_KNIFE_AUTOCOMPLETE_MAX_CACHE_AGE" || rm -f "$FILE" + for FILE in "$_KAC_CACHE_TMP_DIR"/* + do + _KAC_is_file_newer_than "${FILE}" "${_KNIFE_AUTOCOMPLETE_MAX_CACHE_AGE}" || rm -f "${FILE}" done # refresh really stale caches - find "$_KNIFE_AUTOCOMPLETE_CACHE_DIR" -maxdepth 1 -type f -not -name '.*' \ - | while read -r FILE; do - _KAC_is_file_newer_than "$FILE" "$_KNIFE_AUTOCOMPLETE_MAX_CACHE_AGE" && continue + find "${_KNIFE_AUTOCOMPLETE_CACHE_DIR}" -maxdepth 1 -type f -not -name '.*' \ + | while read -r FILE + do + _KAC_is_file_newer_than "${FILE}" "${_KNIFE_AUTOCOMPLETE_MAX_CACHE_AGE}" && continue # first let's get the original command CMD=$(_KAC_get_command_from_cache_name "$(basename "$FILE")") # then regen the cache - _KAC_get_and_regen_cache "$CMD" > /dev/null + _KAC_get_and_regen_cache "${CMD}" > /dev/null done } @@ -109,26 +139,37 @@ _KAC_clean_cache() { ##################################### # returns all the possible knife sub-commands -_KAC_knife_commands() { +function _KAC_knife_commands() +{ + ############ STACK_TRACE_BUILDER ##################### + Function_Name="${FUNCNAME[0]}" + Function_PATH="${Function_PATH}/${Function_Name}" + ###################################################### knife --help | grep -E "^knife" | sed -E 's/ \(options\)//g' } # rebuilds the knife base command currently being completed, and assigns it to $_KAC_CURRENT_COMMAND # additionnally, returns 1 iff the current base command is not complete, 0 otherwise # also sets $_KAC_CURRENT_COMMAND_NB_WORDS if the base command is complete -_KAC_get_current_base_command() { +function _KAC_get_current_base_command() +{ + ############ STACK_TRACE_BUILDER ##################### + Function_Name="${FUNCNAME[0]}" + Function_PATH="${Function_PATH}/${Function_Name}" + ###################################################### local PREVIOUS="knife" local I=1 local CURRENT - while [[ "${I}" -le "${COMP_CWORD}" ]]; do + while [[ "${I}" -le "${COMP_CWORD}" ]] + do # command words are all lower-case echo "${COMP_WORDS[$I]}" | grep -E "^[a-z]+$" > /dev/null || break - CURRENT="$PREVIOUS ${COMP_WORDS[$I]}" - grep -E "^$CURRENT" "$_KAC_CACHE_PATH" > /dev/null || break - PREVIOUS=$CURRENT + CURRENT="${PREVIOUS} ${COMP_WORDS[$I]}" + grep -E "^${CURRENT}" "${_KAC_CACHE_PATH}" > /dev/null || break + PREVIOUS="${CURRENT}" I=$((I + 1)) done - _KAC_CURRENT_COMMAND=$PREVIOUS + _KAC_CURRENT_COMMAND="${PREVIOUS}" [[ "${I}" -le "${COMP_CWORD}" ]] && _KAC_CURRENT_COMMAND_NB_WORDS="${I}" } @@ -136,21 +177,32 @@ _KAC_get_current_base_command() { # (i.e. handles "plural" arguments such as knife cookbook upload cookbook1 cookbook2 and so on...) # assumes the current base command is complete # shellcheck disable=SC2155 -_KAC_get_current_arg_position() { +function _KAC_get_current_arg_position() +{ + ############ STACK_TRACE_BUILDER ##################### + Function_Name="${FUNCNAME[0]}" + Function_PATH="${Function_PATH}/${Function_Name}" + ###################################################### local CURRENT_ARG_POS=$((_KAC_CURRENT_COMMAND_NB_WORDS + 1)) - local COMPLETE_COMMAND=$(grep -E "^$_KAC_CURRENT_COMMAND" "$_KAC_CACHE_PATH") + local COMPLETE_COMMAND=$(grep -E "^${_KAC_CURRENT_COMMAND}" "${_KAC_CACHE_PATH}") local CURRENT_ARG - while [ "$CURRENT_ARG_POS" -le "$COMP_CWORD" ]; do - CURRENT_ARG=$(echo "$COMPLETE_COMMAND" | cut -d ' ' -f "$CURRENT_ARG_POS") + while [ "${CURRENT_ARG_POS}" -le "${COMP_CWORD}" ] + do + CURRENT_ARG=$(echo "${COMPLETE_COMMAND}" | cut -d ' ' -f "${CURRENT_ARG_POS}") # we break if the current arg is a "plural" arg - echo "$CURRENT_ARG" | grep -E "^\\[[^]]+(\\.\\.\\.\\]|$)" > /dev/null && break + echo "${CURRENT_ARG}" | grep -E "^\\[[^]]+(\\.\\.\\.\\]|$)" > /dev/null && break CURRENT_ARG_POS=$((CURRENT_ARG_POS + 1)) done - echo "$CURRENT_ARG_POS" + echo "${CURRENT_ARG_POS}" } # the actual auto-complete function -_knife() { +function _knife() + { + ############ STACK_TRACE_BUILDER ##################### + Function_Name="${FUNCNAME[0]}" + Function_PATH="${Function_PATH}/${Function_Name}" + ###################################################### _KAC_get_and_regen_cache _KAC_knife_commands local RAW_LIST ITEM REGEN_CMD ARG_POSITION # shellcheck disable=SC2034 @@ -165,10 +217,11 @@ _knife() { # current base command - that might limit my script in some situation, but that way I'm sure it caches only # not-sensitive stuff (a generic approach could be pretty bad e.g. with the knife-rackspace plugin) LIST="" - for ITEM in $RAW_LIST; do + for ITEM in $RAW_LIST + do # always relevant if only lower-case chars : continuation of the base command - echo "$ITEM" | grep -E "^[a-z]+$" > /dev/null && LIST="$LIST $ITEM" && continue - case "$ITEM" in + echo "${ITEM}" | grep -E "^[a-z]+$" > /dev/null && LIST="${LIST} ${ITEM}" && continue + case "${ITEM}" in *COOKBOOK*) # special case for cookbooks : from site or local [[ ${COMP_WORDS[2]} == 'site' ]] && REGEN_CMD="knife cookbook site list" || REGEN_CMD="knife cookbook list" @@ -179,11 +232,11 @@ _knife() { *ITEM*) # data bag item : another special case local DATA_BAG_NAME=${COMP_WORDS[$((COMP_CWORD - 1))]} - REGEN_CMD="knife data bag show $DATA_BAG_NAME" + REGEN_CMD="knife data bag show ${DATA_BAG_NAME}" ;; *INDEX*) # see doc @ http://docs.opscode.com/knife_search.html - LIST="$LIST client environment node role" + LIST="${LIST} client environment node role" REGEN_CMD="knife data bag list" ;; *BAG*) REGEN_CMD="knife data bag list" ;; diff --git a/completion/available/kontena.completion.bash b/completion/available/kontena.completion.bash index 916ee15f..03a63cb6 100644 --- a/completion/available/kontena.completion.bash +++ b/completion/available/kontena.completion.bash @@ -1,5 +1,6 @@ # shellcheck shell=bash -if _command_exists kontena; then +if _command_exists kontena + then # shellcheck disable=SC1090 source "$(kontena whoami --bash-completion-path)" fi diff --git a/completion/available/kubectl.completion.bash b/completion/available/kubectl.completion.bash index a9c498b6..50771ccb 100644 --- a/completion/available/kubectl.completion.bash +++ b/completion/available/kubectl.completion.bash @@ -2,6 +2,7 @@ cite "about-completion" about-completion "kubectl (Kubernetes CLI) completion" -if _binary_exists kubectl; then +if _binary_exists kubectl + then eval "$(kubectl completion bash)" fi diff --git a/completion/available/laravel.completion.bash b/completion/available/laravel.completion.bash index 8f032568..a2e262d5 100644 --- a/completion/available/laravel.completion.bash +++ b/completion/available/laravel.completion.bash @@ -2,12 +2,19 @@ _command_exists laravel || return -function __laravel_completion() { +function __laravel_completion() + { + ############ STACK_TRACE_BUILDER ##################### + Function_Name="${FUNCNAME[0]}" + Function_PATH="${Function_PATH}/${Function_Name}" + ###################################################### local OPTS=('-h' '--help' '-q' '--quiet' '--ansi' '--no-ansi' '-n' '--no-interaction' '-v' '-vv' '-vvv' '--verbose' 'help' 'list' 'new') local _opt_ COMPREPLY=() - for _opt_ in "${OPTS[@]}"; do - if [[ "$_opt_" == "$2"* ]]; then + for _opt_ in "${OPTS[@]}" + do + if [[ "${_opt_}" == "${2}"* ]] + then COMPREPLY+=("$_opt_") fi done diff --git a/completion/available/lerna.completion.bash b/completion/available/lerna.completion.bash index f83f1125..ba5a4dca 100644 --- a/completion/available/lerna.completion.bash +++ b/completion/available/lerna.completion.bash @@ -2,7 +2,12 @@ cite "about-completion" about-completion "lerna(javascript project manager tool) completion" -function __lerna_completion() { +function __lerna_completion() +{ + ############ STACK_TRACE_BUILDER ##################### + Function_Name="${FUNCNAME[0]}" + Function_PATH="${Function_PATH}/${Function_Name}" + ###################################################### local cur compls # The currently-being-completed word. diff --git a/completion/available/makefile.completion.bash b/completion/available/makefile.completion.bash index 018586ca..ae3227fb 100644 --- a/completion/available/makefile.completion.bash +++ b/completion/available/makefile.completion.bash @@ -3,7 +3,8 @@ # Bash completion for Makefile # Loosely adapted from http://stackoverflow.com/a/38415982/1472048 -_makecomplete() { +function _makecomplete() +{ COMPREPLY=() # https://www.gnu.org/software/make/manual/html_node/Makefile-Names.html diff --git a/completion/available/maven.completion.bash b/completion/available/maven.completion.bash index 31216449..0b762e67 100644 --- a/completion/available/maven.completion.bash +++ b/completion/available/maven.completion.bash @@ -1,7 +1,7 @@ #!/usr/bin/env bash # Bash Maven completion -_mvn() +function _mvn() { local cmds cur colonprefixes cmds="clean validate compile test package integration-test \ diff --git a/completion/available/minikube.completion.bash b/completion/available/minikube.completion.bash index 44076362..0c946030 100644 --- a/completion/available/minikube.completion.bash +++ b/completion/available/minikube.completion.bash @@ -1,6 +1,7 @@ # shellcheck shell=bash # minikube (Local Kubernetes) completion -if _command_exists minikube; then +if _command_exists minikube + then eval "$(minikube completion bash)" fi diff --git a/completion/available/ng.completion.bash b/completion/available/ng.completion.bash index f219b303..2afacdaf 100644 --- a/completion/available/ng.completion.bash +++ b/completion/available/ng.completion.bash @@ -1,4 +1,5 @@ -if _command_exists ng; then +if _command_exists ng + then # No longer supported, please see https://github.com/angular/angular-cli/issues/11043 # Fix courtesy of https://stackoverflow.com/questions/50194674/ng-completion-no-longer-exists # . <(ng completion --bash) diff --git a/completion/available/ngrok.completion.bash b/completion/available/ngrok.completion.bash index ca50a16f..04220a78 100644 --- a/completion/available/ngrok.completion.bash +++ b/completion/available/ngrok.completion.bash @@ -1,6 +1,7 @@ # shellcheck shell=bash -__ngrok_completion() { +function __ngrok_completion() +{ # shellcheck disable=SC2155 local prev=$(_get_pword) # shellcheck disable=SC2155 diff --git a/completion/available/notify-send.completion.bash b/completion/available/notify-send.completion.bash index 676485f8..73f0fcc3 100644 --- a/completion/available/notify-send.completion.bash +++ b/completion/available/notify-send.completion.bash @@ -1,6 +1,11 @@ # shellcheck shell=bash -function __notify-send_completions() { +function __notify-send_completions() +{ + ############ STACK_TRACE_BUILDER ##################### + Function_Name="${FUNCNAME[0]}" + Function_PATH="${Function_PATH}/${Function_Name}" + ###################################################### # shellcheck disable=SC2155 local curr=$(_get_cword) # shellcheck disable=SC2155 diff --git a/completion/available/npm.completion.bash b/completion/available/npm.completion.bash index cf24585e..2165d689 100644 --- a/completion/available/npm.completion.bash +++ b/completion/available/npm.completion.bash @@ -2,6 +2,7 @@ cite "about-completion" about-completion "npm (Node Package Manager) completion" -if _command_exists npm; then +if _command_exists npm + then eval "$(npm completion)" fi diff --git a/completion/available/packer.completion.bash b/completion/available/packer.completion.bash index 2301f0f2..d213379a 100644 --- a/completion/available/packer.completion.bash +++ b/completion/available/packer.completion.bash @@ -2,6 +2,7 @@ cite "about-completion" about-completion "packer completion" -if _binary_exists packer; then +if _binary_exists packer + then complete -C packer packer fi diff --git a/completion/available/pip.completion.bash b/completion/available/pip.completion.bash index f094d6ed..af0cdbe1 100644 --- a/completion/available/pip.completion.bash +++ b/completion/available/pip.completion.bash @@ -8,8 +8,14 @@ # So that pip is in the system's path. _command_exists pip || return -function __bash_it_complete_pip() { - if _command_exists _pip_completion; then +function __bash_it_complete_pip() +{ + ############ STACK_TRACE_BUILDER ##################### + Function_Name="${FUNCNAME[0]}" + Function_PATH="${Function_PATH}/${Function_Name}" + ###################################################### + if _command_exists _pip_completion + then complete -o default -F _pip_completion pip _pip_completion "$@" else @@ -17,4 +23,5 @@ function __bash_it_complete_pip() { _pip_completion "$@" fi } + complete -o default -F __bash_it_complete_pip pip diff --git a/completion/available/pip3.completion.bash b/completion/available/pip3.completion.bash index 34abc053..3c270a10 100644 --- a/completion/available/pip3.completion.bash +++ b/completion/available/pip3.completion.bash @@ -8,8 +8,14 @@ # So that pip3 is in the system's path. _command_exists pip3 || return -function __bash_it_complete_pip3() { - if _command_exists _pip_completion; then +function __bash_it_complete_pip3() +{ + ############ STACK_TRACE_BUILDER ##################### + Function_Name="${FUNCNAME[0]}" + Function_PATH="${Function_PATH}/${Function_Name}" + ###################################################### + if _command_exists _pip_completion + then complete -o default -F _pip_completion pip3 _pip_completion "$@" else diff --git a/completion/available/pipenv.completion.bash b/completion/available/pipenv.completion.bash index 4adfab95..501097c7 100644 --- a/completion/available/pipenv.completion.bash +++ b/completion/available/pipenv.completion.bash @@ -1,4 +1,5 @@ # shellcheck shell=bash -if _command_exists pipenv; then +if _command_exists pipenv + then eval "$(_PIPENV_COMPLETE=bash_source pipenv)" fi diff --git a/completion/available/pipx.completion.bash b/completion/available/pipx.completion.bash index 16fd844d..7e3337a2 100644 --- a/completion/available/pipx.completion.bash +++ b/completion/available/pipx.completion.bash @@ -1,6 +1,7 @@ # shellcheck shell=bash # pipx completion -if _command_exists register-python-argcomplete && _command_exists pipx; then +if _command_exists register-python-argcomplete && _command_exists pipx + then eval "$(register-python-argcomplete pipx)" fi diff --git a/completion/available/projects.completion.bash b/completion/available/projects.completion.bash index df4f5754..ddf968f2 100644 --- a/completion/available/projects.completion.bash +++ b/completion/available/projects.completion.bash @@ -4,12 +4,17 @@ _is_function _init_completion || _is_function _rl_enabled || _log_error '_rl_enabled not found. Ensure bash-completion 2.0 or newer is installed and configured properly.' -_pj() { +function _pj() +{ + ############ STACK_TRACE_BUILDER ##################### + Function_Name="${FUNCNAME[0]}" + Function_PATH="${Function_PATH}/${Function_Name}" + ###################################################### _is_function _init_completion || return _is_function _rl_enabled || return [ -n "$BASH_IT_PROJECT_PATHS" ] || return shift - [ "$1" == "open" ] && shift + [ "${1}" == "open" ] && shift local cur prev words cword _init_completion || return @@ -21,20 +26,25 @@ _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 ${BASH_IT_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 - if [[ ( $mark_symdirs && -h $j || $mark_dirs && ! -h $j ) && ! -d ${j#$i/} ]]; then + for j in $( compgen -d $i/$cur ) + do + if [[ ( ${mark_symdirs} && -h $j || ${mark_dirs} && ! -h $j ) && ! -d ${j#$i/} ]] + then j+="/" fi COMPREPLY[k++]=${j#$i/} done done - if [[ ${#COMPREPLY[@]} -eq 1 ]]; then + if [[ ${#COMPREPLY[@]} -eq 1 ]] + then i=${COMPREPLY[0]} - if [[ "$i" == "$cur" && $i != "*/" ]]; then + if [[ "$i" == "$cur" && $i != "*/" ]] + then COMPREPLY[0]="${i}/" fi fi diff --git a/completion/available/rake.completion.bash b/completion/available/rake.completion.bash index 453354f9..a604f1ba 100644 --- a/completion/available/rake.completion.bash +++ b/completion/available/rake.completion.bash @@ -3,10 +3,12 @@ export COMP_WORDBREAKS=${COMP_WORDBREAKS/\:/} -_rakecomplete() { - if [ -f Rakefile ]; then +function _rakecomplete() { + if [ -f Rakefile ] + then recent=`ls -t .rake_tasks~ Rakefile **/*.rake 2> /dev/null | head -n 1` - if [[ $recent != '.rake_tasks~' ]]; then + if [[ $recent != '.rake_tasks~' ]] + then rake --silent --tasks | cut -d " " -f 2 > .rake_tasks~ fi COMPREPLY=($(compgen -W "`cat .rake_tasks~`" -- ${COMP_WORDS[COMP_CWORD]})) diff --git a/completion/available/rustup.completion.bash b/completion/available/rustup.completion.bash index 1cf8bc95..70c296fc 100644 --- a/completion/available/rustup.completion.bash +++ b/completion/available/rustup.completion.bash @@ -2,6 +2,7 @@ # rustup (Rust toolchain installer) completion -if _binary_exists rustup; then +if _binary_exists rustup + then eval "$(rustup completions bash)" fi diff --git a/completion/available/salt.completion.bash b/completion/available/salt.completion.bash index 03595f9f..bee85ae5 100644 --- a/completion/available/salt.completion.bash +++ b/completion/available/salt.completion.bash @@ -27,16 +27,24 @@ # TODO: is it ok to use '--timeout 2' ? -_salt_get_grains(){ - if [ "$1" = 'local' ] ; then +function _salt_get_grains() +{ + ############ STACK_TRACE_BUILDER ##################### + Function_Name="${FUNCNAME[0]}" + Function_PATH="${Function_PATH}/${Function_Name}" + ###################################################### + if [ "${1}" = 'local' ] + then salt-call --out=txt -- grains.ls | sed 's/^.*\[//' | tr -d ",']" |sed 's:\([a-z0-9]\) :\1\: :g' else salt '*' --timeout 2 --out=txt -- grains.ls | sed 's/^.*\[//' | tr -d ",']" |sed 's:\([a-z0-9]\) :\1\: :g' fi } -_salt_get_grain_values(){ - if [ "$1" = 'local' ] ; then +function _salt_get_grain_values() +{ + if [ "${1}" = 'local' ] + then salt-call --out=txt -- grains.item $1 |sed 's/^\S*:\s//' |grep -v '^\s*$' else salt '*' --timeout 2 --out=txt -- grains.item $1 |sed 's/^\S*:\s//' |grep -v '^\s*$' @@ -44,15 +52,22 @@ _salt_get_grain_values(){ } -_salt(){ +function _salt() +{ + ############ STACK_TRACE_BUILDER ##################### + Function_Name="${FUNCNAME[0]}" + Function_PATH="${Function_PATH}/${Function_Name}" + ###################################################### local cur prev opts _salt_grains _salt_coms pprev ppprev COMPREPLY=() cur="${COMP_WORDS[COMP_CWORD]}" prev="${COMP_WORDS[COMP_CWORD-1]}" - if [ ${COMP_CWORD} -gt 2 ]; then + if [ ${COMP_CWORD} -gt 2 ] + then pprev="${COMP_WORDS[COMP_CWORD-2]}" fi - if [ ${COMP_CWORD} -gt 3 ]; then + if [ ${COMP_CWORD} -gt 3 ] + then ppprev="${COMP_WORDS[COMP_CWORD-3]}" fi @@ -64,7 +79,8 @@ _salt(){ --ipcidr --out=pprint --out=yaml --out=overstatestage --out=json \ --out=raw --out=highstate --out=key --out=txt --no-color --out-indent= " - if [[ "${cur}" == -* ]] ; then + if [[ "${cur}" == -* ]] + then COMPREPLY=($(compgen -W "${opts}" -- ${cur})) return 0 fi @@ -72,7 +88,8 @@ _salt(){ # 2 special cases for filling up grain values case "${pprev}" in -G|--grain|--grain-pcre) - if [ "${cur}" = ":" ]; then + if [ "${cur}" = ":" ] + then COMPREPLY=($(compgen -W "`_salt_get_grain_values ${prev}`" )) return 0 fi @@ -80,17 +97,20 @@ _salt(){ esac case "${ppprev}" in -G|--grain|--grain-pcre) - if [ "${prev}" = ":" ]; then + if [ "${prev}" = ":" ] + then COMPREPLY=( $(compgen -W "`_salt_get_grain_values ${pprev}`" -- ${cur}) ) return 0 fi ;; esac - if [ "${cur}" = "=" ] && [[ "${prev}" == --* ]]; then + if [ "${cur}" = "=" ] && [[ "${prev}" == --* ]] + then cur="" fi - if [ "${prev}" = "=" ] && [[ "${pprev}" == --* ]]; then + if [ "${prev}" = "=" ] && [[ "${pprev}" == --* ]] + then prev="${pprev}" fi @@ -141,7 +161,12 @@ _salt(){ complete -F _salt salt -_saltkey(){ +function _saltkey() +{ + ############ STACK_TRACE_BUILDER ##################### + Function_Name="${FUNCNAME[0]}" + Function_PATH="${Function_PATH}/${Function_Name}" + ###################################################### local cur prev opts prev pprev COMPREPLY=() cur="${COMP_WORDS[COMP_CWORD]}" @@ -153,21 +178,26 @@ _saltkey(){ -d --delete= -D --delete-all -f --finger= -F --finger-all \ --out=pprint --out=yaml --out=overstatestage --out=json --out=raw \ --out=highstate --out=key --out=txt --no-color --out-indent= " - if [ ${COMP_CWORD} -gt 2 ]; then + if [ ${COMP_CWORD} -gt 2 ] + then pprev="${COMP_WORDS[COMP_CWORD-2]}" fi - if [ ${COMP_CWORD} -gt 3 ]; then + if [ ${COMP_CWORD} -gt 3 ] + then ppprev="${COMP_WORDS[COMP_CWORD-3]}" fi - if [[ "${cur}" == -* ]] ; then + if [[ "${cur}" == -* ]] + then COMPREPLY=($(compgen -W "${opts}" -- ${cur})) return 0 fi - if [ "${cur}" = "=" ] && [[ "${prev}" == --* ]]; then + if [ "${cur}" = "=" ] && [[ "${prev}" == --* ]] + then cur="" fi - if [ "${prev}" = "=" ] && [[ "${pprev}" == --* ]]; then + if [ "${prev}" = "=" ] && [[ "${pprev}" == --* ]] + then prev="${pprev}" fi @@ -217,7 +247,12 @@ _saltkey(){ complete -F _saltkey salt-key -_saltcall(){ +function _saltcall() +{ + ############ STACK_TRACE_BUILDER ##################### + Function_Name="${FUNCNAME[0]}" + Function_PATH="${Function_PATH}/${Function_Name}" + ###################################################### local cur prev opts _salt_coms pprev ppprev COMPREPLY=() cur="${COMP_WORDS[COMP_CWORD]}" @@ -226,21 +261,26 @@ _saltcall(){ -m --module-dirs= -g --grains --return= --local -c --config-dir= -l --log-level= \ --out=pprint --out=yaml --out=overstatestage --out=json --out=raw \ --out=highstate --out=key --out=txt --no-color --out-indent= " - if [ ${COMP_CWORD} -gt 2 ]; then + if [ ${COMP_CWORD} -gt 2 ] + then pprev="${COMP_WORDS[COMP_CWORD-2]}" fi - if [ ${COMP_CWORD} -gt 3 ]; then + if [ ${COMP_CWORD} -gt 3 ] + then ppprev="${COMP_WORDS[COMP_CWORD-3]}" fi - if [[ "${cur}" == -* ]] ; then + if [[ "${cur}" == -* ]] + then COMPREPLY=($(compgen -W "${opts}" -- ${cur})) return 0 fi - if [ "${cur}" = "=" ] && [[ ${prev} == --* ]]; then + if [ "${cur}" = "=" ] && [[ ${prev} == --* ]] + then cur="" fi - if [ "${prev}" = "=" ] && [[ ${pprev} == --* ]]; then + if [ "${prev}" = "=" ] && [[ ${pprev} == --* ]] + then prev="${pprev}" fi @@ -270,7 +310,12 @@ _saltcall(){ complete -F _saltcall salt-call -_saltcp(){ +function _saltcp() +{ + ############ STACK_TRACE_BUILDER ##################### + Function_Name="${FUNCNAME[0]}" + Function_PATH="${Function_PATH}/${Function_Name}" + ###################################################### local cur prev opts target prefpart postpart helper filt pprev ppprev COMPREPLY=() cur="${COMP_WORDS[COMP_CWORD]}" @@ -281,15 +326,18 @@ _saltcp(){ -R --range -C --compound -I --pillar \ --out=pprint --out=yaml --out=overstatestage --out=json --out=raw \ --out=highstate --out=key --out=txt --no-color --out-indent= " - if [[ "${cur}" == -* ]] ; then + if [[ "${cur}" == -* ]] + then COMPREPLY=($(compgen -W "${opts}" -- ${cur})) return 0 fi - if [ "${cur}" = "=" ] && [[ "${prev}" == --* ]]; then + if [ "${cur}" = "=" ] && [[ "${prev}" == --* ]] + then cur="" fi - if [ "${prev}" = "=" ] && [[ "${pprev}" == --* ]]; then + if [ "${prev}" = "=" ] && [[ "${pprev}" == --* ]] + then prev=${pprev} fi diff --git a/completion/available/sdkman.completion.bash b/completion/available/sdkman.completion.bash index 2dc09088..e2d94554 100644 --- a/completion/available/sdkman.completion.bash +++ b/completion/available/sdkman.completion.bash @@ -7,9 +7,11 @@ function _sdkman_complete() { COMPREPLY=() - if [ "$COMP_CWORD" -eq 1 ]; then + if [ "$COMP_CWORD" -eq 1 ] + then mapfile -t COMPREPLY < <(compgen -W "install uninstall rm list ls use default home env current upgrade ug version broadcast help offline selfupdate update flush" -- "${COMP_WORDS[COMP_CWORD]}") - elif [ "$COMP_CWORD" -eq 2 ]; then + elif [ "$COMP_CWORD" -eq 2 ] + then case "${COMP_WORDS[COMP_CWORD - 1]}" in "install" | "i" | "uninstall" | "rm" | "list" | "ls" | "use" | "u" | "default" | "d" | "home" | "h" | "current" | "c" | "upgrade" | "ug") CANDIDATES="${SDKMAN_CANDIDATES_CSV//,/${IFS:0:1}}" @@ -30,7 +32,8 @@ function _sdkman_complete() { *) ;; esac - elif [ "$COMP_CWORD" -eq 3 ]; then + elif [ "$COMP_CWORD" -eq 3 ] + then case "${COMP_WORDS[COMP_CWORD - 2]}" in "uninstall" | "rm" | "use" | "u" | "default" | "d" | "home" | "h") _sdkman_candidate_local_versions "${COMP_WORDS[COMP_CWORD - 1]}" @@ -50,20 +53,22 @@ function _sdkman_complete() { function _sdkman_candidate_local_versions() { - CANDIDATE_VERSIONS=$(__sdkman_cleanup_local_versions "$1") + CANDIDATE_VERSIONS=$(__sdkman_cleanup_local_versions "${1}") } function _sdkman_candidate_all_versions() { - candidate="$1" + candidate="${1}" CANDIDATE_LOCAL_VERSIONS=$(__sdkman_cleanup_local_versions "$candidate") - if [[ "${SDKMAN_OFFLINE_MODE:-false}" == "true" ]]; then + if [[ "${SDKMAN_OFFLINE_MODE:-false}" == "true" ]] + then CANDIDATE_VERSIONS=$CANDIDATE_LOCAL_VERSIONS else # sdkman has a specific output format for Java candidate since # there are multiple vendors and builds. - if [ "$candidate" = "java" ]; then + if [ "$candidate" = "java" ] + then CANDIDATE_ONLINE_VERSIONS="$(__sdkman_list_versions "$candidate" | grep " " | grep "\." | cut -c 62-)" else CANDIDATE_ONLINE_VERSIONS="$(__sdkman_list_versions "$candidate" | grep " " | grep "\." | cut -c 6-)" @@ -79,7 +84,7 @@ function _sdkman_candidate_all_versions() { function __sdkman_cleanup_local_versions() { - __sdkman_build_version_csv "$1" | tr ',' ' ' + __sdkman_build_version_csv "${1}" | tr ',' ' ' } diff --git a/completion/available/sqlmap.completion.bash b/completion/available/sqlmap.completion.bash index 213dd817..e87f838a 100644 --- a/completion/available/sqlmap.completion.bash +++ b/completion/available/sqlmap.completion.bash @@ -79,7 +79,8 @@ then ;; esac - if [[ "$cur" == * ]]; then + if [[ "$cur" == * ]] + then COMPREPLY=( $( compgen -W '-h --help -hh --version -v -d -u --url -l -x -m -r -g -c --method \ --data --param-del --cookie --cookie-del --load-cookies \ --drop-set-cookie --user-agent --random-agent --host --referer \ diff --git a/completion/available/ssh.completion.bash b/completion/available/ssh.completion.bash index 1f71f112..feb18f8c 100644 --- a/completion/available/ssh.completion.bash +++ b/completion/available/ssh.completion.bash @@ -5,7 +5,8 @@ export COMP_WORDBREAKS=${COMP_WORDBREAKS/\:/} _sshcomplete() { local CURRENT_PROMPT="${COMP_WORDS[COMP_CWORD]}" - if [[ ${CURRENT_PROMPT} == *@* ]] ; then + if [[ ${CURRENT_PROMPT} == *@* ]] + then local OPTIONS="-P ${CURRENT_PROMPT/@*/}@ -- ${CURRENT_PROMPT/*@/}" else local OPTIONS=" -- ${CURRENT_PROMPT}" @@ -17,20 +18,24 @@ _sshcomplete() { awk '{for (i=2; i<=NF; i++) print $i}' | sed -Ee "s|^([^/~])|$HOME/.ssh/\1|" -e "s|^~/|$HOME/|") do - if [ -r "$fl" ]; then + if [ -r "$fl" ] + then COMPREPLY=( ${COMPREPLY[@]} $(compgen -W "$(grep -i ^Host "$fl" |grep -v '[*!]' | awk '{for (i=2; i<=NF; i++) print $i}' )" ${OPTIONS}) ) fi done # parse all hosts found in .ssh/known_hosts - if [ -r "$HOME/.ssh/known_hosts" ]; then - if grep -v -q -e '^ ssh-rsa' "$HOME/.ssh/known_hosts" ; then + if [ -r "$HOME/.ssh/known_hosts" ] + then + if grep -v -q -e '^ ssh-rsa' "$HOME/.ssh/known_hosts" + then COMPREPLY=( ${COMPREPLY[@]} $(compgen -W "$( awk '{print $1}' "$HOME/.ssh/known_hosts" | grep -v ^\| | cut -d, -f 1 | sed -e 's/\[//g' | sed -e 's/\]//g' | cut -d: -f1 | grep -v ssh-rsa)" ${OPTIONS}) ) fi fi # parse hosts defined in /etc/hosts - if [ -r /etc/hosts ]; then + if [ -r /etc/hosts ] + then COMPREPLY=( ${COMPREPLY[@]} $(compgen -W "$( grep -v '^[[:space:]]*$' /etc/hosts | grep -v '^#' | awk '{for (i=2; i<=NF; i++) print $i}' )" ${OPTIONS}) ) fi diff --git a/completion/available/svn.completion.bash b/completion/available/svn.completion.bash index 2f0a23fe..c97f72ba 100644 --- a/completion/available/svn.completion.bash +++ b/completion/available/svn.completion.bash @@ -6,13 +6,15 @@ _command_exists svn || return # Don't handle completion if it's already managed -if _completion_exists svn; then +if _completion_exists svn + then _log_warning "completion already loaded - this usually means it is safe to stop using this completion" return 0 fi _svn_bash_completion_xcrun_svn= -if _command_exists xcrun; then +if _command_exists xcrun + then _svn_bash_completion_xcrun_svn="$(xcrun --find svn)" fi _svn_bash_completion_paths=( @@ -25,7 +27,8 @@ _svn_bash_completion_paths=( # Load the first completion file found _svn_bash_completion_found=false for _comp_path in "${_svn_bash_completion_paths[@]}"; do - if [[ -r "$_comp_path" ]]; then + if [[ -r "$_comp_path" ]] + then _svn_bash_completion_found=true # shellcheck disable=SC1090 # don't follow source "$_comp_path" @@ -34,7 +37,8 @@ for _comp_path in "${_svn_bash_completion_paths[@]}"; do done # Cleanup -if [[ "${_svn_bash_completion_found}" == false ]]; then +if [[ "${_svn_bash_completion_found}" == false ]] + then _log_warning "no completion files found - please try enabling the 'system' completion instead." fi unset "${!_svn_bash_completion@}" diff --git a/completion/available/system.completion.bash b/completion/available/system.completion.bash index bb1d14eb..7808720d 100644 --- a/completion/available/system.completion.bash +++ b/completion/available/system.completion.bash @@ -7,7 +7,8 @@ # BASH_IT_LOAD_PRIORITY: 325 # Bash-completion is too large and complex to expect to handle unbound variables throughout the whole codebase. -if shopt -qo nounset; then +if shopt -qo nounset + then __bash_it_restore_nounset=true shopt -uo nounset else @@ -15,14 +16,18 @@ else fi # shellcheck disable=SC1090 disable=SC1091 -if [[ -r "${BASH_COMPLETION:-}" ]]; then +if [[ -r "${BASH_COMPLETION:-}" ]] + then source "${BASH_COMPLETION}" -elif [[ -r /etc/bash_completion ]]; then +elif [[ -r /etc/bash_completion ]] + then source /etc/bash_completion # Some distribution makes use of a profile.d script to import completion. -elif [[ -r /etc/profile.d/bash_completion.sh ]]; then +elif [[ -r /etc/profile.d/bash_completion.sh ]] + then source /etc/profile.d/bash_completion.sh -elif _bash_it_homebrew_check; then +elif _bash_it_homebrew_check + then : "${BASH_COMPLETION_COMPAT_DIR:=${BASH_IT_HOMEBREW_PREFIX}/etc/bash_completion.d}" case "${BASH_VERSION}" in 1* | 2* | 3.0* | 3.1*) @@ -31,7 +36,8 @@ elif _bash_it_homebrew_check; then 3.2* | 4.0* | 4.1*) # Import version 1.x of bash-completion, if installed. BASH_COMPLETION="${BASH_IT_HOMEBREW_PREFIX}/opt/bash-completion@1/etc/bash_completion" - if [[ -r "$BASH_COMPLETION" ]]; then + if [[ -r "$BASH_COMPLETION" ]] + then source "$BASH_COMPLETION" else unset BASH_COMPLETION @@ -39,14 +45,16 @@ elif _bash_it_homebrew_check; then ;; 4.2* | 5* | *) # homebrew/versions/bash-completion2 (required for projects.completion.bash) is installed to this path - if [[ -r "${BASH_IT_HOMEBREW_PREFIX}/opt/bash-completion@2/etc/profile.d/bash_completion.sh" ]]; then + if [[ -r "${BASH_IT_HOMEBREW_PREFIX}/opt/bash-completion@2/etc/profile.d/bash_completion.sh" ]] + then source "${BASH_IT_HOMEBREW_PREFIX}/opt/bash-completion@2/etc/profile.d/bash_completion.sh" fi ;; esac fi -if [[ ${__bash_it_restore_nounset:-false} == "true" ]]; then +if [[ ${__bash_it_restore_nounset:-false} == "true" ]] + then shopt -so nounset fi unset __bash_it_restore_nounset diff --git a/completion/available/test_kitchen.completion.bash b/completion/available/test_kitchen.completion.bash index 25459981..08081d00 100644 --- a/completion/available/test_kitchen.completion.bash +++ b/completion/available/test_kitchen.completion.bash @@ -1,13 +1,14 @@ -__kitchen_instance_list () { +function __kitchen_instance_list () { # cache to .kitchen.list.yml - if [[ .kitchen.yml -nt .kitchen.list.yml || .kitchen.local.yml -nt .kitchen.list.yml ]]; then + if [[ .kitchen.yml -nt .kitchen.list.yml || .kitchen.local.yml -nt .kitchen.list.yml ]] + then # update list if config has updated kitchen list --bare > .kitchen.list.yml fi cat .kitchen.list.yml } -__kitchen_options () { +function __kitchen_options () { cur="${COMP_WORDS[COMP_CWORD]}" prev="${COMP_WORDS[COMP_CWORD-1]}" COMPREPLY=() diff --git a/completion/available/tmux.completion.bash b/completion/available/tmux.completion.bash index 7992ccb4..2a43f0f6 100644 --- a/completion/available/tmux.completion.bash +++ b/completion/available/tmux.completion.bash @@ -4,13 +4,15 @@ # See: http://www.debian-administration.org/articles/317 for how to write more. # Usage: Put "source bash_completion_tmux.sh" into your .bashrc -_tmux_expand () +function _tmux_expand () { [ "$cur" != "${cur%\\}" ] && cur="$cur"'\'; - if [[ "$cur" == \~*/* ]]; then + if [[ "$cur" == \~*/* ]] + then eval cur=$cur; else - if [[ "$cur" == \~* ]]; then + if [[ "$cur" == \~* ]] + then cur=${cur#\~}; COMPREPLY=($( compgen -P '~' -u $cur )); return ${#COMPREPLY[@]}; @@ -18,12 +20,13 @@ _tmux_expand () fi } -_tmux_filedir () +function _tmux_filedir () { local IFS=' '; _tmux_expand || return 0; - if [ "$1" = -d ]; then + if [ "${1}" = -d ] + then COMPREPLY=(${COMPREPLY[@]} $( compgen -d -- $cur )); return 0; fi; @@ -47,7 +50,8 @@ function _tmux_complete_window() { local sessions sessions="$(tmux -q list-sessions 2>/dev/null | sed -re 's/([^:]+:).*$/\1/')" - if [[ -n "${session_name}" ]]; then + if [[ -n "${session_name}" ]] + then sessions="${sessions} $(tmux -q list-windows -t "${session_name}" 2>/dev/null | sed -re 's/^([^:]+):.*$/'"${session_name}"':\1/')" fi @@ -56,7 +60,7 @@ function _tmux_complete_window() { COMPREPLY=( ${COMPREPLY[@]:-} $(compgen -W "${sessions}" -- "${cur}") ) } -_tmux() { +function _tmux() { local cur prev local i cmd cmd_index option option_index local opts="" @@ -64,20 +68,24 @@ _tmux() { cur="${COMP_WORDS[COMP_CWORD]}" prev="${COMP_WORDS[COMP_CWORD-1]}" - if [ ${prev} == -f ]; then + if [ ${prev} == -f ] + then _tmux_filedir else # Search for the command local skip_next=0 for ((i=1; $i<=$COMP_CWORD; i++)); do - if [[ ${skip_next} -eq 1 ]]; then + if [[ ${skip_next} -eq 1 ]] + then #echo "Skipping" skip_next=0; - elif [[ ${COMP_WORDS[i]} != -* ]]; then + elif [[ ${COMP_WORDS[i]} != -* ]] + then cmd="${COMP_WORDS[i]}" cmd_index=${i} break - elif [[ ${COMP_WORDS[i]} == -f ]]; then + elif [[ ${COMP_WORDS[i]} == -f ]] + then skip_next=1 fi done @@ -85,21 +93,26 @@ _tmux() { # Search for the last option command skip_next=0 for ((i=1; $i<=$COMP_CWORD; i++)); do - if [[ ${skip_next} -eq 1 ]]; then + if [[ ${skip_next} -eq 1 ]] + then #echo "Skipping" skip_next=0; - elif [[ ${COMP_WORDS[i]} == -* ]]; then + elif [[ ${COMP_WORDS[i]} == -* ]] + then option="${COMP_WORDS[i]}" option_index=${i} - if [[ ${COMP_WORDS[i]} == -- ]]; then + if [[ ${COMP_WORDS[i]} == -- ]] + then break; fi - elif [[ ${COMP_WORDS[i]} == -f ]]; then + elif [[ ${COMP_WORDS[i]} == -f ]] + then skip_next=1 fi done - if [[ $COMP_CWORD -le $cmd_index ]]; then + if [[ $COMP_CWORD -le $cmd_index ]] + then # The user has not specified a command yet COMPREPLY=( ${COMPREPLY[@]:-} $(compgen -W "$(tmux start-server \; list-commands | cut -d' ' -f1)" -- "${cur}") ) else @@ -129,7 +142,8 @@ _tmux() { -t) _tmux_complete_session "${cur}" ;; -[n|d|s]) options="-d -n -s -t --" ;; *) - if [[ ${COMP_WORDS[option_index]} == -- ]]; then + if [[ ${COMP_WORDS[option_index]} == -- ]] + then _command_offset ${option_index} else options="-d -n -s -t --" @@ -174,7 +188,8 @@ _tmux() { fi # command specified fi # not -f - if [[ -n "${options}" ]]; then + if [[ -n "${options}" ]] + then COMPREPLY=( ${COMPREPLY[@]:-} $(compgen -W "${options}" -- "${cur}") ) fi diff --git a/completion/available/vagrant.completion.bash b/completion/available/vagrant.completion.bash index 0803893f..996530bc 100644 --- a/completion/available/vagrant.completion.bash +++ b/completion/available/vagrant.completion.bash @@ -23,7 +23,7 @@ # SOFTWARE. -__pwdln() { +function __pwdln() { pwdmod="${PWD}/" itr=0 until [[ -z "$pwdmod" ]];do @@ -33,7 +33,7 @@ __pwdln() { echo -n $(($itr-1)) } -__vagrantinvestigate() { +function __vagrantinvestigate() { if [ -f "${PWD}/.vagrant" -o -d "${PWD}/.vagrant" ];then echo "${PWD}/.vagrant" return 0 @@ -50,7 +50,7 @@ __vagrantinvestigate() { return 1 } -_vagrant() { +function _vagrant() { cur="${COMP_WORDS[COMP_CWORD]}" prev="${COMP_WORDS[COMP_CWORD-1]}" commands="box cloud destroy global-status halt help hostmanager init login package plugin port powershell provision push rdp reload resume scp snapshot ssh ssh-config status suspend up upload validate vbguest version winrm winrm-config" @@ -119,7 +119,8 @@ _vagrant() { action="${COMP_WORDS[COMP_CWORD-2]}" case "$action" in "up") - if [ "$prev" == "--no-provision" ]; then + if [ "$prev" == "--no-provision" ] + then COMPREPLY=($(compgen -W "${vm_list}" -- ${cur})) return 0 fi @@ -135,7 +136,8 @@ _vagrant() { esac ;; "snapshot") - if [ "$prev" == "restore" ]; then + if [ "$prev" == "restore" ] + then COMPREPLY=($(compgen -W "${vm_list}" -- ${cur})) return 0 fi @@ -149,7 +151,8 @@ _vagrant() { prev="${COMP_WORDS[COMP_CWORD-2]}" case "$action" in "snapshot") - if [ "$prev" == "restore" ]; then + if [ "$prev" == "restore" ] + then local snapshot_list="$(vagrant snapshot list ${cur} 2>/dev/null | awk '{ORS=" "} /==>/ {next} {print}')" COMPREPLY=($(compgen -W "${snapshot_list}" -- ${cur})) return 0 diff --git a/completion/available/vault.completion.bash b/completion/available/vault.completion.bash index 9520f166..029463ca 100644 --- a/completion/available/vault.completion.bash +++ b/completion/available/vault.completion.bash @@ -2,6 +2,7 @@ cite "about-completion" about-completion "vault completion" -if _binary_exists vault; then +if _binary_exists vault + then complete -C vault vault fi diff --git a/completion/available/virtualbox.completion.bash b/completion/available/virtualbox.completion.bash index 3c29437f..a5d8327d 100644 --- a/completion/available/virtualbox.completion.bash +++ b/completion/available/virtualbox.completion.bash @@ -1,10 +1,10 @@ #!/usr/bin/bash -_vboxmanage_realopts() { +function _vboxmanage_realopts() { echo $(vboxmanage|grep -i vboxmanage|cut -d' ' -f2|grep '\['|tr -s '[\[\|\]\n' ' ') echo " " } -__vboxmanage_startvm() { +function __vboxmanage_startvm() { RUNNING=$(vboxmanage list runningvms | cut -d' ' -f1 | tr -d '"') TOTAL=$(vboxmanage list vms | cut -d' ' -f1 | tr -d '"') @@ -12,7 +12,8 @@ __vboxmanage_startvm() { for VM in $TOTAL; do MATCH=0; for RUN in $RUNNING "x"; do - if [ "$VM" == "$RUN" ]; then + if [ "$VM" == "$RUN" ] + then MATCH=1 fi done @@ -21,11 +22,12 @@ __vboxmanage_startvm() { echo $AVAILABLE } -__vboxmanage_list() { +function __vboxmanage_list() { INPUT=$(vboxmanage list | tr -s '[\[\]\|\n]' ' ' | cut -d' ' -f4-) PRUNED="" - if [ "$1" == "long" ]; then + if [ "${1}" == "long" ] + then for WORD in $INPUT; do [ "$WORD" == "-l" ] && continue; [ "$WORD" == "--long" ] && continue; @@ -40,9 +42,10 @@ __vboxmanage_list() { } -__vboxmanage_list_vms() { +function __vboxmanage_list_vms() { VMS="" - if [ "x$1" == "x" ]; then + if [ "x$1" == "x" ] + then SEPARATOR=" " else SEPARATOR=$1 @@ -56,9 +59,10 @@ __vboxmanage_list_vms() { echo $VMS } -__vboxmanage_list_runningvms() { +function __vboxmanage_list_runningvms() { VMS="" - if [ "$1" == "" ]; then + if [ "${1}" == "" ] + then SEPARATOR=" " else SEPARATOR=$1 @@ -73,7 +77,7 @@ __vboxmanage_list_runningvms() { } -__vboxmanage_controlvm() { +function __vboxmanage_controlvm() { echo "pause resume reset poweroff savestate acpipowerbutton" echo "acpisleepbutton keyboardputscancode guestmemoryballoon" echo "gueststatisticsinterval usbattach usbdetach vrde vrdeport" @@ -93,7 +97,7 @@ __vboxmanage_controlvm() { } -__vboxmanage_default() { +function __vboxmanage_default() { realopts=$(_vboxmanage_realopts) opts=$realopts$(vboxmanage | grep -i vboxmanage | cut -d' ' -f2 | grep -v '\[' | sort | uniq) pruned="" @@ -113,23 +117,28 @@ __vboxmanage_default() { MATCH=0 for OPT in "${COMP_WORDS[@]}"; do # opts=$(echo ${opts} | grep -v $OPT); - if [ "$OPT" == "$WORD" ]; then + if [ "$OPT" == "$WORD" ] + then MATCH=1 break; fi - if [ "$OPT" == "-v" ] && [ "$WORD" == "--version" ]; then + if [ "$OPT" == "-v" ] && [ "$WORD" == "--version" ] + then MATCH=1 break; fi - if [ "$OPT" == "--version" ] && [ "$WORD" == "-v" ]; then + if [ "$OPT" == "--version" ] && [ "$WORD" == "-v" ] + then MATCH=1 break; fi - if [ "$OPT" == "-q" ] && [ "$WORD" == "--nologo" ]; then + if [ "$OPT" == "-q" ] && [ "$WORD" == "--nologo" ] + then MATCH=1 break; fi - if [ "$OPT" == "--nologo" ] && [ "$WORD" == "-q" ]; then + if [ "$OPT" == "--nologo" ] && [ "$WORD" == "-q" ] + then MATCH=1 break; fi @@ -144,7 +153,7 @@ __vboxmanage_default() { return 0 } -_vboxmanage() { +function _vboxmanage() { # vboxmanage | grep -i vboxmanage | cut -d' ' -f2 | sort | uniq local cur p1 p2 p3 p4 opts COMPREPLY=() @@ -199,7 +208,8 @@ _vboxmanage() { esac for VM in $(__vboxmanage_list_vms); do - if [ "$VM" == "$prev" ]; then + if [ "$VM" == "$prev" ] + then pprev=${COMP_WORDS[COMP_CWORD-2]} # echo "previous: $pprev" case $pprev in diff --git a/completion/available/wpscan.completion.bash b/completion/available/wpscan.completion.bash index 105468a3..79480286 100644 --- a/completion/available/wpscan.completion.bash +++ b/completion/available/wpscan.completion.bash @@ -2,12 +2,18 @@ _command_exists wpscan || return -function __wpscan_completion() { +function __wpscan_completion() +{ + ############ STACK_TRACE_BUILDER ##################### + Function_Name="${FUNCNAME[0]}" + Function_PATH="${Function_PATH}/${Function_Name}" + ###################################################### local _opt_ local OPTS=('--help' '--hh' '--version' '--url' '--ignore-main-redirect' '--verbose' '--output' '--format' '--detection-mode' '--scope' '--headers' '--user-agent' '--vhost' '--random-user-agent' '--user-agents-list' '--http-auth' '--max-threads' '--throttle' '--request-timeout' '--connect-timeout' '--disable-tlc-checks' '--proxy' '--proxy-auth' '--cookie-string' '--cookie-jar' '--cache-ttl' '--clear-cache' '--server' '--cache-dir' '--update' '--no-update' '--wp-content-dir' '--wp-plugins-dir' '--wp-version-detection' '--main-theme-detection' '--enumerate' '--exclude-content-based' '--plugins-list' '--plugins-detection' '--plugins-version-all' '--plugins-version-detection' '--themes-list' '--themes-detection' '--themes-version-all' '--themes-version-detection' '--timthumbs-list' '--timthumbs-detection' '--config-backups-list' '--config-backups-detection' '--db-exports-list' '--db-exports-detection' '--medias-detection' '--users-list' '--users-detection' '--passwords' '--usernames' '--multicall-max-passwords' '--password-attack' '--stealthy') COMPREPLY=() for _opt_ in "${OPTS[@]}"; do - if [[ "$_opt_" == "$2"* ]]; then + if [[ "$_opt_" == "${2}"* ]] + then COMPREPLY+=("$_opt_") fi done diff --git a/docs/Makefile b/docs/Makefile index d4bb2cbb..73a28c71 100644 --- a/docs/Makefile +++ b/docs/Makefile @@ -1,20 +1,20 @@ -# Minimal makefile for Sphinx documentation -# - -# You can set these variables from the command line, and also -# from the environment for the first two. -SPHINXOPTS ?= -SPHINXBUILD ?= sphinx-build -SOURCEDIR = . -BUILDDIR = _build - -# Put it first so that "make" without argument is like "make help". -help: - @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) - -.PHONY: help Makefile - -# Catch-all target: route all unknown targets to Sphinx using the new -# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). -%: Makefile - @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) +# Minimal makefile for Sphinx documentation +# + +# You can set these variables from the command line, and also +# from the environment for the first two. +SPHINXOPTS ?= +SPHINXBUILD ?= sphinx-build +SOURCEDIR = . +BUILDDIR = _build + +# Put it first so that "make" without argument is like "make help". +help: + @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) + +.PHONY: help Makefile + +# Catch-all target: route all unknown targets to Sphinx using the new +# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). +%: Makefile + @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) diff --git a/docs/README.md b/docs/README.md index b307a7ab..267d7930 100644 --- a/docs/README.md +++ b/docs/README.md @@ -1,63 +1,63 @@ -![logo](https://github.com/Bash-it/media/raw/master/media/Bash-it.png) - -![Build Status](../../../workflows/CI/badge.svg?event=push) -![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) - -**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:) - -Includes autocompletion, themes, aliases, custom functions, a few stolen pieces from Steve Losh, and more. - -Bash-it provides a solid framework for using, developing and maintaining shell scripts and custom commands for your daily work. -If you're using the _Bourne Again Shell_ (Bash) regularly and have been looking for an easy way on how to keep all of these nice little scripts and aliases under control, then Bash-it is for you! -Stop polluting your `~/bin` directory and your `.bashrc` file, fork/clone Bash-it and start hacking away. - -- [Main Page](https://bash-it.readthedocs.io/en/latest) -- [Contributing](#contributing) -- [Installation](#installation) - - [Install Options](https://bash-it.readthedocs.io/en/latest/installation/#install-options) - - [via Docker](https://bash-it.readthedocs.io/en/latest/installation/#install-using-docker) - - [Updating](https://bash-it.readthedocs.io/en/latest/installation/#updating) -- [Help](https://bash-it.readthedocs.io/en/latest/misc/#help-screens) -- [Search](https://bash-it.readthedocs.io/en/latest/commands/search) - - [Syntax](https://bash-it.readthedocs.io/en/latest/commands/search/#syntax) - - [Searching with Negations]( - https://bash-it.readthedocs.io/en/latest/commands/search/#searching-with-negations) - - [Using Search to Enable or Disable Components](https://bash-it.readthedocs.io/en/latest/commands/search/#using-search-to-enable-or-disable-components) - - [Disabling ASCII Color](https://bash-it.readthedocs.io/en/latest/commands/search/#disabling-ascii-color) -- [Custom scripts, aliases, themes, and functions]( - https://bash-it.readthedocs.io/en/latest/custom) -- [Themes](https://bash-it.readthedocs.io/en/latest/themes) -- [Uninstalling](https://bash-it.readthedocs.io/en/latest/uninstalling) -- [Misc](https://bash-it.readthedocs.io/en/latest/misc) -- [Help Out](https://bash-it.readthedocs.io/en/latest/#help-out) -- [Contributors](#contributors) - -## Installation - -1) Check out a clone of this repo to a location of your choice, such as - ``git clone --depth=1 https://github.com/Bash-it/bash-it.git ~/.bash_it`` -2) Run ``~/.bash_it/install.sh`` - -That's it! :smiley: - -You can check out more components of Bash-it, and customize it to your desire. -For more information, see detailed instructions [here](https://bash-it.readthedocs.io/en/latest/installation/). - - -## Contributing - -Please take a look at the [Contribution Guidelines](https://bash-it.readthedocs.io/en/latest/contributing) before reporting a bug or providing a new feature. - -The [Development Guidelines](https://bash-it.readthedocs.io/en/latest/development) have more information on some of the internal workings of Bash-it, -please feel free to read through this page if you're interested in how Bash-it loads its components. - -## Contributors - -[List of contributors](https://github.com/Bash-it/bash-it/contributors) - -## License - -Bash-it is licensed under the [MIT License](https://github.com/Bash-it/bash-it/blob/master/LICENSE). +![logo](https://github.com/Bash-it/media/raw/master/media/Bash-it.png) + +![Build Status](../../../workflows/CI/badge.svg?event=push) +![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) + +**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:) + +Includes autocompletion, themes, aliases, custom functions, a few stolen pieces from Steve Losh, and more. + +Bash-it provides a solid framework for using, developing and maintaining shell scripts and custom commands for your daily work. +If you're using the _Bourne Again Shell_ (Bash) regularly and have been looking for an easy way on how to keep all of these nice little scripts and aliases under control, then Bash-it is for you! +Stop polluting your `~/bin` directory and your `.bashrc` file, fork/clone Bash-it and start hacking away. + +- [Main Page](https://bash-it.readthedocs.io/en/latest) +- [Contributing](#contributing) +- [Installation](#installation) + - [Install Options](https://bash-it.readthedocs.io/en/latest/installation/#install-options) + - [via Docker](https://bash-it.readthedocs.io/en/latest/installation/#install-using-docker) + - [Updating](https://bash-it.readthedocs.io/en/latest/installation/#updating) +- [Help](https://bash-it.readthedocs.io/en/latest/misc/#help-screens) +- [Search](https://bash-it.readthedocs.io/en/latest/commands/search) + - [Syntax](https://bash-it.readthedocs.io/en/latest/commands/search/#syntax) + - [Searching with Negations]( + https://bash-it.readthedocs.io/en/latest/commands/search/#searching-with-negations) + - [Using Search to Enable or Disable Components](https://bash-it.readthedocs.io/en/latest/commands/search/#using-search-to-enable-or-disable-components) + - [Disabling ASCII Color](https://bash-it.readthedocs.io/en/latest/commands/search/#disabling-ascii-color) +- [Custom scripts, aliases, themes, and functions]( + https://bash-it.readthedocs.io/en/latest/custom) +- [Themes](https://bash-it.readthedocs.io/en/latest/themes) +- [Uninstalling](https://bash-it.readthedocs.io/en/latest/uninstalling) +- [Misc](https://bash-it.readthedocs.io/en/latest/misc) +- [Help Out](https://bash-it.readthedocs.io/en/latest/#help-out) +- [Contributors](#contributors) + +## Installation + +1) Check out a clone of this repo to a location of your choice, such as + ``git clone --depth=1 https://github.com/Bash-it/bash-it.git ~/.bash_it`` +2) Run ``~/.bash_it/install.sh`` + +That's it! :smiley: + +You can check out more components of Bash-it, and customize it to your desire. +For more information, see detailed instructions [here](https://bash-it.readthedocs.io/en/latest/installation/). + + +## Contributing + +Please take a look at the [Contribution Guidelines](https://bash-it.readthedocs.io/en/latest/contributing) before reporting a bug or providing a new feature. + +The [Development Guidelines](https://bash-it.readthedocs.io/en/latest/development) have more information on some of the internal workings of Bash-it, +please feel free to read through this page if you're interested in how Bash-it loads its components. + +## Contributors + +[List of contributors](https://github.com/Bash-it/bash-it/contributors) + +## License + +Bash-it is licensed under the [MIT License](https://github.com/Bash-it/bash-it/blob/master/LICENSE). diff --git a/docs/commands/doctor.rst b/docs/commands/doctor.rst index 625eff20..f2be30f9 100644 --- a/docs/commands/doctor.rst +++ b/docs/commands/doctor.rst @@ -1,20 +1,20 @@ -.. _doctor: - -Bash-it doctor -^^^^^^^^^^^^^^ - -If you encounter problems with any part of Bash-it, run the following command: - -.. code-block:: bash - - bash-it doctor - -This will reload your bash profile and print out logs of various parts in Bash-it. -Note that this command at default will print all logs, including debug logs. -You can call it like this: - -.. code-block:: bash - - bash-it doctor [errors/warnings/all] - -In order to get wanted verbosity. +.. _doctor: + +Bash-it doctor +^^^^^^^^^^^^^^ + +If you encounter problems with any part of Bash-it, run the following command: + +.. code-block:: bash + + bash-it doctor + +This will reload your bash profile and print out logs of various parts in Bash-it. +Note that this command at default will print all logs, including debug logs. +You can call it like this: + +.. code-block:: bash + + bash-it doctor [errors/warnings/all] + +In order to get wanted verbosity. diff --git a/docs/commands/index.rst b/docs/commands/index.rst index 3890a139..3e36d58c 100644 --- a/docs/commands/index.rst +++ b/docs/commands/index.rst @@ -1,16 +1,16 @@ -.. _commands: - -Bash-it Commands -================ - -**Bash-it** boasts a wide range of available commands. -You should be familiar with them in order to fully utilize Bash-it. - -.. toctree:: - :maxdepth: 1 - - update - search - reload - doctor - profile +.. _commands: + +Bash-it Commands +================ + +**Bash-it** boasts a wide range of available commands. +You should be familiar with them in order to fully utilize Bash-it. + +.. toctree:: + :maxdepth: 1 + + update + search + reload + doctor + profile diff --git a/docs/commands/profile.rst b/docs/commands/profile.rst index 67ca9b5b..1851f7a6 100644 --- a/docs/commands/profile.rst +++ b/docs/commands/profile.rst @@ -1,31 +1,31 @@ -.. _profile: - -Bash-it Profile ---------------- - -Have you ever wanted to port your *Bash-it* configuration into another machine? - -If you did, then ``bash-it profile`` is for you! - -This command can save and load custom *"profile"* files, that can be later -used to load and recreate your configuration, in any machine you would like |:smile:| - -When porting your configuration into a new machine, you just need to save your current profile, copy the resulting *"profile"* file, and load it in the other machine. - -Example -^^^^^^^ - -.. code-block:: bash - - # Saves your current profile - bash-it profile save my_profile - # Load the default profile, which is the one used in the default installation. - bash-it profile load default - - # Do whatever you want: - # Disable stuff - bash-it disable ... - # Enable stuff - bash-it enable ... - # If you want to get back into your original configuration, you can do it easily - bash-it profile load my_profile +.. _profile: + +Bash-it Profile +--------------- + +Have you ever wanted to port your *Bash-it* configuration into another machine? + +If you did, then ``bash-it profile`` is for you! + +This command can save and load custom *"profile"* files, that can be later +used to load and recreate your configuration, in any machine you would like |:smile:| + +When porting your configuration into a new machine, you just need to save your current profile, copy the resulting *"profile"* file, and load it in the other machine. + +Example +^^^^^^^ + +.. code-block:: bash + + # Saves your current profile + bash-it profile save my_profile + # Load the default profile, which is the one used in the default installation. + bash-it profile load default + + # Do whatever you want: + # Disable stuff + bash-it disable ... + # Enable stuff + bash-it enable ... + # If you want to get back into your original configuration, you can do it easily + bash-it profile load my_profile diff --git a/docs/commands/reload.rst b/docs/commands/reload.rst index 03a7064c..9ef9c4da 100644 --- a/docs/commands/reload.rst +++ b/docs/commands/reload.rst @@ -1,23 +1,23 @@ -.. _reload: - -Bash-it reload -^^^^^^^^^^^^^^ - -Bash-it creates a ``reload`` alias that makes it convenient to reload -your Bash profile when you make changes. - -Additionally, if you export ``BASH_IT_AUTOMATIC_RELOAD_AFTER_CONFIG_CHANGE`` as a non-null value, -Bash-it will automatically reload itself after activating or deactivating plugins, aliases, or completions. - -.. warning:: - When changing theme, do not use ``bash-it reload``. Instead, use :ref:`restart`. - -.. _restart: - -Bash-it restart -^^^^^^^^^^^^^^^ - -Similar to :ref:`reload`, ``bash-it restart`` can be used to restart your shell. -Instead of reloading your Bash profile, this command re-runs Bash (using exec). - -This is stronger than simple reload, and is similar to the effect of closing and reopening your terminal. +.. _reload: + +Bash-it reload +^^^^^^^^^^^^^^ + +Bash-it creates a ``reload`` alias that makes it convenient to reload +your Bash profile when you make changes. + +Additionally, if you export ``BASH_IT_AUTOMATIC_RELOAD_AFTER_CONFIG_CHANGE`` as a non-null value, +Bash-it will automatically reload itself after activating or deactivating plugins, aliases, or completions. + +.. warning:: + When changing theme, do not use ``bash-it reload``. Instead, use :ref:`restart`. + +.. _restart: + +Bash-it restart +^^^^^^^^^^^^^^^ + +Similar to :ref:`reload`, ``bash-it restart`` can be used to restart your shell. +Instead of reloading your Bash profile, this command re-runs Bash (using exec). + +This is stronger than simple reload, and is similar to the effect of closing and reopening your terminal. diff --git a/docs/commands/search.rst b/docs/commands/search.rst index 1b455f22..360a1acd 100644 --- a/docs/commands/search.rst +++ b/docs/commands/search.rst @@ -1,59 +1,59 @@ -.. _searching: - -Bash-it search --------------- - -If you need to quickly find out which of the plugins, aliases or completions are available for a specific framework, programming language, or an environment, you can *search* for multiple terms related to the commands you use frequently. -Search will find and print out modules with the name or description matching the terms provided. - -Syntax -^^^^^^ - -.. code-block:: bash - - bash-it search term1 [[-]term2] [[-]term3].... - -As an example, a ruby developer might want to enable everything related to the commands such as ``ruby``\ , ``rake``\ , ``gem``\ , ``bundler``\ , and ``rails``. -Search command helps you find related modules so that you can decide which of them you'd like to use: - -.. code-block:: bash - - ❯ bash-it search ruby rake gem bundle irb rails - aliases: bundler rails - plugins: chruby chruby-auto ruby - completions: bundler gem rake - -Currently enabled modules will be shown in green. - -Searching with Negations -^^^^^^^^^^^^^^^^^^^^^^^^ - -You can prefix a search term with a "-" to exclude it from the results. -In the above example, if we wanted to hide ``chruby`` and ``chruby-auto``\ , -we could change the command as follows: - -.. code-block:: bash - - ❯ bash-it search ruby rake gem bundle irb rails -chruby - aliases: bundler rails - plugins: ruby - completions: bundler gem rake - -Using Search to Enable or Disable Components -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -By adding a ``--enable`` or ``--disable`` to the search command, you can automatically enable all modules that come up as a result of a search query. -This could be quite handy if you like to enable a bunch of components related to the same topic. - -Disabling ASCII Color -^^^^^^^^^^^^^^^^^^^^^ - -To remove non-printing non-ASCII characters responsible for the coloring of the search output, you can set environment variable ``NO_COLOR``. -Enabled components will then be shown with a checkmark: - -.. code-block:: bash - - ❯ NO_COLOR=1 bash-it search ruby rake gem bundle irb rails -chruby - aliases => ✓bundler ✓rails - plugins => ✓ruby - completions => bundler gem rake +.. _searching: + +Bash-it search +-------------- + +If you need to quickly find out which of the plugins, aliases or completions are available for a specific framework, programming language, or an environment, you can *search* for multiple terms related to the commands you use frequently. +Search will find and print out modules with the name or description matching the terms provided. + +Syntax +^^^^^^ + +.. code-block:: bash + + bash-it search term1 [[-]term2] [[-]term3].... + +As an example, a ruby developer might want to enable everything related to the commands such as ``ruby``\ , ``rake``\ , ``gem``\ , ``bundler``\ , and ``rails``. +Search command helps you find related modules so that you can decide which of them you'd like to use: + +.. code-block:: bash + + ❯ bash-it search ruby rake gem bundle irb rails + aliases: bundler rails + plugins: chruby chruby-auto ruby + completions: bundler gem rake + +Currently enabled modules will be shown in green. + +Searching with Negations +^^^^^^^^^^^^^^^^^^^^^^^^ + +You can prefix a search term with a "-" to exclude it from the results. +In the above example, if we wanted to hide ``chruby`` and ``chruby-auto``\ , +we could change the command as follows: + +.. code-block:: bash + + ❯ bash-it search ruby rake gem bundle irb rails -chruby + aliases: bundler rails + plugins: ruby + completions: bundler gem rake + +Using Search to Enable or Disable Components +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +By adding a ``--enable`` or ``--disable`` to the search command, you can automatically enable all modules that come up as a result of a search query. +This could be quite handy if you like to enable a bunch of components related to the same topic. + +Disabling ASCII Color +^^^^^^^^^^^^^^^^^^^^^ + +To remove non-printing non-ASCII characters responsible for the coloring of the search output, you can set environment variable ``NO_COLOR``. +Enabled components will then be shown with a checkmark: + +.. code-block:: bash + + ❯ NO_COLOR=1 bash-it search ruby rake gem bundle irb rails -chruby + aliases => ✓bundler ✓rails + plugins => ✓ruby + completions => bundler gem rake diff --git a/docs/commands/update.rst b/docs/commands/update.rst index 92db60fb..57398d1a 100644 --- a/docs/commands/update.rst +++ b/docs/commands/update.rst @@ -1,38 +1,38 @@ -.. _update: - -Bash-it update -^^^^^^^^^^^^^^ - -To update Bash-it to the latest stable version, simply run: - -.. code-block:: bash - - bash-it update stable - -If you want to update to the latest dev version (directly from master), run: - -.. code-block:: bash - - bash-it update dev - -If you want to update automatically and unattended, you can add the optional -``-s/--silent`` flag, for example: - -.. code-block:: bash - - bash-it update dev --silent - -.. _migrate: - -Bash-it migrate -^^^^^^^^^^^^^^^ - -If you are using an older version of Bash-it, it's possible that some functionality has changed, or that the internal structure of how Bash-it organizes its functionality has been updated. -For these cases, we provide a ``migrate`` command: - -.. code-block:: bash - - bash-it migrate - -This command will automatically migrate the Bash-it structure to the latest version. -The ``migrate`` command is run automatically if you run the ``update``\ , ``enable`` or ``disable`` commands. +.. _update: + +Bash-it update +^^^^^^^^^^^^^^ + +To update Bash-it to the latest stable version, simply run: + +.. code-block:: bash + + bash-it update stable + +If you want to update to the latest dev version (directly from master), run: + +.. code-block:: bash + + bash-it update dev + +If you want to update automatically and unattended, you can add the optional +``-s/--silent`` flag, for example: + +.. code-block:: bash + + bash-it update dev --silent + +.. _migrate: + +Bash-it migrate +^^^^^^^^^^^^^^^ + +If you are using an older version of Bash-it, it's possible that some functionality has changed, or that the internal structure of how Bash-it organizes its functionality has been updated. +For these cases, we provide a ``migrate`` command: + +.. code-block:: bash + + bash-it migrate + +This command will automatically migrate the Bash-it structure to the latest version. +The ``migrate`` command is run automatically if you run the ``update``\ , ``enable`` or ``disable`` commands. diff --git a/docs/conf.py b/docs/conf.py index f96485c6..9b02a7b7 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -1,54 +1,54 @@ -# Configuration file for the Sphinx documentation builder. -# -# This file only contains a selection of the most common options. For a full -# list see the documentation: -# https://www.sphinx-doc.org/en/master/usage/configuration.html - -# -- Path setup -------------------------------------------------------------- - -# If extensions (or modules to document with autodoc) are in another directory, -# add these directories to sys.path here. If the directory is relative to the -# documentation root, use os.path.abspath to make it absolute, like shown here. -# -# import os -# import sys -# sys.path.insert(0, os.path.abspath('.')) - -# -- Project information ----------------------------------------------------- - -project = 'Bash-it' -copyright = '2020, Bash-it Team' -author = 'Bash-it Team' - -# The full version, including alpha/beta/rc tags -release = '' - -# -- General configuration --------------------------------------------------- - -# Add any Sphinx extension module names here, as strings. They can be -# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom -# ones. -extensions = [ - 'sphinx_rtd_theme', - 'sphinxemoji.sphinxemoji', -] - -# Add any paths that contain templates here, relative to this directory. -templates_path = ['_templates'] - -# 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', "venv"] - -# -- Options for HTML output ------------------------------------------------- - -# The theme to use for HTML and HTML Help pages. See the documentation for -# a list of builtin themes. -# -html_theme = 'sphinx_rtd_theme' - -# Add any paths that contain custom static files (such as style sheets) here, -# relative to this directory. They are copied after the builtin static files, -# so a file named "default.css" will overwrite the builtin "default.css". -html_static_path = ['_static'] +# Configuration file for the Sphinx documentation builder. +# +# This file only contains a selection of the most common options. For a full +# list see the documentation: +# https://www.sphinx-doc.org/en/master/usage/configuration.html + +# -- Path setup -------------------------------------------------------------- + +# If extensions (or modules to document with autodoc) are in another directory, +# add these directories to sys.path here. If the directory is relative to the +# documentation root, use os.path.abspath to make it absolute, like shown here. +# +# import os +# import sys +# sys.path.insert(0, os.path.abspath('.')) + +# -- Project information ----------------------------------------------------- + +project = 'Bash-it' +copyright = '2020, Bash-it Team' +author = 'Bash-it Team' + +# The full version, including alpha/beta/rc tags +release = '' + +# -- General configuration --------------------------------------------------- + +# Add any Sphinx extension module names here, as strings. They can be +# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom +# ones. +extensions = [ + 'sphinx_rtd_theme', + 'sphinxemoji.sphinxemoji', +] + +# Add any paths that contain templates here, relative to this directory. +templates_path = ['_templates'] + +# 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', "venv"] + +# -- Options for HTML output ------------------------------------------------- + +# The theme to use for HTML and HTML Help pages. See the documentation for +# a list of builtin themes. +# +html_theme = 'sphinx_rtd_theme' + +# Add any paths that contain custom static files (such as style sheets) here, +# relative to this directory. They are copied after the builtin static files, +# so a file named "default.css" will overwrite the builtin "default.css". +html_static_path = ['_static'] diff --git a/docs/contributing.rst b/docs/contributing.rst index 79d8ed1c..21bb2873 100644 --- a/docs/contributing.rst +++ b/docs/contributing.rst @@ -1,115 +1,115 @@ -.. _contributing: - -Contribution Guidelines -======================= - -When contributing a new feature, a bug fix, a new theme, or any other change to Bash-it, please consider the following guidelines. -Most of this is common sense, but please try to stick to the conventions listed here. - -Issues ------- - - -* When reporting a bug or requesting a new feature, consider providing a Pull Request that fixes the issue or can be used as a starting point for the new feature. - Don't be afraid, most things aren't that complex... - -Pull Requests -------------- - - -* Fork the Bash-it repo, create a new feature branch from *master* and apply your changes there. - Create a *Pull Request* from your feature branch against Bash-it's *master* branch. -* Limit each Pull Request to one feature. - Don't bundle multiple features/changes (e.g. a new *Theme* and a fix to an existing plugin) into a single Pull Request - create one PR for the theme, and a separate PR for the fix. -* For complex changes, try to *squash* your changes into a single commit before - pushing code. Once you've pushed your code and opened a PR, please refrain - from force-pushing changes to the PR branch – remember, Bash-it is a - distributed project and your branch may be in use already. -* When in doubt, open a PR with too many commits. Bash-it is a learning project - for everyone involved. Showing your work provides a great history for folks - to learn what works and what didn't. - -Code Style ----------- - - -* When adding new files, be sure to add them into `clean_files.txt`, which is a growing list of linted files in the project. -* When changing existing files, consider also adding them into `clean_files.txt` and fixing the linting errors that arise. See :ref:`linting_your_changes` for more information. -* Indentation is using tabs, not spaces. Most of the code is indented with 2 spaces, some with 4 spaced tabs. Please try to stick to tabs. - If you're using an editor that supports `EditorConfig `_\ , the editor should automatically use the settings defined in Bash-it's `.editorconfig file <.editorconfig>`_. -* Prefer to invoke commands directly using the ``command`` shell builtin. This way, your code - will always execute the command you wanted and not an alias/function that overrides the name of the command. (For example, use ``command rm`` instead of ``rm``) -* When creating new functions, please use a dash ("-") to separate the words of the function's name, e.g. ``my-new-function``. - Don't use underscores, e.g. ``my_new_function``. -* Internal functions that aren't to be used by the end user should start with an underscore, e.g. ``_my-new-internal-function``. -* Use the provided meta functions to document your code, e.g. ``about-plugin``\ , ``about``\ , ``group``\ , ``param``\ , ``example``. - This will make it easier for other people to use your new functionality. - Take a look at the existing code for an example (e.g. `the base plugin `_\ ). -* When adding files, please use the existing file naming conventions, e.g. plugin files need to end in ``.plugin.bash``. - This is important for the installation functionality. -* When using the ``$BASH_IT`` variable, please always enclose it in double quotes to ensure that the code also works when Bash-it is installed in a directory that contains spaces in its name: ``for f in "${BASH_IT}/plugins/available"/*.bash ; do echo "$f" ; done`` -* Bash-it supports Bash 3.2 and higher. Please don't use features only available in Bash 4, such as associative arrays. - -Unit Tests ----------- - -When adding features or making changes/fixes, please run our growing unit test suite to ensure that you did not break existing functionality. -The test suite does not cover all aspects of Bash-it, but please run it anyway to verify that you did not introduce any regression issues. - -Any code pushed to GitHub as part of a Pull Request will automatically trigger a continuous integration build on `GitHub Actions `_\ , where the test suite is run on both Linux and macOS. -The Pull Request will then show the result of the CI build, indicating whether all tests ran fine, or whether there were issues. -Please pay attention to this, Pull Requests with build issues will not be merged. - -Adding new functionality or changing existing functionality is a good opportunity to increase Bash-it's test coverage. -When you're changing the Bash-it codebase, please consider adding some unit tests that cover the new or changed functionality. -Ideally, when fixing a bug, a matching unit test that verifies that the bug is no longer present, is added at the same time. - -To run the test suite, simply execute the following in the directory where you cloned Bash-it: - -.. code-block:: bash - - test/run - -This command will ensure that the `Bats Test Framework `_ is available in the local ``test_lib`` directory (Bats is included as a Git submodule) and then run the test suite found in the `test `_ folder. -The test script will execute each test in turn, and will print a status for each test case. - -When adding new test cases, please take a look at the existing test cases for examples. - -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 - -When verifying test results, please try to use the ``assert`` functions found in these libraries. - -Features --------- - - -* When adding new completions or plugins, please don't simply copy existing tools into the Bash-it codebase, try to load/integrate the tools instead. - An example is using ``nvm``\ : Instead of copying the existing ``nvm`` script into Bash-it, the ``nvm.plugin.bash`` file tries to load an existing installation of ``nvm``. - This means an additional step for the user (installing ``nvm`` from its own repo, or through a package manager), - but it will also ensure that ``nvm`` can be upgraded in an easy way. - -.. _contributing_theme: - -Themes ------- - - -* When adding a new theme, please include a screenshot and a short description about what makes this theme unique in the Pull Request's description field. - Please do not add theme screenshots to the main PR itself, as they will add unnecessary bloat to the main branch in the repo. - The project's docs has a `Themes page `_ where you should add a screenshot, see how :ref:`here`. -* Ideally, you should add a ``.rst`` file describing the theme and its configuration options to ``docs/themes-list`` folder. - -.. _add_screenshot: - -Adding a Screenshot -------------------- - -In order to add a new screenshot, use the ``gh-pages`` branch. -Add your new screenshot to the ``docs/images`` folder, and open a PR. -In the `Themes page `_, see the other screenshots to know what kind of link you should use. +.. _contributing: + +Contribution Guidelines +======================= + +When contributing a new feature, a bug fix, a new theme, or any other change to Bash-it, please consider the following guidelines. +Most of this is common sense, but please try to stick to the conventions listed here. + +Issues +------ + + +* When reporting a bug or requesting a new feature, consider providing a Pull Request that fixes the issue or can be used as a starting point for the new feature. + Don't be afraid, most things aren't that complex... + +Pull Requests +------------- + + +* Fork the Bash-it repo, create a new feature branch from *master* and apply your changes there. + Create a *Pull Request* from your feature branch against Bash-it's *master* branch. +* Limit each Pull Request to one feature. + Don't bundle multiple features/changes (e.g. a new *Theme* and a fix to an existing plugin) into a single Pull Request - create one PR for the theme, and a separate PR for the fix. +* For complex changes, try to *squash* your changes into a single commit before + pushing code. Once you've pushed your code and opened a PR, please refrain + from force-pushing changes to the PR branch – remember, Bash-it is a + distributed project and your branch may be in use already. +* When in doubt, open a PR with too many commits. Bash-it is a learning project + for everyone involved. Showing your work provides a great history for folks + to learn what works and what didn't. + +Code Style +---------- + + +* When adding new files, be sure to add them into `clean_files.txt`, which is a growing list of linted files in the project. +* When changing existing files, consider also adding them into `clean_files.txt` and fixing the linting errors that arise. See :ref:`linting_your_changes` for more information. +* Indentation is using tabs, not spaces. Most of the code is indented with 2 spaces, some with 4 spaced tabs. Please try to stick to tabs. + If you're using an editor that supports `EditorConfig `_\ , the editor should automatically use the settings defined in Bash-it's `.editorconfig file <.editorconfig>`_. +* Prefer to invoke commands directly using the ``command`` shell builtin. This way, your code + will always execute the command you wanted and not an alias/function that overrides the name of the command. (For example, use ``command rm`` instead of ``rm``) +* When creating new functions, please use a dash ("-") to separate the words of the function's name, e.g. ``my-new-function``. + Don't use underscores, e.g. ``my_new_function``. +* Internal functions that aren't to be used by the end user should start with an underscore, e.g. ``_my-new-internal-function``. +* Use the provided meta functions to document your code, e.g. ``about-plugin``\ , ``about``\ , ``group``\ , ``param``\ , ``example``. + This will make it easier for other people to use your new functionality. + Take a look at the existing code for an example (e.g. `the base plugin `_\ ). +* When adding files, please use the existing file naming conventions, e.g. plugin files need to end in ``.plugin.bash``. + This is important for the installation functionality. +* When using the ``$BASH_IT`` variable, please always enclose it in double quotes to ensure that the code also works when Bash-it is installed in a directory that contains spaces in its name: ``for f in "${BASH_IT}/plugins/available"/*.bash ; do echo "$f" ; done`` +* Bash-it supports Bash 3.2 and higher. Please don't use features only available in Bash 4, such as associative arrays. + +Unit Tests +---------- + +When adding features or making changes/fixes, please run our growing unit test suite to ensure that you did not break existing functionality. +The test suite does not cover all aspects of Bash-it, but please run it anyway to verify that you did not introduce any regression issues. + +Any code pushed to GitHub as part of a Pull Request will automatically trigger a continuous integration build on `GitHub Actions `_\ , where the test suite is run on both Linux and macOS. +The Pull Request will then show the result of the CI build, indicating whether all tests ran fine, or whether there were issues. +Please pay attention to this, Pull Requests with build issues will not be merged. + +Adding new functionality or changing existing functionality is a good opportunity to increase Bash-it's test coverage. +When you're changing the Bash-it codebase, please consider adding some unit tests that cover the new or changed functionality. +Ideally, when fixing a bug, a matching unit test that verifies that the bug is no longer present, is added at the same time. + +To run the test suite, simply execute the following in the directory where you cloned Bash-it: + +.. code-block:: bash + + test/run + +This command will ensure that the `Bats Test Framework `_ is available in the local ``test_lib`` directory (Bats is included as a Git submodule) and then run the test suite found in the `test `_ folder. +The test script will execute each test in turn, and will print a status for each test case. + +When adding new test cases, please take a look at the existing test cases for examples. + +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 + +When verifying test results, please try to use the ``assert`` functions found in these libraries. + +Features +-------- + + +* When adding new completions or plugins, please don't simply copy existing tools into the Bash-it codebase, try to load/integrate the tools instead. + An example is using ``nvm``\ : Instead of copying the existing ``nvm`` script into Bash-it, the ``nvm.plugin.bash`` file tries to load an existing installation of ``nvm``. + This means an additional step for the user (installing ``nvm`` from its own repo, or through a package manager), + but it will also ensure that ``nvm`` can be upgraded in an easy way. + +.. _contributing_theme: + +Themes +------ + + +* When adding a new theme, please include a screenshot and a short description about what makes this theme unique in the Pull Request's description field. + Please do not add theme screenshots to the main PR itself, as they will add unnecessary bloat to the main branch in the repo. + The project's docs has a `Themes page `_ where you should add a screenshot, see how :ref:`here`. +* Ideally, you should add a ``.rst`` file describing the theme and its configuration options to ``docs/themes-list`` folder. + +.. _add_screenshot: + +Adding a Screenshot +------------------- + +In order to add a new screenshot, use the ``gh-pages`` branch. +Add your new screenshot to the ``docs/images`` folder, and open a PR. +In the `Themes page `_, see the other screenshots to know what kind of link you should use. diff --git a/docs/custom.rst b/docs/custom.rst index 5da41592..78991cc2 100644 --- a/docs/custom.rst +++ b/docs/custom.rst @@ -1,18 +1,18 @@ -.. _custom: - -Custom Content --------------- - -For custom scripts, and aliases, just create the following files (they'll be ignored by the git repo): - - -* ``aliases/custom.aliases.bash`` -* ``completion/custom.completion.bash`` -* ``lib/custom.bash`` -* ``plugins/custom.plugins.bash`` -* ``custom/themes//.theme.bash`` - -Anything in the custom directory will be ignored, with the exception of ``custom/example.bash``. - -Alternately, if you would like to keep your custom scripts under version control, you can set ``BASH_IT_CUSTOM`` in your ``~/.bashrc`` to another location outside of the ``$BASH_IT`` folder. -In this case, any ``*.bash`` file under every directory below ``BASH_IT_CUSTOM`` folder will be used. +.. _custom: + +Custom Content +-------------- + +For custom scripts, and aliases, just create the following files (they'll be ignored by the git repo): + + +* ``aliases/custom.aliases.bash`` +* ``completion/custom.completion.bash`` +* ``lib/custom.bash`` +* ``plugins/custom.plugins.bash`` +* ``custom/themes//.theme.bash`` + +Anything in the custom directory will be ignored, with the exception of ``custom/example.bash``. + +Alternately, if you would like to keep your custom scripts under version control, you can set ``BASH_IT_CUSTOM`` in your ``~/.bashrc`` to another location outside of the ``$BASH_IT`` folder. +In this case, any ``*.bash`` file under every directory below ``BASH_IT_CUSTOM`` folder will be used. diff --git a/docs/development.rst b/docs/development.rst index 4742e971..4e965ff1 100644 --- a/docs/development.rst +++ b/docs/development.rst @@ -1,180 +1,180 @@ -.. _development: - -Bash-it Development -=================== - -This page summarizes a couple of rules to keep in mind when developing features or making changes in Bash-it. - -Testing -------- - -Make sure to read the :ref:`testing docs`. - -Debugging and Logging ---------------------- - -General Logging -^^^^^^^^^^^^^^^ - -While developing feature or making changes in general, you can log error/warning/debug -using ``_log_error`` ``_log_warning`` and ``_log_debug``. This will help you solve problems quicker -and also propagate important notes to other users of Bash-it. -You can see the logs by using ``bash-it doctor`` command to reload and see the logs. -Alternatively, you can set ``BASH_IT_LOG_LEVEL`` to ``BASH_IT_LOG_LEVEL_ERROR``\ , ``BASH_IT_LOG_LEVEL_WARNING`` or ``BASH_IT_LOG_LEVEL_ALL``. - -Log Prefix/Context -^^^^^^^^^^^^^^^^^^ - -You can define ``BASH_IT_LOG_PREFIX`` in your files in order to a have a constant prefix before your logs. -Note that we prefer to uses "tags" based logging, i.e ``plugins: git: DEBUG: Loading git plugin``. - -Load Order ----------- - -General Load Order -^^^^^^^^^^^^^^^^^^ - -The main ``bash_it.sh`` script loads the frameworks individual components in the following order: - - - - -* ``vendor/github.com/erichs/composure/composure.sh`` -* ``lib/log.bash`` -* ``vendor/init.d/*.bash`` -* Files in ``lib`` with the exception of ``appearance.bash`` - this means that ``log.bash`` is loaded again here (possible improvement?) -* Enabled ``aliases`` -* Enabled ``plugins`` -* Enabled ``completions`` -* ``themes/colors.theme.bash`` -* ``themes/base.theme.bash`` -* ``lib/appearance.bash``\ , which loads the selected theme -* Custom ``aliases`` -* Custom ``plugins`` -* Custom ``completions`` -* Additional custom files from either ``$BASH_IT/custom`` or ``$BASH_IT_CUSTOM`` - -This order is subject to change. - -Individual Component Load Order -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -For ``aliases``\ , ``plugins`` and ``completions``\ , the following rules are applied that influence the load order: - - -* There is a global ``enabled`` directory, which the enabled components are linked into. Enabled plugins are symlinked from ``$BASH_IT/plugins/available`` to ``$BASH_IT/enabled`` for example. All component types are linked into the same common ``$BASH_IT/enabled`` directory. -* Within the common ``enabled`` directories, the files are loaded in alphabetical order, which is based on the item's load priority (see next item). -* When enabling a component, a *load priority* is assigned to the file. The following default priorities are used: - - * Aliases: 150 - * Plugins: 250 - * Completions: 350 - -* When symlinking a component into the ``enabled`` directory, the load priority is used as a prefix for the linked name, separated with three dashes from the name of the component. The ``node.plugin.bash`` would be symlinked to ``250---node.plugin.bash`` for example. -* - Each file can override the default load priority by specifying a new value. To do this, the file needs to include a comment in the following form. This example would cause the ``node.plugin.bash`` (if included in that file) to be linked to ``225---node.plugin.bash``\ : - - .. code-block:: bash - - # BASH_IT_LOAD_PRIORITY: 225 - -Having the order based on a numeric priority in a common directory allows for more flexibility. While in general, aliases are loaded first (since their default priority is 150), it's possible to load some aliases after the plugins, or some plugins after completions by setting the items' load priority. This is more flexible than a fixed type-based order or a strict alphabetical order based on name. - -These items are subject to change. When making changes to the internal functionality, this page needs to be updated as well. - -Working with vendored libs --------------------------- - -Vendored libs are external libraries, meaning source code not maintained by Bash-it -developers. -They are ``git subtrees`` curated in the ``vendor/`` folder. To ease the work with git -vendored libs as subtrees we use the `git-vendor `_ tool. -The `original repo `_ for git vendor is -unmaintained so for now we are recommending Tyrben's fork. - -For more information on ``git vendor`` there are a short `usage description `_ -in the repositories ``README`` file and a website for the original repository has a `manual page `_ which is also included in both -repositories. - -To support a flexible loading of external libraries, a file unique to the vendored -library must be placed in ``vendor/init.d/`` with the ``.bash`` extension. - -Rebasing a feature branch with an added/updated vendored library -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -If your feature branch with a newly added/updated vendored lib has fallen behind master -you might need to rebase it before creating a PR. However rebasing with dangling -subtree commits can cause problems. -The following rebase strategy will pause the rebase at the point where you added a -subtree and let you add it again before continuing the rebasing. - -:: - - [feature/branch] $ git rebase --rebase-merges --strategy subtree master - fatal: refusing to merge unrelated histories - Could not apply 0d6a56b... Add-preexec-from-https-github-com-rcaloras-bash-preexec-0-4-1- # Add "preexec" from "https://github.com/rcaloras/bash-preexec@0.4.1" - [feature/branch] $ git vendor add preexec https://github.com/rcaloras/bash-preexec 0.4.1 - ... - [feature/branch] $ git rebase --continue - -If rebasing makes you a little uneasy (as it probably should). You can always test in -another branch. - -:: - - [feater/branch] $ git checkout -b feature/branch-test-rebase - [feater/branch-test-rebase] $ git rebase --rebase-merges --strategy subtree master - ... - -Afterwards you can make sure the rebase was successful by running ``git vendor list`` -to see if your library is still recognized as a vendored lib - -:: - - [feature/branch] $ git vendor list - preexec@0.4.1: - name: preexec - dir: vendor/github.com/rcaloras/bash-preexec - repo: https://github.com/rcaloras/bash-preexec - ref: 0.4.1 - commit: 8fe585c5cf377a3830b895fe26e694b020d8db1a - [feature/branch] $ - - -Plugin Disable Callbacks ------------------------- - -Plugins can define a function that will be called when the plugin is being disabled. -The callback name should be ``{PLUGIN_NAME}_on_disable``\ , you can see ``gitstatus`` for usage example. - -Library Finalization Callback ------------------------------ - -Specifically for Bash-it library code, e.g. in the `lib` subdirectory, a hook is available to run some code at the very end of the main loader script after all other code has been loaded. For example, `lib/theme` uses `_bash_it_library_finalize_hook+=('_bash_it_appearance_scm_init')` to add a function to be called after all plugins have been loaded. - -Using the pre-commit hook -------------------------- - -Note the file .pre-commit-config.yaml at the top of the repo. -This file configures the behavior of the a pre-commit hook based on `the Pre-Commit framework `_. Please see the site about -installing it (with pip, brew or other tools) then run ``pre-commit install`` in the repo's root to activate the hook. -For the full use of the tool, you may need to install also other third-party tools, such as -`shellcheck `_ and `shfmt `_. - - -.. _linting_your_changes: - -Linting Your Changes --------------------- - -In order to properly lint your changes, you should use our linting script, -by simply running ``./lint_clean_files.sh``. This script iterates over all marked-as-clean -files, and runs the pre-commit hook on them. - -Please note that most of the files in the project are currently not linted, -as we want to make the linting process easier. -In order to add your changed/added files to the linting process, -please add your files to ``clean_files.txt``. This way ``lint_clean_files.sh`` -will know to pick them up and lint them. - -Thank you for helping clean up Bash-it, and making it a nicer and better project |:heart:| +.. _development: + +Bash-it Development +=================== + +This page summarizes a couple of rules to keep in mind when developing features or making changes in Bash-it. + +Testing +------- + +Make sure to read the :ref:`testing docs`. + +Debugging and Logging +--------------------- + +General Logging +^^^^^^^^^^^^^^^ + +While developing feature or making changes in general, you can log error/warning/debug +using ``_log_error`` ``_log_warning`` and ``_log_debug``. This will help you solve problems quicker +and also propagate important notes to other users of Bash-it. +You can see the logs by using ``bash-it doctor`` command to reload and see the logs. +Alternatively, you can set ``BASH_IT_LOG_LEVEL`` to ``BASH_IT_LOG_LEVEL_ERROR``\ , ``BASH_IT_LOG_LEVEL_WARNING`` or ``BASH_IT_LOG_LEVEL_ALL``. + +Log Prefix/Context +^^^^^^^^^^^^^^^^^^ + +You can define ``BASH_IT_LOG_PREFIX`` in your files in order to a have a constant prefix before your logs. +Note that we prefer to uses "tags" based logging, i.e ``plugins: git: DEBUG: Loading git plugin``. + +Load Order +---------- + +General Load Order +^^^^^^^^^^^^^^^^^^ + +The main ``bash_it.sh`` script loads the frameworks individual components in the following order: + + + + +* ``vendor/github.com/erichs/composure/composure.sh`` +* ``lib/log.bash`` +* ``vendor/init.d/*.bash`` +* Files in ``lib`` with the exception of ``appearance.bash`` - this means that ``log.bash`` is loaded again here (possible improvement?) +* Enabled ``aliases`` +* Enabled ``plugins`` +* Enabled ``completions`` +* ``themes/colors.theme.bash`` +* ``themes/base.theme.bash`` +* ``lib/appearance.bash``\ , which loads the selected theme +* Custom ``aliases`` +* Custom ``plugins`` +* Custom ``completions`` +* Additional custom files from either ``$BASH_IT/custom`` or ``$BASH_IT_CUSTOM`` + +This order is subject to change. + +Individual Component Load Order +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +For ``aliases``\ , ``plugins`` and ``completions``\ , the following rules are applied that influence the load order: + + +* There is a global ``enabled`` directory, which the enabled components are linked into. Enabled plugins are symlinked from ``$BASH_IT/plugins/available`` to ``$BASH_IT/enabled`` for example. All component types are linked into the same common ``$BASH_IT/enabled`` directory. +* Within the common ``enabled`` directories, the files are loaded in alphabetical order, which is based on the item's load priority (see next item). +* When enabling a component, a *load priority* is assigned to the file. The following default priorities are used: + + * Aliases: 150 + * Plugins: 250 + * Completions: 350 + +* When symlinking a component into the ``enabled`` directory, the load priority is used as a prefix for the linked name, separated with three dashes from the name of the component. The ``node.plugin.bash`` would be symlinked to ``250---node.plugin.bash`` for example. +* + Each file can override the default load priority by specifying a new value. To do this, the file needs to include a comment in the following form. This example would cause the ``node.plugin.bash`` (if included in that file) to be linked to ``225---node.plugin.bash``\ : + + .. code-block:: bash + + # BASH_IT_LOAD_PRIORITY: 225 + +Having the order based on a numeric priority in a common directory allows for more flexibility. While in general, aliases are loaded first (since their default priority is 150), it's possible to load some aliases after the plugins, or some plugins after completions by setting the items' load priority. This is more flexible than a fixed type-based order or a strict alphabetical order based on name. + +These items are subject to change. When making changes to the internal functionality, this page needs to be updated as well. + +Working with vendored libs +-------------------------- + +Vendored libs are external libraries, meaning source code not maintained by Bash-it +developers. +They are ``git subtrees`` curated in the ``vendor/`` folder. To ease the work with git +vendored libs as subtrees we use the `git-vendor `_ tool. +The `original repo `_ for git vendor is +unmaintained so for now we are recommending Tyrben's fork. + +For more information on ``git vendor`` there are a short `usage description `_ +in the repositories ``README`` file and a website for the original repository has a `manual page `_ which is also included in both +repositories. + +To support a flexible loading of external libraries, a file unique to the vendored +library must be placed in ``vendor/init.d/`` with the ``.bash`` extension. + +Rebasing a feature branch with an added/updated vendored library +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +If your feature branch with a newly added/updated vendored lib has fallen behind master +you might need to rebase it before creating a PR. However rebasing with dangling +subtree commits can cause problems. +The following rebase strategy will pause the rebase at the point where you added a +subtree and let you add it again before continuing the rebasing. + +:: + + [feature/branch] $ git rebase --rebase-merges --strategy subtree master + fatal: refusing to merge unrelated histories + Could not apply 0d6a56b... Add-preexec-from-https-github-com-rcaloras-bash-preexec-0-4-1- # Add "preexec" from "https://github.com/rcaloras/bash-preexec@0.4.1" + [feature/branch] $ git vendor add preexec https://github.com/rcaloras/bash-preexec 0.4.1 + ... + [feature/branch] $ git rebase --continue + +If rebasing makes you a little uneasy (as it probably should). You can always test in +another branch. + +:: + + [feater/branch] $ git checkout -b feature/branch-test-rebase + [feater/branch-test-rebase] $ git rebase --rebase-merges --strategy subtree master + ... + +Afterwards you can make sure the rebase was successful by running ``git vendor list`` +to see if your library is still recognized as a vendored lib + +:: + + [feature/branch] $ git vendor list + preexec@0.4.1: + name: preexec + dir: vendor/github.com/rcaloras/bash-preexec + repo: https://github.com/rcaloras/bash-preexec + ref: 0.4.1 + commit: 8fe585c5cf377a3830b895fe26e694b020d8db1a + [feature/branch] $ + + +Plugin Disable Callbacks +------------------------ + +Plugins can define a function that will be called when the plugin is being disabled. +The callback name should be ``{PLUGIN_NAME}_on_disable``\ , you can see ``gitstatus`` for usage example. + +Library Finalization Callback +----------------------------- + +Specifically for Bash-it library code, e.g. in the `lib` subdirectory, a hook is available to run some code at the very end of the main loader script after all other code has been loaded. For example, `lib/theme` uses `_bash_it_library_finalize_hook+=('_bash_it_appearance_scm_init')` to add a function to be called after all plugins have been loaded. + +Using the pre-commit hook +------------------------- + +Note the file .pre-commit-config.yaml at the top of the repo. +This file configures the behavior of the a pre-commit hook based on `the Pre-Commit framework `_. Please see the site about +installing it (with pip, brew or other tools) then run ``pre-commit install`` in the repo's root to activate the hook. +For the full use of the tool, you may need to install also other third-party tools, such as +`shellcheck `_ and `shfmt `_. + + +.. _linting_your_changes: + +Linting Your Changes +-------------------- + +In order to properly lint your changes, you should use our linting script, +by simply running ``./lint_clean_files.sh``. This script iterates over all marked-as-clean +files, and runs the pre-commit hook on them. + +Please note that most of the files in the project are currently not linted, +as we want to make the linting process easier. +In order to add your changed/added files to the linting process, +please add your files to ``clean_files.txt``. This way ``lint_clean_files.sh`` +will know to pick them up and lint them. + +Thank you for helping clean up Bash-it, and making it a nicer and better project |:heart:| diff --git a/docs/help_screens.rst b/docs/help_screens.rst index e071f7df..81c5b0d0 100644 --- a/docs/help_screens.rst +++ b/docs/help_screens.rst @@ -1,13 +1,13 @@ -.. _help_screens: - -Help Screens -^^^^^^^^^^^^ - -.. code-block:: bash - - bash-it show aliases # shows installed and available aliases - bash-it show completions # shows installed and available completions - bash-it show plugins # shows installed and available plugins - bash-it help aliases # shows help for installed aliases - bash-it help completions # shows help for installed completions - bash-it help plugins # shows help for installed plugins +.. _help_screens: + +Help Screens +^^^^^^^^^^^^ + +.. code-block:: bash + + bash-it show aliases # shows installed and available aliases + bash-it show completions # shows installed and available completions + bash-it show plugins # shows installed and available plugins + bash-it help aliases # shows help for installed aliases + bash-it help completions # shows help for installed completions + bash-it help plugins # shows help for installed plugins diff --git a/docs/index.rst b/docs/index.rst index 1fc3a5c2..68fab90c 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -1,44 +1,44 @@ - -Welcome to Bash-it's documentation! -=================================== - -**Bash-it** is a collection of community Bash commands and scripts for Bash 3.2+. -(And a shameless ripoff of `oh-my-zsh `_) - -Includes autocompletion, themes, aliases, custom functions, a few stolen pieces from Steve Losh, and more. - -Bash-it provides a solid framework for using, developing and maintaining shell scripts and custom commands for your daily work. -If you're using the *Bourne Again Shell* (Bash) regularly and have been looking for an easy way on how to keep all of these nice little scripts and aliases under control, then Bash-it is for you! -Stop polluting your ``~/bin`` directory and your ``.bashrc`` file, fork/clone Bash-it and start hacking away. - -.. toctree:: - :maxdepth: 1 - - contributing - development - test - installation - commands/index - custom - themes - themes-list/index - vcs_user - misc - troubleshooting - uninstalling - - -Help out --------- - -We think everyone has their own custom scripts accumulated over time. -And so, following in the footsteps of oh-my-zsh, Bash-it is a framework for easily customizing your Bash shell. -Everyone's got a custom toolbox, so let's start making them even better, **as a community!** - -Send us a pull request and we'll merge it as long as it looks good. -If you change an existing command, please give an explanation why. -That will help a lot when we merge your changes in. - -Please take a look at the :ref:`Contribution Guidelines ` before reporting a bug or providing a new feature. - -Thanks, and happing bashing! + +Welcome to Bash-it's documentation! +=================================== + +**Bash-it** is a collection of community Bash commands and scripts for Bash 3.2+. +(And a shameless ripoff of `oh-my-zsh `_) + +Includes autocompletion, themes, aliases, custom functions, a few stolen pieces from Steve Losh, and more. + +Bash-it provides a solid framework for using, developing and maintaining shell scripts and custom commands for your daily work. +If you're using the *Bourne Again Shell* (Bash) regularly and have been looking for an easy way on how to keep all of these nice little scripts and aliases under control, then Bash-it is for you! +Stop polluting your ``~/bin`` directory and your ``.bashrc`` file, fork/clone Bash-it and start hacking away. + +.. toctree:: + :maxdepth: 1 + + contributing + development + test + installation + commands/index + custom + themes + themes-list/index + vcs_user + misc + troubleshooting + uninstalling + + +Help out +-------- + +We think everyone has their own custom scripts accumulated over time. +And so, following in the footsteps of oh-my-zsh, Bash-it is a framework for easily customizing your Bash shell. +Everyone's got a custom toolbox, so let's start making them even better, **as a community!** + +Send us a pull request and we'll merge it as long as it looks good. +If you change an existing command, please give an explanation why. +That will help a lot when we merge your changes in. + +Please take a look at the :ref:`Contribution Guidelines ` before reporting a bug or providing a new feature. + +Thanks, and happing bashing! diff --git a/docs/installation.rst b/docs/installation.rst index 9688af20..e259348c 100644 --- a/docs/installation.rst +++ b/docs/installation.rst @@ -1,58 +1,59 @@ -.. _installation: - -Installation ------------- - - -#. Check out a clone of this repo to a location of your choice, such as - ``git clone --depth=1 https://github.com/Bash-it/bash-it.git ~/.bash_it`` -#. Run ``~/.bash_it/install.sh`` (it automatically backs up your ``~/.bash_profile`` or ``~/.bashrc``\ , depending on your OS) -#. Edit your modified config (\ ``~/.bash_profile`` or ``~/.bashrc``\ ) file in order to customize Bash-it. -#. Check out available aliases, completions, and plugins and enable the ones you want to use (see the next section for more details). - -Install Options -^^^^^^^^^^^^^^^ - -The install script can take the following options: - - -* ``--interactive``\ : Asks the user which aliases, completions and plugins to enable. -* ``--silent``\ : Ask nothing and install using default settings. -* ``--no-modify-config``\ : Do not modify the existing config file (\ ``~/.bash_profile`` or ``~/.bashrc``\ ). -* ``--append-to-config``\ : Back up existing config file and append bash-it templates at the end. - -When run without the ``--interactive`` switch, Bash-it only enables a sane default set of functionality to keep your shell clean and to avoid issues with missing dependencies. -Feel free to enable the tools you want to use after the installation. - -When you run without the ``--no-modify-config`` switch, the Bash-it installer automatically modifies/replaces your existing config file. -Use the ``--no-modify-config`` switch to avoid unwanted modifications, e.g. if your Bash config file already contains the code that loads Bash-it. - -**NOTE**\ : Keep in mind how Bash loads its configuration files, -``.bash_profile`` for login shells (and in macOS in terminal emulators like `Terminal.app `_ or -`iTerm2 `_\ ) and ``.bashrc`` for interactive shells (default mode in most of the GNU/Linux terminal emulators), -to ensure that Bash-it is loaded correctly. -A good "practice" is sourcing ``.bashrc`` into ``.bash_profile`` to keep things working in all the scenarios. -To achieve this, you can add this snippet in your ``.bash_profile``\ : - -.. code-block:: - - if [ -f ~/.bashrc ]; then - . ~/.bashrc - fi - -Refer to the official `Bash documentation `_ to get more info. - -Install using Docker -^^^^^^^^^^^^^^^^^^^^ - -You can try Bash-it in an isolated environment without changing any local files via a `Docker `_ Container. -(Bash Shell v4.4 with Bash-it, `bats `_\ ,and bash-completion based on `Alpine Linux `_\ ). - -``docker pull ellerbrock/bash-it`` - -Have a look at our `bash-it-docker repository `_ for further information. - -Updating -^^^^^^^^ - -See :ref:`update command `. +.. _installation: + +Installation +------------ + + +#. Check out a clone of this repo to a location of your choice, such as + ``git clone --depth=1 https://github.com/Bash-it/bash-it.git ~/.bash_it`` +#. Run ``~/.bash_it/install.sh`` (it automatically backs up your ``~/.bash_profile`` or ``~/.bashrc``\ , depending on your OS) +#. Edit your modified config (\ ``~/.bash_profile`` or ``~/.bashrc``\ ) file in order to customize Bash-it. +#. Check out available aliases, completions, and plugins and enable the ones you want to use (see the next section for more details). + +Install Options +^^^^^^^^^^^^^^^ + +The install script can take the following options: + + +* ``--interactive``\ : Asks the user which aliases, completions and plugins to enable. +* ``--silent``\ : Ask nothing and install using default settings. +* ``--no-modify-config``\ : Do not modify the existing config file (\ ``~/.bash_profile`` or ``~/.bashrc``\ ). +* ``--append-to-config``\ : Back up existing config file and append bash-it templates at the end. + +When run without the ``--interactive`` switch, Bash-it only enables a sane default set of functionality to keep your shell clean and to avoid issues with missing dependencies. +Feel free to enable the tools you want to use after the installation. + +When you run without the ``--no-modify-config`` switch, the Bash-it installer automatically modifies/replaces your existing config file. +Use the ``--no-modify-config`` switch to avoid unwanted modifications, e.g. if your Bash config file already contains the code that loads Bash-it. + +**NOTE**\ : Keep in mind how Bash loads its configuration files, +``.bash_profile`` for login shells (and in macOS in terminal emulators like `Terminal.app `_ or +`iTerm2 `_\ ) and ``.bashrc`` for interactive shells (default mode in most of the GNU/Linux terminal emulators), +to ensure that Bash-it is loaded correctly. +A good "practice" is sourcing ``.bashrc`` into ``.bash_profile`` to keep things working in all the scenarios. +To achieve this, you can add this snippet in your ``.bash_profile``\ : + +.. code-block:: + + if [ -f ~/.bashrc ] + then + . ~/.bashrc + fi + +Refer to the official `Bash documentation `_ to get more info. + +Install using Docker +^^^^^^^^^^^^^^^^^^^^ + +You can try Bash-it in an isolated environment without changing any local files via a `Docker `_ Container. +(Bash Shell v4.4 with Bash-it, `bats `_\ ,and bash-completion based on `Alpine Linux `_\ ). + +``docker pull ellerbrock/bash-it`` + +Have a look at our `bash-it-docker repository `_ for further information. + +Updating +^^^^^^^^ + +See :ref:`update command `. diff --git a/docs/misc.rst b/docs/misc.rst index 600fbc27..54fd953f 100644 --- a/docs/misc.rst +++ b/docs/misc.rst @@ -1,10 +1,10 @@ -.. _misc: - -Misc ----- - -.. toctree:: - :maxdepth: 2 - - help_screens - proxy_support +.. _misc: + +Misc +---- + +.. toctree:: + :maxdepth: 2 + + help_screens + proxy_support diff --git a/docs/proxy_support.rst b/docs/proxy_support.rst index 038c8fd3..86caf36a 100644 --- a/docs/proxy_support.rst +++ b/docs/proxy_support.rst @@ -1,43 +1,43 @@ -.. _proxy_support: - -Proxy Support -^^^^^^^^^^^^^ - -If you are working in a corporate environment where you have to go through a proxy server for internet access, -then you know how painful it is to configure the OS proxy variables in the shell, -especially if you are switching between environments, e.g. office (with proxy) and home (without proxy). - -The Bash shell (and many shell tools) use the following variables to define the proxy to use: - - -* ``HTTP_PROXY`` (and ``http_proxy``\ ): Defines the proxy server for HTTP requests -* ``HTTPS_PROXY`` (and ``https_proxy``\ ): Defines the proxy server for HTTPS requests -* ``ALL_PROXY`` (and ``all_proxy``\ ): Used by some tools for the same purpose as above -* ``NO_PROXY`` (and ``no_proxy``\ ): Comma-separated list of hostnames that don't have to go through the proxy - -Bash-it's ``proxy`` plugin allows to enable and disable these variables with a simple command. -To start using the ``proxy`` plugin, run the following: - -.. code-block:: bash - - bash-it enable plugin proxy - -Bash-it also provides support for enabling/disabling proxy settings for various shell tools. -The following backends are currently supported (in addition to the shell's environment variables): Git, SVN, npm, ssh. -The ``proxy`` plugin changes the configuration files of these tools to enable or disable the proxy settings. - -Bash-it uses the following variables to set the shell's proxy settings when you call ``enable-proxy``. -These variables are best defined in a custom script in Bash-it's custom script folder (\ ``$BASH_IT/custom``\ ), e.g. ``$BASH_IT/custom/proxy.env.bash`` - - -* ``BASH_IT_HTTP_PROXY`` and `BASH_IT_HTTPS_PROXY`: Define the proxy URL to be used, e.g. 'http://localhost:1234' -* ``BASH_IT_NO_PROXY``\ : A comma-separated list of proxy exclusions, e.g. ``127.0.0.1,localhost`` - -Once you have defined these variables (and have run ``reload`` to load the changes), you can use the following commands to enable or disable the proxy settings in your current shell: - - -* ``enable-proxy``\ : This sets the shell's proxy environment variables and configures proxy support in your SVN, npm, and SSH configuration files. -* ``disable-proxy``\ : This unsets the shell's proxy environment variables and disables proxy support in your SVN, npm, and SSH configuration files. - -There are many more proxy commands, e.g. for changing the local Git project's proxy settings. -Run ``glossary proxy`` to show the available proxy functions with a short description. +.. _proxy_support: + +Proxy Support +^^^^^^^^^^^^^ + +If you are working in a corporate environment where you have to go through a proxy server for internet access, +then you know how painful it is to configure the OS proxy variables in the shell, +especially if you are switching between environments, e.g. office (with proxy) and home (without proxy). + +The Bash shell (and many shell tools) use the following variables to define the proxy to use: + + +* ``HTTP_PROXY`` (and ``http_proxy``\ ): Defines the proxy server for HTTP requests +* ``HTTPS_PROXY`` (and ``https_proxy``\ ): Defines the proxy server for HTTPS requests +* ``ALL_PROXY`` (and ``all_proxy``\ ): Used by some tools for the same purpose as above +* ``NO_PROXY`` (and ``no_proxy``\ ): Comma-separated list of hostnames that don't have to go through the proxy + +Bash-it's ``proxy`` plugin allows to enable and disable these variables with a simple command. +To start using the ``proxy`` plugin, run the following: + +.. code-block:: bash + + bash-it enable plugin proxy + +Bash-it also provides support for enabling/disabling proxy settings for various shell tools. +The following backends are currently supported (in addition to the shell's environment variables): Git, SVN, npm, ssh. +The ``proxy`` plugin changes the configuration files of these tools to enable or disable the proxy settings. + +Bash-it uses the following variables to set the shell's proxy settings when you call ``enable-proxy``. +These variables are best defined in a custom script in Bash-it's custom script folder (\ ``$BASH_IT/custom``\ ), e.g. ``$BASH_IT/custom/proxy.env.bash`` + + +* ``BASH_IT_HTTP_PROXY`` and `BASH_IT_HTTPS_PROXY`: Define the proxy URL to be used, e.g. 'http://localhost:1234' +* ``BASH_IT_NO_PROXY``\ : A comma-separated list of proxy exclusions, e.g. ``127.0.0.1,localhost`` + +Once you have defined these variables (and have run ``reload`` to load the changes), you can use the following commands to enable or disable the proxy settings in your current shell: + + +* ``enable-proxy``\ : This sets the shell's proxy environment variables and configures proxy support in your SVN, npm, and SSH configuration files. +* ``disable-proxy``\ : This unsets the shell's proxy environment variables and disables proxy support in your SVN, npm, and SSH configuration files. + +There are many more proxy commands, e.g. for changing the local Git project's proxy settings. +Run ``glossary proxy`` to show the available proxy functions with a short description. diff --git a/docs/requirements.txt b/docs/requirements.txt index 7b7fcdd1..db927321 100644 --- a/docs/requirements.txt +++ b/docs/requirements.txt @@ -1,4 +1,4 @@ -sphinx==4.5.0 -sphinx-rtd-theme==0.5.0 -sphinxemoji==0.1.8 -docutils==0.17.1 +sphinx==4.5.0 +sphinx-rtd-theme==0.5.0 +sphinxemoji==0.1.8 +docutils==0.17.1 diff --git a/docs/test.rst b/docs/test.rst index 8f616560..75a58c5b 100644 --- a/docs/test.rst +++ b/docs/test.rst @@ -1,46 +1,46 @@ -.. _test: - -Testing Bash-it -=============== - -Overview --------- - -The Bash-it unit tests leverage the `Bats unit test framework for Bash `_. -There is no need to install Bats explicitly, the test run script will automatically download and install Bats and its dependencies. - -When making changes to Bash-it, the tests are automatically executed in a test build environment on `Travis CI `_. - -Test Execution --------------- - -To execute the unit tests, please run the ``run`` script: - -.. code-block:: bash - - # If you are in the `test` directory: - ./run - - # If you are in the root `.bash_it` directory: - test/run - -The ``run`` script will automatically install if it is not already present, and will then run all tests found under the ``test`` directory, including subdirectories. - -To run only a subset of the tests, you can provide the name of the test subdirectory that you want to run, e.g. like this for the tests in the ``test/themes`` directory: - -.. code-block:: bash - - # If you are in the root `.bash_it` directory: - test/run test/themes - -By default, the tests run in single-threaded mode. -If you want to speed up the test execution, you can install the `GNU ``parallel`` tool `_\ , which is supported by Bats. -When using ``parallel``\ , the ``test/run`` script will use a number of threads in parallel, depending on the available CPU cores of your system. -This can speed up test execution significantly. - -Writing Tests -------------- - -When adding or modifying tests, please stick to the format and conventions of the existing test cases. -The ``test_helper.bash`` script provides a couple of reusable helper functions that you should use when writing a test case, -for example for setting up an isolated test environment. +.. _test: + +Testing Bash-it +=============== + +Overview +-------- + +The Bash-it unit tests leverage the `Bats unit test framework for Bash `_. +There is no need to install Bats explicitly, the test run script will automatically download and install Bats and its dependencies. + +When making changes to Bash-it, the tests are automatically executed in a test build environment on `Travis CI `_. + +Test Execution +-------------- + +To execute the unit tests, please run the ``run`` script: + +.. code-block:: bash + + # If you are in the `test` directory: + ./run + + # If you are in the root `.bash_it` directory: + test/run + +The ``run`` script will automatically install if it is not already present, and will then run all tests found under the ``test`` directory, including subdirectories. + +To run only a subset of the tests, you can provide the name of the test subdirectory that you want to run, e.g. like this for the tests in the ``test/themes`` directory: + +.. code-block:: bash + + # If you are in the root `.bash_it` directory: + test/run test/themes + +By default, the tests run in single-threaded mode. +If you want to speed up the test execution, you can install the `GNU ``parallel`` tool `_\ , which is supported by Bats. +When using ``parallel``\ , the ``test/run`` script will use a number of threads in parallel, depending on the available CPU cores of your system. +This can speed up test execution significantly. + +Writing Tests +------------- + +When adding or modifying tests, please stick to the format and conventions of the existing test cases. +The ``test_helper.bash`` script provides a couple of reusable helper functions that you should use when writing a test case, +for example for setting up an isolated test environment. diff --git a/docs/themes-list/atomic.rst b/docs/themes-list/atomic.rst index 7d471ba9..f416cae3 100644 --- a/docs/themes-list/atomic.rst +++ b/docs/themes-list/atomic.rst @@ -1,200 +1,200 @@ -.. _atomic: - -Atomic theme -============ - -The Best ColorFull terminal prompt theme inspired by a number of themes and based on the theme of @MunifTanjim :ref:`brainy `. - -Supported on all operating systems. - -In constant maintenance and improvement - - -.. image:: https://raw.githubusercontent.com/lfelipe1501/lfelipe-projects/master/AtomicTheme.gif - :target: https://raw.githubusercontent.com/lfelipe1501/lfelipe-projects/master/AtomicTheme.gif - :alt: Atomic-Theme - - -Install Theme -------------- - -Manually -^^^^^^^^ - -You can install the theme manually by following these steps: -Edit your modified config ``~/.bashrc`` file in order to customize Bash-it, set ``BASH_IT_THEME`` to the theme name ``atomic``. - -Examples: - -.. code-block:: bash - - # Use the "atomic" theme - export BASH_IT_THEME="atomic" - -Automatically via terminal -^^^^^^^^^^^^^^^^^^^^^^^^^^ - - -#. You can install the theme automatically using the ``sed`` command from your Linux or OSX Terminal. -#. On macOS, the ~/.bash_profile is used, not the ~/.bashrc. -#. For installation on windows you should use `\ ``Git-Bash`` `_ or make sure the terminal emulator you use (ej: cygwin, mintty, etc) has the ``sed`` command installed. - -Command to execute For Windows and Linux: - -.. code-block:: bash - - # Set the "atomic" theme replacing the theme you are using of bash-it - sed -i 's/'"$BASH_IT_THEME"'/atomic/g' ~/.bashrc - -Command to execute for macOS: - -.. code-block:: bash - - # Set the "atomic" theme replacing the theme you are using of bash-it - sed -i '' 's/'"$BASH_IT_THEME"'/atomic/g' ~/.bash_profile - -Features --------- - -Prompt Segments -^^^^^^^^^^^^^^^ - - -* Username & Hostname -* Current Directory -* SCM Information -* Battery Charge -* Clock -* `Todo.txt `_ status -* Ruby Environment -* Python Environment -* Exit Code - -Others -^^^^^^ - - -* Indicator for cached ``sudo`` credential -* Indicator for abort (ctrl + C) the current task and regain user control -* ``atomic`` command for showing/hiding various prompt segments on-the-fly - -Configuration -------------- - -Various prompt segments can be shown/hidden or modified according to your choice. There are two ways for doing that: - - -#. On-the-fly using ``atomic`` command -#. Theme Environment Variables - -On-the-fly using ``atomic`` command -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -This theme provides a command for showing/hiding prompt segments. - -``atomic show `` - -``atomic hide `` - -Tab-completion for this command is enabled by default. - -Configuration specified by this command will only be applied to current and subsequent child shells. - -Theme Environment Variables -^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -This is used for permanent settings that apply to all terminal sessions. You have to define the value of specific theme variables in your ``bashrc`` (or equivalent) file. - -The name of the variables are listed below along with their default values. - -User Information -~~~~~~~~~~~~~~~~ - -Indicator for cached ``sudo`` credential (see ``sudo`` manpage for more information): - -``THEME_SHOW_SUDO=true`` - -SCM Information -~~~~~~~~~~~~~~~ - -Information about SCM repository status: - -``THEME_SHOW_SCM=true`` - -Ruby Environment -~~~~~~~~~~~~~~~~ - -Ruby environment version information: - -``THEME_SHOW_RUBY=false`` - -Python Environment -~~~~~~~~~~~~~~~~~~ - -Python environment version information: - -``THEME_SHOW_PYTHON=false`` - -ToDo.txt status -~~~~~~~~~~~~~~~ - -`Todo.txt `_ status: - -``THEME_SHOW_TODO=false`` - -Clock -~~~~~ - -``THEME_SHOW_CLOCK=true`` - -``THEME_CLOCK_COLOR=$bold_cyan`` - -Format of the clock (see ``date`` manpage for more information): - -``THEME_CLOCK_FORMAT="%H:%M:%S"`` - -Battery Charge -~~~~~~~~~~~~~~ - -Battery charge percentage: - -``THEME_SHOW_BATTERY=false`` - -Exit Code -~~~~~~~~~ - -Exit code of the last command: - -``THEME_SHOW_EXITCODE=true`` - -Prompt Segments Order ---------------------- - -Currently available prompt segments are: - - -* battery -* char -* clock -* dir -* exitcode -* python -* ruby -* scm -* todo -* user_info - -Three environment variables can be defined to rearrange the segments order. The default values are: - -``___ATOMIC_TOP_LEFT="user_info dir scm"`` - -``___ATOMIC_TOP_RIGHT="exitcode python ruby todo clock battery"`` - -``___ATOMIC_BOTTOM="char"`` - -Development by -^^^^^^^^^^^^^^ - -Developer / Author: `Luis Felipe Sánchez `_ - -This work is licensed under the Creative Commons Attribution 4.0 International License. To view a copy of this license, visit http://creativecommons.org/licenses/by/4.0/ or send a letter to Creative Commons, PO Box 1866, Mountain View, CA 94042, USA. +.. _atomic: + +Atomic theme +============ + +The Best ColorFull terminal prompt theme inspired by a number of themes and based on the theme of @MunifTanjim :ref:`brainy `. + +Supported on all operating systems. + +In constant maintenance and improvement + + +.. image:: https://raw.githubusercontent.com/lfelipe1501/lfelipe-projects/master/AtomicTheme.gif + :target: https://raw.githubusercontent.com/lfelipe1501/lfelipe-projects/master/AtomicTheme.gif + :alt: Atomic-Theme + + +Install Theme +------------- + +Manually +^^^^^^^^ + +You can install the theme manually by following these steps: +Edit your modified config ``~/.bashrc`` file in order to customize Bash-it, set ``BASH_IT_THEME`` to the theme name ``atomic``. + +Examples: + +.. code-block:: bash + + # Use the "atomic" theme + export BASH_IT_THEME="atomic" + +Automatically via terminal +^^^^^^^^^^^^^^^^^^^^^^^^^^ + + +#. You can install the theme automatically using the ``sed`` command from your Linux or OSX Terminal. +#. On macOS, the ~/.bash_profile is used, not the ~/.bashrc. +#. For installation on windows you should use `\ ``Git-Bash`` `_ or make sure the terminal emulator you use (ej: cygwin, mintty, etc) has the ``sed`` command installed. + +Command to execute For Windows and Linux: + +.. code-block:: bash + + # Set the "atomic" theme replacing the theme you are using of bash-it + sed -i 's/'"$BASH_IT_THEME"'/atomic/g' ~/.bashrc + +Command to execute for macOS: + +.. code-block:: bash + + # Set the "atomic" theme replacing the theme you are using of bash-it + sed -i '' 's/'"$BASH_IT_THEME"'/atomic/g' ~/.bash_profile + +Features +-------- + +Prompt Segments +^^^^^^^^^^^^^^^ + + +* Username & Hostname +* Current Directory +* SCM Information +* Battery Charge +* Clock +* `Todo.txt `_ status +* Ruby Environment +* Python Environment +* Exit Code + +Others +^^^^^^ + + +* Indicator for cached ``sudo`` credential +* Indicator for abort (ctrl + C) the current task and regain user control +* ``atomic`` command for showing/hiding various prompt segments on-the-fly + +Configuration +------------- + +Various prompt segments can be shown/hidden or modified according to your choice. There are two ways for doing that: + + +#. On-the-fly using ``atomic`` command +#. Theme Environment Variables + +On-the-fly using ``atomic`` command +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +This theme provides a command for showing/hiding prompt segments. + +``atomic show `` + +``atomic hide `` + +Tab-completion for this command is enabled by default. + +Configuration specified by this command will only be applied to current and subsequent child shells. + +Theme Environment Variables +^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +This is used for permanent settings that apply to all terminal sessions. You have to define the value of specific theme variables in your ``bashrc`` (or equivalent) file. + +The name of the variables are listed below along with their default values. + +User Information +~~~~~~~~~~~~~~~~ + +Indicator for cached ``sudo`` credential (see ``sudo`` manpage for more information): + +``THEME_SHOW_SUDO=true`` + +SCM Information +~~~~~~~~~~~~~~~ + +Information about SCM repository status: + +``THEME_SHOW_SCM=true`` + +Ruby Environment +~~~~~~~~~~~~~~~~ + +Ruby environment version information: + +``THEME_SHOW_RUBY=false`` + +Python Environment +~~~~~~~~~~~~~~~~~~ + +Python environment version information: + +``THEME_SHOW_PYTHON=false`` + +ToDo.txt status +~~~~~~~~~~~~~~~ + +`Todo.txt `_ status: + +``THEME_SHOW_TODO=false`` + +Clock +~~~~~ + +``THEME_SHOW_CLOCK=true`` + +``THEME_CLOCK_COLOR=$bold_cyan`` + +Format of the clock (see ``date`` manpage for more information): + +``THEME_CLOCK_FORMAT="%H:%M:%S"`` + +Battery Charge +~~~~~~~~~~~~~~ + +Battery charge percentage: + +``THEME_SHOW_BATTERY=false`` + +Exit Code +~~~~~~~~~ + +Exit code of the last command: + +``THEME_SHOW_EXITCODE=true`` + +Prompt Segments Order +--------------------- + +Currently available prompt segments are: + + +* battery +* char +* clock +* dir +* exitcode +* python +* ruby +* scm +* todo +* user_info + +Three environment variables can be defined to rearrange the segments order. The default values are: + +``___ATOMIC_TOP_LEFT="user_info dir scm"`` + +``___ATOMIC_TOP_RIGHT="exitcode python ruby todo clock battery"`` + +``___ATOMIC_BOTTOM="char"`` + +Development by +^^^^^^^^^^^^^^ + +Developer / Author: `Luis Felipe Sánchez `_ + +This work is licensed under the Creative Commons Attribution 4.0 International License. To view a copy of this license, visit http://creativecommons.org/licenses/by/4.0/ or send a letter to Creative Commons, PO Box 1866, Mountain View, CA 94042, USA. diff --git a/docs/themes-list/barbuk.rst b/docs/themes-list/barbuk.rst index 79477524..ed805db2 100644 --- a/docs/themes-list/barbuk.rst +++ b/docs/themes-list/barbuk.rst @@ -1,166 +1,166 @@ -.. _barbuk: - -BarbUk theme -============ - -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 ----------------- - -A font with SCM glyphs is required to display the default tool/host logos. -You can use a font from https://www.nerdfonts.com/ or patch your own font with the tool -provided by https://github.com/ryanoasis/nerd-fonts. - -You can also override the default variables if you want to use different glyphs or standard ASCII characters. - -Default theme glyphs -^^^^^^^^^^^^^^^^^^^^ - -.. code-block:: bash - - BARBUK_GITLAB_CHAR=' ' - BARBUK_BITBUCKET_CHAR=' ' - BARBUK_GITHUB_CHAR=' ' - BARBUK_GIT_DEFAULT_CHAR=' ' - BARBUK_GIT_BRANCH_ICON='' - BARBUK_HG_CHAR='☿ ' - BARBUK_SVN_CHAR='⑆ ' - 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 -^^^^^^^^^^^^^^^^ - -Define your custom glyphs before sourcing bash-it: - -.. code-block:: bash - - export BARBUK_GITHUB_CHAR='•' - source "$BASH_IT"/bash_it.sh - -SSH prompt ----------- - -Usage -^^^^^ - -When using a ssh session, the theme will display ``user@hostname``. -You can disable this information with ``BARBUK_SSH_INFO``. - -The hostname is displayed in the FQDN format by default. You -can use the short hostname format with ``BARBUK_HOST_INFO``. - -.. code-block:: bash - - # short or long - export BARBUK_HOST_INFO=short - # true or false - export BARBUK_SSH_INFO=false - source "$BASH_IT"/bash_it.sh - -Keep theme with sudoer -^^^^^^^^^^^^^^^^^^^^^^ - -If you want the theme to persist using ``sudo -s`` in a ssh session, you need to configure sudo to keep the ``HOME`` and ``SSH_CONNECTION`` environment variables. - -``HOME`` contains the path to the home directory of the current user. Keeping it will allow to use your user dotfiles when elevating privileges. - -Keeping ``SSH_CONNECTION`` env is necessary for ssh detection in the theme. - -Please refer to the following documentation for more information: - - -* `sudo manual `_ for ``env_keep`` configuration -* `openssh manual `_ for information about ``SSH_CONNECTION`` environment - -.. code-block:: bash - - cat << EOF > /etc/sudoers.d/keepenv - Defaults env_keep += HOME - Defaults env_keep += SSH_CONNECTION - EOF - chmod 400 /etc/sudoers.d/keepenv - -Command duration ----------------- - -See :ref:`Command duration `. - -Examples --------- - -Clean -^^^^^ - -.. code-block:: bash - - ~ ❯ - -Git -^^^ - -.. code-block:: bash - -  ~/.dotfiles on  master ⤏ origin ↑2 •7 ✗ ❯ - -Ssh -^^^ - -.. code-block:: bash - - user@hostname in  ~/bash-it on  master ✓ ❯ - -Python venv -^^^^^^^^^^^ - -.. code-block:: bash - -   flask ~/test on  master ✓ ❯ - -Command duration -^^^^^^^^^^^^^^^^ - -.. code-block:: bash - - # sleep 3s - user@hostname in  ~/bash-it on  master ✓  3.2s ❯ +.. _barbuk: + +BarbUk theme +============ + +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 +---------------- + +A font with SCM glyphs is required to display the default tool/host logos. +You can use a font from https://www.nerdfonts.com/ or patch your own font with the tool +provided by https://github.com/ryanoasis/nerd-fonts. + +You can also override the default variables if you want to use different glyphs or standard ASCII characters. + +Default theme glyphs +^^^^^^^^^^^^^^^^^^^^ + +.. code-block:: bash + + BARBUK_GITLAB_CHAR=' ' + BARBUK_BITBUCKET_CHAR=' ' + BARBUK_GITHUB_CHAR=' ' + BARBUK_GIT_DEFAULT_CHAR=' ' + BARBUK_GIT_BRANCH_ICON='' + BARBUK_HG_CHAR='☿ ' + BARBUK_SVN_CHAR='⑆ ' + 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 +^^^^^^^^^^^^^^^^ + +Define your custom glyphs before sourcing bash-it: + +.. code-block:: bash + + export BARBUK_GITHUB_CHAR='•' + source "$BASH_IT"/bash_it.sh + +SSH prompt +---------- + +Usage +^^^^^ + +When using a ssh session, the theme will display ``user@hostname``. +You can disable this information with ``BARBUK_SSH_INFO``. + +The hostname is displayed in the FQDN format by default. You +can use the short hostname format with ``BARBUK_HOST_INFO``. + +.. code-block:: bash + + # short or long + export BARBUK_HOST_INFO=short + # true or false + export BARBUK_SSH_INFO=false + source "$BASH_IT"/bash_it.sh + +Keep theme with sudoer +^^^^^^^^^^^^^^^^^^^^^^ + +If you want the theme to persist using ``sudo -s`` in a ssh session, you need to configure sudo to keep the ``HOME`` and ``SSH_CONNECTION`` environment variables. + +``HOME`` contains the path to the home directory of the current user. Keeping it will allow to use your user dotfiles when elevating privileges. + +Keeping ``SSH_CONNECTION`` env is necessary for ssh detection in the theme. + +Please refer to the following documentation for more information: + + +* `sudo manual `_ for ``env_keep`` configuration +* `openssh manual `_ for information about ``SSH_CONNECTION`` environment + +.. code-block:: bash + + cat << EOF > /etc/sudoers.d/keepenv + Defaults env_keep += HOME + Defaults env_keep += SSH_CONNECTION + EOF + chmod 400 /etc/sudoers.d/keepenv + +Command duration +---------------- + +See :ref:`Command duration `. + +Examples +-------- + +Clean +^^^^^ + +.. code-block:: bash + + ~ ❯ + +Git +^^^ + +.. code-block:: bash + +  ~/.dotfiles on  master ⤏ origin ↑2 •7 ✗ ❯ + +Ssh +^^^ + +.. code-block:: bash + + user@hostname in  ~/bash-it on  master ✓ ❯ + +Python venv +^^^^^^^^^^^ + +.. code-block:: bash + +   flask ~/test on  master ✓ ❯ + +Command duration +^^^^^^^^^^^^^^^^ + +.. code-block:: bash + + # sleep 3s + user@hostname in  ~/bash-it on  master ✓  3.2s ❯ diff --git a/docs/themes-list/bira.rst b/docs/themes-list/bira.rst index ee69f712..374df9c9 100644 --- a/docs/themes-list/bira.rst +++ b/docs/themes-list/bira.rst @@ -1,12 +1,12 @@ -.. _bira: - -Bira Theme -========== - -This is a port of Oh My Zsh's `'Bira' `_ theme. It looks the same as the original, except for the following changes: - - -* Exit code of last command is not shown -* More informative git prompt (if you want to keep it minimal, please read: :ref:`git_prompt`) -* Position and colour of virtualenv prompt -* No ruby version prompt +.. _bira: + +Bira Theme +========== + +This is a port of Oh My Zsh's `'Bira' `_ theme. It looks the same as the original, except for the following changes: + + +* Exit code of last command is not shown +* More informative git prompt (if you want to keep it minimal, please read: :ref:`git_prompt`) +* Position and colour of virtualenv prompt +* No ruby version prompt diff --git a/docs/themes-list/brainy.rst b/docs/themes-list/brainy.rst index 04e1652a..4c351283 100644 --- a/docs/themes-list/brainy.rst +++ b/docs/themes-list/brainy.rst @@ -1,145 +1,145 @@ -.. _brainy: - -Brainy theme -============ - -Simple colorful terminal prompt theme (inspired by a number of themes). - -Features --------- - -Prompt Segments -^^^^^^^^^^^^^^^ - - -* Username & Hostname -* Current Directory -* SCM Information -* Battery Charge -* Clock -* `Todo.txt `_ status -* Ruby Environment -* Python Environment -* Exit Code - -Others -^^^^^^ - - -* Indicator for cached ``sudo`` credential -* Indicator for ssh login -* ``brainy`` command for showing/hiding various prompt segments on-the-fly - -Configuration -------------- - -Various prompt segments can be shown/hidden or modified according to your choice. There are two ways for doing that: - - -#. On-the-fly using ``brainy`` command -#. Theme Environment Variables - -On-the-fly using ``brainy`` command -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -This theme provides a command for showing/hiding prompt segments. - -``brainy show `` - -``brainy hide `` - -Tab-completion for this command is enabled by default. - -Configuration specified by this command will only be applied to current and subsequent child shells. - -Theme Environment Variables -^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -This is used for permanent settings that apply to all terminal sessions. You have to define the value of specific theme variables in your ``bashrc`` (or equivalent) file. - -The name of the variables are listed below along with their default values. - -User Information -~~~~~~~~~~~~~~~~ - -Indicator for cached ``sudo`` credential (see ``sudo`` manpage for more information): - -``THEME_SHOW_SUDO=true`` - -SCM Information -~~~~~~~~~~~~~~~ - -Information about SCM repository status: - -``THEME_SHOW_SCM=true`` - -Ruby Environment -~~~~~~~~~~~~~~~~ - -Ruby environment version information: - -``THEME_SHOW_RUBY=false`` - -Python Environment -~~~~~~~~~~~~~~~~~~ - -Python environment version information: - -``THEME_SHOW_PYTHON=false`` - -ToDo.txt status -~~~~~~~~~~~~~~~ - -`Todo.txt `_ status: - -``THEME_SHOW_TODO=false`` - -Clock -~~~~~ - -``THEME_SHOW_CLOCK=true`` - -``THEME_CLOCK_COLOR=$bold_cyan`` - -Format of the clock (see ``date`` manpage for more information): - -``THEME_CLOCK_FORMAT="%H:%M:%S"`` - -Battery Charge -~~~~~~~~~~~~~~ - -Battery charge percentage: - -``THEME_SHOW_BATTERY=false`` - -Exit Code -~~~~~~~~~ - -Exit code of the last command: - -``THEME_SHOW_EXITCODE=true`` - -Prompt Segments Order ---------------------- - -Currently available prompt segments are: - - -* battery -* char -* clock -* dir -* exitcode -* python -* ruby -* scm -* todo -* user_info - -Three environment variables can be defined to rearrange the segments order. The default values are: - -``___BRAINY_TOP_LEFT="user_info dir scm"`` - -``___BRAINY_TOP_RIGHT="python ruby todo clock battery"`` - -``___BRAINY_BOTTOM="exitcode char"`` +.. _brainy: + +Brainy theme +============ + +Simple colorful terminal prompt theme (inspired by a number of themes). + +Features +-------- + +Prompt Segments +^^^^^^^^^^^^^^^ + + +* Username & Hostname +* Current Directory +* SCM Information +* Battery Charge +* Clock +* `Todo.txt `_ status +* Ruby Environment +* Python Environment +* Exit Code + +Others +^^^^^^ + + +* Indicator for cached ``sudo`` credential +* Indicator for ssh login +* ``brainy`` command for showing/hiding various prompt segments on-the-fly + +Configuration +------------- + +Various prompt segments can be shown/hidden or modified according to your choice. There are two ways for doing that: + + +#. On-the-fly using ``brainy`` command +#. Theme Environment Variables + +On-the-fly using ``brainy`` command +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +This theme provides a command for showing/hiding prompt segments. + +``brainy show `` + +``brainy hide `` + +Tab-completion for this command is enabled by default. + +Configuration specified by this command will only be applied to current and subsequent child shells. + +Theme Environment Variables +^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +This is used for permanent settings that apply to all terminal sessions. You have to define the value of specific theme variables in your ``bashrc`` (or equivalent) file. + +The name of the variables are listed below along with their default values. + +User Information +~~~~~~~~~~~~~~~~ + +Indicator for cached ``sudo`` credential (see ``sudo`` manpage for more information): + +``THEME_SHOW_SUDO=true`` + +SCM Information +~~~~~~~~~~~~~~~ + +Information about SCM repository status: + +``THEME_SHOW_SCM=true`` + +Ruby Environment +~~~~~~~~~~~~~~~~ + +Ruby environment version information: + +``THEME_SHOW_RUBY=false`` + +Python Environment +~~~~~~~~~~~~~~~~~~ + +Python environment version information: + +``THEME_SHOW_PYTHON=false`` + +ToDo.txt status +~~~~~~~~~~~~~~~ + +`Todo.txt `_ status: + +``THEME_SHOW_TODO=false`` + +Clock +~~~~~ + +``THEME_SHOW_CLOCK=true`` + +``THEME_CLOCK_COLOR=$bold_cyan`` + +Format of the clock (see ``date`` manpage for more information): + +``THEME_CLOCK_FORMAT="%H:%M:%S"`` + +Battery Charge +~~~~~~~~~~~~~~ + +Battery charge percentage: + +``THEME_SHOW_BATTERY=false`` + +Exit Code +~~~~~~~~~ + +Exit code of the last command: + +``THEME_SHOW_EXITCODE=true`` + +Prompt Segments Order +--------------------- + +Currently available prompt segments are: + + +* battery +* char +* clock +* dir +* exitcode +* python +* ruby +* scm +* todo +* user_info + +Three environment variables can be defined to rearrange the segments order. The default values are: + +``___BRAINY_TOP_LEFT="user_info dir scm"`` + +``___BRAINY_TOP_RIGHT="python ruby todo clock battery"`` + +``___BRAINY_BOTTOM="exitcode char"`` diff --git a/docs/themes-list/codeword.rst b/docs/themes-list/codeword.rst index 00bb7ee4..e3d0ae3e 100644 --- a/docs/themes-list/codeword.rst +++ b/docs/themes-list/codeword.rst @@ -1,28 +1,28 @@ -.. _codeword: - -Codeword Theme -============== - -Single line PS1 theme w/realtime history among windows. -Minimal theme overrides from bash_it base theming - -``user@host:path[virt-env][scm] $`` ---------------------------------------- - -Breakdown of the segments: - - -* **user@host:path** - *convienient for LAN based ``ssh`` and ``scp`` tasks* -* [\ **virtualenv**\ ] - *only appears when activated* -* [\ **scm**\ ] - *only appears when activated* -* **marker** - *$ or # depending on current user* - -Examples -^^^^^^^^ - -.. code-block:: bash - - user@example.lan:~ $ cd /tmp/foo/bar/baz - user@example.lan:/tmp/foo/bar/baz $ cd $HOME/workspace - user@example.lan:~/workspace $ cd sampleRepo/ - user@example.lan:~/workspace/sampleRepo [± |master ↑1 ↓3 {1} S:2 ?:1 ✗|] $ +.. _codeword: + +Codeword Theme +============== + +Single line PS1 theme w/realtime history among windows. +Minimal theme overrides from bash_it base theming + +``user@host:path[virt-env][scm] $`` +--------------------------------------- + +Breakdown of the segments: + + +* **user@host:path** - *convienient for LAN based ``ssh`` and ``scp`` tasks* +* [\ **virtualenv**\ ] - *only appears when activated* +* [\ **scm**\ ] - *only appears when activated* +* **marker** - *$ or # depending on current user* + +Examples +^^^^^^^^ + +.. code-block:: bash + + user@example.lan:~ $ cd /tmp/foo/bar/baz + user@example.lan:/tmp/foo/bar/baz $ cd $HOME/workspace + user@example.lan:~/workspace $ cd sampleRepo/ + user@example.lan:~/workspace/sampleRepo [± |master ↑1 ↓3 {1} S:2 ?:1 ✗|] $ diff --git a/docs/themes-list/easy.rst b/docs/themes-list/easy.rst index cd553cf4..21f75872 100644 --- a/docs/themes-list/easy.rst +++ b/docs/themes-list/easy.rst @@ -1,14 +1,14 @@ -.. _easy: - -Easy Theme -========== - -A simple theme - -Examples --------- - -.. code-block:: bash - - user@hostname ~/.bash_it - [ master ✓ ] ❯ +.. _easy: + +Easy Theme +========== + +A simple theme + +Examples +-------- + +.. code-block:: bash + + user@hostname ~/.bash_it + [ master ✓ ] ❯ diff --git a/docs/themes-list/index.rst b/docs/themes-list/index.rst index 0275001b..9bf17b86 100644 --- a/docs/themes-list/index.rst +++ b/docs/themes-list/index.rst @@ -1,599 +1,599 @@ -.. _list_of_themes: - -List of Themes -============== - -Below is a list of most of the themes (with screenshots) and their documentation that `bash-it `_ ships with. - -.. note:: - Not all themes have documentation! - -.. toctree:: - :maxdepth: 1 - :caption: Documentation of Themes - :glob: - - * - -Alphabetical Screenshots List ------------------------------ - -Bakke -^^^^^ - - -.. image:: https://bash-it.github.io/bash-it/docs/images/bakke-black.jpg - :target: https://bash-it.github.io/bash-it/docs/images/bakke-black.jpg - :alt: Bakke - - -.. image:: https://bash-it.github.io/bash-it/docs/images/bakke-white.jpg - :target: https://bash-it.github.io/bash-it/docs/images/bakke-white.jpg - :alt: Bakke - - ----- - -BarbUk -^^^^^^ - - -.. image:: https://bash-it.github.io/bash-it/docs/images/BarbUk-black.png - :target: https://bash-it.github.io/bash-it/docs/images/BarbUk-black.png - :alt: BarbUk - - -.. image:: https://bash-it.github.io/bash-it/docs/images/BarbUk-white.png - :target: https://bash-it.github.io/bash-it/docs/images/BarbUk-white.png - :alt: BarbUk - - ----- - -Bobby -^^^^^ - - -.. image:: https://bash-it.github.io/bash-it/docs/images/bobby-black.jpg - :target: https://bash-it.github.io/bash-it/docs/images/bobby-black.jpg - :alt: - - -.. image:: https://bash-it.github.io/bash-it/docs/images/bobby-white.jpg - :target: https://bash-it.github.io/bash-it/docs/images/bobby-white.jpg - :alt: - - ----- - -Brunton -^^^^^^^ - - -.. image:: https://bash-it.github.io/bash-it/docs/images/brunton-black.png - :target: https://bash-it.github.io/bash-it/docs/images/brunton-black.png - :alt: - - ----- - -Candy -^^^^^ - - -.. image:: https://bash-it.github.io/bash-it/docs/images/candy-black.jpg - :target: https://bash-it.github.io/bash-it/docs/images/candy-black.jpg - :alt: - - -.. image:: https://bash-it.github.io/bash-it/docs/images/candy-white.jpg - :target: https://bash-it.github.io/bash-it/docs/images/candy-white.jpg - :alt: - - ----- - -Clean -^^^^^ - - -.. image:: https://bash-it.github.io/bash-it/docs/images/clean-black.jpg - :target: https://bash-it.github.io/bash-it/docs/images/clean-black.jpg - :alt: - - -.. image:: https://bash-it.github.io/bash-it/docs/images/clean-white.jpg - :target: https://bash-it.github.io/bash-it/docs/images/clean-white.jpg - :alt: - - ----- - -Demula -^^^^^^ - - -.. image:: https://bash-it.github.io/bash-it/docs/images/demula-black.jpg - :target: https://bash-it.github.io/bash-it/docs/images/demula-black.jpg - :alt: - - -.. image:: https://bash-it.github.io/bash-it/docs/images/demula-white.jpg - :target: https://bash-it.github.io/bash-it/docs/images/demula-white.jpg - :alt: - - ----- - -DOS -^^^ - - -.. image:: https://bash-it.github.io/bash-it/docs/images/dos-black.jpg - :target: https://bash-it.github.io/bash-it/docs/images/dos-black.jpg - :alt: - - -.. image:: https://bash-it.github.io/bash-it/docs/images/dos-white.jpg - :target: https://bash-it.github.io/bash-it/docs/images/dos-white.jpg - :alt: - - ----- - -DoubleTime -^^^^^^^^^^ - - -.. image:: https://bash-it.github.io/bash-it/docs/images/doubletime-black.jpg - :target: https://bash-it.github.io/bash-it/docs/images/doubletime-black.jpg - :alt: - - -.. image:: https://bash-it.github.io/bash-it/docs/images/doubletime-white.jpg - :target: https://bash-it.github.io/bash-it/docs/images/doubletime-white.jpg - :alt: - - ----- - -DoubleTime Multiline -^^^^^^^^^^^^^^^^^^^^ - - -.. image:: https://bash-it.github.io/bash-it/docs/images/doubletime_multiline-black.jpg - :target: https://bash-it.github.io/bash-it/docs/images/doubletime_multiline-black.jpg - :alt: - - -.. image:: https://bash-it.github.io/bash-it/docs/images/doubletime_multiline-white.jpg - :target: https://bash-it.github.io/bash-it/docs/images/doubletime_multiline-white.jpg - :alt: - - ----- - -Doubletime Multiline Python Only -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - - -.. image:: https://bash-it.github.io/bash-it/docs/images/doubletime_multiline_pyonly-black.jpg - :target: https://bash-it.github.io/bash-it/docs/images/doubletime_multiline_pyonly-black.jpg - :alt: - - -.. image:: https://bash-it.github.io/bash-it/docs/images/doubletime_multiline_pyonly-white.jpg - :target: https://bash-it.github.io/bash-it/docs/images/doubletime_multiline_pyonly-white.jpg - :alt: - - ----- - -Easy -^^^^ - - -.. image:: https://bash-it.github.io/bash-it/docs/images/easy-black.jpg - :target: https://bash-it.github.io/bash-it/docs/images/easy-black.jpg - :alt: - - -.. image:: https://bash-it.github.io/bash-it/docs/images/easy-white.jpg - :target: https://bash-it.github.io/bash-it/docs/images/easy-white.jpg - :alt: - - ----- - -Envy -^^^^ - - -.. image:: https://bash-it.github.io/bash-it/docs/images/envy-black.jpg - :target: https://bash-it.github.io/bash-it/docs/images/envy-black.jpg - :alt: - - -.. image:: https://bash-it.github.io/bash-it/docs/images/envy-white.jpg - :target: https://bash-it.github.io/bash-it/docs/images/envy-white.jpg - :alt: - - ----- - -Iterate -^^^^^^^ - -Responsively wraps prompt based on terminal width. - - -.. image:: https://cloud.githubusercontent.com/assets/1319655/2923152/3a763194-d70e-11e3-9e52-3740de9bbb9b.png - :target: https://cloud.githubusercontent.com/assets/1319655/2923152/3a763194-d70e-11e3-9e52-3740de9bbb9b.png - :alt: - - -.. image:: https://cloud.githubusercontent.com/assets/1319655/2923143/14b8e0d2-d70e-11e3-9706-f5341fff8e5c.png - :target: https://cloud.githubusercontent.com/assets/1319655/2923143/14b8e0d2-d70e-11e3-9706-f5341fff8e5c.png - :alt: - - ----- - -Mr Briggs -^^^^^^^^^ - - -.. image:: https://bash-it.github.io/bash-it/docs/images/mbriggs-black.jpg - :target: https://bash-it.github.io/bash-it/docs/images/mbriggs-black.jpg - :alt: - - -.. image:: https://bash-it.github.io/bash-it/docs/images/mbriggs-white.jpg - :target: https://bash-it.github.io/bash-it/docs/images/mbriggs-white.jpg - :alt: - - ----- - -Minimal -^^^^^^^ - - -.. image:: https://bash-it.github.io/bash-it/docs/images/minimal-black.jpg - :target: https://bash-it.github.io/bash-it/docs/images/minimal-black.jpg - :alt: - - -.. image:: https://bash-it.github.io/bash-it/docs/images/minimal-white.jpg - :target: https://bash-it.github.io/bash-it/docs/images/minimal-white.jpg - :alt: - - ----- - -Modern -^^^^^^ - - -.. image:: https://bash-it.github.io/bash-it/docs/images/modern-black.jpg - :target: https://bash-it.github.io/bash-it/docs/images/modern-black.jpg - :alt: - - -.. image:: https://bash-it.github.io/bash-it/docs/images/modern-white.jpg - :target: https://bash-it.github.io/bash-it/docs/images/modern-white.jpg - :alt: - - ----- - -Modern T -^^^^^^^^ - - -.. image:: https://bash-it.github.io/bash-it/docs/images/modern-t-black.jpg - :target: https://bash-it.github.io/bash-it/docs/images/modern-t-black.jpg - :alt: - - -.. image:: https://bash-it.github.io/bash-it/docs/images/modern-t-white.jpg - :target: https://bash-it.github.io/bash-it/docs/images/modern-t-white.jpg - :alt: - - ----- - -Metal -^^^^^ - - -.. image:: https://raw.githubusercontent.com/jrab66/bash-it/7cc82b518d6286fc68c8477d809ce9f417501976/themes/metal/metalthemeblack.png - :target: https://raw.githubusercontent.com/jrab66/bash-it/7cc82b518d6286fc68c8477d809ce9f417501976/themes/metal/metalthemeblack.png - :alt: - - ----- - -n0Qorg -^^^^^^ - - -.. image:: https://bash-it.github.io/bash-it/docs/images/n0qorg-black.jpg - :target: https://bash-it.github.io/bash-it/docs/images/n0qorg-black.jpg - :alt: - - -.. image:: https://bash-it.github.io/bash-it/docs/images/n0qorg-white.jpg - :target: https://bash-it.github.io/bash-it/docs/images/n0qorg-white.jpg - :alt: - - ----- - -.. _nwinkler_image: - -NWinkler -^^^^^^^^ - - -.. image:: https://bash-it.github.io/bash-it/docs/images/nwinkler-black.jpg - :target: https://bash-it.github.io/bash-it/docs/images/nwinkler-black.jpg - :alt: - - -.. image:: https://bash-it.github.io/bash-it/docs/images/nwinkler-white.jpg - :target: https://bash-it.github.io/bash-it/docs/images/nwinkler-white.jpg - :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 -^^^^ - - -.. image:: https://bash-it.github.io/bash-it/docs/images/pete-black.jpg - :target: https://bash-it.github.io/bash-it/docs/images/pete-black.jpg - :alt: - - -.. image:: https://bash-it.github.io/bash-it/docs/images/pete-white.jpg - :target: https://bash-it.github.io/bash-it/docs/images/pete-white.jpg - :alt: - - ----- - -Powerline -^^^^^^^^^ - - -.. image:: https://bash-it.github.io/bash-it/docs/images/powerline-black.jpg - :target: https://bash-it.github.io/bash-it/docs/images/powerline-black.jpg - :alt: - - -.. image:: https://bash-it.github.io/bash-it/docs/images/powerline-white.jpg - :target: https://bash-it.github.io/bash-it/docs/images/powerline-white.jpg - :alt: - - ----- - -Powerline Naked -^^^^^^^^^^^^^^^ - - -.. image:: https://bash-it.github.io/bash-it/docs/images/powerline-naked-black.jpg - :target: https://bash-it.github.io/bash-it/docs/images/powerline-naked-black.jpg - :alt: - - -.. image:: https://bash-it.github.io/bash-it/docs/images/powerline-naked-white.jpg - :target: https://bash-it.github.io/bash-it/docs/images/powerline-naked-white.jpg - :alt: - - ----- - -Powerline Plain -^^^^^^^^^^^^^^^ - - -.. image:: https://bash-it.github.io/bash-it/docs/images/powerline-plain-black.jpg - :target: https://bash-it.github.io/bash-it/docs/images/powerline-plain-black.jpg - :alt: - - -.. image:: https://bash-it.github.io/bash-it/docs/images/powerline-plain-white.jpg - :target: https://bash-it.github.io/bash-it/docs/images/powerline-plain-white.jpg - :alt: - - ----- - -Pure -^^^^ - - -.. image:: https://bash-it.github.io/bash-it/docs/images/pure-black.jpg - :target: https://bash-it.github.io/bash-it/docs/images/pure-black.jpg - :alt: - - -.. image:: https://bash-it.github.io/bash-it/docs/images/pure-white.jpg - :target: https://bash-it.github.io/bash-it/docs/images/pure-white.jpg - :alt: - - ----- - -RainbowBrite -^^^^^^^^^^^^ - - -.. image:: https://bash-it.github.io/bash-it/docs/images/rainbowbrite-black.jpg - :target: https://bash-it.github.io/bash-it/docs/images/rainbowbrite-black.jpg - :alt: - - -.. image:: https://bash-it.github.io/bash-it/docs/images/rainbowbrite-white.jpg - :target: https://bash-it.github.io/bash-it/docs/images/rainbowbrite-white.jpg - :alt: - - ----- - -R Jorgenson -^^^^^^^^^^^ - - -.. image:: https://bash-it.github.io/bash-it/docs/images/rjorgenson-black.jpg - :target: https://bash-it.github.io/bash-it/docs/images/rjorgenson-black.jpg - :alt: - - -.. image:: https://bash-it.github.io/bash-it/docs/images/rjorgenson-white.jpg - :target: https://bash-it.github.io/bash-it/docs/images/rjorgenson-white.jpg - :alt: - - ----- - -Sexy -^^^^ - - -.. image:: https://bash-it.github.io/bash-it/docs/images/sexy-black.jpg - :target: https://bash-it.github.io/bash-it/docs/images/sexy-black.jpg - :alt: - - -.. image:: https://bash-it.github.io/bash-it/docs/images/sexy-white.jpg - :target: https://bash-it.github.io/bash-it/docs/images/sexy-white.jpg - :alt: - - ----- - -Simple -^^^^^^ - - -.. image:: https://bash-it.github.io/bash-it/docs/images/simple-black.jpg - :target: https://bash-it.github.io/bash-it/docs/images/simple-black.jpg - :alt: - - -.. image:: https://bash-it.github.io/bash-it/docs/images/simple-white.jpg - :target: https://bash-it.github.io/bash-it/docs/images/simple-white.jpg - :alt: - - ----- - -SirUp -^^^^^ - - -.. image:: https://bash-it.github.io/bash-it/docs/images/sirup-black.jpg - :target: https://bash-it.github.io/bash-it/docs/images/sirup-black.jpg - :alt: - - -.. image:: https://bash-it.github.io/bash-it/docs/images/sirup-white.jpg - :target: https://bash-it.github.io/bash-it/docs/images/sirup-white.jpg - :alt: - - ----- - -Standard -^^^^^^^^ - - -.. image:: https://bash-it.github.io/bash-it/docs/images/standard-black.jpg - :target: https://bash-it.github.io/bash-it/docs/images/standard-black.jpg - :alt: - - -.. image:: https://bash-it.github.io/bash-it/docs/images/standard-white.jpg - :target: https://bash-it.github.io/bash-it/docs/images/standard-white.jpg - :alt: - - ----- - -Tonka -^^^^^ - - -.. image:: https://bash-it.github.io/bash-it/docs/images/tonka-black.jpg - :target: https://bash-it.github.io/bash-it/docs/images/tonka-black.jpg - :alt: - - -.. image:: https://bash-it.github.io/bash-it/docs/images/tonka-white.jpg - :target: https://bash-it.github.io/bash-it/docs/images/tonka-white.jpg - :alt: - - ----- - -Tylenol -^^^^^^^ - - -.. image:: https://bash-it.github.io/bash-it/docs/images/tylenol-black.jpg - :target: https://bash-it.github.io/bash-it/docs/images/tylenol-black.jpg - :alt: - - -.. image:: https://bash-it.github.io/bash-it/docs/images/tylenol-white.jpg - :target: https://bash-it.github.io/bash-it/docs/images/tylenol-white.jpg - :alt: - - ----- - -Zitron -^^^^^^ - - -.. image:: https://bash-it.github.io/bash-it/docs/images/zitron-black.jpg - :target: https://bash-it.github.io/bash-it/docs/images/zitron-black.jpg - :alt: - - -.. image:: https://bash-it.github.io/bash-it/docs/images/zitron-white.jpg - :target: https://bash-it.github.io/bash-it/docs/images/zitron-white.jpg - :alt: - - ----- - -Zork -^^^^ - - -.. image:: https://bash-it.github.io/bash-it/docs/images/zork-black.jpg - :target: https://bash-it.github.io/bash-it/docs/images/zork-black.jpg - :alt: - - -.. image:: https://bash-it.github.io/bash-it/docs/images/zork-white.jpg - :target: https://bash-it.github.io/bash-it/docs/images/zork-white.jpg - :alt: +.. _list_of_themes: + +List of Themes +============== + +Below is a list of most of the themes (with screenshots) and their documentation that `bash-it `_ ships with. + +.. note:: + Not all themes have documentation! + +.. toctree:: + :maxdepth: 1 + :caption: Documentation of Themes + :glob: + + * + +Alphabetical Screenshots List +----------------------------- + +Bakke +^^^^^ + + +.. image:: https://bash-it.github.io/bash-it/docs/images/bakke-black.jpg + :target: https://bash-it.github.io/bash-it/docs/images/bakke-black.jpg + :alt: Bakke + + +.. image:: https://bash-it.github.io/bash-it/docs/images/bakke-white.jpg + :target: https://bash-it.github.io/bash-it/docs/images/bakke-white.jpg + :alt: Bakke + + +---- + +BarbUk +^^^^^^ + + +.. image:: https://bash-it.github.io/bash-it/docs/images/BarbUk-black.png + :target: https://bash-it.github.io/bash-it/docs/images/BarbUk-black.png + :alt: BarbUk + + +.. image:: https://bash-it.github.io/bash-it/docs/images/BarbUk-white.png + :target: https://bash-it.github.io/bash-it/docs/images/BarbUk-white.png + :alt: BarbUk + + +---- + +Bobby +^^^^^ + + +.. image:: https://bash-it.github.io/bash-it/docs/images/bobby-black.jpg + :target: https://bash-it.github.io/bash-it/docs/images/bobby-black.jpg + :alt: + + +.. image:: https://bash-it.github.io/bash-it/docs/images/bobby-white.jpg + :target: https://bash-it.github.io/bash-it/docs/images/bobby-white.jpg + :alt: + + +---- + +Brunton +^^^^^^^ + + +.. image:: https://bash-it.github.io/bash-it/docs/images/brunton-black.png + :target: https://bash-it.github.io/bash-it/docs/images/brunton-black.png + :alt: + + +---- + +Candy +^^^^^ + + +.. image:: https://bash-it.github.io/bash-it/docs/images/candy-black.jpg + :target: https://bash-it.github.io/bash-it/docs/images/candy-black.jpg + :alt: + + +.. image:: https://bash-it.github.io/bash-it/docs/images/candy-white.jpg + :target: https://bash-it.github.io/bash-it/docs/images/candy-white.jpg + :alt: + + +---- + +Clean +^^^^^ + + +.. image:: https://bash-it.github.io/bash-it/docs/images/clean-black.jpg + :target: https://bash-it.github.io/bash-it/docs/images/clean-black.jpg + :alt: + + +.. image:: https://bash-it.github.io/bash-it/docs/images/clean-white.jpg + :target: https://bash-it.github.io/bash-it/docs/images/clean-white.jpg + :alt: + + +---- + +Demula +^^^^^^ + + +.. image:: https://bash-it.github.io/bash-it/docs/images/demula-black.jpg + :target: https://bash-it.github.io/bash-it/docs/images/demula-black.jpg + :alt: + + +.. image:: https://bash-it.github.io/bash-it/docs/images/demula-white.jpg + :target: https://bash-it.github.io/bash-it/docs/images/demula-white.jpg + :alt: + + +---- + +DOS +^^^ + + +.. image:: https://bash-it.github.io/bash-it/docs/images/dos-black.jpg + :target: https://bash-it.github.io/bash-it/docs/images/dos-black.jpg + :alt: + + +.. image:: https://bash-it.github.io/bash-it/docs/images/dos-white.jpg + :target: https://bash-it.github.io/bash-it/docs/images/dos-white.jpg + :alt: + + +---- + +DoubleTime +^^^^^^^^^^ + + +.. image:: https://bash-it.github.io/bash-it/docs/images/doubletime-black.jpg + :target: https://bash-it.github.io/bash-it/docs/images/doubletime-black.jpg + :alt: + + +.. image:: https://bash-it.github.io/bash-it/docs/images/doubletime-white.jpg + :target: https://bash-it.github.io/bash-it/docs/images/doubletime-white.jpg + :alt: + + +---- + +DoubleTime Multiline +^^^^^^^^^^^^^^^^^^^^ + + +.. image:: https://bash-it.github.io/bash-it/docs/images/doubletime_multiline-black.jpg + :target: https://bash-it.github.io/bash-it/docs/images/doubletime_multiline-black.jpg + :alt: + + +.. image:: https://bash-it.github.io/bash-it/docs/images/doubletime_multiline-white.jpg + :target: https://bash-it.github.io/bash-it/docs/images/doubletime_multiline-white.jpg + :alt: + + +---- + +Doubletime Multiline Python Only +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + +.. image:: https://bash-it.github.io/bash-it/docs/images/doubletime_multiline_pyonly-black.jpg + :target: https://bash-it.github.io/bash-it/docs/images/doubletime_multiline_pyonly-black.jpg + :alt: + + +.. image:: https://bash-it.github.io/bash-it/docs/images/doubletime_multiline_pyonly-white.jpg + :target: https://bash-it.github.io/bash-it/docs/images/doubletime_multiline_pyonly-white.jpg + :alt: + + +---- + +Easy +^^^^ + + +.. image:: https://bash-it.github.io/bash-it/docs/images/easy-black.jpg + :target: https://bash-it.github.io/bash-it/docs/images/easy-black.jpg + :alt: + + +.. image:: https://bash-it.github.io/bash-it/docs/images/easy-white.jpg + :target: https://bash-it.github.io/bash-it/docs/images/easy-white.jpg + :alt: + + +---- + +Envy +^^^^ + + +.. image:: https://bash-it.github.io/bash-it/docs/images/envy-black.jpg + :target: https://bash-it.github.io/bash-it/docs/images/envy-black.jpg + :alt: + + +.. image:: https://bash-it.github.io/bash-it/docs/images/envy-white.jpg + :target: https://bash-it.github.io/bash-it/docs/images/envy-white.jpg + :alt: + + +---- + +Iterate +^^^^^^^ + +Responsively wraps prompt based on terminal width. + + +.. image:: https://cloud.githubusercontent.com/assets/1319655/2923152/3a763194-d70e-11e3-9e52-3740de9bbb9b.png + :target: https://cloud.githubusercontent.com/assets/1319655/2923152/3a763194-d70e-11e3-9e52-3740de9bbb9b.png + :alt: + + +.. image:: https://cloud.githubusercontent.com/assets/1319655/2923143/14b8e0d2-d70e-11e3-9706-f5341fff8e5c.png + :target: https://cloud.githubusercontent.com/assets/1319655/2923143/14b8e0d2-d70e-11e3-9706-f5341fff8e5c.png + :alt: + + +---- + +Mr Briggs +^^^^^^^^^ + + +.. image:: https://bash-it.github.io/bash-it/docs/images/mbriggs-black.jpg + :target: https://bash-it.github.io/bash-it/docs/images/mbriggs-black.jpg + :alt: + + +.. image:: https://bash-it.github.io/bash-it/docs/images/mbriggs-white.jpg + :target: https://bash-it.github.io/bash-it/docs/images/mbriggs-white.jpg + :alt: + + +---- + +Minimal +^^^^^^^ + + +.. image:: https://bash-it.github.io/bash-it/docs/images/minimal-black.jpg + :target: https://bash-it.github.io/bash-it/docs/images/minimal-black.jpg + :alt: + + +.. image:: https://bash-it.github.io/bash-it/docs/images/minimal-white.jpg + :target: https://bash-it.github.io/bash-it/docs/images/minimal-white.jpg + :alt: + + +---- + +Modern +^^^^^^ + + +.. image:: https://bash-it.github.io/bash-it/docs/images/modern-black.jpg + :target: https://bash-it.github.io/bash-it/docs/images/modern-black.jpg + :alt: + + +.. image:: https://bash-it.github.io/bash-it/docs/images/modern-white.jpg + :target: https://bash-it.github.io/bash-it/docs/images/modern-white.jpg + :alt: + + +---- + +Modern T +^^^^^^^^ + + +.. image:: https://bash-it.github.io/bash-it/docs/images/modern-t-black.jpg + :target: https://bash-it.github.io/bash-it/docs/images/modern-t-black.jpg + :alt: + + +.. image:: https://bash-it.github.io/bash-it/docs/images/modern-t-white.jpg + :target: https://bash-it.github.io/bash-it/docs/images/modern-t-white.jpg + :alt: + + +---- + +Metal +^^^^^ + + +.. image:: https://raw.githubusercontent.com/jrab66/bash-it/7cc82b518d6286fc68c8477d809ce9f417501976/themes/metal/metalthemeblack.png + :target: https://raw.githubusercontent.com/jrab66/bash-it/7cc82b518d6286fc68c8477d809ce9f417501976/themes/metal/metalthemeblack.png + :alt: + + +---- + +n0Qorg +^^^^^^ + + +.. image:: https://bash-it.github.io/bash-it/docs/images/n0qorg-black.jpg + :target: https://bash-it.github.io/bash-it/docs/images/n0qorg-black.jpg + :alt: + + +.. image:: https://bash-it.github.io/bash-it/docs/images/n0qorg-white.jpg + :target: https://bash-it.github.io/bash-it/docs/images/n0qorg-white.jpg + :alt: + + +---- + +.. _nwinkler_image: + +NWinkler +^^^^^^^^ + + +.. image:: https://bash-it.github.io/bash-it/docs/images/nwinkler-black.jpg + :target: https://bash-it.github.io/bash-it/docs/images/nwinkler-black.jpg + :alt: + + +.. image:: https://bash-it.github.io/bash-it/docs/images/nwinkler-white.jpg + :target: https://bash-it.github.io/bash-it/docs/images/nwinkler-white.jpg + :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 +^^^^ + + +.. image:: https://bash-it.github.io/bash-it/docs/images/pete-black.jpg + :target: https://bash-it.github.io/bash-it/docs/images/pete-black.jpg + :alt: + + +.. image:: https://bash-it.github.io/bash-it/docs/images/pete-white.jpg + :target: https://bash-it.github.io/bash-it/docs/images/pete-white.jpg + :alt: + + +---- + +Powerline +^^^^^^^^^ + + +.. image:: https://bash-it.github.io/bash-it/docs/images/powerline-black.jpg + :target: https://bash-it.github.io/bash-it/docs/images/powerline-black.jpg + :alt: + + +.. image:: https://bash-it.github.io/bash-it/docs/images/powerline-white.jpg + :target: https://bash-it.github.io/bash-it/docs/images/powerline-white.jpg + :alt: + + +---- + +Powerline Naked +^^^^^^^^^^^^^^^ + + +.. image:: https://bash-it.github.io/bash-it/docs/images/powerline-naked-black.jpg + :target: https://bash-it.github.io/bash-it/docs/images/powerline-naked-black.jpg + :alt: + + +.. image:: https://bash-it.github.io/bash-it/docs/images/powerline-naked-white.jpg + :target: https://bash-it.github.io/bash-it/docs/images/powerline-naked-white.jpg + :alt: + + +---- + +Powerline Plain +^^^^^^^^^^^^^^^ + + +.. image:: https://bash-it.github.io/bash-it/docs/images/powerline-plain-black.jpg + :target: https://bash-it.github.io/bash-it/docs/images/powerline-plain-black.jpg + :alt: + + +.. image:: https://bash-it.github.io/bash-it/docs/images/powerline-plain-white.jpg + :target: https://bash-it.github.io/bash-it/docs/images/powerline-plain-white.jpg + :alt: + + +---- + +Pure +^^^^ + + +.. image:: https://bash-it.github.io/bash-it/docs/images/pure-black.jpg + :target: https://bash-it.github.io/bash-it/docs/images/pure-black.jpg + :alt: + + +.. image:: https://bash-it.github.io/bash-it/docs/images/pure-white.jpg + :target: https://bash-it.github.io/bash-it/docs/images/pure-white.jpg + :alt: + + +---- + +RainbowBrite +^^^^^^^^^^^^ + + +.. image:: https://bash-it.github.io/bash-it/docs/images/rainbowbrite-black.jpg + :target: https://bash-it.github.io/bash-it/docs/images/rainbowbrite-black.jpg + :alt: + + +.. image:: https://bash-it.github.io/bash-it/docs/images/rainbowbrite-white.jpg + :target: https://bash-it.github.io/bash-it/docs/images/rainbowbrite-white.jpg + :alt: + + +---- + +R Jorgenson +^^^^^^^^^^^ + + +.. image:: https://bash-it.github.io/bash-it/docs/images/rjorgenson-black.jpg + :target: https://bash-it.github.io/bash-it/docs/images/rjorgenson-black.jpg + :alt: + + +.. image:: https://bash-it.github.io/bash-it/docs/images/rjorgenson-white.jpg + :target: https://bash-it.github.io/bash-it/docs/images/rjorgenson-white.jpg + :alt: + + +---- + +Sexy +^^^^ + + +.. image:: https://bash-it.github.io/bash-it/docs/images/sexy-black.jpg + :target: https://bash-it.github.io/bash-it/docs/images/sexy-black.jpg + :alt: + + +.. image:: https://bash-it.github.io/bash-it/docs/images/sexy-white.jpg + :target: https://bash-it.github.io/bash-it/docs/images/sexy-white.jpg + :alt: + + +---- + +Simple +^^^^^^ + + +.. image:: https://bash-it.github.io/bash-it/docs/images/simple-black.jpg + :target: https://bash-it.github.io/bash-it/docs/images/simple-black.jpg + :alt: + + +.. image:: https://bash-it.github.io/bash-it/docs/images/simple-white.jpg + :target: https://bash-it.github.io/bash-it/docs/images/simple-white.jpg + :alt: + + +---- + +SirUp +^^^^^ + + +.. image:: https://bash-it.github.io/bash-it/docs/images/sirup-black.jpg + :target: https://bash-it.github.io/bash-it/docs/images/sirup-black.jpg + :alt: + + +.. image:: https://bash-it.github.io/bash-it/docs/images/sirup-white.jpg + :target: https://bash-it.github.io/bash-it/docs/images/sirup-white.jpg + :alt: + + +---- + +Standard +^^^^^^^^ + + +.. image:: https://bash-it.github.io/bash-it/docs/images/standard-black.jpg + :target: https://bash-it.github.io/bash-it/docs/images/standard-black.jpg + :alt: + + +.. image:: https://bash-it.github.io/bash-it/docs/images/standard-white.jpg + :target: https://bash-it.github.io/bash-it/docs/images/standard-white.jpg + :alt: + + +---- + +Tonka +^^^^^ + + +.. image:: https://bash-it.github.io/bash-it/docs/images/tonka-black.jpg + :target: https://bash-it.github.io/bash-it/docs/images/tonka-black.jpg + :alt: + + +.. image:: https://bash-it.github.io/bash-it/docs/images/tonka-white.jpg + :target: https://bash-it.github.io/bash-it/docs/images/tonka-white.jpg + :alt: + + +---- + +Tylenol +^^^^^^^ + + +.. image:: https://bash-it.github.io/bash-it/docs/images/tylenol-black.jpg + :target: https://bash-it.github.io/bash-it/docs/images/tylenol-black.jpg + :alt: + + +.. image:: https://bash-it.github.io/bash-it/docs/images/tylenol-white.jpg + :target: https://bash-it.github.io/bash-it/docs/images/tylenol-white.jpg + :alt: + + +---- + +Zitron +^^^^^^ + + +.. image:: https://bash-it.github.io/bash-it/docs/images/zitron-black.jpg + :target: https://bash-it.github.io/bash-it/docs/images/zitron-black.jpg + :alt: + + +.. image:: https://bash-it.github.io/bash-it/docs/images/zitron-white.jpg + :target: https://bash-it.github.io/bash-it/docs/images/zitron-white.jpg + :alt: + + +---- + +Zork +^^^^ + + +.. image:: https://bash-it.github.io/bash-it/docs/images/zork-black.jpg + :target: https://bash-it.github.io/bash-it/docs/images/zork-black.jpg + :alt: + + +.. image:: https://bash-it.github.io/bash-it/docs/images/zork-white.jpg + :target: https://bash-it.github.io/bash-it/docs/images/zork-white.jpg + :alt: diff --git a/docs/themes-list/nwinkler_random_colors.rst b/docs/themes-list/nwinkler_random_colors.rst index 20ea34c3..1cd948e5 100644 --- a/docs/themes-list/nwinkler_random_colors.rst +++ b/docs/themes-list/nwinkler_random_colors.rst @@ -1,39 +1,39 @@ -.. _nwinkler_random_color: - -Nwinkler Random Color Theme -=========================== - -Description ------------ - -The *Nwinkler Random Color* Theme is based on the :ref:`Nwinkler Theme ` , but it randomizes the colors for: - - -* time -* username -* hostname -* path - -The random colors are chosen the first time this theme is used and saved to the ``~/.nwinkler_random_colors`` file. So, the next time you connect to the same machine, you will get the same colors. - -To force new random colors to be selected, run the command: - -.. code-block:: sh - - randomize_nwinkler - -Screenshot ----------- - -Here it is in action: - - -.. image:: nwinkler_random_colors.png - :target: nwinkler_random_colors.png - :alt: alt text - - -Usage Scenario --------------- - -This theme is especially useful when connecting to many different machines and switching between them often. Yes, the hostname *is* present in the prompt. But I argue that it's a lot faster to get a "feel" of what machine you are currently on because of the custom colors on that machine's prompt than by reading the hostname. +.. _nwinkler_random_color: + +Nwinkler Random Color Theme +=========================== + +Description +----------- + +The *Nwinkler Random Color* Theme is based on the :ref:`Nwinkler Theme ` , but it randomizes the colors for: + + +* time +* username +* hostname +* path + +The random colors are chosen the first time this theme is used and saved to the ``~/.nwinkler_random_colors`` file. So, the next time you connect to the same machine, you will get the same colors. + +To force new random colors to be selected, run the command: + +.. code-block:: sh + + randomize_nwinkler + +Screenshot +---------- + +Here it is in action: + + +.. image:: nwinkler_random_colors.png + :target: nwinkler_random_colors.png + :alt: alt text + + +Usage Scenario +-------------- + +This theme is especially useful when connecting to many different machines and switching between them often. Yes, the hostname *is* present in the prompt. But I argue that it's a lot faster to get a "feel" of what machine you are currently on because of the custom colors on that machine's prompt than by reading the hostname. diff --git a/docs/themes-list/oh-my-posh.rst b/docs/themes-list/oh-my-posh.rst index 974adc0f..13e70df9 100644 --- a/docs/themes-list/oh-my-posh.rst +++ b/docs/themes-list/oh-my-posh.rst @@ -1,15 +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. +.. _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/docs/themes-list/powerline-base.rst b/docs/themes-list/powerline-base.rst index faa1af34..5664e30e 100644 --- a/docs/themes-list/powerline-base.rst +++ b/docs/themes-list/powerline-base.rst @@ -1,130 +1,130 @@ -.. _powerline_base: - -Base Powerline Theme Information -================================ - -This page explains base powerline theme information, shared between -all powerline themes. - -**IMPORTANT:** This theme requires that `a font with the Powerline symbols `_ needs to be used in your terminal emulator, otherwise the prompt won't be displayed correctly, i.e. some of the additional icons and characters will be missing. Please follow your operating system's instructions to install one of the fonts from the above link and select it in your terminal emulator. - -**NOTICE:** The default behavior of this theme assumes that you have sudo privileges on your workstation. If that is not the case (e.g. if you are running on a corporate network where ``sudo`` usage is tracked), you can set the flag 'export THEME_CHECK_SUDO=false' in your ``~/.bashrc`` or ``~/.bash_profile`` to disable the Powerline theme's ``sudo`` check. This will apply to all ``powerline*`` themes. - -Provided Information --------------------- - - -* Current path -* Current username and hostname -* Current time -* Current shell level -* Current dirstack level (\ ``pushd`` / ``popd``\ ) -* Current history number -* Current command number -* An indicator when connected by SSH -* An indicator when ``sudo`` has the credentials cached (see the ``sudo`` manpage for more info about this) -* An indicator when the current shell is inside the Vim editor -* Battery charging status (depends on the battery plugin) -* SCM Repository status (e.g. Git, SVN) -* The current Kubernetes environment -* The current Python environment (Virtualenv, venv, and Conda are supported) in use -* The current Ruby environment (rvm and rbenv are supported) in use -* Last command exit code (only shown when the exit code is greater than 0) - -Configuration -------------- - -This theme is pretty configurable, all the configuration is done by setting environment variables. - -User Information -^^^^^^^^^^^^^^^^ - -By default, the username and hostname are shown, but you can change this behavior by setting the value of the following variable: - -.. code-block:: bash - - export POWERLINE_PROMPT_USER_INFO_MODE="sudo" - - -For now, the only supported value is ``sudo``\ , which hides the username and hostname, and shows an indicator when ``sudo`` has the credentials cached. Other values have no effect at this time. - -Clock Format -^^^^^^^^^^^^ - -You can change the format using the following variable: - -.. code-block:: bash - - export THEME_CLOCK_FORMAT="%H:%M:%S" - - -The time/date is printed by the ``date`` command, so refer to its man page to change the format. - -Segment Order -^^^^^^^^^^^^^ - -The contents of the prompt can be "reordered", all the "segments" (every piece of information) can take any place. The currently available segments are: - - -* ``aws_profile`` - Show the current value of the ``AWS_PROFILE`` environment variable -* ``battery`` - Battery information (you'll need to enable the ``battery`` plugin) -* ``clock`` - Current time in ``HH:MM:SS`` format -* ``cwd`` - Current working directory including full folder hierarchy (c.f. ``wd``\ ) -* ``duration`` - Duration of the last command. See :ref:`Command duration ` for details. -* ``gcloud`` - Current gcloud active account -* ``hostname`` - Host name of machine -* ``in_toolbox`` - Show identifier if running inside a `toolbox `_ -* ``in_vim`` - Show identifier if running in ``:terminal`` from vim -* ``k8s_context`` - Show current kubernetes context -* ``k8s_namespace`` - Show current kubernetes namespace -* ``last_status`` - Exit status of last run command -* ``python_venv`` - Python virtual environment information (\ ``virtualenv``\ , ``venv`` - and ``conda`` supported) -* ``ruby`` - Current ruby version if using ``rvm`` -* ``node`` - Current node version (only ``nvm`` is supported) -* ``scm`` - Version control information, ``git`` -* ``terraform`` - Current terraform workspace -* ``user_info`` - Current user -* ``wd`` - Working directory, like ``cwd`` but doesn't show the full folder - hierarchy, only the directory you're currently in. -* ``shlvl`` - Show the current shell level (based on ``SHLVL`` environment variable), but only if you are not in root shell -* ``dirstack`` - Show the current dirstack level (based on ``DIRSTACK`` environment variable), but only if the stack is not empty -* ``history_number`` - Show current history number -* ``command_number`` - Show current command number - -A variable can be defined to set the order of the prompt segments: - -.. code-block:: - - POWERLINE_PROMPT="user_info scm python_venv ruby cwd" - - -The example values above are the current default values, but if you want to remove anything from the prompt, simply remove the "string" that represents the segment from the variable. - -.. _powerline_compact_settings: - -Compact Settings -^^^^^^^^^^^^^^^^ - -You can configure various aspects of the prompt to use less whitespace. Supported variables are: - -.. list-table:: - :header-rows: 1 - - * - Variable - - Description - * - POWERLINE_COMPACT_BEFORE_SEPARATOR - - Removes the leading space before each separator - * - POWERLINE_COMPACT_AFTER_SEPARATOR - - Removes the trailing space after each separator - * - POWERLINE_COMPACT_BEFOR_FIRST_SEGMENT - - Removes the leading space on the first segment - * - POWERLINE_COMPACT_AFTER_LAST_SEGMENT - - Removes the trailing space on the last segment - * - POWERLINE_COMPACT_PROMPT - - Removes the space after the prompt character - * - POWERLINE_COMPACT - - Enable all Compact settings (you can still override individual settings) - - -The default value for all settings is ``0`` (disabled). Use ``1`` to enable. +.. _powerline_base: + +Base Powerline Theme Information +================================ + +This page explains base powerline theme information, shared between +all powerline themes. + +**IMPORTANT:** This theme requires that `a font with the Powerline symbols `_ needs to be used in your terminal emulator, otherwise the prompt won't be displayed correctly, i.e. some of the additional icons and characters will be missing. Please follow your operating system's instructions to install one of the fonts from the above link and select it in your terminal emulator. + +**NOTICE:** The default behavior of this theme assumes that you have sudo privileges on your workstation. If that is not the case (e.g. if you are running on a corporate network where ``sudo`` usage is tracked), you can set the flag 'export THEME_CHECK_SUDO=false' in your ``~/.bashrc`` or ``~/.bash_profile`` to disable the Powerline theme's ``sudo`` check. This will apply to all ``powerline*`` themes. + +Provided Information +-------------------- + + +* Current path +* Current username and hostname +* Current time +* Current shell level +* Current dirstack level (\ ``pushd`` / ``popd``\ ) +* Current history number +* Current command number +* An indicator when connected by SSH +* An indicator when ``sudo`` has the credentials cached (see the ``sudo`` manpage for more info about this) +* An indicator when the current shell is inside the Vim editor +* Battery charging status (depends on the battery plugin) +* SCM Repository status (e.g. Git, SVN) +* The current Kubernetes environment +* The current Python environment (Virtualenv, venv, and Conda are supported) in use +* The current Ruby environment (rvm and rbenv are supported) in use +* Last command exit code (only shown when the exit code is greater than 0) + +Configuration +------------- + +This theme is pretty configurable, all the configuration is done by setting environment variables. + +User Information +^^^^^^^^^^^^^^^^ + +By default, the username and hostname are shown, but you can change this behavior by setting the value of the following variable: + +.. code-block:: bash + + export POWERLINE_PROMPT_USER_INFO_MODE="sudo" + + +For now, the only supported value is ``sudo``\ , which hides the username and hostname, and shows an indicator when ``sudo`` has the credentials cached. Other values have no effect at this time. + +Clock Format +^^^^^^^^^^^^ + +You can change the format using the following variable: + +.. code-block:: bash + + export THEME_CLOCK_FORMAT="%H:%M:%S" + + +The time/date is printed by the ``date`` command, so refer to its man page to change the format. + +Segment Order +^^^^^^^^^^^^^ + +The contents of the prompt can be "reordered", all the "segments" (every piece of information) can take any place. The currently available segments are: + + +* ``aws_profile`` - Show the current value of the ``AWS_PROFILE`` environment variable +* ``battery`` - Battery information (you'll need to enable the ``battery`` plugin) +* ``clock`` - Current time in ``HH:MM:SS`` format +* ``cwd`` - Current working directory including full folder hierarchy (c.f. ``wd``\ ) +* ``duration`` - Duration of the last command. See :ref:`Command duration ` for details. +* ``gcloud`` - Current gcloud active account +* ``hostname`` - Host name of machine +* ``in_toolbox`` - Show identifier if running inside a `toolbox `_ +* ``in_vim`` - Show identifier if running in ``:terminal`` from vim +* ``k8s_context`` - Show current kubernetes context +* ``k8s_namespace`` - Show current kubernetes namespace +* ``last_status`` - Exit status of last run command +* ``python_venv`` - Python virtual environment information (\ ``virtualenv``\ , ``venv`` + and ``conda`` supported) +* ``ruby`` - Current ruby version if using ``rvm`` +* ``node`` - Current node version (only ``nvm`` is supported) +* ``scm`` - Version control information, ``git`` +* ``terraform`` - Current terraform workspace +* ``user_info`` - Current user +* ``wd`` - Working directory, like ``cwd`` but doesn't show the full folder + hierarchy, only the directory you're currently in. +* ``shlvl`` - Show the current shell level (based on ``SHLVL`` environment variable), but only if you are not in root shell +* ``dirstack`` - Show the current dirstack level (based on ``DIRSTACK`` environment variable), but only if the stack is not empty +* ``history_number`` - Show current history number +* ``command_number`` - Show current command number + +A variable can be defined to set the order of the prompt segments: + +.. code-block:: + + POWERLINE_PROMPT="user_info scm python_venv ruby cwd" + + +The example values above are the current default values, but if you want to remove anything from the prompt, simply remove the "string" that represents the segment from the variable. + +.. _powerline_compact_settings: + +Compact Settings +^^^^^^^^^^^^^^^^ + +You can configure various aspects of the prompt to use less whitespace. Supported variables are: + +.. list-table:: + :header-rows: 1 + + * - Variable + - Description + * - POWERLINE_COMPACT_BEFORE_SEPARATOR + - Removes the leading space before each separator + * - POWERLINE_COMPACT_AFTER_SEPARATOR + - Removes the trailing space after each separator + * - POWERLINE_COMPACT_BEFOR_FIRST_SEGMENT + - Removes the leading space on the first segment + * - POWERLINE_COMPACT_AFTER_LAST_SEGMENT + - Removes the trailing space on the last segment + * - POWERLINE_COMPACT_PROMPT + - Removes the space after the prompt character + * - POWERLINE_COMPACT + - Enable all Compact settings (you can still override individual settings) + + +The default value for all settings is ``0`` (disabled). Use ``1`` to enable. diff --git a/docs/themes-list/powerline-multiline.rst b/docs/themes-list/powerline-multiline.rst index f525f022..3c210023 100644 --- a/docs/themes-list/powerline-multiline.rst +++ b/docs/themes-list/powerline-multiline.rst @@ -1,36 +1,36 @@ -.. _powerline_multiline: - -Powerline Multiline Theme -========================= - -A colorful multiline theme, where the first line shows information about your shell session (divided into two parts, left and right), and the second one is where the shell commands are introduced. - -See :ref:`powerline_base` for general information about the powerline theme. - -Soft Separators -^^^^^^^^^^^^^^^ - -Adjacent segments having the same background color will use a less-pronouced (i.e. soft) separator between them. - -Padding -^^^^^^^ - -To get the length of the left and right segments right, a *padding* value is used. -In most cases, the default value (\ *2*\ ) works fine, but on some operating systems, this needs to be adjusted. -One example is *macOS High Sierra*\ , where the default padding causes the right segment to extend to the next line. -On macOS High Sierra, the padding value needs to be changed to *3* to make the theme look right. -This can be done by setting the ``POWERLINE_PADDING`` variable before Bash-it is loaded, e.g. in your ``~/.bash_profile`` or ``~/.bashrc`` file: - -.. code-block:: bash - - export POWERLINE_PADDING=3 - - -Multiline Mode Right Prompt -^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -For the purposes of the :ref:`Compact ` settings, the segments within the **Right Prompt** are considered to run "right-to-left", i.e.: - - -* The **right-most** segment is considered to be the ``"first"`` segment, while the **left-most** segment is considered to be the ``"last"`` -* The space to the **right** of the separator character is considered to be ``"before"``\ , while the space to the **left** is considered to be ``"after"`` +.. _powerline_multiline: + +Powerline Multiline Theme +========================= + +A colorful multiline theme, where the first line shows information about your shell session (divided into two parts, left and right), and the second one is where the shell commands are introduced. + +See :ref:`powerline_base` for general information about the powerline theme. + +Soft Separators +^^^^^^^^^^^^^^^ + +Adjacent segments having the same background color will use a less-pronouced (i.e. soft) separator between them. + +Padding +^^^^^^^ + +To get the length of the left and right segments right, a *padding* value is used. +In most cases, the default value (\ *2*\ ) works fine, but on some operating systems, this needs to be adjusted. +One example is *macOS High Sierra*\ , where the default padding causes the right segment to extend to the next line. +On macOS High Sierra, the padding value needs to be changed to *3* to make the theme look right. +This can be done by setting the ``POWERLINE_PADDING`` variable before Bash-it is loaded, e.g. in your ``~/.bash_profile`` or ``~/.bashrc`` file: + +.. code-block:: bash + + export POWERLINE_PADDING=3 + + +Multiline Mode Right Prompt +^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +For the purposes of the :ref:`Compact ` settings, the segments within the **Right Prompt** are considered to run "right-to-left", i.e.: + + +* The **right-most** segment is considered to be the ``"first"`` segment, while the **left-most** segment is considered to be the ``"last"`` +* The space to the **right** of the separator character is considered to be ``"before"``\ , while the space to the **left** is considered to be ``"after"`` diff --git a/docs/themes-list/powerline-naked.rst b/docs/themes-list/powerline-naked.rst index cf4b0869..53b6e870 100644 --- a/docs/themes-list/powerline-naked.rst +++ b/docs/themes-list/powerline-naked.rst @@ -1,9 +1,9 @@ -.. _powerline_naked: - -Powerline Naked Theme -===================== - -A colorful theme, where shows a lot information about your shell session. -The naked powerline theme provides a cleaner shell with less background colors. - -See :ref:`powerline_base` for general information about the powerline theme. +.. _powerline_naked: + +Powerline Naked Theme +===================== + +A colorful theme, where shows a lot information about your shell session. +The naked powerline theme provides a cleaner shell with less background colors. + +See :ref:`powerline_base` for general information about the powerline theme. diff --git a/docs/themes-list/powerline-plain.rst b/docs/themes-list/powerline-plain.rst index a7f47c5a..133b445f 100644 --- a/docs/themes-list/powerline-plain.rst +++ b/docs/themes-list/powerline-plain.rst @@ -1,14 +1,14 @@ -.. _powerline_plain: - -Powerline Plain Theme -===================== - -A colorful theme, where shows a lot information about your shell session. -The plain powerline theme provides a simpler shell with less information. - -See :ref:`powerline_base` for general information about the powerline theme. - -Soft Separators -^^^^^^^^^^^^^^^ - -Adjacent segments having the same background color will use a less-pronouced (i.e. soft) separator between them. +.. _powerline_plain: + +Powerline Plain Theme +===================== + +A colorful theme, where shows a lot information about your shell session. +The plain powerline theme provides a simpler shell with less information. + +See :ref:`powerline_base` for general information about the powerline theme. + +Soft Separators +^^^^^^^^^^^^^^^ + +Adjacent segments having the same background color will use a less-pronouced (i.e. soft) separator between them. diff --git a/docs/themes-list/powerline.rst b/docs/themes-list/powerline.rst index afd63ece..b63b178c 100644 --- a/docs/themes-list/powerline.rst +++ b/docs/themes-list/powerline.rst @@ -1,13 +1,13 @@ -.. _powerline: - -Powerline Theme -=============== - -A colorful theme, where shows a lot information about your shell session. - -See :ref:`powerline_base` for general information about the powerline theme. - -Soft Separators -^^^^^^^^^^^^^^^ - -Adjacent segments having the same background color will use a less-pronouced (i.e. soft) separator between them. +.. _powerline: + +Powerline Theme +=============== + +A colorful theme, where shows a lot information about your shell session. + +See :ref:`powerline_base` for general information about the powerline theme. + +Soft Separators +^^^^^^^^^^^^^^^ + +Adjacent segments having the same background color will use a less-pronouced (i.e. soft) separator between them. diff --git a/docs/themes-list/radek.rst b/docs/themes-list/radek.rst index 333999cc..f7e286e1 100644 --- a/docs/themes-list/radek.rst +++ b/docs/themes-list/radek.rst @@ -1,25 +1,25 @@ -.. _radek: - -Radek Theme -=========== - -A colorful theme for Python developers. -It does not have any requirements. - -Provided Information --------------------- - - -* Current username and hostname -* Current path -* Git repository status -* Current Python environment (venv, Conda ) -* Current Python version - -Examples --------- - -.. code-block:: bash - - [radek@photon][~/src/nokia2/cbis] ±[master → origin ↑1 {1}✓][venv-cbis][py-3.7.5] - → +.. _radek: + +Radek Theme +=========== + +A colorful theme for Python developers. +It does not have any requirements. + +Provided Information +-------------------- + + +* Current username and hostname +* Current path +* Git repository status +* Current Python environment (venv, Conda ) +* Current Python version + +Examples +-------- + +.. code-block:: bash + + [radek@photon][~/src/nokia2/cbis] ±[master → origin ↑1 {1}✓][venv-cbis][py-3.7.5] + → diff --git a/docs/themes-list/redline.rst b/docs/themes-list/redline.rst index ba5abcf4..d929a15b 100644 --- a/docs/themes-list/redline.rst +++ b/docs/themes-list/redline.rst @@ -1,56 +1,56 @@ -.. _redline: - -Redline Theme -============= - -changed up the powerline base a little. - -It plays nicest with this font: `DroidSansMonoForPowerline `_ - -Read the :ref:`powerline theme documentation ` - -added ------ - - -* hostname -* distro logo - -changed -------- - - -* sudo credential check -* required font -* some icons - -Works real good like with: - -.. code-block:: bash - - ## set the theme - export BASH_IT_THEME='redline' - - # Set this to false to turn off version control status checking within the prompt for all themes - export SCM_CHECK=true - - ## Set Xterm/screen/Tmux title with only a short hostname. - export SHORT_HOSTNAME=$(hostname -s) - - ## enable sudo prompt - export POWERLINE_PROMPT_USER_INFO_MODE="sudo" - - ## prompt part string - export POWERLINE_PROMPT="python_venv user_info hostname cwd scm" - -enable your distro logo with ----------------------------- - -.. code-block:: bash - - export POWERLINE_PROMPT_DISTRO_LOGO="yes" - - -.. image:: redline.png - :target: redline.png?raw=true - :alt: screenshot +.. _redline: + +Redline Theme +============= + +changed up the powerline base a little. + +It plays nicest with this font: `DroidSansMonoForPowerline `_ + +Read the :ref:`powerline theme documentation ` + +added +----- + + +* hostname +* distro logo + +changed +------- + + +* sudo credential check +* required font +* some icons + +Works real good like with: + +.. code-block:: bash + + ## set the theme + export BASH_IT_THEME='redline' + + # Set this to false to turn off version control status checking within the prompt for all themes + export SCM_CHECK=true + + ## Set Xterm/screen/Tmux title with only a short hostname. + export SHORT_HOSTNAME=$(hostname -s) + + ## enable sudo prompt + export POWERLINE_PROMPT_USER_INFO_MODE="sudo" + + ## prompt part string + export POWERLINE_PROMPT="python_venv user_info hostname cwd scm" + +enable your distro logo with +---------------------------- + +.. code-block:: bash + + export POWERLINE_PROMPT_DISTRO_LOGO="yes" + + +.. image:: redline.png + :target: redline.png?raw=true + :alt: screenshot diff --git a/docs/themes.rst b/docs/themes.rst index 8cfbeb23..6d3f4a17 100644 --- a/docs/themes.rst +++ b/docs/themes.rst @@ -1,93 +1,93 @@ -.. _themes: - -Themes ------- - -There are over 50+ Bash-it themes to pick from in ``$BASH_IT/themes``. -The default theme is ``bobby``. -Set ``BASH_IT_THEME`` to the theme name you want, or if you've developed your own custom theme outside of ``$BASH_IT/themes``\ , -point the ``BASH_IT_THEME`` variable directly to the theme file. -To disable theming completely, leave the variable empty. - -Examples: - -.. code-block:: bash - - # Use the "powerline-multiline" theme - export BASH_IT_THEME="powerline-multiline" - - # Use a theme outside of the Bash-it folder - export BASH_IT_THEME="/home/foo/my_theme/my_theme.theme.bash" - - # Disable theming - export BASH_IT_THEME="" - -You can easily preview the themes in your own shell using ``bash-it preview``. - -If you've created your own custom prompts, we'd love it if you shared them with everyone else! Just submit a Pull Request. -You can see theme screenshots on `wiki/Themes `_. - -**NOTE**\ : Bash-it and some themes use UTF-8 characters, so to avoid strange behavior in your terminal, set your locale to ``LC_ALL=en_US.UTF-8`` or the equivalent to your language if it isn't American English. - -List of Themes -^^^^^^^^^^^^^^ - -See :ref:`here `. - -Theme Switches & Variables -^^^^^^^^^^^^^^^^^^^^^^^^^^ - -.. _command_duration: - -Command duration -================ - -Prints last command duration - -Usage -##### - -Command duration can be enabled by exporting ``BASH_IT_COMMAND_DURATION``: - -.. code-block:: bash - - export BASH_IT_COMMAND_DURATION=true - -The default configuration display last command duration for command lasting one second or more. -You can customize the minimum time in seconds before command duration is displayed in your ``.bashrc``: - -.. code-block:: bash - - export COMMAND_DURATION_MIN_SECONDS=5 - -Clock Related -============= - -function: ``clock_char`` -######################## - -Prints a character indicating clock. - - -* ``THEME_SHOW_CLOCK_CHAR`` : **true**\ /false - -* ``THEME_CLOCK_CHAR`` : "\ **⌚**\ " - -* ``THEME_CLOCK_CHAR_COLOR`` : "\ **$normal**\ " - -function: ``clock_prompt`` -########################## - -Prints the clock prompt (date, time). - - -* ``THEME_SHOW_CLOCK`` : **true**\ /false - -* ``THEME_CLOCK_COLOR`` : "\ **$normal**\ " - -* ``THEME_CLOCK_FORMAT`` : "\ **%H:%M:%S**\ " - -Contributing a new theme -^^^^^^^^^^^^^^^^^^^^^^^^ - -See the :ref:`instructions `. +.. _themes: + +Themes +------ + +There are over 50+ Bash-it themes to pick from in ``$BASH_IT/themes``. +The default theme is ``bobby``. +Set ``BASH_IT_THEME`` to the theme name you want, or if you've developed your own custom theme outside of ``$BASH_IT/themes``\ , +point the ``BASH_IT_THEME`` variable directly to the theme file. +To disable theming completely, leave the variable empty. + +Examples: + +.. code-block:: bash + + # Use the "powerline-multiline" theme + export BASH_IT_THEME="powerline-multiline" + + # Use a theme outside of the Bash-it folder + export BASH_IT_THEME="/home/foo/my_theme/my_theme.theme.bash" + + # Disable theming + export BASH_IT_THEME="" + +You can easily preview the themes in your own shell using ``bash-it preview``. + +If you've created your own custom prompts, we'd love it if you shared them with everyone else! Just submit a Pull Request. +You can see theme screenshots on `wiki/Themes `_. + +**NOTE**\ : Bash-it and some themes use UTF-8 characters, so to avoid strange behavior in your terminal, set your locale to ``LC_ALL=en_US.UTF-8`` or the equivalent to your language if it isn't American English. + +List of Themes +^^^^^^^^^^^^^^ + +See :ref:`here `. + +Theme Switches & Variables +^^^^^^^^^^^^^^^^^^^^^^^^^^ + +.. _command_duration: + +Command duration +================ + +Prints last command duration + +Usage +##### + +Command duration can be enabled by exporting ``BASH_IT_COMMAND_DURATION``: + +.. code-block:: bash + + export BASH_IT_COMMAND_DURATION=true + +The default configuration display last command duration for command lasting one second or more. +You can customize the minimum time in seconds before command duration is displayed in your ``.bashrc``: + +.. code-block:: bash + + export COMMAND_DURATION_MIN_SECONDS=5 + +Clock Related +============= + +function: ``clock_char`` +######################## + +Prints a character indicating clock. + + +* ``THEME_SHOW_CLOCK_CHAR`` : **true**\ /false + +* ``THEME_CLOCK_CHAR`` : "\ **⌚**\ " + +* ``THEME_CLOCK_CHAR_COLOR`` : "\ **$normal**\ " + +function: ``clock_prompt`` +########################## + +Prints the clock prompt (date, time). + + +* ``THEME_SHOW_CLOCK`` : **true**\ /false + +* ``THEME_CLOCK_COLOR`` : "\ **$normal**\ " + +* ``THEME_CLOCK_FORMAT`` : "\ **%H:%M:%S**\ " + +Contributing a new theme +^^^^^^^^^^^^^^^^^^^^^^^^ + +See the :ref:`instructions `. diff --git a/docs/troubleshooting.rst b/docs/troubleshooting.rst index 93d9113a..9dbd947a 100644 --- a/docs/troubleshooting.rst +++ b/docs/troubleshooting.rst @@ -1,45 +1,45 @@ -.. _troubleshooting: - -Troubleshooting Guide -===================== - -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:: 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 +.. _troubleshooting: + +Troubleshooting Guide +===================== + +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:: 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 diff --git a/docs/uninstalling.rst b/docs/uninstalling.rst index dab1430d..3f865db5 100644 --- a/docs/uninstalling.rst +++ b/docs/uninstalling.rst @@ -1,14 +1,14 @@ -.. _uninstalling: - -Uninstalling ------------- - -To uninstall Bash-it, run the ``uninstall.sh`` script found in the ``$BASH_IT`` directory: - -.. code-block:: - - cd $BASH_IT - ./uninstall.sh - -This will restore your previous Bash profile. -After the uninstall script finishes, remove the Bash-it directory from your machine (\ ``rm -rf $BASH_IT``\ ) and start a new shell. +.. _uninstalling: + +Uninstalling +------------ + +To uninstall Bash-it, run the ``uninstall.sh`` script found in the ``$BASH_IT`` directory: + +.. code-block:: + + cd $BASH_IT + ./uninstall.sh + +This will restore your previous Bash profile. +After the uninstall script finishes, remove the Bash-it directory from your machine (\ ``rm -rf $BASH_IT``\ ) and start a new shell. diff --git a/docs/vcs_user.rst b/docs/vcs_user.rst index c6d31a57..962636e3 100644 --- a/docs/vcs_user.rst +++ b/docs/vcs_user.rst @@ -1,200 +1,200 @@ -.. _vcs_user: - -Prompt Version Control Information -================================== - -Bash-it provides prompt :ref:`themes` with the ability to check and display version control information for the current directory. -The information is retrieved for each directory and can slow down the navigation of projects with a large number of files and folders. -Turn version control checking off to prevent slow directory navigation within large projects. - -Controlling Flags -^^^^^^^^^^^^^^^^^ - -Bash-it provides a flag (\ ``SCM_CHECK``\ ) within the ``~/.bash_profile`` file that turns off/on version control information checking and display within all themes. -Version control checking is on by default unless explicitly turned off. - -Set ``SCM_CHECK`` to 'false' to **turn off** version control checks for all themes: - - -* ``export SCM_CHECK=false`` - -Set ``SCM_CHECK`` to 'true' (the default value) to **turn on** version control checks for all themes: - - -* ``export SCM_CHECK=true`` - -**NOTE:** -It is possible for themes to ignore the ``SCM_CHECK`` flag and query specific version control information directly. -For example, themes that use functions like ``git_prompt_vars`` skip the ``SCM_CHECK`` flag to retrieve and display git prompt information. -If you turned version control checking off and you still see version control information within your prompt, then functions like ``git_prompt_vars`` are most likely the reason why. - -.. _git_prompt: - -Git prompt -^^^^^^^^^^ - -Bash-it has some nice features related to Git, continue reading to know more about these features. - -Repository info in the prompt -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -Bash-it can show some information about Git repositories in the shell prompt: the current branch, tag or commit you are at, how many commits the local branch is ahead or behind from the remote branch, and if you have changes stashed. - -Additionally, you can view the status of your working copy and get the count of *staged*\ , *unstaged* and *untracked* files. -This feature is controlled through the flag ``SCM_GIT_SHOW_DETAILS`` as follows: - -Set ``SCM_GIT_SHOW_DETAILS`` to 'true' (the default value) to **show** the working copy details in your prompt: - - -* ``export SCM_GIT_SHOW_DETAILS=true`` - -Set ``SCM_GIT_SHOW_DETAILS`` to 'false' to **don't show** it: - - -* ``export SCM_GIT_SHOW_DETAILS=false`` - -**NOTE:** If using ``SCM_GIT_SHOW_MINIMAL_INFO=true``\ , then the value of ``SCM_GIT_SHOW_DETAILS`` is ignored. - -Remotes and remote branches -^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -In some git workflows, you must work with various remotes, for this reason, Bash-it can provide some useful information about your remotes and your remote branches, for example, the remote on you are working, or if your local branch is tracking a remote branch. - -You can control this feature with the flag ``SCM_GIT_SHOW_REMOTE_INFO`` as follows: - -Set ``SCM_GIT_SHOW_REMOTE_INFO`` to 'auto' (the default value) to activate it only when more than one remote is configured in the current repo: - - -* ``export SCM_GIT_SHOW_REMOTE_INFO=auto`` - -Set ``SCM_GIT_SHOW_REMOTE_INFO`` to 'true' to always activate the feature: - - -* ``export SCM_GIT_SHOW_REMOTE_INFO=true`` - -Set ``SCM_GIT_SHOW_REMOTE_INFO`` to 'false' to **disable the feature**\ : - - -* ``export SCM_GIT_SHOW_REMOTE_INFO=false`` - -**NOTE:** If using ``SCM_GIT_SHOW_MINIMAL_INFO=true``\ , then the value of ``SCM_GIT_SHOW_REMOTE_INFO`` is ignored. - -Untracked files -^^^^^^^^^^^^^^^ - -By default, the ``git status`` command shows information about *untracked* files. -This behavior can be controlled through command-line flags or git configuration files. -For big repositories, ignoring *untracked* files can make git faster. -Bash-it uses ``git status`` to gather the repo information it shows in the prompt, so in some circumstances, it can be useful to instruct Bash-it to ignore these files. -You can control this behavior with the flag ``SCM_GIT_IGNORE_UNTRACKED``\ : - -Set ``SCM_GIT_IGNORE_UNTRACKED`` to 'false' (the default value) to get information about *untracked* files: - - -* ``export SCM_GIT_IGNORE_UNTRACKED=false`` - -Set ``SCM_GIT_IGNORE_UNTRACKED`` to 'true' to **ignore** *untracked* files: - - -* ``export SCM_GIT_IGNORE_UNTRACKED=true`` - -Also, with this flag to false, Bash-it will not show the repository as dirty when the repo has *untracked* files, and will not display the count of *untracked* files. - -**NOTE:** If you set in git configuration file the option to ignore *untracked* files, this flag has no effect, and Bash-it will ignore *untracked* files always. - -Stash item count -^^^^^^^^^^^^^^^^ - -When ``SCM_GIT_SHOW_DETAILS`` is enabled, you can get the count of *stashed* items. This feature can be useful when a user has a lot of stash items. -This feature is controlled through the flag ``SCM_GIT_SHOW_STASH_INFO`` as follows: - -Set ``SCM_GIT_SHOW_STASH_INFO`` to 'true' (the default value) to **show** the count of stashed items: - - -* ``export SCM_GIT_SHOW_STASH_INFO=true`` - -Set ``SCM_GIT_SHOW_STASH_INFO`` to 'false' to **don't show** it: - - -* ``export SCM_GIT_SHOW_STASH_INFO=false`` - -Ahead/Behind Count -^^^^^^^^^^^^^^^^^^ - -When displaying information regarding whether or not the local branch is ahead or behind its remote counterpart, you can opt to display the number of commits ahead/behind. -This is useful if you only care whether or not you are ahead or behind and do not care how far ahead/behind you are. - -Set ``SCM_GIT_SHOW_COMMIT_COUNT`` to 'true' (the default value) to **show** the count of commits ahead/behind: - - -* ``export SCM_GIT_SHOW_COMMIT_COUNT=true`` - -Set ``SCM_GIT_SHOW_COMMIT_COUNT`` to 'false' to **don't show** it: - - -* ``export SCM_GIT_SHOW_COMMIT_COUNT=false`` - -Git user -^^^^^^^^ - -In some environments, it is useful to know the value of the current git user, which is used to mark all new commits. -For example, any organization that uses the practice of pair programming will typically author each commit with `combined names of the two authors `_. -When another pair uses the same pairing station, the authors are changed at the beginning of the session. - -To get up and running with this technique, run ``gem install pivotal_git_scripts``\ , and then edit your ``~/.pairs`` file, according to the specification on the `gem's homepage `_. -After that, you should be able to run ``git pair kg as`` to set the author to, eg. "Konstantin Gredeskoul and Alex Saxby", assuming they've been added to the ``~/.pairs`` file. -Please see gem's documentation for more information. - -To enable the display of the current pair in the prompt, you must set ``SCM_GIT_SHOW_CURRENT_USER`` to ``true``. -Once set, the ``SCM_CURRENT_USER`` variable will be automatically populated with the initials of the git author(s). -It will also be included in the default git prompt. -Even if you do not have ``git pair`` installed, as long as your ``user.name`` is set, your initials will be computed from your name and shown in the prompt. - -You can control the prefix and the suffix of this component using the two variables: - - -* ``export SCM_THEME_CURRENT_USER_PREFFIX=' ☺︎ '`` - -And - - -* ``export SCM_THEME_CURRENT_USER_SUFFIX=' ☺︎ '`` - -**NOTE:** If using ``SCM_GIT_SHOW_MINIMAL_INFO=true``\ , then the value of ``SCM_GIT_SHOW_CURRENT_USER`` is ignored. - -Git show minimal status info -^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -To speed up the prompt while still getting minimal git status information displayed such as the value of ``HEAD`` and whether there are any dirty objects, you can set: - -.. code-block:: - - export SCM_GIT_SHOW_MINIMAL_INFO=true - -Ignore repo status -^^^^^^^^^^^^^^^^^^ - -When working in repos with a large codebase, Bash-it can slow down your prompt when checking the repo status. -To avoid it, there is an option you can set via Git config to disable checking repo status in Bash-it. - -To disable checking the status in the current repo: - -.. code-block:: - - $ git config --add bash-it.hide-status 1 - -But if you would like to disable it globally, and stop checking the status for all of your repos: - -.. code-block:: - - $ git config --global --add bash-it.hide-status 1 - -Setting this flag globally has the same effect as ``SCM_CHECK=true``\ , but only for Git repos. - -Speed up git status calculations -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -As an alternative to ignoring repo status entirely, you can try out the ``gitstatus`` plugin. -This plugin speeds up all ``git status`` calculations by up to 10x times! - -**NOTE**\ : You will need to clone ``gitstatus`` repo from `here `_. +.. _vcs_user: + +Prompt Version Control Information +================================== + +Bash-it provides prompt :ref:`themes` with the ability to check and display version control information for the current directory. +The information is retrieved for each directory and can slow down the navigation of projects with a large number of files and folders. +Turn version control checking off to prevent slow directory navigation within large projects. + +Controlling Flags +^^^^^^^^^^^^^^^^^ + +Bash-it provides a flag (\ ``SCM_CHECK``\ ) within the ``~/.bash_profile`` file that turns off/on version control information checking and display within all themes. +Version control checking is on by default unless explicitly turned off. + +Set ``SCM_CHECK`` to 'false' to **turn off** version control checks for all themes: + + +* ``export SCM_CHECK=false`` + +Set ``SCM_CHECK`` to 'true' (the default value) to **turn on** version control checks for all themes: + + +* ``export SCM_CHECK=true`` + +**NOTE:** +It is possible for themes to ignore the ``SCM_CHECK`` flag and query specific version control information directly. +For example, themes that use functions like ``git_prompt_vars`` skip the ``SCM_CHECK`` flag to retrieve and display git prompt information. +If you turned version control checking off and you still see version control information within your prompt, then functions like ``git_prompt_vars`` are most likely the reason why. + +.. _git_prompt: + +Git prompt +^^^^^^^^^^ + +Bash-it has some nice features related to Git, continue reading to know more about these features. + +Repository info in the prompt +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +Bash-it can show some information about Git repositories in the shell prompt: the current branch, tag or commit you are at, how many commits the local branch is ahead or behind from the remote branch, and if you have changes stashed. + +Additionally, you can view the status of your working copy and get the count of *staged*\ , *unstaged* and *untracked* files. +This feature is controlled through the flag ``SCM_GIT_SHOW_DETAILS`` as follows: + +Set ``SCM_GIT_SHOW_DETAILS`` to 'true' (the default value) to **show** the working copy details in your prompt: + + +* ``export SCM_GIT_SHOW_DETAILS=true`` + +Set ``SCM_GIT_SHOW_DETAILS`` to 'false' to **don't show** it: + + +* ``export SCM_GIT_SHOW_DETAILS=false`` + +**NOTE:** If using ``SCM_GIT_SHOW_MINIMAL_INFO=true``\ , then the value of ``SCM_GIT_SHOW_DETAILS`` is ignored. + +Remotes and remote branches +^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +In some git workflows, you must work with various remotes, for this reason, Bash-it can provide some useful information about your remotes and your remote branches, for example, the remote on you are working, or if your local branch is tracking a remote branch. + +You can control this feature with the flag ``SCM_GIT_SHOW_REMOTE_INFO`` as follows: + +Set ``SCM_GIT_SHOW_REMOTE_INFO`` to 'auto' (the default value) to activate it only when more than one remote is configured in the current repo: + + +* ``export SCM_GIT_SHOW_REMOTE_INFO=auto`` + +Set ``SCM_GIT_SHOW_REMOTE_INFO`` to 'true' to always activate the feature: + + +* ``export SCM_GIT_SHOW_REMOTE_INFO=true`` + +Set ``SCM_GIT_SHOW_REMOTE_INFO`` to 'false' to **disable the feature**\ : + + +* ``export SCM_GIT_SHOW_REMOTE_INFO=false`` + +**NOTE:** If using ``SCM_GIT_SHOW_MINIMAL_INFO=true``\ , then the value of ``SCM_GIT_SHOW_REMOTE_INFO`` is ignored. + +Untracked files +^^^^^^^^^^^^^^^ + +By default, the ``git status`` command shows information about *untracked* files. +This behavior can be controlled through command-line flags or git configuration files. +For big repositories, ignoring *untracked* files can make git faster. +Bash-it uses ``git status`` to gather the repo information it shows in the prompt, so in some circumstances, it can be useful to instruct Bash-it to ignore these files. +You can control this behavior with the flag ``SCM_GIT_IGNORE_UNTRACKED``\ : + +Set ``SCM_GIT_IGNORE_UNTRACKED`` to 'false' (the default value) to get information about *untracked* files: + + +* ``export SCM_GIT_IGNORE_UNTRACKED=false`` + +Set ``SCM_GIT_IGNORE_UNTRACKED`` to 'true' to **ignore** *untracked* files: + + +* ``export SCM_GIT_IGNORE_UNTRACKED=true`` + +Also, with this flag to false, Bash-it will not show the repository as dirty when the repo has *untracked* files, and will not display the count of *untracked* files. + +**NOTE:** If you set in git configuration file the option to ignore *untracked* files, this flag has no effect, and Bash-it will ignore *untracked* files always. + +Stash item count +^^^^^^^^^^^^^^^^ + +When ``SCM_GIT_SHOW_DETAILS`` is enabled, you can get the count of *stashed* items. This feature can be useful when a user has a lot of stash items. +This feature is controlled through the flag ``SCM_GIT_SHOW_STASH_INFO`` as follows: + +Set ``SCM_GIT_SHOW_STASH_INFO`` to 'true' (the default value) to **show** the count of stashed items: + + +* ``export SCM_GIT_SHOW_STASH_INFO=true`` + +Set ``SCM_GIT_SHOW_STASH_INFO`` to 'false' to **don't show** it: + + +* ``export SCM_GIT_SHOW_STASH_INFO=false`` + +Ahead/Behind Count +^^^^^^^^^^^^^^^^^^ + +When displaying information regarding whether or not the local branch is ahead or behind its remote counterpart, you can opt to display the number of commits ahead/behind. +This is useful if you only care whether or not you are ahead or behind and do not care how far ahead/behind you are. + +Set ``SCM_GIT_SHOW_COMMIT_COUNT`` to 'true' (the default value) to **show** the count of commits ahead/behind: + + +* ``export SCM_GIT_SHOW_COMMIT_COUNT=true`` + +Set ``SCM_GIT_SHOW_COMMIT_COUNT`` to 'false' to **don't show** it: + + +* ``export SCM_GIT_SHOW_COMMIT_COUNT=false`` + +Git user +^^^^^^^^ + +In some environments, it is useful to know the value of the current git user, which is used to mark all new commits. +For example, any organization that uses the practice of pair programming will typically author each commit with `combined names of the two authors `_. +When another pair uses the same pairing station, the authors are changed at the beginning of the session. + +To get up and running with this technique, run ``gem install pivotal_git_scripts``\ , and then edit your ``~/.pairs`` file, according to the specification on the `gem's homepage `_. +After that, you should be able to run ``git pair kg as`` to set the author to, eg. "Konstantin Gredeskoul and Alex Saxby", assuming they've been added to the ``~/.pairs`` file. +Please see gem's documentation for more information. + +To enable the display of the current pair in the prompt, you must set ``SCM_GIT_SHOW_CURRENT_USER`` to ``true``. +Once set, the ``SCM_CURRENT_USER`` variable will be automatically populated with the initials of the git author(s). +It will also be included in the default git prompt. +Even if you do not have ``git pair`` installed, as long as your ``user.name`` is set, your initials will be computed from your name and shown in the prompt. + +You can control the prefix and the suffix of this component using the two variables: + + +* ``export SCM_THEME_CURRENT_USER_PREFFIX=' ☺︎ '`` + +And + + +* ``export SCM_THEME_CURRENT_USER_SUFFIX=' ☺︎ '`` + +**NOTE:** If using ``SCM_GIT_SHOW_MINIMAL_INFO=true``\ , then the value of ``SCM_GIT_SHOW_CURRENT_USER`` is ignored. + +Git show minimal status info +^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +To speed up the prompt while still getting minimal git status information displayed such as the value of ``HEAD`` and whether there are any dirty objects, you can set: + +.. code-block:: + + export SCM_GIT_SHOW_MINIMAL_INFO=true + +Ignore repo status +^^^^^^^^^^^^^^^^^^ + +When working in repos with a large codebase, Bash-it can slow down your prompt when checking the repo status. +To avoid it, there is an option you can set via Git config to disable checking repo status in Bash-it. + +To disable checking the status in the current repo: + +.. code-block:: + + $ git config --add bash-it.hide-status 1 + +But if you would like to disable it globally, and stop checking the status for all of your repos: + +.. code-block:: + + $ git config --global --add bash-it.hide-status 1 + +Setting this flag globally has the same effect as ``SCM_CHECK=true``\ , but only for Git repos. + +Speed up git status calculations +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +As an alternative to ignoring repo status entirely, you can try out the ``gitstatus`` plugin. +This plugin speeds up all ``git status`` calculations by up to 10x times! + +**NOTE**\ : You will need to clone ``gitstatus`` repo from `here `_. diff --git a/hooks/check-clean-files-txt.sh b/hooks/check-clean-files-txt.sh index a37ee777..2dc7b15e 100755 --- a/hooks/check-clean-files-txt.sh +++ b/hooks/check-clean-files-txt.sh @@ -2,7 +2,8 @@ file=$1 # Should only be run on clean_files.txt -if [ "$file" != "clean_files.txt" ]; then +if [ "$file" != "clean_files.txt" ] + then echo "Please run this script on clean_files.txt only!" exit 1 fi @@ -14,12 +15,13 @@ function compare_lines() { [[ $line =~ "#" ]] && continue [[ $line == "" ]] && continue # Actual check - if [[ $prev > $line ]]; then + if [[ $prev > $line ]] + then echo "$line should be before $prev" exit 1 fi prev=$line - done <<< "$1" + done <<< "${1}" } # We compare using the legacy way diff --git a/hooks/dot-bash.sh b/hooks/dot-bash.sh index 253cb595..d3d1ed94 100755 --- a/hooks/dot-bash.sh +++ b/hooks/dot-bash.sh @@ -4,7 +4,8 @@ exit_code=0 for file in "$@"; do # Confirm file is not executable # - if [[ -x "${file}" ]]; then + if [[ -x "${file}" ]] + then echo "Bash include file \`${file}\` should not be executable" exit_code=1 fi @@ -12,7 +13,8 @@ for file in "$@"; do # Confirm expected schellcheck header # LINE1="$(head -n 1 "${file}")" - if [[ "${LINE1}" != "# shellcheck shell=bash" ]]; then + if [[ "${LINE1}" != "# shellcheck shell=bash" ]] + then echo "Bash include file \`${file}\` has bad/missing shellcheck header" exit_code=1 fi diff --git a/hooks/dot-sh.sh b/hooks/dot-sh.sh index e1086bb6..c9978855 100755 --- a/hooks/dot-sh.sh +++ b/hooks/dot-sh.sh @@ -4,7 +4,8 @@ exit_code=0 for file in "$@"; do # Confirm file is executable # - if [[ ! -x "${file}" ]]; then + if [[ ! -x "${file}" ]] + then echo "Bash file \`${file}\` is not executable" exit_code=1 fi @@ -12,7 +13,8 @@ for file in "$@"; do # Confirm expected #! header # LINE1="$(head -n 1 "${file}")" - if [[ "${LINE1}" != "#!/usr/bin/env bash" ]]; then + if [[ "${LINE1}" != "#!/usr/bin/env bash" ]] + then echo "Bash file \`${file}\` has bad/missing #! header" exit_code=1 fi diff --git a/install.sh b/install.sh index 58c25537..ea64688d 100755 --- a/install.sh +++ b/install.sh @@ -2,7 +2,12 @@ # bash-it installer # Show how to use this installer -function _bash-it_show_usage() { +function _bash-it_show_usage() +{ + ############ STACK_TRACE_BUILDER ##################### + Function_Name="${FUNCNAME[0]}" + Function_PATH="${Function_PATH}/${Function_Name}" + ###################################################### echo -e "\n$0 : Install bash-it" echo -e "Usage:\n$0 [arguments] \n" echo "Arguments:" @@ -15,13 +20,20 @@ function _bash-it_show_usage() { } # enable a thing -function _bash-it_load_one() { +function _bash-it_load_one() +{ + ############ STACK_TRACE_BUILDER ##################### + Function_Name="${FUNCNAME[0]}" + Function_PATH="${Function_PATH}/${Function_Name}" + ###################################################### + file_type=$1 file_to_enable=$2 mkdir -p "$BASH_IT/${file_type}/enabled" dest="${BASH_IT}/${file_type}/enabled/${file_to_enable}" - if [ ! -e "${dest}" ]; then + if [ ! -e "${dest}" ] + then ln -sf "../available/${file_to_enable}" "${dest}" else echo "File ${dest} exists, skipping" @@ -29,7 +41,13 @@ function _bash-it_load_one() { } # Interactively enable several things -function _bash-it_load_some() { +function _bash-it_load_some() +{ + ############ STACK_TRACE_BUILDER ##################### + Function_Name="${FUNCNAME[0]}" + Function_PATH="${Function_PATH}/${Function_Name}" + ###################################################### + file_type=$1 single_type=$(echo "$file_type" | sed -e "s/aliases$/alias/g" | sed -e "s/plugins$/plugin/g") enable_func="_enable-$single_type" @@ -56,33 +74,58 @@ function _bash-it_load_some() { } # Back up existing profile -function _bash-it_backup() { +function _bash-it_backup() +{ + ############ STACK_TRACE_BUILDER ##################### + Function_Name="${FUNCNAME[0]}" + Function_PATH="${Function_PATH}/${Function_Name}" + ###################################################### + test -w "$HOME/$CONFIG_FILE" \ && cp -aL "$HOME/$CONFIG_FILE" "$HOME/$CONFIG_FILE.bak" \ && echo -e "\033[0;32mYour original $CONFIG_FILE has been backed up to $CONFIG_FILE.bak\033[0m" } # Back up existing profile and create new one for bash-it -function _bash-it_backup_new() { +function _bash-it_backup_new() +{ + ############ STACK_TRACE_BUILDER ##################### + Function_Name="${FUNCNAME[0]}" + Function_PATH="${Function_PATH}/${Function_Name}" + ###################################################### + _bash-it_backup sed "s|{{BASH_IT}}|$BASH_IT|" "$BASH_IT/template/bash_profile.template.bash" > "$HOME/$CONFIG_FILE" echo -e "\033[0;32mCopied the template $CONFIG_FILE into ~/$CONFIG_FILE, edit this file to customize bash-it\033[0m" } # Back up existing profile and append bash-it templates at the end -function _bash-it_backup_append() { +function _bash-it_backup_append() +{ + ############ STACK_TRACE_BUILDER ##################### + Function_Name="${FUNCNAME[0]}" + Function_PATH="${Function_PATH}/${Function_Name}" + ###################################################### _bash-it_backup (sed "s|{{BASH_IT}}|$BASH_IT|" "$BASH_IT/template/bash_profile.template.bash" | tail -n +2) >> "$HOME/$CONFIG_FILE" echo -e "\033[0;32mBash-it template has been added to your $CONFIG_FILE\033[0m" } -function _bash-it_check_for_backup() { - if ! [[ -e "$HOME/$BACKUP_FILE" ]]; then +function _bash-it_check_for_backup() +{ + ############ STACK_TRACE_BUILDER ##################### + Function_Name="${FUNCNAME[0]}" + Function_PATH="${Function_PATH}/${Function_Name}" + ###################################################### + + if ! [[ -e "$HOME/$BACKUP_FILE" ]] + then return fi echo -e "\033[0;33mBackup file already exists. Make sure to backup your .bashrc before running this installation.\033[0m" >&2 - if [[ -z "${overwrite_backup}" ]]; then + if [[ -z "${overwrite_backup}" ]] + then while [[ -z "${silent}" ]]; do read -e -n 1 -r -p "Would you like to overwrite the existing backup? This will delete your existing backup file ($HOME/$BACKUP_FILE) [y/N] " RESP case $RESP in @@ -99,9 +142,11 @@ function _bash-it_check_for_backup() { esac done fi - if [[ -z "${overwrite_backup}" ]]; then + if [[ -z "${overwrite_backup}" ]] + then echo -e "\033[91mInstallation aborted. Please come back soon!\033[m" - if [[ -n "${silent}" ]]; then + if [[ -n "${silent}" ]] + then echo -e "\033[91mUse \"-f\" flag to force overwrite of backup.\033[m" fi exit 1 @@ -110,10 +155,17 @@ function _bash-it_check_for_backup() { fi } -function _bash-it_modify_config_files() { +function _bash-it_modify_config_files() +{ + ############ STACK_TRACE_BUILDER ##################### + Function_Name="${FUNCNAME[0]}" + Function_PATH="${Function_PATH}/${Function_Name}" + ###################################################### + _bash-it_check_for_backup - if [[ -z "${silent}" ]]; then + if [[ -z "${silent}" ]] + then while [[ -z "${append_to_config}" ]]; do read -e -n 1 -r -p "Would you like to keep your $CONFIG_FILE and append bash-it templates at the end? [y/N] " choice case $choice in @@ -130,7 +182,8 @@ function _bash-it_modify_config_files() { esac done fi - if [[ -n "${append_to_config}" ]]; then + if [[ -n "${append_to_config}" ]] + then # backup/append _bash-it_backup_append else @@ -173,12 +226,14 @@ done shift $((OPTIND - 1)) -if [[ -n "${silent}" && -n "${interactive}" ]]; then +if [[ -n "${silent}" && -n "${interactive}" ]] + then echo -e "\033[91mOptions --silent and --interactive are mutually exclusive. Please choose one or the other.\033[m" exit 1 fi -if [[ -n "${no_modify_config}" && -n "${append_to_config}" ]]; then +if [[ -n "${no_modify_config}" && -n "${append_to_config}" ]] + then echo -e "\033[91mOptions --no-modify-config and --append-to-config are mutually exclusive. Please choose one or the other.\033[m" exit 1 fi @@ -196,7 +251,8 @@ esac BACKUP_FILE=$CONFIG_FILE.bak echo "Installing bash-it" -if [[ -z "${no_modify_config}" ]]; then +if [[ -z "${no_modify_config}" ]] + then _bash-it_modify_config_files fi @@ -213,7 +269,8 @@ cite _about _param _example _group _author _version # shellcheck source=./lib/helpers.bash source "$BASH_IT/lib/helpers.bash" -if [[ -n $interactive && -z "${silent}" ]]; then +if [[ -n $interactive && -z "${silent}" ]] + then for type in "aliases" "plugins" "completion"; do echo -e "\033[0;32mEnabling ${type}\033[0m" _bash-it_load_some "$type" diff --git a/lib/appearance.bash b/lib/appearance.bash index e77a1a80..6eee02bb 100644 --- a/lib/appearance.bash +++ b/lib/appearance.bash @@ -7,10 +7,13 @@ export CLICOLOR # Load the theme # shellcheck disable=SC1090 -if [[ -n "${BASH_IT_THEME:-}" ]]; then - if [[ -f "${BASH_IT_THEME}" ]]; then +if [[ -n "${BASH_IT_THEME:-}" ]] + then + if [[ -f "${BASH_IT_THEME}" ]] + then source "${BASH_IT_THEME}" - elif [[ -f "$CUSTOM_THEME_DIR/$BASH_IT_THEME/$BASH_IT_THEME.theme.bash" ]]; then + elif [[ -f "$CUSTOM_THEME_DIR/$BASH_IT_THEME/$BASH_IT_THEME.theme.bash" ]] + then source "$CUSTOM_THEME_DIR/$BASH_IT_THEME/$BASH_IT_THEME.theme.bash" else source "$BASH_IT/themes/$BASH_IT_THEME/$BASH_IT_THEME.theme.bash" diff --git a/lib/command_duration.bash b/lib/command_duration.bash index 2b5e1b4b..951e11a8 100644 --- a/lib/command_duration.bash +++ b/lib/command_duration.bash @@ -45,11 +45,13 @@ function _command_duration() { 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 command_duration="$((current_time_seconds - command_start_seconds))" - if ((current_time_deciseconds >= command_start_deciseconds)); then + if ((current_time_deciseconds >= command_start_deciseconds)) + then deciseconds="$((current_time_deciseconds - command_start_deciseconds))" else ((command_duration -= 1)) @@ -59,12 +61,14 @@ function _command_duration() { command_duration=0 fi - if ((command_duration >= COMMAND_DURATION_MIN_SECONDS)); then + if ((command_duration >= COMMAND_DURATION_MIN_SECONDS)) + then minutes=$((command_duration / 60)) seconds=$((command_duration % 60)) _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" else printf "%s %s%d.%01ds" "${COMMAND_DURATION_ICON:-}" "${COMMAND_DURATION_COLOR:-}" "$seconds" "$deciseconds" diff --git a/lib/helpers.bash b/lib/helpers.bash index 3675b0f2..00fc1b4a 100644 --- a/lib/helpers.bash +++ b/lib/helpers.bash @@ -14,7 +14,8 @@ BASH_IT_LOAD_PRIORITY_SEPARATOR="---" # To use this in Bash-it for inline replacements with `sed`, use the following syntax: # sed "${BASH_IT_SED_I_PARAMETERS[@]}" -e "..." file # shellcheck disable=SC2034 # expected for this case -if sed --version > /dev/null 2>&1; then +if sed --version > /dev/null 2>&1 + then # GNU sed accepts "long" options BASH_IT_SED_I_PARAMETERS=('-i') else @@ -29,7 +30,8 @@ function _command_exists() { _example '$ _command_exists ls && echo exists' _group 'lib' local msg="${2:-Command '$1' does not exist}" - if type -t "$1" > /dev/null; then + if type -t "${1}" > /dev/null + then return 0 else _log_debug "$msg" @@ -44,7 +46,8 @@ function _binary_exists() { _example '$ _binary_exists ls && echo exists' _group 'lib' local msg="${2:-Binary '$1' does not exist}" - if type -P "$1" > /dev/null; then + if type -P "${1}" > /dev/null + then return 0 else _log_debug "$msg" @@ -59,7 +62,8 @@ function _completion_exists() { _example '$ _completion_exists gh && echo exists' _group 'lib' local msg="${2:-Completion for '$1' already exists}" - if complete -p "$1" &> /dev/null; then + if complete -p "${1}" &> /dev/null + then _log_debug "$msg" return 0 else @@ -68,9 +72,11 @@ function _completion_exists() { } function _bash_it_homebrew_check() { - if _binary_exists 'brew'; then + if _binary_exists 'brew' + then # Homebrew is installed - if [[ "${BASH_IT_HOMEBREW_PREFIX:-unset}" == 'unset' ]]; then + if [[ "${BASH_IT_HOMEBREW_PREFIX:-unset}" == 'unset' ]] + then # variable isn't set BASH_IT_HOMEBREW_PREFIX="$(brew --prefix)" else @@ -173,11 +179,14 @@ function bash-it() { esac # pluralize component if necessary - if ! _is_function "$func"; then - if _is_function "${func}s"; then + if ! _is_function "$func" + then + if _is_function "${func}s" + then func="${func}s" else - if _is_function "${func}es"; then + if _is_function "${func}es" + then func="${func}es" else echo "oops! $component is not a valid option!" @@ -187,7 +196,8 @@ function bash-it() { fi fi - if [[ "$verb" == "enable" || "$verb" == "disable" ]]; then + if [[ "$verb" == "enable" || "$verb" == "disable" ]] + then # Automatically run a migration if required _bash-it-migrate @@ -195,7 +205,8 @@ function bash-it() { "$func" "$arg" done - if [[ -n "${BASH_IT_AUTOMATIC_RELOAD_AFTER_CONFIG_CHANGE:-}" ]]; then + if [[ -n "${BASH_IT_AUTOMATIC_RELOAD_AFTER_CONFIG_CHANGE:-}" ]] + then _bash-it-reload fi else @@ -211,7 +222,8 @@ 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-fgrep -q 'function'; then + if LC_ALL=C type -t "${1}" | _bash-it-fgrep -q 'function' + then return 0 else _log_debug "$msg" @@ -258,7 +270,8 @@ function _bash-it_update_migrate_and_restart() { _about 'Checks out the wanted version, pops directory and restart. Does not return (because of the restart!)' _param '1: Which branch to checkout to' _param '2: Which type of version we are using' - if git checkout "${1?}" &> /dev/null; then + if git checkout "${1?}" &> /dev/null + then echo "Bash-it successfully updated." echo "" echo "Migrating your installation to the latest ${2:-} version now..." @@ -280,7 +293,8 @@ function _bash-it-update-() { local silent word DIFF version TARGET revision status revert log_color RESP for word in "$@"; do - if [[ "${word}" == "--silent" || "${word}" == "-s" ]]; then + if [[ "${word}" == "--silent" || "${word}" == "-s" ]] + then silent=true fi done @@ -288,27 +302,32 @@ function _bash-it-update-() { pushd "${BASH_IT?}" > /dev/null || return 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" popd > /dev/null || return return 1 fi - if [[ -z "$BASH_IT_REMOTE" ]]; then + if [[ -z "$BASH_IT_REMOTE" ]] + then BASH_IT_REMOTE="origin" fi git fetch "$BASH_IT_REMOTE" --tags &> /dev/null - if [[ -z "$BASH_IT_DEVELOPMENT_BRANCH" ]]; then + if [[ -z "$BASH_IT_DEVELOPMENT_BRANCH" ]] + then BASH_IT_DEVELOPMENT_BRANCH="master" fi # Defaults to stable update - if [[ -z "${1:-}" || "$1" == "stable" ]]; then + if [[ -z "${1:-}" || "${1}" == "stable" ]] + then version="stable" TARGET=$(git describe --tags "$(git rev-list --tags --max-count=1)" 2> /dev/null) - if [[ -z "$TARGET" ]]; then + if [[ -z "$TARGET" ]] + then echo "Can not find tags, so can not update to latest stable version..." popd > /dev/null || return return @@ -321,14 +340,17 @@ function _bash-it-update-() { revision="HEAD..${TARGET}" status="$(git rev-list "${revision}" 2> /dev/null)" - if [[ -z "${status}" && "${version}" == "stable" ]]; then + if [[ -z "${status}" && "${version}" == "stable" ]] + then revision="${TARGET}..HEAD" status="$(git rev-list "${revision}" 2> /dev/null)" revert=true fi - if [[ -n "${status}" ]]; then - if [[ -n "${revert}" ]]; then + if [[ -n "${status}" ]] + then + if [[ -n "${revert}" ]] + then echo "Your version is a more recent development version ($(git log -1 --format=%h HEAD))" echo "You can continue in order to revert and update to the latest stable version" echo "" @@ -338,7 +360,8 @@ function _bash-it-update-() { git log --no-merges --format="${log_color}%h: %s (%an)" "${revision}" echo "" - if [[ -n "${silent}" ]]; then + if [[ -n "${silent}" ]] + then echo "Updating to ${TARGET}($(git log -1 --format=%h "${TARGET}"))..." _bash-it_update_migrate_and_restart "$TARGET" "$version" else @@ -356,7 +379,8 @@ function _bash-it-update-() { esac fi else - if [[ "${version}" == "stable" ]]; then + if [[ "${version}" == "stable" ]] + then echo "You're on the latest stable version. If you want to check out the latest 'dev' version, please run \"bash-it update dev\"" else echo "Bash-it is up to date, nothing to do!" @@ -394,11 +418,13 @@ function _bash-it-migrate() { done done - if [[ -n "${BASH_IT_AUTOMATIC_RELOAD_AFTER_CONFIG_CHANGE:-}" ]]; then + if [[ -n "${BASH_IT_AUTOMATIC_RELOAD_AFTER_CONFIG_CHANGE:-}" ]] + then _bash-it-reload fi - if [[ "$migrated_something" == "true" ]]; then + if [[ "$migrated_something" == "true" ]] + then echo "" echo "If any migration errors were reported, please try the following: reload && bash-it migrate" fi @@ -412,13 +438,15 @@ function _bash-it-version() { pushd "${BASH_IT?}" > /dev/null || return - if [[ -z "${BASH_IT_REMOTE:-}" ]]; then + if [[ -z "${BASH_IT_REMOTE:-}" ]] + then BASH_IT_REMOTE="origin" fi BASH_IT_GIT_REMOTE="$(git remote get-url "$BASH_IT_REMOTE")" BASH_IT_GIT_URL="${BASH_IT_GIT_REMOTE%.git}" - if [[ "$BASH_IT_GIT_URL" == *"git@"* ]]; then + if [[ "$BASH_IT_GIT_URL" == *"git@"* ]] + then # Fix URL in case it is ssh based URL BASH_IT_GIT_URL="${BASH_IT_GIT_URL/://}" BASH_IT_GIT_URL="${BASH_IT_GIT_URL/git@/https://}" @@ -426,7 +454,8 @@ function _bash-it-version() { current_tag="$(git describe --exact-match --tags 2> /dev/null)" - if [[ -z "$current_tag" ]]; then + if [[ -z "$current_tag" ]] + then BASH_IT_GIT_VERSION_INFO="$(git log --pretty=format:'%h on %aI' -n 1)" TARGET="${BASH_IT_GIT_VERSION_INFO%% *}" echo "Version type: dev" @@ -500,7 +529,8 @@ function _bash-it-profile-save() { done local profile_path="${BASH_IT}/profiles/${name}.bash_it" RESP - if [[ -s "$profile_path" ]]; then + if [[ -s "$profile_path" ]] + then echo -e "${echo_yellow?}Profile '$name' already exists.${echo_reset_color?}" while true; do read -r -e -n 1 -p "Would you like to overwrite existing profile? [y/N] " RESP @@ -525,8 +555,10 @@ function _bash-it-profile-save() { for subdirectory in "plugins" "completion" "aliases"; do echo "Saving $subdirectory configuration..." for f in "${BASH_IT}/$subdirectory/available"/*.bash; do - if _bash-it-component-item-is-enabled "$f"; then - if [[ -z "${component_exists:-}" ]]; then + if _bash-it-component-item-is-enabled "$f" + then + if [[ -z "${component_exists:-}" ]] + then # This is the first component of this type, print the header component_exists="yes" something_exists="yes" @@ -538,7 +570,8 @@ function _bash-it-profile-save() { fi done done - if [[ -z "${something_exists:-}" ]]; then + if [[ -z "${something_exists:-}" ]] + then echo "It seems like no configuration was enabled.." echo "Make sure to double check that this is the wanted behavior." fi @@ -549,7 +582,7 @@ function _bash-it-profile-save() { echo "Load the profile by invoking \"bash-it profile load $name\"" } -_bash-it-profile-load-parse-profile() { +function _bash-it-profile-load-parse-profile() { _about 'Internal function used to parse the profile file' _param '1: path to the profile file' _param '2: dry run- only check integrity of the profile file' @@ -567,7 +600,8 @@ _bash-it-profile-load-parse-profile() { to_enable=("${BASH_IT}/$subdirectory/available/$component.${subdirectory%s}"*.bash) # Ignore botched lines - if [[ ! -e "${to_enable[0]}" ]]; then + if [[ ! -e "${to_enable[0]}" ]] + then echo -e "${echo_orange?}Bad line(#$num) in profile, aborting load...${line[*]}${echo_reset_color?}" bad="bad line" break @@ -582,7 +616,7 @@ _bash-it-profile-load-parse-profile() { [[ -z ${bad:-} ]] } -_bash-it-profile-list() { +function _bash-it-profile-list() { about 'lists all profiles from the "profiles" directory' _group 'lib' local profile @@ -594,58 +628,64 @@ _bash-it-profile-list() { done } -_bash-it-profile-rm() { +function _bash-it-profile-rm() { about 'Removes a profile from the "profiles" directory' _group 'lib' local name="${1:-}" - if [[ -z $name ]]; then + if [[ -z $name ]] + then echo -e "${echo_orange?}Please specify profile name to remove...${echo_reset_color?}" return 1 fi # Users should not be allowed to delete the default profile - if [[ $name == "default" ]]; then + if [[ $name == "default" ]] + then echo -e "${echo_orange?}Can not remove the default profile...${echo_reset_color?}" return 1 fi local profile_path="${BASH_IT}/profiles/$name.bash_it" - if [[ ! -f "$profile_path" ]]; then + if [[ ! -f "${profile_path}" ]] + then echo -e "${echo_orange?}Could not find profile '$name'...${echo_reset_color?}" return 1 fi - command rm "$profile_path" + command rm "${profile_path}" echo "Removed profile '$name' successfully!" } -_bash-it-profile-load() { +function _bash-it-profile-load() { _about 'loads a configuration from the "profiles" directory' _group 'lib' local name="${1:-}" - if [[ -z $name ]]; then + if [[ -z $name ]] + then echo -e "${echo_orange?}Please specify profile name to load, not changing configuration...${echo_reset_color?}" return 1 fi local profile_path="${BASH_IT}/profiles/$name.bash_it" - if [[ ! -f "$profile_path" ]]; then - echo -e "${echo_orange?}Could not find profile '$name', not changing configuration...${echo_reset_color?}" + if [[ ! -f "${profile_path}" ]] + then + echo -e "${echo_orange?}Could not find profile '${name}', not changing configuration...${echo_reset_color?}" return 1 fi - echo "Trying to parse profile '$name'..." - if _bash-it-profile-load-parse-profile "$profile_path" "dry"; then - echo "Profile '$name' parsed successfully!" + echo "Trying to parse profile '${name}'..." + if _bash-it-profile-load-parse-profile "$profile_path" "dry" + then + echo "Profile '${name}' parsed successfully!" echo "Disabling current configuration..." _disable-all echo "" echo "Enabling configuration based on profile..." - _bash-it-profile-load-parse-profile "$profile_path" + _bash-it-profile-load-parse-profile "${profile_path}" echo "" - echo "Profile '$name' enabled!" + echo "Profile '${name}' enabled!" else false # failure fi @@ -675,10 +715,10 @@ function _bash-it-describe() { _example '$ _bash-it-describe "plugins" "a" "plugin" "Plugin"' local subdirectory preposition file_type column_header f enabled enabled_file - subdirectory="$1" - preposition="$2" - file_type="$3" - column_header="$4" + subdirectory="${1}" + preposition="${2}" + file_type="${3}" + column_header="${4}" printf "%-20s %-10s %s\n" "$column_header" 'Enabled?' 'Description' for f in "${BASH_IT?}/$subdirectory/available"/*.*.bash; do @@ -688,10 +728,10 @@ function _bash-it-describe() { _bash-it-component-item-is-enabled "${file_type}" "${enabled_file}" && enabled='x' printf "%-20s %-10s %s\n" "$enabled_file" "[${enabled:- }]" "$(metafor "about-$file_type" < "$f")" done - printf '\n%s\n' "to enable $preposition $file_type, do:" - printf '%s\n' "$ bash-it enable $file_type <$file_type name> [$file_type name]... -or- $ bash-it enable $file_type all" - printf '\n%s\n' "to disable $preposition $file_type, do:" - printf '%s\n' "$ bash-it disable $file_type <$file_type name> [$file_type name]... -or- $ bash-it disable $file_type all" + printf '\n%s\n' "to enable ${preposition} ${file_type}, do:" + printf '%s\n' "$ bash-it enable ${file_type} <$file_type name> [${file_type} name]... -or- $ bash-it enable ${file_type} all" + printf '\n%s\n' "to disable ${preposition} ${file_type}, do:" + printf '%s\n' "$ bash-it disable ${file_type} <$file_type name> [${file_type} name]... -or- $ bash-it disable ${file_type} all" } function _on-disable-callback() { @@ -701,8 +741,9 @@ function _on-disable-callback() { _group 'lib' local callback="${1}_on_disable" - if _command_exists "$callback"; then - "$callback" + if _command_exists "${callback}" + then + "${callback}" fi } @@ -755,7 +796,8 @@ function _disable-thing() { local file_type="${2?}" local file_entity="${3:-}" - if [[ -z "$file_entity" ]]; then + if [[ -z "$file_entity" ]] + then reference "disable-$file_type" return fi @@ -763,9 +805,10 @@ function _disable-thing() { local f suffix _bash_it_config_file plugin suffix="${subdirectory/plugins/plugin}" - if [[ "$file_entity" == "all" ]]; then + if [[ "$file_entity" == "all" ]] + then # Disable everything that's using the old structure and everything in the global "enabled" directory. - for _bash_it_config_file in "${BASH_IT}/$subdirectory/enabled"/*."${suffix}.bash" "${BASH_IT}/enabled"/*".${suffix}.bash"; do + for _bash_it_config_file in "${BASH_IT}/${subdirectory}/enabled"/*."${suffix}.bash" "${BASH_IT}/enabled"/*".${suffix}.bash"; do rm -f "$_bash_it_config_file" done else @@ -774,25 +817,28 @@ function _disable-thing() { # node.plugin.bash # Either one will be matched by this glob for plugin in "${BASH_IT}/enabled"/[[:digit:]][[:digit:]][[:digit:]]"${BASH_IT_LOAD_PRIORITY_SEPARATOR}${file_entity}.${suffix}.bash" "${BASH_IT}/$subdirectory/enabled/"{[[:digit:]][[:digit:]][[:digit:]]"${BASH_IT_LOAD_PRIORITY_SEPARATOR}${file_entity}.${suffix}.bash","${file_entity}.${suffix}.bash"}; do - if [[ -e "${plugin}" ]]; then + if [[ -e "${plugin}" ]] + then rm -f "${plugin}" plugin= break fi done - if [[ -n "${plugin}" ]]; then - printf '%s\n' "sorry, $file_entity does not appear to be an enabled $file_type." + if [[ -n "${plugin}" ]] + then + printf '%s\n' "sorry, ${file_entity} does not appear to be an enabled ${file_type}." return fi fi _bash-it-component-cache-clean "${file_type}" - if [[ "$file_entity" == "all" ]]; then - _bash-it-component-pluralize "$file_type" file_type - printf '%s\n' "$file_entity ${file_type} disabled." + if [[ "$file_entity" == "all" ]] + then + _bash-it-component-pluralize "${file_type}" file_type + printf '%s\n' "${file_entity} ${file_type} disabled." else - printf '%s\n' "$file_entity disabled." + printf '%s\n' "${file_entity} disabled." fi } @@ -830,7 +876,7 @@ function _enable-completion() { _example '$ enable-completion git' _group 'lib' - _enable-thing "completion" "completion" "${1?}" "$BASH_IT_LOAD_PRIORITY_COMPLETION" + _enable-thing "completion" "completion" "${1?}" "${BASH_IT_LOAD_PRIORITY_COMPLETION}" } function _enable-thing() { @@ -847,7 +893,8 @@ function _enable-thing() { local file_entity="${3:-}" local load_priority="${4:-500}" - if [[ -z "$file_entity" ]]; then + if [[ -z "$file_entity" ]] + then reference "enable-$file_type" return fi @@ -855,23 +902,26 @@ function _enable-thing() { local _bash_it_config_file to_enable to_enables enabled_plugin local_file_priority use_load_priority local suffix="${subdirectory/plugins/plugin}" - if [[ "$file_entity" == "all" ]]; then + if [[ "$file_entity" == "all" ]] + then for _bash_it_config_file in "${BASH_IT}/$subdirectory/available"/*.bash; do to_enable="${_bash_it_config_file##*/}" - _enable-thing "$subdirectory" "$file_type" "${to_enable%."${file_type/alias/aliases}".bash}" "$load_priority" + _enable-thing "$subdirectory" "$file_type" "${to_enable%."${file_type/alias/aliases}".bash}" "${load_priority}" done else - to_enables=("${BASH_IT}/$subdirectory/available/$file_entity.${suffix}.bash") - if [[ ! -e "${to_enables[0]}" ]]; then - printf '%s\n' "sorry, $file_entity does not appear to be an available $file_type." + to_enables=("${BASH_IT}/$subdirectory/available/${file_entity}.${suffix}.bash") + if [[ ! -e "${to_enables[0]}" ]] + then + printf '%s\n' "sorry, ${file_entity} does not appear to be an available ${file_type}." return fi to_enable="${to_enables[0]##*/}" # Check for existence of the file using a wildcard, since we don't know which priority might have been used when enabling it. for enabled_plugin in "${BASH_IT}/$subdirectory/enabled"/{[[:digit:]][[:digit:]][[:digit:]]"${BASH_IT_LOAD_PRIORITY_SEPARATOR}${to_enable}","${to_enable}"} "${BASH_IT}/enabled"/[[:digit:]][[:digit:]][[:digit:]]"${BASH_IT_LOAD_PRIORITY_SEPARATOR?}${to_enable}"; do - if [[ -e "${enabled_plugin}" ]]; then - printf '%s\n' "$file_entity is already enabled." + if [[ -e "${enabled_plugin}" ]] + then + printf '%s\n' "${file_entity} is already enabled." return fi done @@ -882,12 +932,12 @@ function _enable-thing() { local_file_priority="$(awk -F': ' '$1 == "# BASH_IT_LOAD_PRIORITY" { print $2 }' "${BASH_IT}/$subdirectory/available/$to_enable")" use_load_priority="${local_file_priority:-$load_priority}" - ln -s "../$subdirectory/available/$to_enable" "${BASH_IT}/enabled/${use_load_priority}${BASH_IT_LOAD_PRIORITY_SEPARATOR}${to_enable}" + ln -s "../${subdirectory}/available/${to_enable}" "${BASH_IT}/enabled/${use_load_priority}${BASH_IT_LOAD_PRIORITY_SEPARATOR}${to_enable}" fi _bash-it-component-cache-clean "${file_type}" - printf '%s\n' "$file_entity enabled with priority $use_load_priority." + printf '%s\n' "$file_entity enabled with priority ${use_load_priority}." } function _help-completions() { @@ -903,8 +953,9 @@ function _help-aliases() { _example '$ alias-help' _example '$ alias-help git' - if [[ -n "${1:-}" ]]; then - case "$1" in + if [[ -n "${1:-}" ]] + then + case "${1}" in custom) alias_path='custom.aliases.bash' ;; @@ -912,7 +963,7 @@ function _help-aliases() { alias_path="available/${1}.aliases.bash" ;; esac - metafor alias < "${BASH_IT}/aliases/$alias_path" | sed "s/$/'/" + metafor alias < "${BASH_IT}/aliases/${alias_path}" | sed "s/$/'/" else local f @@ -921,7 +972,8 @@ function _help-aliases() { _help-list-aliases "$f" done - if [[ -e "${BASH_IT}/aliases/custom.aliases.bash" ]]; then + if [[ -e "${BASH_IT}/aliases/custom.aliases.bash" ]] + then _help-list-aliases "${BASH_IT}/aliases/custom.aliases.bash" fi fi @@ -932,7 +984,7 @@ function _help-list-aliases() { file="$(_bash-it-get-component-name-from-path "${1?}")" printf '\n\n%s:\n' "${file}" # metafor() strips trailing quotes, restore them with sed.. - metafor alias < "$1" | sed "s/$/'/" + metafor alias < "${1}" | sed "s/$/'/" } function _help-plugins() { @@ -946,22 +998,23 @@ function _help-plugins() { while read -ra func; do defn="$(declare -f "${func[2]}")" group="$(metafor group <<< "$defn")" - if [[ -z "$group" ]]; then + if [[ -z "$group" ]] + then group='misc' fi about="$(metafor about <<< "$defn")" - _letterpress "$about" "${func[2]}" >> "$grouplist.$group" - echo "$grouplist.$group" >> "$grouplist" + _letterpress "${about}" "${func[2]}" >> "${grouplist}.${group}" + echo "${grouplist}.${group}" >> "${grouplist}" done < <(declare -F) # clear progress message printf '\r%s\n' ' ' while IFS= read -r gfile; do printf '%s\n' "${gfile##*.}:" - cat "$gfile" + cat "${gfile}" printf '\n' - rm "$gfile" 2> /dev/null - done < <(sort -u "$grouplist") | less - rm "$grouplist" 2> /dev/null + rm "${gfile}" 2> /dev/null + done < <(sort -u "${grouplist}") | less + rm "${grouplist}" 2> /dev/null } function _help-profile() { @@ -1003,8 +1056,10 @@ function pathmunge() { example 'pathmunge /path/to/dir is equivalent to PATH=/path/to/dir:$PATH' example 'pathmunge /path/to/dir after is equivalent to PATH=$PATH:/path/to/dir' - if [[ -d "${1:-}" && ! $PATH =~ (^|:)"${1}"($|:) ]]; then - if [[ "${2:-before}" == "after" ]]; then + if [[ -d "${1:-}" && ! $PATH =~ (^|:)"${1}"($|:) ]] + then + if [[ "${2:-before}" == "after" ]] + then export PATH="$PATH:${1}" else export PATH="${1}:$PATH" @@ -1029,7 +1084,8 @@ function _bash-it-find-in-ancestor() ( # To keep things simple, we do not search the root dir. while [[ "${PWD}" != '/' ]]; do for kin in "$@"; do - if [[ -r "${PWD}/${kin}" ]]; then + if [[ -r "${PWD}/${kin}" ]] + then printf '%s' "${PWD}" return "$?" fi diff --git a/lib/log.bash b/lib/log.bash index a8cb8080..86d09806 100644 --- a/lib/log.bash +++ b/lib/log.bash @@ -31,8 +31,10 @@ function _bash-it-log-prefix-by-path() { component_name="${component_name##[[:digit:]][[:digit:]][[:digit:]]"${BASH_IT_LOAD_PRIORITY_SEPARATOR:----}"}" # best-guess for files without a type - if [[ "${component_type:-${component_name}}" == "${component_name}" ]]; then - if [[ "${component_directory}" == *'vendor'* ]]; then + if [[ "${component_type:-${component_name}}" == "${component_name}" ]] + then + if [[ "${component_directory}" == *'vendor'* ]] + then component_type='vendor' else component_type="${component_directory##*/}" @@ -59,7 +61,8 @@ function _bash-it-log-message() { local color="${1-${echo_cyan:-}}" local level="${2:-TRACE}" local message="${level%: }: ${prefix%: }: ${3?}" - if _has_colors; then + if _has_colors + then printf '%b%s%b\n' "${color}" "${message}" "${echo_normal:-}" else printf '%s\n' "${message}" @@ -72,8 +75,9 @@ function _log_debug() { : _example '$ _log_debug "Loading plugin git..."' : _group 'log' - if [[ "${BASH_IT_LOG_LEVEL:-0}" -ge "${BASH_IT_LOG_LEVEL_INFO?}" ]]; then - _bash-it-log-message "${echo_green:-}" "DEBUG: " "$1" + if [[ "${BASH_IT_LOG_LEVEL:-0}" -ge "${BASH_IT_LOG_LEVEL_INFO?}" ]] + then + _bash-it-log-message "${echo_green:-}" "DEBUG: " "${1}" fi } @@ -83,8 +87,9 @@ function _log_warning() { : _example '$ _log_warning "git binary not found, disabling git plugin..."' : _group 'log' - if [[ "${BASH_IT_LOG_LEVEL:-0}" -ge "${BASH_IT_LOG_LEVEL_WARNING?}" ]]; then - _bash-it-log-message "${echo_yellow:-}" " WARN: " "$1" + if [[ "${BASH_IT_LOG_LEVEL:-0}" -ge "${BASH_IT_LOG_LEVEL_WARNING?}" ]] + then + _bash-it-log-message "${echo_yellow:-}" " WARN: " "${1}" fi } @@ -94,7 +99,8 @@ function _log_error() { : _example '$ _log_error "Failed to load git plugin..."' : _group 'log' - if [[ "${BASH_IT_LOG_LEVEL:-0}" -ge "${BASH_IT_LOG_LEVEL_ERROR?}" ]]; then - _bash-it-log-message "${echo_red:-}" "ERROR: " "$1" + if [[ "${BASH_IT_LOG_LEVEL:-0}" -ge "${BASH_IT_LOG_LEVEL_ERROR?}" ]] + then + _bash-it-log-message "${echo_red:-}" "ERROR: " "${1}" fi } diff --git a/lib/preexec.bash b/lib/preexec.bash index 1dbe8899..f18029b4 100644 --- a/lib/preexec.bash +++ b/lib/preexec.bash @@ -40,19 +40,23 @@ function __check_preexec_conflict() { function safe_append_prompt_command() { local prompt_re prompt_er f - if [[ "${bash_preexec_imported:-${__bp_imported:-missing}}" == "defined" ]]; then + if [[ "${bash_preexec_imported:-${__bp_imported:-missing}}" == "defined" ]] + then # We are using bash-preexec __bp_trim_whitespace f "${1?}" - if ! __check_precmd_conflict "${f}"; then + if ! __check_precmd_conflict "${f}" + then precmd_functions+=("${f}") fi else # Match on word-boundaries prompt_re='(^|[^[:alnum:]_])' prompt_er='([^[:alnum:]_]|$)' - if [[ ${PROMPT_COMMAND} =~ ${prompt_re}"${1}"${prompt_er} ]]; then + if [[ ${PROMPT_COMMAND} =~ ${prompt_re}"${1}"${prompt_er} ]] + then return - elif [[ -z ${PROMPT_COMMAND} ]]; then + elif [[ -z ${PROMPT_COMMAND} ]] + then PROMPT_COMMAND="${1}" else PROMPT_COMMAND="${1};${PROMPT_COMMAND}" @@ -63,10 +67,12 @@ function safe_append_prompt_command() { function safe_append_preexec() { local prompt_re f - if [[ "${bash_preexec_imported:-${__bp_imported:-missing}}" == "defined" ]]; then + if [[ "${bash_preexec_imported:-${__bp_imported:-missing}}" == "defined" ]] + then # We are using bash-preexec __bp_trim_whitespace f "${1?}" - if ! __check_preexec_conflict "${f}"; then + if ! __check_preexec_conflict "${f}" + then preexec_functions+=("${f}") fi else diff --git a/lib/preview.bash b/lib/preview.bash index 46c1618a..0229536e 100644 --- a/lib/preview.bash +++ b/lib/preview.bash @@ -6,7 +6,8 @@ function _bash-it-preview() { local BASH_IT_THEME BASH_IT_LOG_LEVEL local themes IFS=$'\n' cur - if [[ $# -gt '0' ]]; then + if [[ $# -gt '0' ]] + then themes=("$@") else themes=("${BASH_IT?}/themes"/*/*.theme.bash) @@ -14,7 +15,8 @@ function _bash-it-preview() { themes=("${themes[@]%.theme.bash}") fi - if [[ ${COMP_CWORD:-} -gt '0' ]]; then + if [[ ${COMP_CWORD:-} -gt '0' ]] + then cur="${COMP_WORDS[COMP_CWORD]}" read -d '' -ra COMPREPLY < <(compgen -W "all${IFS}${themes[*]}" -- "${cur}") return @@ -28,7 +30,8 @@ function _bash-it-preview() { done } -if [[ -n "${BASH_PREVIEW:-}" ]]; then +if [[ -n "${BASH_PREVIEW:-}" ]] + then _bash-it-preview "${BASH_PREVIEW}" "$@" unset BASH_PREVIEW #Prevent infinite looping fi diff --git a/lib/search.bash b/lib/search.bash index 247e6294..e23b7278 100644 --- a/lib/search.bash +++ b/lib/search.bash @@ -57,7 +57,8 @@ function _bash-it-search() { local BASH_IT_SEARCH_USE_COLOR="${BASH_IT_SEARCH_USE_COLOR:=true}" local -a BASH_IT_COMPONENTS=('aliases' 'plugins' 'completions') - if [[ $# -eq 0 ]]; then + if [[ $# -eq 0 ]] + then _bash-it-search-help return 0 fi @@ -81,7 +82,8 @@ function _bash-it-search() { esac done - if [[ ${#args} -gt 0 ]]; then + if [[ ${#args} -gt 0 ]] + then for component in "${BASH_IT_COMPONENTS[@]}"; do _bash-it-search-component "${component}" "${args[@]}" done @@ -174,7 +176,7 @@ function _bash-it-is-partial-match() { } function _bash-it-component-term-matches-negation() { - local match="$1" + local match="${1}" shift local negative for negative in "$@"; do @@ -199,7 +201,8 @@ function _bash-it-search-component() { local component_singular action action_func local -a search_commands=('enable' 'disable') for search_command in "${search_commands[@]}"; do - if _bash-it-array-contains-element "--${search_command}" "$@"; then + if _bash-it-array-contains-element "--${search_command}" "$@" + then component_singular="${component/es/}" # aliases -> alias component_singular="${component_singular/ns/n}" # plugins -> plugin @@ -224,12 +227,16 @@ function _bash-it-search-component() { for term in "${terms[@]}"; do local search_term="${term:1}" - if [[ "${term:0:2}" == "--" ]]; then + if [[ "${term:0:2}" == "--" ]] + then continue - elif [[ "${term:0:1}" == "-" ]]; then + elif [[ "${term:0:1}" == "-" ]] + then negative_terms+=("${search_term}") - elif [[ "${term:0:1}" == "@" ]]; then - if _bash-it-array-contains-element "${search_term}" "${component_list[@]:-}"; then + elif [[ "${term:0:1}" == "@" ]] + then + if _bash-it-array-contains-element "${search_term}" "${component_list[@]:-}" + then exact_terms+=("${search_term}") fi else @@ -248,7 +255,8 @@ function _bash-it-search-component() { local -a matches=() for match in "${total_matches[@]}"; do local -i include_match=1 - if [[ ${#negative_terms[@]} -gt 0 ]]; then + if [[ ${#negative_terms[@]} -gt 0 ]] + then _bash-it-component-term-matches-negation "${match}" "${negative_terms[@]:-}" && include_match=0 fi ((include_match)) && matches+=("${match}") @@ -276,7 +284,8 @@ function _bash-it-search-result() { [[ -n "${line}" ]] && matches+=("$line") done < <(_bash-it-array-dedup "${@}") - if [[ "${BASH_IT_SEARCH_USE_COLOR}" == "true" ]]; then + if [[ "${BASH_IT_SEARCH_USE_COLOR}" == "true" ]] + then color_component='\e[1;34m' color_enable='\e[1;32m' suffix_enable='' @@ -292,14 +301,16 @@ function _bash-it-search-result() { color_off='' fi - if [[ "${#matches[@]}" -gt 0 ]]; then + if [[ "${#matches[@]}" -gt 0 ]] + then printf "${color_component}%13s${color_sep}${color_off} " "${component}" for match in "${matches[@]}"; do enabled=0 _bash-it-component-item-is-enabled "${component}" "${match}" && enabled=1 - if ((enabled)); then + if ((enabled)) + then match_color="${color_enable}" suffix="${suffix_enable}" opposite_suffix="${suffix_disable}" @@ -315,8 +326,10 @@ function _bash-it-search-result() { len="${#matched}" printf '%b' "${match_color}${matched}" # print current state - if [[ "${action}" == "${compatible_action}" ]]; then - if [[ "${action}" == "enable" && "${BASH_IT_SEARCH_USE_COLOR}" == "true" ]]; then + if [[ "${action}" == "${compatible_action}" ]] + then + if [[ "${action}" == "enable" && "${BASH_IT_SEARCH_USE_COLOR}" == "true" ]] + then _bash-it-flash-term "${len}" "${matched}" else _bash-it-erase-term "${len}" "${matched}" diff --git a/lib/utilities.bash b/lib/utilities.bash index 75e914b8..372eb9c2 100644 --- a/lib/utilities.bash +++ b/lib/utilities.bash @@ -40,7 +40,8 @@ function _bash-it-get-component-type-from-path() { # $ _bash-it-array-contains-element apple "@{fruits[@]}" && echo 'contains apple' # contains apple # -# $ if _bash-it-array-contains-element pear "${fruits[@]}"; then +# $ if _bash-it-array-contains-element pear "${fruits[@]}" + then # echo "contains pear!" # fi # contains pear! @@ -87,7 +88,8 @@ function _bash-it-component-help() { local component file func _bash-it-component-pluralize "${1}" component _bash-it-component-cache-file "${component}" file - if [[ ! -s "${file?}" || -z "$(find "${file}" -mmin -300)" ]]; then + if [[ ! -s "${file?}" || -z "$(find "${file}" -mmin -300)" ]] + then func="_bash-it-${component?}" "${func}" | _bash-it-egrep '\[[x ]\]' >| "${file}" fi @@ -106,9 +108,11 @@ function _bash-it-component-singularize() { local _result="${2:-${FUNCNAME[0]//-/_}}" local _component_to_single="${1?${FUNCNAME[0]}: component name required}" local -i len="$((${#_component_to_single} - 2))" - if [[ "${_component_to_single:${len}:2}" == 'ns' ]]; then + if [[ "${_component_to_single:${len}:2}" == 'ns' ]] + then _component_to_single="${_component_to_single%s}" - elif [[ "${_component_to_single}" == "aliases" ]]; then + elif [[ "${_component_to_single}" == "aliases" ]] + then _component_to_single="${_component_to_single%es}" fi printf -v "${_result?}" '%s' "${_component_to_single}" @@ -119,9 +123,11 @@ function _bash-it-component-pluralize() { local _component_to_plural="${1?${FUNCNAME[0]}: component name required}" local -i len="$((${#_component_to_plural} - 1))" # pluralize component name for consistency - if [[ "${_component_to_plural:${len}:1}" != 's' ]]; then + if [[ "${_component_to_plural:${len}:1}" != 's' ]] + then _component_to_plural="${_component_to_plural}s" - elif [[ "${_component_to_plural}" == "alias" ]]; then + elif [[ "${_component_to_plural}" == "alias" ]] + then _component_to_plural="${_component_to_plural}es" fi printf -v "${_result?}" '%s' "${_component_to_plural}" @@ -131,7 +137,8 @@ function _bash-it-component-cache-clean() { local component="${1:-}" local cache local -a components=('aliases' 'plugins' 'completions') - if [[ -z "${component}" ]]; then + if [[ -z "${component}" ]] + then for component in "${components[@]}"; do _bash-it-component-cache-clean "${component}" done @@ -143,24 +150,24 @@ function _bash-it-component-cache-clean() { # Returns an array of items within each compoenent. function _bash-it-component-list() { - local IFS=$'\n' component="$1" + local IFS=$'\n' component="${1}" _bash-it-component-help "${component}" | awk '{print $1}' | sort -u } function _bash-it-component-list-matching() { - local component="$1" + local component="${1}" shift - local term="$1" + local term="${1}" _bash-it-component-help "${component}" | _bash-it-egrep -- "${term}" | awk '{print $1}' | sort -u } function _bash-it-component-list-enabled() { - local IFS=$'\n' component="$1" + local IFS=$'\n' component="${1}" _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" + local IFS=$'\n' component="${1}" _bash-it-component-help "${component}" | _bash-it-fgrep -v '[x]' | awk '{print $1}' | sort -u } @@ -174,7 +181,8 @@ function _bash-it-component-list-disabled() { function _bash-it-component-item-is-enabled() { local component_type item_name each_file - if [[ -f "${1?}" ]]; then + if [[ -f "${1?}" ]] + then item_name="$(_bash-it-get-component-name-from-path "${1}")" component_type="$(_bash-it-get-component-type-from-path "${1}")" else @@ -184,7 +192,8 @@ function _bash-it-component-item-is-enabled() { for each_file in "${BASH_IT}/enabled"/*"${BASH_IT_LOAD_PRIORITY_SEPARATOR?}${item_name}.${component_type}"*."bash" \ "${BASH_IT}/${component_type}"*/"enabled/${item_name}.${component_type}"*."bash" \ "${BASH_IT}/${component_type}"*/"enabled"/*"${BASH_IT_LOAD_PRIORITY_SEPARATOR?}${item_name}.${component_type}"*."bash"; do - if [[ -f "${each_file}" ]]; then + if [[ -f "${each_file}" ]] + then return 0 fi done diff --git a/plugins/available/autojump.plugin.bash b/plugins/available/autojump.plugin.bash index 3dfa0bca..62275b3d 100644 --- a/plugins/available/autojump.plugin.bash +++ b/plugins/available/autojump.plugin.bash @@ -5,10 +5,13 @@ about-plugin 'Autojump configuration, see https://github.com/wting/autojump for # Only supports the Homebrew variant, Debian and Arch at the moment. # Feel free to provide a PR to support other install locations # shellcheck disable=SC1090 -if _bash_it_homebrew_check && [[ -s "${BASH_IT_HOMEBREW_PREFIX}/etc/profile.d/autojump.sh" ]]; then +if _bash_it_homebrew_check && [[ -s "${BASH_IT_HOMEBREW_PREFIX}/etc/profile.d/autojump.sh" ]] + then source "${BASH_IT_HOMEBREW_PREFIX}/etc/profile.d/autojump.sh" -elif _command_exists dpkg && dpkg -s autojump &> /dev/null; then +elif _command_exists dpkg && dpkg -s autojump &> /dev/null + then source "$(dpkg-query -S autojump.sh | cut -d' ' -f2)" -elif _command_exists pacman && pacman -Q autojump &> /dev/null; then +elif _command_exists pacman && pacman -Q autojump &> /dev/null + then source "$(pacman -Ql autojump | grep autojump.sh | cut -d' ' -f2)" fi diff --git a/plugins/available/aws.plugin.bash b/plugins/available/aws.plugin.bash index 14d26cae..6c8846d0 100644 --- a/plugins/available/aws.plugin.bash +++ b/plugins/available/aws.plugin.bash @@ -9,19 +9,24 @@ function awskeys { about 'helper function for AWS credentials file' group 'aws' - if [[ ! -f "${AWS_SHARED_CREDENTIALS_FILE}" ]]; then + if [[ ! -f "${AWS_SHARED_CREDENTIALS_FILE}" ]] + then echo "AWS credentials file not found" return 1 fi - if [[ $# -eq 1 ]] && [[ "$1" = "list" ]]; then - __awskeys_list "$2" - elif [[ $# -eq 1 ]] && [[ "$1" = "unset" ]]; then - __awskeys_unset "$2" - elif [[ $# -eq 2 ]] && [[ "$1" = "show" ]]; then - __awskeys_show "$2" - elif [[ $# -eq 2 ]] && [[ "$1" = "export" ]]; then - __awskeys_export "$2" + if [[ $# -eq 1 ]] && [[ "${1}" = "list" ]] + then + __awskeys_list "${2}" + elif [[ $# -eq 1 ]] && [[ "${1}" = "unset" ]] + then + __awskeys_unset "${2}" + elif [[ $# -eq 2 ]] && [[ "${1}" = "show" ]] + then + __awskeys_show "${2}" + elif [[ $# -eq 2 ]] && [[ "${1}" = "export" ]] + then + __awskeys_export "${2}" else __awskeys_help fi @@ -40,7 +45,8 @@ function __awskeys_help { function __awskeys_get { 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}" | 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 @@ -48,7 +54,8 @@ function __awskeys_get { function __awskeys_list { 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" for profile in ${credentials_list}; do echo " $(echo ${profile} | tr -d "[]")" @@ -61,7 +68,8 @@ function __awskeys_list { function __awskeys_show { local p_keys="$(__awskeys_get $1)" - if [[ -n "${p_keys}" ]]; then + if [[ -n "${p_keys}" ]] + then echo "${p_keys}" else echo "Profile $1 not found in credentials file" @@ -69,15 +77,17 @@ function __awskeys_show { } function __awskeys_export { - if [[ $(__awskeys_list) == *"$1"* ]]; then + if [[ $(__awskeys_list) == *"${1}"* ]] + then local p_keys=( $(__awskeys_get $1 | tr -d " ") ) - if [[ -n "${p_keys}" ]]; then + if [[ -n "${p_keys}" ]] + then for p_key in ${p_keys[@]}; do local key="${p_key%=*}" export "$(echo ${key} | tr [:lower:] [:upper:])=${p_key#*=}" done fi - export AWS_PROFILE="$1" + export AWS_PROFILE="${1}" else echo "Profile $1 not found in credentials file" fi diff --git a/plugins/available/base.plugin.bash b/plugins/available/base.plugin.bash index 1a905163..6081baab 100644 --- a/plugins/available/base.plugin.bash +++ b/plugins/available/base.plugin.bash @@ -5,9 +5,11 @@ about-plugin 'miscellaneous tools' function ips() { about 'display all ip addresses for this host' group 'base' - if _command_exists ifconfig; then + if _command_exists ifconfig + then ifconfig | awk '/inet /{ gsub(/addr:/, ""); print $2 }' - elif _command_exists ip; then + elif _command_exists ip + then ip addr | grep -oP 'inet \K[\d.]+' else echo "You don't have ifconfig or ip command installed!" @@ -27,7 +29,8 @@ function myip() { group 'base' list=("http://myip.dnsomatic.com/" "http://checkip.dyndns.com/" "http://checkip.dyndns.org/") for url in "${list[@]}"; do - if res="$(curl -fs "${url}")"; then + if res="$(curl -fs "${url}")" + then break fi done @@ -42,7 +45,8 @@ function pickfrom() { group 'base' local file=${1:-} local -i n=0 length - if [[ ! -r "$file" ]]; then + if [[ ! -r "$file" ]] + then reference "${FUNCNAME[0]}" && return fi length="$(wc -l < "$file")" @@ -67,11 +71,13 @@ function passgen() { # Create alias pass to passgen when pass isn't installed or # BASH_IT_LEGACY_PASS is true. -if ! _command_exists pass || [[ "${BASH_IT_LEGACY_PASS:-}" == true ]]; then +if ! _command_exists pass || [[ "${BASH_IT_LEGACY_PASS:-}" == true ]] + then alias pass=passgen fi -if _command_exists markdown && _command_exists browser; then +if _command_exists markdown && _command_exists browser + then function pmdown() { about 'preview markdown file in a browser' param '1: markdown file' @@ -127,21 +133,25 @@ function t() { local todotxt="${XDG_STATE_HOME:-~/.local/state}/bash_it/todo.txt" - if _bash-it-component-item-is-enabled plugin todo; then + if _bash-it-component-item-is-enabled plugin todo + then todo.sh "$@" return - elif [[ ! -f "${todotxt}" && -f ~/.t ]]; then + elif [[ ! -f "${todotxt}" && -f ~/.t ]] + then mv -vn ~/.t "${todotxt}" # Verbose, so the user knows. Don't overwrite, just in case. fi - if [[ "$#" -eq 0 ]]; then + if [[ "$#" -eq 0 ]] + then cat "${todotxt}" else echo "$@" >| "${todotxt}" fi } -if _command_exists mkisofs; then +if _command_exists mkisofs + then function mkiso() { about 'creates iso from current dir in the parent dir (unless defined)' param '1: ISO name' @@ -155,7 +165,8 @@ if _command_exists mkisofs; then local destpath="${2:-../}" local srcpath="${3:-${PWD}}" - if [[ ! -f "${destpath%/}/${isoname}.iso" ]]; then + if [[ ! -f "${destpath%/}/${isoname}.iso" ]] + then echo "writing ${isoname}.iso to ${destpath} from ${srcpath}" mkisofs -V "${isoname}" -iso-level 3 -r -o "${destpath%/}/${isoname}.iso" "${srcpath}" else @@ -174,7 +185,8 @@ function buf() { cp -a "${filename}" "${filename}_${filetime}" } -if ! _command_exists del; then +if ! _command_exists del + then function del() { about 'move files to hidden folder in tmp, that gets cleared on each reboot' param 'file or folder to be deleted' diff --git a/plugins/available/basher.plugin.bash b/plugins/available/basher.plugin.bash index 2c77cbfa..4986a907 100644 --- a/plugins/available/basher.plugin.bash +++ b/plugins/available/basher.plugin.bash @@ -4,8 +4,10 @@ about-plugin 'initializes basher, the shell package manager' # https://github.com/basherpm/basher -if ! _command_exists basher; then - if [[ -x "$HOME/.basher/bin/basher" ]]; then +if ! _command_exists basher + then + if [[ -x "$HOME/.basher/bin/basher" ]] + then pathmunge "$HOME/.basher/bin" else _log_warning 'basher not found' diff --git a/plugins/available/battery.plugin.bash b/plugins/available/battery.plugin.bash index b38d7f9d..479b009d 100644 --- a/plugins/available/battery.plugin.bash +++ b/plugins/available/battery.plugin.bash @@ -3,32 +3,42 @@ about-plugin 'display info about your battery charge level' function ac_adapter_connected() { local batteries - if _command_exists upower; then + if _command_exists upower + then IFS=$'\n' read -d '' -ra batteries < <(upower -e | grep -i BAT) upower -i "${batteries[0]:-}" | grep 'state' | grep -q 'charging\|fully-charged' - elif _command_exists acpi; then + elif _command_exists acpi + then acpi -a | grep -q "on-line" - elif _command_exists pmset; then + elif _command_exists pmset + then pmset -g batt | grep -q 'AC Power' - elif _command_exists ioreg; then + elif _command_exists ioreg + then ioreg -n AppleSmartBattery -r | grep -q '"ExternalConnected" = Yes' - elif _command_exists WMIC; then + elif _command_exists WMIC + then WMIC Path Win32_Battery Get BatteryStatus /Format:List | grep -q 'BatteryStatus=2' fi } function ac_adapter_disconnected() { local batteries - if _command_exists upower; then + if _command_exists upower + then IFS=$'\n' read -d '' -ra batteries < <(upower -e | grep -i BAT) upower -i "${batteries[0]:-}" | grep 'state' | grep -q 'discharging' - elif _command_exists acpi; then + elif _command_exists acpi + then acpi -a | grep -q "off-line" - elif _command_exists pmset; then + elif _command_exists pmset + then pmset -g batt | grep -q 'Battery Power' - elif _command_exists ioreg; then + elif _command_exists ioreg + then ioreg -n AppleSmartBattery -r | grep -q '"ExternalConnected" = No' - elif _command_exists WMIC; then + elif _command_exists WMIC + then WMIC Path Win32_Battery Get BatteryStatus /Format:List | grep -q 'BatteryStatus=1' fi } @@ -39,22 +49,28 @@ function battery_percentage() { local command_output batteries - if _command_exists upower; then + if _command_exists upower + then IFS=$'\n' read -d '' -ra batteries < <(upower -e | grep -i BAT) command_output="$(upower --show-info "${batteries[0]:-}" | grep percentage | grep -o '[0-9]\+' | head -1)" - elif _command_exists acpi; then + elif _command_exists acpi + then command_output=$(acpi -b | awk -F, '/,/{gsub(/ /, "", $0); gsub(/%/,"", $0); print $2}') - elif _command_exists pmset; then + elif _command_exists pmset + then command_output=$(pmset -g ps | sed -n 's/.*[[:blank:]]+*\(.*%\).*/\1/p' | grep -o '[0-9]\+' | head -1) - elif _command_exists ioreg; then + elif _command_exists ioreg + then command_output=$(ioreg -n AppleSmartBattery -r | awk '$1~/Capacity/{c[$1]=$3} END{OFMT="%05.2f"; max=c["\"MaxCapacity\""]; print (max>0? 100*c["\"CurrentCapacity\""]/max: "?")}' | grep -o '[0-9]\+' | head -1) - elif _command_exists WMIC; then + elif _command_exists WMIC + then command_output=$(WMIC PATH Win32_Battery Get EstimatedChargeRemaining /Format:List | grep -o '[0-9]\+' | head -1) else command_output="no" fi - if [[ "${command_output}" != "no" ]]; then + if [[ "${command_output}" != "no" ]] + then printf "%02d" "${command_output:--1}" else echo "${command_output}" diff --git a/plugins/available/blesh.plugin.bash b/plugins/available/blesh.plugin.bash index 6acd19ff..4ca60efc 100644 --- a/plugins/available/blesh.plugin.bash +++ b/plugins/available/blesh.plugin.bash @@ -2,13 +2,15 @@ cite about-plugin about-plugin 'load ble.sh, the Bash line editor!' -if [[ ${BLE_VERSION-} ]]; then +if [[ ${BLE_VERSION-} ]] + then _log_warning "ble.sh is already loaded!" return fi _bash_it_ble_path=${XDG_DATA_HOME:-$HOME/.local/share}/blesh/ble.sh -if [[ -f $_bash_it_ble_path ]]; then +if [[ -f $_bash_it_ble_path ]] + then # shellcheck disable=1090 source "$_bash_it_ble_path" --attach=prompt else diff --git a/plugins/available/boot2docker.plugin.bash b/plugins/available/boot2docker.plugin.bash index f19e91ef..e521362b 100644 --- a/plugins/available/boot2docker.plugin.bash +++ b/plugins/available/boot2docker.plugin.bash @@ -3,7 +3,8 @@ about-plugin 'Helpers to get Docker setup correctly for boot2docker' # Note, this might need to be different if you have an older version # of boot2docker, or its configured for a different IP -if [[ "$OSTYPE" == 'darwin'* ]]; then +if [[ "$OSTYPE" == 'darwin'* ]] + then export DOCKER_HOST="tcp://192.168.59.103:2376" export DOCKER_CERT_PATH="~/.boot2docker/certs/boot2docker-vm" export DOCKER_TLS_VERIFY=1 diff --git a/plugins/available/browser.plugin.bash b/plugins/available/browser.plugin.bash index f7d820aa..0f15517d 100644 --- a/plugins/available/browser.plugin.bash +++ b/plugins/available/browser.plugin.bash @@ -9,8 +9,10 @@ function browser() { example '$ ron -5 man/rip.5.ron | browser' group 'browser' - if [ -t 0 ]; then - if [ -n "$1" ]; then + if [ -t 0 ] + then + if [ -n "${1}" ] + then open $1 else reference browser @@ -29,8 +31,10 @@ function wmate() { example '$ wmate google.com' group 'browser' - if [ -t 0 ]; then - if [ -n "$1" ]; then + if [ -t 0 ] + then + if [ -n "${1}" ] + then wget -qO- $1 | /usr/bin/mate TIDY=`/usr/bin/osascript << EOT @@ -66,8 +70,10 @@ function raw() { example '$ raw google.com' group 'browser' - if [ -t 0 ]; then - if [ -n "$1" ]; then + if [ -t 0 ] + then + if [ -n "${1}" ] + then wget -qO- $1 | browser else reference raw diff --git a/plugins/available/cht-sh.plugin.bash b/plugins/available/cht-sh.plugin.bash index 63e3c9b7..0ceb9a4d 100644 --- a/plugins/available/cht-sh.plugin.bash +++ b/plugins/available/cht-sh.plugin.bash @@ -2,7 +2,8 @@ cite about-plugin about-plugin 'Simplify `curl cht.sh/` to `cht.sh `' # Play nicely if user already installed cht.sh cli tool -if ! _command_exists cht.sh ; then +if ! _command_exists cht.sh + then function cht.sh () { about 'Executes a cht.sh curl query using the provided arguments' param ' [ ( topic [sub-topic] ) | ~keyword ] [ :list | :help | :learn ]' diff --git a/plugins/available/cmd-returned-notify.plugin.bash b/plugins/available/cmd-returned-notify.plugin.bash index e6d221fa..82b289b9 100644 --- a/plugins/available/cmd-returned-notify.plugin.bash +++ b/plugins/available/cmd-returned-notify.plugin.bash @@ -7,7 +7,8 @@ function precmd_return_notification() { 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 + if [[ "${command_duration}" -gt "${NOTIFY_IF_COMMAND_RETURNS_AFTER:-5}" ]] + then printf '\a' fi return 0 diff --git a/plugins/available/colors.plugin.bash b/plugins/available/colors.plugin.bash index 73c144b8..84315950 100644 --- a/plugins/available/colors.plugin.bash +++ b/plugins/available/colors.plugin.bash @@ -121,18 +121,18 @@ function __color_rgb() { } function __color() { - color="$1" + color="${1}" shift - case "$1" in + case "${1}" in fg | bg) - side="$1" + side="${1}" shift ;; *) side="fg" ;; esac - case "$1" in + case "${1}" in normal | bright) - mode="$1" + mode="${1}" shift ;; *) mode=normal ;; diff --git a/plugins/available/direnv.plugin.bash b/plugins/available/direnv.plugin.bash index 62788600..d807f219 100644 --- a/plugins/available/direnv.plugin.bash +++ b/plugins/available/direnv.plugin.bash @@ -2,6 +2,7 @@ cite about-plugin about-plugin 'load direnv, if you are using it: https://direnv.net/' -if _command_exists direnv; then +if _command_exists direnv + then eval "$(direnv hook bash)" fi diff --git a/plugins/available/dirs.plugin.bash b/plugins/available/dirs.plugin.bash index 55d2e88a..fa0b786e 100644 --- a/plugins/available/dirs.plugin.bash +++ b/plugins/available/dirs.plugin.bash @@ -60,12 +60,14 @@ function dirs-help() { # Usage: : "${BASH_IT_DIRS_BKS:=${XDG_STATE_HOME:-${HOME}/.local/state}/bash_it/dirs}" -if [[ -f "${BASH_IT_DIRS_BKS?}" ]]; then +if [[ -f "${BASH_IT_DIRS_BKS?}" ]] + then # shellcheck disable=SC1090 source "${BASH_IT_DIRS_BKS?}" else mkdir -p "${BASH_IT_DIRS_BKS%/*}" - if [[ -f ~/.dirs ]]; then + if [[ -f ~/.dirs ]] + then mv -vn ~/.dirs "${BASH_IT_DIRS_BKS?}" # shellcheck disable=SC1090 source "${BASH_IT_DIRS_BKS?}" @@ -99,7 +101,7 @@ function S() { sed "/$1/d" "${BASH_IT_DIRS_BKS?}" > "${BASH_IT_DIRS_BKS?}.new" command mv "${BASH_IT_DIRS_BKS?}.new" "${BASH_IT_DIRS_BKS?}" - echo "$1"=\""${PWD}"\" >> "${BASH_IT_DIRS_BKS?}" + echo "${1}"=\""${PWD}"\" >> "${BASH_IT_DIRS_BKS?}" # shellcheck disable=SC1090 source "${BASH_IT_DIRS_BKS?}" } diff --git a/plugins/available/docker-compose.plugin.bash b/plugins/available/docker-compose.plugin.bash index 37330dfa..80e19ace 100644 --- a/plugins/available/docker-compose.plugin.bash +++ b/plugins/available/docker-compose.plugin.bash @@ -8,7 +8,8 @@ function docker-compose-fresh() { example 'docker-compose-fresh docker-compose-foo.yaml' local DCO_FILE_PARAM="" - if [ -n "$1" ]; then + if [ -n "${1}" ] + then echo "Using docker-compose file: $1" DCO_FILE_PARAM="--file $1" fi diff --git a/plugins/available/docker.plugin.bash b/plugins/available/docker.plugin.bash index 2632c3cc..494d006a 100644 --- a/plugins/available/docker.plugin.bash +++ b/plugins/available/docker.plugin.bash @@ -32,7 +32,8 @@ function docker-enter() { function docker-remove-images() { about 'attempt to remove images with supplied tags or all if no tags are supplied' group 'docker' - if [ -z "$1" ]; then + if [ -z "${1}" ] + then docker rmi $(docker images -q) else DOCKER_IMAGES="" @@ -47,7 +48,8 @@ function docker-remove-images() { function docker-image-dependencies() { about 'attempt to create a Graphiz image of the supplied image ID dependencies' group 'docker' - if hash dot 2>/dev/null; then + if hash dot 2>/dev/null + then OUT=$(mktemp -t docker-viz-XXXX.png) docker images -viz | dot -Tpng > $OUT case $OSTYPE in @@ -75,7 +77,8 @@ function docker-archive-content() { param '1: image archive name' example 'docker-archive-content images.tar.gz' - if [ -n "$1" ]; then + if [ -n "${1}" ] + then tar -xzOf $1 manifest.json | jq '[.[] | .RepoTags] | add' fi } diff --git a/plugins/available/explain.plugin.bash b/plugins/available/explain.plugin.bash index ab7b4a0c..76627a24 100644 --- a/plugins/available/explain.plugin.bash +++ b/plugins/available/explain.plugin.bash @@ -8,12 +8,14 @@ explain () { example '$ explain '"'"'cmd -o | ...'"'"' # one quoted command to explain it.' group 'explain' - if [ "$#" -eq 0 ]; then + if [ "$#" -eq 0 ] + then while read -p "Command: " cmd; do curl -Gs "https://www.mankier.com/api/explain/?cols="$(tput cols) --data-urlencode "q=$cmd" done echo "Bye!" - elif [ "$#" -eq 1 ]; then + elif [ "$#" -eq 1 ] + then curl -Gs "https://www.mankier.com/api/explain/?cols="$(tput cols) --data-urlencode "q=$1" else echo "Usage" diff --git a/plugins/available/extract.plugin.bash b/plugins/available/extract.plugin.bash index 9fc05c7d..590839cb 100644 --- a/plugins/available/extract.plugin.bash +++ b/plugins/available/extract.plugin.bash @@ -29,7 +29,8 @@ End-Of-Usage [ $# -eq 0 ] && extract -h && return 1 while [ $# -gt 0 ]; do - if [[ ! -f "$1" ]]; then + if [[ ! -f "${1}" ]] + then echo "extract: '$1' is not a valid file" >&2 shift continue @@ -38,32 +39,34 @@ End-Of-Usage local -r filename=$(basename -- $1) local -r filedirname=$(dirname -- $1) local targetdirname=$(sed 's/\(\.tar\.bz2$\|\.tbz$\|\.tbz2$\|\.tar\.gz$\|\.tgz$\|\.tar$\|\.tar\.xz$\|\.txz$\|\.tar\.Z$\|\.7z$\|\.nupkg$\|\.zip$\|\.war$\|\.jar$\)//g' <<< $filename) - if [ "$filename" = "$targetdirname" ]; then + if [ "$filename" = "$targetdirname" ] + then # archive type either not supported or it doesn't need dir creation targetdirname="" else mkdir -v "$filedirname/$targetdirname" fi - if [ -f "$1" ]; then - case "$1" in - *.tar.bz2|*.tbz|*.tbz2) tar "x${verbose}jf" "$1" -C "$filedirname/$targetdirname" ;; - *.tar.gz|*.tgz) tar "x${verbose}zf" "$1" -C "$filedirname/$targetdirname" ;; - *.tar.xz|*.txz) tar "x${verbose}Jf" "$1" -C "$filedirname/$targetdirname" ;; - *.tar.Z) tar "x${verbose}Zf" "$1" -C "$filedirname/$targetdirname" ;; - *.bz2) bunzip2 "$1" ;; - *.deb) dpkg-deb -x${verbose} "$1" "${1:0:-4}" ;; - *.pax.gz) gunzip "$1"; set -- "$@" "${1:0:-3}" ;; - *.gz) gunzip "$1" ;; - *.pax) pax -r -f "$1" ;; - *.pkg) pkgutil --expand "$1" "${1:0:-4}" ;; - *.rar) unrar x "$1" ;; - *.rpm) rpm2cpio "$1" | cpio -idm${verbose} ;; - *.tar) tar "x${verbose}f" "$1" -C "$filedirname/$targetdirname" ;; - *.xz) xz --decompress "$1" ;; - *.zip|*.war|*.jar|*.nupkg) unzip "$1" -d "$filedirname/$targetdirname" ;; - *.Z) uncompress "$1" ;; - *.7z) 7za x -o"$filedirname/$targetdirname" "$1" ;; + if [ -f "${1}" ] + then + case "${1}" in + *.tar.bz2|*.tbz|*.tbz2) tar "x${verbose}jf" "${1}" -C "$filedirname/$targetdirname" ;; + *.tar.gz|*.tgz) tar "x${verbose}zf" "${1}" -C "$filedirname/$targetdirname" ;; + *.tar.xz|*.txz) tar "x${verbose}Jf" "${1}" -C "$filedirname/$targetdirname" ;; + *.tar.Z) tar "x${verbose}Zf" "${1}" -C "$filedirname/$targetdirname" ;; + *.bz2) bunzip2 "${1}" ;; + *.deb) dpkg-deb -x${verbose} "${1}" "${1:0:-4}" ;; + *.pax.gz) gunzip "${1}"; set -- "$@" "${1:0:-3}" ;; + *.gz) gunzip "${1}" ;; + *.pax) pax -r -f "${1}" ;; + *.pkg) pkgutil --expand "${1}" "${1:0:-4}" ;; + *.rar) unrar x "${1}" ;; + *.rpm) rpm2cpio "${1}" | cpio -idm${verbose} ;; + *.tar) tar "x${verbose}f" "${1}" -C "$filedirname/$targetdirname" ;; + *.xz) xz --decompress "${1}" ;; + *.zip|*.war|*.jar|*.nupkg) unzip "${1}" -d "$filedirname/$targetdirname" ;; + *.Z) uncompress "${1}" ;; + *.7z) 7za x -o"$filedirname/$targetdirname" "${1}" ;; *) echo "'$1' cannot be extracted via extract" >&2;; esac fi diff --git a/plugins/available/fzf.plugin.bash b/plugins/available/fzf.plugin.bash index 21182ac2..ed118315 100644 --- a/plugins/available/fzf.plugin.bash +++ b/plugins/available/fzf.plugin.bash @@ -4,16 +4,19 @@ cite about-plugin about-plugin 'load fzf, if you are using it' -if [ -r ~/.fzf.bash ] ; then +if [ -r ~/.fzf.bash ] + then source ~/.fzf.bash -elif [ -r "${XDG_CONFIG_HOME:-$HOME/.config}"/fzf/fzf.bash ] ; then +elif [ -r "${XDG_CONFIG_HOME:-$HOME/.config}"/fzf/fzf.bash ] + then source "${XDG_CONFIG_HOME:-$HOME/.config}"/fzf/fzf.bash fi # No need to continue if the command is not present _command_exists fzf || return -if [ -z ${FZF_DEFAULT_COMMAND+x} ] && _command_exists fd ; then +if [ -z ${FZF_DEFAULT_COMMAND+x} ] && _command_exists fd + then export FZF_DEFAULT_COMMAND='fd --type f' fi @@ -25,7 +28,7 @@ fe() { local IFS=$'\n' local files - files=($(fzf-tmux --query="$1" --multi --select-1 --exit-0)) + files=($(fzf-tmux --query="${1}" --multi --select-1 --exit-0)) [[ -n "$files" ]] && ${EDITOR:-vim} "${files[@]}" } diff --git a/plugins/available/gif.plugin.bash b/plugins/available/gif.plugin.bash index a04ff5c7..e716414c 100644 --- a/plugins/available/gif.plugin.bash +++ b/plugins/available/gif.plugin.bash @@ -54,7 +54,8 @@ function v2gif() { } getopt="$(type -p getopt)" - if [[ "$OSTYPE" == "darwin"* ]]; then + if [[ "$OSTYPE" == "darwin"* ]] + then # Getopt on BSD is incompatible with GNU getopt=/usr/local/opt/gnu-getopt/bin/getopt [[ -x "$getopt" ]] || { @@ -83,7 +84,7 @@ function v2gif() { local make_webm="" local alert=5000 while [[ $# -ge 1 ]]; do - case "$1" in + case "${1}" in --) # No more options left. shift @@ -124,13 +125,13 @@ function v2gif() { ;; -f | --fps) # select fps - infps="$2" + infps="${2}" giftag="${giftag}-f$2" shift 2 ;; -a | --alert) # set size alert - alert="$2" + alert="${2}" shift 2 ;; -m | --webm) @@ -141,7 +142,8 @@ function v2gif() { esac done - if [[ -z "$*" ]]; then + if [[ -z "$*" ]] + then echo "$(tput setaf 1)No input files given. Example: v2gif file [file...] [-w ] [-l ] $(tput sgr 0)" echo "-d/--del/--delete Delete original vid if done suceessfully (and file not over the size limit)" echo "-h/--high High Quality - use Gifski instead of gifsicle" @@ -163,18 +165,21 @@ function v2gif() { local output_file="${file%.*}${giftag}.gif" local del_after=$opt_del_after - if [[ -n "$make_webm" ]]; then + if [[ -n "$make_webm" ]] + then $ffmpeg -loglevel panic -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 # Set FPS to match the video if possible, otherwise fallback to default. - if [[ -n "$infps" ]]; then + if [[ -n "$infps" ]] + then fps=$infps else fps=$defaultfps - if [[ -x "$mediainfo" ]]; then + if [[ -x "$mediainfo" ]] + then fps=$($mediainfo "$file" | grep "Frame rate " | sed 's/.*: \([0-9.]\+\) .*/\1/' | head -1) [[ -z "$fps" ]] && fps=$($mediainfo "$file" | grep "Minimum frame rate" | sed 's/.*: \([0-9.]\+\) .*/\1/' | head -1) fi @@ -182,7 +187,8 @@ function v2gif() { echo "$(tput setaf 2)Creating '$output_file' at $fps FPS ...$(tput sgr 0)" - if [[ "$use_gifski" = "true" ]]; then + 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 @@ -195,9 +201,11 @@ function v2gif() { rm v2gif-tmp-*.png # Checking if the file is bigger than Twitter likes and warn - if [[ $alert -gt 0 ]]; then + if [[ $alert -gt 0 ]] + then out_size=$(wc --bytes < "$output_file") - if [[ $out_size -gt $((alert * 1000)) ]]; then + if [[ $out_size -gt $((alert * 1000)) ]] + then echo "$(tput setaf 3)Warning: '$output_file' is $((out_size / 1000))kb.$(tput sgr 0)" [[ "$del_after" == "true" ]] && echo "$(tput setaf 3)Warning: Keeping '$file' even though --del requested.$(tput sgr 0)" del_after="" @@ -242,7 +250,7 @@ function any2webm() { local bandwidth="2M" local alert=5000 while [[ $# -ge 1 ]]; do - case "$1" in + case "${1}" in --) # No more options left. shift @@ -271,19 +279,20 @@ function any2webm() { ;; -b | --bandwidth) # select bandwidth - bandwidth="$2" + bandwidth="${2}" webmtag="${webmtag}-b$2" shift 2 ;; -a | --alert) # set size alert - alert="$2" + alert="${2}" shift 2 ;; esac done - if [[ -z "$*" ]]; then + if [[ -z "$*" ]] + then echo "$(tput setaf 1)No input files given. Example: any2webm file [file...] [-w ] < $(tput sgr 0)" return 1 fi @@ -304,9 +313,11 @@ function any2webm() { -quality best "$fps" "$size" -loop 0 -pix_fmt yuva420p "$output_file" || return 2 # Checking if the file is bigger than Twitter likes and warn - if [[ $alert -gt 0 ]]; then + if [[ $alert -gt 0 ]] + then out_size=$(wc --bytes < "$output_file") - if [[ $out_size -gt $((alert * 1000)) ]]; then + if [[ $out_size -gt $((alert * 1000)) ]] + then echo "$(tput setaf 3)Warning: '$output_file' is $((out_size / 1000))kb.$(tput sgr 0)" [[ "$del_after" == "true" ]] && echo "$(tput setaf 3)Warning: Keeping '$file' even though --del requested.$(tput sgr 0)" del_after="" diff --git a/plugins/available/git-subrepo.plugin.bash b/plugins/available/git-subrepo.plugin.bash index 6eb8d7c4..c05aae25 100644 --- a/plugins/available/git-subrepo.plugin.bash +++ b/plugins/available/git-subrepo.plugin.bash @@ -1,7 +1,8 @@ # shellcheck shell=bash about-plugin 'load git-subrepo if you are using it, and initialize completions' -if [[ -s "${GIT_SUBREPO_ROOT:=$HOME/.git-subrepo}/init" ]]; then +if [[ -s "${GIT_SUBREPO_ROOT:=$HOME/.git-subrepo}/init" ]] + then # shellcheck disable=SC1091 source "$GIT_SUBREPO_ROOT/init" fi diff --git a/plugins/available/git.plugin.bash b/plugins/available/git.plugin.bash index 3a130955..9046ce7d 100644 --- a/plugins/available/git.plugin.bash +++ b/plugins/available/git.plugin.bash @@ -43,14 +43,16 @@ function git_rollback() { group 'git' function is_clean() { - if [[ $(git diff --shortstat 2> /dev/null | tail -n1) != "" ]]; then + if [[ $(git diff --shortstat 2> /dev/null | tail -n1) != "" ]] + then echo "Your branch is dirty, please commit your changes" kill -INT $$ fi } function commit_exists() { - if git rev-list --quiet "${1:?}"; then + if git rev-list --quiet "${1:?}" + then echo "Commit ${1} does not exist" kill -INT $$ fi @@ -64,12 +66,12 @@ function git_rollback() { [yY]) echo "Rolling back to commit ${1} with unstaged changes" - git reset "$1" + git reset "${1}" break ;; [nN]) echo "Rolling back to commit ${1} with a clean working tree" - git reset --hard "$1" + git reset --hard "${1}" break ;; *) @@ -79,9 +81,10 @@ function git_rollback() { done } - if [ -n "$(git symbolic-ref HEAD 2> /dev/null)" ]; then + if [ -n "$(git symbolic-ref HEAD 2> /dev/null)" ] + then is_clean - commit_exists "$1" + commit_exists "${1}" while true; do # shellcheck disable=SC2162 @@ -89,7 +92,7 @@ function git_rollback() { case "${RESP}" in [yY]) - keep_changes "$1" + keep_changes "${1}" break ;; [nN]) @@ -117,7 +120,7 @@ function local-ignore() { about 'adds file or path to git exclude file' param '1: file or path fragment to ignore' group 'git' - echo "$1" >> .git/info/exclude + echo "${1}" >> .git/info/exclude } # get a quick overview for your git repo @@ -125,7 +128,8 @@ function git_info() { about 'overview for your git repo' group 'git' - if [ -n "$(git symbolic-ref HEAD 2> /dev/null)" ]; then + if [ -n "$(git symbolic-ref HEAD 2> /dev/null)" ] + then # print informations echo "git repo overview" echo "-----------------" @@ -140,7 +144,8 @@ function git_info() { # print status of working repo echo "status:" - if [ -n "$(git status -s 2> /dev/null)" ]; then + if [ -n "$(git status -s 2> /dev/null)" ] + then git status -s else echo "working directory is clean" @@ -165,20 +170,24 @@ function git_stats { # awesome work from https://github.com/esc/git-stats # including some modifications - if [ -n "$(git symbolic-ref HEAD 2> /dev/null)" ]; then + if [ -n "$(git symbolic-ref HEAD 2> /dev/null)" ] + then echo "Number of commits per author:" git --no-pager shortlog -sn --all AUTHORS=$(git shortlog -sn --all | cut -f2 | cut -f1 -d' ') LOGOPTS="" - if [ "$1" == '-w' ]; then + if [ "${1}" == '-w' ] + then LOGOPTS="${LOGOPTS} -w" shift fi - if [ "$1" == '-M' ]; then + if [ "${1}" == '-M' ] + then LOGOPTS="${LOGOPTS} -M" shift fi - if [ "$1" == '-C' ]; then + if [ "${1}" == '-C' ] + then LOGOPTS="${LOGOPTS} -C --find-copies-harder" shift fi @@ -211,12 +220,15 @@ function gittowork() { result=$(curl -L "https://www.gitignore.io/api/$1" 2> /dev/null) - if [[ "${result}" =~ ERROR ]]; then + if [[ "${result}" =~ ERROR ]] + then echo "Query '$1' has no match. See a list of possible queries with 'gittowork list'" - elif [[ $1 == list ]]; then + elif [[ $1 == list ]] + then echo "${result}" else - if [[ -f .gitignore ]]; then + if [[ -f .gitignore ]] + then result=$(grep -v "# Created by http://www.gitignore.io" <<< "${result}") echo ".gitignore already exists, appending..." fi @@ -240,21 +252,24 @@ function gitignore-reload() { err=0 # Disallow unstaged changes in the working tree - if ! git diff-files --quiet --ignore-submodules --; then + if ! git diff-files --quiet --ignore-submodules -- + then echo >&2 "ERROR: Cannot reload .gitignore: Your index contains unstaged changes." git diff-index --cached --name-status -r --ignore-submodules HEAD -- >&2 err=1 fi # Disallow uncommited changes in the index - if ! git diff-index --cached --quiet HEAD --ignore-submodules; then + if ! git diff-index --cached --quiet HEAD --ignore-submodules + then echo >&2 "ERROR: Cannot reload .gitignore: Your index contains uncommited changes." git diff-index --cached --name-status -r --ignore-submodules HEAD -- >&2 err=1 fi # Prompt user to commit or stash changes and exit - if [[ "${err}" == 1 ]]; then + if [[ "${err}" == 1 ]] + then echo >&2 "Please commit or stash them." fi @@ -262,7 +277,8 @@ function gitignore-reload() { # If we're here, then there are no uncommited or unstaged changes dangling around. # Proceed to reload .gitignore - if [[ "${err}" == 0 ]]; then + if [[ "${err}" == 0 ]] + then # Remove all cached files git rm -r --cached . @@ -282,7 +298,8 @@ function git-changelog() { group 'git' example '$ git-changelog origin/master...origin/release [md|txt]' - if [[ "$1" != *"..."* ]]; then + if [[ "${1}" != *"..."* ]] + then echo "Please include the valid 'diff' to make changelog" return 1 fi @@ -290,11 +307,12 @@ function git-changelog() { # shellcheck disable=SC2155 local NEXT=$(date +%F) - if [[ "$2" == "md" ]]; then + if [[ "${2}" == "md" ]] + then echo "# CHANGELOG $1" # shellcheck disable=SC2162 - git log "$1" --no-merges --format="%cd" --date=short | sort -u -r | while read DATE; do + git log "${1}" --no-merges --format="%cd" --date=short | sort -u -r | while read DATE; do echo echo "### ${DATE}" git log --no-merges --format=" * (%h) %s by [%an](mailto:%ae)" --since="${DATE} 00:00:00" --until="${DATE} 24:00:00" @@ -305,7 +323,7 @@ function git-changelog() { echo ---------------------- # shellcheck disable=SC2162 - git log "$1" --no-merges --format="%cd" --date=short | sort -u -r | while read DATE; do + git log "${1}" --no-merges --format="%cd" --date=short | sort -u -r | while read DATE; do echo echo "[${DATE}]" git log --no-merges --format=" * (%h) %s by %an <%ae>" --since="${DATE} 00:00:00" --until="${DATE} 24:00:00" diff --git a/plugins/available/gitstatus.plugin.bash b/plugins/available/gitstatus.plugin.bash index 9df65a82..037369c3 100644 --- a/plugins/available/gitstatus.plugin.bash +++ b/plugins/available/gitstatus.plugin.bash @@ -16,7 +16,8 @@ function gitstatus_on_disable() { [[ $- == *i* ]] || return : "${SCM_GIT_GITSTATUS_DIR:="$HOME/gitstatus"}" -if [[ -d ${SCM_GIT_GITSTATUS_DIR} ]]; then +if [[ -d ${SCM_GIT_GITSTATUS_DIR} ]] + then source "${SCM_GIT_GITSTATUS_DIR}/gitstatus.plugin.sh" # Start the actual gitstatus binary gitstatus_stop && gitstatus_start -s -1 -u -1 -c -1 -d -1 diff --git a/plugins/available/go.plugin.bash b/plugins/available/go.plugin.bash index 5592a006..45f11268 100644 --- a/plugins/available/go.plugin.bash +++ b/plugins/available/go.plugin.bash @@ -19,7 +19,8 @@ export GOPATH="${GOPATH:-$(go env GOPATH)}" _bash-it-gopath-pathmunge() { _about 'Ensures paths in GOPATH are added to PATH using pathmunge, with /bin appended' _group 'go' - if [[ -z $GOPATH ]]; then + if [[ -z $GOPATH ]] + then echo 'GOPATH empty' >&2 return 1 fi @@ -28,7 +29,8 @@ _bash-it-gopath-pathmunge() { i=${#paths[@]} while [[ $i -gt 0 ]]; do i=$((i - 1)) - if [[ -n "${paths[i]}" ]]; then + if [[ -n "${paths[i]}" ]] + then pathmunge "${paths[i]}/bin" fi done diff --git a/plugins/available/goenv.plugin.bash b/plugins/available/goenv.plugin.bash index 17e4a0ff..0fe7a591 100644 --- a/plugins/available/goenv.plugin.bash +++ b/plugins/available/goenv.plugin.bash @@ -20,7 +20,8 @@ _command_exists goenv \ export GOENV_ROOT="${GOENV_ROOT:-$HOME/.goenv}" # Add GOENV_ROOT/bin to PATH, if that's where it's installed -if ! _command_exists goenv && [[ -x "$GOENV_ROOT/bin/goenv" ]]; then +if ! _command_exists goenv && [[ -x "$GOENV_ROOT/bin/goenv" ]] + then pathmunge "$GOENV_ROOT/bin" fi @@ -33,7 +34,8 @@ _bash-it-goenv-preexec() { GOENV_OLD_VERSION="$(goenv version-name)" } _bash-it-goenv-precmd() { - if [[ -n $GOENV_OLD_VERSION ]] && [[ "$GOENV_OLD_VERSION" != "$(goenv version-name)" ]]; then + if [[ -n $GOENV_OLD_VERSION ]] && [[ "$GOENV_OLD_VERSION" != "$(goenv version-name)" ]] + then exec env -u PATH -u GOROOT -u GOPATH -u GOENV_OLD_VERSION "${0/-/}" --login fi unset GOENV_OLD_VERSION diff --git a/plugins/available/hg.plugin.bash b/plugins/available/hg.plugin.bash index 020b920d..4b9740ea 100644 --- a/plugins/available/hg.plugin.bash +++ b/plugins/available/hg.plugin.bash @@ -1,7 +1,7 @@ cite about-plugin about-plugin 'hg helper functions' -hg_dirty() { +function hg_dirty() { about 'displays dirty status of hg repository' group 'hg' @@ -10,14 +10,14 @@ hg_dirty() { | sort | uniq | head -c1 } -hg_in_repo() { +function hg_in_repo() { about 'determine if pwd is an hg repo' group 'hg' [[ `hg branch 2> /dev/null` ]] && echo 'on ' } -hg_branch() { +function hg_branch() { about 'display current hg branch' group 'hg' diff --git a/plugins/available/history-eternal.plugin.bash b/plugins/available/history-eternal.plugin.bash index 829868df..da4463cc 100644 --- a/plugins/available/history-eternal.plugin.bash +++ b/plugins/available/history-eternal.plugin.bash @@ -1,7 +1,8 @@ # shellcheck shell=bash about-plugin 'eternal bash history' -if [[ ${BASH_VERSINFO[0]} -lt 4 ]] || [[ ${BASH_VERSINFO[0]} -eq 4 && ${BASH_VERSINFO[1]} -lt 3 ]]; then +if [[ ${BASH_VERSINFO[0]} -lt 4 ]] || [[ ${BASH_VERSINFO[0]} -eq 4 && ${BASH_VERSINFO[1]} -lt 3 ]] + then _log_warning "Bash version 4.3 introduced the 'unlimited' history size capability." return 1 fi diff --git a/plugins/available/history-search.plugin.bash b/plugins/available/history-search.plugin.bash index 96941993..14bc1640 100644 --- a/plugins/available/history-search.plugin.bash +++ b/plugins/available/history-search.plugin.bash @@ -3,7 +3,8 @@ about-plugin 'search history using the prefix already entered' # enter a few characters and press UpArrow/DownArrow # to search backwards/forwards through the history -if [[ ${SHELLOPTS} =~ (vi|emacs) ]]; then +if [[ ${SHELLOPTS} =~ (vi|emacs) ]] + then bind '"\e[A":history-search-backward' bind '"\e[B":history-search-forward' fi diff --git a/plugins/available/history-substring-search.plugin.bash b/plugins/available/history-substring-search.plugin.bash index dde32720..d1e3ddba 100644 --- a/plugins/available/history-substring-search.plugin.bash +++ b/plugins/available/history-substring-search.plugin.bash @@ -3,7 +3,8 @@ about-plugin 'search history using the substring already entered' # enter a few characters and press UpArrow/DownArrow # to search backwards/forwards through the history -if [[ ${SHELLOPTS} =~ (vi|emacs) ]]; then +if [[ ${SHELLOPTS} =~ (vi|emacs) ]] + then bind '"\e[A":history-substring-search-backward' bind '"\e[B":history-substring-search-forward' fi diff --git a/plugins/available/hub.plugin.bash b/plugins/available/hub.plugin.bash index e9a8cbab..20a039b8 100644 --- a/plugins/available/hub.plugin.bash +++ b/plugins/available/hub.plugin.bash @@ -2,6 +2,7 @@ cite about-plugin about-plugin 'load hub, if you are using it' -if _command_exists hub; then +if _command_exists hub + then eval "$(hub alias -s)" fi diff --git a/plugins/available/javascript.plugin.bash b/plugins/available/javascript.plugin.bash index e8037b9d..db53273d 100644 --- a/plugins/available/javascript.plugin.bash +++ b/plugins/available/javascript.plugin.bash @@ -17,11 +17,11 @@ function jquery_install { about 'download jquery.js into public/javascripts' group 'javascript' - if [ -z "$1" ] + if [ -z "${1}" ] then version=$JQUERY_VERSION_NUMBER else - version="$1" + version="${1}" fi curl -o public/javascripts/jquery.js "http://ajax.googleapis.com/ajax/libs/jquery/$version/jquery.min.js" } @@ -30,11 +30,11 @@ function jquery_ui_install { about 'download jquery_us.js into public/javascripts' group 'javascript' - if [ -z "$1" ] + if [ -z "${1}" ] then version=$JQUERY_UI_VERSION_NUMBER else - version="$1" + version="${1}" fi curl -o public/javascripts/jquery_ui.js "http://ajax.googleapis.com/ajax/libs/jqueryui/$version/jquery-ui.min.js" diff --git a/plugins/available/jekyll.plugin.bash b/plugins/available/jekyll.plugin.bash index 3c12d826..ffafebde 100644 --- a/plugins/available/jekyll.plugin.bash +++ b/plugins/available/jekyll.plugin.bash @@ -9,20 +9,23 @@ function editpost() { local SITE site POST DATE TITLE POSTS local -i COUNTER=1 POST_TO_EDIT ret - if [[ -z "${1:-}" ]]; then + if [[ -z "${1:-}" ]] + then echo "Error: no site specified." echo "The site is the name of the directory your project is in." return 1 fi for site in "${SITES[@]:-}"; do - if [[ "${site##*/}" == "$1" ]]; then + if [[ "${site##*/}" == "${1}" ]] + then SITE="${site}" break fi done - if [[ -z "${SITE:-}" ]]; then + if [[ -z "${SITE:-}" ]] + then echo "No such site." return 1 fi @@ -52,19 +55,22 @@ function newpost() { local SITE site FNAME_POST_TITLE FNAME YAML_DATE local JEKYLL_FORMATTING FNAME_DATE OPTIONS OPTION POST_TYPE POST_TITLE local -i loc=0 ret - if [[ -z "${1:-}" ]]; then + if [[ -z "${1:-}" ]] + then echo "Error: no site specified." echo "The site is the name of the directory your project is in." return 1 fi - if [[ -z "${SITE}" ]]; then + if [[ -z "${SITE}" ]] + then echo "No such site." return 1 fi for site in "${SITES[@]}"; do - if [[ "${site##*/}" == "$1" ]]; then + if [[ "${site##*/}" == "${1}" ]] + then SITE="$site" JEKYLL_FORMATTING="${MARKUPS[loc]}" break @@ -81,7 +87,8 @@ function newpost() { # If the user is using markdown or textile formatting, let them choose what type of post they want. Sort of like Tumblr. OPTIONS=('Text' 'Quote' 'Image' 'Audio' 'Video' 'Link') - if [[ $JEKYLL_FORMATTING == "markdown" || $JEKYLL_FORMATTING == "textile" ]]; then + if [[ $JEKYLL_FORMATTING == "markdown" || $JEKYLL_FORMATTING == "textile" ]] + then select OPTION in "${OPTIONS[@]}"; do POST_TYPE="${OPTION}" break @@ -121,7 +128,8 @@ function newpost() { } > "${FNAME}" # Generate template text based on the post type - if [[ $JEKYLL_FORMATTING == "markdown" ]]; then + if [[ $JEKYLL_FORMATTING == "markdown" ]] + then case $POST_TYPE in "Text") true @@ -148,7 +156,8 @@ function newpost() { echo "[1]: url" ;; esac - elif [[ $JEKYLL_FORMATTING == "textile" ]]; then + elif [[ $JEKYLL_FORMATTING == "textile" ]] + then case $POST_TYPE in "Text") true @@ -189,20 +198,23 @@ function testsite() { local SITE site local -i ret - if [[ -z "${1:-}" ]]; then + if [[ -z "${1:-}" ]] + then echo "Error: no site specified." echo "The site is the name of the directory your project is in." return 1 fi for site in "${SITES[@]}"; do - if [[ "${site##*/}" == "$1" ]]; then + if [[ "${site##*/}" == "${1}" ]] + then SITE="$site" break fi done - if [[ -z "${SITE}" ]]; then + if [[ -z "${SITE}" ]] + then echo "No such site." return 1 fi @@ -221,20 +233,23 @@ function buildsite() { local SITE site local -i ret - if [[ -z "${1:-}" ]]; then + if [[ -z "${1:-}" ]] + then echo "Error: no site specified." echo "The site is the name of the directory your project is in." return 1 fi for site in "${SITES[@]}"; do - if [[ "${site##*/}" == "$1" ]]; then + if [[ "${site##*/}" == "${1}" ]] + then SITE="$site" break fi done - if [[ -z "${SITE}" ]]; then + if [[ -z "${SITE}" ]] + then echo "No such site." return 1 fi @@ -254,14 +269,16 @@ function deploysite() { local SITE site REMOTE local -i loc=0 ret - if [[ -z "${1:-}" ]]; then + if [[ -z "${1:-}" ]] + then echo "Error: no site specified." echo "The site is the name of the directory your project is in." return 1 fi for site in "${SITES[@]}"; do - if [[ "${site##*/}" == "$1" ]]; then + if [[ "${site##*/}" == "${1}" ]] + then SITE="$site" # shellcheck disable=SC2153 # who knows REMOTE="${REMOTES[loc]}" @@ -270,7 +287,8 @@ function deploysite() { loc=$((loc + 1)) done - if [[ -z "${SITE}" ]]; then + if [[ -z "${SITE}" ]] + then echo "No such site." return 1 fi @@ -283,6 +301,7 @@ function deploysite() { } # Load the Jekyll config -if [[ -s "$HOME/.jekyllconfig" ]]; then +if [[ -s "$HOME/.jekyllconfig" ]] + then source "$HOME/.jekyllconfig" fi diff --git a/plugins/available/jump.plugin.bash b/plugins/available/jump.plugin.bash index 1713d1b7..c7ff7a4a 100644 --- a/plugins/available/jump.plugin.bash +++ b/plugins/available/jump.plugin.bash @@ -4,7 +4,8 @@ cite about-plugin about-plugin 'initialize jump (see https://github.com/gsamokovarov/jump). Add `export JUMP_OPTS=("--bind=z")` to change keybinding' function __init_jump() { - if _command_exists jump; then + if _command_exists jump + then eval "$(jump shell bash "${JUMP_OPTS[@]}")" fi } diff --git a/plugins/available/latex.plugin.bash b/plugins/available/latex.plugin.bash index 474f4abc..d2ce9d82 100644 --- a/plugins/available/latex.plugin.bash +++ b/plugins/available/latex.plugin.bash @@ -10,7 +10,8 @@ _bash_it_plugin_latex_paths=( # add mactex to the path if its present for _bash_it_plugin_latex_path in "${_bash_it_plugin_latex_paths[@]}"; do - if [[ -d "$_bash_it_plugin_latex_path/" ]]; then + if [[ -d "$_bash_it_plugin_latex_path/" ]] + then pathmunge "$_bash_it_plugin_latex_path" after && break fi done diff --git a/plugins/available/nginx.plugin.bash b/plugins/available/nginx.plugin.bash index 8d75a881..7c6f11ae 100644 --- a/plugins/available/nginx.plugin.bash +++ b/plugins/available/nginx.plugin.bash @@ -9,7 +9,8 @@ function nginx_reload() { group 'nginx' local FILE="${NGINX_PATH?}/logs/nginx.pid" - if [[ -s $FILE ]]; then + if [[ -s $FILE ]] + then echo "Reloading NGINX..." read -r PID < "${FILE}" sudo kill -HUP "${PID?}" @@ -24,7 +25,8 @@ function nginx_stop() { group 'nginx' local FILE="${NGINX_PATH?}/logs/nginx.pid" - if [[ -s $FILE ]]; then + if [[ -s $FILE ]] + then echo "Stopping NGINX..." read -r PID < "${FILE}" sudo kill -INT "${PID?}" @@ -39,7 +41,8 @@ function nginx_start() { group 'nginx' local FILE="${NGINX_PATH?}/sbin/nginx" - if [[ -x $FILE ]]; then + if [[ -x $FILE ]] + then echo "Starting NGINX..." sudo "${FILE}" else diff --git a/plugins/available/node.plugin.bash b/plugins/available/node.plugin.bash index 8bf876df..8292610d 100644 --- a/plugins/available/node.plugin.bash +++ b/plugins/available/node.plugin.bash @@ -9,6 +9,7 @@ _command_exists npm || return pathmunge "./node_modules/.bin" "after" # If not using nodenv, ensure global modules are in PATH -if [[ ! "$(type -p npm)" == *"nodenv/shims"* ]]; then +if [[ ! "$(type -p npm)" == *"nodenv/shims"* ]] + then pathmunge "$(npm config get prefix)/bin" "after" fi diff --git a/plugins/available/nodenv.plugin.bash b/plugins/available/nodenv.plugin.bash index 262a57c3..d3c61323 100644 --- a/plugins/available/nodenv.plugin.bash +++ b/plugins/available/nodenv.plugin.bash @@ -5,6 +5,7 @@ about-plugin 'load nodenv, if you are using it' export NODENV_ROOT="$HOME/.nodenv" pathmunge "$NODENV_ROOT/bin" -if _command_exists nodenv; then +if _command_exists nodenv + then eval "$(nodenv init - bash)" fi diff --git a/plugins/available/osx-timemachine.plugin.bash b/plugins/available/osx-timemachine.plugin.bash index e30d37bd..04d5efd9 100644 --- a/plugins/available/osx-timemachine.plugin.bash +++ b/plugins/available/osx-timemachine.plugin.bash @@ -1,7 +1,8 @@ # shellcheck shell=bash about-plugin 'OS X Time Machine functions' -if [[ "${OSTYPE}" != 'darwin'* ]]; then +if [[ "${OSTYPE}" != 'darwin'* ]] + then _log_warning "This plugin only works with Mac OS X" return 1 fi diff --git a/plugins/available/osx.plugin.bash b/plugins/available/osx.plugin.bash index 139f58a1..6394cf18 100644 --- a/plugins/available/osx.plugin.bash +++ b/plugins/available/osx.plugin.bash @@ -1,13 +1,15 @@ # shellcheck shell=bash about-plugin 'osx-specific functions' -if [[ "${OSTYPE}" != 'darwin'* ]]; then +if [[ "${OSTYPE}" != 'darwin'* ]] + then _log_warning "This plugin only works with Mac OS X." return 1 fi # OS X: Open new tabs in same directory -if _is_function update_terminal_cwd; then +if _is_function update_terminal_cwd + then safe_append_prompt_command 'update_terminal_cwd' fi @@ -82,7 +84,8 @@ function list-jvms() { # Map state of JVM for ((i = 0; i < ${#JVMS[@]}; i++)); do - if [[ -f "${JVMS[i]}/Contents/Info.plist" ]]; then + if [[ -f "${JVMS[i]}/Contents/Info.plist" ]] + then JVMS_STATES[i]=enabled else JVMS_STATES[i]=disabled @@ -105,11 +108,13 @@ function pick-default-jvm() { # OPTION for default jdk and set variables while [[ ! "$OPTION" =~ ^[0-9]+$ || OPTION -ge "${#JVMS[@]}" ]]; do read -rp "Enter Default JVM: " OPTION - if [[ ! "$OPTION" =~ ^[0-9]+$ ]]; then + if [[ ! "$OPTION" =~ ^[0-9]+$ ]] + then echo "Please enter a number" fi - if [[ OPTION -ge "${#JVMS[@]}" ]]; then + if [[ OPTION -ge "${#JVMS[@]}" ]] + then echo "Please select one of the displayed JVMs" fi done @@ -119,13 +124,15 @@ function pick-default-jvm() { # Disable all jdk for ((i = 0; i < ${#JVMS[@]}; i++)); do - if [[ "${JVMS[i]}" != "${DEFAULT_JVM_DIR}" && -f "${JVMS[i]}/Contents/Info.plist" ]]; then + if [[ "${JVMS[i]}" != "${DEFAULT_JVM_DIR}" && -f "${JVMS[i]}/Contents/Info.plist" ]] + then sudo mv "${JVMS[i]}/Contents/Info.plist" "${JVMS[i]}/Contents/Info.plist.disable" fi done # Enable default jdk - if [[ -f "${DEFAULT_JVM_DIR}/Contents/Info.plist.disable" ]]; then + if [[ -f "${DEFAULT_JVM_DIR}/Contents/Info.plist.disable" ]] + then sudo mv -vn "${DEFAULT_JVM_DIR}/Contents/Info.plist.disable" "${DEFAULT_JVM_DIR}/Contents/Info.plist" \ && echo "Enabled ${DEFAULT_JVM} as default JVM" fi diff --git a/plugins/available/pack.plugin.bash b/plugins/available/pack.plugin.bash index a63a8e57..83e8d2b6 100644 --- a/plugins/available/pack.plugin.bash +++ b/plugins/available/pack.plugin.bash @@ -6,7 +6,8 @@ about-plugin 'CNB pack cli aliases' __pack_debug() { - if [[ -n ${BASH_COMP_DEBUG_FILE} ]]; then + if [[ -n ${BASH_COMP_DEBUG_FILE} ]] + then echo "$*" >> "${BASH_COMP_DEBUG_FILE}" fi } @@ -45,23 +46,28 @@ __pack_handle_reply() __pack_debug "${FUNCNAME[0]}" case $cur in -*) - if [[ $(type -t compopt) = "builtin" ]]; then + if [[ $(type -t compopt) = "builtin" ]] + then compopt -o nospace fi local allflags - if [ ${#must_have_one_flag[@]} -ne 0 ]; then + if [ ${#must_have_one_flag[@]} -ne 0 ] + then allflags=("${must_have_one_flag[@]}") else allflags=("${flags[*]} ${two_word_flags[*]}") fi COMPREPLY=( $(compgen -W "${allflags[*]}" -- "$cur") ) - if [[ $(type -t compopt) = "builtin" ]]; then + if [[ $(type -t compopt) = "builtin" ]] + then [[ "${COMPREPLY[0]}" == *= ]] || compopt +o nospace fi # complete after --flag=abc - if [[ $cur == *=* ]]; then - if [[ $(type -t compopt) = "builtin" ]]; then + if [[ $cur == *=* ]] + then + if [[ $(type -t compopt) = "builtin" ]] + then compopt +o nospace fi @@ -69,11 +75,13 @@ __pack_handle_reply() flag="${cur%=*}" __pack_index_of_word "${flag}" "${flags_with_completion[@]}" COMPREPLY=() - if [[ ${index} -ge 0 ]]; then + if [[ ${index} -ge 0 ]] + then PREFIX="" cur="${cur#*=}" ${flags_completion[${index}]} - if [ -n "${ZSH_VERSION}" ]; then + if [ -n "${ZSH_VERSION}" ] + then # zsh completion needs --flag= prefix eval "COMPREPLY=( \"\${COMPREPLY[@]/#/${flag}=}\" )" fi @@ -86,42 +94,50 @@ __pack_handle_reply() # check if we are handling a flag with special work handling local index __pack_index_of_word "${prev}" "${flags_with_completion[@]}" - if [[ ${index} -ge 0 ]]; then + if [[ ${index} -ge 0 ]] + then ${flags_completion[${index}]} return fi # we are parsing a flag and don't have a special handler, no completion - if [[ ${cur} != "${words[cword]}" ]]; then + if [[ ${cur} != "${words[cword]}" ]] + then return fi local completions completions=("${commands[@]}") - if [[ ${#must_have_one_noun[@]} -ne 0 ]]; then + if [[ ${#must_have_one_noun[@]} -ne 0 ]] + then completions=("${must_have_one_noun[@]}") fi - if [[ ${#must_have_one_flag[@]} -ne 0 ]]; then + if [[ ${#must_have_one_flag[@]} -ne 0 ]] + then completions+=("${must_have_one_flag[@]}") fi COMPREPLY=( $(compgen -W "${completions[*]}" -- "$cur") ) - if [[ ${#COMPREPLY[@]} -eq 0 && ${#noun_aliases[@]} -gt 0 && ${#must_have_one_noun[@]} -ne 0 ]]; then + if [[ ${#COMPREPLY[@]} -eq 0 && ${#noun_aliases[@]} -gt 0 && ${#must_have_one_noun[@]} -ne 0 ]] + then COMPREPLY=( $(compgen -W "${noun_aliases[*]}" -- "$cur") ) fi - if [[ ${#COMPREPLY[@]} -eq 0 ]]; then + if [[ ${#COMPREPLY[@]} -eq 0 ]] + then declare -F __custom_func >/dev/null && __custom_func fi # available in bash-completion >= 2, not always present on macOS - if declare -F __ltrim_colon_completions >/dev/null; then + if declare -F __ltrim_colon_completions >/dev/null + then __ltrim_colon_completions "$cur" fi # If there is only 1 completion and it is a flag with an = it will be completed # but we don't want a space after the = - if [[ "${#COMPREPLY[@]}" -eq "1" ]] && [[ $(type -t compopt) = "builtin" ]] && [[ "${COMPREPLY[0]}" == --*= ]]; then + if [[ "${#COMPREPLY[@]}" -eq "1" ]] && [[ $(type -t compopt) = "builtin" ]] && [[ "${COMPREPLY[0]}" == --*= ]] + then compopt -o nospace fi } @@ -129,13 +145,13 @@ __pack_handle_reply() # The arguments should be in the form "ext1|ext2|extn" __pack_handle_filename_extension_flag() { - local ext="$1" + local ext="${1}" _filedir "@(${ext})" } __pack_handle_subdirs_in_dir_flag() { - local dir="$1" + local dir="${1}" pushd "${dir}" >/dev/null 2>&1 && _filedir -d && popd >/dev/null 2>&1 } @@ -147,27 +163,33 @@ __pack_handle_flag() local flagname=${words[c]} local flagvalue # if the word contained an = - if [[ ${words[c]} == *"="* ]]; then + if [[ ${words[c]} == *"="* ]] + then flagvalue=${flagname#*=} # take in as flagvalue after the = flagname=${flagname%=*} # strip everything after the = flagname="${flagname}=" # but put the = back fi __pack_debug "${FUNCNAME[0]}: looking for ${flagname}" - if __pack_contains_word "${flagname}" "${must_have_one_flag[@]}"; then + if __pack_contains_word "${flagname}" "${must_have_one_flag[@]}" + then must_have_one_flag=() fi # if you set a flag which only applies to this command, don't show subcommands - if __pack_contains_word "${flagname}" "${local_nonpersistent_flags[@]}"; then + if __pack_contains_word "${flagname}" "${local_nonpersistent_flags[@]}" + then commands=() fi # keep flag value with flagname as flaghash # flaghash variable is an associative array which is only supported in bash > 3. - if [[ -z "${BASH_VERSION}" || "${BASH_VERSINFO[0]}" -gt 3 ]]; then - if [ -n "${flagvalue}" ] ; then + if [[ -z "${BASH_VERSION}" || "${BASH_VERSINFO[0]}" -gt 3 ]] + then + if [ -n "${flagvalue}" ] + then flaghash[${flagname}]=${flagvalue} - elif [ -n "${words[ $((c+1)) ]}" ] ; then + elif [ -n "${words[ $((c+1)) ]}" ] + then flaghash[${flagname}]=${words[ $((c+1)) ]} else flaghash[${flagname}]="true" # pad "true" for bool flag @@ -175,10 +197,12 @@ __pack_handle_flag() fi # skip the argument to a two word flag - if __pack_contains_word "${words[c]}" "${two_word_flags[@]}"; then + if __pack_contains_word "${words[c]}" "${two_word_flags[@]}" + then c=$((c+1)) # if we are looking for a flags value, don't show commands - if [[ $c -eq $cword ]]; then + if [[ $c -eq $cword ]] + then commands=() fi fi @@ -191,9 +215,11 @@ __pack_handle_noun() { __pack_debug "${FUNCNAME[0]}: c is $c words[c] is ${words[c]}" - if __pack_contains_word "${words[c]}" "${must_have_one_noun[@]}"; then + if __pack_contains_word "${words[c]}" "${must_have_one_noun[@]}" + then must_have_one_noun=() - elif __pack_contains_word "${words[c]}" "${noun_aliases[@]}"; then + elif __pack_contains_word "${words[c]}" "${noun_aliases[@]}" + then must_have_one_noun=() fi @@ -206,10 +232,12 @@ __pack_handle_command() __pack_debug "${FUNCNAME[0]}: c is $c words[c] is ${words[c]}" local next_command - if [[ -n ${last_command} ]]; then + if [[ -n ${last_command} ]] + then next_command="_${last_command}_${words[c]//:/__}" else - if [[ $c -eq 0 ]]; then + if [[ $c -eq 0 ]] + then next_command="_pack_root_command" else next_command="_${words[c]//:/__}" @@ -222,20 +250,26 @@ __pack_handle_command() __pack_handle_word() { - if [[ $c -ge $cword ]]; then + if [[ $c -ge $cword ]] + then __pack_handle_reply return fi __pack_debug "${FUNCNAME[0]}: c is $c words[c] is ${words[c]}" - if [[ "${words[c]}" == -* ]]; then + if [[ "${words[c]}" == -* ]] + then __pack_handle_flag - elif __pack_contains_word "${words[c]}" "${commands[@]}"; then + elif __pack_contains_word "${words[c]}" "${commands[@]}" + then __pack_handle_command - elif [[ $c -eq 0 ]]; then + elif [[ $c -eq 0 ]] + then __pack_handle_command - elif __pack_contains_word "${words[c]}" "${command_aliases[@]}"; then + elif __pack_contains_word "${words[c]}" "${command_aliases[@]}" + then # aliashash variable is an associative array which is only supported in bash > 3. - if [[ -z "${BASH_VERSION}" || "${BASH_VERSINFO[0]}" -gt 3 ]]; then + if [[ -z "${BASH_VERSION}" || "${BASH_VERSINFO[0]}" -gt 3 ]] + then words[c]=${aliashash[${words[c]}]} __pack_handle_command else @@ -591,7 +625,8 @@ __start_pack() local cur prev words cword declare -A flaghash 2>/dev/null || : declare -A aliashash 2>/dev/null || : - if declare -F _init_completion >/dev/null 2>&1; then + if declare -F _init_completion >/dev/null 2>&1 + then _init_completion -s || return else __pack_init_completion -n "=" || return @@ -612,7 +647,8 @@ __start_pack() __pack_handle_word } -if [[ $(type -t compopt) = "builtin" ]]; then +if [[ $(type -t compopt) = "builtin" ]] + then complete -o default -F __start_pack pack else complete -o default -o nospace -F __start_pack pack diff --git a/plugins/available/percol.plugin.bash b/plugins/available/percol.plugin.bash index 027dfdc4..294a1113 100644 --- a/plugins/available/percol.plugin.bash +++ b/plugins/available/percol.plugin.bash @@ -15,7 +15,8 @@ about-plugin 'Search&Select history with percol' _command_exists percol || return -if [[ ${BASH_VERSINFO[0]} -lt 4 ]]; then +if [[ ${BASH_VERSINFO[0]} -lt 4 ]] + then _log_warning "You have to upgrade Bash to Bash v4.x to use the 'percol' plugin." _log_warning "Your current Bash version is $BASH_VERSION." return diff --git a/plugins/available/plenv.plugin.bash b/plugins/available/plenv.plugin.bash index 79a9cf49..c4a889cf 100644 --- a/plugins/available/plenv.plugin.bash +++ b/plugins/available/plenv.plugin.bash @@ -5,12 +5,14 @@ cite about-plugin about-plugin 'plenv plugin for Perl' -if [[ -d "${HOME}/.plenv/bin" ]]; then +if [[ -d "${HOME}/.plenv/bin" ]] + then # load plenv bin dir into path if it exists pathmunge "${HOME}/.plenv/bin" fi -if _command_exists plenv; then +if _command_exists plenv + then # init plenv eval "$(plenv init - bash)" fi diff --git a/plugins/available/projects.plugin.bash b/plugins/available/projects.plugin.bash index 34fa001e..7b68eecf 100644 --- a/plugins/available/projects.plugin.bash +++ b/plugins/available/projects.plugin.bash @@ -11,7 +11,8 @@ function pj() { local cmd PS3 dest d local -a dests - if [[ "$proj" == "open" ]]; then + if [[ "$proj" == "open" ]] + then shift proj="${1}" cmd="${EDITOR?}" @@ -21,7 +22,8 @@ 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]}/${proj}" ]]; then + if [[ ! -d "${dests[d]}/${proj}" ]] + then unset 'dests[d]' fi done diff --git a/plugins/available/proxy.plugin.bash b/plugins/available/proxy.plugin.bash index 985d77b4..6b1a5937 100644 --- a/plugins/available/proxy.plugin.bash +++ b/plugins/available/proxy.plugin.bash @@ -108,7 +108,8 @@ function npm-show-proxy() { about 'Shows the npm proxy settings' group 'proxy' - if _command_exists npm; then + if _command_exists npm + then echo "" echo "npm" echo "===" @@ -122,7 +123,8 @@ function npm-disable-proxy() { about 'Disables npm proxy settings' group 'proxy' - if _command_exists npm; then + if _command_exists npm + then npm config delete proxy npm config delete https-proxy npm config delete noproxy @@ -138,7 +140,8 @@ function npm-enable-proxy() { local my_https_proxy="${2:-${BASH_IT_HTTPS_PROXY:-}}" local my_no_proxy="${3:-${BASH_IT_NO_PROXY:-}}" - if _command_exists npm; then + if _command_exists npm + then npm config set proxy "${my_http_proxy:?}" || return npm config set https-proxy "${my_https_proxy:?}" || return npm config set noproxy "${my_no_proxy:-}" || return @@ -150,7 +153,8 @@ function git-global-show-proxy() { about 'Shows global Git proxy settings' group 'proxy' - if _command_exists git; then + if _command_exists git + then echo "" echo "Git (Global Settings)" echo "=====================" @@ -163,7 +167,8 @@ function git-global-disable-proxy() { about 'Disables global Git proxy settings' group 'proxy' - if _command_exists git; then + if _command_exists git + then git config --global --unset-all http.proxy git config --global --unset-all https.proxy echo "Disabled global Git proxy settings" @@ -174,7 +179,8 @@ function git-global-enable-proxy() { about 'Enables global Git proxy settings' group 'proxy' - if _command_exists git; then + if _command_exists git + then git-global-disable-proxy git config --global --add http.proxy "${BASH_IT_HTTP_PROXY:?}" @@ -187,7 +193,8 @@ function git-show-proxy() { about 'Shows current Git project proxy settings' group 'proxy' - if _command_exists git; then + if _command_exists git + then echo "Git Project Proxy Settings" echo "=====================" echo "Git HTTP proxy: $(git config --get http.proxy)" @@ -199,7 +206,8 @@ function git-disable-proxy() { about 'Disables current Git project proxy settings' group 'proxy' - if _command_exists git; then + if _command_exists git + then git config --unset-all http.proxy git config --unset-all https.proxy echo "Disabled Git project proxy settings" @@ -210,7 +218,8 @@ function git-enable-proxy() { about 'Enables current Git project proxy settings' group 'proxy' - if _command_exists git; then + if _command_exists git + then git-disable-proxy git config --add http.proxy "${BASH_IT_HTTP_PROXY:?}" @@ -223,7 +232,8 @@ function svn-show-proxy() { about 'Shows SVN proxy settings' group 'proxy' - if _command_exists svn && _command_exists python2; then + if _command_exists svn && _command_exists python2 + then echo "" echo "SVN Proxy Settings" echo "==================" @@ -252,7 +262,8 @@ function svn-disable-proxy() { about 'Disables SVN proxy settings' group 'proxy' - if _command_exists svn_command_exists python2; then + if _command_exists svn_command_exists python2 + then python2 - << END import ConfigParser, os config = ConfigParser.ConfigParser() @@ -280,7 +291,8 @@ function svn-enable-proxy() { about 'Enables SVN proxy settings' group 'proxy' - if _command_exists svn _command_exists python2; then + if _command_exists svn _command_exists python2 + then local my_http_proxy="${1:-${BASH_IT_HTTP_PROXY:-}}" python2 - "${my_http_proxy:?}" "${BASH_IT_NO_PROXY:-}" << END @@ -316,7 +328,8 @@ function ssh-show-proxy() { about 'Shows SSH config proxy settings (from ~/.ssh/config)' group 'proxy' - if [ -f ~/.ssh/config ]; then + if [ -f ~/.ssh/config ] + then echo "" echo "SSH Config Enabled in ~/.ssh/config" echo "===================================" @@ -352,7 +365,8 @@ function ssh-disable-proxy() { about 'Disables SSH config proxy settings' group 'proxy' - if [ -f ~/.ssh/config ]; then + if [ -f ~/.ssh/config ] + then sed -e's/^.*ProxyCommand/# ProxyCommand/' "${BASH_IT_SED_I_PARAMETERS[@]}" ~/.ssh/config echo "Disabled SSH config proxy settings" fi @@ -362,7 +376,8 @@ function ssh-enable-proxy() { about 'Enables SSH config proxy settings' group 'proxy' - if [ -f ~/.ssh/config ]; then + if [ -f ~/.ssh/config ] + then sed -e's/# ProxyCommand/ ProxyCommand/' "${BASH_IT_SED_I_PARAMETERS[@]}" ~/.ssh/config echo "Enabled SSH config proxy settings" fi diff --git a/plugins/available/pyenv.plugin.bash b/plugins/available/pyenv.plugin.bash index 05d28478..f5fe7c1e 100644 --- a/plugins/available/pyenv.plugin.bash +++ b/plugins/available/pyenv.plugin.bash @@ -20,7 +20,8 @@ _command_exists pyenv \ export PYENV_ROOT="${PYENV_ROOT:-$HOME/.pyenv}" # Add PYENV_ROOT/bin to PATH, if that's where it's installed -if ! _command_exists pyenv && [[ -x "$PYENV_ROOT/bin/pyenv" ]]; then +if ! _command_exists pyenv && [[ -x "$PYENV_ROOT/bin/pyenv" ]] + then pathmunge "$PYENV_ROOT/bin" fi @@ -29,6 +30,7 @@ pathmunge "$PYENV_ROOT/shims" eval "$(pyenv init - bash)" # Load pyenv virtualenv if the virtualenv plugin is installed. -if pyenv virtualenv-init - &> /dev/null; then +if pyenv virtualenv-init - &> /dev/null + then eval "$(pyenv virtualenv-init - bash)" fi diff --git a/plugins/available/python.plugin.bash b/plugins/available/python.plugin.bash index bd644e8b..71e9343b 100644 --- a/plugins/available/python.plugin.bash +++ b/plugins/available/python.plugin.bash @@ -1,9 +1,11 @@ # shellcheck shell=bash about-plugin 'alias "shttp" to SimpleHTTPServer' -if _command_exists python3; then +if _command_exists python3 + then alias shttp='python3 -m http.server' -elif _command_exists python; then +elif _command_exists python + then alias shttp='python -m http.server' else _log_warning "Unable to load 'plugin/python' due to being unable to find a working 'python'" @@ -18,10 +20,12 @@ function pyedit() { xpyc="$(python -c "import os, sys; f = open(os.devnull, 'w'); sys.stderr = f; module = __import__('$1'); sys.stdout.write(module.__file__)")" - if [[ "$xpyc" == "" ]]; then + if [[ "$xpyc" == "" ]] + then echo "Python module $1 not found" return 1 - elif [[ "$xpyc" == *__init__.py* ]]; then + elif [[ "$xpyc" == *__init__.py* ]] + then xpydir="${xpyc%/*}" echo "$EDITOR $xpydir" ${VISUAL:-${EDITOR:-${ALTERNATE_EDITOR:-nano}}} "$xpydir" diff --git a/plugins/available/rails.plugin.bash b/plugins/available/rails.plugin.bash index 414fd9f9..528e3810 100644 --- a/plugins/available/rails.plugin.bash +++ b/plugins/available/rails.plugin.bash @@ -7,7 +7,8 @@ function killrails() { group 'rails' railsPid="$(cat tmp/pids/server.pid)" - if [ ! -z "$railsPid" ]; then + if [ ! -z "$railsPid" ] + then echo "[OK] Rails Server Process Id : ${railsPid}" kill -9 $railsPid echo "[OK] Process Killed" diff --git a/plugins/available/rbenv.plugin.bash b/plugins/available/rbenv.plugin.bash index f3605f58..415df1e1 100644 --- a/plugins/available/rbenv.plugin.bash +++ b/plugins/available/rbenv.plugin.bash @@ -5,6 +5,7 @@ about-plugin 'load rbenv, if you are using it' export RBENV_ROOT="$HOME/.rbenv" pathmunge "$RBENV_ROOT/bin" -if _command_exists rbenv; then +if _command_exists rbenv + then eval "$(rbenv init - bash)" fi diff --git a/plugins/available/ruby.plugin.bash b/plugins/available/ruby.plugin.bash index aed8daf8..6b1154e3 100644 --- a/plugins/available/ruby.plugin.bash +++ b/plugins/available/ruby.plugin.bash @@ -4,7 +4,8 @@ about-plugin 'ruby and rubygems specific functions and settings' # Make commands installed with 'gem install --user-install' available # ~/.gem/ruby/${RUBY_VERSION}/bin/ -if _command_exists ruby && _command_exists gem; then +if _command_exists ruby && _command_exists gem + then pathmunge "$(ruby -e 'print Gem.user_dir')/bin" after fi diff --git a/plugins/available/sshagent.plugin.bash b/plugins/available/sshagent.plugin.bash index 42acfb51..aa4e8e05 100644 --- a/plugins/available/sshagent.plugin.bash +++ b/plugins/available/sshagent.plugin.bash @@ -23,7 +23,8 @@ function _get_process_status_field() { field="${2}" status_file="/proc/${pid}/status" if ! ([[ -d "${status_file%/*}" ]] \ - && [[ -r "${status_file}" ]]); then + && [[ -r "${status_file}" ]]) + then echo ""; return; fi grep "${field}:" "${status_file}" \ @@ -35,7 +36,8 @@ function _get_process_status_field() { function _is_item_in_list() { local item for item in "${@:1}"; do - if [[ "${item}" == "${1}" ]]; then + if [[ "${item}" == "${1}" ]] + then return 1 fi done @@ -55,7 +57,8 @@ function _is_proc_alive_at_pid() { actual_name=$(_get_process_status_field "${pid}" "Name") [[ "${expected_name}" == "${actual_name}" ]] || return 1 actual_state=$(_get_process_status_field "${pid}" "State") - if _is_item_in_list "${actual_state}" "X" "T" "Z"; then + if _is_item_in_list "${actual_state}" "X" "T" "Z" + then return 1 fi return 0 @@ -71,26 +74,30 @@ function _ensure_valid_sshagent_env() { type restorecon &> /dev/null tmp_res="$?" - if [[ "${tmp_res}" -eq 0 ]]; then + if [[ "${tmp_res}" -eq 0 ]] + then restorecon -rv "${HOME}/.ssh" fi # no env file -> shoot a new agent - if ! [[ -r "${SSH_AGENT_ENV}" ]]; then + if ! [[ -r "${SSH_AGENT_ENV}" ]] + then ssh-agent > "${SSH_AGENT_ENV}" return fi ## do not trust pre-existing SSH_AGENT_ENV agent_pid=$(_get_sshagent_pid_from_env_file "${SSH_AGENT_ENV}") - if [[ -z "${agent_pid}" ]]; then + if [[ -z "${agent_pid}" ]] + then # no pid detected -> shoot a new agent ssh-agent > "${SSH_AGENT_ENV}" return fi ## do not trust SSH_AGENT_PID - if _is_proc_alive_at_pid "${agent_pid}"; then + if _is_proc_alive_at_pid "${agent_pid}" + then return fi diff --git a/plugins/available/subversion.plugin.bash b/plugins/available/subversion.plugin.bash index bdb3edf1..3cfdfd66 100644 --- a/plugins/available/subversion.plugin.bash +++ b/plugins/available/subversion.plugin.bash @@ -6,7 +6,8 @@ rm_svn(){ param '1: directory to search for files' group 'svn' - if [ -z "$1" ]; then + if [ -z "${1}" ] + then reference rm_svn return fi diff --git a/plugins/available/sudo.plugin.bash b/plugins/available/sudo.plugin.bash index eb155daa..686feca9 100644 --- a/plugins/available/sudo.plugin.bash +++ b/plugins/available/sudo.plugin.bash @@ -6,7 +6,8 @@ function sudo-command-line() { group "sudo" [[ ${#READLINE_LINE} -eq 0 ]] && READLINE_LINE=$(fc -l -n -1 | xargs) - if [[ $READLINE_LINE == sudo\ * ]]; then + if [[ $READLINE_LINE == sudo\ * ]] + then READLINE_LINE="${READLINE_LINE#sudo }" else READLINE_LINE="sudo $READLINE_LINE" @@ -17,6 +18,7 @@ function sudo-command-line() { # Define shortcut keys: [Esc] [Esc] # Readline library requires bash version 4 or later -if [ "${BASH_VERSINFO}" -ge 4 ]; then +if [ "${BASH_VERSINFO}" -ge 4 ] + then bind -x '"\e\e": sudo-command-line' fi diff --git a/plugins/available/textmate.plugin.bash b/plugins/available/textmate.plugin.bash index 5c81f195..860b4124 100644 --- a/plugins/available/textmate.plugin.bash +++ b/plugins/available/textmate.plugin.bash @@ -2,7 +2,8 @@ cite about-plugin about-plugin 'set textmate as a default editor' -if _command_exists mate; then +if _command_exists mate + then EDITOR="$(type -p mate) -w" GIT_EDITOR="$EDITOR" export EDITOR GIT_EDITOR diff --git a/plugins/available/thefuck.plugin.bash b/plugins/available/thefuck.plugin.bash index 242a77df..f3f490b6 100644 --- a/plugins/available/thefuck.plugin.bash +++ b/plugins/available/thefuck.plugin.bash @@ -3,7 +3,8 @@ about-plugin 'Initialization for fuck' # https://github.com/nvbn/thefuck -if _command_exists thefuck; then +if _command_exists thefuck + then # shellcheck disable=SC2046 eval $(thefuck --alias) fi diff --git a/plugins/available/virtualenv.plugin.bash b/plugins/available/virtualenv.plugin.bash index 41d55ddf..e4838e88 100644 --- a/plugins/available/virtualenv.plugin.bash +++ b/plugins/available/virtualenv.plugin.bash @@ -5,9 +5,11 @@ cite about-plugin about-plugin 'virtualenvwrapper and pyenv-virtualenvwrapper helper functions' -if _command_exists pyenv; then +if _command_exists pyenv + then pyenv virtualenvwrapper -elif _command_exists virtualenvwrapper.sh; then +elif _command_exists virtualenvwrapper.sh + then source virtualenvwrapper.sh fi diff --git a/plugins/available/xterm.plugin.bash b/plugins/available/xterm.plugin.bash index 740460e4..c961c355 100644 --- a/plugins/available/xterm.plugin.bash +++ b/plugins/available/xterm.plugin.bash @@ -2,34 +2,36 @@ cite about-plugin about-plugin 'automatically set your xterm title with host and location info' -_short-dirname() { +function _short-dirname() { local dir_name="${PWD/~/\~}" - if [[ "${SHORT_TERM_LINE:-}" == true && "${#dir_name}" -gt 8 ]]; then + if [[ "${SHORT_TERM_LINE:-}" == true && "${#dir_name}" -gt 8 ]] + then echo "${dir_name##*/}" else echo "${dir_name}" fi } -_short-command() { +function _short-command() { local input_command="$*" - if [[ "${SHORT_TERM_LINE:-}" == true && "${#input_command}" -gt 8 ]]; then + if [[ "${SHORT_TERM_LINE:-}" == true && "${#input_command}" -gt 8 ]] + then echo "${input_command%% *}" else echo "${input_command}" fi } -set_xterm_title() { +function set_xterm_title() { local title="${1:-}" echo -ne "\033]0;${title}\007" } -precmd_xterm_title() { +function precmd_xterm_title() { set_xterm_title "${SHORT_USER:-${USER}}@${SHORT_HOSTNAME:-${HOSTNAME}} $(_short-dirname) ${PROMPT_CHAR:-\$}" } -preexec_xterm_title() { +function preexec_xterm_title() { local command_line="${BASH_COMMAND:-${1:-}}" local directory_name short_command directory_name="$(_short-dirname)" diff --git a/plugins/available/zoxide.plugin.bash b/plugins/available/zoxide.plugin.bash index 5f9d634f..8a4a0456 100644 --- a/plugins/available/zoxide.plugin.bash +++ b/plugins/available/zoxide.plugin.bash @@ -2,7 +2,8 @@ cite about-plugin about-plugin 'zoxide is a smarter cd command for your shell.' -if _command_exists zoxide; then +if _command_exists zoxide + then eval "$(zoxide init bash)" else _log_error 'zoxide not found, please install it from https://github.com/ajeetdsouza/zoxide' diff --git a/profiles/default.bash_it b/profiles/default.bash_it index 9a55f6c7..e21aafad 100644 --- a/profiles/default.bash_it +++ b/profiles/default.bash_it @@ -1,12 +1,12 @@ -# This is the default profile of Bash-it - -# plugins -plugins base - -# completion -completion aliases -completion bash-it -completion system - -# aliases -aliases general +# This is the default profile of Bash-it + +# plugins +plugins base + +# completion +completion aliases +completion bash-it +completion system + +# aliases +aliases general diff --git a/scripts/reloader.bash b/scripts/reloader.bash index 846bbf75..694dc9fc 100644 --- a/scripts/reloader.bash +++ b/scripts/reloader.bash @@ -6,7 +6,8 @@ BASH_IT_LOG_PREFIX="core: reloader: " _bash_it_reloader_type="" -if [[ "${1:-}" != "skip" ]] && [[ -d "${BASH_IT?}/enabled" ]]; then +if [[ "${1:-}" != "skip" ]] && [[ -d "${BASH_IT?}/enabled" ]] + then case $1 in alias | completion | plugin) _bash_it_reloader_type=$1 @@ -18,7 +19,8 @@ if [[ "${1:-}" != "skip" ]] && [[ -d "${BASH_IT?}/enabled" ]]; then esac for _bash_it_reloader_file in "$BASH_IT/enabled"/*"${_bash_it_reloader_type}.bash"; do - if [[ -e "${_bash_it_reloader_file}" ]]; then + if [[ -e "${_bash_it_reloader_file}" ]] + then _bash-it-log-prefix-by-path "${_bash_it_reloader_file}" _log_debug "Loading component..." # shellcheck source=/dev/null @@ -30,12 +32,14 @@ if [[ "${1:-}" != "skip" ]] && [[ -d "${BASH_IT?}/enabled" ]]; then done fi -if [[ -n "${2:-}" ]] && [[ -d "$BASH_IT/${2}/enabled" ]]; then +if [[ -n "${2:-}" ]] && [[ -d "$BASH_IT/${2}/enabled" ]] + then case $2 in aliases | completion | plugins) _log_warning "Using legacy enabling for $2, please update your bash-it version and migrate" for _bash_it_reloader_file in "$BASH_IT/${2}/enabled"/*.bash; do - if [[ -e "$_bash_it_reloader_file" ]]; then + if [[ -e "$_bash_it_reloader_file" ]] + then _bash-it-log-prefix-by-path "${_bash_it_reloader_file}" _log_debug "Loading component..." # shellcheck source=/dev/null diff --git a/test/bash_it/bash_it.bats b/test/bash_it/bash_it.bats index ef3cdbab..ca8861ea 100644 --- a/test/bash_it/bash_it.bats +++ b/test/bash_it/bash_it.bats @@ -1,343 +1,343 @@ -# shellcheck shell=bats - -load "${MAIN_BASH_IT_DIR?}/test/test_helper.bash" - -function local_setup_file() { - # Copy the test fixture to the Bash-it folder - cp -fRP "${BASH_IT?}/test/fixtures/bash_it"/* "${BASH_IT?}/" || true - # don't load any libraries as the tests here test the *whole* kit -} - -@test "bash-it: verify that the test fixture is available" { - assert_file_exist "$BASH_IT/aliases/available/a.aliases.bash" - assert_file_exist "$BASH_IT/aliases/available/b.aliases.bash" -} - -@test "bash-it: load aliases in order" { - mkdir -p $BASH_IT/aliases/enabled - mkdir -p $BASH_IT/plugins/enabled - - ln -s $BASH_IT/plugins/available/base.plugin.bash $BASH_IT/plugins/enabled/250---base.plugin.bash - assert_link_exist "$BASH_IT/plugins/enabled/250---base.plugin.bash" - - ln -s $BASH_IT/aliases/available/a.aliases.bash $BASH_IT/aliases/enabled/150---a.aliases.bash - assert_link_exist "$BASH_IT/aliases/enabled/150---a.aliases.bash" - ln -s $BASH_IT/aliases/available/b.aliases.bash $BASH_IT/aliases/enabled/150---b.aliases.bash - assert_link_exist "$BASH_IT/aliases/enabled/150---b.aliases.bash" - - # The `test_alias` alias should not exist - run alias test_alias &> /dev/null - assert_failure - - load "$BASH_IT/bash_it.sh" - - run alias test_alias &> /dev/null - assert_success - assert_line -n 0 "alias test_alias='b'" -} - -@test "bash-it: load aliases in priority order" { - mkdir -p $BASH_IT/aliases/enabled - mkdir -p $BASH_IT/plugins/enabled - - ln -s $BASH_IT/plugins/available/base.plugin.bash $BASH_IT/plugins/enabled/250---base.plugin.bash - assert_link_exist "$BASH_IT/plugins/enabled/250---base.plugin.bash" - - ln -s $BASH_IT/aliases/available/a.aliases.bash $BASH_IT/aliases/enabled/175---a.aliases.bash - assert_link_exist "$BASH_IT/aliases/enabled/175---a.aliases.bash" - ln -s $BASH_IT/aliases/available/b.aliases.bash $BASH_IT/aliases/enabled/150---b.aliases.bash - assert_link_exist "$BASH_IT/aliases/enabled/150---b.aliases.bash" - - # The `test_alias` alias should not exist - run alias test_alias &> /dev/null - assert_failure - - load "$BASH_IT/bash_it.sh" - - run alias test_alias &> /dev/null - assert_success - assert_line -n 0 "alias test_alias='a'" -} - -@test "bash-it: load aliases and plugins in priority order" { - mkdir -p $BASH_IT/aliases/enabled - mkdir -p $BASH_IT/plugins/enabled - - ln -s $BASH_IT/plugins/available/base.plugin.bash $BASH_IT/plugins/enabled/250---base.plugin.bash - assert_link_exist "$BASH_IT/plugins/enabled/250---base.plugin.bash" - - ln -s $BASH_IT/aliases/available/a.aliases.bash $BASH_IT/aliases/enabled/150---a.aliases.bash - assert_link_exist "$BASH_IT/aliases/enabled/150---a.aliases.bash" - ln -s $BASH_IT/aliases/available/b.aliases.bash $BASH_IT/aliases/enabled/150---b.aliases.bash - assert_link_exist "$BASH_IT/aliases/enabled/150---b.aliases.bash" - ln -s $BASH_IT/plugins/available/c.plugin.bash $BASH_IT/plugins/enabled/250---c.plugin.bash - assert_link_exist "$BASH_IT/plugins/enabled/250---c.plugin.bash" - - # The `test_alias` alias should not exist - run alias test_alias &> /dev/null - assert_failure - - load "$BASH_IT/bash_it.sh" - - run alias test_alias &> /dev/null - assert_success - assert_line -n 0 "alias test_alias='c'" -} - -@test "bash-it: load aliases, plugins and completions in priority order" { - mkdir -p $BASH_IT/aliases/enabled - mkdir -p $BASH_IT/plugins/enabled - mkdir -p $BASH_IT/completion/enabled - - ln -s $BASH_IT/plugins/available/base.plugin.bash $BASH_IT/plugins/enabled/250---base.plugin.bash - assert_link_exist "$BASH_IT/plugins/enabled/250---base.plugin.bash" - - ln -s $BASH_IT/aliases/available/a.aliases.bash $BASH_IT/aliases/enabled/150---a.aliases.bash - assert_link_exist "$BASH_IT/aliases/enabled/150---a.aliases.bash" - ln -s $BASH_IT/aliases/available/b.aliases.bash $BASH_IT/completion/enabled/350---b.completion.bash - assert_link_exist "$BASH_IT/completion/enabled/350---b.completion.bash" - ln -s $BASH_IT/plugins/available/c.plugin.bash $BASH_IT/plugins/enabled/250---c.plugin.bash - assert_link_exist "$BASH_IT/plugins/enabled/250---c.plugin.bash" - - # The `test_alias` alias should not exist - run alias test_alias &> /dev/null - assert_failure - - load "$BASH_IT/bash_it.sh" - - run alias test_alias &> /dev/null - assert_success - # "b" wins since completions are loaded last in the old directory structure - assert_line -n 0 "alias test_alias='b'" -} - -@test "bash-it: load aliases, plugins and completions in priority order, even if the priority says otherwise" { - mkdir -p $BASH_IT/aliases/enabled - mkdir -p $BASH_IT/plugins/enabled - mkdir -p $BASH_IT/completion/enabled - - ln -s $BASH_IT/plugins/available/base.plugin.bash $BASH_IT/plugins/enabled/250---base.plugin.bash - assert_link_exist "$BASH_IT/plugins/enabled/250---base.plugin.bash" - - ln -s $BASH_IT/aliases/available/a.aliases.bash $BASH_IT/aliases/enabled/450---a.aliases.bash - assert_link_exist "$BASH_IT/aliases/enabled/450---a.aliases.bash" - ln -s $BASH_IT/aliases/available/b.aliases.bash $BASH_IT/completion/enabled/350---b.completion.bash - assert_link_exist "$BASH_IT/completion/enabled/350---b.completion.bash" - ln -s $BASH_IT/plugins/available/c.plugin.bash $BASH_IT/plugins/enabled/950---c.plugin.bash - assert_link_exist "$BASH_IT/plugins/enabled/950---c.plugin.bash" - - # The `test_alias` alias should not exist - run alias test_alias &> /dev/null - assert_failure - - load "$BASH_IT/bash_it.sh" - - run alias test_alias &> /dev/null - assert_success - # "b" wins since completions are loaded last in the old directory structure - assert_line -n 0 "alias test_alias='b'" -} - -@test "bash-it: load aliases and plugins in priority order, with one alias higher than plugins" { - mkdir -p $BASH_IT/aliases/enabled - mkdir -p $BASH_IT/plugins/enabled - - ln -s $BASH_IT/plugins/available/base.plugin.bash $BASH_IT/plugins/enabled/250---base.plugin.bash - assert_link_exist "$BASH_IT/plugins/enabled/250---base.plugin.bash" - - ln -s $BASH_IT/aliases/available/a.aliases.bash $BASH_IT/aliases/enabled/350---a.aliases.bash - assert_link_exist "$BASH_IT/aliases/enabled/350---a.aliases.bash" - ln -s $BASH_IT/aliases/available/b.aliases.bash $BASH_IT/aliases/enabled/150---b.aliases.bash - assert_link_exist "$BASH_IT/aliases/enabled/150---b.aliases.bash" - ln -s $BASH_IT/plugins/available/c.plugin.bash $BASH_IT/plugins/enabled/250---c.plugin.bash - assert_link_exist "$BASH_IT/plugins/enabled/250---c.plugin.bash" - - # The `test_alias` alias should not exist - run alias test_alias &> /dev/null - assert_failure - - load "$BASH_IT/bash_it.sh" - - run alias test_alias &> /dev/null - assert_success - # This will be c, loaded from the c plugin, since the individual directories - # are loaded one by one. - assert_line -n 0 "alias test_alias='c'" -} - -@test "bash-it: load global aliases in order" { - mkdir -p $BASH_IT/enabled - - ln -s $BASH_IT/plugins/available/base.plugin.bash $BASH_IT/enabled/250---base.plugin.bash - assert_link_exist "$BASH_IT/enabled/250---base.plugin.bash" - - ln -s $BASH_IT/aliases/available/a.aliases.bash $BASH_IT/enabled/150---a.aliases.bash - assert_link_exist "$BASH_IT/enabled/150---a.aliases.bash" - ln -s $BASH_IT/aliases/available/b.aliases.bash $BASH_IT/enabled/150---b.aliases.bash - assert_link_exist "$BASH_IT/enabled/150---b.aliases.bash" - - # The `test_alias` alias should not exist - run alias test_alias &> /dev/null - assert_failure - - load "$BASH_IT/bash_it.sh" - - run alias test_alias &> /dev/null - assert_success - assert_line -n 0 "alias test_alias='b'" -} - -@test "bash-it: load global aliases in priority order" { - mkdir -p $BASH_IT/enabled - - ln -s $BASH_IT/plugins/available/base.plugin.bash $BASH_IT/enabled/250---base.plugin.bash - assert_link_exist "$BASH_IT/enabled/250---base.plugin.bash" - - ln -s $BASH_IT/aliases/available/a.aliases.bash $BASH_IT/enabled/175---a.aliases.bash - assert_link_exist "$BASH_IT/enabled/175---a.aliases.bash" - ln -s $BASH_IT/aliases/available/b.aliases.bash $BASH_IT/enabled/150---b.aliases.bash - assert_link_exist "$BASH_IT/enabled/150---b.aliases.bash" - - # The `test_alias` alias should not exist - run alias test_alias &> /dev/null - assert_failure - - load "$BASH_IT/bash_it.sh" - - run alias test_alias &> /dev/null - assert_success - assert_line -n 0 "alias test_alias='a'" -} - -@test "bash-it: load global aliases and plugins in priority order" { - mkdir -p $BASH_IT/enabled - - ln -s $BASH_IT/plugins/available/base.plugin.bash $BASH_IT/enabled/250---base.plugin.bash - assert_link_exist "$BASH_IT/enabled/250---base.plugin.bash" - - ln -s $BASH_IT/aliases/available/a.aliases.bash $BASH_IT/enabled/150---a.aliases.bash - assert_link_exist "$BASH_IT/enabled/150---a.aliases.bash" - ln -s $BASH_IT/aliases/available/b.aliases.bash $BASH_IT/enabled/150---b.aliases.bash - assert_link_exist "$BASH_IT/enabled/150---b.aliases.bash" - ln -s $BASH_IT/plugins/available/c.plugin.bash $BASH_IT/enabled/250---c.plugin.bash - assert_link_exist "$BASH_IT/enabled/250---c.plugin.bash" - - # The `test_alias` alias should not exist - run alias test_alias &> /dev/null - assert_failure - - load "$BASH_IT/bash_it.sh" - - run alias test_alias &> /dev/null - assert_success - assert_line -n 0 "alias test_alias='c'" -} - -@test "bash-it: load global aliases and plugins in priority order, with one alias higher than plugins" { - mkdir -p $BASH_IT/enabled - - ln -s $BASH_IT/plugins/available/base.plugin.bash $BASH_IT/enabled/250---base.plugin.bash - assert_link_exist "$BASH_IT/enabled/250---base.plugin.bash" - - ln -s $BASH_IT/aliases/available/a.aliases.bash $BASH_IT/enabled/350---a.aliases.bash - assert_link_exist "$BASH_IT/enabled/350---a.aliases.bash" - ln -s $BASH_IT/aliases/available/b.aliases.bash $BASH_IT/enabled/150---b.aliases.bash - assert_link_exist "$BASH_IT/enabled/150---b.aliases.bash" - ln -s $BASH_IT/plugins/available/c.plugin.bash $BASH_IT/enabled/250---c.plugin.bash - assert_link_exist "$BASH_IT/enabled/250---c.plugin.bash" - - # The `test_alias` alias should not exist - run alias test_alias &> /dev/null - assert_failure - - load "$BASH_IT/bash_it.sh" - - run alias test_alias &> /dev/null - assert_success - # This will be a, loaded from the a aliases, since the global directory - # loads all component types at once - assert_line -n 0 "alias test_alias='a'" -} - -@test "bash-it: load global aliases and plugins in priority order, individual old directories are loaded later" { - mkdir -p $BASH_IT/enabled - mkdir -p $BASH_IT/aliases/enabled - - ln -s $BASH_IT/plugins/available/base.plugin.bash $BASH_IT/enabled/250---base.plugin.bash - assert_link_exist "$BASH_IT/enabled/250---base.plugin.bash" - - ln -s $BASH_IT/aliases/available/a.aliases.bash $BASH_IT/enabled/350---a.aliases.bash - assert_link_exist "$BASH_IT/enabled/350---a.aliases.bash" - ln -s $BASH_IT/aliases/available/b.aliases.bash $BASH_IT/enabled/150---b.aliases.bash - assert_link_exist "$BASH_IT/enabled/150---b.aliases.bash" - ln -s $BASH_IT/plugins/available/c.plugin.bash $BASH_IT/enabled/250---c.plugin.bash - assert_link_exist "$BASH_IT/enabled/250---c.plugin.bash" - # Add one file in the old directory structure - ln -s $BASH_IT/aliases/available/b.aliases.bash $BASH_IT/aliases/enabled/150---b.aliases.bash - assert_link_exist "$BASH_IT/aliases/enabled/150---b.aliases.bash" - - # The `test_alias` alias should not exist - run alias test_alias &> /dev/null - assert_failure - - load "$BASH_IT/bash_it.sh" - - run alias test_alias &> /dev/null - assert_success - # This will be "b", loaded from the b aliases in the individual directory, since - # the individual directories are loaded after the global one. - assert_line -n 0 "alias test_alias='b'" -} - -@test "bash-it: load enabled aliases from new structure, priority-based" { - mkdir -p $BASH_IT/enabled - ln -s $BASH_IT/aliases/available/atom.aliases.bash $BASH_IT/enabled/150---atom.aliases.bash - assert_link_exist "$BASH_IT/enabled/150---atom.aliases.bash" - ln -s $BASH_IT/plugins/available/base.plugin.bash $BASH_IT/enabled/250---base.plugin.bash - assert_link_exist "$BASH_IT/enabled/250---base.plugin.bash" - - # The `ah` alias should not exist - run alias ah &> /dev/null - assert_failure - - load "$BASH_IT/bash_it.sh" - - run alias ah &> /dev/null - assert_success -} - -@test "bash-it: load enabled aliases from old structure, priority-based" { - mkdir -p $BASH_IT/aliases/enabled - mkdir -p $BASH_IT/plugins/enabled - ln -s $BASH_IT/aliases/available/atom.aliases.bash $BASH_IT/aliases/enabled/150---atom.aliases.bash - assert_link_exist "$BASH_IT/aliases/enabled/150---atom.aliases.bash" - ln -s $BASH_IT/plugins/available/base.plugin.bash $BASH_IT/plugins/enabled/250---base.plugin.bash - assert_link_exist "$BASH_IT/plugins/enabled/250---base.plugin.bash" - - # The `ah` alias should not exist - run alias ah &> /dev/null - assert_failure - - load "$BASH_IT/bash_it.sh" - - run alias ah &> /dev/null - assert_success -} - -@test "bash-it: load enabled aliases from old structure, without priorities" { - mkdir -p $BASH_IT/aliases/enabled - mkdir -p $BASH_IT/plugins/enabled - ln -s $BASH_IT/aliases/available/atom.aliases.bash $BASH_IT/aliases/enabled/atom.aliases.bash - assert_link_exist "$BASH_IT/aliases/enabled/atom.aliases.bash" - ln -s $BASH_IT/plugins/available/base.plugin.bash $BASH_IT/plugins/enabled/base.plugin.bash - assert_link_exist "$BASH_IT/plugins/enabled/base.plugin.bash" - - # The `ah` alias should not exist - run alias ah &> /dev/null - assert_failure - - load "$BASH_IT/bash_it.sh" - - run alias ah &> /dev/null - assert_success -} +# shellcheck shell=bats + +load "${MAIN_BASH_IT_DIR?}/test/test_helper.bash" + +function local_setup_file() { + # Copy the test fixture to the Bash-it folder + cp -fRP "${BASH_IT?}/test/fixtures/bash_it"/* "${BASH_IT?}/" || true + # don't load any libraries as the tests here test the *whole* kit +} + +@test "bash-it: verify that the test fixture is available" { + assert_file_exist "$BASH_IT/aliases/available/a.aliases.bash" + assert_file_exist "$BASH_IT/aliases/available/b.aliases.bash" +} + +@test "bash-it: load aliases in order" { + mkdir -p $BASH_IT/aliases/enabled + mkdir -p $BASH_IT/plugins/enabled + + ln -s $BASH_IT/plugins/available/base.plugin.bash $BASH_IT/plugins/enabled/250---base.plugin.bash + assert_link_exist "$BASH_IT/plugins/enabled/250---base.plugin.bash" + + ln -s $BASH_IT/aliases/available/a.aliases.bash $BASH_IT/aliases/enabled/150---a.aliases.bash + assert_link_exist "$BASH_IT/aliases/enabled/150---a.aliases.bash" + ln -s $BASH_IT/aliases/available/b.aliases.bash $BASH_IT/aliases/enabled/150---b.aliases.bash + assert_link_exist "$BASH_IT/aliases/enabled/150---b.aliases.bash" + + # The `test_alias` alias should not exist + run alias test_alias &> /dev/null + assert_failure + + load "$BASH_IT/bash_it.sh" + + run alias test_alias &> /dev/null + assert_success + assert_line -n 0 "alias test_alias='b'" +} + +@test "bash-it: load aliases in priority order" { + mkdir -p $BASH_IT/aliases/enabled + mkdir -p $BASH_IT/plugins/enabled + + ln -s $BASH_IT/plugins/available/base.plugin.bash $BASH_IT/plugins/enabled/250---base.plugin.bash + assert_link_exist "$BASH_IT/plugins/enabled/250---base.plugin.bash" + + ln -s $BASH_IT/aliases/available/a.aliases.bash $BASH_IT/aliases/enabled/175---a.aliases.bash + assert_link_exist "$BASH_IT/aliases/enabled/175---a.aliases.bash" + ln -s $BASH_IT/aliases/available/b.aliases.bash $BASH_IT/aliases/enabled/150---b.aliases.bash + assert_link_exist "$BASH_IT/aliases/enabled/150---b.aliases.bash" + + # The `test_alias` alias should not exist + run alias test_alias &> /dev/null + assert_failure + + load "$BASH_IT/bash_it.sh" + + run alias test_alias &> /dev/null + assert_success + assert_line -n 0 "alias test_alias='a'" +} + +@test "bash-it: load aliases and plugins in priority order" { + mkdir -p $BASH_IT/aliases/enabled + mkdir -p $BASH_IT/plugins/enabled + + ln -s $BASH_IT/plugins/available/base.plugin.bash $BASH_IT/plugins/enabled/250---base.plugin.bash + assert_link_exist "$BASH_IT/plugins/enabled/250---base.plugin.bash" + + ln -s $BASH_IT/aliases/available/a.aliases.bash $BASH_IT/aliases/enabled/150---a.aliases.bash + assert_link_exist "$BASH_IT/aliases/enabled/150---a.aliases.bash" + ln -s $BASH_IT/aliases/available/b.aliases.bash $BASH_IT/aliases/enabled/150---b.aliases.bash + assert_link_exist "$BASH_IT/aliases/enabled/150---b.aliases.bash" + ln -s $BASH_IT/plugins/available/c.plugin.bash $BASH_IT/plugins/enabled/250---c.plugin.bash + assert_link_exist "$BASH_IT/plugins/enabled/250---c.plugin.bash" + + # The `test_alias` alias should not exist + run alias test_alias &> /dev/null + assert_failure + + load "$BASH_IT/bash_it.sh" + + run alias test_alias &> /dev/null + assert_success + assert_line -n 0 "alias test_alias='c'" +} + +@test "bash-it: load aliases, plugins and completions in priority order" { + mkdir -p $BASH_IT/aliases/enabled + mkdir -p $BASH_IT/plugins/enabled + mkdir -p $BASH_IT/completion/enabled + + ln -s $BASH_IT/plugins/available/base.plugin.bash $BASH_IT/plugins/enabled/250---base.plugin.bash + assert_link_exist "$BASH_IT/plugins/enabled/250---base.plugin.bash" + + ln -s $BASH_IT/aliases/available/a.aliases.bash $BASH_IT/aliases/enabled/150---a.aliases.bash + assert_link_exist "$BASH_IT/aliases/enabled/150---a.aliases.bash" + ln -s $BASH_IT/aliases/available/b.aliases.bash $BASH_IT/completion/enabled/350---b.completion.bash + assert_link_exist "$BASH_IT/completion/enabled/350---b.completion.bash" + ln -s $BASH_IT/plugins/available/c.plugin.bash $BASH_IT/plugins/enabled/250---c.plugin.bash + assert_link_exist "$BASH_IT/plugins/enabled/250---c.plugin.bash" + + # The `test_alias` alias should not exist + run alias test_alias &> /dev/null + assert_failure + + load "$BASH_IT/bash_it.sh" + + run alias test_alias &> /dev/null + assert_success + # "b" wins since completions are loaded last in the old directory structure + assert_line -n 0 "alias test_alias='b'" +} + +@test "bash-it: load aliases, plugins and completions in priority order, even if the priority says otherwise" { + mkdir -p $BASH_IT/aliases/enabled + mkdir -p $BASH_IT/plugins/enabled + mkdir -p $BASH_IT/completion/enabled + + ln -s $BASH_IT/plugins/available/base.plugin.bash $BASH_IT/plugins/enabled/250---base.plugin.bash + assert_link_exist "$BASH_IT/plugins/enabled/250---base.plugin.bash" + + ln -s $BASH_IT/aliases/available/a.aliases.bash $BASH_IT/aliases/enabled/450---a.aliases.bash + assert_link_exist "$BASH_IT/aliases/enabled/450---a.aliases.bash" + ln -s $BASH_IT/aliases/available/b.aliases.bash $BASH_IT/completion/enabled/350---b.completion.bash + assert_link_exist "$BASH_IT/completion/enabled/350---b.completion.bash" + ln -s $BASH_IT/plugins/available/c.plugin.bash $BASH_IT/plugins/enabled/950---c.plugin.bash + assert_link_exist "$BASH_IT/plugins/enabled/950---c.plugin.bash" + + # The `test_alias` alias should not exist + run alias test_alias &> /dev/null + assert_failure + + load "$BASH_IT/bash_it.sh" + + run alias test_alias &> /dev/null + assert_success + # "b" wins since completions are loaded last in the old directory structure + assert_line -n 0 "alias test_alias='b'" +} + +@test "bash-it: load aliases and plugins in priority order, with one alias higher than plugins" { + mkdir -p $BASH_IT/aliases/enabled + mkdir -p $BASH_IT/plugins/enabled + + ln -s $BASH_IT/plugins/available/base.plugin.bash $BASH_IT/plugins/enabled/250---base.plugin.bash + assert_link_exist "$BASH_IT/plugins/enabled/250---base.plugin.bash" + + ln -s $BASH_IT/aliases/available/a.aliases.bash $BASH_IT/aliases/enabled/350---a.aliases.bash + assert_link_exist "$BASH_IT/aliases/enabled/350---a.aliases.bash" + ln -s $BASH_IT/aliases/available/b.aliases.bash $BASH_IT/aliases/enabled/150---b.aliases.bash + assert_link_exist "$BASH_IT/aliases/enabled/150---b.aliases.bash" + ln -s $BASH_IT/plugins/available/c.plugin.bash $BASH_IT/plugins/enabled/250---c.plugin.bash + assert_link_exist "$BASH_IT/plugins/enabled/250---c.plugin.bash" + + # The `test_alias` alias should not exist + run alias test_alias &> /dev/null + assert_failure + + load "$BASH_IT/bash_it.sh" + + run alias test_alias &> /dev/null + assert_success + # This will be c, loaded from the c plugin, since the individual directories + # are loaded one by one. + assert_line -n 0 "alias test_alias='c'" +} + +@test "bash-it: load global aliases in order" { + mkdir -p $BASH_IT/enabled + + ln -s $BASH_IT/plugins/available/base.plugin.bash $BASH_IT/enabled/250---base.plugin.bash + assert_link_exist "$BASH_IT/enabled/250---base.plugin.bash" + + ln -s $BASH_IT/aliases/available/a.aliases.bash $BASH_IT/enabled/150---a.aliases.bash + assert_link_exist "$BASH_IT/enabled/150---a.aliases.bash" + ln -s $BASH_IT/aliases/available/b.aliases.bash $BASH_IT/enabled/150---b.aliases.bash + assert_link_exist "$BASH_IT/enabled/150---b.aliases.bash" + + # The `test_alias` alias should not exist + run alias test_alias &> /dev/null + assert_failure + + load "$BASH_IT/bash_it.sh" + + run alias test_alias &> /dev/null + assert_success + assert_line -n 0 "alias test_alias='b'" +} + +@test "bash-it: load global aliases in priority order" { + mkdir -p $BASH_IT/enabled + + ln -s $BASH_IT/plugins/available/base.plugin.bash $BASH_IT/enabled/250---base.plugin.bash + assert_link_exist "$BASH_IT/enabled/250---base.plugin.bash" + + ln -s $BASH_IT/aliases/available/a.aliases.bash $BASH_IT/enabled/175---a.aliases.bash + assert_link_exist "$BASH_IT/enabled/175---a.aliases.bash" + ln -s $BASH_IT/aliases/available/b.aliases.bash $BASH_IT/enabled/150---b.aliases.bash + assert_link_exist "$BASH_IT/enabled/150---b.aliases.bash" + + # The `test_alias` alias should not exist + run alias test_alias &> /dev/null + assert_failure + + load "$BASH_IT/bash_it.sh" + + run alias test_alias &> /dev/null + assert_success + assert_line -n 0 "alias test_alias='a'" +} + +@test "bash-it: load global aliases and plugins in priority order" { + mkdir -p $BASH_IT/enabled + + ln -s $BASH_IT/plugins/available/base.plugin.bash $BASH_IT/enabled/250---base.plugin.bash + assert_link_exist "$BASH_IT/enabled/250---base.plugin.bash" + + ln -s $BASH_IT/aliases/available/a.aliases.bash $BASH_IT/enabled/150---a.aliases.bash + assert_link_exist "$BASH_IT/enabled/150---a.aliases.bash" + ln -s $BASH_IT/aliases/available/b.aliases.bash $BASH_IT/enabled/150---b.aliases.bash + assert_link_exist "$BASH_IT/enabled/150---b.aliases.bash" + ln -s $BASH_IT/plugins/available/c.plugin.bash $BASH_IT/enabled/250---c.plugin.bash + assert_link_exist "$BASH_IT/enabled/250---c.plugin.bash" + + # The `test_alias` alias should not exist + run alias test_alias &> /dev/null + assert_failure + + load "$BASH_IT/bash_it.sh" + + run alias test_alias &> /dev/null + assert_success + assert_line -n 0 "alias test_alias='c'" +} + +@test "bash-it: load global aliases and plugins in priority order, with one alias higher than plugins" { + mkdir -p $BASH_IT/enabled + + ln -s $BASH_IT/plugins/available/base.plugin.bash $BASH_IT/enabled/250---base.plugin.bash + assert_link_exist "$BASH_IT/enabled/250---base.plugin.bash" + + ln -s $BASH_IT/aliases/available/a.aliases.bash $BASH_IT/enabled/350---a.aliases.bash + assert_link_exist "$BASH_IT/enabled/350---a.aliases.bash" + ln -s $BASH_IT/aliases/available/b.aliases.bash $BASH_IT/enabled/150---b.aliases.bash + assert_link_exist "$BASH_IT/enabled/150---b.aliases.bash" + ln -s $BASH_IT/plugins/available/c.plugin.bash $BASH_IT/enabled/250---c.plugin.bash + assert_link_exist "$BASH_IT/enabled/250---c.plugin.bash" + + # The `test_alias` alias should not exist + run alias test_alias &> /dev/null + assert_failure + + load "$BASH_IT/bash_it.sh" + + run alias test_alias &> /dev/null + assert_success + # This will be a, loaded from the a aliases, since the global directory + # loads all component types at once + assert_line -n 0 "alias test_alias='a'" +} + +@test "bash-it: load global aliases and plugins in priority order, individual old directories are loaded later" { + mkdir -p $BASH_IT/enabled + mkdir -p $BASH_IT/aliases/enabled + + ln -s $BASH_IT/plugins/available/base.plugin.bash $BASH_IT/enabled/250---base.plugin.bash + assert_link_exist "$BASH_IT/enabled/250---base.plugin.bash" + + ln -s $BASH_IT/aliases/available/a.aliases.bash $BASH_IT/enabled/350---a.aliases.bash + assert_link_exist "$BASH_IT/enabled/350---a.aliases.bash" + ln -s $BASH_IT/aliases/available/b.aliases.bash $BASH_IT/enabled/150---b.aliases.bash + assert_link_exist "$BASH_IT/enabled/150---b.aliases.bash" + ln -s $BASH_IT/plugins/available/c.plugin.bash $BASH_IT/enabled/250---c.plugin.bash + assert_link_exist "$BASH_IT/enabled/250---c.plugin.bash" + # Add one file in the old directory structure + ln -s $BASH_IT/aliases/available/b.aliases.bash $BASH_IT/aliases/enabled/150---b.aliases.bash + assert_link_exist "$BASH_IT/aliases/enabled/150---b.aliases.bash" + + # The `test_alias` alias should not exist + run alias test_alias &> /dev/null + assert_failure + + load "$BASH_IT/bash_it.sh" + + run alias test_alias &> /dev/null + assert_success + # This will be "b", loaded from the b aliases in the individual directory, since + # the individual directories are loaded after the global one. + assert_line -n 0 "alias test_alias='b'" +} + +@test "bash-it: load enabled aliases from new structure, priority-based" { + mkdir -p $BASH_IT/enabled + ln -s $BASH_IT/aliases/available/atom.aliases.bash $BASH_IT/enabled/150---atom.aliases.bash + assert_link_exist "$BASH_IT/enabled/150---atom.aliases.bash" + ln -s $BASH_IT/plugins/available/base.plugin.bash $BASH_IT/enabled/250---base.plugin.bash + assert_link_exist "$BASH_IT/enabled/250---base.plugin.bash" + + # The `ah` alias should not exist + run alias ah &> /dev/null + assert_failure + + load "$BASH_IT/bash_it.sh" + + run alias ah &> /dev/null + assert_success +} + +@test "bash-it: load enabled aliases from old structure, priority-based" { + mkdir -p $BASH_IT/aliases/enabled + mkdir -p $BASH_IT/plugins/enabled + ln -s $BASH_IT/aliases/available/atom.aliases.bash $BASH_IT/aliases/enabled/150---atom.aliases.bash + assert_link_exist "$BASH_IT/aliases/enabled/150---atom.aliases.bash" + ln -s $BASH_IT/plugins/available/base.plugin.bash $BASH_IT/plugins/enabled/250---base.plugin.bash + assert_link_exist "$BASH_IT/plugins/enabled/250---base.plugin.bash" + + # The `ah` alias should not exist + run alias ah &> /dev/null + assert_failure + + load "$BASH_IT/bash_it.sh" + + run alias ah &> /dev/null + assert_success +} + +@test "bash-it: load enabled aliases from old structure, without priorities" { + mkdir -p $BASH_IT/aliases/enabled + mkdir -p $BASH_IT/plugins/enabled + ln -s $BASH_IT/aliases/available/atom.aliases.bash $BASH_IT/aliases/enabled/atom.aliases.bash + assert_link_exist "$BASH_IT/aliases/enabled/atom.aliases.bash" + ln -s $BASH_IT/plugins/available/base.plugin.bash $BASH_IT/plugins/enabled/base.plugin.bash + assert_link_exist "$BASH_IT/plugins/enabled/base.plugin.bash" + + # The `ah` alias should not exist + run alias ah &> /dev/null + assert_failure + + load "$BASH_IT/bash_it.sh" + + run alias ah &> /dev/null + assert_success +} diff --git a/test/completion/aliases.completion.bats b/test/completion/aliases.completion.bats index 83ae947a..60738f67 100644 --- a/test/completion/aliases.completion.bats +++ b/test/completion/aliases.completion.bats @@ -1,30 +1,30 @@ -# shellcheck shell=bats - -load "${MAIN_BASH_IT_DIR?}/test/test_helper.bash" - -function local_setup_file() { - setup_libs "helpers" - # Load something, anything... - load ../../completion/available/capistrano.completion -} - -@test "alias-completion: See that aliases with double quotes and brackets do not break the plugin" { - alias gtest="git log --graph --pretty=format:'%C(bold)%h%Creset%C(magenta)%d%Creset %s %C(yellow)<%an> %C(cyan)(%cr)%Creset' --abbrev-commit --date=relative" - run load "${BASH_IT?}/completion/available/aliases.completion.bash" - - assert_success -} - -@test "alias-completion: See that aliases with single quotes and brackets do not break the plugin" { - alias gtest='git log --graph --pretty=format:"%C(bold)%h%Creset%C(magenta)%d%Creset %s %C(yellow)<%an> %C(cyan)(%cr)%Creset" --abbrev-commit --date=relative' - run load "${BASH_IT?}/completion/available/aliases.completion.bash" - - assert_success -} - -@test "alias-completion: See that having aliased rm command does not output unnecessary output" { - alias rm='rm -v' - run load "${BASH_IT?}/completion/available/aliases.completion.bash" - - refute_output -} +# shellcheck shell=bats + +load "${MAIN_BASH_IT_DIR?}/test/test_helper.bash" + +function local_setup_file() { + setup_libs "helpers" + # Load something, anything... + load ../../completion/available/capistrano.completion +} + +@test "alias-completion: See that aliases with double quotes and brackets do not break the plugin" { + alias gtest="git log --graph --pretty=format:'%C(bold)%h%Creset%C(magenta)%d%Creset %s %C(yellow)<%an> %C(cyan)(%cr)%Creset' --abbrev-commit --date=relative" + run load "${BASH_IT?}/completion/available/aliases.completion.bash" + + assert_success +} + +@test "alias-completion: See that aliases with single quotes and brackets do not break the plugin" { + alias gtest='git log --graph --pretty=format:"%C(bold)%h%Creset%C(magenta)%d%Creset %s %C(yellow)<%an> %C(cyan)(%cr)%Creset" --abbrev-commit --date=relative' + run load "${BASH_IT?}/completion/available/aliases.completion.bash" + + assert_success +} + +@test "alias-completion: See that having aliased rm command does not output unnecessary output" { + alias rm='rm -v' + run load "${BASH_IT?}/completion/available/aliases.completion.bash" + + refute_output +} diff --git a/test/completion/bash-it.completion.bats b/test/completion/bash-it.completion.bats index 29d1dc94..6e555bbd 100755 --- a/test/completion/bash-it.completion.bats +++ b/test/completion/bash-it.completion.bats @@ -1,359 +1,360 @@ -# shellcheck shell=bats - -load "${MAIN_BASH_IT_DIR?}/test/test_helper.bash" - -function local_setup_file() { - setup_libs "helpers" - load "${BASH_IT?}/completion/available/bash-it.completion.bash" -} - -@test "completion bash-it: ensure that the _bash-it function is available" { - run type -t _bash-it - assert_success - assert_output "function" -} - -function __check_completion () { - # Get the parameters as a single value - COMP_LINE=$* - - # Get the parameters as an array - eval set -- "$@" - COMP_WORDS=("$@") - - # Index of the cursor in the line - COMP_POINT=${#COMP_LINE} - - # Get the last character of the line that was entered - COMP_LAST=$((${COMP_POINT} - 1)) - - # If the last character was a space... - if [[ ${COMP_LINE:$COMP_LAST} = ' ' ]]; then - # ...then add an empty array item - COMP_WORDS+=('') - fi - - # Word index of the last word - COMP_CWORD=$(( ${#COMP_WORDS[@]} - 1 )) - - # Run the Bash-it completion function - _bash-it - - # Return the completion output - echo "${COMPREPLY[@]}" -} - -@test "completion bash-it: doctor - show options" { - run __check_completion 'bash-it doctor ' - assert_line -n 0 "errors warnings all" -} - -@test "completion bash-it: help - show options" { - run __check_completion 'bash-it help ' - assert_line -n 0 "aliases completions migrate plugins update" -} - -@test "completion bash-it: help - aliases v" { - run __check_completion 'bash-it help aliases v' - assert_line -n 0 "vagrant vault vim" -} - -@test "completion bash-it: update - show options" { - run __check_completion 'bash-it update ' - assert_line -n 0 "stable dev" -} - -@test "completion bash-it: update - show optional flags" { - run __check_completion 'bash-it update -' - assert_line -n 0 "-s --silent" -} - -@test "completion bash-it: search - show no options" { - run __check_completion 'bash-it search ' - assert_line -n 0 "" -} - -@test "completion bash-it: migrate - show no options" { - run __check_completion 'bash-it migrate ' - assert_line -n 0 "" -} - -@test "completion bash-it: show options" { - run __check_completion 'bash-it ' - assert_line -n 0 "disable enable help migrate reload restart preview profile doctor search show update version" -} - -@test "completion bash-it: bash-ti - show options" { - run __check_completion 'bash-ti ' - assert_line -n 0 "disable enable help migrate reload restart preview profile doctor search show update version" -} - -@test "completion bash-it: shit - show options" { - run __check_completion 'shit ' - assert_line -n 0 "disable enable help migrate reload restart preview profile doctor search show update version" -} - -@test "completion bash-it: bashit - show options" { - run __check_completion 'bashit ' - assert_line -n 0 "disable enable help migrate reload restart preview profile doctor search show update version" -} - -@test "completion bash-it: batshit - show options" { - run __check_completion 'batshit ' - assert_line -n 0 "disable enable help migrate reload restart preview profile doctor search show update version" -} - -@test "completion bash-it: bash_it - show options" { - run __check_completion 'bash_it ' - assert_line -n 0 "disable enable help migrate reload restart preview profile doctor search show update version" -} - -@test "completion bash-it: profile - show options" { - run __check_completion 'bash-it profile ' - assert_line -n 0 "load save list rm" -} - -@test "completion bash-it: profile load - show options" { - run __check_completion 'bash-it profile load ' - assert_line -n 0 "default" -} - -@test "completion bash-it: show - show options" { - run __check_completion 'bash-it show ' - assert_line -n 0 "aliases completions plugins" -} - -@test "completion bash-it: enable - show options" { - run __check_completion 'bash-it enable ' - assert_line -n 0 "alias completion plugin" -} - -@test "completion bash-it: enable - show options a" { - run __check_completion 'bash-it enable a' - assert_line -n 0 "alias" -} - -@test "completion bash-it: disable - show options" { - run __check_completion 'bash-it disable ' - assert_line -n 0 "alias completion plugin" -} - -@test "completion bash-it: disable - show options a" { - run __check_completion 'bash-it disable a' - assert_line -n 0 "alias" -} - -@test "completion bash-it: disable - provide nothing when atom is not enabled" { - run __check_completion 'bash-it disable alias ato' - assert_line -n 0 "" -} - -@test "completion bash-it: disable - provide all when atom is not enabled" { - run __check_completion 'bash-it disable alias a' - assert_line -n 0 "all" -} - -@test "completion bash-it: disable - provide the a* aliases when atom is enabled with the old location and name" { - ln -s "$BASH_IT/aliases/available/atom.aliases.bash" "$BASH_IT/aliases/enabled/atom.aliases.bash" - assert_link_exist "$BASH_IT/aliases/enabled/atom.aliases.bash" - - ln -s "$BASH_IT/completion/available/apm.completion.bash" "$BASH_IT/completion/enabled/apm.completion.bash" - assert_link_exist "$BASH_IT/completion/enabled/apm.completion.bash" - - run __check_completion 'bash-it disable alias a' - assert_line -n 0 "all atom" -} - -@test "completion bash-it: disable - provide the a* aliases when atom is enabled with the old location and priority-based name" { - ln -s "$BASH_IT/aliases/available/atom.aliases.bash" "$BASH_IT/aliases/enabled/150---atom.aliases.bash" - assert_link_exist "$BASH_IT/aliases/enabled/150---atom.aliases.bash" - - ln -s "$BASH_IT/completion/available/apm.completion.bash" "$BASH_IT/completion/enabled/350---apm.completion.bash" - assert_link_exist "$BASH_IT/completion/enabled/350---apm.completion.bash" - - run __check_completion 'bash-it disable alias a' - assert_line -n 0 "all atom" -} - -@test "completion bash-it: disable - provide the a* aliases when atom is enabled with the new location and priority-based name" { - ln -s "$BASH_IT/aliases/available/atom.aliases.bash" "$BASH_IT/enabled/150---atom.aliases.bash" - assert_link_exist "$BASH_IT/enabled/150---atom.aliases.bash" - - ln -s "$BASH_IT/completion/available/apm.completion.bash" "$BASH_IT/enabled/350---apm.completion.bash" - assert_link_exist "$BASH_IT/enabled/350---apm.completion.bash" - - run __check_completion 'bash-it disable alias a' - assert_line -n 0 "all atom" -} - -@test "completion bash-it: disable - provide the docker-machine plugin when docker-machine is enabled with the old location and name" { - ln -s "$BASH_IT/aliases/available/docker-compose.aliases.bash" "$BASH_IT/aliases/enabled/docker-compose.aliases.bash" - assert_link_exist "$BASH_IT/aliases/enabled/docker-compose.aliases.bash" - - ln -s "$BASH_IT/plugins/available/docker-machine.plugin.bash" "$BASH_IT/plugins/enabled/docker-machine.plugin.bash" - assert_link_exist "$BASH_IT/plugins/enabled/docker-machine.plugin.bash" - - run __check_completion 'bash-it disable plugin docker' - assert_line -n 0 "docker-machine" -} - -@test "completion bash-it: disable - provide the docker-machine plugin when docker-machine is enabled with the old location and priority-based name" { - ln -s "$BASH_IT/aliases/available/docker-compose.aliases.bash" "$BASH_IT/aliases/enabled/150---docker-compose.aliases.bash" - assert_link_exist "$BASH_IT/aliases/enabled/150---docker-compose.aliases.bash" - - ln -s "$BASH_IT/plugins/available/docker-machine.plugin.bash" "$BASH_IT/plugins/enabled/350---docker-machine.plugin.bash" - assert_link_exist "$BASH_IT/plugins/enabled/350---docker-machine.plugin.bash" - - run __check_completion 'bash-it disable plugin docker' - assert_line -n 0 "docker-machine" -} - -@test "completion bash-it: disable - provide the docker-machine plugin when docker-machine is enabled with the new location and priority-based name" { - ln -s "$BASH_IT/aliases/available/docker-compose.aliases.bash" "$BASH_IT/enabled/150---docker-compose.aliases.bash" - assert_link_exist "$BASH_IT/enabled/150---docker-compose.aliases.bash" - - ln -s "$BASH_IT/plugins/available/docker-machine.plugin.bash" "$BASH_IT/enabled/350---docker-machine.plugin.bash" - assert_link_exist "$BASH_IT/enabled/350---docker-machine.plugin.bash" - - run __check_completion 'bash-it disable plugin docker' - assert_line -n 0 "docker-machine" -} - -@test "completion bash-it: disable - provide the todo.txt-cli aliases when todo plugin is enabled with the old location and name" { - ln -s "$BASH_IT/aliases/available/todo.txt-cli.aliases.bash" "$BASH_IT/aliases/enabled/todo.txt-cli.aliases.bash" - assert_link_exist "$BASH_IT/aliases/enabled/todo.txt-cli.aliases.bash" - - ln -s "$BASH_IT/plugins/available/todo.plugin.bash" "$BASH_IT/plugins/enabled/todo.plugin.bash" - assert_link_exist "$BASH_IT/plugins/enabled/todo.plugin.bash" - - run __check_completion 'bash-it disable alias to' - assert_line -n 0 "todo.txt-cli" -} - -@test "completion bash-it: disable - provide the todo.txt-cli aliases when todo plugin is enabled with the old location and priority-based name" { - ln -s "$BASH_IT/aliases/available/todo.txt-cli.aliases.bash" "$BASH_IT/aliases/enabled/150---todo.txt-cli.aliases.bash" - assert_link_exist "$BASH_IT/aliases/enabled/150---todo.txt-cli.aliases.bash" - - ln -s "$BASH_IT/plugins/available/todo.plugin.bash" "$BASH_IT/plugins/enabled/350---todo.plugin.bash" - assert_link_exist "$BASH_IT/plugins/enabled/350---todo.plugin.bash" - - run __check_completion 'bash-it disable alias to' - assert_line -n 0 "todo.txt-cli" -} - -@test "completion bash-it: disable - provide the todo.txt-cli aliases when todo plugin is enabled with the new location and priority-based name" { - ln -s "$BASH_IT/aliases/available/todo.txt-cli.aliases.bash" "$BASH_IT/enabled/150---todo.txt-cli.aliases.bash" - assert_link_exist "$BASH_IT/enabled/150---todo.txt-cli.aliases.bash" - - ln -s "$BASH_IT/plugins/available/todo.plugin.bash" "$BASH_IT/enabled/350---todo.plugin.bash" - assert_link_exist "$BASH_IT/enabled/350---todo.plugin.bash" - - run __check_completion 'bash-it disable alias to' - assert_line -n 0 "todo.txt-cli" -} - -@test "completion bash-it: enable - provide the atom aliases when not enabled" { - run __check_completion 'bash-it enable alias ato' - assert_line -n 0 "atom" -} - -@test "completion bash-it: enable - provide the a* aliases when not enabled" { - run __check_completion 'bash-it enable alias a' - assert_line -n 0 "all ag ansible apt atom" -} - -@test "completion bash-it: enable - provide the a* aliases when atom is enabled with the old location and name" { - ln -s "$BASH_IT/aliases/available/atom.aliases.bash" "$BASH_IT/aliases/enabled/atom.aliases.bash" - assert_link_exist "$BASH_IT/aliases/enabled/atom.aliases.bash" - - run __check_completion 'bash-it enable alias a' - assert_line -n 0 "all ag ansible apt" -} - -@test "completion bash-it: enable - provide the a* aliases when atom is enabled with the old location and priority-based name" { - ln -s "$BASH_IT/aliases/available/atom.aliases.bash" "$BASH_IT/aliases/enabled/150---atom.aliases.bash" - assert_link_exist "$BASH_IT/aliases/enabled/150---atom.aliases.bash" - - run __check_completion 'bash-it enable alias a' - assert_line -n 0 "all ag ansible apt" -} - -@test "completion bash-it: enable - provide the a* aliases when atom is enabled with the new location and priority-based name" { - ln -s "$BASH_IT/aliases/available/atom.aliases.bash" "$BASH_IT/enabled/150---atom.aliases.bash" - assert_link_exist "$BASH_IT/enabled/150---atom.aliases.bash" - - run __check_completion 'bash-it enable alias a' - assert_line -n 0 "all ag ansible apt" -} - -@test "completion bash-it: enable - provide the docker* plugins when docker-compose is enabled with the old location and name" { - ln -s "$BASH_IT/aliases/available/docker-compose.aliases.bash" "$BASH_IT/aliases/enabled/docker-compose.aliases.bash" - assert_link_exist "$BASH_IT/aliases/enabled/docker-compose.aliases.bash" - - run __check_completion 'bash-it enable plugin docker' - assert_line -n 0 "docker docker-compose docker-machine" -} - -@test "completion bash-it: enable - provide the docker-* plugins when docker-compose is enabled with the old location and priority-based name" { - ln -s "$BASH_IT/aliases/available/docker-compose.aliases.bash" "$BASH_IT/aliases/enabled/150---docker-compose.aliases.bash" - assert_link_exist "$BASH_IT/aliases/enabled/150---docker-compose.aliases.bash" - - run __check_completion 'bash-it enable plugin docker' - assert_line -n 0 "docker docker-compose docker-machine" -} - -@test "completion bash-it: enable - provide the docker-* plugins when docker-compose is enabled with the new location and priority-based name" { - ln -s "$BASH_IT/aliases/available/docker-compose.aliases.bash" "$BASH_IT/enabled/150---docker-compose.aliases.bash" - assert_link_exist "$BASH_IT/enabled/150---docker-compose.aliases.bash" - - run __check_completion 'bash-it enable plugin docker' - assert_line -n 0 "docker docker-compose docker-machine" -} - -@test "completion bash-it: enable - provide the docker* completions when docker-compose is enabled with the old location and name" { - ln -s "$BASH_IT/aliases/available/docker-compose.aliases.bash" "$BASH_IT/aliases/enabled/docker-compose.aliases.bash" - assert_link_exist "$BASH_IT/aliases/enabled/docker-compose.aliases.bash" - - run __check_completion 'bash-it enable completion docker' - assert_line -n 0 "docker docker-compose docker-machine" -} - -@test "completion bash-it: enable - provide the docker* completions when docker-compose is enabled with the old location and priority-based name" { - ln -s "$BASH_IT/aliases/available/docker-compose.aliases.bash" "$BASH_IT/aliases/enabled/150---docker-compose.aliases.bash" - assert_link_exist "$BASH_IT/aliases/enabled/150---docker-compose.aliases.bash" - - run __check_completion 'bash-it enable completion docker' - assert_line -n 0 "docker docker-compose docker-machine" -} - -@test "completion bash-it: enable - provide the docker* completions when docker-compose is enabled with the new location and priority-based name" { - ln -s "$BASH_IT/aliases/available/docker-compose.aliases.bash" "$BASH_IT/enabled/150---docker-compose.aliases.bash" - assert_link_exist "$BASH_IT/enabled/150---docker-compose.aliases.bash" - - run __check_completion 'bash-it enable completion docker' - assert_line -n 0 "docker docker-compose docker-machine" -} - -@test "completion bash-it: enable - provide the todo.txt-cli aliases when todo plugin is enabled with the old location and name" { - ln -s "$BASH_IT/plugins/available/todo.plugin.bash" "$BASH_IT/plugins/enabled/todo.plugin.bash" - assert_link_exist "$BASH_IT/plugins/enabled/todo.plugin.bash" - - run __check_completion 'bash-it enable alias to' - assert_line -n 0 "todo.txt-cli" -} - -@test "completion bash-it: enable - provide the todo.txt-cli aliases when todo plugin is enabled with the old location and priority-based name" { - ln -s "$BASH_IT/plugins/available/todo.plugin.bash" "$BASH_IT/plugins/enabled/350---todo.plugin.bash" - assert_link_exist "$BASH_IT/plugins/enabled/350---todo.plugin.bash" - - run __check_completion 'bash-it enable alias to' - assert_line -n 0 "todo.txt-cli" -} - -@test "completion bash-it: enable - provide the todo.txt-cli aliases when todo plugin is enabled with the new location and priority-based name" { - ln -s "$BASH_IT/plugins/available/todo.plugin.bash" "$BASH_IT/enabled/350---todo.plugin.bash" - assert_link_exist "$BASH_IT/enabled/350---todo.plugin.bash" - - run __check_completion 'bash-it enable alias to' - assert_line -n 0 "todo.txt-cli" -} +# shellcheck shell=bats + +load "${MAIN_BASH_IT_DIR?}/test/test_helper.bash" + +function local_setup_file() { + setup_libs "helpers" + load "${BASH_IT?}/completion/available/bash-it.completion.bash" +} + +@test "completion bash-it: ensure that the _bash-it function is available" { + run type -t _bash-it + assert_success + assert_output "function" +} + +function __check_completion () { + # Get the parameters as a single value + COMP_LINE=$* + + # Get the parameters as an array + eval set -- "$@" + COMP_WORDS=("$@") + + # Index of the cursor in the line + COMP_POINT=${#COMP_LINE} + + # Get the last character of the line that was entered + COMP_LAST=$((${COMP_POINT} - 1)) + + # If the last character was a space... + if [[ ${COMP_LINE:$COMP_LAST} = ' ' ]] + then + # ...then add an empty array item + COMP_WORDS+=('') + fi + + # Word index of the last word + COMP_CWORD=$(( ${#COMP_WORDS[@]} - 1 )) + + # Run the Bash-it completion function + _bash-it + + # Return the completion output + echo "${COMPREPLY[@]}" +} + +@test "completion bash-it: doctor - show options" { + run __check_completion 'bash-it doctor ' + assert_line -n 0 "errors warnings all" +} + +@test "completion bash-it: help - show options" { + run __check_completion 'bash-it help ' + assert_line -n 0 "aliases completions migrate plugins update" +} + +@test "completion bash-it: help - aliases v" { + run __check_completion 'bash-it help aliases v' + assert_line -n 0 "vagrant vault vim" +} + +@test "completion bash-it: update - show options" { + run __check_completion 'bash-it update ' + assert_line -n 0 "stable dev" +} + +@test "completion bash-it: update - show optional flags" { + run __check_completion 'bash-it update -' + assert_line -n 0 "-s --silent" +} + +@test "completion bash-it: search - show no options" { + run __check_completion 'bash-it search ' + assert_line -n 0 "" +} + +@test "completion bash-it: migrate - show no options" { + run __check_completion 'bash-it migrate ' + assert_line -n 0 "" +} + +@test "completion bash-it: show options" { + run __check_completion 'bash-it ' + assert_line -n 0 "disable enable help migrate reload restart preview profile doctor search show update version" +} + +@test "completion bash-it: bash-ti - show options" { + run __check_completion 'bash-ti ' + assert_line -n 0 "disable enable help migrate reload restart preview profile doctor search show update version" +} + +@test "completion bash-it: shit - show options" { + run __check_completion 'shit ' + assert_line -n 0 "disable enable help migrate reload restart preview profile doctor search show update version" +} + +@test "completion bash-it: bashit - show options" { + run __check_completion 'bashit ' + assert_line -n 0 "disable enable help migrate reload restart preview profile doctor search show update version" +} + +@test "completion bash-it: batshit - show options" { + run __check_completion 'batshit ' + assert_line -n 0 "disable enable help migrate reload restart preview profile doctor search show update version" +} + +@test "completion bash-it: bash_it - show options" { + run __check_completion 'bash_it ' + assert_line -n 0 "disable enable help migrate reload restart preview profile doctor search show update version" +} + +@test "completion bash-it: profile - show options" { + run __check_completion 'bash-it profile ' + assert_line -n 0 "load save list rm" +} + +@test "completion bash-it: profile load - show options" { + run __check_completion 'bash-it profile load ' + assert_line -n 0 "default" +} + +@test "completion bash-it: show - show options" { + run __check_completion 'bash-it show ' + assert_line -n 0 "aliases completions plugins" +} + +@test "completion bash-it: enable - show options" { + run __check_completion 'bash-it enable ' + assert_line -n 0 "alias completion plugin" +} + +@test "completion bash-it: enable - show options a" { + run __check_completion 'bash-it enable a' + assert_line -n 0 "alias" +} + +@test "completion bash-it: disable - show options" { + run __check_completion 'bash-it disable ' + assert_line -n 0 "alias completion plugin" +} + +@test "completion bash-it: disable - show options a" { + run __check_completion 'bash-it disable a' + assert_line -n 0 "alias" +} + +@test "completion bash-it: disable - provide nothing when atom is not enabled" { + run __check_completion 'bash-it disable alias ato' + assert_line -n 0 "" +} + +@test "completion bash-it: disable - provide all when atom is not enabled" { + run __check_completion 'bash-it disable alias a' + assert_line -n 0 "all" +} + +@test "completion bash-it: disable - provide the a* aliases when atom is enabled with the old location and name" { + ln -s "$BASH_IT/aliases/available/atom.aliases.bash" "$BASH_IT/aliases/enabled/atom.aliases.bash" + assert_link_exist "$BASH_IT/aliases/enabled/atom.aliases.bash" + + ln -s "$BASH_IT/completion/available/apm.completion.bash" "$BASH_IT/completion/enabled/apm.completion.bash" + assert_link_exist "$BASH_IT/completion/enabled/apm.completion.bash" + + run __check_completion 'bash-it disable alias a' + assert_line -n 0 "all atom" +} + +@test "completion bash-it: disable - provide the a* aliases when atom is enabled with the old location and priority-based name" { + ln -s "$BASH_IT/aliases/available/atom.aliases.bash" "$BASH_IT/aliases/enabled/150---atom.aliases.bash" + assert_link_exist "$BASH_IT/aliases/enabled/150---atom.aliases.bash" + + ln -s "$BASH_IT/completion/available/apm.completion.bash" "$BASH_IT/completion/enabled/350---apm.completion.bash" + assert_link_exist "$BASH_IT/completion/enabled/350---apm.completion.bash" + + run __check_completion 'bash-it disable alias a' + assert_line -n 0 "all atom" +} + +@test "completion bash-it: disable - provide the a* aliases when atom is enabled with the new location and priority-based name" { + ln -s "$BASH_IT/aliases/available/atom.aliases.bash" "$BASH_IT/enabled/150---atom.aliases.bash" + assert_link_exist "$BASH_IT/enabled/150---atom.aliases.bash" + + ln -s "$BASH_IT/completion/available/apm.completion.bash" "$BASH_IT/enabled/350---apm.completion.bash" + assert_link_exist "$BASH_IT/enabled/350---apm.completion.bash" + + run __check_completion 'bash-it disable alias a' + assert_line -n 0 "all atom" +} + +@test "completion bash-it: disable - provide the docker-machine plugin when docker-machine is enabled with the old location and name" { + ln -s "$BASH_IT/aliases/available/docker-compose.aliases.bash" "$BASH_IT/aliases/enabled/docker-compose.aliases.bash" + assert_link_exist "$BASH_IT/aliases/enabled/docker-compose.aliases.bash" + + ln -s "$BASH_IT/plugins/available/docker-machine.plugin.bash" "$BASH_IT/plugins/enabled/docker-machine.plugin.bash" + assert_link_exist "$BASH_IT/plugins/enabled/docker-machine.plugin.bash" + + run __check_completion 'bash-it disable plugin docker' + assert_line -n 0 "docker-machine" +} + +@test "completion bash-it: disable - provide the docker-machine plugin when docker-machine is enabled with the old location and priority-based name" { + ln -s "$BASH_IT/aliases/available/docker-compose.aliases.bash" "$BASH_IT/aliases/enabled/150---docker-compose.aliases.bash" + assert_link_exist "$BASH_IT/aliases/enabled/150---docker-compose.aliases.bash" + + ln -s "$BASH_IT/plugins/available/docker-machine.plugin.bash" "$BASH_IT/plugins/enabled/350---docker-machine.plugin.bash" + assert_link_exist "$BASH_IT/plugins/enabled/350---docker-machine.plugin.bash" + + run __check_completion 'bash-it disable plugin docker' + assert_line -n 0 "docker-machine" +} + +@test "completion bash-it: disable - provide the docker-machine plugin when docker-machine is enabled with the new location and priority-based name" { + ln -s "$BASH_IT/aliases/available/docker-compose.aliases.bash" "$BASH_IT/enabled/150---docker-compose.aliases.bash" + assert_link_exist "$BASH_IT/enabled/150---docker-compose.aliases.bash" + + ln -s "$BASH_IT/plugins/available/docker-machine.plugin.bash" "$BASH_IT/enabled/350---docker-machine.plugin.bash" + assert_link_exist "$BASH_IT/enabled/350---docker-machine.plugin.bash" + + run __check_completion 'bash-it disable plugin docker' + assert_line -n 0 "docker-machine" +} + +@test "completion bash-it: disable - provide the todo.txt-cli aliases when todo plugin is enabled with the old location and name" { + ln -s "$BASH_IT/aliases/available/todo.txt-cli.aliases.bash" "$BASH_IT/aliases/enabled/todo.txt-cli.aliases.bash" + assert_link_exist "$BASH_IT/aliases/enabled/todo.txt-cli.aliases.bash" + + ln -s "$BASH_IT/plugins/available/todo.plugin.bash" "$BASH_IT/plugins/enabled/todo.plugin.bash" + assert_link_exist "$BASH_IT/plugins/enabled/todo.plugin.bash" + + run __check_completion 'bash-it disable alias to' + assert_line -n 0 "todo.txt-cli" +} + +@test "completion bash-it: disable - provide the todo.txt-cli aliases when todo plugin is enabled with the old location and priority-based name" { + ln -s "$BASH_IT/aliases/available/todo.txt-cli.aliases.bash" "$BASH_IT/aliases/enabled/150---todo.txt-cli.aliases.bash" + assert_link_exist "$BASH_IT/aliases/enabled/150---todo.txt-cli.aliases.bash" + + ln -s "$BASH_IT/plugins/available/todo.plugin.bash" "$BASH_IT/plugins/enabled/350---todo.plugin.bash" + assert_link_exist "$BASH_IT/plugins/enabled/350---todo.plugin.bash" + + run __check_completion 'bash-it disable alias to' + assert_line -n 0 "todo.txt-cli" +} + +@test "completion bash-it: disable - provide the todo.txt-cli aliases when todo plugin is enabled with the new location and priority-based name" { + ln -s "$BASH_IT/aliases/available/todo.txt-cli.aliases.bash" "$BASH_IT/enabled/150---todo.txt-cli.aliases.bash" + assert_link_exist "$BASH_IT/enabled/150---todo.txt-cli.aliases.bash" + + ln -s "$BASH_IT/plugins/available/todo.plugin.bash" "$BASH_IT/enabled/350---todo.plugin.bash" + assert_link_exist "$BASH_IT/enabled/350---todo.plugin.bash" + + run __check_completion 'bash-it disable alias to' + assert_line -n 0 "todo.txt-cli" +} + +@test "completion bash-it: enable - provide the atom aliases when not enabled" { + run __check_completion 'bash-it enable alias ato' + assert_line -n 0 "atom" +} + +@test "completion bash-it: enable - provide the a* aliases when not enabled" { + run __check_completion 'bash-it enable alias a' + assert_line -n 0 "all ag ansible apt atom" +} + +@test "completion bash-it: enable - provide the a* aliases when atom is enabled with the old location and name" { + ln -s "$BASH_IT/aliases/available/atom.aliases.bash" "$BASH_IT/aliases/enabled/atom.aliases.bash" + assert_link_exist "$BASH_IT/aliases/enabled/atom.aliases.bash" + + run __check_completion 'bash-it enable alias a' + assert_line -n 0 "all ag ansible apt" +} + +@test "completion bash-it: enable - provide the a* aliases when atom is enabled with the old location and priority-based name" { + ln -s "$BASH_IT/aliases/available/atom.aliases.bash" "$BASH_IT/aliases/enabled/150---atom.aliases.bash" + assert_link_exist "$BASH_IT/aliases/enabled/150---atom.aliases.bash" + + run __check_completion 'bash-it enable alias a' + assert_line -n 0 "all ag ansible apt" +} + +@test "completion bash-it: enable - provide the a* aliases when atom is enabled with the new location and priority-based name" { + ln -s "$BASH_IT/aliases/available/atom.aliases.bash" "$BASH_IT/enabled/150---atom.aliases.bash" + assert_link_exist "$BASH_IT/enabled/150---atom.aliases.bash" + + run __check_completion 'bash-it enable alias a' + assert_line -n 0 "all ag ansible apt" +} + +@test "completion bash-it: enable - provide the docker* plugins when docker-compose is enabled with the old location and name" { + ln -s "$BASH_IT/aliases/available/docker-compose.aliases.bash" "$BASH_IT/aliases/enabled/docker-compose.aliases.bash" + assert_link_exist "$BASH_IT/aliases/enabled/docker-compose.aliases.bash" + + run __check_completion 'bash-it enable plugin docker' + assert_line -n 0 "docker docker-compose docker-machine" +} + +@test "completion bash-it: enable - provide the docker-* plugins when docker-compose is enabled with the old location and priority-based name" { + ln -s "$BASH_IT/aliases/available/docker-compose.aliases.bash" "$BASH_IT/aliases/enabled/150---docker-compose.aliases.bash" + assert_link_exist "$BASH_IT/aliases/enabled/150---docker-compose.aliases.bash" + + run __check_completion 'bash-it enable plugin docker' + assert_line -n 0 "docker docker-compose docker-machine" +} + +@test "completion bash-it: enable - provide the docker-* plugins when docker-compose is enabled with the new location and priority-based name" { + ln -s "$BASH_IT/aliases/available/docker-compose.aliases.bash" "$BASH_IT/enabled/150---docker-compose.aliases.bash" + assert_link_exist "$BASH_IT/enabled/150---docker-compose.aliases.bash" + + run __check_completion 'bash-it enable plugin docker' + assert_line -n 0 "docker docker-compose docker-machine" +} + +@test "completion bash-it: enable - provide the docker* completions when docker-compose is enabled with the old location and name" { + ln -s "$BASH_IT/aliases/available/docker-compose.aliases.bash" "$BASH_IT/aliases/enabled/docker-compose.aliases.bash" + assert_link_exist "$BASH_IT/aliases/enabled/docker-compose.aliases.bash" + + run __check_completion 'bash-it enable completion docker' + assert_line -n 0 "docker docker-compose docker-machine" +} + +@test "completion bash-it: enable - provide the docker* completions when docker-compose is enabled with the old location and priority-based name" { + ln -s "$BASH_IT/aliases/available/docker-compose.aliases.bash" "$BASH_IT/aliases/enabled/150---docker-compose.aliases.bash" + assert_link_exist "$BASH_IT/aliases/enabled/150---docker-compose.aliases.bash" + + run __check_completion 'bash-it enable completion docker' + assert_line -n 0 "docker docker-compose docker-machine" +} + +@test "completion bash-it: enable - provide the docker* completions when docker-compose is enabled with the new location and priority-based name" { + ln -s "$BASH_IT/aliases/available/docker-compose.aliases.bash" "$BASH_IT/enabled/150---docker-compose.aliases.bash" + assert_link_exist "$BASH_IT/enabled/150---docker-compose.aliases.bash" + + run __check_completion 'bash-it enable completion docker' + assert_line -n 0 "docker docker-compose docker-machine" +} + +@test "completion bash-it: enable - provide the todo.txt-cli aliases when todo plugin is enabled with the old location and name" { + ln -s "$BASH_IT/plugins/available/todo.plugin.bash" "$BASH_IT/plugins/enabled/todo.plugin.bash" + assert_link_exist "$BASH_IT/plugins/enabled/todo.plugin.bash" + + run __check_completion 'bash-it enable alias to' + assert_line -n 0 "todo.txt-cli" +} + +@test "completion bash-it: enable - provide the todo.txt-cli aliases when todo plugin is enabled with the old location and priority-based name" { + ln -s "$BASH_IT/plugins/available/todo.plugin.bash" "$BASH_IT/plugins/enabled/350---todo.plugin.bash" + assert_link_exist "$BASH_IT/plugins/enabled/350---todo.plugin.bash" + + run __check_completion 'bash-it enable alias to' + assert_line -n 0 "todo.txt-cli" +} + +@test "completion bash-it: enable - provide the todo.txt-cli aliases when todo plugin is enabled with the new location and priority-based name" { + ln -s "$BASH_IT/plugins/available/todo.plugin.bash" "$BASH_IT/enabled/350---todo.plugin.bash" + assert_link_exist "$BASH_IT/enabled/350---todo.plugin.bash" + + run __check_completion 'bash-it enable alias to' + assert_line -n 0 "todo.txt-cli" +} diff --git a/test/fixtures/bash_it/profiles/test-bad-component.bash_it b/test/fixtures/bash_it/profiles/test-bad-component.bash_it index 068c4b63..006b9e43 100644 --- a/test/fixtures/bash_it/profiles/test-bad-component.bash_it +++ b/test/fixtures/bash_it/profiles/test-bad-component.bash_it @@ -1,12 +1,12 @@ -# plugins -plugins base - -# completion -completion aliases -completion bash-it -completion system - -# aliases -aliases general -# Bad component -aliases bla +# plugins +plugins base + +# completion +completion aliases +completion bash-it +completion system + +# aliases +aliases general +# Bad component +aliases bla diff --git a/test/fixtures/bash_it/profiles/test-bad-type.bash_it b/test/fixtures/bash_it/profiles/test-bad-type.bash_it index 102c52ea..2cf83ba3 100644 --- a/test/fixtures/bash_it/profiles/test-bad-type.bash_it +++ b/test/fixtures/bash_it/profiles/test-bad-type.bash_it @@ -1,12 +1,12 @@ -# plugins -plugins base -# Bad type -compleetion aliases - -# completion -completion aliases -completion bash-it -completion system - -# aliases -aliases general +# plugins +plugins base +# Bad type +compleetion aliases + +# completion +completion aliases +completion bash-it +completion system + +# aliases +aliases general diff --git a/test/fixtures/svn/broken/svn b/test/fixtures/svn/broken/svn index c9f5235b..7916d766 100755 --- a/test/fixtures/svn/broken/svn +++ b/test/fixtures/svn/broken/svn @@ -1,4 +1,4 @@ -#!/usr/bin/env bash - -# Simply return an error code to simulate a broken SVN installation -exit 72 +#!/usr/bin/env bash + +# Simply return an error code to simulate a broken SVN installation +exit 72 diff --git a/test/fixtures/svn/working/svn b/test/fixtures/svn/working/svn index 910d01e7..01417c75 100755 --- a/test/fixtures/svn/working/svn +++ b/test/fixtures/svn/working/svn @@ -1,10 +1,11 @@ -#!/usr/bin/env bash - -# If the info command is called -# AND the parent folder contains the .svn folder -# THEN return the current path, similar to what `svn info` does -if [[ "$1" == "info" ]] && [[ -d "../.svn" ]]; then - echo "$PWD" -fi - -exit 0 +#!/usr/bin/env bash + +# If the info command is called +# AND the parent folder contains the .svn folder +# THEN return the current path, similar to what `svn info` does +if [[ "${1}" == "info" ]] && [[ -d "../.svn" ]] + then + echo "$PWD" +fi + +exit 0 diff --git a/test/install/install.bats b/test/install/install.bats index c9e1794c..b15e18e5 100644 --- a/test/install/install.bats +++ b/test/install/install.bats @@ -1,88 +1,88 @@ -# shellcheck shell=bats - -load "${MAIN_BASH_IT_DIR?}/test/test_helper.bash" - -function local_setup() { - export HOME="$BATS_TEST_TMPDIR" -} - -function local_setup_file() { - # Determine which config file to use based on OS. - case $OSTYPE in - darwin*) - export BASH_IT_CONFIG_FILE=.bash_profile - ;; - *) - export BASH_IT_CONFIG_FILE=.bashrc - ;; - esac - # don't load any libraries as the tests here test the *whole* kit -} - -@test "install: verify that the install script exists" { - assert_file_exist "$BASH_IT/install.sh" -} - -@test "install: run the install script silently" { - cd "$BASH_IT" - - ./install.sh --silent - - assert_file_exist "$HOME/$BASH_IT_CONFIG_FILE" - - assert_link_exist "$BASH_IT/enabled/150---general.aliases.bash" - assert_link_exist "$BASH_IT/enabled/250---base.plugin.bash" - assert_link_exist "$BASH_IT/enabled/800---aliases.completion.bash" - assert_link_exist "$BASH_IT/enabled/350---bash-it.completion.bash" - assert_link_exist "$BASH_IT/enabled/325---system.completion.bash" -} - -@test "install: verify that a backup file is created" { - cd "$BASH_IT" - - touch "$HOME/$BASH_IT_CONFIG_FILE" - echo "test file content" > "$HOME/$BASH_IT_CONFIG_FILE" - local md5_orig=$(md5sum "$HOME/$BASH_IT_CONFIG_FILE" | awk '{print $1}') - - ./install.sh --silent - - assert_file_exist "$HOME/$BASH_IT_CONFIG_FILE" - assert_file_exist "$HOME/$BASH_IT_CONFIG_FILE.bak" - - local md5_bak=$(md5sum "$HOME/$BASH_IT_CONFIG_FILE.bak" | awk '{print $1}') - - assert_equal "$md5_orig" "$md5_bak" -} - -@test "install: verify that silent and interactive can not be used at the same time" { - cd "$BASH_IT" - - run ./install.sh --silent --interactive - - assert_failure -} - -@test "install: verify that no-modify-config and append-to-config can not be used at the same time" { - cd "$BASH_IT" - - run ./install.sh --silent --no-modify-config --append-to-config - - assert_failure -} - -@test "install: verify that the template is appended" { - cd "$BASH_IT" - - touch "$HOME/$BASH_IT_CONFIG_FILE" - echo "test file content" > "$HOME/$BASH_IT_CONFIG_FILE" - - ./install.sh --silent --append-to-config - - assert_file_exist "$HOME/$BASH_IT_CONFIG_FILE" - assert_file_exist "$HOME/$BASH_IT_CONFIG_FILE.bak" - - run cat "$HOME/$BASH_IT_CONFIG_FILE" - - assert_line "test file content" - assert_line "source \"\$BASH_IT\"/bash_it.sh" -} +# shellcheck shell=bats + +load "${MAIN_BASH_IT_DIR?}/test/test_helper.bash" + +function local_setup() { + export HOME="$BATS_TEST_TMPDIR" +} + +function local_setup_file() { + # Determine which config file to use based on OS. + case $OSTYPE in + darwin*) + export BASH_IT_CONFIG_FILE=.bash_profile + ;; + *) + export BASH_IT_CONFIG_FILE=.bashrc + ;; + esac + # don't load any libraries as the tests here test the *whole* kit +} + +@test "install: verify that the install script exists" { + assert_file_exist "$BASH_IT/install.sh" +} + +@test "install: run the install script silently" { + cd "$BASH_IT" + + ./install.sh --silent + + assert_file_exist "$HOME/$BASH_IT_CONFIG_FILE" + + assert_link_exist "$BASH_IT/enabled/150---general.aliases.bash" + assert_link_exist "$BASH_IT/enabled/250---base.plugin.bash" + assert_link_exist "$BASH_IT/enabled/800---aliases.completion.bash" + assert_link_exist "$BASH_IT/enabled/350---bash-it.completion.bash" + assert_link_exist "$BASH_IT/enabled/325---system.completion.bash" +} + +@test "install: verify that a backup file is created" { + cd "$BASH_IT" + + touch "$HOME/$BASH_IT_CONFIG_FILE" + echo "test file content" > "$HOME/$BASH_IT_CONFIG_FILE" + local md5_orig=$(md5sum "$HOME/$BASH_IT_CONFIG_FILE" | awk '{print $1}') + + ./install.sh --silent + + assert_file_exist "$HOME/$BASH_IT_CONFIG_FILE" + assert_file_exist "$HOME/$BASH_IT_CONFIG_FILE.bak" + + local md5_bak=$(md5sum "$HOME/$BASH_IT_CONFIG_FILE.bak" | awk '{print $1}') + + assert_equal "$md5_orig" "$md5_bak" +} + +@test "install: verify that silent and interactive can not be used at the same time" { + cd "$BASH_IT" + + run ./install.sh --silent --interactive + + assert_failure +} + +@test "install: verify that no-modify-config and append-to-config can not be used at the same time" { + cd "$BASH_IT" + + run ./install.sh --silent --no-modify-config --append-to-config + + assert_failure +} + +@test "install: verify that the template is appended" { + cd "$BASH_IT" + + touch "$HOME/$BASH_IT_CONFIG_FILE" + echo "test file content" > "$HOME/$BASH_IT_CONFIG_FILE" + + ./install.sh --silent --append-to-config + + assert_file_exist "$HOME/$BASH_IT_CONFIG_FILE" + assert_file_exist "$HOME/$BASH_IT_CONFIG_FILE.bak" + + run cat "$HOME/$BASH_IT_CONFIG_FILE" + + assert_line "test file content" + assert_line "source \"\$BASH_IT\"/bash_it.sh" +} diff --git a/test/install/uninstall.bats b/test/install/uninstall.bats index ab71a775..e6e07684 100644 --- a/test/install/uninstall.bats +++ b/test/install/uninstall.bats @@ -1,61 +1,61 @@ -# shellcheck shell=bats - -load "${MAIN_BASH_IT_DIR?}/test/test_helper.bash" - -function local_setup() { - export HOME="$BATS_TEST_TMPDIR" -} - -function local_setup_file() { - # Determine which config file to use based on OS. - case $OSTYPE in - darwin*) - export BASH_IT_CONFIG_FILE=.bash_profile - ;; - *) - export BASH_IT_CONFIG_FILE=.bashrc - ;; - esac - # don't load any libraries as the tests here test the *whole* kit -} - -@test "uninstall: verify that the uninstall script exists" { - assert_file_exist "$BASH_IT/uninstall.sh" -} - -@test "uninstall: run the uninstall script with an existing backup file" { - cd "$BASH_IT" - - echo "test file content for backup" > "$HOME/$BASH_IT_CONFIG_FILE.bak" - echo "test file content for original file" > "$HOME/$BASH_IT_CONFIG_FILE" - local md5_bak=$(md5sum "$HOME/$BASH_IT_CONFIG_FILE.bak" | awk '{print $1}') - - run ./uninstall.sh - assert_success - - assert_file_not_exist "$HOME/$BASH_IT_CONFIG_FILE.uninstall" - assert_file_not_exist "$HOME/$BASH_IT_CONFIG_FILE.bak" - assert_file_exist "$HOME/$BASH_IT_CONFIG_FILE" - - local md5_conf=$(md5sum "$HOME/$BASH_IT_CONFIG_FILE" | awk '{print $1}') - - assert_equal "$md5_bak" "$md5_conf" -} - -@test "uninstall: run the uninstall script without an existing backup file" { - cd "$BASH_IT" - - echo "test file content for original file" > "$HOME/$BASH_IT_CONFIG_FILE" - local md5_orig=$(md5sum "$HOME/$BASH_IT_CONFIG_FILE" | awk '{print $1}') - - run ./uninstall.sh - assert_success - - assert_file_exist "$HOME/$BASH_IT_CONFIG_FILE.uninstall" - assert_file_not_exist "$HOME/$BASH_IT_CONFIG_FILE.bak" - assert_file_not_exist "$HOME/$BASH_IT_CONFIG_FILE" - - local md5_uninstall=$(md5sum "$HOME/$BASH_IT_CONFIG_FILE.uninstall" | awk '{print $1}') - - assert_equal "$md5_orig" "$md5_uninstall" -} +# shellcheck shell=bats + +load "${MAIN_BASH_IT_DIR?}/test/test_helper.bash" + +function local_setup() { + export HOME="$BATS_TEST_TMPDIR" +} + +function local_setup_file() { + # Determine which config file to use based on OS. + case $OSTYPE in + darwin*) + export BASH_IT_CONFIG_FILE=.bash_profile + ;; + *) + export BASH_IT_CONFIG_FILE=.bashrc + ;; + esac + # don't load any libraries as the tests here test the *whole* kit +} + +@test "uninstall: verify that the uninstall script exists" { + assert_file_exist "$BASH_IT/uninstall.sh" +} + +@test "uninstall: run the uninstall script with an existing backup file" { + cd "$BASH_IT" + + echo "test file content for backup" > "$HOME/$BASH_IT_CONFIG_FILE.bak" + echo "test file content for original file" > "$HOME/$BASH_IT_CONFIG_FILE" + local md5_bak=$(md5sum "$HOME/$BASH_IT_CONFIG_FILE.bak" | awk '{print $1}') + + run ./uninstall.sh + assert_success + + assert_file_not_exist "$HOME/$BASH_IT_CONFIG_FILE.uninstall" + assert_file_not_exist "$HOME/$BASH_IT_CONFIG_FILE.bak" + assert_file_exist "$HOME/$BASH_IT_CONFIG_FILE" + + local md5_conf=$(md5sum "$HOME/$BASH_IT_CONFIG_FILE" | awk '{print $1}') + + assert_equal "$md5_bak" "$md5_conf" +} + +@test "uninstall: run the uninstall script without an existing backup file" { + cd "$BASH_IT" + + echo "test file content for original file" > "$HOME/$BASH_IT_CONFIG_FILE" + local md5_orig=$(md5sum "$HOME/$BASH_IT_CONFIG_FILE" | awk '{print $1}') + + run ./uninstall.sh + assert_success + + assert_file_exist "$HOME/$BASH_IT_CONFIG_FILE.uninstall" + assert_file_not_exist "$HOME/$BASH_IT_CONFIG_FILE.bak" + assert_file_not_exist "$HOME/$BASH_IT_CONFIG_FILE" + + local md5_uninstall=$(md5sum "$HOME/$BASH_IT_CONFIG_FILE.uninstall" | awk '{print $1}') + + assert_equal "$md5_orig" "$md5_uninstall" +} diff --git a/test/lib/composure.bats b/test/lib/composure.bats index 01bfd967..25fbb18e 100644 --- a/test/lib/composure.bats +++ b/test/lib/composure.bats @@ -1,13 +1,13 @@ -# shellcheck shell=bats - -load "${MAIN_BASH_IT_DIR?}/test/test_helper.bash" - -function local_setup_file() { - true - # don't load any libraries as the tests here test the *whole* kit -} - -@test "lib composure: _composure_keywords()" { - run _composure_keywords - assert_output "about author example group param version" -} +# shellcheck shell=bats + +load "${MAIN_BASH_IT_DIR?}/test/test_helper.bash" + +function local_setup_file() { + true + # don't load any libraries as the tests here test the *whole* kit +} + +@test "lib composure: _composure_keywords()" { + run _composure_keywords + assert_output "about author example group param version" +} diff --git a/test/lib/helpers.bats b/test/lib/helpers.bats index 38a917fe..7e4593da 100644 --- a/test/lib/helpers.bats +++ b/test/lib/helpers.bats @@ -1,732 +1,733 @@ -# shellcheck shell=bats - -load "${MAIN_BASH_IT_DIR?}/test/test_helper.bash" - -function local_setup_file() { - setup_libs "colors" - load "${BASH_IT?}/plugins/available/base.plugin.bash" -} - -function local_setup() { - # Copy the test fixture to the Bash-it folder - cp -RP "$BASH_IT/test/fixtures/bash_it"/* "$BASH_IT/" -} - -# TODO Create global __is_enabled function -# TODO Create global __get_base_name function -# TODO Create global __get_enabled_name function -@test "bash-it: verify that the test fixture is available" { - assert_file_exist "$BASH_IT/profiles/test-bad-component.bash_it" - assert_file_exist "$BASH_IT/profiles/test-bad-type.bash_it" -} - -@test "helpers: _command_exists function exists" { - run type -a _command_exists &> /dev/null - assert_success -} - -@test "helpers: _command_exists function positive test ls" { - run _command_exists ls - assert_success -} - -@test "helpers: _command_exists function positive test bash-it" { - run _command_exists bash-it - assert_success -} - -@test "helpers: _command_exists function negative test" { - run _command_exists __addfkds_dfdsjdf - assert_failure -} - -@test "helpers: _binary_exists function exists" { - run type -a _binary_exists &> /dev/null - assert_success -} - -@test "helpers: _binary_exists function positive test ls" { - run _binary_exists ls - assert_success -} - -@test "helpers: _binary_exists function negative test function" { - run _binary_exists _binary_exists - assert_failure -} - -@test "helpers: _binary_exists function negative test" { - run _binary_exists __addfkds_dfdsjdf - assert_failure -} - -@test "helpers: bash-it help aliases ag" { - run bash-it help aliases "ag" - assert_line -n 0 "ag='ag --smart-case --pager=\"less -MIRFX'" -} - -@test "helpers: bash-it help aliases without any aliases enabled" { - run bash-it help aliases - assert_line -n 0 "" -} - -@test "helpers: bash-it help plugins" { - run bash-it help plugins - assert_line -n 1 "base:" -} - -@test "helpers: bash-it help list aliases without any aliases enabled" { - run _help-list-aliases "$BASH_IT/aliases/available/ag.aliases.bash" - assert_line -n 0 "ag:" -} - -@test "helpers: bash-it help list aliases with ag aliases enabled" { - ln -s $BASH_IT/aliases/available/ag.aliases.bash $BASH_IT/aliases/enabled/150---ag.aliases.bash - assert_link_exist "$BASH_IT/aliases/enabled/150---ag.aliases.bash" - - run _help-list-aliases "$BASH_IT/aliases/enabled/150---ag.aliases.bash" - assert_line -n 0 "ag:" -} - -@test "helpers: bash-it help list aliases with todo.txt-cli aliases enabled" { - ln -s $BASH_IT/aliases/available/todo.txt-cli.aliases.bash $BASH_IT/aliases/enabled/150---todo.txt-cli.aliases.bash - assert_link_exist "$BASH_IT/aliases/enabled/150---todo.txt-cli.aliases.bash" - - run _help-list-aliases "$BASH_IT/aliases/enabled/150---todo.txt-cli.aliases.bash" - assert_line -n 0 "todo.txt-cli:" -} - -@test "helpers: bash-it help list aliases with docker-compose aliases enabled" { - ln -s $BASH_IT/aliases/available/docker-compose.aliases.bash $BASH_IT/aliases/enabled/150---docker-compose.aliases.bash - assert_link_exist "$BASH_IT/aliases/enabled/150---docker-compose.aliases.bash" - - run _help-list-aliases "$BASH_IT/aliases/enabled/150---docker-compose.aliases.bash" - assert_line -n 0 "docker-compose:" -} - -@test "helpers: bash-it help list aliases with ag aliases enabled in global directory" { - ln -s $BASH_IT/aliases/available/ag.aliases.bash $BASH_IT/enabled/150---ag.aliases.bash - assert_link_exist "$BASH_IT/enabled/150---ag.aliases.bash" - - run _help-list-aliases "$BASH_IT/enabled/150---ag.aliases.bash" - assert_line -n 0 "ag:" -} - -@test "helpers: bash-it help aliases one alias enabled in the old directory" { - ln -s $BASH_IT/aliases/available/ag.aliases.bash $BASH_IT/aliases/enabled/150---ag.aliases.bash - assert_link_exist "$BASH_IT/aliases/enabled/150---ag.aliases.bash" - - run bash-it help aliases - assert_line -n 0 "ag:" -} - -@test "helpers: bash-it help aliases one alias enabled in global directory" { - run bash-it enable alias "ag" - assert_line -n 0 'ag enabled with priority 150.' - assert_link_exist "$BASH_IT/enabled/150---ag.aliases.bash" - - run bash-it enable plugin "aws" - assert_line -n 0 'aws enabled with priority 250.' - assert_link_exist "$BASH_IT/enabled/250---aws.plugin.bash" - - run bash-it help aliases - assert_line -n 0 "ag:" - assert_line -n 1 "ag='ag --smart-case --pager=\"less -MIRFX'" -} - -@test "helpers: enable the todo.txt-cli aliases through the bash-it function" { - run bash-it enable alias "todo.txt-cli" - assert_line -n 0 'todo.txt-cli enabled with priority 150.' - assert_link_exist "$BASH_IT/enabled/150---todo.txt-cli.aliases.bash" -} - -@test "helpers: enable the curl aliases" { - run _enable-alias "curl" - assert_line -n 0 'curl enabled with priority 150.' - assert_link_exist "$BASH_IT/enabled/150---curl.aliases.bash" -} - -@test "helpers: enable the apm completion through the bash-it function" { - run bash-it enable completion "apm" - assert_line -n 0 'apm enabled with priority 350.' - assert_link_exist "$BASH_IT/enabled/350---apm.completion.bash" -} - -@test "helpers: enable the brew completion" { - run _enable-completion "brew" - assert_line -n 0 'brew enabled with priority 375.' - assert_link_exist "$BASH_IT/enabled/375---brew.completion.bash" -} - -@test "helpers: enable the node plugin" { - run _enable-plugin "node" - assert_line -n 0 'node enabled with priority 250.' - assert_link_exist "$BASH_IT/enabled/250---node.plugin.bash" "../plugins/available/node.plugin.bash" -} - -@test "helpers: enable the node plugin through the bash-it function" { - run bash-it enable plugin "node" - assert_line -n 0 'node enabled with priority 250.' - assert_link_exist "$BASH_IT/enabled/250---node.plugin.bash" -} - -@test "helpers: enable the node and nvm plugins through the bash-it function" { - run bash-it enable plugin "node" "nvm" - assert_line -n 0 'node enabled with priority 250.' - assert_line -n 1 'nvm enabled with priority 225.' - assert_link_exist "$BASH_IT/enabled/250---node.plugin.bash" - assert_link_exist "$BASH_IT/enabled/225---nvm.plugin.bash" -} - -@test "helpers: enable the foo-unkown and nvm plugins through the bash-it function" { - run bash-it enable plugin "foo-unknown" "nvm" - assert_line -n 0 'sorry, foo-unknown does not appear to be an available plugin.' - assert_line -n 1 'nvm enabled with priority 225.' - assert_link_exist "$BASH_IT/enabled/225---nvm.plugin.bash" -} - -@test "helpers: enable the nvm plugin" { - run _enable-plugin "nvm" - assert_line -n 0 'nvm enabled with priority 225.' - assert_link_exist "$BASH_IT/enabled/225---nvm.plugin.bash" -} - -@test "helpers: enable an unknown plugin" { - run _enable-plugin "unknown-foo" - assert_line -n 0 'sorry, unknown-foo does not appear to be an available plugin.' - - # Check for both old an new structure - assert [ ! -L "$BASH_IT/plugins/enabled/250---unknown-foo.plugin.bash" ] - assert [ ! -L "$BASH_IT/plugins/enabled/unknown-foo.plugin.bash" ] - - assert [ ! -L "$BASH_IT/enabled/250---unknown-foo.plugin.bash" ] - assert [ ! -L "$BASH_IT/enabled/unknown-foo.plugin.bash" ] -} - -@test "helpers: enable an unknown plugin through the bash-it function" { - run bash-it enable plugin "unknown-foo" - echo "${lines[@]}" - assert_line -n 0 'sorry, unknown-foo does not appear to be an available plugin.' - - # Check for both old an new structure - assert [ ! -L "$BASH_IT/plugins/enabled/250---unknown-foo.plugin.bash" ] - assert [ ! -L "$BASH_IT/plugins/enabled/unknown-foo.plugin.bash" ] - - assert [ ! -L "$BASH_IT/enabled/250---unknown-foo.plugin.bash" ] - assert [ ! -L "$BASH_IT/enabled/unknown-foo.plugin.bash" ] -} - -@test "helpers: disable a plugin that is not enabled" { - run _disable-plugin "sdkman" - assert_line -n 0 'sorry, sdkman does not appear to be an enabled plugin.' -} - -@test "helpers: enable and disable the nvm plugin" { - run _enable-plugin "nvm" - assert_line -n 0 'nvm enabled with priority 225.' - assert_link_exist "$BASH_IT/enabled/225---nvm.plugin.bash" - assert [ ! -L "$BASH_IT/plugins/enabled/225---nvm.plugin.bash" ] - - run _disable-plugin "nvm" - assert_line -n 0 'nvm disabled.' - assert [ ! -L "$BASH_IT/enabled/225---nvm.plugin.bash" ] -} - -@test "helpers: disable the nvm plugin if it was enabled with a priority, but in the component-specific directory" { - ln -s $BASH_IT/plugins/available/nvm.plugin.bash $BASH_IT/plugins/enabled/225---nvm.plugin.bash - assert_link_exist "$BASH_IT/plugins/enabled/225---nvm.plugin.bash" - assert [ ! -L "$BASH_IT/enabled/225---nvm.plugin.bash" ] - - run _disable-plugin "nvm" - assert_line -n 0 'nvm disabled.' - assert [ ! -L "$BASH_IT/plugins/enabled/225---nvm.plugin.bash" ] - assert [ ! -L "$BASH_IT/enabled/225---nvm.plugin.bash" ] -} - -@test "helpers: disable the nvm plugin if it was enabled without a priority" { - ln -s $BASH_IT/plugins/available/nvm.plugin.bash $BASH_IT/plugins/enabled/nvm.plugin.bash - assert_link_exist "$BASH_IT/plugins/enabled/nvm.plugin.bash" - - run _disable-plugin "nvm" - assert_line -n 0 'nvm disabled.' - assert [ ! -L "$BASH_IT/plugins/enabled/nvm.plugin.bash" ] -} - -@test "helpers: enable the nvm plugin if it was enabled without a priority" { - ln -s $BASH_IT/plugins/available/nvm.plugin.bash $BASH_IT/plugins/enabled/nvm.plugin.bash - assert_link_exist "$BASH_IT/plugins/enabled/nvm.plugin.bash" - - run _enable-plugin "nvm" - assert_line -n 0 'nvm is already enabled.' - assert_link_exist "$BASH_IT/plugins/enabled/nvm.plugin.bash" - assert [ ! -L "$BASH_IT/plugins/enabled/225---nvm.plugin.bash" ] - assert [ ! -L "$BASH_IT/enabled/225---nvm.plugin.bash" ] -} - -@test "helpers: enable the nvm plugin if it was enabled with a priority, but in the component-specific directory" { - ln -s $BASH_IT/plugins/available/nvm.plugin.bash $BASH_IT/plugins/enabled/225---nvm.plugin.bash - assert_link_exist "$BASH_IT/plugins/enabled/225---nvm.plugin.bash" - - run _enable-plugin "nvm" - assert_line -n 0 'nvm is already enabled.' - assert [ ! -L "$BASH_IT/plugins/enabled/nvm.plugin.bash" ] - assert_link_exist "$BASH_IT/plugins/enabled/225---nvm.plugin.bash" - assert [ ! -L "$BASH_IT/enabled/225---nvm.plugin.bash" ] -} - -@test "helpers: enable the nvm plugin twice" { - run _enable-plugin "nvm" - assert_line -n 0 'nvm enabled with priority 225.' - assert_link_exist "$BASH_IT/enabled/225---nvm.plugin.bash" - - run _enable-plugin "nvm" - assert_line -n 0 'nvm is already enabled.' - assert_link_exist "$BASH_IT/enabled/225---nvm.plugin.bash" -} - -@test "helpers: profile load command sanity" { - run _bash-it-profile-load "default" - assert_success - - assert_link_exist "$BASH_IT/enabled/150---general.aliases.bash" - assert_link_exist "$BASH_IT/enabled/250---base.plugin.bash" - assert_link_exist "$BASH_IT/enabled/800---aliases.completion.bash" - assert_link_exist "$BASH_IT/enabled/350---bash-it.completion.bash" - assert_link_exist "$BASH_IT/enabled/325---system.completion.bash" -} - -@test "helpers: profile save command sanity" { - run _enable-plugin "nvm" - - run _bash-it-profile-save "test" - assert_line -n 0 "Saving plugins configuration..." - assert_line -n 1 "Saving completion configuration..." - assert_line -n 2 "Saving aliases configuration..." - assert_line -n 3 "All done!" - assert_file_exist "$BASH_IT/profiles/test.bash_it" -} - -@test "helpers: profile save creates valid file with only plugin enabled" { - run _enable-plugin "nvm" - - run _bash-it-profile-save "test" - run cat "$BASH_IT/profiles/test.bash_it" - assert_line -n 0 "# This file is auto generated by Bash-it. Do not edit manually!" - assert_line -n 1 "# plugins" - assert_line -n 2 "plugins nvm" -} - -@test "helpers: profile save creates valid file with only completion enabled" { - run _enable-completion "bash-it" - - run _bash-it-profile-save "test" - run cat "$BASH_IT/profiles/test.bash_it" - assert_line -n 0 "# This file is auto generated by Bash-it. Do not edit manually!" - assert_line -n 1 "# completion" - assert_line -n 2 "completion bash-it" -} - -@test "helpers: profile save creates valid file with only aliases enabled" { - run _enable-alias "general" - - run _bash-it-profile-save "test" - run cat "$BASH_IT/profiles/test.bash_it" - assert_line -n 0 "# This file is auto generated by Bash-it. Do not edit manually!" - assert_line -n 1 "# aliases" - assert_line -n 2 "aliases general" -} - -@test "helpers: profile edge case, empty configuration" { - run _bash-it-profile-save "test" - assert_line -n 3 "It seems like no configuration was enabled.." - assert_line -n 4 "Make sure to double check that this is the wanted behavior." - - run _enable-alias "general" - run _enable-plugin "base" - run _enable-plugin "alias-completion" - run _enable-completion "bash-it" - run _enable-completion "system" - - run _bash-it-profile-load "test" - assert_link_not_exist "$BASH_IT/enabled/150---general.aliases.bash" - assert_link_not_exist "$BASH_IT/enabled/250---base.plugin.bash" - assert_link_not_exist "$BASH_IT/enabled/800---aliases.completion.bash" - assert_link_not_exist "$BASH_IT/enabled/350---bash-it.completion.bash" - assert_link_not_exist "$BASH_IT/enabled/325---system.completion.bash" -} - -@test "helpers: profile save and load" { - run _enable-alias "general" - run _enable-plugin "base" - run _enable-plugin "alias-completion" - run _enable-completion "bash-it" - run _enable-completion "system" - - run _bash-it-profile-save "test" - assert_success - - run _disable-alias "general" - assert_link_not_exist "$BASH_IT/enabled/150---general.aliases.bash" - run _bash-it-profile-load "test" - assert_link_exist "$BASH_IT/enabled/150---general.aliases.bash" -} - -@test "helpers: profile load corrupted profile file: bad component" { - run _bash-it-profile-load "test-bad-component" - assert_line -n 1 -p "Bad line(#12) in profile, aborting load..." -} - -@test "helpers: profile load corrupted profile file: bad subdirectory" { - run _bash-it-profile-load "test-bad-type" - assert_line -n 1 -p "Bad line(#4) in profile, aborting load..." -} - -@test "helpers: profile rm sanity" { - run _bash-it-profile-save "test" - assert_file_exist "$BASH_IT/profiles/test.bash_it" - run _bash-it-profile-rm "test" - assert_line -n 0 "Removed profile 'test' successfully!" - assert_file_not_exist "$BASH_IT/profiles/test.bash_it" -} - -@test "helpers: profile rm no params" { - run _bash-it-profile-rm "" - assert_line -n 0 -p "Please specify profile name to remove..." -} - -@test "helpers: profile load no params" { - run _bash-it-profile-load "" - assert_line -n 0 -p "Please specify profile name to load, not changing configuration..." -} - -@test "helpers: profile rm default" { - run _bash-it-profile-rm "default" - assert_line -n 0 -p "Can not remove the default profile..." - assert_file_exist "$BASH_IT/profiles/default.bash_it" -} - -@test "helpers: profile rm bad profile name" { - run _bash-it-profile-rm "notexisting" - assert_line -n 0 -p "Could not find profile 'notexisting'..." -} - -@test "helpers: profile list sanity" { - run _bash-it-profile-list - assert_line -n 0 "Available profiles:" - assert_line -n 1 "default" -} - -@test "helpers: profile list more profiles" { - run _bash-it-profile-save "cactus" - run _bash-it-profile-save "another" - run _bash-it-profile-save "brother" - run _bash-it-profile-list - assert_line -n 0 "Available profiles:" - assert_line -n 4 "default" - assert_line -n 3 "cactus" - assert_line -n 1 "another" - assert_line -n 2 "brother" -} - -@test "helpers: migrate plugins and completions that share the same name" { - ln -s $BASH_IT/completion/available/dirs.completion.bash $BASH_IT/completion/enabled/350---dirs.completion.bash - assert_link_exist "$BASH_IT/completion/enabled/350---dirs.completion.bash" - - ln -s $BASH_IT/plugins/available/dirs.plugin.bash $BASH_IT/plugins/enabled/250---dirs.plugin.bash - assert_link_exist "$BASH_IT/plugins/enabled/250---dirs.plugin.bash" - - run _bash-it-migrate - assert_line -n 0 'Migrating plugin dirs.' - assert_line -n 1 'dirs disabled.' - assert_line -n 2 'dirs enabled with priority 250.' - assert_line -n 3 'Migrating completion dirs.' - assert_line -n 4 'dirs disabled.' - assert_line -n 5 'dirs enabled with priority 350.' - assert_line -n 6 'If any migration errors were reported, please try the following: reload && bash-it migrate' - - assert_link_exist "$BASH_IT/enabled/350---dirs.completion.bash" - assert_link_exist "$BASH_IT/enabled/250---dirs.plugin.bash" - assert [ ! -L "$BASH_IT/completion/enabled/350----dirs.completion.bash" ] - assert [ ! -L "$BASH_IT/plugins/enabled/250----dirs.plugin.bash" ] -} - -@test "helpers: migrate enabled plugins that don't use the new priority-based configuration" { - ln -s $BASH_IT/plugins/available/nvm.plugin.bash $BASH_IT/plugins/enabled/nvm.plugin.bash - assert_link_exist "$BASH_IT/plugins/enabled/nvm.plugin.bash" - - ln -s $BASH_IT/plugins/available/node.plugin.bash $BASH_IT/plugins/enabled/node.plugin.bash - assert_link_exist "$BASH_IT/plugins/enabled/node.plugin.bash" - - ln -s $BASH_IT/aliases/available/todo.txt-cli.aliases.bash $BASH_IT/aliases/enabled/todo.txt-cli.aliases.bash - assert_link_exist "$BASH_IT/aliases/enabled/todo.txt-cli.aliases.bash" - - run _enable-plugin "ssh" - assert_link_exist "$BASH_IT/enabled/250---ssh.plugin.bash" - - run _bash-it-migrate - assert_line -n 0 'Migrating alias todo.txt-cli.' - assert_line -n 1 'todo.txt-cli disabled.' - assert_line -n 2 'todo.txt-cli enabled with priority 150.' - - assert_link_exist "$BASH_IT/enabled/225---nvm.plugin.bash" - assert_link_exist "$BASH_IT/enabled/250---node.plugin.bash" - assert_link_exist "$BASH_IT/enabled/250---ssh.plugin.bash" - assert_link_exist "$BASH_IT/enabled/150---todo.txt-cli.aliases.bash" - assert [ ! -L "$BASH_IT/plugins/enabled/node.plugin.bash" ] - assert [ ! -L "$BASH_IT/plugins/enabled/nvm.plugin.bash" ] - assert [ ! -L "$BASH_IT/aliases/enabled/todo.txt-cli.aliases.bash" ] -} - -@test "helpers: migrate enabled plugins that use the new priority-based configuration in the individual directories" { - ln -s $BASH_IT/plugins/available/nvm.plugin.bash $BASH_IT/plugins/enabled/225---nvm.plugin.bash - assert_link_exist "$BASH_IT/plugins/enabled/225---nvm.plugin.bash" - - ln -s $BASH_IT/plugins/available/node.plugin.bash $BASH_IT/plugins/enabled/250---node.plugin.bash - assert_link_exist "$BASH_IT/plugins/enabled/250---node.plugin.bash" - - ln -s $BASH_IT/aliases/available/todo.txt-cli.aliases.bash $BASH_IT/aliases/enabled/250---todo.txt-cli.aliases.bash - assert_link_exist "$BASH_IT/aliases/enabled/250---todo.txt-cli.aliases.bash" - - run _enable-plugin "ssh" - assert_link_exist "$BASH_IT/enabled/250---ssh.plugin.bash" - - run _bash-it-migrate - assert_link_exist "$BASH_IT/enabled/225---nvm.plugin.bash" - assert_link_exist "$BASH_IT/enabled/250---node.plugin.bash" - assert_link_exist "$BASH_IT/enabled/250---ssh.plugin.bash" - assert_link_exist "$BASH_IT/enabled/150---todo.txt-cli.aliases.bash" - assert [ ! -L "$BASH_IT/plugins/enabled/225----node.plugin.bash" ] - assert [ ! -L "$BASH_IT/plugins/enabled/250----nvm.plugin.bash" ] - assert [ ! -L "$BASH_IT/aliases/enabled/250----todo.txt-cli.aliases.bash" ] -} - -@test "helpers: run the migrate command without anything to migrate and nothing enabled" { - run _bash-it-migrate -} - -@test "helpers: run the migrate command without anything to migrate" { - run _enable-plugin "ssh" - assert_link_exist "$BASH_IT/enabled/250---ssh.plugin.bash" - - run _bash-it-migrate - assert_link_exist "$BASH_IT/enabled/250---ssh.plugin.bash" -} - -function __migrate_all_components() { - subdirectory="$1" - one_type="$2" - priority="$3" - - for f in "${BASH_IT}/$subdirectory/available/"*.bash - do - to_enable=$(basename $f) - if [ -z "$priority" ]; then - ln -s "../available/$to_enable" "${BASH_IT}/${subdirectory}/enabled/$to_enable" - else - ln -s "../available/$to_enable" "${BASH_IT}/${subdirectory}/enabled/$priority---$to_enable" - fi - done - - ls ${BASH_IT}/${subdirectory}/enabled - - all_available=$(compgen -G "${BASH_IT}/${subdirectory}/available/*.$one_type.bash" | wc -l | xargs) - all_enabled_old=$(compgen -G "${BASH_IT}/${subdirectory}/enabled/*.$one_type.bash" | wc -l | xargs) - - assert_equal "$all_available" "$all_enabled_old" - - run bash-it migrate - - all_enabled_old_after=$(compgen -G "${BASH_IT}/${subdirectory}/enabled/*.$one_type.bash" | wc -l | xargs) - assert_equal "0" "$all_enabled_old_after" - - all_enabled_new_after=$(compgen -G "${BASH_IT}/enabled/*.$one_type.bash" | wc -l | xargs) - assert_equal "$all_enabled_old" "$all_enabled_new_after" -} - -@test "helpers: migrate all plugins" { - subdirectory="plugins" - one_type="plugin" - - __migrate_all_components "$subdirectory" "$one_type" -} - -@test "helpers: migrate all aliases" { - subdirectory="aliases" - one_type="aliases" - - __migrate_all_components "$subdirectory" "$one_type" -} - -@test "helpers: migrate all completions" { - subdirectory="completion" - one_type="completion" - - __migrate_all_components "$subdirectory" "$one_type" -} - -@test "helpers: migrate all plugins with previous priority" { - subdirectory="plugins" - one_type="plugin" - - __migrate_all_components "$subdirectory" "$one_type" "100" -} - -@test "helpers: migrate all aliases with previous priority" { - subdirectory="aliases" - one_type="aliases" - - __migrate_all_components "$subdirectory" "$one_type" "100" -} - -@test "helpers: migrate all completions with previous priority" { - subdirectory="completion" - one_type="completion" - - __migrate_all_components "$subdirectory" "$one_type" "100" -} - -@test "helpers: verify that existing components are automatically migrated when something is enabled" { - ln -s $BASH_IT/plugins/available/nvm.plugin.bash $BASH_IT/plugins/enabled/nvm.plugin.bash - assert_link_exist "$BASH_IT/plugins/enabled/nvm.plugin.bash" - - run bash-it enable plugin "node" - assert_line -n 0 'Migrating plugin nvm.' - assert_line -n 1 'nvm disabled.' - assert_line -n 2 'nvm enabled with priority 225.' - assert_line -n 3 'If any migration errors were reported, please try the following: reload && bash-it migrate' - assert_line -n 4 'node enabled with priority 250.' - assert [ ! -L "$BASH_IT/plugins/enabled/nvm.plugin.bash" ] - assert_link_exist "$BASH_IT/enabled/225---nvm.plugin.bash" - assert_link_exist "$BASH_IT/enabled/250---node.plugin.bash" -} - -@test "helpers: verify that existing components are automatically migrated when something is disabled" { - ln -s $BASH_IT/plugins/available/nvm.plugin.bash $BASH_IT/plugins/enabled/nvm.plugin.bash - assert_link_exist "$BASH_IT/plugins/enabled/nvm.plugin.bash" - ln -s $BASH_IT/plugins/available/node.plugin.bash $BASH_IT/plugins/enabled/250---node.plugin.bash - assert_link_exist "$BASH_IT/plugins/enabled/250---node.plugin.bash" - - run bash-it disable plugin "node" - assert_line -n 0 'Migrating plugin node.' - assert_line -n 1 'node disabled.' - assert_line -n 2 'node enabled with priority 250.' - assert_line -n 3 'Migrating plugin nvm.' - assert_line -n 4 'nvm disabled.' - assert_line -n 5 'nvm enabled with priority 225.' - assert_line -n 6 'If any migration errors were reported, please try the following: reload && bash-it migrate' - assert_line -n 7 'node disabled.' - assert [ ! -L "$BASH_IT/plugins/enabled/nvm.plugin.bash" ] - assert_link_exist "$BASH_IT/enabled/225---nvm.plugin.bash" - assert [ ! -L "$BASH_IT/plugins/enabled/250---node.plugin.bash" ] - assert [ ! -L "$BASH_IT/enabled/250---node.plugin.bash" ] -} - -@test "helpers: enable all plugins" { - run _enable-plugin "all" - local available=$(find $BASH_IT/plugins/available -name *.plugin.bash | wc -l | xargs) - local enabled=$(find $BASH_IT/enabled -name [0-9]*.plugin.bash | wc -l | xargs) - assert_equal "$available" "$enabled" -} - -@test "helpers: disable all plugins" { - run _enable-plugin "all" - local available=$(find $BASH_IT/plugins/available -name *.plugin.bash | wc -l | xargs) - local enabled=$(find $BASH_IT/enabled -name [0-9]*.plugin.bash | wc -l | xargs) - assert_equal "$available" "$enabled" - - run _enable-alias "ag" - assert_link_exist "$BASH_IT/enabled/150---ag.aliases.bash" - - run _disable-plugin "all" - local enabled2=$(find $BASH_IT/enabled -name [0-9]*.plugin.bash | wc -l | xargs) - assert_equal "0" "$enabled2" - assert_link_exist "$BASH_IT/enabled/150---ag.aliases.bash" -} - -@test "helpers: disable all plugins in the old directory structure" { - ln -s $BASH_IT/plugins/available/nvm.plugin.bash $BASH_IT/plugins/enabled/nvm.plugin.bash - assert_link_exist "$BASH_IT/plugins/enabled/nvm.plugin.bash" - - ln -s $BASH_IT/plugins/available/node.plugin.bash $BASH_IT/plugins/enabled/node.plugin.bash - assert_link_exist "$BASH_IT/plugins/enabled/node.plugin.bash" - - local enabled=$(find $BASH_IT/plugins/enabled -name *.plugin.bash | wc -l | xargs) - assert_equal "2" "$enabled" - - run _enable-alias "ag" - assert_link_exist "$BASH_IT/enabled/150---ag.aliases.bash" - - run _disable-plugin "all" - local enabled2=$(find $BASH_IT/plugins/enabled -name *.plugin.bash | wc -l | xargs) - assert_equal "0" "$enabled2" - assert_link_exist "$BASH_IT/enabled/150---ag.aliases.bash" -} - -@test "helpers: disable all plugins in the old directory structure with priority" { - ln -s $BASH_IT/plugins/available/nvm.plugin.bash $BASH_IT/plugins/enabled/250---nvm.plugin.bash - assert_link_exist "$BASH_IT/plugins/enabled/250---nvm.plugin.bash" - - ln -s $BASH_IT/plugins/available/node.plugin.bash $BASH_IT/plugins/enabled/250---node.plugin.bash - assert_link_exist "$BASH_IT/plugins/enabled/250---node.plugin.bash" - - local enabled=$(find $BASH_IT/plugins/enabled -name *.plugin.bash | wc -l | xargs) - assert_equal "2" "$enabled" - - run _enable-alias "ag" - assert_link_exist "$BASH_IT/enabled/150---ag.aliases.bash" - - run _disable-plugin "all" - local enabled2=$(find $BASH_IT/plugins/enabled -name *.plugin.bash | wc -l | xargs) - assert_equal "0" "$enabled2" - assert_link_exist "$BASH_IT/enabled/150---ag.aliases.bash" -} - -@test "helpers: disable all plugins without anything enabled" { - local enabled=$(find $BASH_IT/enabled -name [0-9]*.plugin.bash | wc -l | xargs) - assert_equal "0" "$enabled" - - run _enable-alias "ag" - assert_link_exist "$BASH_IT/enabled/150---ag.aliases.bash" - - run _disable-plugin "all" - local enabled2=$(find $BASH_IT/enabled -name [0-9]*.plugin.bash | wc -l | xargs) - assert_equal "0" "$enabled2" - assert_link_exist "$BASH_IT/enabled/150---ag.aliases.bash" -} - -@test "helpers: enable the ansible aliases through the bash-it function" { - run bash-it enable alias "ansible" - assert_line -n 0 'ansible enabled with priority 150.' - assert_link_exist "$BASH_IT/enabled/150---ansible.aliases.bash" -} - -@test "helpers: describe the nvm plugin without enabling it" { - _bash-it-plugins | grep "nvm" | grep "\[ \]" -} - -@test "helpers: describe the nvm plugin after enabling it" { - run _enable-plugin "nvm" - assert_line -n 0 'nvm enabled with priority 225.' - assert_link_exist "$BASH_IT/enabled/225---nvm.plugin.bash" - - _bash-it-plugins | grep "nvm" | grep "\[x\]" -} - -@test "helpers: describe the nvm plugin after enabling it in the old directory" { - ln -s $BASH_IT/plugins/available/nvm.plugin.bash $BASH_IT/plugins/enabled/nvm.plugin.bash - assert_link_exist "$BASH_IT/plugins/enabled/nvm.plugin.bash" - - _bash-it-plugins | grep "nvm" | grep "\[x\]" -} - -@test "helpers: describe the nvm plugin after enabling it in the old directory with priority" { - ln -s $BASH_IT/plugins/available/nvm.plugin.bash $BASH_IT/plugins/enabled/225---nvm.plugin.bash - assert_link_exist "$BASH_IT/plugins/enabled/225---nvm.plugin.bash" - - _bash-it-plugins | grep "nvm" | grep "\[x\]" -} - -@test "helpers: describe the todo.txt-cli aliases without enabling them" { - run _bash-it-aliases - assert_line "todo.txt-cli [ ] todo.txt-cli abbreviations" -} +# shellcheck shell=bats + +load "${MAIN_BASH_IT_DIR?}/test/test_helper.bash" + +function local_setup_file() { + setup_libs "colors" + load "${BASH_IT?}/plugins/available/base.plugin.bash" +} + +function local_setup() { + # Copy the test fixture to the Bash-it folder + cp -RP "$BASH_IT/test/fixtures/bash_it"/* "$BASH_IT/" +} + +# TODO Create global __is_enabled function +# TODO Create global __get_base_name function +# TODO Create global __get_enabled_name function +@test "bash-it: verify that the test fixture is available" { + assert_file_exist "$BASH_IT/profiles/test-bad-component.bash_it" + assert_file_exist "$BASH_IT/profiles/test-bad-type.bash_it" +} + +@test "helpers: _command_exists function exists" { + run type -a _command_exists &> /dev/null + assert_success +} + +@test "helpers: _command_exists function positive test ls" { + run _command_exists ls + assert_success +} + +@test "helpers: _command_exists function positive test bash-it" { + run _command_exists bash-it + assert_success +} + +@test "helpers: _command_exists function negative test" { + run _command_exists __addfkds_dfdsjdf + assert_failure +} + +@test "helpers: _binary_exists function exists" { + run type -a _binary_exists &> /dev/null + assert_success +} + +@test "helpers: _binary_exists function positive test ls" { + run _binary_exists ls + assert_success +} + +@test "helpers: _binary_exists function negative test function" { + run _binary_exists _binary_exists + assert_failure +} + +@test "helpers: _binary_exists function negative test" { + run _binary_exists __addfkds_dfdsjdf + assert_failure +} + +@test "helpers: bash-it help aliases ag" { + run bash-it help aliases "ag" + assert_line -n 0 "ag='ag --smart-case --pager=\"less -MIRFX'" +} + +@test "helpers: bash-it help aliases without any aliases enabled" { + run bash-it help aliases + assert_line -n 0 "" +} + +@test "helpers: bash-it help plugins" { + run bash-it help plugins + assert_line -n 1 "base:" +} + +@test "helpers: bash-it help list aliases without any aliases enabled" { + run _help-list-aliases "$BASH_IT/aliases/available/ag.aliases.bash" + assert_line -n 0 "ag:" +} + +@test "helpers: bash-it help list aliases with ag aliases enabled" { + ln -s $BASH_IT/aliases/available/ag.aliases.bash $BASH_IT/aliases/enabled/150---ag.aliases.bash + assert_link_exist "$BASH_IT/aliases/enabled/150---ag.aliases.bash" + + run _help-list-aliases "$BASH_IT/aliases/enabled/150---ag.aliases.bash" + assert_line -n 0 "ag:" +} + +@test "helpers: bash-it help list aliases with todo.txt-cli aliases enabled" { + ln -s $BASH_IT/aliases/available/todo.txt-cli.aliases.bash $BASH_IT/aliases/enabled/150---todo.txt-cli.aliases.bash + assert_link_exist "$BASH_IT/aliases/enabled/150---todo.txt-cli.aliases.bash" + + run _help-list-aliases "$BASH_IT/aliases/enabled/150---todo.txt-cli.aliases.bash" + assert_line -n 0 "todo.txt-cli:" +} + +@test "helpers: bash-it help list aliases with docker-compose aliases enabled" { + ln -s $BASH_IT/aliases/available/docker-compose.aliases.bash $BASH_IT/aliases/enabled/150---docker-compose.aliases.bash + assert_link_exist "$BASH_IT/aliases/enabled/150---docker-compose.aliases.bash" + + run _help-list-aliases "$BASH_IT/aliases/enabled/150---docker-compose.aliases.bash" + assert_line -n 0 "docker-compose:" +} + +@test "helpers: bash-it help list aliases with ag aliases enabled in global directory" { + ln -s $BASH_IT/aliases/available/ag.aliases.bash $BASH_IT/enabled/150---ag.aliases.bash + assert_link_exist "$BASH_IT/enabled/150---ag.aliases.bash" + + run _help-list-aliases "$BASH_IT/enabled/150---ag.aliases.bash" + assert_line -n 0 "ag:" +} + +@test "helpers: bash-it help aliases one alias enabled in the old directory" { + ln -s $BASH_IT/aliases/available/ag.aliases.bash $BASH_IT/aliases/enabled/150---ag.aliases.bash + assert_link_exist "$BASH_IT/aliases/enabled/150---ag.aliases.bash" + + run bash-it help aliases + assert_line -n 0 "ag:" +} + +@test "helpers: bash-it help aliases one alias enabled in global directory" { + run bash-it enable alias "ag" + assert_line -n 0 'ag enabled with priority 150.' + assert_link_exist "$BASH_IT/enabled/150---ag.aliases.bash" + + run bash-it enable plugin "aws" + assert_line -n 0 'aws enabled with priority 250.' + assert_link_exist "$BASH_IT/enabled/250---aws.plugin.bash" + + run bash-it help aliases + assert_line -n 0 "ag:" + assert_line -n 1 "ag='ag --smart-case --pager=\"less -MIRFX'" +} + +@test "helpers: enable the todo.txt-cli aliases through the bash-it function" { + run bash-it enable alias "todo.txt-cli" + assert_line -n 0 'todo.txt-cli enabled with priority 150.' + assert_link_exist "$BASH_IT/enabled/150---todo.txt-cli.aliases.bash" +} + +@test "helpers: enable the curl aliases" { + run _enable-alias "curl" + assert_line -n 0 'curl enabled with priority 150.' + assert_link_exist "$BASH_IT/enabled/150---curl.aliases.bash" +} + +@test "helpers: enable the apm completion through the bash-it function" { + run bash-it enable completion "apm" + assert_line -n 0 'apm enabled with priority 350.' + assert_link_exist "$BASH_IT/enabled/350---apm.completion.bash" +} + +@test "helpers: enable the brew completion" { + run _enable-completion "brew" + assert_line -n 0 'brew enabled with priority 375.' + assert_link_exist "$BASH_IT/enabled/375---brew.completion.bash" +} + +@test "helpers: enable the node plugin" { + run _enable-plugin "node" + assert_line -n 0 'node enabled with priority 250.' + assert_link_exist "$BASH_IT/enabled/250---node.plugin.bash" "../plugins/available/node.plugin.bash" +} + +@test "helpers: enable the node plugin through the bash-it function" { + run bash-it enable plugin "node" + assert_line -n 0 'node enabled with priority 250.' + assert_link_exist "$BASH_IT/enabled/250---node.plugin.bash" +} + +@test "helpers: enable the node and nvm plugins through the bash-it function" { + run bash-it enable plugin "node" "nvm" + assert_line -n 0 'node enabled with priority 250.' + assert_line -n 1 'nvm enabled with priority 225.' + assert_link_exist "$BASH_IT/enabled/250---node.plugin.bash" + assert_link_exist "$BASH_IT/enabled/225---nvm.plugin.bash" +} + +@test "helpers: enable the foo-unkown and nvm plugins through the bash-it function" { + run bash-it enable plugin "foo-unknown" "nvm" + assert_line -n 0 'sorry, foo-unknown does not appear to be an available plugin.' + assert_line -n 1 'nvm enabled with priority 225.' + assert_link_exist "$BASH_IT/enabled/225---nvm.plugin.bash" +} + +@test "helpers: enable the nvm plugin" { + run _enable-plugin "nvm" + assert_line -n 0 'nvm enabled with priority 225.' + assert_link_exist "$BASH_IT/enabled/225---nvm.plugin.bash" +} + +@test "helpers: enable an unknown plugin" { + run _enable-plugin "unknown-foo" + assert_line -n 0 'sorry, unknown-foo does not appear to be an available plugin.' + + # Check for both old an new structure + assert [ ! -L "$BASH_IT/plugins/enabled/250---unknown-foo.plugin.bash" ] + assert [ ! -L "$BASH_IT/plugins/enabled/unknown-foo.plugin.bash" ] + + assert [ ! -L "$BASH_IT/enabled/250---unknown-foo.plugin.bash" ] + assert [ ! -L "$BASH_IT/enabled/unknown-foo.plugin.bash" ] +} + +@test "helpers: enable an unknown plugin through the bash-it function" { + run bash-it enable plugin "unknown-foo" + echo "${lines[@]}" + assert_line -n 0 'sorry, unknown-foo does not appear to be an available plugin.' + + # Check for both old an new structure + assert [ ! -L "$BASH_IT/plugins/enabled/250---unknown-foo.plugin.bash" ] + assert [ ! -L "$BASH_IT/plugins/enabled/unknown-foo.plugin.bash" ] + + assert [ ! -L "$BASH_IT/enabled/250---unknown-foo.plugin.bash" ] + assert [ ! -L "$BASH_IT/enabled/unknown-foo.plugin.bash" ] +} + +@test "helpers: disable a plugin that is not enabled" { + run _disable-plugin "sdkman" + assert_line -n 0 'sorry, sdkman does not appear to be an enabled plugin.' +} + +@test "helpers: enable and disable the nvm plugin" { + run _enable-plugin "nvm" + assert_line -n 0 'nvm enabled with priority 225.' + assert_link_exist "$BASH_IT/enabled/225---nvm.plugin.bash" + assert [ ! -L "$BASH_IT/plugins/enabled/225---nvm.plugin.bash" ] + + run _disable-plugin "nvm" + assert_line -n 0 'nvm disabled.' + assert [ ! -L "$BASH_IT/enabled/225---nvm.plugin.bash" ] +} + +@test "helpers: disable the nvm plugin if it was enabled with a priority, but in the component-specific directory" { + ln -s $BASH_IT/plugins/available/nvm.plugin.bash $BASH_IT/plugins/enabled/225---nvm.plugin.bash + assert_link_exist "$BASH_IT/plugins/enabled/225---nvm.plugin.bash" + assert [ ! -L "$BASH_IT/enabled/225---nvm.plugin.bash" ] + + run _disable-plugin "nvm" + assert_line -n 0 'nvm disabled.' + assert [ ! -L "$BASH_IT/plugins/enabled/225---nvm.plugin.bash" ] + assert [ ! -L "$BASH_IT/enabled/225---nvm.plugin.bash" ] +} + +@test "helpers: disable the nvm plugin if it was enabled without a priority" { + ln -s $BASH_IT/plugins/available/nvm.plugin.bash $BASH_IT/plugins/enabled/nvm.plugin.bash + assert_link_exist "$BASH_IT/plugins/enabled/nvm.plugin.bash" + + run _disable-plugin "nvm" + assert_line -n 0 'nvm disabled.' + assert [ ! -L "$BASH_IT/plugins/enabled/nvm.plugin.bash" ] +} + +@test "helpers: enable the nvm plugin if it was enabled without a priority" { + ln -s $BASH_IT/plugins/available/nvm.plugin.bash $BASH_IT/plugins/enabled/nvm.plugin.bash + assert_link_exist "$BASH_IT/plugins/enabled/nvm.plugin.bash" + + run _enable-plugin "nvm" + assert_line -n 0 'nvm is already enabled.' + assert_link_exist "$BASH_IT/plugins/enabled/nvm.plugin.bash" + assert [ ! -L "$BASH_IT/plugins/enabled/225---nvm.plugin.bash" ] + assert [ ! -L "$BASH_IT/enabled/225---nvm.plugin.bash" ] +} + +@test "helpers: enable the nvm plugin if it was enabled with a priority, but in the component-specific directory" { + ln -s $BASH_IT/plugins/available/nvm.plugin.bash $BASH_IT/plugins/enabled/225---nvm.plugin.bash + assert_link_exist "$BASH_IT/plugins/enabled/225---nvm.plugin.bash" + + run _enable-plugin "nvm" + assert_line -n 0 'nvm is already enabled.' + assert [ ! -L "$BASH_IT/plugins/enabled/nvm.plugin.bash" ] + assert_link_exist "$BASH_IT/plugins/enabled/225---nvm.plugin.bash" + assert [ ! -L "$BASH_IT/enabled/225---nvm.plugin.bash" ] +} + +@test "helpers: enable the nvm plugin twice" { + run _enable-plugin "nvm" + assert_line -n 0 'nvm enabled with priority 225.' + assert_link_exist "$BASH_IT/enabled/225---nvm.plugin.bash" + + run _enable-plugin "nvm" + assert_line -n 0 'nvm is already enabled.' + assert_link_exist "$BASH_IT/enabled/225---nvm.plugin.bash" +} + +@test "helpers: profile load command sanity" { + run _bash-it-profile-load "default" + assert_success + + assert_link_exist "$BASH_IT/enabled/150---general.aliases.bash" + assert_link_exist "$BASH_IT/enabled/250---base.plugin.bash" + assert_link_exist "$BASH_IT/enabled/800---aliases.completion.bash" + assert_link_exist "$BASH_IT/enabled/350---bash-it.completion.bash" + assert_link_exist "$BASH_IT/enabled/325---system.completion.bash" +} + +@test "helpers: profile save command sanity" { + run _enable-plugin "nvm" + + run _bash-it-profile-save "test" + assert_line -n 0 "Saving plugins configuration..." + assert_line -n 1 "Saving completion configuration..." + assert_line -n 2 "Saving aliases configuration..." + assert_line -n 3 "All done!" + assert_file_exist "$BASH_IT/profiles/test.bash_it" +} + +@test "helpers: profile save creates valid file with only plugin enabled" { + run _enable-plugin "nvm" + + run _bash-it-profile-save "test" + run cat "$BASH_IT/profiles/test.bash_it" + assert_line -n 0 "# This file is auto generated by Bash-it. Do not edit manually!" + assert_line -n 1 "# plugins" + assert_line -n 2 "plugins nvm" +} + +@test "helpers: profile save creates valid file with only completion enabled" { + run _enable-completion "bash-it" + + run _bash-it-profile-save "test" + run cat "$BASH_IT/profiles/test.bash_it" + assert_line -n 0 "# This file is auto generated by Bash-it. Do not edit manually!" + assert_line -n 1 "# completion" + assert_line -n 2 "completion bash-it" +} + +@test "helpers: profile save creates valid file with only aliases enabled" { + run _enable-alias "general" + + run _bash-it-profile-save "test" + run cat "$BASH_IT/profiles/test.bash_it" + assert_line -n 0 "# This file is auto generated by Bash-it. Do not edit manually!" + assert_line -n 1 "# aliases" + assert_line -n 2 "aliases general" +} + +@test "helpers: profile edge case, empty configuration" { + run _bash-it-profile-save "test" + assert_line -n 3 "It seems like no configuration was enabled.." + assert_line -n 4 "Make sure to double check that this is the wanted behavior." + + run _enable-alias "general" + run _enable-plugin "base" + run _enable-plugin "alias-completion" + run _enable-completion "bash-it" + run _enable-completion "system" + + run _bash-it-profile-load "test" + assert_link_not_exist "$BASH_IT/enabled/150---general.aliases.bash" + assert_link_not_exist "$BASH_IT/enabled/250---base.plugin.bash" + assert_link_not_exist "$BASH_IT/enabled/800---aliases.completion.bash" + assert_link_not_exist "$BASH_IT/enabled/350---bash-it.completion.bash" + assert_link_not_exist "$BASH_IT/enabled/325---system.completion.bash" +} + +@test "helpers: profile save and load" { + run _enable-alias "general" + run _enable-plugin "base" + run _enable-plugin "alias-completion" + run _enable-completion "bash-it" + run _enable-completion "system" + + run _bash-it-profile-save "test" + assert_success + + run _disable-alias "general" + assert_link_not_exist "$BASH_IT/enabled/150---general.aliases.bash" + run _bash-it-profile-load "test" + assert_link_exist "$BASH_IT/enabled/150---general.aliases.bash" +} + +@test "helpers: profile load corrupted profile file: bad component" { + run _bash-it-profile-load "test-bad-component" + assert_line -n 1 -p "Bad line(#12) in profile, aborting load..." +} + +@test "helpers: profile load corrupted profile file: bad subdirectory" { + run _bash-it-profile-load "test-bad-type" + assert_line -n 1 -p "Bad line(#4) in profile, aborting load..." +} + +@test "helpers: profile rm sanity" { + run _bash-it-profile-save "test" + assert_file_exist "$BASH_IT/profiles/test.bash_it" + run _bash-it-profile-rm "test" + assert_line -n 0 "Removed profile 'test' successfully!" + assert_file_not_exist "$BASH_IT/profiles/test.bash_it" +} + +@test "helpers: profile rm no params" { + run _bash-it-profile-rm "" + assert_line -n 0 -p "Please specify profile name to remove..." +} + +@test "helpers: profile load no params" { + run _bash-it-profile-load "" + assert_line -n 0 -p "Please specify profile name to load, not changing configuration..." +} + +@test "helpers: profile rm default" { + run _bash-it-profile-rm "default" + assert_line -n 0 -p "Can not remove the default profile..." + assert_file_exist "$BASH_IT/profiles/default.bash_it" +} + +@test "helpers: profile rm bad profile name" { + run _bash-it-profile-rm "notexisting" + assert_line -n 0 -p "Could not find profile 'notexisting'..." +} + +@test "helpers: profile list sanity" { + run _bash-it-profile-list + assert_line -n 0 "Available profiles:" + assert_line -n 1 "default" +} + +@test "helpers: profile list more profiles" { + run _bash-it-profile-save "cactus" + run _bash-it-profile-save "another" + run _bash-it-profile-save "brother" + run _bash-it-profile-list + assert_line -n 0 "Available profiles:" + assert_line -n 4 "default" + assert_line -n 3 "cactus" + assert_line -n 1 "another" + assert_line -n 2 "brother" +} + +@test "helpers: migrate plugins and completions that share the same name" { + ln -s $BASH_IT/completion/available/dirs.completion.bash $BASH_IT/completion/enabled/350---dirs.completion.bash + assert_link_exist "$BASH_IT/completion/enabled/350---dirs.completion.bash" + + ln -s $BASH_IT/plugins/available/dirs.plugin.bash $BASH_IT/plugins/enabled/250---dirs.plugin.bash + assert_link_exist "$BASH_IT/plugins/enabled/250---dirs.plugin.bash" + + run _bash-it-migrate + assert_line -n 0 'Migrating plugin dirs.' + assert_line -n 1 'dirs disabled.' + assert_line -n 2 'dirs enabled with priority 250.' + assert_line -n 3 'Migrating completion dirs.' + assert_line -n 4 'dirs disabled.' + assert_line -n 5 'dirs enabled with priority 350.' + assert_line -n 6 'If any migration errors were reported, please try the following: reload && bash-it migrate' + + assert_link_exist "$BASH_IT/enabled/350---dirs.completion.bash" + assert_link_exist "$BASH_IT/enabled/250---dirs.plugin.bash" + assert [ ! -L "$BASH_IT/completion/enabled/350----dirs.completion.bash" ] + assert [ ! -L "$BASH_IT/plugins/enabled/250----dirs.plugin.bash" ] +} + +@test "helpers: migrate enabled plugins that don't use the new priority-based configuration" { + ln -s $BASH_IT/plugins/available/nvm.plugin.bash $BASH_IT/plugins/enabled/nvm.plugin.bash + assert_link_exist "$BASH_IT/plugins/enabled/nvm.plugin.bash" + + ln -s $BASH_IT/plugins/available/node.plugin.bash $BASH_IT/plugins/enabled/node.plugin.bash + assert_link_exist "$BASH_IT/plugins/enabled/node.plugin.bash" + + ln -s $BASH_IT/aliases/available/todo.txt-cli.aliases.bash $BASH_IT/aliases/enabled/todo.txt-cli.aliases.bash + assert_link_exist "$BASH_IT/aliases/enabled/todo.txt-cli.aliases.bash" + + run _enable-plugin "ssh" + assert_link_exist "$BASH_IT/enabled/250---ssh.plugin.bash" + + run _bash-it-migrate + assert_line -n 0 'Migrating alias todo.txt-cli.' + assert_line -n 1 'todo.txt-cli disabled.' + assert_line -n 2 'todo.txt-cli enabled with priority 150.' + + assert_link_exist "$BASH_IT/enabled/225---nvm.plugin.bash" + assert_link_exist "$BASH_IT/enabled/250---node.plugin.bash" + assert_link_exist "$BASH_IT/enabled/250---ssh.plugin.bash" + assert_link_exist "$BASH_IT/enabled/150---todo.txt-cli.aliases.bash" + assert [ ! -L "$BASH_IT/plugins/enabled/node.plugin.bash" ] + assert [ ! -L "$BASH_IT/plugins/enabled/nvm.plugin.bash" ] + assert [ ! -L "$BASH_IT/aliases/enabled/todo.txt-cli.aliases.bash" ] +} + +@test "helpers: migrate enabled plugins that use the new priority-based configuration in the individual directories" { + ln -s $BASH_IT/plugins/available/nvm.plugin.bash $BASH_IT/plugins/enabled/225---nvm.plugin.bash + assert_link_exist "$BASH_IT/plugins/enabled/225---nvm.plugin.bash" + + ln -s $BASH_IT/plugins/available/node.plugin.bash $BASH_IT/plugins/enabled/250---node.plugin.bash + assert_link_exist "$BASH_IT/plugins/enabled/250---node.plugin.bash" + + ln -s $BASH_IT/aliases/available/todo.txt-cli.aliases.bash $BASH_IT/aliases/enabled/250---todo.txt-cli.aliases.bash + assert_link_exist "$BASH_IT/aliases/enabled/250---todo.txt-cli.aliases.bash" + + run _enable-plugin "ssh" + assert_link_exist "$BASH_IT/enabled/250---ssh.plugin.bash" + + run _bash-it-migrate + assert_link_exist "$BASH_IT/enabled/225---nvm.plugin.bash" + assert_link_exist "$BASH_IT/enabled/250---node.plugin.bash" + assert_link_exist "$BASH_IT/enabled/250---ssh.plugin.bash" + assert_link_exist "$BASH_IT/enabled/150---todo.txt-cli.aliases.bash" + assert [ ! -L "$BASH_IT/plugins/enabled/225----node.plugin.bash" ] + assert [ ! -L "$BASH_IT/plugins/enabled/250----nvm.plugin.bash" ] + assert [ ! -L "$BASH_IT/aliases/enabled/250----todo.txt-cli.aliases.bash" ] +} + +@test "helpers: run the migrate command without anything to migrate and nothing enabled" { + run _bash-it-migrate +} + +@test "helpers: run the migrate command without anything to migrate" { + run _enable-plugin "ssh" + assert_link_exist "$BASH_IT/enabled/250---ssh.plugin.bash" + + run _bash-it-migrate + assert_link_exist "$BASH_IT/enabled/250---ssh.plugin.bash" +} + +function __migrate_all_components() { + subdirectory="${1}" + one_type="${2}" + priority="${3}" + + for f in "${BASH_IT}/$subdirectory/available/"*.bash + do + to_enable=$(basename $f) + if [ -z "$priority" ] + then + ln -s "../available/$to_enable" "${BASH_IT}/${subdirectory}/enabled/$to_enable" + else + ln -s "../available/$to_enable" "${BASH_IT}/${subdirectory}/enabled/$priority---$to_enable" + fi + done + + ls ${BASH_IT}/${subdirectory}/enabled + + all_available=$(compgen -G "${BASH_IT}/${subdirectory}/available/*.$one_type.bash" | wc -l | xargs) + all_enabled_old=$(compgen -G "${BASH_IT}/${subdirectory}/enabled/*.$one_type.bash" | wc -l | xargs) + + assert_equal "$all_available" "$all_enabled_old" + + run bash-it migrate + + all_enabled_old_after=$(compgen -G "${BASH_IT}/${subdirectory}/enabled/*.$one_type.bash" | wc -l | xargs) + assert_equal "0" "$all_enabled_old_after" + + all_enabled_new_after=$(compgen -G "${BASH_IT}/enabled/*.$one_type.bash" | wc -l | xargs) + assert_equal "$all_enabled_old" "$all_enabled_new_after" +} + +@test "helpers: migrate all plugins" { + subdirectory="plugins" + one_type="plugin" + + __migrate_all_components "$subdirectory" "$one_type" +} + +@test "helpers: migrate all aliases" { + subdirectory="aliases" + one_type="aliases" + + __migrate_all_components "$subdirectory" "$one_type" +} + +@test "helpers: migrate all completions" { + subdirectory="completion" + one_type="completion" + + __migrate_all_components "$subdirectory" "$one_type" +} + +@test "helpers: migrate all plugins with previous priority" { + subdirectory="plugins" + one_type="plugin" + + __migrate_all_components "$subdirectory" "$one_type" "100" +} + +@test "helpers: migrate all aliases with previous priority" { + subdirectory="aliases" + one_type="aliases" + + __migrate_all_components "$subdirectory" "$one_type" "100" +} + +@test "helpers: migrate all completions with previous priority" { + subdirectory="completion" + one_type="completion" + + __migrate_all_components "$subdirectory" "$one_type" "100" +} + +@test "helpers: verify that existing components are automatically migrated when something is enabled" { + ln -s $BASH_IT/plugins/available/nvm.plugin.bash $BASH_IT/plugins/enabled/nvm.plugin.bash + assert_link_exist "$BASH_IT/plugins/enabled/nvm.plugin.bash" + + run bash-it enable plugin "node" + assert_line -n 0 'Migrating plugin nvm.' + assert_line -n 1 'nvm disabled.' + assert_line -n 2 'nvm enabled with priority 225.' + assert_line -n 3 'If any migration errors were reported, please try the following: reload && bash-it migrate' + assert_line -n 4 'node enabled with priority 250.' + assert [ ! -L "$BASH_IT/plugins/enabled/nvm.plugin.bash" ] + assert_link_exist "$BASH_IT/enabled/225---nvm.plugin.bash" + assert_link_exist "$BASH_IT/enabled/250---node.plugin.bash" +} + +@test "helpers: verify that existing components are automatically migrated when something is disabled" { + ln -s $BASH_IT/plugins/available/nvm.plugin.bash $BASH_IT/plugins/enabled/nvm.plugin.bash + assert_link_exist "$BASH_IT/plugins/enabled/nvm.plugin.bash" + ln -s $BASH_IT/plugins/available/node.plugin.bash $BASH_IT/plugins/enabled/250---node.plugin.bash + assert_link_exist "$BASH_IT/plugins/enabled/250---node.plugin.bash" + + run bash-it disable plugin "node" + assert_line -n 0 'Migrating plugin node.' + assert_line -n 1 'node disabled.' + assert_line -n 2 'node enabled with priority 250.' + assert_line -n 3 'Migrating plugin nvm.' + assert_line -n 4 'nvm disabled.' + assert_line -n 5 'nvm enabled with priority 225.' + assert_line -n 6 'If any migration errors were reported, please try the following: reload && bash-it migrate' + assert_line -n 7 'node disabled.' + assert [ ! -L "$BASH_IT/plugins/enabled/nvm.plugin.bash" ] + assert_link_exist "$BASH_IT/enabled/225---nvm.plugin.bash" + assert [ ! -L "$BASH_IT/plugins/enabled/250---node.plugin.bash" ] + assert [ ! -L "$BASH_IT/enabled/250---node.plugin.bash" ] +} + +@test "helpers: enable all plugins" { + run _enable-plugin "all" + local available=$(find $BASH_IT/plugins/available -name *.plugin.bash | wc -l | xargs) + local enabled=$(find $BASH_IT/enabled -name [0-9]*.plugin.bash | wc -l | xargs) + assert_equal "$available" "$enabled" +} + +@test "helpers: disable all plugins" { + run _enable-plugin "all" + local available=$(find $BASH_IT/plugins/available -name *.plugin.bash | wc -l | xargs) + local enabled=$(find $BASH_IT/enabled -name [0-9]*.plugin.bash | wc -l | xargs) + assert_equal "$available" "$enabled" + + run _enable-alias "ag" + assert_link_exist "$BASH_IT/enabled/150---ag.aliases.bash" + + run _disable-plugin "all" + local enabled2=$(find $BASH_IT/enabled -name [0-9]*.plugin.bash | wc -l | xargs) + assert_equal "0" "$enabled2" + assert_link_exist "$BASH_IT/enabled/150---ag.aliases.bash" +} + +@test "helpers: disable all plugins in the old directory structure" { + ln -s $BASH_IT/plugins/available/nvm.plugin.bash $BASH_IT/plugins/enabled/nvm.plugin.bash + assert_link_exist "$BASH_IT/plugins/enabled/nvm.plugin.bash" + + ln -s $BASH_IT/plugins/available/node.plugin.bash $BASH_IT/plugins/enabled/node.plugin.bash + assert_link_exist "$BASH_IT/plugins/enabled/node.plugin.bash" + + local enabled=$(find $BASH_IT/plugins/enabled -name *.plugin.bash | wc -l | xargs) + assert_equal "2" "$enabled" + + run _enable-alias "ag" + assert_link_exist "$BASH_IT/enabled/150---ag.aliases.bash" + + run _disable-plugin "all" + local enabled2=$(find $BASH_IT/plugins/enabled -name *.plugin.bash | wc -l | xargs) + assert_equal "0" "$enabled2" + assert_link_exist "$BASH_IT/enabled/150---ag.aliases.bash" +} + +@test "helpers: disable all plugins in the old directory structure with priority" { + ln -s $BASH_IT/plugins/available/nvm.plugin.bash $BASH_IT/plugins/enabled/250---nvm.plugin.bash + assert_link_exist "$BASH_IT/plugins/enabled/250---nvm.plugin.bash" + + ln -s $BASH_IT/plugins/available/node.plugin.bash $BASH_IT/plugins/enabled/250---node.plugin.bash + assert_link_exist "$BASH_IT/plugins/enabled/250---node.plugin.bash" + + local enabled=$(find $BASH_IT/plugins/enabled -name *.plugin.bash | wc -l | xargs) + assert_equal "2" "$enabled" + + run _enable-alias "ag" + assert_link_exist "$BASH_IT/enabled/150---ag.aliases.bash" + + run _disable-plugin "all" + local enabled2=$(find $BASH_IT/plugins/enabled -name *.plugin.bash | wc -l | xargs) + assert_equal "0" "$enabled2" + assert_link_exist "$BASH_IT/enabled/150---ag.aliases.bash" +} + +@test "helpers: disable all plugins without anything enabled" { + local enabled=$(find $BASH_IT/enabled -name [0-9]*.plugin.bash | wc -l | xargs) + assert_equal "0" "$enabled" + + run _enable-alias "ag" + assert_link_exist "$BASH_IT/enabled/150---ag.aliases.bash" + + run _disable-plugin "all" + local enabled2=$(find $BASH_IT/enabled -name [0-9]*.plugin.bash | wc -l | xargs) + assert_equal "0" "$enabled2" + assert_link_exist "$BASH_IT/enabled/150---ag.aliases.bash" +} + +@test "helpers: enable the ansible aliases through the bash-it function" { + run bash-it enable alias "ansible" + assert_line -n 0 'ansible enabled with priority 150.' + assert_link_exist "$BASH_IT/enabled/150---ansible.aliases.bash" +} + +@test "helpers: describe the nvm plugin without enabling it" { + _bash-it-plugins | grep "nvm" | grep "\[ \]" +} + +@test "helpers: describe the nvm plugin after enabling it" { + run _enable-plugin "nvm" + assert_line -n 0 'nvm enabled with priority 225.' + assert_link_exist "$BASH_IT/enabled/225---nvm.plugin.bash" + + _bash-it-plugins | grep "nvm" | grep "\[x\]" +} + +@test "helpers: describe the nvm plugin after enabling it in the old directory" { + ln -s $BASH_IT/plugins/available/nvm.plugin.bash $BASH_IT/plugins/enabled/nvm.plugin.bash + assert_link_exist "$BASH_IT/plugins/enabled/nvm.plugin.bash" + + _bash-it-plugins | grep "nvm" | grep "\[x\]" +} + +@test "helpers: describe the nvm plugin after enabling it in the old directory with priority" { + ln -s $BASH_IT/plugins/available/nvm.plugin.bash $BASH_IT/plugins/enabled/225---nvm.plugin.bash + assert_link_exist "$BASH_IT/plugins/enabled/225---nvm.plugin.bash" + + _bash-it-plugins | grep "nvm" | grep "\[x\]" +} + +@test "helpers: describe the todo.txt-cli aliases without enabling them" { + run _bash-it-aliases + assert_line "todo.txt-cli [ ] todo.txt-cli abbreviations" +} diff --git a/test/lib/log.bats b/test/lib/log.bats index 7d868fd6..91ec281f 100644 --- a/test/lib/log.bats +++ b/test/lib/log.bats @@ -1,84 +1,84 @@ -# shellcheck shell=bats - -load "${MAIN_BASH_IT_DIR?}/test/test_helper.bash" - -function local_setup_file() { - setup_libs "log" -} - -@test "lib log: basic debug logging with BASH_IT_LOG_LEVEL_ALL" { - BASH_IT_LOG_LEVEL=$BASH_IT_LOG_LEVEL_ALL - run _log_debug "test test test" - assert_output "DEBUG: default: test test test" -} - -@test "lib log: basic warning logging with BASH_IT_LOG_LEVEL_ALL" { - BASH_IT_LOG_LEVEL=$BASH_IT_LOG_LEVEL_ALL - run _log_warning "test test test" - assert_output " WARN: default: test test test" -} - -@test "lib log: basic error logging with BASH_IT_LOG_LEVEL_ALL" { - BASH_IT_LOG_LEVEL=$BASH_IT_LOG_LEVEL_ALL - run _log_error "test test test" - assert_output "ERROR: default: test test test" -} - -@test "lib log: basic debug logging with BASH_IT_LOG_LEVEL_WARNING" { - BASH_IT_LOG_LEVEL=$BASH_IT_LOG_LEVEL_WARNING - run _log_debug "test test test" - refute_output -} - -@test "lib log: basic warning logging with BASH_IT_LOG_LEVEL_WARNING" { - BASH_IT_LOG_LEVEL=$BASH_IT_LOG_LEVEL_WARNING - run _log_warning "test test test" - assert_output " WARN: default: test test test" -} - -@test "lib log: basic error logging with BASH_IT_LOG_LEVEL_WARNING" { - BASH_IT_LOG_LEVEL=$BASH_IT_LOG_LEVEL_WARNING - run _log_error "test test test" - assert_output "ERROR: default: test test test" -} - - -@test "lib log: basic debug logging with BASH_IT_LOG_LEVEL_ERROR" { - BASH_IT_LOG_LEVEL=$BASH_IT_LOG_LEVEL_ERROR - run _log_debug "test test test" - refute_output -} - -@test "lib log: basic warning logging with BASH_IT_LOG_LEVEL_ERROR" { - BASH_IT_LOG_LEVEL=$BASH_IT_LOG_LEVEL_ERROR - run _log_warning "test test test" - refute_output -} - -@test "lib log: basic error logging with BASH_IT_LOG_LEVEL_ERROR" { - BASH_IT_LOG_LEVEL=$BASH_IT_LOG_LEVEL_ERROR - run _log_error "test test test" - assert_output "ERROR: default: test test test" -} - -@test "lib log: basic debug silent logging" { - run _log_debug "test test test" - refute_output -} - -@test "lib log: basic warning silent logging" { - run _log_warning "test test test" - refute_output -} - -@test "lib log: basic error silent logging" { - run _log_error "test test test" - refute_output -} - -@test "lib log: logging with prefix" { - BASH_IT_LOG_LEVEL=$BASH_IT_LOG_LEVEL_ALL - BASH_IT_LOG_PREFIX="nice: prefix: " - run _log_debug "test test test" - assert_output "DEBUG: nice: prefix: test test test" -} +# shellcheck shell=bats + +load "${MAIN_BASH_IT_DIR?}/test/test_helper.bash" + +function local_setup_file() { + setup_libs "log" +} + +@test "lib log: basic debug logging with BASH_IT_LOG_LEVEL_ALL" { + BASH_IT_LOG_LEVEL=$BASH_IT_LOG_LEVEL_ALL + run _log_debug "test test test" + assert_output "DEBUG: default: test test test" +} + +@test "lib log: basic warning logging with BASH_IT_LOG_LEVEL_ALL" { + BASH_IT_LOG_LEVEL=$BASH_IT_LOG_LEVEL_ALL + run _log_warning "test test test" + assert_output " WARN: default: test test test" +} + +@test "lib log: basic error logging with BASH_IT_LOG_LEVEL_ALL" { + BASH_IT_LOG_LEVEL=$BASH_IT_LOG_LEVEL_ALL + run _log_error "test test test" + assert_output "ERROR: default: test test test" +} + +@test "lib log: basic debug logging with BASH_IT_LOG_LEVEL_WARNING" { + BASH_IT_LOG_LEVEL=$BASH_IT_LOG_LEVEL_WARNING + run _log_debug "test test test" + refute_output +} + +@test "lib log: basic warning logging with BASH_IT_LOG_LEVEL_WARNING" { + BASH_IT_LOG_LEVEL=$BASH_IT_LOG_LEVEL_WARNING + run _log_warning "test test test" + assert_output " WARN: default: test test test" +} + +@test "lib log: basic error logging with BASH_IT_LOG_LEVEL_WARNING" { + BASH_IT_LOG_LEVEL=$BASH_IT_LOG_LEVEL_WARNING + run _log_error "test test test" + assert_output "ERROR: default: test test test" +} + + +@test "lib log: basic debug logging with BASH_IT_LOG_LEVEL_ERROR" { + BASH_IT_LOG_LEVEL=$BASH_IT_LOG_LEVEL_ERROR + run _log_debug "test test test" + refute_output +} + +@test "lib log: basic warning logging with BASH_IT_LOG_LEVEL_ERROR" { + BASH_IT_LOG_LEVEL=$BASH_IT_LOG_LEVEL_ERROR + run _log_warning "test test test" + refute_output +} + +@test "lib log: basic error logging with BASH_IT_LOG_LEVEL_ERROR" { + BASH_IT_LOG_LEVEL=$BASH_IT_LOG_LEVEL_ERROR + run _log_error "test test test" + assert_output "ERROR: default: test test test" +} + +@test "lib log: basic debug silent logging" { + run _log_debug "test test test" + refute_output +} + +@test "lib log: basic warning silent logging" { + run _log_warning "test test test" + refute_output +} + +@test "lib log: basic error silent logging" { + run _log_error "test test test" + refute_output +} + +@test "lib log: logging with prefix" { + BASH_IT_LOG_LEVEL=$BASH_IT_LOG_LEVEL_ALL + BASH_IT_LOG_PREFIX="nice: prefix: " + run _log_debug "test test test" + assert_output "DEBUG: nice: prefix: test test test" +} diff --git a/test/lib/preexec.bats b/test/lib/preexec.bats index 10dc666d..6e325ad9 100644 --- a/test/lib/preexec.bats +++ b/test/lib/preexec.bats @@ -1,164 +1,164 @@ -# shellcheck shell=bats - -load ../test_helper - -function local_setup { - setup_test_fixture - export __bp_enable_subshells=yas -} - -@test "vendor preexec: __bp_install_after_session_init() without existing" { - test_prompt_string="" - export PROMPT_COMMAND="$test_prompt_string" - - load ../../vendor/github.com/rcaloras/bash-preexec/bash-preexec.sh - assert_success - - assert_equal "${PROMPT_COMMAND}" $'__bp_trap_string="$(trap -p DEBUG)"\ntrap - DEBUG\n__bp_install' -} - -@test "vendor preexec: __bp_install_after_session_init() with existing" { - test_prompt_string="nah" - export PROMPT_COMMAND="$test_prompt_string" - - load ../../vendor/github.com/rcaloras/bash-preexec/bash-preexec.sh - assert_success - - assert_equal "${PROMPT_COMMAND}" "$test_prompt_string"$'\n__bp_trap_string="$(trap -p DEBUG)"\ntrap - DEBUG\n__bp_install' -} - -@test "vendor preexec: __bp_install_after_session_init() delayed" { - test_prompt_string="nah" - export PROMPT_COMMAND="$test_prompt_string" - export __bp_delay_install="blarg" - - load ../../vendor/github.com/rcaloras/bash-preexec/bash-preexec.sh - assert_success - - assert_equal "${PROMPT_COMMAND}" "$test_prompt_string" - - run __bp_install_after_session_init - assert_success - - __bp_install_after_session_init - assert_equal "${PROMPT_COMMAND}" "$test_prompt_string"$'\n__bp_trap_string="$(trap -p DEBUG)"\ntrap - DEBUG\n__bp_install' -} - -@test "vendor preexec: __bp_install() without existing" { - test_prompt_string="" - export PROMPT_COMMAND="$test_prompt_string" - - load ../../vendor/github.com/rcaloras/bash-preexec/bash-preexec.sh - assert_success - - run __bp_install - assert_success - - __bp_install - assert_equal "${PROMPT_COMMAND}" $'__bp_precmd_invoke_cmd\n__bp_interactive_mode' -} - -@test "vendor preexec: __bp_install() with existing" { - test_prompt_string="nah" - export PROMPT_COMMAND="$test_prompt_string" - - load ../../vendor/github.com/rcaloras/bash-preexec/bash-preexec.sh - assert_success - - run __bp_install - assert_success - - __bp_install - assert_equal "${PROMPT_COMMAND}" $'__bp_precmd_invoke_cmd\n'"$test_prompt_string"$'\n__bp_interactive_mode' -} - -@test "lib preexec: __bp_require_not_readonly()" { - run type -t __bp_require_not_readonly - assert_failure - - run load ../../lib/preexec.bash - assert_success - load ../../lib/preexec.bash - - run type -t __bp_require_not_readonly - assert_success - - export HISTCONTROL=blah:blah PROMPT_COMMAND="silly;rabbit" - readonly HISTCONTROL PROMPT_COMMAND - - run __bp_require_not_readonly - assert_success -} - -@test "lib preexec: __bp_adjust_histcontrol()" { - run type -t __bp_adjust_histcontrol - assert_failure - - run load ../../lib/preexec.bash - assert_success - load ../../lib/preexec.bash - - run type -t __bp_adjust_histcontrol - assert_success - - test_history_control_string="ignoreall:ignoredups:ignorespace:erasedups" - export HISTCONTROL="${test_history_control_string}" - - run __bp_adjust_histcontrol - assert_success - assert_equal "${HISTCONTROL}" "${test_history_control_string}" -} - -@test "lib preexec: __check_precmd_conflict()" { - test_precmd_function_name="test" - setup_libs "preexec" - - run __check_precmd_conflict "$test_precmd_function_name" - assert_failure - - export precmd_functions=("$test_precmd_function_name") - - run __check_precmd_conflict "$test_precmd_function_name" - assert_success -} - -@test "lib preexec: __check_preexec_conflict()" { - test_preexec_function_name="test" - setup_libs "preexec" - - run __check_preexec_conflict "$test_preexec_function_name" - assert_failure - - export preexec_functions=("$test_preexec_function_name") - - run __check_preexec_conflict "$test_preexec_function_name" - assert_success -} - -@test "lib preexec: safe_append_prompt_command()" { - test_precmd_function_name="test" - setup_libs "preexec" - - export precmd_functions=() - assert_equal "${precmd_functions[*]}" "" - - run safe_append_prompt_command "$test_precmd_function_name" - assert_success - - safe_append_prompt_command "$test_precmd_function_name" - assert_equal "${precmd_functions[*]}" "$test_precmd_function_name" -} - -@test "lib preexec: safe_append_preexec()" { - test_preexec_function_name="test" - setup_libs "preexec" - - export preexec_functions=() - assert_equal "${preexec_functions[*]}" "" - - run safe_append_preexec "$test_preexec_function_name" - assert_success - - safe_append_preexec "$test_preexec_function_name" - assert_equal "${preexec_functions[*]}" "$test_preexec_function_name" -} +# shellcheck shell=bats + +load ../test_helper + +function local_setup { + setup_test_fixture + export __bp_enable_subshells=yas +} + +@test "vendor preexec: __bp_install_after_session_init() without existing" { + test_prompt_string="" + export PROMPT_COMMAND="$test_prompt_string" + + load ../../vendor/github.com/rcaloras/bash-preexec/bash-preexec.sh + assert_success + + assert_equal "${PROMPT_COMMAND}" $'__bp_trap_string="$(trap -p DEBUG)"\ntrap - DEBUG\n__bp_install' +} + +@test "vendor preexec: __bp_install_after_session_init() with existing" { + test_prompt_string="nah" + export PROMPT_COMMAND="$test_prompt_string" + + load ../../vendor/github.com/rcaloras/bash-preexec/bash-preexec.sh + assert_success + + assert_equal "${PROMPT_COMMAND}" "$test_prompt_string"$'\n__bp_trap_string="$(trap -p DEBUG)"\ntrap - DEBUG\n__bp_install' +} + +@test "vendor preexec: __bp_install_after_session_init() delayed" { + test_prompt_string="nah" + export PROMPT_COMMAND="$test_prompt_string" + export __bp_delay_install="blarg" + + load ../../vendor/github.com/rcaloras/bash-preexec/bash-preexec.sh + assert_success + + assert_equal "${PROMPT_COMMAND}" "$test_prompt_string" + + run __bp_install_after_session_init + assert_success + + __bp_install_after_session_init + assert_equal "${PROMPT_COMMAND}" "$test_prompt_string"$'\n__bp_trap_string="$(trap -p DEBUG)"\ntrap - DEBUG\n__bp_install' +} + +@test "vendor preexec: __bp_install() without existing" { + test_prompt_string="" + export PROMPT_COMMAND="$test_prompt_string" + + load ../../vendor/github.com/rcaloras/bash-preexec/bash-preexec.sh + assert_success + + run __bp_install + assert_success + + __bp_install + assert_equal "${PROMPT_COMMAND}" $'__bp_precmd_invoke_cmd\n__bp_interactive_mode' +} + +@test "vendor preexec: __bp_install() with existing" { + test_prompt_string="nah" + export PROMPT_COMMAND="$test_prompt_string" + + load ../../vendor/github.com/rcaloras/bash-preexec/bash-preexec.sh + assert_success + + run __bp_install + assert_success + + __bp_install + assert_equal "${PROMPT_COMMAND}" $'__bp_precmd_invoke_cmd\n'"$test_prompt_string"$'\n__bp_interactive_mode' +} + +@test "lib preexec: __bp_require_not_readonly()" { + run type -t __bp_require_not_readonly + assert_failure + + run load ../../lib/preexec.bash + assert_success + load ../../lib/preexec.bash + + run type -t __bp_require_not_readonly + assert_success + + export HISTCONTROL=blah:blah PROMPT_COMMAND="silly;rabbit" + readonly HISTCONTROL PROMPT_COMMAND + + run __bp_require_not_readonly + assert_success +} + +@test "lib preexec: __bp_adjust_histcontrol()" { + run type -t __bp_adjust_histcontrol + assert_failure + + run load ../../lib/preexec.bash + assert_success + load ../../lib/preexec.bash + + run type -t __bp_adjust_histcontrol + assert_success + + test_history_control_string="ignoreall:ignoredups:ignorespace:erasedups" + export HISTCONTROL="${test_history_control_string}" + + run __bp_adjust_histcontrol + assert_success + assert_equal "${HISTCONTROL}" "${test_history_control_string}" +} + +@test "lib preexec: __check_precmd_conflict()" { + test_precmd_function_name="test" + setup_libs "preexec" + + run __check_precmd_conflict "$test_precmd_function_name" + assert_failure + + export precmd_functions=("$test_precmd_function_name") + + run __check_precmd_conflict "$test_precmd_function_name" + assert_success +} + +@test "lib preexec: __check_preexec_conflict()" { + test_preexec_function_name="test" + setup_libs "preexec" + + run __check_preexec_conflict "$test_preexec_function_name" + assert_failure + + export preexec_functions=("$test_preexec_function_name") + + run __check_preexec_conflict "$test_preexec_function_name" + assert_success +} + +@test "lib preexec: safe_append_prompt_command()" { + test_precmd_function_name="test" + setup_libs "preexec" + + export precmd_functions=() + assert_equal "${precmd_functions[*]}" "" + + run safe_append_prompt_command "$test_precmd_function_name" + assert_success + + safe_append_prompt_command "$test_precmd_function_name" + assert_equal "${precmd_functions[*]}" "$test_precmd_function_name" +} + +@test "lib preexec: safe_append_preexec()" { + test_preexec_function_name="test" + setup_libs "preexec" + + export preexec_functions=() + assert_equal "${preexec_functions[*]}" "" + + run safe_append_preexec "$test_preexec_function_name" + assert_success + + safe_append_preexec "$test_preexec_function_name" + assert_equal "${preexec_functions[*]}" "$test_preexec_function_name" +} diff --git a/test/lib/search.bats b/test/lib/search.bats index e28922f4..673db035 100644 --- a/test/lib/search.bats +++ b/test/lib/search.bats @@ -1,68 +1,68 @@ -# shellcheck shell=bats - -load "${MAIN_BASH_IT_DIR?}/test/test_helper.bash" - -function local_setup_file() { - setup_libs "search" -} - -function local_setup() { - # shellcheck disable=SC2034 - BASH_IT_SEARCH_USE_COLOR=false -} - -@test "search: plugin base" { - export BASH_IT_SEARCH_USE_COLOR=false - run _bash-it-search-component 'plugins' 'base' - assert_line -n 0 ' plugins: base ' -} - -@test "search: git" { - run _bash-it-search 'git' --no-color - assert_line -n 0 ' aliases: git gitsvn ' - assert_line -n 1 -p ' plugins:' - for plugin in "autojump" "git" "gitstatus" "git-subrepo" "jgitflow" "jump" - do - echo $plugin - assert_line -n 1 -p $plugin - done - assert_line -n 2 ' completions: git git_flow git_flow_avh github-cli ' -} - -@test "search: ruby gem bundle rake rails" { - run _bash-it-search rails ruby gem bundler rake --no-color - - assert_line -n 0 ' aliases: bundler rails ' - assert_line -n 1 ' plugins: chruby chruby-auto rails ruby ' - assert_line -n 2 ' completions: bundler gem rake ' -} - -@test "search: rails ruby gem bundler rake -chruby" { - run _bash-it-search rails ruby gem bundler rake -chruby --no-color - - assert_line -n 0 ' aliases: bundler rails ' - assert_line -n 1 ' plugins: rails ruby ' - assert_line -n 2 ' completions: bundler gem rake ' -} - -@test "search: @git" { - run _bash-it-search '@git' --no-color - assert_line -n 0 ' aliases: git ' - assert_line -n 1 ' plugins: git ' - assert_line -n 2 ' completions: git ' -} - -@test "search: @git --enable / --disable" { - set -e - run _bash-it-search '@git' --enable --no-color - run _bash-it-search '@git' --no-color - - [[ "${lines[0]}" =~ '✓' ]] - - run _bash-it-search '@git' --disable --no-color - run _bash-it-search '@git' --no-color - - assert_line -n 0 ' aliases: git ' - assert_line -n 1 ' plugins: git ' - assert_line -n 2 ' completions: git ' -} +# shellcheck shell=bats + +load "${MAIN_BASH_IT_DIR?}/test/test_helper.bash" + +function local_setup_file() { + setup_libs "search" +} + +function local_setup() { + # shellcheck disable=SC2034 + BASH_IT_SEARCH_USE_COLOR=false +} + +@test "search: plugin base" { + export BASH_IT_SEARCH_USE_COLOR=false + run _bash-it-search-component 'plugins' 'base' + assert_line -n 0 ' plugins: base ' +} + +@test "search: git" { + run _bash-it-search 'git' --no-color + assert_line -n 0 ' aliases: git gitsvn ' + assert_line -n 1 -p ' plugins:' + for plugin in "autojump" "git" "gitstatus" "git-subrepo" "jgitflow" "jump" + do + echo $plugin + assert_line -n 1 -p $plugin + done + assert_line -n 2 ' completions: git git_flow git_flow_avh github-cli ' +} + +@test "search: ruby gem bundle rake rails" { + run _bash-it-search rails ruby gem bundler rake --no-color + + assert_line -n 0 ' aliases: bundler rails ' + assert_line -n 1 ' plugins: chruby chruby-auto rails ruby ' + assert_line -n 2 ' completions: bundler gem rake ' +} + +@test "search: rails ruby gem bundler rake -chruby" { + run _bash-it-search rails ruby gem bundler rake -chruby --no-color + + assert_line -n 0 ' aliases: bundler rails ' + assert_line -n 1 ' plugins: rails ruby ' + assert_line -n 2 ' completions: bundler gem rake ' +} + +@test "search: @git" { + run _bash-it-search '@git' --no-color + assert_line -n 0 ' aliases: git ' + assert_line -n 1 ' plugins: git ' + assert_line -n 2 ' completions: git ' +} + +@test "search: @git --enable / --disable" { + set -e + run _bash-it-search '@git' --enable --no-color + run _bash-it-search '@git' --no-color + + [[ "${lines[0]}" =~ '✓' ]] + + run _bash-it-search '@git' --disable --no-color + run _bash-it-search '@git' --no-color + + assert_line -n 0 ' aliases: git ' + assert_line -n 1 ' plugins: git ' + assert_line -n 2 ' completions: git ' +} diff --git a/test/lib/utilities.bats b/test/lib/utilities.bats index 78913870..40622de4 100644 --- a/test/lib/utilities.bats +++ b/test/lib/utilities.bats @@ -1,83 +1,83 @@ -# shellcheck shell=bats - -load "${MAIN_BASH_IT_DIR?}/test/test_helper.bash" - -function local_setup_file() { - setup_libs "helpers" -} - -@test "_bash-it-component-item-is-enabled() - for a disabled item" { - run _bash-it-component-item-is-enabled aliases svn - assert_failure -} - -@test "_bash-it-component-item-is-enabled() - for an enabled/disabled item" { - run bash-it enable alias svn - assert_line -n 0 'svn enabled with priority 150.' - - run _bash-it-component-item-is-enabled alias svn - assert_success - run _bash-it-component-item-is-disabled alias svn - assert_failure - - run bash-it disable alias svn - assert_line -n 0 'svn disabled.' - - run _bash-it-component-item-is-enabled alias svn - assert_failure - run _bash-it-component-item-is-disabled alias svn - assert_success -} - -@test "_bash-it-component-item-is-disabled() - for a disabled item" { - run _bash-it-component-item-is-disabled alias svn - assert_success -} - -@test "_bash-it-component-item-is-disabled() - for an enabled/disabled item" { - run bash-it enable alias svn - assert_line -n 0 'svn enabled with priority 150.' - - run _bash-it-component-item-is-disabled alias svn - assert_failure - run _bash-it-component-item-is-enabled alias svn - assert_success - - run bash-it disable alias svn - assert_line -n 0 'svn disabled.' - - run _bash-it-component-item-is-disabled alias svn - assert_success - run _bash-it-component-item-is-enabled alias svn - assert_failure -} - -@test "_bash-it-array-contains-element() - when match is found, and is the first" { - declare -a fruits=(apple pear orange mandarin) - run _bash-it-array-contains-element apple "${fruits[@]}" - assert_success -} - -@test "_bash-it-array-contains-element() - when match is found, and is the last" { - declare -a fruits=(apple pear orange mandarin) - run _bash-it-array-contains-element mandarin "${fruits[@]}" - assert_success -} - -@test "_bash-it-array-contains-element() - when match is found, and is in the middle" { - declare -a fruits=(apple pear orange mandarin) - run _bash-it-array-contains-element pear "${fruits[@]}" - assert_success -} - -@test "_bash-it-array-contains-element() - when match is found, and it has spaces" { - declare -a fruits=(apple pear orange mandarin "yellow watermelon") - run _bash-it-array-contains-element "yellow watermelon" "${fruits[@]}" - assert_success -} - -@test "_bash-it-array-contains-element() - when match is not found" { - declare -a fruits=(apple pear orange mandarin) - run _bash-it-array-contains-element xyz "${fruits[@]}" - assert_failure -} +# shellcheck shell=bats + +load "${MAIN_BASH_IT_DIR?}/test/test_helper.bash" + +function local_setup_file() { + setup_libs "helpers" +} + +@test "_bash-it-component-item-is-enabled() - for a disabled item" { + run _bash-it-component-item-is-enabled aliases svn + assert_failure +} + +@test "_bash-it-component-item-is-enabled() - for an enabled/disabled item" { + run bash-it enable alias svn + assert_line -n 0 'svn enabled with priority 150.' + + run _bash-it-component-item-is-enabled alias svn + assert_success + run _bash-it-component-item-is-disabled alias svn + assert_failure + + run bash-it disable alias svn + assert_line -n 0 'svn disabled.' + + run _bash-it-component-item-is-enabled alias svn + assert_failure + run _bash-it-component-item-is-disabled alias svn + assert_success +} + +@test "_bash-it-component-item-is-disabled() - for a disabled item" { + run _bash-it-component-item-is-disabled alias svn + assert_success +} + +@test "_bash-it-component-item-is-disabled() - for an enabled/disabled item" { + run bash-it enable alias svn + assert_line -n 0 'svn enabled with priority 150.' + + run _bash-it-component-item-is-disabled alias svn + assert_failure + run _bash-it-component-item-is-enabled alias svn + assert_success + + run bash-it disable alias svn + assert_line -n 0 'svn disabled.' + + run _bash-it-component-item-is-disabled alias svn + assert_success + run _bash-it-component-item-is-enabled alias svn + assert_failure +} + +@test "_bash-it-array-contains-element() - when match is found, and is the first" { + declare -a fruits=(apple pear orange mandarin) + run _bash-it-array-contains-element apple "${fruits[@]}" + assert_success +} + +@test "_bash-it-array-contains-element() - when match is found, and is the last" { + declare -a fruits=(apple pear orange mandarin) + run _bash-it-array-contains-element mandarin "${fruits[@]}" + assert_success +} + +@test "_bash-it-array-contains-element() - when match is found, and is in the middle" { + declare -a fruits=(apple pear orange mandarin) + run _bash-it-array-contains-element pear "${fruits[@]}" + assert_success +} + +@test "_bash-it-array-contains-element() - when match is found, and it has spaces" { + declare -a fruits=(apple pear orange mandarin "yellow watermelon") + run _bash-it-array-contains-element "yellow watermelon" "${fruits[@]}" + assert_success +} + +@test "_bash-it-array-contains-element() - when match is not found" { + declare -a fruits=(apple pear orange mandarin) + run _bash-it-array-contains-element xyz "${fruits[@]}" + assert_failure +} diff --git a/test/lint-requirements.txt b/test/lint-requirements.txt index 72224bf8..d81c110c 100644 --- a/test/lint-requirements.txt +++ b/test/lint-requirements.txt @@ -1 +1 @@ -pre-commit==2.3.0 +pre-commit==2.3.0 diff --git a/test/plugins/base.plugin.bats b/test/plugins/base.plugin.bats index 6022451a..bfea1005 100644 --- a/test/plugins/base.plugin.bats +++ b/test/plugins/base.plugin.bats @@ -1,76 +1,76 @@ -# shellcheck shell=bats - -load "${MAIN_BASH_IT_DIR?}/test/test_helper.bash" - -function local_setup_file() { - setup_libs "helpers" - load "${BASH_IT?}/plugins/available/base.plugin.bash" -} - -@test 'plugins base: ips()' { - declare -r localhost='127.0.0.1' - run ips - assert_success - assert_line $localhost -} - -@test 'plugins base: myip()' { - run myip - assert_success - declare -r mask_ip=$(echo $output | tr -s '[0-9]' '?') - [[ $mask_ip == 'Your public IP is:'*'?.?.?.?'* ]] -} - -@test 'plugins base: pickfrom()' { - stub_file="${BATS_TEST_TMPDIR}/stub_file" - printf "l1\nl2\nl3" > $stub_file - run pickfrom $stub_file - assert_success - [[ $output == l? ]] -} - -@test 'plugins base: mkcd()' { - cd "${BATS_TEST_TMPDIR}" - declare -r dir_name="-dir_with_dash" - - # Make sure that the directory does not exist prior to the test - rm -rf "${BATS_TEST_TMPDIR}/${dir_name}" - - run mkcd "${dir_name}" - assert_success - assert_dir_exist "${BATS_TEST_TMPDIR}/${dir_name}" - - mkcd "${dir_name}" - assert_equal "${PWD}" "${BATS_TEST_TMPDIR//\/\///}/${dir_name}" -} - -@test 'plugins base: lsgrep()' { - for i in 1 2 3; do mkdir -p "${BASH_IT}/${i}"; done - cd $BASH_IT - run lsgrep 2 - assert_success - assert_equal $output 2 -} - -@test 'plugins base: buf()' { - declare -r file="${BATS_TEST_TMPDIR}/file" - touch $file - - # Take one timestamp before running the `buf` function - declare -r stamp1=$(date +%Y%m%d_%H%M%S) - - run buf $file - - # Take another timestamp after running `buf`. - declare -r stamp2=$(date +%Y%m%d_%H%M%S) - - # Verify that the backup file ends with one of the two timestamps. - # This is done to avoid race conditions where buf is run close to the end - # of a second, in which case the second timestamp might be in the next second, - # causing the test to fail. - # By using `or` for the two checks, we can verify that one of the two files is present. - # In most cases, it's going to have the same timestamp anyway. - # We can't use `assert_file_exist` here, since it only checks for a single file name. - assert [ -e "${file}_${stamp1}" \ - -o -e "${file}_${stamp2}" ] -} +# shellcheck shell=bats + +load "${MAIN_BASH_IT_DIR?}/test/test_helper.bash" + +function local_setup_file() { + setup_libs "helpers" + load "${BASH_IT?}/plugins/available/base.plugin.bash" +} + +@test 'plugins base: ips()' { + declare -r localhost='127.0.0.1' + run ips + assert_success + assert_line $localhost +} + +@test 'plugins base: myip()' { + run myip + assert_success + declare -r mask_ip=$(echo $output | tr -s '[0-9]' '?') + [[ $mask_ip == 'Your public IP is:'*'?.?.?.?'* ]] +} + +@test 'plugins base: pickfrom()' { + stub_file="${BATS_TEST_TMPDIR}/stub_file" + printf "l1\nl2\nl3" > $stub_file + run pickfrom $stub_file + assert_success + [[ $output == l? ]] +} + +@test 'plugins base: mkcd()' { + cd "${BATS_TEST_TMPDIR}" + declare -r dir_name="-dir_with_dash" + + # Make sure that the directory does not exist prior to the test + rm -rf "${BATS_TEST_TMPDIR}/${dir_name}" + + run mkcd "${dir_name}" + assert_success + assert_dir_exist "${BATS_TEST_TMPDIR}/${dir_name}" + + mkcd "${dir_name}" + assert_equal "${PWD}" "${BATS_TEST_TMPDIR//\/\///}/${dir_name}" +} + +@test 'plugins base: lsgrep()' { + for i in 1 2 3; do mkdir -p "${BASH_IT}/${i}"; done + cd $BASH_IT + run lsgrep 2 + assert_success + assert_equal $output 2 +} + +@test 'plugins base: buf()' { + declare -r file="${BATS_TEST_TMPDIR}/file" + touch $file + + # Take one timestamp before running the `buf` function + declare -r stamp1=$(date +%Y%m%d_%H%M%S) + + run buf $file + + # Take another timestamp after running `buf`. + declare -r stamp2=$(date +%Y%m%d_%H%M%S) + + # Verify that the backup file ends with one of the two timestamps. + # This is done to avoid race conditions where buf is run close to the end + # of a second, in which case the second timestamp might be in the next second, + # causing the test to fail. + # By using `or` for the two checks, we can verify that one of the two files is present. + # In most cases, it's going to have the same timestamp anyway. + # We can't use `assert_file_exist` here, since it only checks for a single file name. + assert [ -e "${file}_${stamp1}" \ + -o -e "${file}_${stamp2}" ] +} diff --git a/test/plugins/battery.plugin.bats b/test/plugins/battery.plugin.bats index 49199ef2..3e1b0fb4 100644 --- a/test/plugins/battery.plugin.bats +++ b/test/plugins/battery.plugin.bats @@ -1,384 +1,384 @@ -# shellcheck shell=bats - -load "${MAIN_BASH_IT_DIR?}/test/test_helper.bash" - -function local_setup_file() { - setup_libs "helpers" - load "${BASH_IT?}/plugins/available/battery.plugin.bash" -} - -# Sets up the `_command_exists` function so that it only responds `true` if called with -# the name of the function that was passed in as an argument to `setup_command_exists`. -# This is used to ensure that the test cases can test the various energy management tools -# without actually having them. When called like -# -# setup_command_exists "pmset" -# -# then calling `_command_exists "pmset"` will return `true`, -# while calling `_command_exists "ioreg"` (or other commands) will return `false`. -# -# It's cool that Bash allows to define functions within functions, works almost like -# a closure in JavaScript. -function setup_command_exists { - success_command="$1" - - function _command_exists { - case "$1" in - "${success_command}") - true - ;; - *) - false - ;; - esac - } -} - -####################### -# -# no tool -# - -@test 'plugins battery: battery-percentage with no tool' { - setup_command_exists "fooooo" - - run battery_percentage - assert_output "no" -} - -####################### -# -# pmset -# - -# Creates a `pmset` function that simulates output like the real `pmset` command. -# The passed in parameter is used for the remaining battery percentage. -function setup_pmset { - percent="$1" - - function pmset { - printf "\-InternalBattery-0 (id=12345) %s; discharging; 16:00 remaining present: true" "${percent}" - } -} - -@test 'plugins battery: battery-percentage with pmset, 100%' { - setup_command_exists "pmset" - - setup_pmset "100%" - - run battery_percentage - assert_output "100" -} - -@test 'plugins battery: battery-percentage with pmset, 98%' { - setup_command_exists "pmset" - - setup_pmset "98%" - - run battery_percentage - assert_output "98" -} - -@test 'plugins battery: battery-percentage with pmset, 98.5%' { - setup_command_exists "pmset" - - setup_pmset "98.5%" - - run battery_percentage - assert_output "98" -} - -@test 'plugins battery: battery-percentage with pmset, 4%' { - setup_command_exists "pmset" - - setup_pmset "4%" - - run battery_percentage - assert_output "04" -} - -@test 'plugins battery: battery-percentage with pmset, no status' { - setup_command_exists "pmset" - - setup_pmset "" - - run battery_percentage - assert_output "-1" -} - -####################### -# -# acpi -# - -# Creates a `acpi` function that simulates output like the real `acpi` command. -# The passed in parameters are used for -# 1) the remaining battery percentage. -# 2) the battery status -function setup_acpi { - percent="$1" - status="$2" - - function acpi { - printf "Battery 0: %s, %s, 01:02:48 until charged" "${status}" "${percent}" - } -} - -@test 'plugins battery: battery-percentage with acpi, 100% Full' { - setup_command_exists "acpi" - - setup_acpi "100%" "Full" - - run battery_percentage - assert_output "100" -} - -@test 'plugins battery: battery-percentage with acpi, 98% Charging' { - setup_command_exists "acpi" - - setup_acpi "98%" "Charging" - - run battery_percentage - assert_output "98" -} - -@test 'plugins battery: battery-percentage with acpi, 98% Discharging' { - setup_command_exists "acpi" - - setup_acpi "98%" "Discharging" - - run battery_percentage - assert_output "98" -} - -@test 'plugins battery: battery-percentage with acpi, 98% Unknown' { - setup_command_exists "acpi" - - setup_acpi "98%" "Unknown" - - run battery_percentage - assert_output "98" -} - -@test 'plugins battery: battery-percentage with acpi, 4% Charging' { - setup_command_exists "acpi" - - setup_acpi "4%" "Charging" - - run battery_percentage - assert_output "04" -} - -@test 'plugins battery: battery-percentage with acpi, 4% no status' { - setup_command_exists "acpi" - - setup_acpi "4%" "" - - run battery_percentage - assert_output "04" -} - -@test 'plugins battery: battery-percentage with acpi, no status' { - setup_command_exists "acpi" - - setup_acpi "" "" - - run battery_percentage - assert_output "-1" -} - -####################### -# -# upower -# - -# Creates a `upower` function that simulates output like the real `upower` command. -# The passed in parameter is used for the remaining battery percentage. -function setup_upower { - percent="$1" - BAT0="/org/freedesktop/UPower/devices/battery_BAT$RANDOM" - - function upower { - case $1 in - '-e'|'--enumerate') - printf '%s\n' "$BAT0" "/org/freedesktop/UPower/devices/mouse_hid_${RANDOM}_battery" - ;; - '-i'|'--show-info') - if [[ $2 == "$BAT0" ]] - then - printf "voltage: 12.191 V\n time to full: 57.3 minutes\n percentage: %s\n capacity: 84.6964" "${percent}" - else - false - fi - ;; - esac - } -} - -@test 'plugins battery: battery-percentage with upower, 100%' { - setup_command_exists "upower" - - setup_upower "100.00%" - - run battery_percentage - assert_output "100" -} - -@test 'plugins battery: battery-percentage with upower, 98%' { - setup_command_exists "upower" - - setup_upower "98.4567%" - - run battery_percentage - assert_output "98" -} - -@test 'plugins battery: battery-percentage with upower, 98.5%' { - setup_command_exists "upower" - - setup_upower "98.5%" - - run battery_percentage - assert_output "98" -} - -@test 'plugins battery: battery-percentage with upower, 4%' { - setup_command_exists "upower" - - setup_upower "4.2345%" - - run battery_percentage - assert_output "04" -} - -@test 'plugins battery: battery-percentage with upower, no output' { - setup_command_exists "upower" - - setup_upower "" - - run battery_percentage - assert_output "-1" -} - -####################### -# -# ioreg -# - -# Creates a `ioreg` function that simulates output like the real `ioreg` command. -# The passed in parameter is used for the remaining battery percentage. -function setup_ioreg { - percent="$1" - - function ioreg { - printf "\"MaxCapacity\" = 100\n\"CurrentCapacity\" = %s" "${percent}" - } -} - -@test 'plugins battery: battery-percentage with ioreg, 100%' { - setup_command_exists "ioreg" - - setup_ioreg "100%" - - run battery_percentage - assert_output "100" -} - -@test 'plugins battery: battery-percentage with ioreg, 98%' { - setup_command_exists "ioreg" - - setup_ioreg "98%" - - run battery_percentage - assert_output "98" -} - -@test 'plugins battery: battery-percentage with ioreg, 98.5%' { - setup_command_exists "ioreg" - - setup_ioreg "98.5%" - - run battery_percentage - assert_output "98" -} - -@test 'plugins battery: battery-percentage with ioreg, 4%' { - setup_command_exists "ioreg" - - setup_ioreg "4%" - - run battery_percentage - assert_output "04" -} - -@test 'plugins battery: battery-percentage with ioreg, no status' { - setup_command_exists "ioreg" - - # Simulate that no battery is present - function ioreg { - printf "" - } - - run battery_percentage - assert_output "-1" -} - -####################### -# -# WMIC -# - -# Creates a `WMIC` function that simulates output like the real `WMIC` command. -# The passed in parameter is used for the remaining battery percentage. -function setup_WMIC { - percent="$1" - - function WMIC { - printf "Charge: %s" "${percent}" - } -} - -@test 'plugins battery: battery-percentage with WMIC, 100%' { - setup_command_exists "WMIC" - - setup_WMIC "100%" - - run battery_percentage - assert_output "100" -} - -@test 'plugins battery: battery-percentage with WMIC, 98%' { - setup_command_exists "WMIC" - - setup_WMIC "98%" - - run battery_percentage - assert_output "98" -} - -@test 'plugins battery: battery-percentage with WMIC, 98.5%' { - setup_command_exists "WMIC" - - setup_WMIC "98.5%" - - run battery_percentage - assert_output "98" -} - -@test 'plugins battery: battery-percentage with WMIC, 4%' { - setup_command_exists "WMIC" - - setup_WMIC "4%" - - run battery_percentage - assert_output "04" -} - -@test 'plugins battery: battery-percentage with WMIC, no status' { - setup_command_exists "WMIC" - - setup_WMIC "" - - run battery_percentage - assert_output "-1" -} +# shellcheck shell=bats + +load "${MAIN_BASH_IT_DIR?}/test/test_helper.bash" + +function local_setup_file() { + setup_libs "helpers" + load "${BASH_IT?}/plugins/available/battery.plugin.bash" +} + +# Sets up the `_command_exists` function so that it only responds `true` if called with +# the name of the function that was passed in as an argument to `setup_command_exists`. +# This is used to ensure that the test cases can test the various energy management tools +# without actually having them. When called like +# +# setup_command_exists "pmset" +# +# then calling `_command_exists "pmset"` will return `true`, +# while calling `_command_exists "ioreg"` (or other commands) will return `false`. +# +# It's cool that Bash allows to define functions within functions, works almost like +# a closure in JavaScript. +function setup_command_exists { + success_command="${1}" + + function _command_exists { + case "${1}" in + "${success_command}") + true + ;; + *) + false + ;; + esac + } +} + +####################### +# +# no tool +# + +@test 'plugins battery: battery-percentage with no tool' { + setup_command_exists "fooooo" + + run battery_percentage + assert_output "no" +} + +####################### +# +# pmset +# + +# Creates a `pmset` function that simulates output like the real `pmset` command. +# The passed in parameter is used for the remaining battery percentage. +function setup_pmset { + percent="${1}" + + function pmset { + printf "\-InternalBattery-0 (id=12345) %s; discharging; 16:00 remaining present: true" "${percent}" + } +} + +@test 'plugins battery: battery-percentage with pmset, 100%' { + setup_command_exists "pmset" + + setup_pmset "100%" + + run battery_percentage + assert_output "100" +} + +@test 'plugins battery: battery-percentage with pmset, 98%' { + setup_command_exists "pmset" + + setup_pmset "98%" + + run battery_percentage + assert_output "98" +} + +@test 'plugins battery: battery-percentage with pmset, 98.5%' { + setup_command_exists "pmset" + + setup_pmset "98.5%" + + run battery_percentage + assert_output "98" +} + +@test 'plugins battery: battery-percentage with pmset, 4%' { + setup_command_exists "pmset" + + setup_pmset "4%" + + run battery_percentage + assert_output "04" +} + +@test 'plugins battery: battery-percentage with pmset, no status' { + setup_command_exists "pmset" + + setup_pmset "" + + run battery_percentage + assert_output "-1" +} + +####################### +# +# acpi +# + +# Creates a `acpi` function that simulates output like the real `acpi` command. +# The passed in parameters are used for +# 1) the remaining battery percentage. +# 2) the battery status +function setup_acpi { + percent="${1}" + status="${2}" + + function acpi { + printf "Battery 0: %s, %s, 01:02:48 until charged" "${status}" "${percent}" + } +} + +@test 'plugins battery: battery-percentage with acpi, 100% Full' { + setup_command_exists "acpi" + + setup_acpi "100%" "Full" + + run battery_percentage + assert_output "100" +} + +@test 'plugins battery: battery-percentage with acpi, 98% Charging' { + setup_command_exists "acpi" + + setup_acpi "98%" "Charging" + + run battery_percentage + assert_output "98" +} + +@test 'plugins battery: battery-percentage with acpi, 98% Discharging' { + setup_command_exists "acpi" + + setup_acpi "98%" "Discharging" + + run battery_percentage + assert_output "98" +} + +@test 'plugins battery: battery-percentage with acpi, 98% Unknown' { + setup_command_exists "acpi" + + setup_acpi "98%" "Unknown" + + run battery_percentage + assert_output "98" +} + +@test 'plugins battery: battery-percentage with acpi, 4% Charging' { + setup_command_exists "acpi" + + setup_acpi "4%" "Charging" + + run battery_percentage + assert_output "04" +} + +@test 'plugins battery: battery-percentage with acpi, 4% no status' { + setup_command_exists "acpi" + + setup_acpi "4%" "" + + run battery_percentage + assert_output "04" +} + +@test 'plugins battery: battery-percentage with acpi, no status' { + setup_command_exists "acpi" + + setup_acpi "" "" + + run battery_percentage + assert_output "-1" +} + +####################### +# +# upower +# + +# Creates a `upower` function that simulates output like the real `upower` command. +# The passed in parameter is used for the remaining battery percentage. +function setup_upower { + percent="${1}" + BAT0="/org/freedesktop/UPower/devices/battery_BAT$RANDOM" + + function upower { + case $1 in + '-e'|'--enumerate') + printf '%s\n' "$BAT0" "/org/freedesktop/UPower/devices/mouse_hid_${RANDOM}_battery" + ;; + '-i'|'--show-info') + if [[ $2 == "$BAT0" ]] + then + printf "voltage: 12.191 V\n time to full: 57.3 minutes\n percentage: %s\n capacity: 84.6964" "${percent}" + else + false + fi + ;; + esac + } +} + +@test 'plugins battery: battery-percentage with upower, 100%' { + setup_command_exists "upower" + + setup_upower "100.00%" + + run battery_percentage + assert_output "100" +} + +@test 'plugins battery: battery-percentage with upower, 98%' { + setup_command_exists "upower" + + setup_upower "98.4567%" + + run battery_percentage + assert_output "98" +} + +@test 'plugins battery: battery-percentage with upower, 98.5%' { + setup_command_exists "upower" + + setup_upower "98.5%" + + run battery_percentage + assert_output "98" +} + +@test 'plugins battery: battery-percentage with upower, 4%' { + setup_command_exists "upower" + + setup_upower "4.2345%" + + run battery_percentage + assert_output "04" +} + +@test 'plugins battery: battery-percentage with upower, no output' { + setup_command_exists "upower" + + setup_upower "" + + run battery_percentage + assert_output "-1" +} + +####################### +# +# ioreg +# + +# Creates a `ioreg` function that simulates output like the real `ioreg` command. +# The passed in parameter is used for the remaining battery percentage. +function setup_ioreg { + percent="${1}" + + function ioreg { + printf "\"MaxCapacity\" = 100\n\"CurrentCapacity\" = %s" "${percent}" + } +} + +@test 'plugins battery: battery-percentage with ioreg, 100%' { + setup_command_exists "ioreg" + + setup_ioreg "100%" + + run battery_percentage + assert_output "100" +} + +@test 'plugins battery: battery-percentage with ioreg, 98%' { + setup_command_exists "ioreg" + + setup_ioreg "98%" + + run battery_percentage + assert_output "98" +} + +@test 'plugins battery: battery-percentage with ioreg, 98.5%' { + setup_command_exists "ioreg" + + setup_ioreg "98.5%" + + run battery_percentage + assert_output "98" +} + +@test 'plugins battery: battery-percentage with ioreg, 4%' { + setup_command_exists "ioreg" + + setup_ioreg "4%" + + run battery_percentage + assert_output "04" +} + +@test 'plugins battery: battery-percentage with ioreg, no status' { + setup_command_exists "ioreg" + + # Simulate that no battery is present + function ioreg { + printf "" + } + + run battery_percentage + assert_output "-1" +} + +####################### +# +# WMIC +# + +# Creates a `WMIC` function that simulates output like the real `WMIC` command. +# The passed in parameter is used for the remaining battery percentage. +function setup_WMIC { + percent="${1}" + + function WMIC { + printf "Charge: %s" "${percent}" + } +} + +@test 'plugins battery: battery-percentage with WMIC, 100%' { + setup_command_exists "WMIC" + + setup_WMIC "100%" + + run battery_percentage + assert_output "100" +} + +@test 'plugins battery: battery-percentage with WMIC, 98%' { + setup_command_exists "WMIC" + + setup_WMIC "98%" + + run battery_percentage + assert_output "98" +} + +@test 'plugins battery: battery-percentage with WMIC, 98.5%' { + setup_command_exists "WMIC" + + setup_WMIC "98.5%" + + run battery_percentage + assert_output "98" +} + +@test 'plugins battery: battery-percentage with WMIC, 4%' { + setup_command_exists "WMIC" + + setup_WMIC "4%" + + run battery_percentage + assert_output "04" +} + +@test 'plugins battery: battery-percentage with WMIC, no status' { + setup_command_exists "WMIC" + + setup_WMIC "" + + run battery_percentage + assert_output "-1" +} diff --git a/test/plugins/cmd-returned-notify.plugin.bats b/test/plugins/cmd-returned-notify.plugin.bats index a5ae591a..e12ddf69 100644 --- a/test/plugins/cmd-returned-notify.plugin.bats +++ b/test/plugins/cmd-returned-notify.plugin.bats @@ -1,41 +1,41 @@ -# shellcheck shell=bats - -load "${MAIN_BASH_IT_DIR?}/test/test_helper.bash" - -function local_setup_file() { - setup_libs "command_duration" - load "${BASH_IT?}/plugins/available/cmd-returned-notify.plugin.bash" -} - -@test "plugins cmd-returned-notify: notify after elapsed time" { - export NOTIFY_IF_COMMAND_RETURNS_AFTER=0 - export COMMAND_DURATION_START_SECONDS="$(_shell_duration_en)" - sleep 1 - run precmd_return_notification - assert_success - assert_output $'\a' -} - -@test "plugins cmd-returned-notify: do not notify before elapsed time" { - export NOTIFY_IF_COMMAND_RETURNS_AFTER=10 - export COMMAND_DURATION_START_SECONDS="$(_shell_duration_en)" - sleep 1 - run precmd_return_notification - assert_success - assert_output $'' -} - -@test "lib command_duration: preexec no output" { - export COMMAND_DURATION_START_SECONDS= - run _command_duration_pre_exec - assert_success - assert_output "" -} -@test "lib command_duration: preexec set COMMAND_DURATION_START_SECONDS" { - export COMMAND_DURATION_START_SECONDS= - assert_equal "${COMMAND_DURATION_START_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%.*}" -} +# shellcheck shell=bats + +load "${MAIN_BASH_IT_DIR?}/test/test_helper.bash" + +function local_setup_file() { + setup_libs "command_duration" + load "${BASH_IT?}/plugins/available/cmd-returned-notify.plugin.bash" +} + +@test "plugins cmd-returned-notify: notify after elapsed time" { + export NOTIFY_IF_COMMAND_RETURNS_AFTER=0 + export COMMAND_DURATION_START_SECONDS="$(_shell_duration_en)" + sleep 1 + run precmd_return_notification + assert_success + assert_output $'\a' +} + +@test "plugins cmd-returned-notify: do not notify before elapsed time" { + export NOTIFY_IF_COMMAND_RETURNS_AFTER=10 + export COMMAND_DURATION_START_SECONDS="$(_shell_duration_en)" + sleep 1 + run precmd_return_notification + assert_success + assert_output $'' +} + +@test "lib command_duration: preexec no output" { + export COMMAND_DURATION_START_SECONDS= + run _command_duration_pre_exec + assert_success + assert_output "" +} +@test "lib command_duration: preexec set COMMAND_DURATION_START_SECONDS" { + export COMMAND_DURATION_START_SECONDS= + assert_equal "${COMMAND_DURATION_START_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%.*}" +} diff --git a/test/plugins/go.plugin.bats b/test/plugins/go.plugin.bats index ebb9cd88..98051584 100644 --- a/test/plugins/go.plugin.bats +++ b/test/plugins/go.plugin.bats @@ -1,74 +1,74 @@ -# shellcheck shell=bats - -load "${MAIN_BASH_IT_DIR?}/test/test_helper.bash" - -function local_setup_file() { - setup_libs "helpers" -} - -function setup_go_path() -{ - local go_path="$1" - - # Make sure that the requested GO folder is available - assert_dir_exist "$go_path/bin" - - # Make sure that the requested GO folder is on the path - export GOPATH="$go_path:${GOPATH:-}" -} - -# We test `go version` in each test to account for users with goenv and no system go. - -@test 'ensure _bash-it-gopath-pathmunge is defined' { - { _command_exists go && go version &>/dev/null; } || skip 'golang not found' - load ../../plugins/available/go.plugin - run type -t _bash-it-gopath-pathmunge - assert_line 'function' -} - -@test 'plugins go: single entry in GOPATH' { - { _command_exists go && go version &>/dev/null; } || skip 'golang not found' - setup_go_path "$BASH_IT/test/fixtures/go/gopath" - load ../../plugins/available/go.plugin - assert_equal "$(cut -d':' -f1 <<<$PATH)" "$BASH_IT/test/fixtures/go/gopath/bin" -} - -@test 'plugins go: single entry in GOPATH, with space' { - { _command_exists go && go version &>/dev/null; } || skip 'golang not found' - setup_go_path "$BASH_IT/test/fixtures/go/go path" - load ../../plugins/available/go.plugin - assert_equal "$(cut -d':' -f1 <<<$PATH)" "$BASH_IT/test/fixtures/go/go path/bin" -} - -@test 'plugins go: single entry in GOPATH, with escaped space' { - skip 'huh?' - { _command_exists go && go version &>/dev/null; } || skip 'golang not found' - setup_go_path "$BASH_IT/test/fixtures/go/go\ path" - load ../../plugins/available/go.plugin - assert_equal "$(cut -d':' -f1 <<<$PATH)" "$BASH_IT/test/fixtures/go/go\ path/bin" -} - -@test 'plugins go: multiple entries in GOPATH' { - { _command_exists go && go version &>/dev/null; } || skip 'golang not found' - setup_go_path "$BASH_IT/test/fixtures/go/gopath" - setup_go_path "$BASH_IT/test/fixtures/go/gopath2" - load ../../plugins/available/go.plugin - assert_equal "$(cut -d':' -f1,2 <<<$PATH)" "$BASH_IT/test/fixtures/go/gopath2/bin:$BASH_IT/test/fixtures/go/gopath/bin" -} - -@test 'plugins go: multiple entries in GOPATH, with space' { - { _command_exists go && go version &>/dev/null; } || skip 'golang not found' - setup_go_path "$BASH_IT/test/fixtures/go/gopath" - setup_go_path "$BASH_IT/test/fixtures/go/go path" - load ../../plugins/available/go.plugin - assert_equal "$(cut -d':' -f1,2 <<<$PATH)" "$BASH_IT/test/fixtures/go/go path/bin:$BASH_IT/test/fixtures/go/gopath/bin" -} - -@test 'plugins go: multiple entries in GOPATH, with escaped space' { - skip 'huh?' - { _command_exists go && go version &>/dev/null; } || skip 'golang not found' - setup_go_path "$BASH_IT/test/fixtures/go/gopath" - setup_go_path "$BASH_IT/test/fixtures/go/go path" - load ../../plugins/available/go.plugin - assert_equal "$(cut -d':' -f1,2 <<<$PATH)" "$BASH_IT/test/fixtures/go/go\ path/bin:$BASH_IT/test/fixtures/go/gopath/bin" -} +# shellcheck shell=bats + +load "${MAIN_BASH_IT_DIR?}/test/test_helper.bash" + +function local_setup_file() { + setup_libs "helpers" +} + +function setup_go_path() +{ + local go_path="${1}" + + # Make sure that the requested GO folder is available + assert_dir_exist "$go_path/bin" + + # Make sure that the requested GO folder is on the path + export GOPATH="$go_path:${GOPATH:-}" +} + +# We test `go version` in each test to account for users with goenv and no system go. + +@test 'ensure _bash-it-gopath-pathmunge is defined' { + { _command_exists go && go version &>/dev/null; } || skip 'golang not found' + load ../../plugins/available/go.plugin + run type -t _bash-it-gopath-pathmunge + assert_line 'function' +} + +@test 'plugins go: single entry in GOPATH' { + { _command_exists go && go version &>/dev/null; } || skip 'golang not found' + setup_go_path "$BASH_IT/test/fixtures/go/gopath" + load ../../plugins/available/go.plugin + assert_equal "$(cut -d':' -f1 <<<$PATH)" "$BASH_IT/test/fixtures/go/gopath/bin" +} + +@test 'plugins go: single entry in GOPATH, with space' { + { _command_exists go && go version &>/dev/null; } || skip 'golang not found' + setup_go_path "$BASH_IT/test/fixtures/go/go path" + load ../../plugins/available/go.plugin + assert_equal "$(cut -d':' -f1 <<<$PATH)" "$BASH_IT/test/fixtures/go/go path/bin" +} + +@test 'plugins go: single entry in GOPATH, with escaped space' { + skip 'huh?' + { _command_exists go && go version &>/dev/null; } || skip 'golang not found' + setup_go_path "$BASH_IT/test/fixtures/go/go\ path" + load ../../plugins/available/go.plugin + assert_equal "$(cut -d':' -f1 <<<$PATH)" "$BASH_IT/test/fixtures/go/go\ path/bin" +} + +@test 'plugins go: multiple entries in GOPATH' { + { _command_exists go && go version &>/dev/null; } || skip 'golang not found' + setup_go_path "$BASH_IT/test/fixtures/go/gopath" + setup_go_path "$BASH_IT/test/fixtures/go/gopath2" + load ../../plugins/available/go.plugin + assert_equal "$(cut -d':' -f1,2 <<<$PATH)" "$BASH_IT/test/fixtures/go/gopath2/bin:$BASH_IT/test/fixtures/go/gopath/bin" +} + +@test 'plugins go: multiple entries in GOPATH, with space' { + { _command_exists go && go version &>/dev/null; } || skip 'golang not found' + setup_go_path "$BASH_IT/test/fixtures/go/gopath" + setup_go_path "$BASH_IT/test/fixtures/go/go path" + load ../../plugins/available/go.plugin + assert_equal "$(cut -d':' -f1,2 <<<$PATH)" "$BASH_IT/test/fixtures/go/go path/bin:$BASH_IT/test/fixtures/go/gopath/bin" +} + +@test 'plugins go: multiple entries in GOPATH, with escaped space' { + skip 'huh?' + { _command_exists go && go version &>/dev/null; } || skip 'golang not found' + setup_go_path "$BASH_IT/test/fixtures/go/gopath" + setup_go_path "$BASH_IT/test/fixtures/go/go path" + load ../../plugins/available/go.plugin + assert_equal "$(cut -d':' -f1,2 <<<$PATH)" "$BASH_IT/test/fixtures/go/go\ path/bin:$BASH_IT/test/fixtures/go/gopath/bin" +} diff --git a/test/plugins/ruby.plugin.bats b/test/plugins/ruby.plugin.bats index 7bfc6455..4b10b4f5 100644 --- a/test/plugins/ruby.plugin.bats +++ b/test/plugins/ruby.plugin.bats @@ -1,31 +1,32 @@ -# shellcheck shell=bats - -load "${MAIN_BASH_IT_DIR?}/test/test_helper.bash" - -function local_setup_file() { - setup_libs "helpers" -} - -@test "plugins ruby: remove_gem is defined" { - run load "${BASH_IT?}/plugins/available/ruby.plugin.bash" - assert_success - load "${BASH_IT?}/plugins/available/ruby.plugin.bash" - - run type remove_gem - assert_line -n 1 "remove_gem () " -} - -@test "plugins ruby: PATH includes ~/.gem/ruby/bin" { - if ! type ruby >/dev/null; then - skip 'ruby not installed' - fi - - mkdir -p "$(ruby -e 'print Gem.user_dir')/bin" - - run load "${BASH_IT?}/plugins/available/ruby.plugin.bash" - assert_success - load "${BASH_IT?}/plugins/available/ruby.plugin.bash" - - local last_path_entry="$(tail -1 <<<"${PATH//:/$'\n'}")" - [[ "${last_path_entry}" == "$(ruby -e 'print Gem.user_dir')/bin" ]] -} +# shellcheck shell=bats + +load "${MAIN_BASH_IT_DIR?}/test/test_helper.bash" + +function local_setup_file() { + setup_libs "helpers" +} + +@test "plugins ruby: remove_gem is defined" { + run load "${BASH_IT?}/plugins/available/ruby.plugin.bash" + assert_success + load "${BASH_IT?}/plugins/available/ruby.plugin.bash" + + run type remove_gem + assert_line -n 1 "remove_gem () " +} + +@test "plugins ruby: PATH includes ~/.gem/ruby/bin" { + if ! type ruby >/dev/null + then + skip 'ruby not installed' + fi + + mkdir -p "$(ruby -e 'print Gem.user_dir')/bin" + + run load "${BASH_IT?}/plugins/available/ruby.plugin.bash" + assert_success + load "${BASH_IT?}/plugins/available/ruby.plugin.bash" + + local last_path_entry="$(tail -1 <<<"${PATH//:/$'\n'}")" + [[ "${last_path_entry}" == "$(ruby -e 'print Gem.user_dir')/bin" ]] +} diff --git a/test/plugins/xterm.plugin.bats b/test/plugins/xterm.plugin.bats index 4cb1ffda..430be231 100644 --- a/test/plugins/xterm.plugin.bats +++ b/test/plugins/xterm.plugin.bats @@ -1,42 +1,42 @@ -# shellcheck shell=bats - -load "${MAIN_BASH_IT_DIR?}/test/test_helper.bash" - -function local_setup_file() { - setup_libs "helpers" - load "${BASH_IT?}/plugins/available/xterm.plugin.bash" -} - -@test "plugins xterm: shorten command output" { - export SHORT_TERM_LINE=true - run _short-command "${BASH_IT}/test/fixtures/plugin/xterm/files"/* - assert_success - assert_output "${BASH_IT}/test/fixtures/plugin/xterm/files/arg0" -} - -@test "plugins xterm: full command output" { - export SHORT_TERM_LINE=false - run _short-command "${BASH_IT}/test/fixtures/plugin/xterm/files"/* - assert_success - assert_output "$(echo "${BASH_IT}/test/fixtures/plugin/xterm/files"/*)" -} - -@test "plugins xterm: shorten dirname output" { - export SHORT_TERM_LINE=true - run _short-dirname - assert_success - assert_output "$(basename "${PWD}")" -} - -@test "plugins xterm: full dirname output" { - export SHORT_TERM_LINE=false - run _short-dirname - assert_success - assert_output "${PWD}" -} - -@test "plugins xterm: set xterm title" { - run set_xterm_title title - assert_success - assert_output $'\033]0;title\007' -} +# shellcheck shell=bats + +load "${MAIN_BASH_IT_DIR?}/test/test_helper.bash" + +function local_setup_file() { + setup_libs "helpers" + load "${BASH_IT?}/plugins/available/xterm.plugin.bash" +} + +@test "plugins xterm: shorten command output" { + export SHORT_TERM_LINE=true + run _short-command "${BASH_IT}/test/fixtures/plugin/xterm/files"/* + assert_success + assert_output "${BASH_IT}/test/fixtures/plugin/xterm/files/arg0" +} + +@test "plugins xterm: full command output" { + export SHORT_TERM_LINE=false + run _short-command "${BASH_IT}/test/fixtures/plugin/xterm/files"/* + assert_success + assert_output "$(echo "${BASH_IT}/test/fixtures/plugin/xterm/files"/*)" +} + +@test "plugins xterm: shorten dirname output" { + export SHORT_TERM_LINE=true + run _short-dirname + assert_success + assert_output "$(basename "${PWD}")" +} + +@test "plugins xterm: full dirname output" { + export SHORT_TERM_LINE=false + run _short-dirname + assert_success + assert_output "${PWD}" +} + +@test "plugins xterm: set xterm title" { + run set_xterm_title title + assert_success + assert_output $'\033]0;title\007' +} diff --git a/test/run b/test/run index 78467366..37e7cf22 100755 --- a/test/run +++ b/test/run @@ -1,51 +1,56 @@ -#!/usr/bin/env bash -test_directory="$(cd "$(dirname "$0")" && pwd)" -bats_executable="${test_directory}/../test_lib/bats-core/bin/bats" - -# Locate ourselves for easy reference. -export MAIN_BASH_IT_DIR="${test_directory%/*}" -export MAIN_BASH_IT_GITDIR="${MAIN_BASH_IT_DIR}/.git" - -# Make sure BATS is available: -git submodule init && git submodule update - -# Warn user that tests run from the current git HEAD -if ! git diff --quiet; then - echo "${BASH_SOURCE##*/}: your worktree is dirty; uncommitted changes will *not* be tested!" -fi - -# Which tests do we run? -if [[ $# -eq '0' ]]; then - test_dirs=("${test_directory}"/{bash_it,completion,install,lib,plugins,themes}) -else - test_dirs=("$@") -fi - -# Make sure that the `parallel` command is installed, -# AND that it is the GNU version of `parallel`. -# If that is the case, try to guess the number of CPU cores, -# so we can run `bats` in parallel processing mode, which is a lot faster. -if command -v parallel &> /dev/null \ - && parallel -V &> /dev/null \ - && { parallel -V 2> /dev/null | grep -q '^GNU\>'; }; then - # Expect to run at least on a dual-core CPU; slightly degraded performance - # shouldn't matter otherwise. - declare -i -r test_jobs_default=2 - # shellcheck disable=SC2155 - declare -i -r test_jobs_effective="$( - if [[ "${TEST_JOBS:-detect}" = "detect" ]] \ - && command -v nproc &> /dev/null; then - nproc - elif [[ -n "${TEST_JOBS}" ]] \ - && [[ "${TEST_JOBS}" != "detect" ]]; then - echo "${TEST_JOBS}" - else - echo "${test_jobs_default}" - fi - )" - exec "$bats_executable" "${CI:+--tap}" --jobs "${test_jobs_effective}" \ - --no-parallelize-within-files "${test_dirs[@]}" -else - # Run `bats` in single-threaded mode. - exec "$bats_executable" "${CI:+--tap}" "${test_dirs[@]}" -fi +#!/usr/bin/env bash +test_directory="$(cd "$(dirname "$0")" && pwd)" +bats_executable="${test_directory}/../test_lib/bats-core/bin/bats" + +# Locate ourselves for easy reference. +export MAIN_BASH_IT_DIR="${test_directory%/*}" +export MAIN_BASH_IT_GITDIR="${MAIN_BASH_IT_DIR}/.git" + +# Make sure BATS is available: +git submodule init && git submodule update + +# Warn user that tests run from the current git HEAD +if ! git diff --quiet + then + echo "${BASH_SOURCE##*/}: your worktree is dirty; uncommitted changes will *not* be tested!" +fi + +# Which tests do we run? +if [[ $# -eq '0' ]] + then + test_dirs=("${test_directory}"/{bash_it,completion,install,lib,plugins,themes}) +else + test_dirs=("$@") +fi + +# Make sure that the `parallel` command is installed, +# AND that it is the GNU version of `parallel`. +# If that is the case, try to guess the number of CPU cores, +# so we can run `bats` in parallel processing mode, which is a lot faster. +if command -v parallel &> /dev/null \ + && parallel -V &> /dev/null \ + && { parallel -V 2> /dev/null | grep -q '^GNU\>'; } + then + # Expect to run at least on a dual-core CPU; slightly degraded performance + # shouldn't matter otherwise. + declare -i -r test_jobs_default=2 + # shellcheck disable=SC2155 + declare -i -r test_jobs_effective="$( + if [[ "${TEST_JOBS:-detect}" = "detect" ]] \ + && command -v nproc &> /dev/null + then + nproc + elif [[ -n "${TEST_JOBS}" ]] \ + && [[ "${TEST_JOBS}" != "detect" ]] + then + echo "${TEST_JOBS}" + else + echo "${test_jobs_default}" + fi + )" + exec "$bats_executable" "${CI:+--tap}" --jobs "${test_jobs_effective}" \ + --no-parallelize-within-files "${test_dirs[@]}" +else + # Run `bats` in single-threaded mode. + exec "$bats_executable" "${CI:+--tap}" "${test_dirs[@]}" +fi diff --git a/test/themes/base.theme.bats b/test/themes/base.theme.bats index 81b08a01..21cbfd78 100644 --- a/test/themes/base.theme.bats +++ b/test/themes/base.theme.bats @@ -1,73 +1,73 @@ -# shellcheck shell=bats - -load "${MAIN_BASH_IT_DIR?}/test/test_helper.bash" - -function local_setup_file() { - setup_libs "colors" #"theme" - load "${BASH_IT?}/themes/base.theme.bash" -} - -@test 'themes base: battery_percentage should not exist' { - run type -a battery_percentage &> /dev/null - assert_failure -} - -@test 'themes base: battery_percentage should exist if battery plugin loaded' { - load "${BASH_IT?}/plugins/available/battery.plugin.bash" - - run type -a battery_percentage &> /dev/null - assert_success -} - -@test 'themes base: battery_char should exist' { - run type -t battery_char - assert_success - assert_line "function" - - run battery_char - assert_line -n 0 "" -} - -@test 'themes base: battery_char should exist if battery plugin loaded' { - unset -f battery_char - - load "${BASH_IT?}/plugins/available/battery.plugin.bash" - run type -t battery_percentage - assert_success - assert_line "function" - - load "${BASH_IT?}/themes/base.theme.bash" - run type -t battery_char - assert_success - assert_line "function" - - run battery_char - assert_success - - run type -a battery_char - assert_output --partial 'THEME_BATTERY_PERCENTAGE_CHECK' -} - -@test 'themes base: battery_charge should exist' { - run type -a battery_charge &> /dev/null - assert_success - - run battery_charge - assert_success - assert_output "" -} - -@test 'themes base: battery_charge should exist if battery plugin loaded' { - unset -f battery_charge - load "${BASH_IT?}/plugins/available/battery.plugin.bash" - load "${BASH_IT?}/themes/base.theme.bash" - - run type -a battery_charge &> /dev/null - assert_success - - run battery_charge - assert_success - - run type -a battery_charge - assert_line ' no)' -} +# shellcheck shell=bats + +load "${MAIN_BASH_IT_DIR?}/test/test_helper.bash" + +function local_setup_file() { + setup_libs "colors" #"theme" + load "${BASH_IT?}/themes/base.theme.bash" +} + +@test 'themes base: battery_percentage should not exist' { + run type -a battery_percentage &> /dev/null + assert_failure +} + +@test 'themes base: battery_percentage should exist if battery plugin loaded' { + load "${BASH_IT?}/plugins/available/battery.plugin.bash" + + run type -a battery_percentage &> /dev/null + assert_success +} + +@test 'themes base: battery_char should exist' { + run type -t battery_char + assert_success + assert_line "function" + + run battery_char + assert_line -n 0 "" +} + +@test 'themes base: battery_char should exist if battery plugin loaded' { + unset -f battery_char + + load "${BASH_IT?}/plugins/available/battery.plugin.bash" + run type -t battery_percentage + assert_success + assert_line "function" + + load "${BASH_IT?}/themes/base.theme.bash" + run type -t battery_char + assert_success + assert_line "function" + + run battery_char + assert_success + + run type -a battery_char + assert_output --partial 'THEME_BATTERY_PERCENTAGE_CHECK' +} + +@test 'themes base: battery_charge should exist' { + run type -a battery_charge &> /dev/null + assert_success + + run battery_charge + assert_success + assert_output "" +} + +@test 'themes base: battery_charge should exist if battery plugin loaded' { + unset -f battery_charge + load "${BASH_IT?}/plugins/available/battery.plugin.bash" + load "${BASH_IT?}/themes/base.theme.bash" + + run type -a battery_charge &> /dev/null + assert_success + + run battery_charge + assert_success + + run type -a battery_charge + assert_line ' no)' +} diff --git a/test/themes/base.theme.git.bats b/test/themes/base.theme.git.bats index b2bc7c5a..9fb95573 100644 --- a/test/themes/base.theme.git.bats +++ b/test/themes/base.theme.git.bats @@ -1,387 +1,387 @@ -# shellcheck shell=bats -# shellcheck disable=SC2034 -# shellcheck disable=SC2016 - -load "${MAIN_BASH_IT_DIR?}/test/test_helper.bash" - -function local_setup_file() { - setup_libs "colors" #"theme" - load "${BASH_IT?}/themes/base.theme.bash" - load "${BASH_IT?}/themes/githelpers.theme.bash" -} - -add_commit() { - local file_name="general-${RANDOM}" - touch "${file_name}" - echo "" >> "${file_name}" - git add "${file_name}" - git commit -m"message" -} - -enter_new_git_repo() { - repo="$(setup_repo)" - pushd "${repo}" -} - -setup_repo() { - upstream="$(mktemp -d)" - pushd "$upstream" > /dev/null - git init . > /dev/null - - echo "$upstream" -} - -setup_repo_with_upstream() { - upstream="$(setup_repo)" - pushd "$upstream" > /dev/null - add_commit > /dev/null - git checkout -b branch-two - git checkout -b gone-branch - git checkout master - popd > /dev/null - - downstream="$(setup_repo)" - pushd "$downstream" > /dev/null - add_commit > /dev/null - git remote add my-remote "$upstream" - git fetch my-remote - git branch -u my-remote/master > /dev/null - popd > /dev/null - - pushd "$upstream" > /dev/null - git branch -d gone-branch > /dev/null - popd > /dev/null - - pushd "$downstream" > /dev/null - git fetch my-remote - popd > /dev/null - - echo "$downstream" -} - -@test 'themes base: Git: when tracking a remote branch: it shows the commits ahead and behind' { - pre="\$(_git-friendly-ref)" - - remote="$(setup_repo)" - pushd "$remote" - add_commit - add_commit - popd - - clone="$(mktemp -d)" - pushd "$clone" - git clone "$remote" clone - cd clone - - SCM_GIT_SHOW_COMMIT_COUNT=true - - git_prompt_vars - assert_equal "$SCM_BRANCH" "${pre}" - - add_commit - - git_prompt_vars - assert_equal "$SCM_BRANCH" "${pre} ↑1" - - add_commit - - git_prompt_vars - assert_equal "$SCM_BRANCH" "${pre} ↑2" - popd - - pushd "$remote" - add_commit - add_commit - add_commit - popd - - pushd "$clone/clone" - git fetch - - git_prompt_vars - assert_equal "$SCM_BRANCH" "${pre} ↑2 ↓3" - - git reset HEAD~2 --hard - - SCM_GIT_BEHIND_CHAR="↓" - git_prompt_vars - assert_equal "$SCM_BRANCH" "${pre} ↓3" -} - -@test 'themes base: Git: when stashes exist: it shows the number of stashes' { - pre="\$(_git-friendly-ref)" - - enter_new_git_repo - add_commit - - touch file - git add file - git stash - - SCM_GIT_SHOW_STASH_INFO=true - - git_prompt_vars - assert_equal "$SCM_BRANCH" "${pre} {1}" - - touch file2 - git add file2 - git stash - - git_prompt_vars - assert_equal "$SCM_BRANCH" "${pre} {2}" -} - -@test 'themes base: Git: remote info: when there is no upstream remote: is empty' { - pre="\$(_git-friendly-ref)" - post=" ↑1 ↓1" - - enter_new_git_repo - add_commit - - git_prompt_vars - assert_equal "$SCM_BRANCH" "${pre}" -} - -@test 'themes base: Git: remote info: when SCM_GIT_SHOW_REMOTE_INFO is true: includes the remote' { - pre="\$(_git-friendly-ref) → " - eval_pre="master → " - post=" ↑1 ↓1" - - repo="$(setup_repo_with_upstream)" - pushd "${repo}" - - SCM_GIT_SHOW_REMOTE_INFO=true - SCM_GIT_SHOW_COMMIT_COUNT=true - - git_prompt_vars - assert_equal "$SCM_BRANCH" "${pre}my-remote${post}" - - git branch -u my-remote/branch-two - - git_prompt_vars - assert_equal "$SCM_BRANCH" "${pre}\$(_git-upstream)${post}" - assert_equal "$(eval "echo \"$SCM_BRANCH\"")" "${eval_pre}my-remote/branch-two${post}" -} - -@test 'themes base: Git: remote info: when SCM_GIT_SHOW_REMOTE_INFO is auto: includes the remote when more than one remote' { - pre="\$(_git-friendly-ref)" - eval_pre="master" - post=" ↑1 ↓1" - - repo="$(setup_repo_with_upstream)" - pushd "${repo}" - - SCM_GIT_SHOW_REMOTE_INFO=auto - SCM_GIT_SHOW_COMMIT_COUNT=true - - git_prompt_vars - assert_equal "$SCM_BRANCH" "${pre}${post}" - - pre="${pre} → " - eval_pre="${eval_pre} → " - git branch -u my-remote/branch-two - - git_prompt_vars - assert_equal "$SCM_BRANCH" "${pre}\$(_git-upstream-branch)${post}" - assert_equal "$(eval "echo \"$SCM_BRANCH\"")" "${eval_pre}branch-two${post}" - - git remote add second-remote "$(mktemp -d)" - git branch -u my-remote/master - - git_prompt_vars - assert_equal "$SCM_BRANCH" "${pre}my-remote${post}" - - git branch -u my-remote/branch-two - - git_prompt_vars - assert_equal "$SCM_BRANCH" "${pre}\$(_git-upstream)${post}" - assert_equal "$(eval "echo \"$SCM_BRANCH\"")" "${eval_pre}my-remote/branch-two${post}" -} - -@test 'themes base: Git: remote info: when SCM_GIT_SHOW_REMOTE_INFO is false: never include the remote' { - pre="\$(_git-friendly-ref)" - eval_pre="master" - post=" ↑1 ↓1" - - repo="$(setup_repo_with_upstream)" - pushd "${repo}" - git remote add second-remote "$(mktemp -d)" - git remote add third-remote "$(mktemp -d)" - - SCM_GIT_SHOW_REMOTE_INFO=false - SCM_GIT_SHOW_COMMIT_COUNT=true - - git_prompt_vars - assert_equal "$SCM_BRANCH" "${pre}${post}" - - pre="${pre} → " - eval_pre="${eval_pre} → " - git branch -u my-remote/branch-two - - git_prompt_vars - assert_equal "$SCM_BRANCH" "${pre}\$(_git-upstream-branch)${post}" - assert_equal "$(eval "echo \"$SCM_BRANCH\"")" "${eval_pre}branch-two${post}" -} - -@test 'themes base: Git: remote info: when showing remote info: show if upstream branch is gone' { - pre="\$(_git-friendly-ref)" - post=" ↑1 ↓1" - - repo="$(setup_repo_with_upstream)" - pushd "${repo}" - - SCM_GIT_SHOW_REMOTE_INFO=true - SCM_GIT_SHOW_COMMIT_COUNT=true - - git_prompt_vars - assert_equal "$SCM_BRANCH" "${pre} → my-remote${post}" - - git checkout gone-branch - git fetch --prune --all - - git_prompt_vars - assert_equal "$SCM_BRANCH" "${pre} ⇢ my-remote" -} - -@test 'themes base: Git: git friendly ref: when a branch is checked out: shows that branch' { - enter_new_git_repo - - git_prompt_vars - assert_equal "$(eval "echo \"$SCM_BRANCH\"")" "master" - - git checkout -b second-branch - - git_prompt_vars - assert_equal "$(eval "echo \"$SCM_BRANCH\"")" "second-branch" -} - -@test 'themes base: Git: git friendly ref: when a branch is not checked out: shows that branch' { - enter_new_git_repo - - git_prompt_vars - assert_equal "$(eval "echo \"$SCM_BRANCH\"")" "master" - - git checkout -b second-branch - - git_prompt_vars - assert_equal "$(eval "echo \"$SCM_BRANCH\"")" "second-branch" -} - -@test 'themes base: Git: git friendly ref: when detached: commit has branch and tag: show a tag' { - enter_new_git_repo - add_commit - git tag first-tag - git checkout -b second-branch - add_commit - git checkout HEAD~1 - - git_prompt_vars - assert_equal "$(eval "echo \"$SCM_BRANCH\"")" "tag:first-tag" -} - -@test 'themes base: Git: git friendly ref: when detached: commit has branch and no tag: show a branch' { - enter_new_git_repo - add_commit - git checkout -b second-branch - add_commit - git checkout HEAD~1 - - git_prompt_vars - assert_equal "$(eval "echo \"$SCM_BRANCH\"")" "detached:master" -} - -@test 'themes base: Git: git friendly ref: when detached with no branch or tag: commit is parent to a named ref: show relative name' { - enter_new_git_repo - add_commit - add_commit - git checkout HEAD~1 - - git_prompt_vars - assert_equal "$(eval "echo \"$SCM_BRANCH\"")" "detached:master~1" -} - -@test 'themes base: Git: git friendly ref: when detached with no branch or tag: commit is not parent to a named ref: show short sha' { - enter_new_git_repo - add_commit - add_commit - sha="$(git rev-parse --short HEAD)" - git reset --hard HEAD~1 - git checkout "$sha" - - git_prompt_vars - assert_equal "$(eval "echo \"$SCM_BRANCH\"")" "detached:$sha" -} - -@test 'themes base: Git: git friendly ref: shows staged, unstaged, and untracked file counts' { - pre="\$(_git-friendly-ref)" - - enter_new_git_repo - echo "line1" > file1 - echo "line1" > file2 - echo "line1" > file3 - echo "line1" > file4 - git add . - git commit -m"commit1" - - git_prompt_vars - assert_equal "$SCM_STATE" " ✓" - - echo "line2" >> file1 - git add file1 - - SCM_GIT_SHOW_DETAILS=true - - git_prompt_vars - assert_equal "$SCM_BRANCH" "${pre} S:1" - assert_equal "$SCM_STATE" " ✗" - assert_equal "$SCM_DIRTY" "3" - - echo "line2" >> file2 - echo "line2" >> file3 - echo "line2" >> file4 - - git_prompt_vars - assert_equal "$SCM_BRANCH" "${pre} S:1 U:3" - assert_equal "$SCM_DIRTY" "2" - - echo "line1" > newfile5 - echo "line1" > newfile6 - - git_prompt_vars - assert_equal "$SCM_BRANCH" "${pre} S:1 U:3 ?:2" - assert_equal "$SCM_DIRTY" "1" - - git config bash-it.hide-status 1 - - SCM_DIRTY='nope' - git_prompt_vars - assert_equal "$SCM_BRANCH" "${pre}" - assert_equal "$SCM_DIRTY" "nope" -} - -@test 'themes base: Git: git user info: shows user initials' { - pre="\$(_git-friendly-ref)" - - enter_new_git_repo - git config user.name "Cool User" - - git_prompt_vars - assert_equal "$SCM_BRANCH" "${pre}" - - SCM_GIT_SHOW_CURRENT_USER=true - - git_prompt_vars - assert_equal "$SCM_BRANCH" "${pre} ☺︎ cu" - - git config user.name "Çool Üser" - - git_prompt_vars - assert_equal "$SCM_BRANCH" "${pre} ☺︎ çü" - - # show initials set by `git pair` - - git config user.initials "ab cd" - - git_prompt_vars - assert_equal "$SCM_BRANCH" "${pre} ☺︎ ab+cd" -} +# shellcheck shell=bats +# shellcheck disable=SC2034 +# shellcheck disable=SC2016 + +load "${MAIN_BASH_IT_DIR?}/test/test_helper.bash" + +function local_setup_file() { + setup_libs "colors" #"theme" + load "${BASH_IT?}/themes/base.theme.bash" + load "${BASH_IT?}/themes/githelpers.theme.bash" +} + +add_commit() { + local file_name="general-${RANDOM}" + touch "${file_name}" + echo "" >> "${file_name}" + git add "${file_name}" + git commit -m"message" +} + +enter_new_git_repo() { + repo="$(setup_repo)" + pushd "${repo}" +} + +setup_repo() { + upstream="$(mktemp -d)" + pushd "$upstream" > /dev/null + git init . > /dev/null + + echo "$upstream" +} + +setup_repo_with_upstream() { + upstream="$(setup_repo)" + pushd "$upstream" > /dev/null + add_commit > /dev/null + git checkout -b branch-two + git checkout -b gone-branch + git checkout master + popd > /dev/null + + downstream="$(setup_repo)" + pushd "$downstream" > /dev/null + add_commit > /dev/null + git remote add my-remote "$upstream" + git fetch my-remote + git branch -u my-remote/master > /dev/null + popd > /dev/null + + pushd "$upstream" > /dev/null + git branch -d gone-branch > /dev/null + popd > /dev/null + + pushd "$downstream" > /dev/null + git fetch my-remote + popd > /dev/null + + echo "$downstream" +} + +@test 'themes base: Git: when tracking a remote branch: it shows the commits ahead and behind' { + pre="\$(_git-friendly-ref)" + + remote="$(setup_repo)" + pushd "$remote" + add_commit + add_commit + popd + + clone="$(mktemp -d)" + pushd "$clone" + git clone "$remote" clone + cd clone + + SCM_GIT_SHOW_COMMIT_COUNT=true + + git_prompt_vars + assert_equal "$SCM_BRANCH" "${pre}" + + add_commit + + git_prompt_vars + assert_equal "$SCM_BRANCH" "${pre} ↑1" + + add_commit + + git_prompt_vars + assert_equal "$SCM_BRANCH" "${pre} ↑2" + popd + + pushd "$remote" + add_commit + add_commit + add_commit + popd + + pushd "$clone/clone" + git fetch + + git_prompt_vars + assert_equal "$SCM_BRANCH" "${pre} ↑2 ↓3" + + git reset HEAD~2 --hard + + SCM_GIT_BEHIND_CHAR="↓" + git_prompt_vars + assert_equal "$SCM_BRANCH" "${pre} ↓3" +} + +@test 'themes base: Git: when stashes exist: it shows the number of stashes' { + pre="\$(_git-friendly-ref)" + + enter_new_git_repo + add_commit + + touch file + git add file + git stash + + SCM_GIT_SHOW_STASH_INFO=true + + git_prompt_vars + assert_equal "$SCM_BRANCH" "${pre} {1}" + + touch file2 + git add file2 + git stash + + git_prompt_vars + assert_equal "$SCM_BRANCH" "${pre} {2}" +} + +@test 'themes base: Git: remote info: when there is no upstream remote: is empty' { + pre="\$(_git-friendly-ref)" + post=" ↑1 ↓1" + + enter_new_git_repo + add_commit + + git_prompt_vars + assert_equal "$SCM_BRANCH" "${pre}" +} + +@test 'themes base: Git: remote info: when SCM_GIT_SHOW_REMOTE_INFO is true: includes the remote' { + pre="\$(_git-friendly-ref) → " + eval_pre="master → " + post=" ↑1 ↓1" + + repo="$(setup_repo_with_upstream)" + pushd "${repo}" + + SCM_GIT_SHOW_REMOTE_INFO=true + SCM_GIT_SHOW_COMMIT_COUNT=true + + git_prompt_vars + assert_equal "$SCM_BRANCH" "${pre}my-remote${post}" + + git branch -u my-remote/branch-two + + git_prompt_vars + assert_equal "$SCM_BRANCH" "${pre}\$(_git-upstream)${post}" + assert_equal "$(eval "echo \"$SCM_BRANCH\"")" "${eval_pre}my-remote/branch-two${post}" +} + +@test 'themes base: Git: remote info: when SCM_GIT_SHOW_REMOTE_INFO is auto: includes the remote when more than one remote' { + pre="\$(_git-friendly-ref)" + eval_pre="master" + post=" ↑1 ↓1" + + repo="$(setup_repo_with_upstream)" + pushd "${repo}" + + SCM_GIT_SHOW_REMOTE_INFO=auto + SCM_GIT_SHOW_COMMIT_COUNT=true + + git_prompt_vars + assert_equal "$SCM_BRANCH" "${pre}${post}" + + pre="${pre} → " + eval_pre="${eval_pre} → " + git branch -u my-remote/branch-two + + git_prompt_vars + assert_equal "$SCM_BRANCH" "${pre}\$(_git-upstream-branch)${post}" + assert_equal "$(eval "echo \"$SCM_BRANCH\"")" "${eval_pre}branch-two${post}" + + git remote add second-remote "$(mktemp -d)" + git branch -u my-remote/master + + git_prompt_vars + assert_equal "$SCM_BRANCH" "${pre}my-remote${post}" + + git branch -u my-remote/branch-two + + git_prompt_vars + assert_equal "$SCM_BRANCH" "${pre}\$(_git-upstream)${post}" + assert_equal "$(eval "echo \"$SCM_BRANCH\"")" "${eval_pre}my-remote/branch-two${post}" +} + +@test 'themes base: Git: remote info: when SCM_GIT_SHOW_REMOTE_INFO is false: never include the remote' { + pre="\$(_git-friendly-ref)" + eval_pre="master" + post=" ↑1 ↓1" + + repo="$(setup_repo_with_upstream)" + pushd "${repo}" + git remote add second-remote "$(mktemp -d)" + git remote add third-remote "$(mktemp -d)" + + SCM_GIT_SHOW_REMOTE_INFO=false + SCM_GIT_SHOW_COMMIT_COUNT=true + + git_prompt_vars + assert_equal "$SCM_BRANCH" "${pre}${post}" + + pre="${pre} → " + eval_pre="${eval_pre} → " + git branch -u my-remote/branch-two + + git_prompt_vars + assert_equal "$SCM_BRANCH" "${pre}\$(_git-upstream-branch)${post}" + assert_equal "$(eval "echo \"$SCM_BRANCH\"")" "${eval_pre}branch-two${post}" +} + +@test 'themes base: Git: remote info: when showing remote info: show if upstream branch is gone' { + pre="\$(_git-friendly-ref)" + post=" ↑1 ↓1" + + repo="$(setup_repo_with_upstream)" + pushd "${repo}" + + SCM_GIT_SHOW_REMOTE_INFO=true + SCM_GIT_SHOW_COMMIT_COUNT=true + + git_prompt_vars + assert_equal "$SCM_BRANCH" "${pre} → my-remote${post}" + + git checkout gone-branch + git fetch --prune --all + + git_prompt_vars + assert_equal "$SCM_BRANCH" "${pre} ⇢ my-remote" +} + +@test 'themes base: Git: git friendly ref: when a branch is checked out: shows that branch' { + enter_new_git_repo + + git_prompt_vars + assert_equal "$(eval "echo \"$SCM_BRANCH\"")" "master" + + git checkout -b second-branch + + git_prompt_vars + assert_equal "$(eval "echo \"$SCM_BRANCH\"")" "second-branch" +} + +@test 'themes base: Git: git friendly ref: when a branch is not checked out: shows that branch' { + enter_new_git_repo + + git_prompt_vars + assert_equal "$(eval "echo \"$SCM_BRANCH\"")" "master" + + git checkout -b second-branch + + git_prompt_vars + assert_equal "$(eval "echo \"$SCM_BRANCH\"")" "second-branch" +} + +@test 'themes base: Git: git friendly ref: when detached: commit has branch and tag: show a tag' { + enter_new_git_repo + add_commit + git tag first-tag + git checkout -b second-branch + add_commit + git checkout HEAD~1 + + git_prompt_vars + assert_equal "$(eval "echo \"$SCM_BRANCH\"")" "tag:first-tag" +} + +@test 'themes base: Git: git friendly ref: when detached: commit has branch and no tag: show a branch' { + enter_new_git_repo + add_commit + git checkout -b second-branch + add_commit + git checkout HEAD~1 + + git_prompt_vars + assert_equal "$(eval "echo \"$SCM_BRANCH\"")" "detached:master" +} + +@test 'themes base: Git: git friendly ref: when detached with no branch or tag: commit is parent to a named ref: show relative name' { + enter_new_git_repo + add_commit + add_commit + git checkout HEAD~1 + + git_prompt_vars + assert_equal "$(eval "echo \"$SCM_BRANCH\"")" "detached:master~1" +} + +@test 'themes base: Git: git friendly ref: when detached with no branch or tag: commit is not parent to a named ref: show short sha' { + enter_new_git_repo + add_commit + add_commit + sha="$(git rev-parse --short HEAD)" + git reset --hard HEAD~1 + git checkout "$sha" + + git_prompt_vars + assert_equal "$(eval "echo \"$SCM_BRANCH\"")" "detached:$sha" +} + +@test 'themes base: Git: git friendly ref: shows staged, unstaged, and untracked file counts' { + pre="\$(_git-friendly-ref)" + + enter_new_git_repo + echo "line1" > file1 + echo "line1" > file2 + echo "line1" > file3 + echo "line1" > file4 + git add . + git commit -m"commit1" + + git_prompt_vars + assert_equal "$SCM_STATE" " ✓" + + echo "line2" >> file1 + git add file1 + + SCM_GIT_SHOW_DETAILS=true + + git_prompt_vars + assert_equal "$SCM_BRANCH" "${pre} S:1" + assert_equal "$SCM_STATE" " ✗" + assert_equal "$SCM_DIRTY" "3" + + echo "line2" >> file2 + echo "line2" >> file3 + echo "line2" >> file4 + + git_prompt_vars + assert_equal "$SCM_BRANCH" "${pre} S:1 U:3" + assert_equal "$SCM_DIRTY" "2" + + echo "line1" > newfile5 + echo "line1" > newfile6 + + git_prompt_vars + assert_equal "$SCM_BRANCH" "${pre} S:1 U:3 ?:2" + assert_equal "$SCM_DIRTY" "1" + + git config bash-it.hide-status 1 + + SCM_DIRTY='nope' + git_prompt_vars + assert_equal "$SCM_BRANCH" "${pre}" + assert_equal "$SCM_DIRTY" "nope" +} + +@test 'themes base: Git: git user info: shows user initials' { + pre="\$(_git-friendly-ref)" + + enter_new_git_repo + git config user.name "Cool User" + + git_prompt_vars + assert_equal "$SCM_BRANCH" "${pre}" + + SCM_GIT_SHOW_CURRENT_USER=true + + git_prompt_vars + assert_equal "$SCM_BRANCH" "${pre} ☺︎ cu" + + git config user.name "Çool Üser" + + git_prompt_vars + assert_equal "$SCM_BRANCH" "${pre} ☺︎ çü" + + # show initials set by `git pair` + + git config user.initials "ab cd" + + git_prompt_vars + assert_equal "$SCM_BRANCH" "${pre} ☺︎ ab+cd" +} diff --git a/test/themes/base.theme.svn.bats b/test/themes/base.theme.svn.bats index 360e8636..42dc90ca 100644 --- a/test/themes/base.theme.svn.bats +++ b/test/themes/base.theme.svn.bats @@ -1,106 +1,106 @@ -# shellcheck shell=bats - -load "${MAIN_BASH_IT_DIR?}/test/test_helper.bash" - -function local_setup_file() { - setup_libs "colors" #"theme" - load "${BASH_IT?}/themes/base.theme.bash" -} - -function setup_repo { - upstream="$(mktemp -d)" - pushd "$upstream" > /dev/null - # Create a dummy SVN folder - this will not work with an actual `svn` command, - # but will be enough to trigger the SVN check in the base theme. - mkdir .svn - - echo "$upstream" -} - -function setup_svn_path { - local svn_path="$1" - - # Make sure that the requested SVN script is available - assert_file_exist "$svn_path/svn" - - # Make sure that the requested SVN script is on the path - export PATH="$svn_path:/usr/bin:/bin:/usr/sbin" -} - -@test 'themes base: SVN: detect SVN repo' { - repo="$(setup_repo)" - pushd "$repo" - - setup_svn_path "$BASH_IT/test/fixtures/svn/working" - - # Init the base theme again so that the working SVN script is detected - _bash_it_appearance_scm_init - - scm - # Make sure that the SVN command is used - assert_equal "$SCM" "$SCM_SVN" -} - -@test 'themes base: SVN: detect SVN repo even from a subfolder' { - repo="$(setup_repo)" - pushd "$repo" - - mkdir foo - pushd foo - - setup_svn_path "$BASH_IT/test/fixtures/svn/working" - - # init the base theme again so that the working SVN script is detected - _bash_it_appearance_scm_init - - scm - # Make sure that the SVN command is used - assert_equal "$SCM" "$SCM_SVN" -} - -@test 'themes base: SVN: no SCM if no .svn folder can be found' { - repo="$(setup_repo)" - pushd "$repo" - - rm -rf .svn - - setup_svn_path "$BASH_IT/test/fixtures/svn/working" - - # Init the base theme again so that the working SVN script is detected - _bash_it_appearance_scm_init - - scm - # Make sure that no SVN command is used - assert_equal "$SCM" "$SCM_NONE" -} - -@test 'themes base: SVN: ignore SVN repo when using broken SVN command' { - repo="$(setup_repo)" - pushd "$repo" - - setup_svn_path "$BASH_IT/test/fixtures/svn/broken" - - # Init the base theme again so that the broken SVN script is detected - _bash_it_appearance_scm_init - - scm - # Make sure that no SVN command is not used - assert_equal "$SCM" "$SCM_NONE" -} - -@test 'themes base: SVN: ignore SVN repo even from a subfolder when using a broken SVN' { - repo="$(setup_repo)" - pushd "$repo" - - mkdir foo - pushd foo - - setup_svn_path "$BASH_IT/test/fixtures/svn/broken" - - # Init the base theme again so that the broken SVN script is detected - _bash_it_appearance_scm_init - - scm - # Make sure that no SVN command is used - assert_equal "$SCM" "$SCM_NONE" -} +# shellcheck shell=bats + +load "${MAIN_BASH_IT_DIR?}/test/test_helper.bash" + +function local_setup_file() { + setup_libs "colors" #"theme" + load "${BASH_IT?}/themes/base.theme.bash" +} + +function setup_repo { + upstream="$(mktemp -d)" + pushd "$upstream" > /dev/null + # Create a dummy SVN folder - this will not work with an actual `svn` command, + # but will be enough to trigger the SVN check in the base theme. + mkdir .svn + + echo "$upstream" +} + +function setup_svn_path { + local svn_path="${1}" + + # Make sure that the requested SVN script is available + assert_file_exist "$svn_path/svn" + + # Make sure that the requested SVN script is on the path + export PATH="$svn_path:/usr/bin:/bin:/usr/sbin" +} + +@test 'themes base: SVN: detect SVN repo' { + repo="$(setup_repo)" + pushd "$repo" + + setup_svn_path "$BASH_IT/test/fixtures/svn/working" + + # Init the base theme again so that the working SVN script is detected + _bash_it_appearance_scm_init + + scm + # Make sure that the SVN command is used + assert_equal "$SCM" "$SCM_SVN" +} + +@test 'themes base: SVN: detect SVN repo even from a subfolder' { + repo="$(setup_repo)" + pushd "$repo" + + mkdir foo + pushd foo + + setup_svn_path "$BASH_IT/test/fixtures/svn/working" + + # init the base theme again so that the working SVN script is detected + _bash_it_appearance_scm_init + + scm + # Make sure that the SVN command is used + assert_equal "$SCM" "$SCM_SVN" +} + +@test 'themes base: SVN: no SCM if no .svn folder can be found' { + repo="$(setup_repo)" + pushd "$repo" + + rm -rf .svn + + setup_svn_path "$BASH_IT/test/fixtures/svn/working" + + # Init the base theme again so that the working SVN script is detected + _bash_it_appearance_scm_init + + scm + # Make sure that no SVN command is used + assert_equal "$SCM" "$SCM_NONE" +} + +@test 'themes base: SVN: ignore SVN repo when using broken SVN command' { + repo="$(setup_repo)" + pushd "$repo" + + setup_svn_path "$BASH_IT/test/fixtures/svn/broken" + + # Init the base theme again so that the broken SVN script is detected + _bash_it_appearance_scm_init + + scm + # Make sure that no SVN command is not used + assert_equal "$SCM" "$SCM_NONE" +} + +@test 'themes base: SVN: ignore SVN repo even from a subfolder when using a broken SVN' { + repo="$(setup_repo)" + pushd "$repo" + + mkdir foo + pushd foo + + setup_svn_path "$BASH_IT/test/fixtures/svn/broken" + + # Init the base theme again so that the broken SVN script is detected + _bash_it_appearance_scm_init + + scm + # Make sure that no SVN command is used + assert_equal "$SCM" "$SCM_NONE" +} diff --git a/themes/agnoster/agnoster.theme.bash b/themes/agnoster/agnoster.theme.bash index d5bac5ca..46feb507 100644 --- a/themes/agnoster/agnoster.theme.bash +++ b/themes/agnoster/agnoster.theme.bash @@ -36,7 +36,8 @@ # then add the following to your .bashrc: # export THEME=$HOME/.bash/themes/agnoster-bash/agnoster.bash -# if [[ -f $THEME ]]; then +# if [[ -f $THEME ]] + then # export DEFAULT_USER=`whoami` # source $THEME # fi @@ -70,8 +71,9 @@ PROMPT_DIRTRIM=2 # bash4 and above ###################################################################### DEBUG=0 -debug() { - if [[ ${DEBUG} -ne 0 ]]; then +function debug() { + if [[ ${DEBUG} -ne 0 ]] + then echo >&2 -e "$@" fi } @@ -87,8 +89,8 @@ RIGHT_SEPARATOR='' LEFT_SUBSEG='' RIGHT_SUBSEG='' -text_effect() { - case "$1" in +function text_effect() { + case "${1}" in reset) echo 0 ;; bold) echo 1 ;; underline) echo 4 ;; @@ -98,8 +100,8 @@ text_effect() { # to add colors, see # http://bitmote.com/index.php?post/2012/11/19/Using-ANSI-Color-Codes-to-Colorize-Your-Bash-Prompt-on-Linux # under the "256 (8-bit) Colors" section, and follow the example for orange below -fg_color() { - case "$1" in +function fg_color() { + case "${1}" in black) echo 30 ;; red) echo 31 ;; green) echo 32 ;; @@ -112,8 +114,8 @@ fg_color() { esac } -bg_color() { - case "$1" in +function bg_color() { + case "${1}" in black) echo 40 ;; red) echo 41 ;; green) echo 42 ;; @@ -129,7 +131,7 @@ bg_color() { # TIL: declare is global not local, so best use a different name # for codes (mycodes) as otherwise it'll clobber the original. # this changes from BASH v3 to BASH v4. -ansi() { +function ansi() { local seq declare -a mycodes=("${!1}") @@ -137,7 +139,8 @@ ansi() { seq="" for ((i = 0; i < ${#mycodes[@]}; i++)); do - if [[ -n $seq ]]; then + if [[ -n $seq ]] + then seq="${seq};" fi seq="${seq}${mycodes[$i]}" @@ -147,14 +150,14 @@ ansi() { # PR="$PR\[\033[${seq}m\]" } -ansi_single() { - echo -ne '\[\033['"$1"'m\]' +function ansi_single() { + echo -ne '\[\033['"${1}"'m\]' } # Begin a segment # Takes two arguments, background and foreground. Both can be omitted, # rendering default background/foreground. -prompt_segment() { +function prompt_segment() { local bg fg declare -a codes @@ -164,16 +167,19 @@ prompt_segment() { # if it did anything, but it messed up things like # prompt_status - Erik 1/14/17 - # if [[ -z $1 || ( -z $2 && $2 != default ) ]]; then + # if [[ -z $1 || ( -z $2 && $2 != default ) ]] + then codes=("${codes[@]}" "$(text_effect reset)") # fi - if [[ -n $1 ]]; then - bg=$(bg_color "$1") + if [[ -n $1 ]] + then + bg=$(bg_color "${1}") codes=("${codes[@]}" "$bg") debug "Added $bg as background to codes" fi - if [[ -n $2 ]]; then - fg=$(fg_color "$2") + if [[ -n $2 ]] + then + fg=$(fg_color "${2}") codes=("${codes[@]}" "$fg") debug "Added $fg as foreground to codes" fi @@ -181,8 +187,9 @@ prompt_segment() { debug "Codes: " # declare -p codes - if [[ $CURRENT_BG != NONE && $1 != "$CURRENT_BG" ]]; then - declare -a intermediate=("$(fg_color "$CURRENT_BG")" "$(bg_color "$1")") + if [[ $CURRENT_BG != NONE && $1 != "$CURRENT_BG" ]] + then + 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[@])" @@ -196,8 +203,9 @@ prompt_segment() { } # End the prompt, closing any open segments -prompt_end() { - if [[ -n $CURRENT_BG ]]; then +function prompt_end() { + if [[ -n $CURRENT_BG ]] + then declare -a codes=("$(text_effect reset)" "$(fg_color "$CURRENT_BG")") PR="$PR $(ansi codes[@])$SEGMENT_SEPARATOR" fi @@ -207,8 +215,9 @@ prompt_end() { } ### virtualenv prompt -prompt_virtualenv() { - if [[ -n $VIRTUAL_ENV ]]; then +function prompt_virtualenv() { + if [[ -n $VIRTUAL_ENV ]] + then color=cyan prompt_segment $color "$PRIMARY_FG" ve=$(basename "$VIRTUAL_ENV") @@ -220,33 +229,36 @@ prompt_virtualenv() { # Each component will draw itself, and hide itself if no information needs to be shown # Context: user@hostname (who am I and where am I) -prompt_context() { +function prompt_context() { local user="${USER:-${LOGNAME:?}}" - if [[ $user != "$DEFAULT_USER" || -n $SSH_CLIENT ]]; then + if [[ $user != "$DEFAULT_USER" || -n $SSH_CLIENT ]] + then prompt_segment black default "$user@\h" fi } # prints history followed by HH:MM, useful for remembering what # we did previously -prompt_histdt() { +function prompt_histdt() { prompt_segment black default "\! [\A]" } -git_status_dirty() { +function git_status_dirty() { dirty=$(git status -s 2> /dev/null | tail -n 1) [[ -n $dirty ]] && echo " ●" } # Git: branch/detached head, dirty status -prompt_git() { +function prompt_git() { local ref dirty - if git rev-parse --is-inside-work-tree > /dev/null 2>&1; then + if git rev-parse --is-inside-work-tree > /dev/null 2>&1 + then ZSH_THEME_GIT_PROMPT_DIRTY='±' dirty=$(git_status_dirty) ref=$(git symbolic-ref HEAD 2> /dev/null) || ref="➦ $(git show-ref --head -s --abbrev | head -n1 2> /dev/null)" - if [[ -n $dirty ]]; then + if [[ -n $dirty ]] + then prompt_segment yellow black else prompt_segment green black @@ -256,7 +268,7 @@ prompt_git() { } # Dir: current working directory -prompt_dir() { +function prompt_dir() { prompt_segment blue black '\w' } @@ -264,7 +276,7 @@ prompt_dir() { # - was there an error # - am I root # - are there background jobs? -prompt_status() { +function prompt_status() { local symbols symbols=() [[ $RETVAL -ne 0 ]] && symbols+=("$(ansi_single "$(fg_color red)")✘") @@ -280,12 +292,12 @@ prompt_status() { # requires setting prompt_foo to use PRIGHT vs PR # doesn't quite work per above -rightprompt() { +function rightprompt() { printf "%*s" $COLUMNS "$PRIGHT" } # quick right prompt I grabbed to test things. -__command_rprompt() { +function __command_rprompt() { local times=n=$COLUMNS tz for tz in ZRH:Europe/Zurich PIT:US/Eastern \ MTV:US/Pacific TOK:Asia/Tokyo; do @@ -299,7 +311,7 @@ __command_rprompt() { # PROMPT_COMMAND=__command_rprompt # this doens't wrap code in \[ \] -ansi_r() { +function ansi_r() { local seq declare -a mycodes2=("${!1}") @@ -307,7 +319,8 @@ ansi_r() { seq="" for ((i = 0; i < ${#mycodes2[@]}; i++)); do - if [[ -n $seq ]]; then + if [[ -n $seq ]] + then seq="${seq};" fi seq="${seq}${mycodes2[$i]}" @@ -320,7 +333,7 @@ ansi_r() { # Begin a segment on the right # Takes two arguments, background and foreground. Both can be omitted, # rendering default background/foreground. -prompt_right_segment() { +function prompt_right_segment() { local bg fg declare -a codes @@ -331,16 +344,19 @@ prompt_right_segment() { # if it did anything, but it messed up things like # prompt_status - Erik 1/14/17 - # if [[ -z $1 || ( -z $2 && $2 != default ) ]]; then + # if [[ -z $1 || ( -z $2 && $2 != default ) ]] + then codes=("${codes[@]}" "$(text_effect reset)") # fi - if [[ -n $1 ]]; then - bg=$(bg_color "$1") + if [[ -n $1 ]] + then + bg=$(bg_color "${1}") codes=("${codes[@]}" "$bg") debug "Added $bg as background to codes" fi - if [[ -n $2 ]]; then - fg=$(fg_color "$2") + if [[ -n $2 ]] + then + fg=$(fg_color "${2}") codes=("${codes[@]}" "$fg") debug "Added $fg as foreground to codes" fi @@ -349,10 +365,11 @@ prompt_right_segment() { # declare -p codes # right always has a separator - # if [[ $CURRENT_RBG != NONE && $1 != $CURRENT_RBG ]]; then + # if [[ $CURRENT_RBG != NONE && $1 != $CURRENT_RBG ]] + then # $CURRENT_RBG= # fi - declare -a intermediate2=("$(fg_color "$1")" "$(bg_color $CURRENT_RBG)") + declare -a intermediate2=("$(fg_color "${1}")" "$(bg_color $CURRENT_RBG)") # PRIGHT="$PRIGHT---" debug "pre prompt " "$(ansi_r intermediate2[@])" PRIGHT="$PRIGHT$(ansi_r intermediate2[@])$RIGHT_SEPARATOR" @@ -383,7 +400,7 @@ prompt_right_segment() { # (add-hook 'comint-preoutput-filter-functions # 'dirtrack-filter-out-pwd-prompt t t))) -prompt_emacsdir() { +function prompt_emacsdir() { # no color or other setting... this will be deleted per above PR="DIR \w DIR$PR" } @@ -391,7 +408,7 @@ prompt_emacsdir() { ###################################################################### ## Main prompt -build_prompt() { +function build_prompt() { [[ -n ${AG_EMACS_DIR+x} ]] && prompt_emacsdir prompt_status #[[ -z ${AG_NO_HIST+x} ]] && prompt_histdt @@ -407,7 +424,7 @@ build_prompt() { # this doesn't work... new model: create a prompt via a PR variable and # use that. -set_bash_prompt() { +function set_bash_prompt() { RETVAL=$? PR="" PRIGHT="" diff --git a/themes/atomic/atomic.theme.bash b/themes/atomic/atomic.theme.bash index c59dbdc9..bda59dab 100644 --- a/themes/atomic/atomic.theme.bash +++ b/themes/atomic/atomic.theme.bash @@ -33,11 +33,13 @@ function ____atomic_top_left_parse() { local IFS="|" read -r -a args <<< "$@" IFS="${ifs_old}" - if [[ -n "${args[3]:-}" ]]; then + if [[ -n "${args[3]:-}" ]] + then _TOP_LEFT+="${args[2]?}${args[3]?}" fi _TOP_LEFT+="${args[0]?}${args[1]:-}" - if [[ -n "${args[4]:-}" ]]; then + if [[ -n "${args[4]:-}" ]] + then _TOP_LEFT+="${args[2]?}${args[4]?}" fi _TOP_LEFT+="" @@ -49,11 +51,13 @@ function ____atomic_top_right_parse() { read -r -a args <<< "$@" IFS="${ifs_old}" _TOP_RIGHT+=" " - if [[ -n "${args[3]:-}" ]]; then + if [[ -n "${args[3]:-}" ]] + then _TOP_RIGHT+="${args[2]?}${args[3]?}" fi _TOP_RIGHT+="${args[0]?}${args[1]:-}" - if [[ -n "${args[4]:-}" ]]; then + if [[ -n "${args[4]:-}" ]] + then _TOP_RIGHT+="${args[2]?}${args[4]?}" fi __TOP_RIGHT_LEN=$((__TOP_RIGHT_LEN + ${#args[1]} + ${#args[3]} + ${#args[4]} + 1)) @@ -171,11 +175,14 @@ function ___atomic_prompt_battery() { || [[ "$(battery_percentage)" = "no" ]] && return batp=$(battery_percentage) - if [[ "$batp" -eq 50 || "$batp" -gt 50 ]]; then + if [[ "$batp" -eq 50 || "$batp" -gt 50 ]] + then color="${bold_green?}" - elif [[ "$batp" -lt 50 && "$batp" -gt 25 ]]; then + elif [[ "$batp" -lt 50 && "$batp" -gt 25 ]] + then color="${bold_yellow?}" - elif [[ "$batp" -eq 25 || "$batp" -lt 25 ]]; then + elif [[ "$batp" -eq 25 || "$batp" -lt 25 ]] + then color="${IRed?}" fi box="[|]" @@ -195,8 +202,10 @@ function ___atomic_prompt_exitcode() { function ___atomic_prompt_char() { local color="${white?}" local prompt_char="${__ATOMIC_PROMPT_CHAR_PS1?}" - if [[ "${THEME_SHOW_SUDO:-}" == "true" ]]; then - if sudo -vn 1> /dev/null 2>&1; then + if [[ "${THEME_SHOW_SUDO:-}" == "true" ]] + then + if sudo -vn 1> /dev/null 2>&1 + then prompt_char="${__ATOMIC_PROMPT_CHAR_PS1_SUDO?}" fi fi diff --git a/themes/axin/axin.theme.bash b/themes/axin/axin.theme.bash index 7e90aded..e3f26478 100644 --- a/themes/axin/axin.theme.bash +++ b/themes/axin/axin.theme.bash @@ -3,8 +3,10 @@ # Axin Bash Prompt, inspired by theme "Sexy" and "Bobby" # thanks to them -if tput setaf 1 &> /dev/null; then - if [[ $(tput colors) -ge 256 ]] 2> /dev/null; then +if tput setaf 1 &> /dev/null + then + if [[ $(tput colors) -ge 256 ]] 2> /dev/null + then MAGENTA=$(tput setaf 9) ORANGE=$(tput setaf 172) GREEN=$(tput setaf 190) diff --git a/themes/barbuk/barbuk.theme.bash b/themes/barbuk/barbuk.theme.bash index 6e6eb88a..0636495c 100644 --- a/themes/barbuk/barbuk.theme.bash +++ b/themes/barbuk/barbuk.theme.bash @@ -85,7 +85,8 @@ function git_prompt_info() { } function __exit_prompt() { - if [[ "$exit_code" -ne 0 ]]; then + if [[ "$exit_code" -ne 0 ]] + then echo "${purple?}${EXIT_CODE_ICON}${yellow?}${exit_code}${bold_orange?} " else echo "${bold_green}" @@ -93,13 +94,15 @@ function __exit_prompt() { } function __aws_profile_prompt() { - if [[ -n "${AWS_PROFILE}" ]]; then + 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 + if [[ -n "${SCW_PROFILE}" ]] + then echo -n "${bold_purple?}${SCALEWAY_PROFILE_CHAR}${normal?}${SCW_PROFILE} " fi } @@ -120,7 +123,8 @@ function __cloud_prompt() { function __terraform_prompt() { local terraform_workspace="" - if [ -d .terraform ]; then + if [ -d .terraform ] + then terraform_workspace="$(terraform_workspace_prompt)" [[ -n "${terraform_workspace}" ]] && echo "${bold_purple?}${TERRAFORM_CHAR}${normal?}${terraform_workspace} " fi @@ -142,8 +146,10 @@ function __ruby_prompt() { function __ssh_prompt() { # Detect ssh - if [[ -n "${SSH_CONNECTION}" ]] && [ "$SSH_INFO" = true ]; then - if [ "$HOST_INFO" = long ]; then + if [[ -n "${SSH_CONNECTION}" ]] && [ "$SSH_INFO" = true ] + then + if [ "$HOST_INFO" = long ] + then host="\H" else host="\h" @@ -154,9 +160,11 @@ function __ssh_prompt() { function __python_venv_prompt() { # Detect python venv - if [[ -n "${CONDA_DEFAULT_ENV}" ]]; then + if [[ -n "${CONDA_DEFAULT_ENV}" ]] + then echo "${bold_purple?}$PYTHON_VENV_CHAR${normal?}${CONDA_DEFAULT_ENV} " - elif [[ -n "${VIRTUAL_ENV}" ]]; then + elif [[ -n "${VIRTUAL_ENV}" ]] + then echo "${bold_purple?}$PYTHON_VENV_CHAR${normal?}$(basename "${VIRTUAL_ENV}") " fi } @@ -164,7 +172,8 @@ function __python_venv_prompt() { function __path_prompt() { local dir_color=${green?} # Detect root shell - if [ "$(whoami)" = root ]; then + if [ "$(whoami)" = root ] + then dir_color=${red?} fi @@ -193,7 +202,8 @@ function __prompt-command() { done # Cut prompt when it's too long - if [[ ${#PS1} -gt $((COLUMNS * 2)) ]]; then + if [[ ${#PS1} -gt $((COLUMNS * 2)) ]] + then wrap_char="\n" fi diff --git a/themes/base.theme.bash b/themes/base.theme.bash index 92a56e5e..f4e827fd 100644 --- a/themes/base.theme.bash +++ b/themes/base.theme.bash @@ -105,8 +105,10 @@ function _bash_it_appearance_scm_init() { # Check for broken SVN exe that is caused by some versions of Xcode. # See https://github.com/Bash-it/bash-it/issues/1612 for more details. - if [[ -x "${SVN_EXE-}" && -x "${SVN_EXE%/svn}/xcrun" ]]; then - if ! "${SVN_EXE}" --version > /dev/null 2>&1; then + if [[ -x "${SVN_EXE-}" && -x "${SVN_EXE%/svn}/xcrun" ]] + then + if ! "${SVN_EXE}" --version > /dev/null 2>&1 + then # Unset the SVN exe variable so that SVN commands are avoided. SVN_EXE="" fi @@ -116,15 +118,20 @@ function _bash_it_appearance_scm_init() { _bash_it_library_finalize_hook+=('_bash_it_appearance_scm_init') function scm() { - if [[ "${SCM_CHECK:-true}" == "false" ]]; then + if [[ "${SCM_CHECK:-true}" == "false" ]] + then SCM="${SCM_NONE-NONE}" - elif [[ -x "${GIT_EXE-}" ]] && _bash-it-find-in-ancestor '.git' > /dev/null; then + elif [[ -x "${GIT_EXE-}" ]] && _bash-it-find-in-ancestor '.git' > /dev/null + then SCM="${SCM_GIT?}" - elif [[ -x "${HG_EXE-}" ]] && _bash-it-find-in-ancestor '.hg' > /dev/null; then + elif [[ -x "${HG_EXE-}" ]] && _bash-it-find-in-ancestor '.hg' > /dev/null + then SCM="${SCM_HG?}" - elif [[ -x "${SVN_EXE-}" ]] && _bash-it-find-in-ancestor '.svn' > /dev/null; then + elif [[ -x "${SVN_EXE-}" ]] && _bash-it-find-in-ancestor '.svn' > /dev/null + then SCM="${SCM_SVN?}" - elif [[ -x "${P4_EXE-}" && -n "$(p4 set P4CLIENT 2> /dev/null)" ]]; then + elif [[ -x "${P4_EXE-}" && -n "$(p4 set P4CLIENT 2> /dev/null)" ]] + then SCM="${SCM_P4?}" else SCM="${SCM_NONE-NONE}" @@ -137,14 +144,16 @@ function scm_prompt() { scm_char="$(scm_char)" scm_prompt_info="$(scm_prompt_info)" - if [[ "${scm_char}" != "${SCM_NONE_CHAR:-}" ]]; then + if [[ "${scm_char}" != "${SCM_NONE_CHAR:-}" ]] + then # shellcheck disable=2059 printf "${format}" "${scm_char}" "${scm_prompt_info}" fi } function scm_prompt_char() { - if [[ -z "${SCM:-}" ]]; then + if [[ -z "${SCM:-}" ]] + then scm fi @@ -196,7 +205,8 @@ function scm_prompt_info_common() { case ${SCM?} in "${SCM_GIT?}") - if [[ ${SCM_GIT_SHOW_MINIMAL_INFO:-false} == "true" ]]; then + if [[ ${SCM_GIT_SHOW_MINIMAL_INFO:-false} == "true" ]] + then # user requests minimal git status information prompt_info="${SCM}_prompt_minimal_info" else @@ -213,15 +223,18 @@ function scm_prompt_info_common() { } function terraform_workspace_prompt() { - if _command_exists terraform; then - if [[ -d .terraform ]]; then + if _command_exists terraform + then + if [[ -d .terraform ]] + then terraform workspace show 2> /dev/null fi fi } function active_gcloud_account_prompt() { - if _command_exists gcloud; then + if _command_exists gcloud + then gcloud config list account --format "value(core.account)" 2> /dev/null fi } @@ -233,7 +246,8 @@ function git_prompt_minimal_info() { SCM_BRANCH="${SCM_THEME_BRANCH_PREFIX-}\$(_git-friendly-ref)" - if [[ -n "$(_git-status | tail -n1)" ]]; then + if [[ -n "$(_git-status | tail -n1)" ]] + then SCM_DIRTY=1 SCM_STATE="${SCM_THEME_PROMPT_DIRTY?}" fi @@ -245,7 +259,8 @@ function git_prompt_minimal_info() { } function git_prompt_vars() { - if [[ "${SCM_GIT_USE_GITSTATUS:-false}" != "false" ]] && _command_exists gitstatus_query && gitstatus_query && [[ "${VCS_STATUS_RESULT:-}" == "ok-sync" ]]; then + if [[ "${SCM_GIT_USE_GITSTATUS:-false}" != "false" ]] && _command_exists gitstatus_query && gitstatus_query && [[ "${VCS_STATUS_RESULT:-}" == "ok-sync" ]] + then # we can use faster gitstatus # use this variable in githelpers and below to choose gitstatus output SCM_GIT_GITSTATUS_RAN=true @@ -253,14 +268,16 @@ function git_prompt_vars() { SCM_GIT_GITSTATUS_RAN=false fi - if _git-branch &> /dev/null; then + if _git-branch &> /dev/null + then SCM_GIT_DETACHED="false" SCM_BRANCH="${SCM_THEME_BRANCH_PREFIX}\$(_git-friendly-ref)$(_git-remote-info)" else SCM_GIT_DETACHED="true" local detached_prefix - if _git-tag &> /dev/null; then + if _git-tag &> /dev/null + then detached_prefix="${SCM_THEME_TAG_PREFIX}" else detached_prefix="${SCM_THEME_DETACHED_PREFIX}" @@ -268,24 +285,29 @@ function git_prompt_vars() { SCM_BRANCH="${detached_prefix}\$(_git-friendly-ref)" fi - if [[ "${SCM_GIT_GITSTATUS_RAN:-}" == "true" ]]; then + if [[ "${SCM_GIT_GITSTATUS_RAN:-}" == "true" ]] + then commits_behind="${VCS_STATUS_COMMITS_BEHIND?}" commits_ahead="${VCS_STATUS_COMMITS_AHEAD?}" else IFS=$'\t' read -r commits_behind commits_ahead <<< "$(_git-upstream-behind-ahead)" fi - if [[ "${commits_ahead}" -gt 0 ]]; then + if [[ "${commits_ahead}" -gt 0 ]] + then SCM_BRANCH+="${SCM_GIT_AHEAD_BEHIND_PREFIX_CHAR}${SCM_GIT_AHEAD_CHAR}" [[ "${SCM_GIT_SHOW_COMMIT_COUNT}" == "true" ]] && SCM_BRANCH+="${commits_ahead}" fi - if [[ "${commits_behind}" -gt 0 ]]; then + if [[ "${commits_behind}" -gt 0 ]] + then SCM_BRANCH+="${SCM_GIT_AHEAD_BEHIND_PREFIX_CHAR}${SCM_GIT_BEHIND_CHAR}" [[ "${SCM_GIT_SHOW_COMMIT_COUNT}" == "true" ]] && SCM_BRANCH+="${commits_behind}" fi - if [[ "${SCM_GIT_SHOW_STASH_INFO}" == "true" ]]; then + if [[ "${SCM_GIT_SHOW_STASH_INFO}" == "true" ]] + then local stash_count - if [[ "${SCM_GIT_GITSTATUS_RAN}" == "true" ]]; then + if [[ "${SCM_GIT_GITSTATUS_RAN}" == "true" ]] + then stash_count="${VCS_STATUS_STASHES?}" else stash_count="$(git stash list 2> /dev/null | wc -l | tr -d ' ')" @@ -294,17 +316,21 @@ function git_prompt_vars() { fi SCM_STATE="${GIT_THEME_PROMPT_CLEAN:-${SCM_THEME_PROMPT_CLEAN:-}}" - if ! _git-hide-status; then - if [[ "${SCM_GIT_GITSTATUS_RAN:-}" == "true" ]]; then + if ! _git-hide-status + then + if [[ "${SCM_GIT_GITSTATUS_RAN:-}" == "true" ]] + then untracked_count="${VCS_STATUS_NUM_UNTRACKED?}" unstaged_count="${VCS_STATUS_NUM_UNSTAGED?}" staged_count="${VCS_STATUS_NUM_STAGED?}" else IFS=$'\t' read -r untracked_count unstaged_count staged_count < <(_git-status-counts) fi - if [[ "${untracked_count}" -gt 0 || "${unstaged_count}" -gt 0 || "${staged_count}" -gt 0 ]]; then + if [[ "${untracked_count}" -gt 0 || "${unstaged_count}" -gt 0 || "${staged_count}" -gt 0 ]] + then SCM_DIRTY=1 - if [[ "${SCM_GIT_SHOW_DETAILS}" == "true" ]]; then + if [[ "${SCM_GIT_SHOW_DETAILS}" == "true" ]] + then [[ "${staged_count}" -gt 0 ]] && SCM_BRANCH+=" ${SCM_GIT_STAGED_CHAR}${staged_count}" && SCM_DIRTY=3 [[ "${unstaged_count}" -gt 0 ]] && SCM_BRANCH+=" ${SCM_GIT_UNSTAGED_CHAR}${unstaged_count}" && SCM_DIRTY=2 [[ "${untracked_count}" -gt 0 ]] && SCM_BRANCH+=" ${SCM_GIT_UNTRACKED_CHAR}${untracked_count}" && SCM_DIRTY=1 @@ -330,7 +356,8 @@ function p4_prompt_vars() { opened_count non_default_changes default_count \ add_file_count edit_file_count delete_file_count \ < <(_p4-opened-counts) - if [[ "${opened_count}" -gt 0 ]]; then + if [[ "${opened_count}" -gt 0 ]] + then SCM_DIRTY=1 SCM_STATE="${SCM_THEME_PROMPT_DIRTY?}" [[ "${opened_count}" -gt 0 ]] && SCM_BRANCH+=" ${SCM_P4_OPENED_CHAR?}${opened_count}" @@ -346,7 +373,8 @@ function p4_prompt_vars() { } function svn_prompt_vars() { - if [[ -n "$(svn status | head -c1 2> /dev/null)" ]]; then + if [[ -n "$(svn status | head -c1 2> /dev/null)" ]] + then SCM_DIRTY=1 SCM_STATE="${SVN_THEME_PROMPT_DIRTY:-${SCM_THEME_PROMPT_DIRTY?}}" else @@ -361,7 +389,8 @@ function svn_prompt_vars() { function hg_prompt_vars() { local hg_root bookmark - if [[ -n $(hg status 2> /dev/null) ]]; then + if [[ -n $(hg status 2> /dev/null) ]] + then SCM_DIRTY=1 SCM_STATE="${HG_THEME_PROMPT_DIRTY:-${SCM_THEME_PROMPT_DIRTY?}}" else @@ -373,7 +402,8 @@ function hg_prompt_vars() { hg_root="$(_bash-it-find-in-ancestor ".hg")/.hg" - if [[ -f "$hg_root/branch" ]]; then + if [[ -f "$hg_root/branch" ]] + then # Mercurial holds it's current branch in .hg/branch file SCM_BRANCH=$(< "${hg_root}/branch") bookmark="${hg_root}/bookmarks.current" @@ -382,7 +412,8 @@ function hg_prompt_vars() { SCM_BRANCH=$(hg summary 2> /dev/null | grep branch: | awk '{print $2}') fi - if [[ -f "$hg_root/dirstate" ]]; then + if [[ -f "$hg_root/dirstate" ]] + then # Mercurial holds various information about the working directory in .hg/dirstate file. More on http://mercurial.selenic.com/wiki/DirState SCM_CHANGE=$(hexdump -vn 10 -e '1/1 "%02x"' "$hg_root/dirstate" | cut -c-12) else @@ -392,7 +423,8 @@ function hg_prompt_vars() { function nvm_version_prompt() { local node - if _is_function nvm; then + if _is_function nvm + then node=$(nvm current 2> /dev/null) [[ "${node}" == "system" ]] && return echo -ne "${NVM_THEME_PROMPT_PREFIX-}${node}${NVM_THEME_PROMPT_SUFFIX-}" @@ -404,39 +436,47 @@ function node_version_prompt() { } function rvm_version_prompt() { - if _command_exists rvm; then + if _command_exists rvm + then rvm="$(rvm-prompt)" || return - if [[ -n "$rvm" ]]; then + if [[ -n "$rvm" ]] + then echo -ne "${RVM_THEME_PROMPT_PREFIX-}${rvm}${RVM_THEME_PROMPT_SUFFIX-}" fi fi } function rbenv_version_prompt() { - if _command_exists rbenv; then + if _command_exists rbenv + then rbenv=$(rbenv version-name) || return rbenv commands | grep -q gemset && gemset=$(rbenv gemset active 2> /dev/null) && rbenv="$rbenv@${gemset%% *}" - if [[ "$rbenv" != "system" ]]; then + if [[ "$rbenv" != "system" ]] + then echo -ne "${RBENV_THEME_PROMPT_PREFIX-}${rbenv}${RBENV_THEME_PROMPT_SUFFIX-}" fi fi } function rbfu_version_prompt() { - if [[ -n "${RBFU_RUBY_VERSION:-}" ]]; then + if [[ -n "${RBFU_RUBY_VERSION:-}" ]] + then echo -ne "${RBFU_THEME_PROMPT_PREFIX-}${RBFU_RUBY_VERSION}${RBFU_THEME_PROMPT_SUFFIX-}" fi } function chruby_version_prompt() { - if _is_function chruby; then - if _is_function chruby_auto; then + if _is_function chruby + then + if _is_function chruby_auto + then chruby_auto fi ruby_version=$(ruby --version | awk '{print $1, $2;}') || return - if ! chruby | grep -q '\*'; then + if ! chruby | grep -q '\*' + then ruby_version="${ruby_version} (system)" fi echo -ne "${CHRUBY_THEME_PROMPT_PREFIX-}${ruby_version}${CHRUBY_THEME_PROMPT_SUFFIX-}" @@ -444,7 +484,8 @@ function chruby_version_prompt() { } function ruby_version_prompt() { - if [[ "${THEME_SHOW_RUBY_PROMPT:-}" == "true" ]]; then + if [[ "${THEME_SHOW_RUBY_PROMPT:-}" == "true" ]] + then rbfu_version_prompt rbenv_version_prompt rvm_version_prompt @@ -462,14 +503,16 @@ function k8s_namespace_prompt() { function virtualenv_prompt() { local virtualenv - if [[ -n "${VIRTUAL_ENV:-}" ]]; then + if [[ -n "${VIRTUAL_ENV:-}" ]] + then virtualenv="${VIRTUAL_ENV##*/}" echo -ne "${VIRTUALENV_THEME_PROMPT_PREFIX-}${virtualenv}${VIRTUALENV_THEME_PROMPT_SUFFIX-}" fi } function condaenv_prompt() { - if [[ -n "${CONDA_DEFAULT_ENV:-}" ]]; then + if [[ -n "${CONDA_DEFAULT_ENV:-}" ]] + then echo -ne "${CONDAENV_THEME_PROMPT_PREFIX-}${CONDA_DEFAULT_ENV}${CONDAENV_THEME_PROMPT_SUFFIX-}" fi } @@ -501,7 +544,8 @@ function clock_char() { clock_char_color="${THEME_CLOCK_CHAR_COLOR:-${normal:-}}" show_clock_char="${THEME_SHOW_CLOCK_CHAR:-"true"}" - if [[ "${show_clock_char}" == "true" ]]; then + if [[ "${show_clock_char}" == "true" ]] + then echo -ne "${clock_char_color}${CLOCK_CHAR_THEME_PROMPT_PREFIX-}${clock_char}${CLOCK_CHAR_THEME_PROMPT_SUFFIX-}" fi } @@ -512,13 +556,15 @@ function clock_prompt() { local show_clock="${THEME_SHOW_CLOCK:-${THEME_CLOCK_CHECK:-true}}" local clock_string="\D{${clock_format}}" - if [[ "${show_clock}" == "true" ]]; then + if [[ "${show_clock}" == "true" ]] + then echo -ne "${clock_color}${CLOCK_THEME_PROMPT_PREFIX-}${clock_string}${CLOCK_THEME_PROMPT_SUFFIX-}" fi } function user_host_prompt() { - if [[ "${THEME_SHOW_USER_HOST:-false}" == "true" ]]; then + if [[ "${THEME_SHOW_USER_HOST:-false}" == "true" ]] + then echo -ne "${USER_HOST_THEME_PROMPT_PREFIX-}\u@${THEME_PROMPT_HOST:-\h}${USER_HOST_THEME_PROMPT_SUFFIX-}" fi } @@ -556,14 +602,16 @@ function prompt_char() { function battery_char() { # The battery_char function depends on the presence of the battery_percentage function. - if [[ "${THEME_BATTERY_PERCENTAGE_CHECK}" == true ]] && _command_exists battery_percentage; then + if [[ "${THEME_BATTERY_PERCENTAGE_CHECK}" == true ]] && _command_exists battery_percentage + then echo -ne "${bold_red?}$(battery_percentage)%" else false fi } -if ! _command_exists battery_charge; then +if ! _command_exists battery_charge + then # if user has installed battery plugin, skip this... function battery_charge() { : # no op @@ -571,7 +619,8 @@ if ! _command_exists battery_charge; then fi function aws_profile() { - if [[ -n "${AWS_DEFAULT_PROFILE:-}" ]]; then + if [[ -n "${AWS_DEFAULT_PROFILE:-}" ]] + then echo -ne "${AWS_DEFAULT_PROFILE}" else echo -ne "default" diff --git a/themes/binaryanomaly/binaryanomaly.theme.bash b/themes/binaryanomaly/binaryanomaly.theme.bash index c4488c4c..214dde9a 100644 --- a/themes/binaryanomaly/binaryanomaly.theme.bash +++ b/themes/binaryanomaly/binaryanomaly.theme.bash @@ -4,8 +4,10 @@ # Detect whether a reboot is required function show_reboot_required() { - if [ -n "$_bf_prompt_reboot_info" ]; then - if [ -f /var/run/reboot-required ]; then + if [ -n "$_bf_prompt_reboot_info" ] + then + if [ -f /var/run/reboot-required ] + then printf "Reboot required!" fi fi @@ -14,7 +16,8 @@ function show_reboot_required() { # Set different host color for local and remote sessions function set_host_color() { # Detect if connection is through SSH - if [[ -n $SSH_CLIENT ]]; then + if [[ -n $SSH_CLIENT ]] + then printf '%s' "${lime_yellow}" else printf '%s' "${light_orange}" diff --git a/themes/bira/bira.theme.bash b/themes/bira/bira.theme.bash index f30d8d5d..8fc47c1b 100644 --- a/themes/bira/bira.theme.bash +++ b/themes/bira/bira.theme.bash @@ -9,7 +9,8 @@ VIRTUALENV_THEME_PROMPT_SUFFIX="›${reset_color?}" bold="\[\e[1m\]" -if [[ ${UID} -eq 0 ]]; then +if [[ ${UID} -eq 0 ]] + then user_host="${bold_red?}\u@\h${normal?}${reset_color?}" else user_host="${bold_green?}\u@\h${normal?}${reset_color?}" diff --git a/themes/bobby/bobby.theme.bash b/themes/bobby/bobby.theme.bash index 08f54c41..6778f514 100644 --- a/themes/bobby/bobby.theme.bash +++ b/themes/bobby/bobby.theme.bash @@ -17,7 +17,8 @@ RVM_THEME_PROMPT_SUFFIX="|" function __bobby_clock() { printf '%s' "$(clock_prompt) " - if [[ "${THEME_SHOW_CLOCK_CHAR:-}" == "true" ]]; then + if [[ "${THEME_SHOW_CLOCK_CHAR:-}" == "true" ]] + then printf '%s' "$(clock_char) " fi } diff --git a/themes/brainy/brainy.theme.bash b/themes/brainy/brainy.theme.bash index e1c36175..3f16d6e6 100644 --- a/themes/brainy/brainy.theme.bash +++ b/themes/brainy/brainy.theme.bash @@ -9,39 +9,43 @@ ## Parsers ## ############# -____brainy_top_left_parse() { +function ____brainy_top_left_parse() { ifs_old="${IFS}" IFS="|" read -r -a args <<< "$@" IFS="${ifs_old}" - if [ -n "${args[3]}" ]; then + if [ -n "${args[3]}" ] + then _TOP_LEFT+="${args[2]}${args[3]}" fi _TOP_LEFT+="${args[0]}${args[1]}" - if [ -n "${args[4]}" ]; then + if [ -n "${args[4]}" ] + then _TOP_LEFT+="${args[2]}${args[4]}" fi _TOP_LEFT+=" " } -____brainy_top_right_parse() { +function ____brainy_top_right_parse() { ifs_old="${IFS}" IFS="|" read -r -a args <<< "$@" IFS="${ifs_old}" _TOP_RIGHT+=" " - if [ -n "${args[3]}" ]; then + if [ -n "${args[3]}" ] + then _TOP_RIGHT+="${args[2]}${args[3]}" fi _TOP_RIGHT+="${args[0]}${args[1]}" - if [ -n "${args[4]}" ]; then + if [ -n "${args[4]}" ] + then _TOP_RIGHT+="${args[2]}${args[4]}" fi __TOP_RIGHT_LEN=$((__TOP_RIGHT_LEN + ${#args[1]} + ${#args[3]} + ${#args[4]} + 1)) ((__SEG_AT_RIGHT += 1)) } -____brainy_bottom_parse() { +function ____brainy_bottom_parse() { ifs_old="${IFS}" IFS="|" read -r -a args <<< "$@" @@ -50,7 +54,7 @@ ____brainy_bottom_parse() { [ ${#args[1]} -gt 0 ] && _BOTTOM+=" " } -____brainy_top() { +function ____brainy_top() { _TOP_LEFT="" _TOP_RIGHT="" __TOP_RIGHT_LEN=0 @@ -76,7 +80,7 @@ ____brainy_top() { printf "%s%s" "${_TOP_LEFT}" "${_TOP_RIGHT}" } -____brainy_bottom() { +function ____brainy_bottom() { _BOTTOM="" for seg in $___BRAINY_BOTTOM; do info="$(___brainy_prompt_"${seg}")" @@ -89,30 +93,33 @@ ____brainy_bottom() { ## Segments ## ############## -___brainy_prompt_user_info() { +function ___brainy_prompt_user_info() { color=$bold_blue - if [ "${THEME_SHOW_SUDO}" == "true" ]; then - if sudo -vn 1> /dev/null 2>&1; then + if [ "${THEME_SHOW_SUDO}" == "true" ] + then + if sudo -vn 1> /dev/null 2>&1 + then color=$bold_red fi fi box="[|]" info="\u@\H" - if [ -n "${SSH_CLIENT}" ]; then + if [ -n "${SSH_CLIENT}" ] + then printf "%s|%s|%s|%s" "${color}" "${info}" "${bold_white}" "${box}" else printf "%s|%s" "${color}" "${info}" fi } -___brainy_prompt_dir() { +function ___brainy_prompt_dir() { color=$bold_yellow box="[|]" info="\w" printf "%s|%s|%s|%s" "${color}" "${info}" "${bold_white}" "${box}" } -___brainy_prompt_scm() { +function ___brainy_prompt_scm() { [ "${THEME_SHOW_SCM}" != "true" ] && return color=$bold_green box="$(scm_char) " @@ -120,7 +127,7 @@ ___brainy_prompt_scm() { printf "%s|%s|%s|%s" "${color}" "${info}" "${bold_white}" "${box}" } -___brainy_prompt_python() { +function ___brainy_prompt_python() { [ "${THEME_SHOW_PYTHON}" != "true" ] && return color=$bold_yellow box="[|]" @@ -128,7 +135,7 @@ ___brainy_prompt_python() { printf "%s|%s|%s|%s" "${color}" "${info}" "${bold_blue}" "${box}" } -___brainy_prompt_ruby() { +function ___brainy_prompt_ruby() { [ "${THEME_SHOW_RUBY}" != "true" ] && return color=$bold_white box="[|]" @@ -136,7 +143,7 @@ ___brainy_prompt_ruby() { printf "%s|%s|%s|%s" "${color}" "${info}" "${bold_red}" "${box}" } -___brainy_prompt_todo() { +function ___brainy_prompt_todo() { [ "${THEME_SHOW_TODO}" != "true" ] \ || [ -z "$(which todo.sh)" ] && return color=$bold_white @@ -145,7 +152,7 @@ ___brainy_prompt_todo() { printf "%s|%s|%s|%s" "${color}" "${info}" "${bold_green}" "${box}" } -___brainy_prompt_clock() { +function ___brainy_prompt_clock() { [ "${THEME_SHOW_CLOCK}" != "true" ] && return color=$THEME_CLOCK_COLOR box="[|]" @@ -153,16 +160,18 @@ ___brainy_prompt_clock() { printf "%s|%s|%s|%s" "${color}" "${info}" "${bold_purple}" "${box}" } -___brainy_prompt_battery() { +function ___brainy_prompt_battery() { ! _command_exists battery_percentage \ || [ "${THEME_SHOW_BATTERY}" != "true" ] \ || [ "$(battery_percentage)" = "no" ] && return info=$(battery_percentage) color=$bold_green - if [ "$info" -lt 50 ]; then + if [ "$info" -lt 50 ] + then color=$bold_yellow - elif [ "$info" -lt 25 ]; then + elif [ "$info" -lt 25 ] + then color=$bold_red fi box="[|]" @@ -173,13 +182,13 @@ ___brainy_prompt_battery() { printf "%s|%s|%s|%s" "${color}" "${info}" "${bold_white}" "${box}" } -___brainy_prompt_exitcode() { +function ___brainy_prompt_exitcode() { [ "${THEME_SHOW_EXITCODE}" != "true" ] && return color=$bold_purple [ "$exitcode" -ne 0 ] && printf "%s|%s" "${color}" "${exitcode}" } -___brainy_prompt_char() { +function ___brainy_prompt_char() { color=$bold_white prompt_char="${__BRAINY_PROMPT_CHAR_PS1}" printf "%s|%s" "${color}" "${prompt_char}" @@ -189,19 +198,19 @@ ___brainy_prompt_char() { ## cli ## ######### -__brainy_show() { +function __brainy_show() { typeset _seg=${1:-} shift export "THEME_SHOW_${_seg}"=true } -__brainy_hide() { +function __brainy_hide() { typeset _seg=${1:-} shift export "THEME_SHOW_${_seg}"=false } -_brainy_completion() { +function _brainy_completion() { local cur _action actions segments COMPREPLY=() cur="${COMP_WORDS[COMP_CWORD]}" @@ -221,7 +230,7 @@ _brainy_completion() { return 0 } -brainy() { +function brainy() { typeset action=${1:-} shift typeset segs=${*:-} @@ -284,16 +293,16 @@ ___BRAINY_BOTTOM=${___BRAINY_BOTTOM:-"exitcode char"} ## Prompt ## ############ -__brainy_ps1() { +function __brainy_ps1() { printf "%s%s%s" "$(____brainy_top)" "$(____brainy_bottom)" "${normal}" } -__brainy_ps2() { +function __brainy_ps2() { color=$bold_white printf "%s%s%s" "${color}" "${__BRAINY_PROMPT_CHAR_PS2} " "${normal}" } -_brainy_prompt() { +function _brainy_prompt() { exitcode="$?" PS1="$(__brainy_ps1)" diff --git a/themes/brunton/brunton.theme.bash b/themes/brunton/brunton.theme.bash index 04dcbb3e..67223905 100644 --- a/themes/brunton/brunton.theme.bash +++ b/themes/brunton/brunton.theme.bash @@ -11,7 +11,8 @@ SCM_SVN_CHAR="${bold_cyan?}⑆${normal?}" SCM_HG_CHAR="${bold_red?}☿${normal?}" function is_vim_shell() { - if [[ -n "${VIMRUNTIME:-}" ]]; then + if [[ -n "${VIMRUNTIME:-}" ]] + then echo "[${cyan?}vim shell${normal?}]" fi } diff --git a/themes/clean/clean.theme.bash b/themes/clean/clean.theme.bash index 0082d671..3ddd8e0a 100644 --- a/themes/clean/clean.theme.bash +++ b/themes/clean/clean.theme.bash @@ -11,7 +11,8 @@ export LS_COLORS='no=00:fi=00:di=01;34:ln=00;36:pi=40;33:so=01;35:do=01;35:bd=40 function prompt_command() { - if [ "$(whoami)" = root ]; then no_color=$red; else no_color=$white; fi + if [ "$(whoami)" = root ] + then no_color=$red; else no_color=$white; fi PS1="${no_color}\u${reset_color}:${blue}\W/${reset_color} $(scm_prompt_info)${normal}$ " } diff --git a/themes/cooperkid/cooperkid.theme.bash b/themes/cooperkid/cooperkid.theme.bash index 1ffb95aa..5cfe63ad 100644 --- a/themes/cooperkid/cooperkid.theme.bash +++ b/themes/cooperkid/cooperkid.theme.bash @@ -13,9 +13,11 @@ GIT_SHA_PREFIX="${blue}" GIT_SHA_SUFFIX="${reset_color}" function rvm_version_prompt { - if which rvm &> /dev/null; then + if which rvm &> /dev/null + then rvm=$(rvm-prompt) || return - if [ -n "$rvm" ]; then + if [ -n "$rvm" ] + then echo -e "$rvm" fi fi diff --git a/themes/cupcake/cupcake.theme.bash b/themes/cupcake/cupcake.theme.bash index 889f3e68..c0f10a57 100644 --- a/themes/cupcake/cupcake.theme.bash +++ b/themes/cupcake/cupcake.theme.bash @@ -51,7 +51,8 @@ icon_end="└❯ " # Display virtual environment info function virtualenv_prompt { - if [[ -n "$VIRTUAL_ENV" ]]; then + if [[ -n "$VIRTUAL_ENV" ]] + then virtualenv=`basename "$VIRTUAL_ENV"` echo -e "$VIRTUALENV_CHAR$virtualenv " fi diff --git a/themes/doubletime/doubletime.theme.bash b/themes/doubletime/doubletime.theme.bash index 8186db73..2df0281b 100644 --- a/themes/doubletime/doubletime.theme.bash +++ b/themes/doubletime/doubletime.theme.bash @@ -7,14 +7,16 @@ SCM_SVN_CHAR="${bold_cyan}⑆${normal}" SCM_HG_CHAR="${bold_red}☿${normal}" SCM_THEME_PROMPT_PREFIX="" SCM_THEME_PROMPT_SUFFIX="" -if [ ! -z $RVM_THEME_PROMPT_COLOR ]; then +if [ ! -z $RVM_THEME_PROMPT_COLOR ] + then RVM_THEME_PROMPT_COLOR=$(eval echo $`echo ${RVM_THEME_PROMPT_COLOR}`); else RVM_THEME_PROMPT_COLOR="${red}" fi RVM_THEME_PROMPT_PREFIX="(${RVM_THEME_PROMPT_COLOR}rb${normal}: " RVM_THEME_PROMPT_SUFFIX=") " -if [ ! -z $VIRTUALENV_THEME_PROMPT_COLOR ]; then +if [ ! -z $VIRTUALENV_THEME_PROMPT_COLOR ] + then VIRTUALENV_THEME_PROMPT_COLOR=$(eval echo $`echo ${VIRTUALENV_THEME_PROMPT_COLOR}`); else VIRTUALENV_THEME_PROMPT_COLOR="${green}" @@ -22,7 +24,8 @@ fi VIRTUALENV_THEME_PROMPT_PREFIX="(${VIRTUALENV_THEME_PROMPT_COLOR}py${normal}: " VIRTUALENV_THEME_PROMPT_SUFFIX=") " -if [ ! -z $THEME_PROMPT_HOST_COLOR ]; then +if [ ! -z $THEME_PROMPT_HOST_COLOR ] + then THEME_PROMPT_HOST_COLOR=$(eval echo $`echo ${THEME_PROMPT_HOST_COLOR}`); else THEME_PROMPT_HOST_COLOR="$blue" diff --git a/themes/dulcie/dulcie.theme.bash b/themes/dulcie/dulcie.theme.bash index f70c7864..f7e17496 100755 --- a/themes/dulcie/dulcie.theme.bash +++ b/themes/dulcie/dulcie.theme.bash @@ -15,15 +15,15 @@ DULCIE_COLOR=${DULCIE_COLOR:=1} # 0 = monochrome, 1 = colorful DULCIE_MULTILINE=${DULCIE_MULTILINE:=1} # 0 = Single line, 1 = SCM in separate line -dulcie_color() { +function dulcie_color() { echo -en "\[\e[38;5;${1}m\]" } -dulcie_background() { +function dulcie_background() { echo -en "\[\e[48;5;${1}m\]" } -dulcie_prompt() { +function dulcie_prompt() { color_user_root=$(dulcie_color 169) color_user_nonroot="${green}" color_host_local=$(dulcie_color 230) @@ -35,14 +35,17 @@ dulcie_prompt() { SCM_THEME_ROOT_SUFFIX="|$(scm_char) " # Set colors - if [ "${DULCIE_COLOR}" -eq "1" ]; then - if [[ $EUID -ne 0 ]]; then + if [ "${DULCIE_COLOR}" -eq "1" ] + then + if [[ $EUID -ne 0 ]] + then color_user="${color_user_nonroot}" else color_user="${color_user_root}" fi - if [[ -n "${SSH_CLIENT}" ]]; then + if [[ -n "${SSH_CLIENT}" ]] + then color_host="${color_host_remote}" else color_host="${color_host_local}" @@ -80,9 +83,11 @@ dulcie_prompt() { _is_function __vte_osc7 && __vte_osc7 PS1="${reset_color}[${DULCIE_USER}@${DULCIE_HOST}$(scm_prompt_info)${reset_color} ${DULCIE_WORKINGDIR}]" - if [[ "${DULCIE_MULTILINE}" -eq "1" ]]; then + if [[ "${DULCIE_MULTILINE}" -eq "1" ]] + then PS1="${reset_color}[${DULCIE_USER}@${DULCIE_HOST}${reset_color} ${DULCIE_WORKINGDIR}]" - if [[ "$(scm_prompt_info)" ]]; then + if [[ "$(scm_prompt_info)" ]] + then SCM_THEME_PROMPT_PREFIX="${DULCIE_SCM_BACKGROUND}|${DULCIE_SCM_DIR_COLOR}" SCM_THEME_PROMPT_SUFFIX="|${normal}" PS1="$(scm_prompt_info)\n${PS1}" diff --git a/themes/easy/easy.theme.bash b/themes/easy/easy.theme.bash index 3cb171d7..aa73d150 100644 --- a/themes/easy/easy.theme.bash +++ b/themes/easy/easy.theme.bash @@ -8,7 +8,8 @@ SCM_THEME_PROMPT_CLEAN=" ${bold_green?}✓" function prompt_command() { local scm_prompt_info - if [ "${USER:-${LOGNAME?}}" = root ]; then + if [ "${USER:-${LOGNAME?}}" = root ] + then cursor_color="${bold_red?}" user_color="${green?}" else diff --git a/themes/emperor/emperor.theme.bash b/themes/emperor/emperor.theme.bash index e3f2df8c..5d13ca44 100644 --- a/themes/emperor/emperor.theme.bash +++ b/themes/emperor/emperor.theme.bash @@ -16,11 +16,14 @@ RVM_THEME_PROMPT_SUFFIX="|" function get_hour_color { hour_color=$red min=$(date +%M) - if [ "$min" -lt "15" ]; then + if [ "$min" -lt "15" ] + then hour_color=$white - elif [ "$min" -lt "30" ]; then + elif [ "$min" -lt "30" ] + then hour_color=$green - elif [ "$min" -lt "45" ]; then + elif [ "$min" -lt "45" ] + then hour_color=$yellow else hour_color=$red diff --git a/themes/essential/essential.theme.bash b/themes/essential/essential.theme.bash index 05e84314..908c3c33 100644 --- a/themes/essential/essential.theme.bash +++ b/themes/essential/essential.theme.bash @@ -3,7 +3,8 @@ function _user-prompt() { local -r user='\u' - if [[ "${EUID}" -eq 0 ]]; then + if [[ "${EUID}" -eq 0 ]] + then # Privileged users: local -r user_color="${bold_red?}" else @@ -19,7 +20,8 @@ function _host-prompt() { local -r host='\h' # Check whether or not $SSH_TTY is set: - if [[ -z "${SSH_TTY:-}" ]]; then + if [[ -z "${SSH_TTY:-}" ]] + then # For local hosts, set the host's prompt color to blue: local -r host_color="${bold_blue?}" else @@ -43,7 +45,8 @@ function _exit-status-prompt() { local -r exit_status="${2}" # Check the exit status of the last command captured by $exit_status: - if [[ "${exit_status}" -eq 0 ]]; then + if [[ "${exit_status}" -eq 0 ]] + then # For commands that return an exit status of zero, set the exit status's # notifier to green: local -r exit_status_color="${bold_green?}" @@ -53,10 +56,12 @@ function _exit-status-prompt() { local -r exit_status_color="${bold_red?}" fi - if [[ "${prompt_string}" -eq 1 ]]; then + if [[ "${prompt_string}" -eq 1 ]] + then # $PS1: printf '%b +%b' "${exit_status_color}" "${normal?} " - elif [[ "${prompt_string}" -eq 2 ]]; then + elif [[ "${prompt_string}" -eq 2 ]] + then # $PS2: printf '%b |%b' "${exit_status_color}" "${normal?} " else diff --git a/themes/font/font.theme.bash b/themes/font/font.theme.bash index 2dbcccea..97a7fdb6 100644 --- a/themes/font/font.theme.bash +++ b/themes/font/font.theme.bash @@ -49,7 +49,8 @@ function prompt_command() { virtualenv="${white}$(virtualenv_prompt)" # Set return status color - if [[ ${RC} == 0 ]]; then + if [[ ${RC} == 0 ]] + then ret_status="${bold_green}" else ret_status="${bold_red}" diff --git a/themes/githelpers.theme.bash b/themes/githelpers.theme.bash index 719effec..2185c9ad 100644 --- a/themes/githelpers.theme.bash +++ b/themes/githelpers.theme.bash @@ -9,8 +9,10 @@ function _git-symbolic-ref() { # same commit. _git-branch is used to explicitly choose the checked-out # branch. function _git-branch() { - if [[ "${SCM_GIT_GITSTATUS_RAN:-}" == "true" ]]; then - if [[ -n "${VCS_STATUS_LOCAL_BRANCH:-}" ]]; then + if [[ "${SCM_GIT_GITSTATUS_RAN:-}" == "true" ]] + then + if [[ -n "${VCS_STATUS_LOCAL_BRANCH:-}" ]] + then echo "${VCS_STATUS_LOCAL_BRANCH}" else return 1 @@ -21,8 +23,10 @@ function _git-branch() { } function _git-tag() { - if [[ "${SCM_GIT_GITSTATUS_RAN:-}" == "true" ]]; then - if [[ -n "${VCS_STATUS_TAG:-}" ]]; then + if [[ "${SCM_GIT_GITSTATUS_RAN:-}" == "true" ]] + then + if [[ -n "${VCS_STATUS_TAG:-}" ]] + then echo "${VCS_STATUS_TAG}" fi else @@ -35,7 +39,8 @@ function _git-commit-description() { } function _git-short-sha() { - if [[ "${SCM_GIT_GITSTATUS_RAN:-}" == "true" ]]; then + if [[ "${SCM_GIT_GITSTATUS_RAN:-}" == "true" ]] + then echo "${VCS_STATUS_COMMIT:0:7}" else git rev-parse --short HEAD @@ -44,7 +49,8 @@ function _git-short-sha() { # Try the checked-out branch first to avoid collision with branches pointing to the same ref. function _git-friendly-ref() { - if [[ "${SCM_GIT_GITSTATUS_RAN:-}" == "true" ]]; then + if [[ "${SCM_GIT_GITSTATUS_RAN:-}" == "true" ]] + then _git-branch || _git-tag || _git-short-sha # there is no tag based describe output in gitstatus else _git-branch || _git-tag || _git-commit-description || _git-short-sha @@ -93,7 +99,8 @@ function _git-hide-status() { function _git-status() { local git_status_flags= - if [[ "${SCM_GIT_IGNORE_UNTRACKED:-}" == "true" ]]; then + if [[ "${SCM_GIT_IGNORE_UNTRACKED:-}" == "true" ]] + then git_status_flags='-uno' fi git status --porcelain "${git_status_flags:---}" 2> /dev/null @@ -126,20 +133,25 @@ function _git-status-counts() { function _git-remote-info() { local same_branch_name="" branch_prefix # prompt handling only, reimplement because patching the routine below gets ugly - if [[ "${SCM_GIT_GITSTATUS_RAN:-}" == "true" ]]; then + if [[ "${SCM_GIT_GITSTATUS_RAN:-}" == "true" ]] + then [[ "${VCS_STATUS_REMOTE_NAME?}" == "" ]] && return [[ "${VCS_STATUS_LOCAL_BRANCH?}" == "${VCS_STATUS_REMOTE_BRANCH?}" ]] && same_branch_name=true # no multiple remote support in gitstatusd - if [[ "${SCM_GIT_SHOW_REMOTE_INFO:-}" == "true" || "${SCM_GIT_SHOW_REMOTE_INFO:-}" == "auto" ]]; then - if [[ ${same_branch_name:-} != "true" ]]; then + if [[ "${SCM_GIT_SHOW_REMOTE_INFO:-}" == "true" || "${SCM_GIT_SHOW_REMOTE_INFO:-}" == "auto" ]] + then + if [[ ${same_branch_name:-} != "true" ]] + then remote_info="${VCS_STATUS_REMOTE_NAME?}/${VCS_STATUS_REMOTE_BRANCH?}" else remote_info="${VCS_STATUS_REMOTE_NAME?}" fi - elif [[ ${same_branch_name:-} != "true" ]]; then + elif [[ ${same_branch_name:-} != "true" ]] + then remote_info="${VCS_STATUS_REMOTE_BRANCH?}" fi - if [[ -n "${remote_info:-}" ]]; then + if [[ -n "${remote_info:-}" ]] + then # no support for gone remote branches in gitstatusd branch_prefix="${SCM_THEME_BRANCH_TRACK_PREFIX:-}" echo "${branch_prefix}${remote_info:-}" @@ -149,20 +161,25 @@ function _git-remote-info() { [[ "$(_git-branch)" == "$(_git-upstream-branch)" ]] && same_branch_name=true if [[ ("${SCM_GIT_SHOW_REMOTE_INFO}" == "auto" && "$(_git-num-remotes)" -ge 2) || - "${SCM_GIT_SHOW_REMOTE_INFO}" == "true" ]]; then - if [[ ${same_branch_name:-} != "true" ]]; then + "${SCM_GIT_SHOW_REMOTE_INFO}" == "true" ]] + then + if [[ ${same_branch_name:-} != "true" ]] + then # shellcheck disable=SC2016 remote_info='$(_git-upstream)' else remote_info="$(_git-upstream-remote)" fi - elif [[ ${same_branch_name:-} != "true" ]]; then + elif [[ ${same_branch_name:-} != "true" ]] + then # shellcheck disable=SC2016 remote_info='$(_git-upstream-branch)' fi - if [[ -n "${remote_info:-}" ]]; then + if [[ -n "${remote_info:-}" ]] + then local branch_prefix - if _git-upstream-branch-gone; then + if _git-upstream-branch-gone + then branch_prefix="${SCM_THEME_BRANCH_GONE_PREFIX:-}" else branch_prefix="${SCM_THEME_BRANCH_TRACK_PREFIX:-}" diff --git a/themes/gitline/powerline.base.bash b/themes/gitline/powerline.base.bash index 7f6f3130..077c88f7 100644 --- a/themes/gitline/powerline.base.bash +++ b/themes/gitline/powerline.base.bash @@ -2,10 +2,12 @@ #To set color for foreground and background function set_color { set +u - if [[ "${1}" != "-" ]]; then + if [[ "${1}" != "-" ]] + then fg="38;5;${1}" fi - if [[ "${2}" != "-" ]]; then + if [[ "${2}" != "-" ]] + then bg="48;5;${2}" [[ -n "${fg}" ]] && bg=";${bg}" fi @@ -18,22 +20,26 @@ function __powerline_user_info_prompt { local color=${USER_INFO_THEME_PROMPT_COLOR} local fg_color=15 - if [[ "${THEME_CHECK_SUDO}" = true ]]; then - if sudo -n uptime 2>&1 | grep -q "load"; then + if [[ "${THEME_CHECK_SUDO}" = true ]] + then + if sudo -n uptime 2>&1 | grep -q "load" + then color=${USER_INFO_THEME_PROMPT_COLOR_SUDO} fi fi case "${POWERLINE_PROMPT_USER_INFO_MODE}" in "sudo") - if [[ "${color}" = "${USER_INFO_THEME_PROMPT_COLOR_SUDO}" ]]; then + if [[ "${color}" = "${USER_INFO_THEME_PROMPT_COLOR_SUDO}" ]] + then user_info="👑 ${USER}" fg_color=227 color=${USER_INFO_THEME_PROMPT_COLOR_SUDO} fi ;; *) - if [[ -n "${SSH_CLIENT}" ]] || [[ -n "${SSH_CONNECTION}" ]]; then + if [[ -n "${SSH_CLIENT}" ]] || [[ -n "${SSH_CONNECTION}" ]] + then user_info="${USER_INFO_SSH_CHAR}${USER}" else user_info="${USER}" @@ -48,9 +54,11 @@ function __powerline_ruby_prompt { local ruby_version="" local fg_color=206 - if _command_exists rvm; then + if _command_exists rvm + then ruby_version="$(rvm_version_prompt)" - elif _command_exists rbenv; then + elif _command_exists rbenv + then ruby_version=$(rbenv_version_prompt) fi @@ -63,10 +71,12 @@ function __powerline_python_venv_prompt { local python_venv="" local fg_color=206 - if [[ -n "${CONDA_DEFAULT_ENV}" ]]; then + if [[ -n "${CONDA_DEFAULT_ENV}" ]] + then python_venv="${CONDA_DEFAULT_ENV}" PYTHON_VENV_CHAR=${CONDA_PYTHON_VENV_CHAR} - elif [[ -n "${VIRTUAL_ENV}" ]]; then + elif [[ -n "${VIRTUAL_ENV}" ]] + then python_venv=$(basename "${VIRTUAL_ENV}") fi @@ -82,28 +92,36 @@ function __powerline_scm_prompt { scm_prompt_vars - if [[ "${SCM_NONE_CHAR}" != "${SCM_CHAR}" ]]; then - if [[ "${SCM_DIRTY}" -eq 3 ]]; then + if [[ "${SCM_NONE_CHAR}" != "${SCM_CHAR}" ]] + then + if [[ "${SCM_DIRTY}" -eq 3 ]] + then color=${SCM_THEME_PROMPT_STAGED_COLOR} fg_color=124 - elif [[ "${SCM_DIRTY}" -eq 2 ]]; then + elif [[ "${SCM_DIRTY}" -eq 2 ]] + then color=${SCM_THEME_PROMPT_UNSTAGED_COLOR} fg_color=56 - elif [[ "${SCM_DIRTY}" -eq 1 ]]; then + elif [[ "${SCM_DIRTY}" -eq 1 ]] + then color=${SCM_THEME_PROMPT_DIRTY_COLOR} fg_color=118 - elif [[ "${SCM_DIRTY}" -eq 0 ]]; then + elif [[ "${SCM_DIRTY}" -eq 0 ]] + then color=${SCM_THEME_PROMPT_CLEAN_COLOR} fg_color=16 else color=${SCM_THEME_PROMPT_COLOR} fg_color=255 fi - if [[ "${SCM_GIT_CHAR}" == "${SCM_CHAR}" ]]; then + if [[ "${SCM_GIT_CHAR}" == "${SCM_CHAR}" ]] + then scm_prompt+="${SCM_CHAR}${SCM_BRANCH}${SCM_STATE}" - elif [[ "${SCM_P4_CHAR}" == "${SCM_CHAR}" ]]; then + elif [[ "${SCM_P4_CHAR}" == "${SCM_CHAR}" ]] + then scm_prompt+="${SCM_CHAR}${SCM_BRANCH}${SCM_STATE}" - elif [[ "${SCM_HG_CHAR}" == "${SCM_CHAR}" ]]; then + elif [[ "${SCM_HG_CHAR}" == "${SCM_CHAR}" ]] + then scm_prompt+="${SCM_CHAR}${SCM_BRANCH}${SCM_STATE}" fi echo "${scm_prompt}${scm}|${color}|${fg_color}" @@ -140,12 +158,15 @@ function __powerline_battery_prompt { local battery_status="$(battery_percentage 2> /dev/null)" local fg_color=255 - if [[ -z "${battery_status}" ]] || [[ "${battery_status}" = "-1" ]] || [[ "${battery_status}" = "no" ]]; then + if [[ -z "${battery_status}" ]] || [[ "${battery_status}" = "-1" ]] || [[ "${battery_status}" = "no" ]] + then true else - if [[ "$((10#${battery_status}))" -le 5 ]]; then + if [[ "$((10#${battery_status}))" -le 5 ]] + then color="${BATTERY_STATUS_THEME_PROMPT_CRITICAL_COLOR}" - elif [[ "$((10#${battery_status}))" -le 25 ]]; then + elif [[ "$((10#${battery_status}))" -le 25 ]] + then color="${BATTERY_STATUS_THEME_PROMPT_LOW_COLOR}" else color="${BATTERY_STATUS_THEME_PROMPT_GOOD_COLOR}" @@ -158,7 +179,8 @@ function __powerline_battery_prompt { function __powerline_in_vim_prompt { local fg_color=206 - if [ -n "$VIMRUNTIME" ]; then + if [ -n "$VIMRUNTIME" ] + then echo "${IN_VIM_THEME_PROMPT_TEXT}|${IN_VIM_THEME_PROMPT_COLOR}|${fg_color}" fi } @@ -166,7 +188,8 @@ function __powerline_in_vim_prompt { function __powerline_aws_profile_prompt { local fg_color=206 - if [[ -n "${AWS_PROFILE}" ]]; then + if [[ -n "${AWS_PROFILE}" ]] + then echo "${AWS_PROFILE_CHAR}${AWS_PROFILE}|${AWS_PROFILE_PROMPT_COLOR}|${fg_color}" fi } @@ -174,7 +197,8 @@ function __powerline_aws_profile_prompt { function __powerline_in_toolbox_prompt { local fg_color=206 - if [ -f /run/.containerenv ] && [ -f /run/.toolboxenv ]; then + if [ -f /run/.containerenv ] && [ -f /run/.toolboxenv ] + then echo "${IN_TOOLBOX_THEME_PROMPT_TEXT}|${IN_TOOLBOX_THEME_PROMPT_COLOR}|${fg_color}" fi } @@ -188,7 +212,8 @@ function __powerline_left_segment { local fg_color=206 #for seperator character - if [[ "${SEGMENTS_AT_LEFT}" -gt 0 ]]; then + if [[ "${SEGMENTS_AT_LEFT}" -gt 0 ]] + then separator="$(set_color ${LAST_SEGMENT_COLOR} ${params[1]})${separator_char}${normal}" fi #change here to cahnge fg color @@ -199,7 +224,7 @@ function __powerline_left_segment { } function __powerline_last_status_prompt { - [[ "$1" -ne 0 ]] && echo "${1}|${LAST_STATUS_THEME_PROMPT_COLOR}" + [[ "${1}" -ne 0 ]] && echo "${1}|${LAST_STATUS_THEME_PROMPT_COLOR}" } function __powerline_prompt_command { @@ -211,7 +236,8 @@ function __powerline_prompt_command { LAST_SEGMENT_COLOR="" - if [[ -n "${POWERLINE_PROMPT_DISTRO_LOGO}" ]]; then + if [[ -n "${POWERLINE_PROMPT_DISTRO_LOGO}" ]] + then LEFT_PROMPT+="$(set_color ${PROMPT_DISTRO_LOGO_COLOR} ${PROMPT_DISTRO_LOGO_COLORBG})${PROMPT_DISTRO_LOGO}$(set_color - -)" fi diff --git a/themes/hawaii50/hawaii50.theme.bash b/themes/hawaii50/hawaii50.theme.bash index 404088d9..9b2a28e3 100644 --- a/themes/hawaii50/hawaii50.theme.bash +++ b/themes/hawaii50/hawaii50.theme.bash @@ -90,7 +90,8 @@ function get_ip_info { # Displays ip prompt function ip_prompt_info() { - if [[ $IP_ENABLED == 1 ]]; then + if [[ $IP_ENABLED == 1 ]] + then echo -e " ${DEFAULT_COLOR}(${IP_COLOR}$(get_ip_info)${DEFAULT_COLOR})" fi } @@ -120,7 +121,8 @@ function virtual_prompt_info() { # Parse git info function git_prompt_info() { - if [[ -n $(git status -s 2> /dev/null |grep -v ^# |grep -v "working directory clean") ]]; then + if [[ -n $(git status -s 2> /dev/null |grep -v ^# |grep -v "working directory clean") ]] + then state=${GIT_THEME_PROMPT_DIRTY:-$SCM_THEME_PROMPT_DIRTY} else state=${GIT_THEME_PROMPT_CLEAN:-$SCM_THEME_PROMPT_CLEAN} @@ -135,7 +137,8 @@ function git_prompt_info() { # Parse hg info function hg_prompt_info() { - if [[ -n $(hg status 2> /dev/null) ]]; then + if [[ -n $(hg status 2> /dev/null) ]] + then state=${HG_THEME_PROMPT_DIRTY:-$SCM_THEME_PROMPT_DIRTY} else state=${HG_THEME_PROMPT_CLEAN:-$SCM_THEME_PROMPT_CLEAN} @@ -150,7 +153,8 @@ function hg_prompt_info() { # Parse svn info function svn_prompt_info() { - if [[ -n $(svn status --ignore-externals -q 2> /dev/null) ]]; then + if [[ -n $(svn status --ignore-externals -q 2> /dev/null) ]] + then state=${SVN_THEME_PROMPT_DIRTY:-$SCM_THEME_PROMPT_DIRTY} else state=${SVN_THEME_PROMPT_CLEAN:-$SCM_THEME_PROMPT_CLEAN} @@ -188,7 +192,8 @@ function prompt() { local UC=$USER_COLOR [ $UID -eq "0" ] && UC=$SUPERUSER_COLOR - if [[ $VIRTUAL_PROMPT_ENABLED == 1 ]]; then + if [[ $VIRTUAL_PROMPT_ENABLED == 1 ]] + then PS1="$(scm_char) ${UC}\u ${DEFAULT_COLOR}at ${MACHINE_COLOR}\h$(ip_prompt_info) ${DEFAULT_COLOR}in ${DIRECTORY_COLOR}$(limited_pwd)${DEFAULT_COLOR}$(virtual_prompt_info)$(scm_prompt_info)${reset_color} \$ " else PS1="$(scm_char) ${UC}\u ${DEFAULT_COLOR}at ${MACHINE_COLOR}\h$(ip_prompt_info) ${DEFAULT_COLOR}in ${DIRECTORY_COLOR}$(limited_pwd)${DEFAULT_COLOR}$(scm_prompt_info)${reset_color} \$ " diff --git a/themes/iterate/iterate.theme.bash b/themes/iterate/iterate.theme.bash index cf682a9f..545065c0 100644 --- a/themes/iterate/iterate.theme.bash +++ b/themes/iterate/iterate.theme.bash @@ -28,7 +28,8 @@ RBFU_THEME_PROMPT_PREFIX="|" RBFU_THEME_PROMPT_SUFFIX="| " function rvm_version_prompt { - if which rvm &> /dev/null; then + if which rvm &> /dev/null + then rvm_current=$(rvm tools identifier) || return rvm_default=$(rvm strings default) || return [ "$rvm_current" != "$rvm_default" ] && ( echo -e "$RVM_THEME_PROMPT_PREFIX$rvm_current$RVM_THEME_PROMPT_SUFFIX" ) @@ -45,7 +46,8 @@ function prompt_command() { local new_PS1="${bold_cyan}$(scm_char)${yellow}$(ruby_version_prompt)${green}\w $(scm_prompt_info)" local new_prompt=$(PS1="$new_PS1" "$BASH" --norc -i &1 | sed -n '${s/^\(.*\)exit$/\1/p;}') - if [ "$LAST_PROMPT" = "$new_prompt" ]; then + if [ "$LAST_PROMPT" = "$new_prompt" ] + then new_PS1="" else LAST_PROMPT="$new_prompt" diff --git a/themes/liquidprompt/.gitignore b/themes/liquidprompt/.gitignore index 760c6d6f..fbbba950 100644 --- a/themes/liquidprompt/.gitignore +++ b/themes/liquidprompt/.gitignore @@ -1 +1 @@ -liquidprompt +liquidprompt diff --git a/themes/liquidprompt/liquidprompt.theme.bash b/themes/liquidprompt/liquidprompt.theme.bash index 60e64210..a25873c3 100644 --- a/themes/liquidprompt/liquidprompt.theme.bash +++ b/themes/liquidprompt/liquidprompt.theme.bash @@ -5,7 +5,8 @@ targetdir="$BASH_IT/themes/liquidprompt/liquidprompt" gray="\[\e[1;90m\]" cwd="$PWD" -if cd "$targetdir" &>/dev/null && git rev-parse --is-inside-work-tree &>/dev/null; then +if cd "$targetdir" &>/dev/null && git rev-parse --is-inside-work-tree &>/dev/null + then true else git clone https://github.com/nojhan/liquidprompt.git "$targetdir" && \ @@ -38,7 +39,8 @@ _lp_git_branch() local branch # Recent versions of Git support the --short option for symbolic-ref, but # not 1.7.9 (Ubuntu 12.04) - if branch="$(\git symbolic-ref -q HEAD)"; then + if branch="$(\git symbolic-ref -q HEAD)" + then _lp_escape "$(\git rev-parse --short=5 -q HEAD 2>/dev/null):${branch#refs/heads/}" else # In detached head state, use commit instead @@ -48,7 +50,8 @@ _lp_git_branch() } _lp_time() { - if (( LP_ENABLE_TIME )) && (( ! LP_TIME_ANALOG )); then + if (( LP_ENABLE_TIME )) && (( ! LP_TIME_ANALOG )) + then LP_TIME="${gray}$(date +%d-%H:%M)${normal}" else LP_TIME="" diff --git a/themes/mairan/mairan.theme.bash b/themes/mairan/mairan.theme.bash index 89466ead..699b18f8 100644 --- a/themes/mairan/mairan.theme.bash +++ b/themes/mairan/mairan.theme.bash @@ -1,7 +1,9 @@ # Mairan Bash Prompt, inspired by "Zork" -if tput setaf 1 &> /dev/null; then - if [[ $(tput colors) -ge 256 ]] 2>/dev/null; then +if tput setaf 1 &> /dev/null + then + if [[ $(tput colors) -ge 256 ]] 2>/dev/null + then MAGENTA=$(tput setaf 9) ORANGE=$(tput setaf 172) GREEN=$(tput setaf 190) diff --git a/themes/metal/metal.theme.bash b/themes/metal/metal.theme.bash index e0eddd26..d4b7e844 100644 --- a/themes/metal/metal.theme.bash +++ b/themes/metal/metal.theme.bash @@ -53,7 +53,8 @@ icon_end="└🤘-> " # Display virtual environment info function virtualenv_prompt { - if [[ -n "$VIRTUAL_ENV" ]]; then + if [[ -n "$VIRTUAL_ENV" ]] + then virtualenv=`basename "$VIRTUAL_ENV"` echo -e "$VIRTUALENV_CHAR$virtualenv " fi diff --git a/themes/minimal/minimal.theme.bash b/themes/minimal/minimal.theme.bash index 72fb2200..b5801c6e 100644 --- a/themes/minimal/minimal.theme.bash +++ b/themes/minimal/minimal.theme.bash @@ -5,7 +5,7 @@ SCM_THEME_PROMPT_SUFFIX="${cyan})" SCM_THEME_PROMPT_DIRTY=" ${red}✗" SCM_THEME_PROMPT_CLEAN=" ${green}✓" -prompt() { +function prompt() { PS1="$(scm_prompt_info)${reset_color} ${cyan}\W${reset_color} " } diff --git a/themes/modern-t/modern-t.theme.bash b/themes/modern-t/modern-t.theme.bash index 197f5a23..cc0ce2ae 100644 --- a/themes/modern-t/modern-t.theme.bash +++ b/themes/modern-t/modern-t.theme.bash @@ -25,14 +25,14 @@ esac PS3=">> " -is_vim_shell() { +function is_vim_shell() { if [ ! -z "$VIMRUNTIME" ] then echo "[${cyan}vim shell${normal}]" fi } -prompt() { +function prompt() { SCM_PROMPT_FORMAT='[%s][%s]' if [ $? -ne 0 ] then diff --git a/themes/modern-time/modern-time.theme.bash b/themes/modern-time/modern-time.theme.bash index fc8458ff..a129b661 100644 --- a/themes/modern-time/modern-time.theme.bash +++ b/themes/modern-time/modern-time.theme.bash @@ -21,18 +21,18 @@ esac PS3=">> " -is_vim_shell() { +function is_vim_shell() { if [ ! -z "$VIMRUNTIME" ] then echo "[${cyan}vim shell${normal}]" fi } -modern_current_time_prompt() { +function modern_current_time_prompt() { echo "[$(date '+%l:%M%p')]" } -prompt() { +function prompt() { SCM_PROMPT_FORMAT='[%s][%s]' if [ $? -ne 0 ] then diff --git a/themes/modern/modern.theme.bash b/themes/modern/modern.theme.bash index eadb0762..0f3f7703 100644 --- a/themes/modern/modern.theme.bash +++ b/themes/modern/modern.theme.bash @@ -22,26 +22,30 @@ esac PS3=">> " -is_vim_shell() { - if [ -n "$VIMRUNTIME" ]; then +function is_vim_shell() { + if [ -n "$VIMRUNTIME" ] + then echo "[${cyan}vim shell${normal}]" fi } -detect_venv() { +function detect_venv() { 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}) " - elif [[ -n "${VIRTUAL_ENV}" ]]; then + elif [[ -n "${VIRTUAL_ENV}" ]] + then python_venv="($PYTHON_VENV_CHAR$(basename "${VIRTUAL_ENV}")) " fi } -prompt() { +function prompt() { SCM_PROMPT_FORMAT='[%s][%s]' retval=$? - if [[ retval -ne 0 ]]; then + if [[ retval -ne 0 ]] + then PS1="${TITLEBAR}${bold_red}┌─${reset_color}$(scm_prompt)[${cyan}\u${normal}][${cyan}\w${normal}]$(is_vim_shell)\n${bold_red}└─▪${normal} " else PS1="${TITLEBAR}┌─$(scm_prompt)[${cyan}\u${normal}][${cyan}\w${normal}]$(is_vim_shell)\n└─▪ " diff --git a/themes/newin/newin.theme.bash b/themes/newin/newin.theme.bash index 9f54dc8a..56f7220b 100644 --- a/themes/newin/newin.theme.bash +++ b/themes/newin/newin.theme.bash @@ -5,9 +5,10 @@ SCM_THEME_PROMPT_CLEAN=" ${green}✓" SCM_THEME_PROMPT_PREFIX=" ${purple}|${green} " SCM_THEME_PROMPT_SUFFIX="${purple} |" -prompt() { +function prompt() { exit_code=$? - PS1="$(if [[ ${exit_code} = 0 ]]; then echo "${green}${exit_code}"; else echo "${red}${exit_code}"; fi) ${yellow}\t ${cyan}\w$(scm_prompt_info)${reset_color}\n${orange}$ ${reset_color}" + PS1="$(if [[ ${exit_code} = 0 ]] + then echo "${green}${exit_code}"; else echo "${red}${exit_code}"; fi) ${yellow}\t ${cyan}\w$(scm_prompt_info)${reset_color}\n${orange}$ ${reset_color}" } safe_append_prompt_command prompt diff --git a/themes/norbu/norbu.theme.bash b/themes/norbu/norbu.theme.bash index def58d81..4da94fac 100644 --- a/themes/norbu/norbu.theme.bash +++ b/themes/norbu/norbu.theme.bash @@ -2,7 +2,8 @@ # shellcheck disable=SC2034 # Expected behavior for themes. function set_prompt_symbol() { - if [[ $1 -eq 0 ]]; then + if [[ $1 -eq 0 ]] + then prompt_symbol=">_" else prompt_symbol="${orange?}>_${normal?}" @@ -11,7 +12,8 @@ function set_prompt_symbol() { function prompt_command() { local ret_val="$?" prompt_symbol scm_prompt_info - if [[ -n "${VIRTUAL_ENV:-}" ]]; then + if [[ -n "${VIRTUAL_ENV:-}" ]] + then PYTHON_VIRTUALENV="${bold_yellow?}[${VIRTUAL_ENV##*/}]" fi diff --git a/themes/nwinkler/nwinkler.theme.bash b/themes/nwinkler/nwinkler.theme.bash index 983c8d00..9679c9f1 100644 --- a/themes/nwinkler/nwinkler.theme.bash +++ b/themes/nwinkler/nwinkler.theme.bash @@ -23,9 +23,10 @@ function prompt_end() { echo -e "$PROMPT_END" } -prompt_setter() { +function prompt_setter() { local exit_status=$? - if [[ $exit_status -eq 0 ]]; then PROMPT_END=$PROMPT_END_CLEAN + if [[ $exit_status -eq 0 ]] + then PROMPT_END=$PROMPT_END_CLEAN else PROMPT_END=$PROMPT_END_DIRTY fi # Save history diff --git a/themes/nwinkler_random_colors/nwinkler_random_colors.theme.bash b/themes/nwinkler_random_colors/nwinkler_random_colors.theme.bash index 05391b0b..58a8b8e1 100644 --- a/themes/nwinkler_random_colors/nwinkler_random_colors.theme.bash +++ b/themes/nwinkler_random_colors/nwinkler_random_colors.theme.bash @@ -90,9 +90,10 @@ function prompt_end() { echo -e "$PROMPT_END" } -prompt_setter() { +function prompt_setter() { local exit_status=$? - if [[ $exit_status -eq 0 ]]; then PROMPT_END=$PROMPT_END_CLEAN + if [[ $exit_status -eq 0 ]] + then PROMPT_END=$PROMPT_END_CLEAN else PROMPT_END=$PROMPT_END_DIRTY fi # Save history diff --git a/themes/oh-my-posh/oh-my-posh.theme.bash b/themes/oh-my-posh/oh-my-posh.theme.bash index ba3c77f1..473052a4 100644 --- a/themes/oh-my-posh/oh-my-posh.theme.bash +++ b/themes/oh-my-posh/oh-my-posh.theme.bash @@ -1,6 +1,7 @@ # shellcheck shell=bash -if _command_exists oh-my-posh; then +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 diff --git a/themes/parrot/parrot.theme.bash b/themes/parrot/parrot.theme.bash index 251eb942..7b84d547 100644 --- a/themes/parrot/parrot.theme.bash +++ b/themes/parrot/parrot.theme.bash @@ -15,8 +15,10 @@ function prompt() { local force_color_prompt=yes - if [ -n "$force_color_prompt" ]; then - if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then + if [ -n "$force_color_prompt" ] + then + if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null + then # We have color support; assume it's compliant with Ecma-48 # (ISO/IEC-6429). (Lack of such support is extremely rare, and such # a case would tend to support setf rather than setaf.) @@ -26,8 +28,10 @@ function prompt() { fi fi - if [ "$color_prompt" = yes ]; then - PS1="\[\033[0;31m\]\342\224\214\342\224\200\$([[ \$? != 0 ]] && echo \"[\[\033[0;31m\]\342\234\227\[\033[0;37m\]]\342\224\200\")[$(if [[ ${EUID} == 0 ]]; then echo '\[\033[01;31m\]root\[\033[01;33m\]@\[\033[01;96m\]\h'; else echo '\[\033[0;39m\]\u\[\033[01;33m\]@\[\033[01;96m\]\h'; fi)\[\033[0;31m\]]\342\224\200[\[\033[0;32m\]\w\[\033[0;31m\]]\n\[\033[0;31m\]\342\224\224\342\224\200\342\224\200\342\225\274 \[\033[0m\]\[\e[01;33m\]$(parse_git_branch) $\[\e[0m\] " + if [ "$color_prompt" = yes ] + then + PS1="\[\033[0;31m\]\342\224\214\342\224\200\$([[ \$? != 0 ]] && echo \"[\[\033[0;31m\]\342\234\227\[\033[0;37m\]]\342\224\200\")[$(if [[ ${EUID} == 0 ]] + then echo '\[\033[01;31m\]root\[\033[01;33m\]@\[\033[01;96m\]\h'; else echo '\[\033[0;39m\]\u\[\033[01;33m\]@\[\033[01;96m\]\h'; fi)\[\033[0;31m\]]\342\224\200[\[\033[0;32m\]\w\[\033[0;31m\]]\n\[\033[0;31m\]\342\224\224\342\224\200\342\224\200\342\225\274 \[\033[0m\]\[\e[01;33m\]$(parse_git_branch) $\[\e[0m\] " else PS1='┌──[\u@\h]─[\w]\n└──╼ $(parse_git_branch_no_color) $ ' diff --git a/themes/powerline-multiline/powerline-multiline.base.bash b/themes/powerline-multiline/powerline-multiline.base.bash index f752bd75..99ba3c39 100644 --- a/themes/powerline-multiline/powerline-multiline.base.bash +++ b/themes/powerline-multiline/powerline-multiline.base.bash @@ -1,7 +1,7 @@ . "$BASH_IT/themes/powerline/powerline.base.bash" function __powerline_last_status_prompt { - [[ "$1" -ne 0 ]] && echo "$(set_color ${LAST_STATUS_THEME_PROMPT_COLOR} -) ${1} ${normal}" + [[ "${1}" -ne 0 ]] && echo "$(set_color ${LAST_STATUS_THEME_PROMPT_COLOR} -) ${1} ${normal}" } function __powerline_right_segment { @@ -11,23 +11,28 @@ function __powerline_right_segment { local padding=0 local pad_before_segment=" " - if [[ "${SEGMENTS_AT_RIGHT}" -eq 0 ]]; then - if [[ "${POWERLINE_COMPACT_AFTER_LAST_SEGMENT}" -ne 0 ]]; then + if [[ "${SEGMENTS_AT_RIGHT}" -eq 0 ]] + then + if [[ "${POWERLINE_COMPACT_AFTER_LAST_SEGMENT}" -ne 0 ]] + then pad_before_segment="" fi RIGHT_PROMPT+="$(set_color ${params[1]} -)${POWERLINE_RIGHT_END}${normal}" (( padding += 1 )) else - if [[ "${POWERLINE_COMPACT_BEFORE_SEPARATOR}" -ne 0 ]]; then + if [[ "${POWERLINE_COMPACT_BEFORE_SEPARATOR}" -ne 0 ]] + then pad_before_segment="" fi # Since the previous segment wasn't the last segment, add padding, if needed # - if [[ "${POWERLINE_COMPACT_AFTER_SEPARATOR}" -eq 0 ]]; then + if [[ "${POWERLINE_COMPACT_AFTER_SEPARATOR}" -eq 0 ]] + then RIGHT_PROMPT+="$(set_color - ${LAST_SEGMENT_COLOR}) ${normal}" (( padding += 1 )) fi - if [[ "${LAST_SEGMENT_COLOR}" -eq "${params[1]}" ]]; then + if [[ "${LAST_SEGMENT_COLOR}" -eq "${params[1]}" ]] + then RIGHT_PROMPT+="$(set_color - ${LAST_SEGMENT_COLOR})${POWERLINE_RIGHT_SEPARATOR_SOFT}${normal}" else RIGHT_PROMPT+="$(set_color ${params[1]} ${LAST_SEGMENT_COLOR})${POWERLINE_RIGHT_SEPARATOR}${normal}" @@ -69,21 +74,24 @@ function __powerline_prompt_command { [[ -n "${info}" ]] && __powerline_left_segment "${info}" done - if [[ -n "${LEFT_PROMPT}" ]] && [[ "${POWERLINE_COMPACT_AFTER_LAST_SEGMENT}" -eq 0 ]]; then + if [[ -n "${LEFT_PROMPT}" ]] && [[ "${POWERLINE_COMPACT_AFTER_LAST_SEGMENT}" -eq 0 ]] + then __powerline_left_last_segment_padding fi [[ -n "${LEFT_PROMPT}" ]] && LEFT_PROMPT+="$(set_color ${LAST_SEGMENT_COLOR} -)${POWERLINE_LEFT_END}${normal}" ## right prompt ## - if [[ -n "${POWERLINE_RIGHT_PROMPT}" ]]; then + if [[ -n "${POWERLINE_RIGHT_PROMPT}" ]] + then # LEFT_PROMPT+="${move_cursor_rightmost}" for segment in $POWERLINE_RIGHT_PROMPT; do local info="$(__powerline_${segment}_prompt)" [[ -n "${info}" ]] && __powerline_right_segment "${info}" done - if [[ -n "${RIGHT_PROMPT}" ]] && [[ "${POWERLINE_COMPACT_BEFORE_FIRST_SEGMENT}" -eq 0 ]]; then + if [[ -n "${RIGHT_PROMPT}" ]] && [[ "${POWERLINE_COMPACT_BEFORE_FIRST_SEGMENT}" -eq 0 ]] + then __powerline_right_first_segment_padding fi @@ -93,7 +101,8 @@ function __powerline_prompt_command { fi local prompt="${PROMPT_CHAR}" - if [[ "${POWERLINE_COMPACT_PROMPT}" -eq 0 ]]; then + if [[ "${POWERLINE_COMPACT_PROMPT}" -eq 0 ]] + then prompt+=" " fi diff --git a/themes/powerline-naked/powerline-naked.base.bash b/themes/powerline-naked/powerline-naked.base.bash index dfc63f76..efe5f2a5 100644 --- a/themes/powerline-naked/powerline-naked.base.bash +++ b/themes/powerline-naked/powerline-naked.base.bash @@ -7,17 +7,21 @@ function __powerline_left_segment { local separator="" local pad_before_segment=" " - if [[ "${SEGMENTS_AT_LEFT}" -eq 0 ]]; then - if [[ "${POWERLINE_COMPACT_BEFORE_FIRST_SEGMENT}" -ne 0 ]]; then + if [[ "${SEGMENTS_AT_LEFT}" -eq 0 ]] + then + if [[ "${POWERLINE_COMPACT_BEFORE_FIRST_SEGMENT}" -ne 0 ]] + then pad_before_segment="" fi else - if [[ "${POWERLINE_COMPACT_AFTER_SEPARATOR}" -ne 0 ]]; then + if [[ "${POWERLINE_COMPACT_AFTER_SEPARATOR}" -ne 0 ]] + then pad_before_segment="" fi # Since the previous segment wasn't the last segment, add padding, if needed # - if [[ "${POWERLINE_COMPACT_BEFORE_SEPARATOR}" -eq 0 ]]; then + if [[ "${POWERLINE_COMPACT_BEFORE_SEPARATOR}" -eq 0 ]] + then LEFT_PROMPT+=" " fi LEFT_PROMPT+="${POWERLINE_LEFT_SEPARATOR}" diff --git a/themes/powerline-plain/powerline-plain.base.bash b/themes/powerline-plain/powerline-plain.base.bash index ce91ef89..850863a4 100644 --- a/themes/powerline-plain/powerline-plain.base.bash +++ b/themes/powerline-plain/powerline-plain.base.bash @@ -6,17 +6,21 @@ function __powerline_left_segment { IFS="${OLD_IFS}" local pad_before_segment=" " - if [[ "${SEGMENTS_AT_LEFT}" -eq 0 ]]; then - if [[ "${POWERLINE_COMPACT_BEFORE_FIRST_SEGMENT}" -ne 0 ]]; then + if [[ "${SEGMENTS_AT_LEFT}" -eq 0 ]] + then + if [[ "${POWERLINE_COMPACT_BEFORE_FIRST_SEGMENT}" -ne 0 ]] + then pad_before_segment="" fi else - if [[ "${POWERLINE_COMPACT_AFTER_SEPARATOR}" -ne 0 ]]; then + if [[ "${POWERLINE_COMPACT_AFTER_SEPARATOR}" -ne 0 ]] + then pad_before_segment="" fi # Since the previous segment wasn't the last segment, add padding, if needed # - if [[ "${POWERLINE_COMPACT_BEFORE_SEPARATOR}" -eq 0 ]]; then + if [[ "${POWERLINE_COMPACT_BEFORE_SEPARATOR}" -eq 0 ]] + then LEFT_PROMPT+="$(set_color - ${LAST_SEGMENT_COLOR}) ${normal}" fi fi @@ -44,11 +48,13 @@ function __powerline_prompt_command { [[ "${last_status}" -ne 0 ]] && __powerline_left_segment $(__powerline_last_status_prompt ${last_status}) - if [[ -n "${LEFT_PROMPT}" ]] && [[ "${POWERLINE_COMPACT_AFTER_LAST_SEGMENT}" -eq 0 ]]; then + if [[ -n "${LEFT_PROMPT}" ]] && [[ "${POWERLINE_COMPACT_AFTER_LAST_SEGMENT}" -eq 0 ]] + then __powerline_left_last_segment_padding fi - if [[ "${POWERLINE_COMPACT_PROMPT}" -eq 0 ]]; then + if [[ "${POWERLINE_COMPACT_PROMPT}" -eq 0 ]] + then LEFT_PROMPT+=" " fi diff --git a/themes/powerline/powerline.base.bash b/themes/powerline/powerline.base.bash index 84469e87..4808d714 100644 --- a/themes/powerline/powerline.base.bash +++ b/themes/powerline/powerline.base.bash @@ -3,10 +3,12 @@ function set_color() { local fg='' bg='' - if [[ "${1:-}" != "-" ]]; then + if [[ "${1:-}" != "-" ]] + then fg="38;5;${1}" fi - if [[ "${2:-}" != "-" ]]; then + if [[ "${2:-}" != "-" ]] + then bg="48;5;${2}" [[ -n "${fg}" ]] && bg=";${bg}" fi @@ -17,19 +19,22 @@ function __powerline_user_info_prompt() { local user_info="" local color=${USER_INFO_THEME_PROMPT_COLOR} - if [[ "${THEME_CHECK_SUDO}" = true ]]; then + if [[ "${THEME_CHECK_SUDO}" = true ]] + then sudo -vn 1> /dev/null 2>&1 && color=${USER_INFO_THEME_PROMPT_COLOR_SUDO} fi case "${POWERLINE_PROMPT_USER_INFO_MODE}" in "sudo") - if [[ "${color}" = "${USER_INFO_THEME_PROMPT_COLOR_SUDO}" ]]; then + if [[ "${color}" = "${USER_INFO_THEME_PROMPT_COLOR_SUDO}" ]] + then user_info="!" fi ;; *) local user=${SHORT_USER:-${USER}} - if [[ -n "${SSH_CLIENT}" ]] || [[ -n "${SSH_CONNECTION}" ]]; then + if [[ -n "${SSH_CLIENT}" ]] || [[ -n "${SSH_CONNECTION}" ]] + then user_info="${USER_INFO_SSH_CHAR}${user}" else user_info="${user}" @@ -42,7 +47,8 @@ function __powerline_user_info_prompt() { function __powerline_terraform_prompt() { local terraform_workspace="" - if [ -d .terraform ]; then + if [ -d .terraform ] + then terraform_workspace="$(terraform_workspace_prompt)" [[ -n "${terraform_workspace}" ]] && echo "${TERRAFORM_CHAR}${terraform_workspace}|${TERRAFORM_THEME_PROMPT_COLOR}" fi @@ -65,9 +71,11 @@ function __powerline_node_prompt() { function __powerline_ruby_prompt() { local ruby_version="" - if _command_exists rvm; then + if _command_exists rvm + then ruby_version="$(rvm_version_prompt)" - elif _command_exists rbenv; then + elif _command_exists rbenv + then ruby_version=$(rbenv_version_prompt) fi @@ -77,7 +85,8 @@ function __powerline_ruby_prompt() { function __powerline_k8s_context_prompt() { local kubernetes_context="" - if _command_exists kubectl; then + if _command_exists kubectl + then kubernetes_context="$(k8s_context_prompt)" fi @@ -87,7 +96,8 @@ function __powerline_k8s_context_prompt() { function __powerline_k8s_namespace_prompt() { local kubernetes_namespace="" - if _command_exists kubectl; then + if _command_exists kubectl + then kubernetes_namespace="$(k8s_namespace_prompt)" fi @@ -97,10 +107,12 @@ function __powerline_k8s_namespace_prompt() { function __powerline_python_venv_prompt() { local python_venv="" - if [[ -n "${CONDA_DEFAULT_ENV:-}" ]]; then + if [[ -n "${CONDA_DEFAULT_ENV:-}" ]] + then python_venv="${CONDA_DEFAULT_ENV}" PYTHON_VENV_CHAR=${CONDA_PYTHON_VENV_CHAR} - elif [[ -n "${VIRTUAL_ENV:-}" ]]; then + elif [[ -n "${VIRTUAL_ENV:-}" ]] + then python_venv="${VIRTUAL_ENV##*/}" fi @@ -113,23 +125,31 @@ function __powerline_scm_prompt() { scm_prompt_vars - if [[ "${SCM_NONE_CHAR}" != "${SCM_CHAR}" ]]; then - if [[ "${SCM_DIRTY}" -eq 3 ]]; then + if [[ "${SCM_NONE_CHAR}" != "${SCM_CHAR}" ]] + then + if [[ "${SCM_DIRTY}" -eq 3 ]] + then color=${SCM_THEME_PROMPT_STAGED_COLOR} - elif [[ "${SCM_DIRTY}" -eq 2 ]]; then + elif [[ "${SCM_DIRTY}" -eq 2 ]] + then color=${SCM_THEME_PROMPT_UNSTAGED_COLOR} - elif [[ "${SCM_DIRTY}" -eq 1 ]]; then + elif [[ "${SCM_DIRTY}" -eq 1 ]] + then color=${SCM_THEME_PROMPT_DIRTY_COLOR} else color=${SCM_THEME_PROMPT_CLEAN_COLOR} fi - if [[ "${SCM_GIT_CHAR}" == "${SCM_CHAR}" ]]; then + if [[ "${SCM_GIT_CHAR}" == "${SCM_CHAR}" ]] + then scm_prompt+="${SCM_CHAR}${SCM_BRANCH}${SCM_STATE}" - elif [[ "${SCM_P4_CHAR}" == "${SCM_CHAR}" ]]; then + elif [[ "${SCM_P4_CHAR}" == "${SCM_CHAR}" ]] + then scm_prompt+="${SCM_CHAR}${SCM_BRANCH}${SCM_STATE}" - elif [[ "${SCM_HG_CHAR}" == "${SCM_CHAR}" ]]; then + elif [[ "${SCM_HG_CHAR}" == "${SCM_CHAR}" ]] + then scm_prompt+="${SCM_CHAR}${SCM_BRANCH}${SCM_STATE}" - elif [[ "${SCM_SVN_CHAR}" == "${SCM_CHAR}" ]]; then + elif [[ "${SCM_SVN_CHAR}" == "${SCM_CHAR}" ]] + then scm_prompt+="${SCM_CHAR}${SCM_BRANCH}${SCM_STATE}" fi echo "${scm_prompt?}|${color}" @@ -156,12 +176,15 @@ function __powerline_battery_prompt() { local color="" battery_status battery_status="$(battery_percentage 2> /dev/null)" - if [[ -z "${battery_status}" || "${battery_status}" == "-1" || "${battery_status}" == "no" ]]; then + if [[ -z "${battery_status}" || "${battery_status}" == "-1" || "${battery_status}" == "no" ]] + then true else - if [[ "$((10#${battery_status}))" -le 5 ]]; then + if [[ "$((10#${battery_status}))" -le 5 ]] + then color="${BATTERY_STATUS_THEME_PROMPT_CRITICAL_COLOR}" - elif [[ "$((10#${battery_status}))" -le 25 ]]; then + elif [[ "$((10#${battery_status}))" -le 25 ]] + then color="${BATTERY_STATUS_THEME_PROMPT_LOW_COLOR}" else color="${BATTERY_STATUS_THEME_PROMPT_GOOD_COLOR}" @@ -172,25 +195,29 @@ function __powerline_battery_prompt() { } function __powerline_in_vim_prompt() { - if [[ -n "$VIMRUNTIME" ]]; then + if [[ -n "$VIMRUNTIME" ]] + then echo "${IN_VIM_THEME_PROMPT_TEXT}|${IN_VIM_THEME_PROMPT_COLOR}" fi } function __powerline_aws_profile_prompt() { - if [[ -n "${AWS_PROFILE}" ]]; then + if [[ -n "${AWS_PROFILE}" ]] + then echo "${AWS_PROFILE_CHAR}${AWS_PROFILE}|${AWS_PROFILE_PROMPT_COLOR}" fi } function __powerline_in_toolbox_prompt() { - if [ -f /run/.containerenv ] && [ -f /run/.toolboxenv ]; then + if [ -f /run/.containerenv ] && [ -f /run/.toolboxenv ] + then echo "${IN_TOOLBOX_THEME_PROMPT_TEXT}|${IN_TOOLBOX_THEME_PROMPT_COLOR}" fi } function __powerline_shlvl_prompt() { - if [[ "${SHLVL}" -gt 1 ]]; then + if [[ "${SHLVL}" -gt 1 ]] + then local prompt="${SHLVL_THEME_PROMPT_CHAR}" local level=$((SHLVL - 1)) echo "${prompt}${level}|${SHLVL_THEME_PROMPT_COLOR}" @@ -198,10 +225,12 @@ function __powerline_shlvl_prompt() { } function __powerline_dirstack_prompt() { - if [[ "${#DIRSTACK[@]}" -gt 1 ]]; then + if [[ "${#DIRSTACK[@]}" -gt 1 ]] + then local depth=$((${#DIRSTACK[@]} - 1)) local prompt="${DIRSTACK_THEME_PROMPT_CHAR}" - if [[ "${depth}" -ge 2 ]]; then + if [[ "${depth}" -ge 2 ]] + then prompt+="${depth}" fi echo "${prompt}|${DIRSTACK_THEME_PROMPT_COLOR}" @@ -227,20 +256,25 @@ function __powerline_left_segment() { IFS="|" read -ra params <<< "${1}" local pad_before_segment=" " - if [[ "${SEGMENTS_AT_LEFT}" -eq 0 ]]; then - if [[ "${POWERLINE_COMPACT_BEFORE_FIRST_SEGMENT}" -ne 0 ]]; then + if [[ "${SEGMENTS_AT_LEFT}" -eq 0 ]] + then + if [[ "${POWERLINE_COMPACT_BEFORE_FIRST_SEGMENT}" -ne 0 ]] + then pad_before_segment="" fi else - if [[ "${POWERLINE_COMPACT_AFTER_SEPARATOR}" -ne 0 ]]; then + if [[ "${POWERLINE_COMPACT_AFTER_SEPARATOR}" -ne 0 ]] + then pad_before_segment="" fi # Since the previous segment wasn't the last segment, add padding, if needed # - if [[ "${POWERLINE_COMPACT_BEFORE_SEPARATOR}" -eq 0 ]]; then + if [[ "${POWERLINE_COMPACT_BEFORE_SEPARATOR}" -eq 0 ]] + then LEFT_PROMPT+="$(set_color - "${LAST_SEGMENT_COLOR}") ${normal?}" fi - if [[ "${LAST_SEGMENT_COLOR}" -eq "${params[1]}" ]]; then + if [[ "${LAST_SEGMENT_COLOR}" -eq "${params[1]}" ]] + then LEFT_PROMPT+="$(set_color - "${LAST_SEGMENT_COLOR}")${POWERLINE_LEFT_SEPARATOR_SOFT}${normal?}" else LEFT_PROMPT+="$(set_color "${LAST_SEGMENT_COLOR}" "${params[1]}")${POWERLINE_LEFT_SEPARATOR}${normal?}" @@ -257,7 +291,7 @@ function __powerline_left_last_segment_padding() { } function __powerline_last_status_prompt() { - [[ "$1" -ne 0 ]] && echo "${1}|${LAST_STATUS_THEME_PROMPT_COLOR}" + [[ "${1}" -ne 0 ]] && echo "${1}|${LAST_STATUS_THEME_PROMPT_COLOR}" } function __powerline_prompt_command() { @@ -270,7 +304,8 @@ function __powerline_prompt_command() { _save-and-reload-history "${HISTORY_AUTOSAVE:-0}" - if [[ -n "${POWERLINE_PROMPT_DISTRO_LOGO}" ]]; then + if [[ -n "${POWERLINE_PROMPT_DISTRO_LOGO}" ]] + then LEFT_PROMPT+="$(set_color "${PROMPT_DISTRO_LOGO_COLOR}" "${PROMPT_DISTRO_LOGO_COLORBG}")${PROMPT_DISTRO_LOGO}$(set_color - -)" fi @@ -282,20 +317,23 @@ function __powerline_prompt_command() { [[ "${last_status}" -ne 0 ]] && __powerline_left_segment "$(__powerline_last_status_prompt "${last_status}")" - if [[ -n "${LEFT_PROMPT}" ]] && [[ "${POWERLINE_COMPACT_AFTER_LAST_SEGMENT:-}" -eq 0 ]]; then + if [[ -n "${LEFT_PROMPT}" ]] && [[ "${POWERLINE_COMPACT_AFTER_LAST_SEGMENT:-}" -eq 0 ]] + then __powerline_left_last_segment_padding fi # By default we try to match the prompt to the adjacent segment's background color, # but when part of the prompt exists within that segment, we instead match the foreground color. prompt_color="$(set_color "${LAST_SEGMENT_COLOR}" -)" - if [[ -n "${LEFT_PROMPT}" ]] && [[ -n "${POWERLINE_LEFT_LAST_SEGMENT_PROMPT_CHAR}" ]]; then + if [[ -n "${LEFT_PROMPT}" ]] && [[ -n "${POWERLINE_LEFT_LAST_SEGMENT_PROMPT_CHAR}" ]] + then LEFT_PROMPT+="$(set_color - "${LAST_SEGMENT_COLOR}")${POWERLINE_LEFT_LAST_SEGMENT_PROMPT_CHAR}" prompt_color="${normal?}" fi [[ -n "${LEFT_PROMPT}" ]] && LEFT_PROMPT+="${prompt_color}${separator_char}${normal?}" - if [[ "${POWERLINE_COMPACT_PROMPT:-}" -eq 0 ]]; then + if [[ "${POWERLINE_COMPACT_PROMPT:-}" -eq 0 ]] + then LEFT_PROMPT+=" " fi diff --git a/themes/powerturk/powerturk.theme.bash b/themes/powerturk/powerturk.theme.bash index 3352f680..2e59bd5f 100644 --- a/themes/powerturk/powerturk.theme.bash +++ b/themes/powerturk/powerturk.theme.bash @@ -45,7 +45,8 @@ _swd(){ current="" # The section of the path we're currently working on. end="${2:-${PWD}}/" # The unmodified rest of the path. - if [[ "$end" =~ "$HOME" ]]; then + if [[ "$end" =~ "$HOME" ]] + then INHOME=1 end="${end#$HOME}" #strip /home/username from start of string begin="$HOME" #start expansion from the right spot @@ -86,7 +87,8 @@ _swd(){ shortenedpath="${shortenedpath#/}" # strip leading / # Replaces slashes with  except first occurence. - if [ $INHOME -eq 1 ]; then + if [ $INHOME -eq 1 ] + then echo "~/$shortenedpath" | sed "s/\///2g" # make sure it starts with ~/ else echo "/$shortenedpath" | sed "s/\///2g" # Make sure it starts with / @@ -96,10 +98,12 @@ _swd(){ } function set_rgb_color { - if [[ "${1}" != "-" ]]; then + if [[ "${1}" != "-" ]] + then fg="38;5;${1}" fi - if [[ "${2}" != "-" ]]; then + if [[ "${2}" != "-" ]] + then bg="48;5;${2}" [[ -n "${fg}" ]] && bg=";${bg}" fi @@ -107,7 +111,8 @@ function set_rgb_color { } function powerline_shell_prompt { - if [[ -n "${SSH_CLIENT}" ]]; then + if [[ -n "${SSH_CLIENT}" ]] + then SHELL_PROMPT="${bold_white}$(set_rgb_color - ${SHELL_SSH_THEME_PROMPT_COLOR}) ${SHELL_SSH_CHAR}\u@\h ${normal}" LAST_THEME_COLOR=${SHELL_SSH_THEME_PROMPT_COLOR} else @@ -119,13 +124,16 @@ function powerline_shell_prompt { function powerline_virtualenv_prompt { local environ="" - if [[ -n "$CONDA_DEFAULT_ENV" ]]; then + if [[ -n "$CONDA_DEFAULT_ENV" ]] + then environ="conda: $CONDA_DEFAULT_ENV" - elif [[ -n "$VIRTUAL_ENV" ]]; then + elif [[ -n "$VIRTUAL_ENV" ]] + then environ=$(basename "$VIRTUAL_ENV") fi - if [[ -n "$environ" ]]; then + if [[ -n "$environ" ]] + then VIRTUALENV_PROMPT="$(set_rgb_color ${LAST_THEME_COLOR} ${VIRTUALENV_THEME_PROMPT_COLOR})${THEME_PROMPT_SEPARATOR}${normal}$(set_rgb_color - ${VIRTUALENV_THEME_PROMPT_COLOR}) ${VIRTUALENV_CHAR}$environ ${normal}" LAST_THEME_COLOR=${VIRTUALENV_THEME_PROMPT_COLOR} else @@ -136,17 +144,22 @@ function powerline_virtualenv_prompt { function powerline_scm_prompt { scm_prompt_vars - if [[ "${SCM_NONE_CHAR}" != "${SCM_CHAR}" ]]; then - if [[ "${SCM_DIRTY}" -eq 3 ]]; then + if [[ "${SCM_NONE_CHAR}" != "${SCM_CHAR}" ]] + then + if [[ "${SCM_DIRTY}" -eq 3 ]] + then SCM_PROMPT="$(set_rgb_color ${SCM_THEME_PROMPT_STAGED_COLOR} ${SCM_THEME_PROMPT_COLOR})" - elif [[ "${SCM_DIRTY}" -eq 2 ]]; then + elif [[ "${SCM_DIRTY}" -eq 2 ]] + then SCM_PROMPT="$(set_rgb_color ${SCM_THEME_PROMPT_UNSTAGED_COLOR} ${SCM_THEME_PROMPT_COLOR})" - elif [[ "${SCM_DIRTY}" -eq 1 ]]; then + elif [[ "${SCM_DIRTY}" -eq 1 ]] + then SCM_PROMPT="$(set_rgb_color ${SCM_THEME_PROMPT_DIRTY_COLOR} ${SCM_THEME_PROMPT_COLOR})" else SCM_PROMPT="$(set_rgb_color ${SCM_THEME_PROMPT_CLEAN_COLOR} ${SCM_THEME_PROMPT_COLOR})" fi - if [[ "${SCM_GIT_CHAR}" == "${SCM_CHAR}" ]]; then + if [[ "${SCM_GIT_CHAR}" == "${SCM_CHAR}" ]] + then SCM_PROMPT+=" ${SCM_CHAR}${SCM_BRANCH}${SCM_STATE}" fi SCM_PROMPT="$(set_rgb_color ${LAST_THEME_COLOR} ${SCM_THEME_PROMPT_COLOR})${THEME_PROMPT_SEPARATOR}${normal}${SCM_PROMPT} ${normal}" @@ -162,7 +175,8 @@ CWD_PROMPT="$(set_rgb_color ${LAST_THEME_COLOR} ${CWD_THEME_PROMPT_COLOR})${THEM } function powerline_last_status_prompt { - if [[ "$1" -eq 0 ]]; then + if [[ "${1}" -eq 0 ]] + then LAST_STATUS_PROMPT="$(set_rgb_color ${LAST_THEME_COLOR} -)${THEME_PROMPT_SEPARATOR}${normal}" else LAST_STATUS_PROMPT="$(set_rgb_color ${LAST_THEME_COLOR} ${LAST_STATUS_THEME_PROMPT_COLOR})${THEME_PROMPT_SEPARATOR}${normal}$(set_rgb_color - ${LAST_STATUS_THEME_PROMPT_COLOR}) ${LAST_STATUS} ${normal}$(set_rgb_color ${LAST_STATUS_THEME_PROMPT_COLOR} -)${THEME_PROMPT_SEPARATOR}${normal}" diff --git a/themes/purity/purity.theme.bash b/themes/purity/purity.theme.bash index 0fc6c4cf..d87a3cdb 100644 --- a/themes/purity/purity.theme.bash +++ b/themes/purity/purity.theme.bash @@ -18,9 +18,11 @@ STATUS_THEME_PROMPT_OK="${bold_green?}❯${reset_color?}${normal?} " function venv_prompt() { 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}) " - elif [[ -n "${VIRTUAL_ENV}" ]]; then + elif [[ -n "${VIRTUAL_ENV}" ]] + then python_venv="(${PYTHON_VENV_CHAR}${VIRTUAL_ENV##*/}) " fi [[ -n "${python_venv}" ]] && echo "${python_venv}" diff --git a/themes/rainbowbrite/rainbowbrite.theme.bash b/themes/rainbowbrite/rainbowbrite.theme.bash index 07e5843f..d2cbeada 100644 --- a/themes/rainbowbrite/rainbowbrite.theme.bash +++ b/themes/rainbowbrite/rainbowbrite.theme.bash @@ -5,7 +5,7 @@ # ± ~/path/to (branch ✓) $ # in glorious red / blue / yellow color scheme -prompt_setter() { +function prompt_setter() { # Save history _save-and-reload-history 1 # displays user@server in purple diff --git a/themes/ramses/ramses.theme.bash b/themes/ramses/ramses.theme.bash index 054a3160..c5ac7954 100644 --- a/themes/ramses/ramses.theme.bash +++ b/themes/ramses/ramses.theme.bash @@ -21,7 +21,7 @@ esac PS3=">> " -__my_rvm_ruby_version() { +function __my_rvm_ruby_version() { local gemset=$(echo $GEM_HOME | awk -F'@' '{print $2}') [ "$gemset" != "" ] && gemset="@$gemset" local version=$(echo $MY_RUBY_HOME | awk -F'-' '{print $2}') @@ -29,7 +29,7 @@ __my_rvm_ruby_version() { [ "$full" != "" ] && echo "[$full]" } -is_vim_shell() { +function is_vim_shell() { if [ ! -z "$VIMRUNTIME" ] then echo "[${cyan}vim shell${normal}]" @@ -37,7 +37,7 @@ is_vim_shell() { } # show chroot if exist -chroot(){ +function chroot(){ if [ -n "$debian_chroot" ] then my_ps_chroot="${bold_cyan}$debian_chroot${normal}"; @@ -46,7 +46,7 @@ chroot(){ } # show virtualenvwrapper -my_ve(){ +function my_ve(){ if [ -n "$CONDA_DEFAULT_ENV" ] then @@ -60,7 +60,7 @@ my_ve(){ echo ""; } -prompt() { +function prompt() { SCM_PROMPT_FORMAT='[%s][%s]' my_ps_host="${green}\h${normal}"; # yes, these are the the same for now ... diff --git a/themes/rana/rana.theme.bash b/themes/rana/rana.theme.bash index 3da74d6d..21bdb2fc 100644 --- a/themes/rana/rana.theme.bash +++ b/themes/rana/rana.theme.bash @@ -88,7 +88,7 @@ case $TERM in ;; esac -is_vim_shell() { +function is_vim_shell() { if [ ! -z "$VIMRUNTIME" ]; then echo "${D_INTERMEDIATE_COLOR}on ${D_VIMSHELL_COLOR}\ @@ -96,7 +96,7 @@ vim shell${D_DEFAULT_COLOR} " fi } -mitsuhikos_lastcommandfailed() { +function mitsuhikos_lastcommandfailed() { code=$? if [ $code != 0 ]; then @@ -106,7 +106,7 @@ $code ${D_DEFAULT_COLOR}" } # vcprompt for scm instead of bash_it default -demula_vcprompt() { +function demula_vcprompt() { if [ ! -z "$VCPROMPT_EXECUTABLE" ]; then local D_VCPROMPT_FORMAT="on ${D_SCM_COLOR}%s${D_INTERMEDIATE_COLOR}:\ @@ -116,43 +116,49 @@ ${D_BRANCH_COLOR}%b %r ${D_CHANGES_COLOR}%m%u ${D_DEFAULT_COLOR}" } # checks if the plugin is installed before calling battery_charge -safe_battery_charge() { +function safe_battery_charge() { if _command_exists battery_charge ; then battery_charge fi } -prompt_git() { +function prompt_git() { local s=''; local branchName=''; # Check if the current directory is in a Git repository. - if [ $(git rev-parse --is-inside-work-tree &>/dev/null; echo "${?}") == '0' ]; then + if [ $(git rev-parse --is-inside-work-tree &>/dev/null; echo "${?}") == '0' ] + then # check if the current directory is in .git before running git checks - if [ "$(git rev-parse --is-inside-git-dir 2> /dev/null)" == 'false' ]; then + if [ "$(git rev-parse --is-inside-git-dir 2> /dev/null)" == 'false' ] + then # Ensure the index is up to date. git update-index --really-refresh -q &>/dev/null; # Check for uncommitted changes in the index. - if ! $(git diff --quiet --ignore-submodules --cached); then + if ! $(git diff --quiet --ignore-submodules --cached) + then s+='+'; fi; # Check for unstaged changes. - if ! $(git diff-files --quiet --ignore-submodules --); then + if ! $(git diff-files --quiet --ignore-submodules --) + then s+='!'; fi; # Check for untracked files. - if [ -n "$(git ls-files --others --exclude-standard)" ]; then + if [ -n "$(git ls-files --others --exclude-standard)" ] + then s+='?'; fi; # Check for stashed files. - if $(git rev-parse --verify refs/stash &>/dev/null); then + if $(git rev-parse --verify refs/stash &>/dev/null) + then s+='$'; fi; @@ -174,7 +180,7 @@ prompt_git() { } # -------------------------------------------------------------- PROMPT OUTPUT -prompt() { +function prompt() { local LAST_COMMAND_FAILED=$(mitsuhikos_lastcommandfailed) local SAVE_CURSOR='\033[s' local RESTORE_CURSOR='\033[u' diff --git a/themes/rjorgenson/rjorgenson.theme.bash b/themes/rjorgenson/rjorgenson.theme.bash index 6e73c4a2..ea6f2795 100644 --- a/themes/rjorgenson/rjorgenson.theme.bash +++ b/themes/rjorgenson/rjorgenson.theme.bash @@ -30,7 +30,7 @@ esac PS3=">> " -__my_rvm_ruby_version() { +function __my_rvm_ruby_version() { local gemset=$(echo $GEM_HOME | awk -F'@' '{print $2}') [ "$gemset" != "" ] && gemset="@$gemset" local version=$(echo $MY_RUBY_HOME | awk -F'-' '{print $2}') @@ -38,7 +38,7 @@ __my_rvm_ruby_version() { [ "$full" != "" ] && echo "${BRACKET_COLOR}[${STRING_COLOR}$full${BRACKET_COLOR}]${normal}" } -is_vim_shell() { +function is_vim_shell() { if [ ! -z "$VIMRUNTIME" ] then echo "${BRACKET_COLOR}[${STRING_COLOR}vim shell${BRACKET_COLOR}]${normal}" @@ -46,28 +46,31 @@ is_vim_shell() { } function is_integer() { # helper function for todo-txt-count - [ "$1" -eq "$1" ] > /dev/null 2>&1 + [ "${1}" -eq "${1}" ] > /dev/null 2>&1 return $? } -todo_txt_count() { - if `hash todo.sh 2>&-`; then # is todo.sh installed +function todo_txt_count() { + if `hash todo.sh 2>&-` + then # is todo.sh installed 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" fi fi } -my_prompt_char() { - if [[ $OSTYPE =~ "darwin" ]]; then +function my_prompt_char() { + if [[ $OSTYPE =~ "darwin" ]] + then echo "${BRACKET_COLOR}➞ ${normal}" else echo "${BRACKET_COLOR}➞ ${normal}" fi } -prompt() { +function prompt() { SCM_PROMPT_FORMAT="${BRACKET_COLOR}[%s${BRACKET_COLOR}][${STRING_COLOR}%s${BRACKET_COLOR}]" my_ps_host="${STRING_COLOR}\h${normal}"; diff --git a/themes/roderik/roderik.theme.bash b/themes/roderik/roderik.theme.bash index 8a1c1045..d893bdc2 100644 --- a/themes/roderik/roderik.theme.bash +++ b/themes/roderik/roderik.theme.bash @@ -7,7 +7,8 @@ export GIT_PS1_SHOWSTASHSTATE=true export PROMPT_DIRTRIM=3 function prompt_command() { - if [[ ${EUID} == 0 ]] ; then + if [[ ${EUID} == 0 ]] + then PS1="[$(clock_prompt)]${yellow}[${red}\u@\h ${green}\w${yellow}]${red}$(__git_ps1 "(%s)")${normal}\\$ " else PS1="[$(clock_prompt)]${yellow}[${cyan}\u@\h ${green}\w${yellow}]${red}$(__git_ps1 "(%s)")${normal}\\$ " diff --git a/themes/sexy/sexy.theme.bash b/themes/sexy/sexy.theme.bash index 41d195d2..8d216596 100644 --- a/themes/sexy/sexy.theme.bash +++ b/themes/sexy/sexy.theme.bash @@ -9,8 +9,10 @@ # Default setting SEXY_THEME_SHOW_PYTHON="${SEXY_THEME_SHOW_PYTHON:=false}" -if tput setaf 1 &> /dev/null; then - if [[ $(tput colors) -ge 256 ]] 2>/dev/null; then +if tput setaf 1 &> /dev/null + then + if [[ $(tput colors) -ge 256 ]] 2>/dev/null + then MAGENTA=$(tput setaf 9) ORANGE=$(tput setaf 172) GREEN=$(tput setaf 190) @@ -35,20 +37,21 @@ else RESET="\033[m" fi -parse_git_dirty () { +function parse_git_dirty () { [[ $(git status 2> /dev/null | tail -n1 | cut -c 1-17) != "nothing to commit" ]] && echo "*" } -parse_git_branch () { +function parse_git_branch () { git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/\1$(parse_git_dirty)/" } -env_prompt () { +function env_prompt () { echo -e "($(virtualenv_prompt)$(condaenv_prompt))" } function prompt_command() { PS1="\[${BOLD}${MAGENTA}\]\u \[$WHITE\]at \[$ORANGE\]\h \[$WHITE\]in \[$GREEN\]\w\[$WHITE\]\$([[ -n \$(git branch 2> /dev/null) ]] && echo \" on \")\[$PURPLE\]\$(parse_git_branch)\[$WHITE\]\n\$ \[$RESET\]" - if [ "$SEXY_THEME_SHOW_PYTHON" = true ] ; then + if [ "$SEXY_THEME_SHOW_PYTHON" = true ] + then PS1="\[${BOLD}${WHITE}\]$(env_prompt) "$PS1 fi } diff --git a/themes/slick/slick.theme.bash b/themes/slick/slick.theme.bash index b0979b7c..b77cd700 100644 --- a/themes/slick/slick.theme.bash +++ b/themes/slick/slick.theme.bash @@ -21,7 +21,7 @@ esac PS3=">> " -__my_rvm_ruby_version() { +function __my_rvm_ruby_version() { local gemset=$(echo $GEM_HOME | awk -F'@' '{print $2}') [ "$gemset" != "" ] && gemset="@$gemset" local version=$(echo $MY_RUBY_HOME | awk -F'-' '{print $2}') @@ -29,21 +29,21 @@ __my_rvm_ruby_version() { [ "$full" != "" ] && echo "[$full]" } -__my_venv_prompt() { +function __my_venv_prompt() { if [ ! -z "$VIRTUAL_ENV" ] then echo "[${blue}@${normal}${VIRTUAL_ENV##*/}]" fi } -is_vim_shell() { +function is_vim_shell() { if [ ! -z "$VIMRUNTIME" ] then echo "[${cyan}vim shell${normal}]" fi } -prompt() { +function prompt() { SCM_PROMPT_FORMAT='[%s][%s]' case $HOSTNAME in "clappy"* ) my_ps_host="${green}\h${normal}"; diff --git a/themes/tonka/tonka.theme.bash b/themes/tonka/tonka.theme.bash index e97a5712..5a3d8fa0 100644 --- a/themes/tonka/tonka.theme.bash +++ b/themes/tonka/tonka.theme.bash @@ -1,23 +1,24 @@ #!/usr/bin/env bash -__tonka_time() { +function __tonka_time() { THEME_CLOCK_FORMAT="%H%M" clock_prompt } -__tonka_date() { +function __tonka_date() { THEME_CLOCK_FORMAT="%a,%d %b %y" clock_prompt } -__tonka_clock() { +function __tonka_clock() { local LIGHT_BLUE="\[\033[1;34m\]" - if [[ "${THEME_SHOW_CLOCK}" = "true" ]]; then + if [[ "${THEME_SHOW_CLOCK}" = "true" ]] + then echo "$(__tonka_time)${LIGHT_BLUE}:$(__tonka_date)${LIGHT_BLUE}:" fi } -prompt_setter() { +function prompt_setter() { # Named "Tonka" because of the colour scheme local WHITE="\[\033[1;37m\]" diff --git a/themes/wanelo/wanelo.theme.bash b/themes/wanelo/wanelo.theme.bash index 437fd327..a8911241 100644 --- a/themes/wanelo/wanelo.theme.bash +++ b/themes/wanelo/wanelo.theme.bash @@ -13,7 +13,8 @@ RVM_THEME_PROMPT_PREFIX="|" RVM_THEME_PROMPT_SUFFIX="|" function prompt_command() { - if [ $? -eq 0 ]; then + if [ $? -eq 0 ] + then status=❤️ else status=💔 diff --git a/themes/zork/zork.theme.bash b/themes/zork/zork.theme.bash index c8053450..25fd6942 100644 --- a/themes/zork/zork.theme.bash +++ b/themes/zork/zork.theme.bash @@ -21,7 +21,7 @@ esac PS3=">> " -__my_rvm_ruby_version() { +function __my_rvm_ruby_version() { local gemset=$(echo $GEM_HOME | awk -F'@' '{print $2}') [ "$gemset" != "" ] && gemset="@$gemset" local version=$(echo $MY_RUBY_HOME | awk -F'-' '{print $2}') @@ -29,7 +29,7 @@ __my_rvm_ruby_version() { [ "$full" != "" ] && echo "[$full]" } -is_vim_shell() { +function is_vim_shell() { if [ ! -z "$VIMRUNTIME" ] then echo "[${cyan}vim shell${normal}]" @@ -37,7 +37,7 @@ is_vim_shell() { } # show chroot if exist -chroot(){ +function chroot(){ if [ -n "$debian_chroot" ] then my_ps_chroot="${bold_cyan}$debian_chroot${normal}"; @@ -46,7 +46,7 @@ chroot(){ } # show virtualenvwrapper -my_ve(){ +function my_ve(){ if [ -n "$CONDA_DEFAULT_ENV" ] then @@ -60,7 +60,7 @@ my_ve(){ echo ""; } -prompt() { +function prompt() { SCM_PROMPT_FORMAT='[%s][%s]' my_ps_host="${green}\h${normal}"; # yes, these are the the same for now ... diff --git a/uninstall.sh b/uninstall.sh index 17712610..6af2dc83 100755 --- a/uninstall.sh +++ b/uninstall.sh @@ -15,7 +15,8 @@ esac BACKUP_FILE=$CONFIG_FILE.bak -if [ ! -e "$HOME/$BACKUP_FILE" ]; then +if [ ! -e "$HOME/$BACKUP_FILE" ] + then echo -e "\033[0;33mBackup file $HOME/$BACKUP_FILE not found.\033[0m" >&2 test -w "$HOME/$CONFIG_FILE" && diff --git a/vendor/.gitattributes b/vendor/.gitattributes index b82ad7fe..a7c8c944 100644 --- a/vendor/.gitattributes +++ b/vendor/.gitattributes @@ -1,2 +1,2 @@ -* -whitespace -init.d/*.bash text eol=lf +* -whitespace +init.d/*.bash text eol=lf diff --git a/vendor/github.com/django/django/AUTHORS b/vendor/github.com/django/django/AUTHORS index a77b219f..a6b46466 100644 --- a/vendor/github.com/django/django/AUTHORS +++ b/vendor/github.com/django/django/AUTHORS @@ -1,982 +1,982 @@ -Django was originally created in late 2003 at World Online, the Web division -of the Lawrence Journal-World newspaper in Lawrence, Kansas. - -Here is an inevitably incomplete list of MUCH-APPRECIATED CONTRIBUTORS -- -people who have submitted patches, reported bugs, added translations, helped -answer newbie questions, and generally made Django that much better: - - Aaron Cannon - Aaron Swartz - Aaron T. Myers - Abeer Upadhyay - Abhijeet Viswa - Abhinav Patil - Abhishek Gautam - Adam Allred - Adam Bogdał - Adam Donaghy - Adam Johnson - Adam Malinowski - Adam Vandenberg - Adiyat Mubarak - Adnan Umer - Adrian Holovaty - Adrien Lemaire - Afonso Fernández Nogueira - AgarFu - Ahmad Alhashemi - Ahmad Al-Ibrahim - Ahmed Eltawela - ajs - Akash Agrawal - Akis Kesoglou - Aksel Ethem - Akshesh Doshi - alang@bright-green.com - Alasdair Nicol - Albert Wang - Alcides Fonseca - Aldian Fazrihady - Aleksandra Sendecka - Aleksi Häkli - Alexander Dutton - Alexander Myodov - Alexandr Tatarinov - Alex Aktsipetrov - Alex Becker - Alex Couper - Alex Dedul - Alex Gaynor - Alex Hill - Alex Ogier - Alex Robbins - Alexey Boriskin - Alexey Tsivunin - Aljosa Mohorovic - Amit Chakradeo - Amit Ramon - Amit Upadhyay - A. Murat Eren - Ana Belen Sarabia - Ana Krivokapic - Andi Albrecht - André Ericson - Andrei Kulakov - Andreas - Andreas Mock - Andreas Pelme - Andrés Torres Marroquín - Andrew Brehaut - Andrew Clark - Andrew Durdin - Andrew Godwin - Andrew Pinkham - Andrews Medina - Andriy Sokolovskiy - Andy Dustman - Andy Gayton - andy@jadedplanet.net - Anssi Kääriäinen - ant9000@netwise.it - Anthony Briggs - Anton Samarchyan - Antoni Aloy - Antonio Cavedoni - Antonis Christofides - Antti Haapala - Antti Kaihola - Anubhav Joshi - Aram Dulyan - arien - Armin Ronacher - Aron Podrigal - Artem Gnilov - Arthur - Arthur Koziel - Arthur Rio - Arvis Bickovskis - Aryeh Leib Taurog - A S Alam - Asif Saif Uddin - atlithorn - Audrey Roy - av0000@mail.ru - Axel Haustant - Aymeric Augustin - Bahadır Kandemir - Baishampayan Ghose - Baptiste Mispelon - Barry Pederson - Bartolome Sanchez Salado - Bartosz Grabski - Bashar Al-Abdulhadi - Bastian Kleineidam - Batiste Bieler - Batman - Batuhan Taskaya - Baurzhan Ismagulov - Ben Dean Kawamura - Ben Firshman - Ben Godfrey - Benjamin Wohlwend - Ben Khoo - Ben Slavin - Ben Sturmfels - Berker Peksag - Bernd Schlapsi - Bernhard Essl - berto - Bill Fenner - Bjørn Stabell - Bo Marchman - Bogdan Mateescu - Bojan Mihelac - Bouke Haarsma - Božidar Benko - Brad Melin - Brandon Chinn - Brant Harris - Brendan Hayward - Brendan Quinn - Brenton Simpson - Brett Cannon - Brett Hoerner - Brian Beck - Brian Fabian Crain - Brian Harring - Brian Helba - Brian Ray - Brian Rosner - Bruce Kroeze - Bruno Alla - Bruno Renié - brut.alll@gmail.com - Bryan Chow - Bryan Veloso - bthomas - btoll@bestweb.net - C8E - Caio Ariede - Calvin Spealman - Cameron Curry - Cameron Knight (ckknight) - Can Burak Çilingir - Can Sarıgöl - Carl Meyer - Carles Pina i Estany - Carlos Eduardo de Paula - Carlos Matías de la Torre - Carlton Gibson - cedric@terramater.net - Chad Whitman - ChaosKCW - Charlie Leifer - charly.wilhelm@gmail.com - Chason Chaffin - Cheng Zhang - Chris Adams - Chris Beaven - Chris Bennett - Chris Cahoon - Chris Chamberlin - Chris Jerdonek - Chris Jones - Chris Lamb - Chris Streeter - Christian Barcenas - Christian Metts - Christian Oudard - Christian Tanzer - Christoffer Sjöbergsson - Christophe Pettus - Christopher Adams - Christopher Babiak - Christopher Lenz - Christoph Mędrela - Chris Wagner - Chris Wesseling - Chris Wilson - Claude Paroz - Clint Ecker - colin@owlfish.com - Colin Wood - Collin Anderson - Collin Grady - Colton Hicks - Craig Blaszczyk - crankycoder@gmail.com - Curtis Maloney (FunkyBob) - dackze+django@gmail.com - Dagur Páll Ammendrup - Dane Springmeyer - Dan Fairs - Daniel Alves Barbosa de Oliveira Vaz - Daniel Duan - Daniele Procida - Daniel Greenfeld - dAniel hAhler - Daniel Jilg - Daniel Lindsley - Daniel Poelzleithner - Daniel Pyrathon - Daniel Roseman - Daniel Tao - Daniel Wiesmann - Danilo Bargen - Dan Johnson - Dan Palmer - Dan Poirier - Dan Stephenson - Dan Watson - dave@thebarproject.com - David Ascher - David Avsajanishvili - David Blewett - David Brenneman - David Cramer - David Danier - David Eklund - David Foster - David Gouldin - david@kazserve.org - David Krauth - David Larlet - David Reynolds - David Sanders - David Schein - David Tulig - David Wobrock - Davide Ceretti - Deep L. Sukhwani - Deepak Thukral - Denis Kuzmichyov - Dennis Schwertel - Derek Willis - Deric Crago - deric@monowerks.com - Deryck Hodge - Dimitris Glezos - Dirk Datzert - Dirk Eschler - Dmitri Fedortchenko - Dmitry Jemerov - dne@mayonnaise.net - Dolan Antenucci - Donald Harvey - Donald Stufft - Don Spaulding - Doug Beck - Doug Napoleone - dready - dusk@woofle.net - Dustyn Gibson - Ed Morley - eibaan@gmail.com - elky - Emmanuelle Delescolle - Emil Stenström - enlight - Enrico - Eric Boersma - Eric Brandwein - Eric Floehr - Eric Florenzano - Eric Holscher - Eric Moritz - Eric Palakovich Carr - Erik Karulf - Erik Romijn - eriks@win.tue.nl - Erwin Junge - Esdras Beleza - Espen Grindhaug - Eugene Lazutkin - Evan Grim - Fabrice Aneche - Farhaan Bukhsh - favo@exoweb.net - fdr - Federico Capoano - Felipe Lee - Filip Noetzel - Filip Wasilewski - Finn Gruwier Larsen - Flávio Juvenal da Silva Junior - flavio.curella@gmail.com - Florian Apolloner - Florian Moussous - Fran Hrženjak - Francisco Albarran Cristobal - Francisco Couzo - François Freitag - Frank Tegtmeyer - Frank Wierzbicki - Frank Wiles - František Malina - Fraser Nevett - Gabriel Grant - Gabriel Hurley - gandalf@owca.info - Garry Lawrence - Garry Polley - Garth Kidd - Gary Wilson - Gasper Koren - Gasper Zejn - Gavin Wahl - Ge Hanbin - geber@datacollect.com - Geert Vanderkelen - George Karpenkov - George Song - George Vilches - Georg "Hugo" Bauer - Georgi Stanojevski - Gerardo Orozco - Gil Gonçalves - Girish Kumar - Gisle Aas - Glenn Maynard - glin@seznam.cz - GomoX - Gonzalo Saavedra - Gopal Narayanan - Graham Carlyle - Grant Jenks - Greg Chapple - Gregor Allensworth - Gregor Müllegger - Grigory Fateyev - Grzegorz Ślusarek - Guilherme Mesquita Gondim - Guillaume Pannatier - Gustavo Picon - hambaloney - Hang Park - Hannes Ljungberg - Hannes Struß - Hasan Ramezani - Hawkeye - Helen Sherwood-Taylor - Henrique Romano - Henry Dang - Hidde Bultsma - Himanshu Chauhan - hipertracker@gmail.com - Hiroki Kiyohara - Honza Král - Horst Gutmann - Hugo Osvaldo Barrera - HyukJin Jang - Hyun Mi Ae - Iacopo Spalletti - Ian A Wilson - Ian Clelland - Ian G. Kelly - Ian Holsman - Ian Lee - Ibon - Idan Gazit - Idan Melamed - Ifedapo Olarewaju - Igor Kolar - Illia Volochii - Ilya Semenov - Ingo Klöcker - I.S. van Oostveen - ivan.chelubeev@gmail.com - Ivan Sagalaev (Maniac) - Jaap Roes - Jack Moffitt - Jacob Burch - Jacob Green - Jacob Kaplan-Moss - Jakub Paczkowski - Jakub Wilk - Jakub Wiśniowski - james_027@yahoo.com - James Aylett - James Bennett - James Murty - James Tauber - James Timmins - James Turk - James Wheare - Jannis Leidel - Janos Guljas - Jan Pazdziora - Jan Rademaker - Jarek Głowacki - Jarek Zgoda - Jason Davies (Esaj) - Jason Huggins - Jason McBrayer - jason.sidabras@gmail.com - Jason Yan - Javier Mansilla - Jay Parlar - Jay Welborn - Jay Wineinger - J. Clifford Dyer - jcrasta@gmail.com - jdetaeye - Jeff Anderson - Jeff Balogh - Jeff Hui - Jeffrey Gelens - Jeff Triplett - Jeffrey Yancey - Jens Diemer - Jens Page - Jensen Cochran - Jeong-Min Lee - Jérémie Blaser - Jeremy Bowman - Jeremy Carbaugh - Jeremy Dunck - Jeremy Lainé - Jesse Young - Jezeniel Zapanta - jhenry - Jim Dalton - Jimmy Song - Jiri Barton - Joachim Jablon - Joao Oliveira - Joao Pedro Silva - Joe Heck - Joel Bohman - Joel Heenan - Joel Watts - Joe Topjian - Johan C. Stöver - Johann Queuniet - john@calixto.net - John D'Agostino - John D'Ambrosio - John Huddleston - John Moses - John Paulett - John Shaffer - Jökull Sólberg Auðunsson - Jon Dufresne - Jonas Haag - Jonatas C. D. - Jonathan Buchanan - Jonathan Daugherty (cygnus) - Jonathan Feignberg - Jonathan Slenders - Jordan Dimov - Jordi J. Tablada - Jorge Bastida - Jorge Gajon - José Tomás Tocino García - Josef Rousek - Joseph Kocherhans - Josh Smeaton - Joshua Cannon - Joshua Ginsberg - Jozko Skrablin - J. Pablo Fernandez - jpellerin@gmail.com - Juan Catalano - Juan Manuel Caicedo - Juan Pedro Fisanotti - Julia Elman - Julia Matsieva - Julian Bez - Julien Phalip - Junyoung Choi - junzhang.jn@gmail.com - Jure Cuhalev - Justin Bronn - Justine Tunney - Justin Lilly - Justin Michalicek - Justin Myles Holmes - Jyrki Pulliainen - Kadesarin Sanjek - Karderio - Karen Tracey - Karol Sikora - Katherine “Kati” Michel - Kathryn Killebrew - Katie Miller - Keith Bussell - Kenneth Love - Kent Hauser - Kevin Grinberg - Kevin Kubasik - Kevin McConnell - Kieran Holland - kilian - Kim Joon Hwan 김준환 - Klaas van Schelven - knox - konrad@gwu.edu - Kowito Charoenratchatabhan - Krišjānis Vaiders - krzysiek.pawlik@silvermedia.pl - Krzysztof Jurewicz - Krzysztof Kulewski - kurtiss@meetro.com - Lakin Wecker - Lars Yencken - Lau Bech Lauritzen - Laurent Luce - Laurent Rahuel - lcordier@point45.com - Leah Culver - Leandra Finger - Lee Reilly - Lee Sanghyuck - Leo "hylje" Honkanen - Leo Shklovskii - Leo Soto - lerouxb@gmail.com - Lex Berezhny - Liang Feng - limodou - Lincoln Smith - Liu Yijie <007gzs@gmail.com> - Loek van Gent - Loïc Bistuer - Lowe Thiderman - Luan Pablo - Lucas Connors - Luciano Ramalho - Ludvig Ericson - Luis C. Berrocal - Łukasz Langa - Łukasz Rekucki - Luke Granger-Brown - Luke Plant - Maciej Fijalkowski - Maciej Wiśniowski - Mads Jensen - Makoto Tsuyuki - Malcolm Tredinnick - Manuel Saelices - Manuzhai - Marc Aymerich Gubern - Marc Egli - Marcel Telka - Marc Fargas - Marc Garcia - Marcin Wróbel - Marc Remolt - Marc Tamlyn - Marc-Aurèle Brothier - Marian Andre - Marijn Vriens - Mario Gonzalez - Mariusz Felisiak - Mark Biggers - Mark Gensler - mark@junklight.com - Mark Lavin - Mark Sandstrom - Markus Amalthea Magnuson - Markus Holtermann - Marten Kenbeek - Marti Raudsepp - martin.glueck@gmail.com - Martin Green - Martin Kosír - Martin Mahner - Martin Maney - Martin von Gagern - Mart Sõmermaa - Marty Alchin - Masashi Shibata - masonsimon+django@gmail.com - Massimiliano Ravelli - Massimo Scamarcia - Mathieu Agopian - Matías Bordese - Matt Boersma - Matt Croydon - Matt Deacalion Stevens - Matt Dennenbaum - Matthew Flanagan - Matthew Schinckel - Matthew Somerville - Matthew Tretter - Matthew Wilkes - Matthias Kestenholz - Matthias Pronk - Matt Hoskins - Matt McClanahan - Matt Riggott - Matt Robenolt - Mattia Larentis - Mattia Procopio - Mattias Loverot - mattycakes@gmail.com - Max Burstein - Max Derkachev - Max Smolens - Maxime Lorant - Maxime Turcotte - Maximilian Merz - Maximillian Dornseif - mccutchen@gmail.com - Meir Kriheli - Michael S. Brown - Michael Hall - Michael Josephson - Michael Manfre - michael.mcewan@gmail.com - Michael Placentra II - Michael Radziej - Michael Sanders - Michael Schwarz - Michael Sinov - Michael Thornhill - Michal Chruszcz - michal@plovarna.cz - Michał Modzelewski - Mihai Damian - Mihai Preda - Mikaël Barbero - Mike Axiak - Mike Grouchy - Mike Malone - Mike Richardson - Mike Wiacek - Mikhail Korobov - Mikko Hellsing - Mikołaj Siedlarek - milkomeda - Milton Waddams - mitakummaa@gmail.com - mmarshall - Moayad Mardini - Morgan Aubert - Moritz Sichert - Morten Bagai - msaelices - msundstr - Mushtaq Ali - Mykola Zamkovoi - Nadège Michel - Nagy Károly - Nasimul Haque - Nasir Hussain - Natalia Bidart - Nate Bragg - Nathan Gaberel - Neal Norwitz - Nebojša Dorđević - Ned Batchelder - Nena Kojadin - Niall Dalton - Niall Kelly - Nick Efford - Nick Lane - Nick Pope - Nick Presta - Nick Sandford - Nick Sarbicki - Niclas Olofsson - Nicola Larosa - Nicolas Lara - Nicolas Noé - Niran Babalola - Nis Jørgensen - Nowell Strite - Nuno Mariz - oggie rob - oggy - Oliver Beattie - Oliver Rutherfurd - Olivier Sels - Olivier Tabone - Orestis Markou - Orne Brocaar - Oscar Ramirez - Ossama M. Khayat - Owen Griffiths - Pablo Martín - Panos Laganakos - Paolo Melchiorre - Pascal Hartig - Pascal Varet - Patrik Sletmo - Paul Bissex - Paul Collier - Paul Collins - Paul Donohue - Paul Lanier - Paul McLanahan - Paul McMillan - Paulo Poiati - Paulo Scardine - Paul Smith - Pavel Kulikov - pavithran s - Pavlo Kapyshin - permonik@mesias.brnonet.cz - Petar Marić - Pete Crosier - peter@mymart.com - Peter Sheats - Peter van Kampen - Peter Zsoldos - Pete Shinners - Petr Marhoun - pgross@thoughtworks.com - phaedo - phil.h.smith@gmail.com - Philip Lindborg - Philippe Raoult - phil@produxion.net - Piotr Jakimiak - Piotr Lewandowski - plisk - polpak@yahoo.com - pradeep.gowda@gmail.com - Preston Holmes - Preston Timmons - Priyansh Saxena - Przemysław Buczkowski - Przemysław Suliga - Qi Zhao - Rachel Tobin - Rachel Willmer - Radek Švarz - Raffaele Salmaso - Rajesh Dhawan - Ramez Ashraf - Ramin Farajpour Cami - Ramiro Morales - Ramon Saraiva - Ram Rachum - Randy Barlow - Raphaël Barrois - Raphael Michel - Raúl Cumplido - Rebecca Smith - Remco Wendt - Renaud Parent - Renbi Yu - Reza Mohammadi - rhettg@gmail.com - Ricardo Javier Cárdenes Medina - ricardojbarrios@gmail.com - Riccardo Di Virgilio - Riccardo Magliocchetti - Richard Davies - Richard House - Rick Wagner - Rigel Di Scala - Robert Coup - Robert Myers - Roberto Aguilar - Robert Rock Howard - Robert Wittams - Rob Golding-Day - Rob Hudson - Rob Nguyen - Robin Munn - Rodrigo Pinheiro Marques de Araújo - Romain Garrigues - Ronny Haryanto - Ross Poulton - Rozza - Rudolph Froger - Rudy Mutter - Rune Rønde Laursen - Russell Cloran - Russell Keith-Magee - Russ Webber - Ryan Hall - ryankanno - Ryan Kelly - Ryan Niemeyer - Ryan Petrello - Ryan Rubin - Ryno Mathee - Sachin Jat - Sage M. Abdullah - Sam Newman - Sander Dijkhuis - Sanket Saurav - Sanyam Khurana - Sarthak Mehrish - schwank@gmail.com - Scot Hacker - Scott Barr - Scott Fitsimones - Scott Pashley - scott@staplefish.com - Sean Brant - Sebastian Hillig - Sebastian Spiegel - Segyo Myung - Selwin Ong - Sengtha Chay - Senko Rašić - serbaut@gmail.com - Sergei Maertens - Sergey Fedoseev - Sergey Kolosov - Seth Hill - Shai Berger - Shannon -jj Behrens - Shawn Milochik - Silvan Spross - Simeon Visser - Simon Blanchard - Simon Charette - Simon Greenhill - Simon Litchfield - Simon Meers - Simon Williams - Simon Willison - Sjoerd Job Postmus - Slawek Mikula - sloonz - smurf@smurf.noris.de - sopel - Srinivas Reddy Thatiparthy - Stanislas Guerra - Stanislaus Madueke - Stanislav Karpov - starrynight - Stefan R. Filipek - Stefane Fermgier - Stefano Rivera - Stéphane Raimbault - Stephan Jaekel - Stephen Burrows - Steven L. Smith (fvox13) - Steven Noorbergen (Xaroth) - Stuart Langridge - Subhav Gautam - Sujay S Kumar - Sune Kirkeby - Sung-Jin Hong - SuperJared - Susan Tan - Sutrisno Efendi - Swaroop C H - Szilveszter Farkas - Taavi Teska - Tai Lee - Takashi Matsuo - Tareque Hossain - Taylor Mitchell - Terry Huang - thebjorn - Thejaswi Puthraya - Thijs van Dien - Thom Wiggers - Thomas Chaumeny - Thomas Güttler - Thomas Kerpe - Thomas Sorrel - Thomas Steinacher - Thomas Stromberg - Thomas Tanner - tibimicu@gmx.net - Tim Allen - Tim Givois - Tim Graham - Tim Heap - Tim Saylor - Tobias Kunze - Tobias McNulty - tobias@neuyork.de - Todd O'Bryan - Tom Carrick - Tom Christie - Tom Forbes - Tom Insam - Tom Tobin - Tomáš Ehrlich - Tomáš Kopeček - Tome Cvitan - Tomek Paczkowski - Tomer Chachamu - Tommy Beadle - Tore Lundqvist - torne-django@wolfpuppy.org.uk - Travis Cline - Travis Pinney - Travis Swicegood - Travis Terry - Trevor Caira - Trey Long - tstromberg@google.com - tt@gurgle.no - Tyler Tarabula - Tyson Clugg - Tyson Tate - Unai Zalakain - Valentina Mukhamedzhanova - valtron - Vasiliy Stavenko - Vasil Vangelovski - Vibhu Agarwal - Victor Andrée - viestards.lists@gmail.com - Viktor Danyliuk - Ville Säävuori - Vinay Karanam - Vinay Sajip - Vincent Foley - Vinny Do - Vitaly Babiy - Vladimir Kuzma - Vlado - Vsevolod Solovyov - Vytis Banaitis - wam-djangobug@wamber.net - Wang Chun - Warren Smith - Waylan Limberg - Wiktor Kołodziej - Wiley Kestner - Wiliam Alves de Souza - Will Ayd - William Schwartz - Will Hardy - Wilson Miner - Wim Glenn - wojtek - Xavier Francisco - Xia Kai - Yann Fouillat - Yann Malet - Yasushi Masuda - ye7cakf02@sneakemail.com - ymasuda@ethercube.com - Yoong Kang Lim - Yusuke Miyazaki - Zac Hatfield-Dodds - Zachary Voase - Zach Liu - Zach Thompson - Zain Memon - Zak Johnson - Žan Anderle - Zbigniew Siciarz - zegor - Zeynel Özdemir - Zlatko Mašek - zriv - - -A big THANK YOU goes to: - - Rob Curley and Ralph Gage for letting us open-source Django. - - Frank Wiles for making excellent arguments for open-sourcing, and for - his sage sysadmin advice. - - Ian Bicking for convincing Adrian to ditch code generation. - - Mark Pilgrim for "Dive Into Python" (https://www.diveinto.org/python3/). - - Guido van Rossum for creating Python. +Django was originally created in late 2003 at World Online, the Web division +of the Lawrence Journal-World newspaper in Lawrence, Kansas. + +Here is an inevitably incomplete list of MUCH-APPRECIATED CONTRIBUTORS -- +people who have submitted patches, reported bugs, added translations, helped +answer newbie questions, and generally made Django that much better: + + Aaron Cannon + Aaron Swartz + Aaron T. Myers + Abeer Upadhyay + Abhijeet Viswa + Abhinav Patil + Abhishek Gautam + Adam Allred + Adam Bogdał + Adam Donaghy + Adam Johnson + Adam Malinowski + Adam Vandenberg + Adiyat Mubarak + Adnan Umer + Adrian Holovaty + Adrien Lemaire + Afonso Fernández Nogueira + AgarFu + Ahmad Alhashemi + Ahmad Al-Ibrahim + Ahmed Eltawela + ajs + Akash Agrawal + Akis Kesoglou + Aksel Ethem + Akshesh Doshi + alang@bright-green.com + Alasdair Nicol + Albert Wang + Alcides Fonseca + Aldian Fazrihady + Aleksandra Sendecka + Aleksi Häkli + Alexander Dutton + Alexander Myodov + Alexandr Tatarinov + Alex Aktsipetrov + Alex Becker + Alex Couper + Alex Dedul + Alex Gaynor + Alex Hill + Alex Ogier + Alex Robbins + Alexey Boriskin + Alexey Tsivunin + Aljosa Mohorovic + Amit Chakradeo + Amit Ramon + Amit Upadhyay + A. Murat Eren + Ana Belen Sarabia + Ana Krivokapic + Andi Albrecht + André Ericson + Andrei Kulakov + Andreas + Andreas Mock + Andreas Pelme + Andrés Torres Marroquín + Andrew Brehaut + Andrew Clark + Andrew Durdin + Andrew Godwin + Andrew Pinkham + Andrews Medina + Andriy Sokolovskiy + Andy Dustman + Andy Gayton + andy@jadedplanet.net + Anssi Kääriäinen + ant9000@netwise.it + Anthony Briggs + Anton Samarchyan + Antoni Aloy + Antonio Cavedoni + Antonis Christofides + Antti Haapala + Antti Kaihola + Anubhav Joshi + Aram Dulyan + arien + Armin Ronacher + Aron Podrigal + Artem Gnilov + Arthur + Arthur Koziel + Arthur Rio + Arvis Bickovskis + Aryeh Leib Taurog + A S Alam + Asif Saif Uddin + atlithorn + Audrey Roy + av0000@mail.ru + Axel Haustant + Aymeric Augustin + Bahadır Kandemir + Baishampayan Ghose + Baptiste Mispelon + Barry Pederson + Bartolome Sanchez Salado + Bartosz Grabski + Bashar Al-Abdulhadi + Bastian Kleineidam + Batiste Bieler + Batman + Batuhan Taskaya + Baurzhan Ismagulov + Ben Dean Kawamura + Ben Firshman + Ben Godfrey + Benjamin Wohlwend + Ben Khoo + Ben Slavin + Ben Sturmfels + Berker Peksag + Bernd Schlapsi + Bernhard Essl + berto + Bill Fenner + Bjørn Stabell + Bo Marchman + Bogdan Mateescu + Bojan Mihelac + Bouke Haarsma + Božidar Benko + Brad Melin + Brandon Chinn + Brant Harris + Brendan Hayward + Brendan Quinn + Brenton Simpson + Brett Cannon + Brett Hoerner + Brian Beck + Brian Fabian Crain + Brian Harring + Brian Helba + Brian Ray + Brian Rosner + Bruce Kroeze + Bruno Alla + Bruno Renié + brut.alll@gmail.com + Bryan Chow + Bryan Veloso + bthomas + btoll@bestweb.net + C8E + Caio Ariede + Calvin Spealman + Cameron Curry + Cameron Knight (ckknight) + Can Burak Çilingir + Can Sarıgöl + Carl Meyer + Carles Pina i Estany + Carlos Eduardo de Paula + Carlos Matías de la Torre + Carlton Gibson + cedric@terramater.net + Chad Whitman + ChaosKCW + Charlie Leifer + charly.wilhelm@gmail.com + Chason Chaffin + Cheng Zhang + Chris Adams + Chris Beaven + Chris Bennett + Chris Cahoon + Chris Chamberlin + Chris Jerdonek + Chris Jones + Chris Lamb + Chris Streeter + Christian Barcenas + Christian Metts + Christian Oudard + Christian Tanzer + Christoffer Sjöbergsson + Christophe Pettus + Christopher Adams + Christopher Babiak + Christopher Lenz + Christoph Mędrela + Chris Wagner + Chris Wesseling + Chris Wilson + Claude Paroz + Clint Ecker + colin@owlfish.com + Colin Wood + Collin Anderson + Collin Grady + Colton Hicks + Craig Blaszczyk + crankycoder@gmail.com + Curtis Maloney (FunkyBob) + dackze+django@gmail.com + Dagur Páll Ammendrup + Dane Springmeyer + Dan Fairs + Daniel Alves Barbosa de Oliveira Vaz + Daniel Duan + Daniele Procida + Daniel Greenfeld + dAniel hAhler + Daniel Jilg + Daniel Lindsley + Daniel Poelzleithner + Daniel Pyrathon + Daniel Roseman + Daniel Tao + Daniel Wiesmann + Danilo Bargen + Dan Johnson + Dan Palmer + Dan Poirier + Dan Stephenson + Dan Watson + dave@thebarproject.com + David Ascher + David Avsajanishvili + David Blewett + David Brenneman + David Cramer + David Danier + David Eklund + David Foster + David Gouldin + david@kazserve.org + David Krauth + David Larlet + David Reynolds + David Sanders + David Schein + David Tulig + David Wobrock + Davide Ceretti + Deep L. Sukhwani + Deepak Thukral + Denis Kuzmichyov + Dennis Schwertel + Derek Willis + Deric Crago + deric@monowerks.com + Deryck Hodge + Dimitris Glezos + Dirk Datzert + Dirk Eschler + Dmitri Fedortchenko + Dmitry Jemerov + dne@mayonnaise.net + Dolan Antenucci + Donald Harvey + Donald Stufft + Don Spaulding + Doug Beck + Doug Napoleone + dready + dusk@woofle.net + Dustyn Gibson + Ed Morley + eibaan@gmail.com + elky + Emmanuelle Delescolle + Emil Stenström + enlight + Enrico + Eric Boersma + Eric Brandwein + Eric Floehr + Eric Florenzano + Eric Holscher + Eric Moritz + Eric Palakovich Carr + Erik Karulf + Erik Romijn + eriks@win.tue.nl + Erwin Junge + Esdras Beleza + Espen Grindhaug + Eugene Lazutkin + Evan Grim + Fabrice Aneche + Farhaan Bukhsh + favo@exoweb.net + fdr + Federico Capoano + Felipe Lee + Filip Noetzel + Filip Wasilewski + Finn Gruwier Larsen + Flávio Juvenal da Silva Junior + flavio.curella@gmail.com + Florian Apolloner + Florian Moussous + Fran Hrženjak + Francisco Albarran Cristobal + Francisco Couzo + François Freitag + Frank Tegtmeyer + Frank Wierzbicki + Frank Wiles + František Malina + Fraser Nevett + Gabriel Grant + Gabriel Hurley + gandalf@owca.info + Garry Lawrence + Garry Polley + Garth Kidd + Gary Wilson + Gasper Koren + Gasper Zejn + Gavin Wahl + Ge Hanbin + geber@datacollect.com + Geert Vanderkelen + George Karpenkov + George Song + George Vilches + Georg "Hugo" Bauer + Georgi Stanojevski + Gerardo Orozco + Gil Gonçalves + Girish Kumar + Gisle Aas + Glenn Maynard + glin@seznam.cz + GomoX + Gonzalo Saavedra + Gopal Narayanan + Graham Carlyle + Grant Jenks + Greg Chapple + Gregor Allensworth + Gregor Müllegger + Grigory Fateyev + Grzegorz Ślusarek + Guilherme Mesquita Gondim + Guillaume Pannatier + Gustavo Picon + hambaloney + Hang Park + Hannes Ljungberg + Hannes Struß + Hasan Ramezani + Hawkeye + Helen Sherwood-Taylor + Henrique Romano + Henry Dang + Hidde Bultsma + Himanshu Chauhan + hipertracker@gmail.com + Hiroki Kiyohara + Honza Král + Horst Gutmann + Hugo Osvaldo Barrera + HyukJin Jang + Hyun Mi Ae + Iacopo Spalletti + Ian A Wilson + Ian Clelland + Ian G. Kelly + Ian Holsman + Ian Lee + Ibon + Idan Gazit + Idan Melamed + Ifedapo Olarewaju + Igor Kolar + Illia Volochii + Ilya Semenov + Ingo Klöcker + I.S. van Oostveen + ivan.chelubeev@gmail.com + Ivan Sagalaev (Maniac) + Jaap Roes + Jack Moffitt + Jacob Burch + Jacob Green + Jacob Kaplan-Moss + Jakub Paczkowski + Jakub Wilk + Jakub Wiśniowski + james_027@yahoo.com + James Aylett + James Bennett + James Murty + James Tauber + James Timmins + James Turk + James Wheare + Jannis Leidel + Janos Guljas + Jan Pazdziora + Jan Rademaker + Jarek Głowacki + Jarek Zgoda + Jason Davies (Esaj) + Jason Huggins + Jason McBrayer + jason.sidabras@gmail.com + Jason Yan + Javier Mansilla + Jay Parlar + Jay Welborn + Jay Wineinger + J. Clifford Dyer + jcrasta@gmail.com + jdetaeye + Jeff Anderson + Jeff Balogh + Jeff Hui + Jeffrey Gelens + Jeff Triplett + Jeffrey Yancey + Jens Diemer + Jens Page + Jensen Cochran + Jeong-Min Lee + Jérémie Blaser + Jeremy Bowman + Jeremy Carbaugh + Jeremy Dunck + Jeremy Lainé + Jesse Young + Jezeniel Zapanta + jhenry + Jim Dalton + Jimmy Song + Jiri Barton + Joachim Jablon + Joao Oliveira + Joao Pedro Silva + Joe Heck + Joel Bohman + Joel Heenan + Joel Watts + Joe Topjian + Johan C. Stöver + Johann Queuniet + john@calixto.net + John D'Agostino + John D'Ambrosio + John Huddleston + John Moses + John Paulett + John Shaffer + Jökull Sólberg Auðunsson + Jon Dufresne + Jonas Haag + Jonatas C. D. + Jonathan Buchanan + Jonathan Daugherty (cygnus) + Jonathan Feignberg + Jonathan Slenders + Jordan Dimov + Jordi J. Tablada + Jorge Bastida + Jorge Gajon + José Tomás Tocino García + Josef Rousek + Joseph Kocherhans + Josh Smeaton + Joshua Cannon + Joshua Ginsberg + Jozko Skrablin + J. Pablo Fernandez + jpellerin@gmail.com + Juan Catalano + Juan Manuel Caicedo + Juan Pedro Fisanotti + Julia Elman + Julia Matsieva + Julian Bez + Julien Phalip + Junyoung Choi + junzhang.jn@gmail.com + Jure Cuhalev + Justin Bronn + Justine Tunney + Justin Lilly + Justin Michalicek + Justin Myles Holmes + Jyrki Pulliainen + Kadesarin Sanjek + Karderio + Karen Tracey + Karol Sikora + Katherine “Kati” Michel + Kathryn Killebrew + Katie Miller + Keith Bussell + Kenneth Love + Kent Hauser + Kevin Grinberg + Kevin Kubasik + Kevin McConnell + Kieran Holland + kilian + Kim Joon Hwan 김준환 + Klaas van Schelven + knox + konrad@gwu.edu + Kowito Charoenratchatabhan + Krišjānis Vaiders + krzysiek.pawlik@silvermedia.pl + Krzysztof Jurewicz + Krzysztof Kulewski + kurtiss@meetro.com + Lakin Wecker + Lars Yencken + Lau Bech Lauritzen + Laurent Luce + Laurent Rahuel + lcordier@point45.com + Leah Culver + Leandra Finger + Lee Reilly + Lee Sanghyuck + Leo "hylje" Honkanen + Leo Shklovskii + Leo Soto + lerouxb@gmail.com + Lex Berezhny + Liang Feng + limodou + Lincoln Smith + Liu Yijie <007gzs@gmail.com> + Loek van Gent + Loïc Bistuer + Lowe Thiderman + Luan Pablo + Lucas Connors + Luciano Ramalho + Ludvig Ericson + Luis C. Berrocal + Łukasz Langa + Łukasz Rekucki + Luke Granger-Brown + Luke Plant + Maciej Fijalkowski + Maciej Wiśniowski + Mads Jensen + Makoto Tsuyuki + Malcolm Tredinnick + Manuel Saelices + Manuzhai + Marc Aymerich Gubern + Marc Egli + Marcel Telka + Marc Fargas + Marc Garcia + Marcin Wróbel + Marc Remolt + Marc Tamlyn + Marc-Aurèle Brothier + Marian Andre + Marijn Vriens + Mario Gonzalez + Mariusz Felisiak + Mark Biggers + Mark Gensler + mark@junklight.com + Mark Lavin + Mark Sandstrom + Markus Amalthea Magnuson + Markus Holtermann + Marten Kenbeek + Marti Raudsepp + martin.glueck@gmail.com + Martin Green + Martin Kosír + Martin Mahner + Martin Maney + Martin von Gagern + Mart Sõmermaa + Marty Alchin + Masashi Shibata + masonsimon+django@gmail.com + Massimiliano Ravelli + Massimo Scamarcia + Mathieu Agopian + Matías Bordese + Matt Boersma + Matt Croydon + Matt Deacalion Stevens + Matt Dennenbaum + Matthew Flanagan + Matthew Schinckel + Matthew Somerville + Matthew Tretter + Matthew Wilkes + Matthias Kestenholz + Matthias Pronk + Matt Hoskins + Matt McClanahan + Matt Riggott + Matt Robenolt + Mattia Larentis + Mattia Procopio + Mattias Loverot + mattycakes@gmail.com + Max Burstein + Max Derkachev + Max Smolens + Maxime Lorant + Maxime Turcotte + Maximilian Merz + Maximillian Dornseif + mccutchen@gmail.com + Meir Kriheli + Michael S. Brown + Michael Hall + Michael Josephson + Michael Manfre + michael.mcewan@gmail.com + Michael Placentra II + Michael Radziej + Michael Sanders + Michael Schwarz + Michael Sinov + Michael Thornhill + Michal Chruszcz + michal@plovarna.cz + Michał Modzelewski + Mihai Damian + Mihai Preda + Mikaël Barbero + Mike Axiak + Mike Grouchy + Mike Malone + Mike Richardson + Mike Wiacek + Mikhail Korobov + Mikko Hellsing + Mikołaj Siedlarek + milkomeda + Milton Waddams + mitakummaa@gmail.com + mmarshall + Moayad Mardini + Morgan Aubert + Moritz Sichert + Morten Bagai + msaelices + msundstr + Mushtaq Ali + Mykola Zamkovoi + Nadège Michel + Nagy Károly + Nasimul Haque + Nasir Hussain + Natalia Bidart + Nate Bragg + Nathan Gaberel + Neal Norwitz + Nebojša Dorđević + Ned Batchelder + Nena Kojadin + Niall Dalton + Niall Kelly + Nick Efford + Nick Lane + Nick Pope + Nick Presta + Nick Sandford + Nick Sarbicki + Niclas Olofsson + Nicola Larosa + Nicolas Lara + Nicolas Noé + Niran Babalola + Nis Jørgensen + Nowell Strite + Nuno Mariz + oggie rob + oggy + Oliver Beattie + Oliver Rutherfurd + Olivier Sels + Olivier Tabone + Orestis Markou + Orne Brocaar + Oscar Ramirez + Ossama M. Khayat + Owen Griffiths + Pablo Martín + Panos Laganakos + Paolo Melchiorre + Pascal Hartig + Pascal Varet + Patrik Sletmo + Paul Bissex + Paul Collier + Paul Collins + Paul Donohue + Paul Lanier + Paul McLanahan + Paul McMillan + Paulo Poiati + Paulo Scardine + Paul Smith + Pavel Kulikov + pavithran s + Pavlo Kapyshin + permonik@mesias.brnonet.cz + Petar Marić + Pete Crosier + peter@mymart.com + Peter Sheats + Peter van Kampen + Peter Zsoldos + Pete Shinners + Petr Marhoun + pgross@thoughtworks.com + phaedo + phil.h.smith@gmail.com + Philip Lindborg + Philippe Raoult + phil@produxion.net + Piotr Jakimiak + Piotr Lewandowski + plisk + polpak@yahoo.com + pradeep.gowda@gmail.com + Preston Holmes + Preston Timmons + Priyansh Saxena + Przemysław Buczkowski + Przemysław Suliga + Qi Zhao + Rachel Tobin + Rachel Willmer + Radek Švarz + Raffaele Salmaso + Rajesh Dhawan + Ramez Ashraf + Ramin Farajpour Cami + Ramiro Morales + Ramon Saraiva + Ram Rachum + Randy Barlow + Raphaël Barrois + Raphael Michel + Raúl Cumplido + Rebecca Smith + Remco Wendt + Renaud Parent + Renbi Yu + Reza Mohammadi + rhettg@gmail.com + Ricardo Javier Cárdenes Medina + ricardojbarrios@gmail.com + Riccardo Di Virgilio + Riccardo Magliocchetti + Richard Davies + Richard House + Rick Wagner + Rigel Di Scala + Robert Coup + Robert Myers + Roberto Aguilar + Robert Rock Howard + Robert Wittams + Rob Golding-Day + Rob Hudson + Rob Nguyen + Robin Munn + Rodrigo Pinheiro Marques de Araújo + Romain Garrigues + Ronny Haryanto + Ross Poulton + Rozza + Rudolph Froger + Rudy Mutter + Rune Rønde Laursen + Russell Cloran + Russell Keith-Magee + Russ Webber + Ryan Hall + ryankanno + Ryan Kelly + Ryan Niemeyer + Ryan Petrello + Ryan Rubin + Ryno Mathee + Sachin Jat + Sage M. Abdullah + Sam Newman + Sander Dijkhuis + Sanket Saurav + Sanyam Khurana + Sarthak Mehrish + schwank@gmail.com + Scot Hacker + Scott Barr + Scott Fitsimones + Scott Pashley + scott@staplefish.com + Sean Brant + Sebastian Hillig + Sebastian Spiegel + Segyo Myung + Selwin Ong + Sengtha Chay + Senko Rašić + serbaut@gmail.com + Sergei Maertens + Sergey Fedoseev + Sergey Kolosov + Seth Hill + Shai Berger + Shannon -jj Behrens + Shawn Milochik + Silvan Spross + Simeon Visser + Simon Blanchard + Simon Charette + Simon Greenhill + Simon Litchfield + Simon Meers + Simon Williams + Simon Willison + Sjoerd Job Postmus + Slawek Mikula + sloonz + smurf@smurf.noris.de + sopel + Srinivas Reddy Thatiparthy + Stanislas Guerra + Stanislaus Madueke + Stanislav Karpov + starrynight + Stefan R. Filipek + Stefane Fermgier + Stefano Rivera + Stéphane Raimbault + Stephan Jaekel + Stephen Burrows + Steven L. Smith (fvox13) + Steven Noorbergen (Xaroth) + Stuart Langridge + Subhav Gautam + Sujay S Kumar + Sune Kirkeby + Sung-Jin Hong + SuperJared + Susan Tan + Sutrisno Efendi + Swaroop C H + Szilveszter Farkas + Taavi Teska + Tai Lee + Takashi Matsuo + Tareque Hossain + Taylor Mitchell + Terry Huang + thebjorn + Thejaswi Puthraya + Thijs van Dien + Thom Wiggers + Thomas Chaumeny + Thomas Güttler + Thomas Kerpe + Thomas Sorrel + Thomas Steinacher + Thomas Stromberg + Thomas Tanner + tibimicu@gmx.net + Tim Allen + Tim Givois + Tim Graham + Tim Heap + Tim Saylor + Tobias Kunze + Tobias McNulty + tobias@neuyork.de + Todd O'Bryan + Tom Carrick + Tom Christie + Tom Forbes + Tom Insam + Tom Tobin + Tomáš Ehrlich + Tomáš Kopeček + Tome Cvitan + Tomek Paczkowski + Tomer Chachamu + Tommy Beadle + Tore Lundqvist + torne-django@wolfpuppy.org.uk + Travis Cline + Travis Pinney + Travis Swicegood + Travis Terry + Trevor Caira + Trey Long + tstromberg@google.com + tt@gurgle.no + Tyler Tarabula + Tyson Clugg + Tyson Tate + Unai Zalakain + Valentina Mukhamedzhanova + valtron + Vasiliy Stavenko + Vasil Vangelovski + Vibhu Agarwal + Victor Andrée + viestards.lists@gmail.com + Viktor Danyliuk + Ville Säävuori + Vinay Karanam + Vinay Sajip + Vincent Foley + Vinny Do + Vitaly Babiy + Vladimir Kuzma + Vlado + Vsevolod Solovyov + Vytis Banaitis + wam-djangobug@wamber.net + Wang Chun + Warren Smith + Waylan Limberg + Wiktor Kołodziej + Wiley Kestner + Wiliam Alves de Souza + Will Ayd + William Schwartz + Will Hardy + Wilson Miner + Wim Glenn + wojtek + Xavier Francisco + Xia Kai + Yann Fouillat + Yann Malet + Yasushi Masuda + ye7cakf02@sneakemail.com + ymasuda@ethercube.com + Yoong Kang Lim + Yusuke Miyazaki + Zac Hatfield-Dodds + Zachary Voase + Zach Liu + Zach Thompson + Zain Memon + Zak Johnson + Žan Anderle + Zbigniew Siciarz + zegor + Zeynel Özdemir + Zlatko Mašek + zriv + + +A big THANK YOU goes to: + + Rob Curley and Ralph Gage for letting us open-source Django. + + Frank Wiles for making excellent arguments for open-sourcing, and for + his sage sysadmin advice. + + Ian Bicking for convincing Adrian to ditch code generation. + + Mark Pilgrim for "Dive Into Python" (https://www.diveinto.org/python3/). + + Guido van Rossum for creating Python. diff --git a/vendor/github.com/django/django/LICENSE b/vendor/github.com/django/django/LICENSE index 5f4f225d..79215757 100644 --- a/vendor/github.com/django/django/LICENSE +++ b/vendor/github.com/django/django/LICENSE @@ -1,27 +1,27 @@ -Copyright (c) Django Software Foundation and individual contributors. -All rights reserved. - -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - 1. Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - 2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - 3. Neither the name of Django nor the names of its contributors may be used - to endorse or promote products derived from this software without - specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +Copyright (c) Django Software Foundation and individual contributors. +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + 3. Neither the name of Django nor the names of its contributors may be used + to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/vendor/github.com/django/django/LICENSE.python b/vendor/github.com/django/django/LICENSE.python index 8e1c6182..e36d1669 100644 --- a/vendor/github.com/django/django/LICENSE.python +++ b/vendor/github.com/django/django/LICENSE.python @@ -1,265 +1,265 @@ -Django is licensed under the three-clause BSD license; see the file -LICENSE for details. - -Django includes code from the Python standard library, which is licensed under -the Python license, a permissive open source license. The copyright and license -is included below for compliance with Python's terms. - ----------------------------------------------------------------------- - -Copyright (c) 2001-present Python Software Foundation; All Rights Reserved - -A. HISTORY OF THE SOFTWARE -========================== - -Python was created in the early 1990s by Guido van Rossum at Stichting -Mathematisch Centrum (CWI, see http://www.cwi.nl) in the Netherlands -as a successor of a language called ABC. Guido remains Python's -principal author, although it includes many contributions from others. - -In 1995, Guido continued his work on Python at the Corporation for -National Research Initiatives (CNRI, see http://www.cnri.reston.va.us) -in Reston, Virginia where he released several versions of the -software. - -In May 2000, Guido and the Python core development team moved to -BeOpen.com to form the BeOpen PythonLabs team. In October of the same -year, the PythonLabs team moved to Digital Creations, which became -Zope Corporation. In 2001, the Python Software Foundation (PSF, see -https://www.python.org/psf/) was formed, a non-profit organization -created specifically to own Python-related Intellectual Property. -Zope Corporation was a sponsoring member of the PSF. - -All Python releases are Open Source (see http://www.opensource.org for -the Open Source Definition). Historically, most, but not all, Python -releases have also been GPL-compatible; the table below summarizes -the various releases. - - Release Derived Year Owner GPL- - from compatible? (1) - - 0.9.0 thru 1.2 1991-1995 CWI yes - 1.3 thru 1.5.2 1.2 1995-1999 CNRI yes - 1.6 1.5.2 2000 CNRI no - 2.0 1.6 2000 BeOpen.com no - 1.6.1 1.6 2001 CNRI yes (2) - 2.1 2.0+1.6.1 2001 PSF no - 2.0.1 2.0+1.6.1 2001 PSF yes - 2.1.1 2.1+2.0.1 2001 PSF yes - 2.1.2 2.1.1 2002 PSF yes - 2.1.3 2.1.2 2002 PSF yes - 2.2 and above 2.1.1 2001-now PSF yes - -Footnotes: - -(1) GPL-compatible doesn't mean that we're distributing Python under - the GPL. All Python licenses, unlike the GPL, let you distribute - a modified version without making your changes open source. The - GPL-compatible licenses make it possible to combine Python with - other software that is released under the GPL; the others don't. - -(2) According to Richard Stallman, 1.6.1 is not GPL-compatible, - because its license has a choice of law clause. According to - CNRI, however, Stallman's lawyer has told CNRI's lawyer that 1.6.1 - is "not incompatible" with the GPL. - -Thanks to the many outside volunteers who have worked under Guido's -direction to make these releases possible. - - -B. TERMS AND CONDITIONS FOR ACCESSING OR OTHERWISE USING PYTHON -=============================================================== - -PYTHON SOFTWARE FOUNDATION LICENSE VERSION 2 --------------------------------------------- - -1. This LICENSE AGREEMENT is between the Python Software Foundation -("PSF"), and the Individual or Organization ("Licensee") accessing and -otherwise using this software ("Python") in source or binary form and -its associated documentation. - -2. Subject to the terms and conditions of this License Agreement, PSF hereby -grants Licensee a nonexclusive, royalty-free, world-wide license to reproduce, -analyze, test, perform and/or display publicly, prepare derivative works, -distribute, and otherwise use Python alone or in any derivative version, -provided, however, that PSF's License Agreement and PSF's notice of copyright, -i.e., "Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, -2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020 Python Software Foundation; -All Rights Reserved" are retained in Python alone or in any derivative version -prepared by Licensee. - -3. In the event Licensee prepares a derivative work that is based on -or incorporates Python or any part thereof, and wants to make -the derivative work available to others as provided herein, then -Licensee hereby agrees to include in any such work a brief summary of -the changes made to Python. - -4. PSF is making Python available to Licensee on an "AS IS" -basis. PSF MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR -IMPLIED. BY WAY OF EXAMPLE, BUT NOT LIMITATION, PSF MAKES NO AND -DISCLAIMS ANY REPRESENTATION OR WARRANTY OF MERCHANTABILITY OR FITNESS -FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF PYTHON WILL NOT -INFRINGE ANY THIRD PARTY RIGHTS. - -5. PSF SHALL NOT BE LIABLE TO LICENSEE OR ANY OTHER USERS OF PYTHON -FOR ANY INCIDENTAL, SPECIAL, OR CONSEQUENTIAL DAMAGES OR LOSS AS -A RESULT OF MODIFYING, DISTRIBUTING, OR OTHERWISE USING PYTHON, -OR ANY DERIVATIVE THEREOF, EVEN IF ADVISED OF THE POSSIBILITY THEREOF. - -6. This License Agreement will automatically terminate upon a material -breach of its terms and conditions. - -7. Nothing in this License Agreement shall be deemed to create any -relationship of agency, partnership, or joint venture between PSF and -Licensee. This License Agreement does not grant permission to use PSF -trademarks or trade name in a trademark sense to endorse or promote -products or services of Licensee, or any third party. - -8. By copying, installing or otherwise using Python, Licensee -agrees to be bound by the terms and conditions of this License -Agreement. - - -BEOPEN.COM LICENSE AGREEMENT FOR PYTHON 2.0 -------------------------------------------- - -BEOPEN PYTHON OPEN SOURCE LICENSE AGREEMENT VERSION 1 - -1. This LICENSE AGREEMENT is between BeOpen.com ("BeOpen"), having an -office at 160 Saratoga Avenue, Santa Clara, CA 95051, and the -Individual or Organization ("Licensee") accessing and otherwise using -this software in source or binary form and its associated -documentation ("the Software"). - -2. Subject to the terms and conditions of this BeOpen Python License -Agreement, BeOpen hereby grants Licensee a non-exclusive, -royalty-free, world-wide license to reproduce, analyze, test, perform -and/or display publicly, prepare derivative works, distribute, and -otherwise use the Software alone or in any derivative version, -provided, however, that the BeOpen Python License is retained in the -Software, alone or in any derivative version prepared by Licensee. - -3. BeOpen is making the Software available to Licensee on an "AS IS" -basis. BEOPEN MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR -IMPLIED. BY WAY OF EXAMPLE, BUT NOT LIMITATION, BEOPEN MAKES NO AND -DISCLAIMS ANY REPRESENTATION OR WARRANTY OF MERCHANTABILITY OR FITNESS -FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF THE SOFTWARE WILL NOT -INFRINGE ANY THIRD PARTY RIGHTS. - -4. BEOPEN SHALL NOT BE LIABLE TO LICENSEE OR ANY OTHER USERS OF THE -SOFTWARE FOR ANY INCIDENTAL, SPECIAL, OR CONSEQUENTIAL DAMAGES OR LOSS -AS A RESULT OF USING, MODIFYING OR DISTRIBUTING THE SOFTWARE, OR ANY -DERIVATIVE THEREOF, EVEN IF ADVISED OF THE POSSIBILITY THEREOF. - -5. This License Agreement will automatically terminate upon a material -breach of its terms and conditions. - -6. This License Agreement shall be governed by and interpreted in all -respects by the law of the State of California, excluding conflict of -law provisions. Nothing in this License Agreement shall be deemed to -create any relationship of agency, partnership, or joint venture -between BeOpen and Licensee. This License Agreement does not grant -permission to use BeOpen trademarks or trade names in a trademark -sense to endorse or promote products or services of Licensee, or any -third party. As an exception, the "BeOpen Python" logos available at -http://www.pythonlabs.com/logos.html may be used according to the -permissions granted on that web page. - -7. By copying, installing or otherwise using the software, Licensee -agrees to be bound by the terms and conditions of this License -Agreement. - - -CNRI LICENSE AGREEMENT FOR PYTHON 1.6.1 ---------------------------------------- - -1. This LICENSE AGREEMENT is between the Corporation for National -Research Initiatives, having an office at 1895 Preston White Drive, -Reston, VA 20191 ("CNRI"), and the Individual or Organization -("Licensee") accessing and otherwise using Python 1.6.1 software in -source or binary form and its associated documentation. - -2. Subject to the terms and conditions of this License Agreement, CNRI -hereby grants Licensee a nonexclusive, royalty-free, world-wide -license to reproduce, analyze, test, perform and/or display publicly, -prepare derivative works, distribute, and otherwise use Python 1.6.1 -alone or in any derivative version, provided, however, that CNRI's -License Agreement and CNRI's notice of copyright, i.e., "Copyright (c) -1995-2001 Corporation for National Research Initiatives; All Rights -Reserved" are retained in Python 1.6.1 alone or in any derivative -version prepared by Licensee. Alternately, in lieu of CNRI's License -Agreement, Licensee may substitute the following text (omitting the -quotes): "Python 1.6.1 is made available subject to the terms and -conditions in CNRI's License Agreement. This Agreement together with -Python 1.6.1 may be located on the Internet using the following -unique, persistent identifier (known as a handle): 1895.22/1013. This -Agreement may also be obtained from a proxy server on the Internet -using the following URL: http://hdl.handle.net/1895.22/1013". - -3. In the event Licensee prepares a derivative work that is based on -or incorporates Python 1.6.1 or any part thereof, and wants to make -the derivative work available to others as provided herein, then -Licensee hereby agrees to include in any such work a brief summary of -the changes made to Python 1.6.1. - -4. CNRI is making Python 1.6.1 available to Licensee on an "AS IS" -basis. CNRI MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR -IMPLIED. BY WAY OF EXAMPLE, BUT NOT LIMITATION, CNRI MAKES NO AND -DISCLAIMS ANY REPRESENTATION OR WARRANTY OF MERCHANTABILITY OR FITNESS -FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF PYTHON 1.6.1 WILL NOT -INFRINGE ANY THIRD PARTY RIGHTS. - -5. CNRI SHALL NOT BE LIABLE TO LICENSEE OR ANY OTHER USERS OF PYTHON -1.6.1 FOR ANY INCIDENTAL, SPECIAL, OR CONSEQUENTIAL DAMAGES OR LOSS AS -A RESULT OF MODIFYING, DISTRIBUTING, OR OTHERWISE USING PYTHON 1.6.1, -OR ANY DERIVATIVE THEREOF, EVEN IF ADVISED OF THE POSSIBILITY THEREOF. - -6. This License Agreement will automatically terminate upon a material -breach of its terms and conditions. - -7. This License Agreement shall be governed by the federal -intellectual property law of the United States, including without -limitation the federal copyright law, and, to the extent such -U.S. federal law does not apply, by the law of the Commonwealth of -Virginia, excluding Virginia's conflict of law provisions. -Notwithstanding the foregoing, with regard to derivative works based -on Python 1.6.1 that incorporate non-separable material that was -previously distributed under the GNU General Public License (GPL), the -law of the Commonwealth of Virginia shall govern this License -Agreement only as to issues arising under or with respect to -Paragraphs 4, 5, and 7 of this License Agreement. Nothing in this -License Agreement shall be deemed to create any relationship of -agency, partnership, or joint venture between CNRI and Licensee. This -License Agreement does not grant permission to use CNRI trademarks or -trade name in a trademark sense to endorse or promote products or -services of Licensee, or any third party. - -8. By clicking on the "ACCEPT" button where indicated, or by copying, -installing or otherwise using Python 1.6.1, Licensee agrees to be -bound by the terms and conditions of this License Agreement. - - ACCEPT - - -CWI LICENSE AGREEMENT FOR PYTHON 0.9.0 THROUGH 1.2 --------------------------------------------------- - -Copyright (c) 1991 - 1995, Stichting Mathematisch Centrum Amsterdam, -The Netherlands. All rights reserved. - -Permission to use, copy, modify, and distribute this software and its -documentation for any purpose and without fee is hereby granted, -provided that the above copyright notice appear in all copies and that -both that copyright notice and this permission notice appear in -supporting documentation, and that the name of Stichting Mathematisch -Centrum or CWI not be used in advertising or publicity pertaining to -distribution of the software without specific, written prior -permission. - -STICHTING MATHEMATISCH CENTRUM DISCLAIMS ALL WARRANTIES WITH REGARD TO -THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND -FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH CENTRUM BE LIABLE -FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT -OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +Django is licensed under the three-clause BSD license; see the file +LICENSE for details. + +Django includes code from the Python standard library, which is licensed under +the Python license, a permissive open source license. The copyright and license +is included below for compliance with Python's terms. + +---------------------------------------------------------------------- + +Copyright (c) 2001-present Python Software Foundation; All Rights Reserved + +A. HISTORY OF THE SOFTWARE +========================== + +Python was created in the early 1990s by Guido van Rossum at Stichting +Mathematisch Centrum (CWI, see http://www.cwi.nl) in the Netherlands +as a successor of a language called ABC. Guido remains Python's +principal author, although it includes many contributions from others. + +In 1995, Guido continued his work on Python at the Corporation for +National Research Initiatives (CNRI, see http://www.cnri.reston.va.us) +in Reston, Virginia where he released several versions of the +software. + +In May 2000, Guido and the Python core development team moved to +BeOpen.com to form the BeOpen PythonLabs team. In October of the same +year, the PythonLabs team moved to Digital Creations, which became +Zope Corporation. In 2001, the Python Software Foundation (PSF, see +https://www.python.org/psf/) was formed, a non-profit organization +created specifically to own Python-related Intellectual Property. +Zope Corporation was a sponsoring member of the PSF. + +All Python releases are Open Source (see http://www.opensource.org for +the Open Source Definition). Historically, most, but not all, Python +releases have also been GPL-compatible; the table below summarizes +the various releases. + + Release Derived Year Owner GPL- + from compatible? (1) + + 0.9.0 thru 1.2 1991-1995 CWI yes + 1.3 thru 1.5.2 1.2 1995-1999 CNRI yes + 1.6 1.5.2 2000 CNRI no + 2.0 1.6 2000 BeOpen.com no + 1.6.1 1.6 2001 CNRI yes (2) + 2.1 2.0+1.6.1 2001 PSF no + 2.0.1 2.0+1.6.1 2001 PSF yes + 2.1.1 2.1+2.0.1 2001 PSF yes + 2.1.2 2.1.1 2002 PSF yes + 2.1.3 2.1.2 2002 PSF yes + 2.2 and above 2.1.1 2001-now PSF yes + +Footnotes: + +(1) GPL-compatible doesn't mean that we're distributing Python under + the GPL. All Python licenses, unlike the GPL, let you distribute + a modified version without making your changes open source. The + GPL-compatible licenses make it possible to combine Python with + other software that is released under the GPL; the others don't. + +(2) According to Richard Stallman, 1.6.1 is not GPL-compatible, + because its license has a choice of law clause. According to + CNRI, however, Stallman's lawyer has told CNRI's lawyer that 1.6.1 + is "not incompatible" with the GPL. + +Thanks to the many outside volunteers who have worked under Guido's +direction to make these releases possible. + + +B. TERMS AND CONDITIONS FOR ACCESSING OR OTHERWISE USING PYTHON +=============================================================== + +PYTHON SOFTWARE FOUNDATION LICENSE VERSION 2 +-------------------------------------------- + +1. This LICENSE AGREEMENT is between the Python Software Foundation +("PSF"), and the Individual or Organization ("Licensee") accessing and +otherwise using this software ("Python") in source or binary form and +its associated documentation. + +2. Subject to the terms and conditions of this License Agreement, PSF hereby +grants Licensee a nonexclusive, royalty-free, world-wide license to reproduce, +analyze, test, perform and/or display publicly, prepare derivative works, +distribute, and otherwise use Python alone or in any derivative version, +provided, however, that PSF's License Agreement and PSF's notice of copyright, +i.e., "Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, +2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020 Python Software Foundation; +All Rights Reserved" are retained in Python alone or in any derivative version +prepared by Licensee. + +3. In the event Licensee prepares a derivative work that is based on +or incorporates Python or any part thereof, and wants to make +the derivative work available to others as provided herein, then +Licensee hereby agrees to include in any such work a brief summary of +the changes made to Python. + +4. PSF is making Python available to Licensee on an "AS IS" +basis. PSF MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR +IMPLIED. BY WAY OF EXAMPLE, BUT NOT LIMITATION, PSF MAKES NO AND +DISCLAIMS ANY REPRESENTATION OR WARRANTY OF MERCHANTABILITY OR FITNESS +FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF PYTHON WILL NOT +INFRINGE ANY THIRD PARTY RIGHTS. + +5. PSF SHALL NOT BE LIABLE TO LICENSEE OR ANY OTHER USERS OF PYTHON +FOR ANY INCIDENTAL, SPECIAL, OR CONSEQUENTIAL DAMAGES OR LOSS AS +A RESULT OF MODIFYING, DISTRIBUTING, OR OTHERWISE USING PYTHON, +OR ANY DERIVATIVE THEREOF, EVEN IF ADVISED OF THE POSSIBILITY THEREOF. + +6. This License Agreement will automatically terminate upon a material +breach of its terms and conditions. + +7. Nothing in this License Agreement shall be deemed to create any +relationship of agency, partnership, or joint venture between PSF and +Licensee. This License Agreement does not grant permission to use PSF +trademarks or trade name in a trademark sense to endorse or promote +products or services of Licensee, or any third party. + +8. By copying, installing or otherwise using Python, Licensee +agrees to be bound by the terms and conditions of this License +Agreement. + + +BEOPEN.COM LICENSE AGREEMENT FOR PYTHON 2.0 +------------------------------------------- + +BEOPEN PYTHON OPEN SOURCE LICENSE AGREEMENT VERSION 1 + +1. This LICENSE AGREEMENT is between BeOpen.com ("BeOpen"), having an +office at 160 Saratoga Avenue, Santa Clara, CA 95051, and the +Individual or Organization ("Licensee") accessing and otherwise using +this software in source or binary form and its associated +documentation ("the Software"). + +2. Subject to the terms and conditions of this BeOpen Python License +Agreement, BeOpen hereby grants Licensee a non-exclusive, +royalty-free, world-wide license to reproduce, analyze, test, perform +and/or display publicly, prepare derivative works, distribute, and +otherwise use the Software alone or in any derivative version, +provided, however, that the BeOpen Python License is retained in the +Software, alone or in any derivative version prepared by Licensee. + +3. BeOpen is making the Software available to Licensee on an "AS IS" +basis. BEOPEN MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR +IMPLIED. BY WAY OF EXAMPLE, BUT NOT LIMITATION, BEOPEN MAKES NO AND +DISCLAIMS ANY REPRESENTATION OR WARRANTY OF MERCHANTABILITY OR FITNESS +FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF THE SOFTWARE WILL NOT +INFRINGE ANY THIRD PARTY RIGHTS. + +4. BEOPEN SHALL NOT BE LIABLE TO LICENSEE OR ANY OTHER USERS OF THE +SOFTWARE FOR ANY INCIDENTAL, SPECIAL, OR CONSEQUENTIAL DAMAGES OR LOSS +AS A RESULT OF USING, MODIFYING OR DISTRIBUTING THE SOFTWARE, OR ANY +DERIVATIVE THEREOF, EVEN IF ADVISED OF THE POSSIBILITY THEREOF. + +5. This License Agreement will automatically terminate upon a material +breach of its terms and conditions. + +6. This License Agreement shall be governed by and interpreted in all +respects by the law of the State of California, excluding conflict of +law provisions. Nothing in this License Agreement shall be deemed to +create any relationship of agency, partnership, or joint venture +between BeOpen and Licensee. This License Agreement does not grant +permission to use BeOpen trademarks or trade names in a trademark +sense to endorse or promote products or services of Licensee, or any +third party. As an exception, the "BeOpen Python" logos available at +http://www.pythonlabs.com/logos.html may be used according to the +permissions granted on that web page. + +7. By copying, installing or otherwise using the software, Licensee +agrees to be bound by the terms and conditions of this License +Agreement. + + +CNRI LICENSE AGREEMENT FOR PYTHON 1.6.1 +--------------------------------------- + +1. This LICENSE AGREEMENT is between the Corporation for National +Research Initiatives, having an office at 1895 Preston White Drive, +Reston, VA 20191 ("CNRI"), and the Individual or Organization +("Licensee") accessing and otherwise using Python 1.6.1 software in +source or binary form and its associated documentation. + +2. Subject to the terms and conditions of this License Agreement, CNRI +hereby grants Licensee a nonexclusive, royalty-free, world-wide +license to reproduce, analyze, test, perform and/or display publicly, +prepare derivative works, distribute, and otherwise use Python 1.6.1 +alone or in any derivative version, provided, however, that CNRI's +License Agreement and CNRI's notice of copyright, i.e., "Copyright (c) +1995-2001 Corporation for National Research Initiatives; All Rights +Reserved" are retained in Python 1.6.1 alone or in any derivative +version prepared by Licensee. Alternately, in lieu of CNRI's License +Agreement, Licensee may substitute the following text (omitting the +quotes): "Python 1.6.1 is made available subject to the terms and +conditions in CNRI's License Agreement. This Agreement together with +Python 1.6.1 may be located on the Internet using the following +unique, persistent identifier (known as a handle): 1895.22/1013. This +Agreement may also be obtained from a proxy server on the Internet +using the following URL: http://hdl.handle.net/1895.22/1013". + +3. In the event Licensee prepares a derivative work that is based on +or incorporates Python 1.6.1 or any part thereof, and wants to make +the derivative work available to others as provided herein, then +Licensee hereby agrees to include in any such work a brief summary of +the changes made to Python 1.6.1. + +4. CNRI is making Python 1.6.1 available to Licensee on an "AS IS" +basis. CNRI MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR +IMPLIED. BY WAY OF EXAMPLE, BUT NOT LIMITATION, CNRI MAKES NO AND +DISCLAIMS ANY REPRESENTATION OR WARRANTY OF MERCHANTABILITY OR FITNESS +FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF PYTHON 1.6.1 WILL NOT +INFRINGE ANY THIRD PARTY RIGHTS. + +5. CNRI SHALL NOT BE LIABLE TO LICENSEE OR ANY OTHER USERS OF PYTHON +1.6.1 FOR ANY INCIDENTAL, SPECIAL, OR CONSEQUENTIAL DAMAGES OR LOSS AS +A RESULT OF MODIFYING, DISTRIBUTING, OR OTHERWISE USING PYTHON 1.6.1, +OR ANY DERIVATIVE THEREOF, EVEN IF ADVISED OF THE POSSIBILITY THEREOF. + +6. This License Agreement will automatically terminate upon a material +breach of its terms and conditions. + +7. This License Agreement shall be governed by the federal +intellectual property law of the United States, including without +limitation the federal copyright law, and, to the extent such +U.S. federal law does not apply, by the law of the Commonwealth of +Virginia, excluding Virginia's conflict of law provisions. +Notwithstanding the foregoing, with regard to derivative works based +on Python 1.6.1 that incorporate non-separable material that was +previously distributed under the GNU General Public License (GPL), the +law of the Commonwealth of Virginia shall govern this License +Agreement only as to issues arising under or with respect to +Paragraphs 4, 5, and 7 of this License Agreement. Nothing in this +License Agreement shall be deemed to create any relationship of +agency, partnership, or joint venture between CNRI and Licensee. This +License Agreement does not grant permission to use CNRI trademarks or +trade name in a trademark sense to endorse or promote products or +services of Licensee, or any third party. + +8. By clicking on the "ACCEPT" button where indicated, or by copying, +installing or otherwise using Python 1.6.1, Licensee agrees to be +bound by the terms and conditions of this License Agreement. + + ACCEPT + + +CWI LICENSE AGREEMENT FOR PYTHON 0.9.0 THROUGH 1.2 +-------------------------------------------------- + +Copyright (c) 1991 - 1995, Stichting Mathematisch Centrum Amsterdam, +The Netherlands. All rights reserved. + +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, +provided that the above copyright notice appear in all copies and that +both that copyright notice and this permission notice appear in +supporting documentation, and that the name of Stichting Mathematisch +Centrum or CWI not be used in advertising or publicity pertaining to +distribution of the software without specific, written prior +permission. + +STICHTING MATHEMATISCH CENTRUM DISCLAIMS ALL WARRANTIES WITH REGARD TO +THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND +FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH CENTRUM BE LIABLE +FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT +OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. diff --git a/vendor/github.com/django/django/extras/Makefile b/vendor/github.com/django/django/extras/Makefile index 66efd0d4..c8ea9179 100644 --- a/vendor/github.com/django/django/extras/Makefile +++ b/vendor/github.com/django/django/extras/Makefile @@ -1,9 +1,9 @@ -all: sdist bdist_wheel - -sdist: - python setup.py sdist - -bdist_wheel: - python setup.py bdist_wheel - -.PHONY : sdist bdist_wheel +all: sdist bdist_wheel + +sdist: + python setup.py sdist + +bdist_wheel: + python setup.py bdist_wheel + +.PHONY : sdist bdist_wheel diff --git a/vendor/github.com/django/django/extras/README.TXT b/vendor/github.com/django/django/extras/README.TXT index 3fb2a846..d533d329 100644 --- a/vendor/github.com/django/django/extras/README.TXT +++ b/vendor/github.com/django/django/extras/README.TXT @@ -1 +1 @@ -This directory contains extra stuff that can improve your Django experience. +This directory contains extra stuff that can improve your Django experience. diff --git a/vendor/github.com/django/django/extras/django_bash_completion b/vendor/github.com/django/django/extras/django_bash_completion index fa77d59a..4e5d221b 100755 --- a/vendor/github.com/django/django/extras/django_bash_completion +++ b/vendor/github.com/django/django/extras/django_bash_completion @@ -1,71 +1,75 @@ -# ############################################################################# -# This bash script adds tab-completion feature to django-admin and manage.py. -# -# Testing it out without installing -# ================================= -# -# To test out the completion without "installing" this, just run this file -# directly, like so: -# -# . ~/path/to/django_bash_completion -# -# Note: There's a dot ('.') at the beginning of that command. -# -# After you do that, tab completion will immediately be made available in your -# current Bash shell. But it won't be available next time you log in. -# -# Installing -# ========== -# -# To install this, point to this file from your .bash_profile, like so: -# -# . ~/path/to/django_bash_completion -# -# Do the same in your .bashrc if .bashrc doesn't invoke .bash_profile. -# -# Settings will take effect the next time you log in. -# -# Uninstalling -# ============ -# -# To uninstall, just remove the line from your .bash_profile and .bashrc. - -_django_completion() -{ - COMPREPLY=( $( COMP_WORDS="${COMP_WORDS[*]}" \ - COMP_CWORD=$COMP_CWORD \ - DJANGO_AUTO_COMPLETE=1 $1 ) ) -} -# When the django-admin.py deprecation ends, remove django-admin.py. -complete -F _django_completion -o default django-admin.py manage.py django-admin - -_python_django_completion() -{ - if [[ ${COMP_CWORD} -ge 2 ]]; then - local PYTHON_EXE=${COMP_WORDS[0]##*/} - if echo "$PYTHON_EXE" | grep -qE "python([3-9]\.[0-9])?"; then - local PYTHON_SCRIPT=${COMP_WORDS[1]##*/} - if echo "$PYTHON_SCRIPT" | grep -qE "manage\.py|django-admin(\.py)?"; then - COMPREPLY=( $( COMP_WORDS=( "${COMP_WORDS[*]:1}" ) - COMP_CWORD=$(( COMP_CWORD-1 )) - DJANGO_AUTO_COMPLETE=1 ${COMP_WORDS[*]} ) ) - fi - fi - fi -} - -# Support for multiple interpreters. -unset pythons -if command -v whereis &>/dev/null; then - python_interpreters=$(whereis python | cut -d " " -f 2-) - for python in $python_interpreters; do - [[ $python != *-config ]] && pythons="${pythons} ${python##*/}" - done - unset python_interpreters - pythons=$(echo "$pythons" | tr " " "\n" | sort -u | tr "\n" " ") -else - pythons=python -fi - -complete -F _python_django_completion -o default $pythons -unset pythons +# ############################################################################# +# This bash script adds tab-completion feature to django-admin and manage.py. +# +# Testing it out without installing +# ================================= +# +# To test out the completion without "installing" this, just run this file +# directly, like so: +# +# . ~/path/to/django_bash_completion +# +# Note: There's a dot ('.') at the beginning of that command. +# +# After you do that, tab completion will immediately be made available in your +# current Bash shell. But it won't be available next time you log in. +# +# Installing +# ========== +# +# To install this, point to this file from your .bash_profile, like so: +# +# . ~/path/to/django_bash_completion +# +# Do the same in your .bashrc if .bashrc doesn't invoke .bash_profile. +# +# Settings will take effect the next time you log in. +# +# Uninstalling +# ============ +# +# To uninstall, just remove the line from your .bash_profile and .bashrc. + +_django_completion() +{ + COMPREPLY=( $( COMP_WORDS="${COMP_WORDS[*]}" \ + COMP_CWORD=$COMP_CWORD \ + DJANGO_AUTO_COMPLETE=1 $1 ) ) +} +# When the django-admin.py deprecation ends, remove django-admin.py. +complete -F _django_completion -o default django-admin.py manage.py django-admin + +_python_django_completion() +{ + if [[ ${COMP_CWORD} -ge 2 ]] + then + local PYTHON_EXE=${COMP_WORDS[0]##*/} + if echo "$PYTHON_EXE" | grep -qE "python([3-9]\.[0-9])?" + then + local PYTHON_SCRIPT=${COMP_WORDS[1]##*/} + if echo "$PYTHON_SCRIPT" | grep -qE "manage\.py|django-admin(\.py)?" + then + COMPREPLY=( $( COMP_WORDS=( "${COMP_WORDS[*]:1}" ) + COMP_CWORD=$(( COMP_CWORD-1 )) + DJANGO_AUTO_COMPLETE=1 ${COMP_WORDS[*]} ) ) + fi + fi + fi +} + +# Support for multiple interpreters. +unset pythons +if command -v whereis &>/dev/null + then + python_interpreters=$(whereis python | cut -d " " -f 2-) + for python in $python_interpreters; do + [[ $python != *-config ]] && pythons="${pythons} ${python##*/}" + done + unset python_interpreters + pythons=$(echo "$pythons" | tr " " "\n" | sort -u | tr "\n" " ") +else + pythons=python +fi + +complete -F _python_django_completion -o default $pythons +unset pythons diff --git a/vendor/github.com/dsifford/yarn-completion/yarn b/vendor/github.com/dsifford/yarn-completion/yarn index ff78e471..c6815d69 100644 --- a/vendor/github.com/dsifford/yarn-completion/yarn +++ b/vendor/github.com/dsifford/yarn-completion/yarn @@ -1,1208 +1,1226 @@ -# 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 +# 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. +## +function __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 +## +function __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 +## +function __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 +## +function __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 +## +function __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 +## +function __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 +} + +function _yarn_add() { + ((depth++)) + flags=( + --audit -A + --dev -D + --exact -E + --optional -O + --peer -P + --tilde -T + --ignore-workspace-root-check -W + ) + return 1 +} + +function _yarn_audit() { + ((depth++)) + flags=( + --groups + --level + --summary + ) + return 1 +} + +function _yarn_autoclean() { + ((depth++)) + flags=( + --force -F + --init -I + ) + return 1 +} + +function _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 +} + +function _yarn_check() { + ((depth++)) + flags=( + --integrity + --verify-tree + ) + return 1 +} + +function _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 +} + +function _yarn_create() { + ((depth++)) + declare -i args + case "$cur" in + -*) ;; + *) + __yarn_count_args -d $depth + ((args == 0)) && return 0 + ;; + esac + return 1 +} + +function _yarn_generate_lock_entry() { + ((depth++)) + flags=( + --resolved + --use-manifest + ) + return 1 +} + +function _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 +} + +function _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 +} + +function _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 +} + +function _yarn_init() { + ((depth++)) + flags=( + --yes -y + --private -p + --install -i + ) + return 1 +} + +function _yarn_install() { + ((depth++)) + flags=( + --audit -A + ) + return 1 +} + +function _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 +} + +function _yarn_list() { + ((depth++)) + flags=( + --depth + --pattern + ) + return 1 +} + +function _yarn_node() { + ((depth++)) + flags=( + --into + ) + return 1 +} + +function _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 +} + +function _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 +} + +function _yarn_pack() { + ((depth++)) + flags=( + --filename -f + ) + return 1 +} + +function _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 +} + +function _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 +} + +function _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 +} + +function _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 +} + +function _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 +} + +function _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 +} + +function _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 +} + +function _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 +} + +function _yarn_upgrade_interactive() { + ((depth++)) + flags=( + --caret -C + --exact -E + --latest + --scope -S + --tilde -T + ) + return 1 +} + +function _yarn_version() { + ((depth++)) + flags=( + --major + --message + --minor + --new-version + --no-commit-hooks + --no-git-tag-version + --patch + --preid + --premajor + --preminor + --prepatch + --prerelease + ) + return 1 +} + +function _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 +} + +function _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 +} + +function _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 +} + +function _yarn_yarn() { + ((depth++)) + case "$cur" in + -*) ;; + *) + COMPREPLY=($(compgen -W "${commands[*]}" -- "$cur")) + return 0 + ;; + esac + return 1 +} + +function _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 diff --git a/vendor/github.com/erichs/composure/.gitignore b/vendor/github.com/erichs/composure/.gitignore index c093caa2..0082f483 100644 --- a/vendor/github.com/erichs/composure/.gitignore +++ b/vendor/github.com/erichs/composure/.gitignore @@ -1 +1 @@ -composure_test/** +composure_test/** diff --git a/vendor/github.com/erichs/composure/.travis.yml b/vendor/github.com/erichs/composure/.travis.yml index 505faa5f..15dd9ee9 100644 --- a/vendor/github.com/erichs/composure/.travis.yml +++ b/vendor/github.com/erichs/composure/.travis.yml @@ -1,9 +1,9 @@ -language: c -script: make tests -branches: - only: - - testing - - master -before_install: - - sudo apt-get update -qq - - sudo apt-get install -qq ksh zsh +language: c +script: make tests +branches: + only: + - testing + - master +before_install: + - sudo apt-get update -qq + - sudo apt-get install -qq ksh zsh diff --git a/vendor/github.com/erichs/composure/History.md b/vendor/github.com/erichs/composure/History.md index a12572fa..ed5fff8e 100644 --- a/vendor/github.com/erichs/composure/History.md +++ b/vendor/github.com/erichs/composure/History.md @@ -1,90 +1,90 @@ -1.3 / 2015-11-04 -================== - * Make glossary() faster by not introspecting loaded shell functions - * Remove brittle and incomplete test suite - * Fixes for shellcheck.net - -1.2.4 / 2015-08-29 -================== - * Minor updates for latest shellcheck.net codes - * Fix write() function, thanks @IsoLinearCHiP! - -1.2.3 / 2015-04-01 -================== - * Minor fixes for latest shellcheck.net codes - * Better wrapping for long about metadata - * Support leading hyphens in function names - -1.2.2 / 2015-01-16 -================== -various fixes, including contributions from: - * @nilbus - * @martinlauer - * @DrVanScott - -1.2.1 / 2014-01-05 -================== - * Tab completion for revise(), new compost() func - * Improve shell determination and bootstrapping sequence - -1.2.0 / 2013-11-17 -================== - * Auto-load composed functions - -1.1.1 / 2013-10-29 -================== - * Fix issue with zsh noclobber option - -1.1.0 / 2013-10-23 -================== - * Auto-revise drafted functions - * Populate author metadata on draft - * Use tpope-style commit msgs - * Respect XDG_DATA_HOME - -1.0.4 / 2013-08-30 -================== - - * increase letterpress spacing - * refactor composure extras - -1.0.3 / 2012-11-29 -================== - - * make revise() smarter - * write() includes shebang and main() invocation - -1.0.2 / 2012-05-24 -================== - - * use _plumbing nomenclature - -1.0.1 / 2012-05-19 -================== - - * revise() takes an optional -e flag - * revise() aborts on an empty file - * metadata cleaned up - -1.0 / 2012-05-17 -================== - - * performance improvements - * fix draft(): ensure alias names are not used for function names - * porcelain is self-referential - * consolidate plumbing fns - * add diagram - * write() porcelain - * apidoc for author & version - * second-order functions - * asciicast demo! - * prompt for git repo creation - * full POSIX compatibility - * revised documentation - * sed-fu rescues case blocks - solves #1 - * basic git tracking - * remove hyphens from function names - * fix for non-interactive shells - * respect EDITOR preference - * add readme - * initial commit +1.3 / 2015-11-04 +================== + * Make glossary() faster by not introspecting loaded shell functions + * Remove brittle and incomplete test suite + * Fixes for shellcheck.net + +1.2.4 / 2015-08-29 +================== + * Minor updates for latest shellcheck.net codes + * Fix write() function, thanks @IsoLinearCHiP! + +1.2.3 / 2015-04-01 +================== + * Minor fixes for latest shellcheck.net codes + * Better wrapping for long about metadata + * Support leading hyphens in function names + +1.2.2 / 2015-01-16 +================== +various fixes, including contributions from: + * @nilbus + * @martinlauer + * @DrVanScott + +1.2.1 / 2014-01-05 +================== + * Tab completion for revise(), new compost() func + * Improve shell determination and bootstrapping sequence + +1.2.0 / 2013-11-17 +================== + * Auto-load composed functions + +1.1.1 / 2013-10-29 +================== + * Fix issue with zsh noclobber option + +1.1.0 / 2013-10-23 +================== + * Auto-revise drafted functions + * Populate author metadata on draft + * Use tpope-style commit msgs + * Respect XDG_DATA_HOME + +1.0.4 / 2013-08-30 +================== + + * increase letterpress spacing + * refactor composure extras + +1.0.3 / 2012-11-29 +================== + + * make revise() smarter + * write() includes shebang and main() invocation + +1.0.2 / 2012-05-24 +================== + + * use _plumbing nomenclature + +1.0.1 / 2012-05-19 +================== + + * revise() takes an optional -e flag + * revise() aborts on an empty file + * metadata cleaned up + +1.0 / 2012-05-17 +================== + + * performance improvements + * fix draft(): ensure alias names are not used for function names + * porcelain is self-referential + * consolidate plumbing fns + * add diagram + * write() porcelain + * apidoc for author & version + * second-order functions + * asciicast demo! + * prompt for git repo creation + * full POSIX compatibility + * revised documentation + * sed-fu rescues case blocks - solves #1 + * basic git tracking + * remove hyphens from function names + * fix for non-interactive shells + * respect EDITOR preference + * add readme + * initial commit diff --git a/vendor/github.com/erichs/composure/LICENSE b/vendor/github.com/erichs/composure/LICENSE index d779d2d5..5a8015ac 100644 --- a/vendor/github.com/erichs/composure/LICENSE +++ b/vendor/github.com/erichs/composure/LICENSE @@ -1,16 +1,16 @@ -License: The MIT License -Copyright © 2012, 2016 Erich Smith -Permission is hereby granted, free of charge, to any person obtaining a copy of this -software and associated documentation files (the "Software"), to deal in the Software -without restriction, including without limitation the rights to use, copy, modify, -merge, publish, distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to the following -conditions: -The above copyright notice and this permission notice shall be included in all copies -or substantial portions of the Software. -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, -INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A -PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF -CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE -OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +License: The MIT License +Copyright © 2012, 2016 Erich Smith +Permission is hereby granted, free of charge, to any person obtaining a copy of this +software and associated documentation files (the "Software"), to deal in the Software +without restriction, including without limitation the rights to use, copy, modify, +merge, publish, distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to the following +conditions: +The above copyright notice and this permission notice shall be included in all copies +or substantial portions of the Software. +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF +CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE +OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/vendor/github.com/erichs/composure/Makefile b/vendor/github.com/erichs/composure/Makefile index 472a5f8f..229995fa 100644 --- a/vendor/github.com/erichs/composure/Makefile +++ b/vendor/github.com/erichs/composure/Makefile @@ -1,10 +1,10 @@ - -TARGET = tests -all: $(TARGET) - -tests: - cd test && make tests - -clean:: - rm -f test/*~ test/t/*~ - rm -rf test/composure_test + +TARGET = tests +all: $(TARGET) + +tests: + cd test && make tests + +clean:: + rm -f test/*~ test/t/*~ + rm -rf test/composure_test diff --git a/vendor/github.com/erichs/composure/README.md b/vendor/github.com/erichs/composure/README.md index e1f9bb8c..610412f7 100644 --- a/vendor/github.com/erichs/composure/README.md +++ b/vendor/github.com/erichs/composure/README.md @@ -1,242 +1,242 @@ - - e88~~\ e88~-_ 888-~88e-~88e 888-~88e e88~-_ d88~\ 888 888 888-~\ e88~~8e - d888 d888 i 888 888 888 888 888b d888 i C888 888 888 888 d888 88b - 8888 8888 | 888 888 888 888 8888 8888 | Y88b 888 888 888 8888__888 - Y888 Y888 ' 888 888 888 888 888P Y888 ' 888D 888 888 888 Y888 , - "88__/ "88_-~ 888 888 888 888-_88" "88_-~ \_88P "88_-888 888 "88___/ - 888 - - # Composure: don't fear the Unix chainsaw - -These light-hearted functions make programming the shell easier and -more intuitive: - -* Transition organically from command, to function, to script -* Use an unobtrusive help system with arbitrary shell metadata -* Automatically version and store your shell functions with Git - -static analysis and automated tests: [![Build Status](https://travis-ci.org/erichs/composure.png?branch=master)](https://travis-ci.org/erichs/composure) - -## Demo! - -[Composing a simple network monitoring script](http://asciinema.org/a/476) (4 minutes) - -## Compatibility - -Composure is POSIX-compliant, and is known to work on ksh93, zsh, and -bash, on osx and linux. - -Please feel free to open an issue if you have any difficulties on your system. - -## Installing - -Put composure.sh where you'd like it to live and source it from your -shell's profile or rc file. - -On Bash: - -```bash - cd /your/favorite/directory - curl -L http://git.io/composure > composure.sh - chmod +x composure.sh - echo "source $(pwd)/composure.sh" >> ~/.bashrc # or, ~/.bash_profile on osx -``` - -Users upgrading from a version prior to 1.1.0 need to execute the following commands, as the directory for composure's local repo has changed: - -```bash - mkdir ~/.local 2>/dev/null - mv ~/.composure ~/.local/composure -``` - -## Craft - Draft - Revise - Write - - - -### Crafting the command line - -[REPL environments](http://repl.it) are great for trying out programming ideas -and crafting snippets of working code, aren't they? Composure helps you make -better use of the REPL environment constantly at your fingertips: the shell. - -Many Unix users I know like to iteratively build up complex commands by trying -something out, hitting the up arrow and perhaps adding a filter with a pipe: - -```bash - $ cat servers.txt - bashful: up - doc: down - - up-arrow - - $ cat servers.txt | grep down - doc: down - - up-arrow - - $ cat servers.txt | grep down | mail -s "down server(s)" admin@here.com -``` - -Composure helps by letting you quickly draft simple shell functions, breaking down -your long pipe filters and complex commands into readable and reusable chunks. - -### Draft first, ask questions later - -Once you've crafted your gem of a command, don't throw it away! Use 'draft ()' -and give it a [good name](http://martinfowler.com/bliki/TwoHardThings.html). -This stores your last command as a function you can reuse later. Think of it -like a rough draft. - -```bash - $ cat servers.txt - bashful: up - doc: down - - up-arrow - - $ cat servers.txt | grep down - doc: down - - $ draft finddown - - $ finddown | mail -s "down server(s)" admin@here.com -``` - -### Revise, revise, revise! - -Now that you've got a minimal shell function, you may want to make it better -through refactoring and revision. Use the 'revise ()' command to revise your -shell function in your favorite editor. - - * generalize functions with input parameters - * add or remove functionality - * add supporting metadata for documentation - -```bash - $ revise finddown - finddown () - { - about finds servers marked 'down' in text file - group admin - cat $1 | grep down - } - - $ finddown servers.txt - doc: down -``` - -### Get it in Writing - -When it is time to put your function or functions to use in a shell script, just call write: - -```bash - $ write finddown > finddown.sh -``` - -Edit the main() function, chmod +x, and you're ready to go! - -## Arbitrary shell metadata! - -Composure uses a simple system of dynamic keywords that allow you to add -metadata to your functions. Just call 'cite ()' to initialize your new -keyword(s), and use them freely in your functions: - -```bash - foo() - { - cite about - about perform mad script-foo - echo 'foo' - } -``` - -Retrieve your metadata later by calling 'metafor ()': - -```bash - typeset -f foo | metafor about # displays: - perform mad script-foo -``` - -By default, composure knows the keywords: about, param, group, author, and example. - -These default keywords are used by the help system: - -## Intuitive help system - -The 'glossary ()' function will automatically summarize all functions with -'about' metadata. If called with a 'group' name as a parameter, it will -summarize functions belonging to that group. - -To display apidoc-style help for a function, use 'reference ()'. - -```bash - $ glossary # displays: - cite creates a new meta keyword for use in your functions - draft wraps last command into a new function - finddown finds servers marked 'down' in text file - foo perform mad script-foo - glossary displays help summary for all functions, or summary for a group of functions - metafor prints function metadata associated with keyword - reference displays apidoc help for a specific function - revise loads function into editor for revision - write writes one or more composed function definitions to stdout - - meanwhile - - $ glossary admin # displays: - finddown finds servers marked 'down' in text file - - and - - $ reference draft # displays: - draft wraps last command into a new function - parameters: - 1: name to give function - examples: - $ ls - $ draft list - $ list -``` - -## Git integration - -If you already use git, installing composure will initialize a ~/.local/composure -repository, and store and version your functions there. Just use 'draft ()' and -'revise ()', they automatically version for you. - -Composure supports the [XDG Base Directory](http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html) -specification, and will respect your local XDG_DATA_HOME environment variable. - -Why do this? - - * the latest version of any function you've composed may always be sourced from - your composure repo - * never throw away code--keep your one-off functions in your composure 'junk - drawer', and grep through it later for long-forgotten gems - * every version of every function you write is always - available to you via basic git commands - -## Persistent access - -Draft or revise a function, and the latest version is automatically sourced into your current shell environment. By default, composure automatically sources all of your composed functions when you source the composure.sh script. If you are concerned about shell startup time, have many hundreds of versioned shell functions, or otherwise want to control which functions are loaded from your composure repository, you may disable the default behavior by adding the following line to your shell's startup script: - -```shell -export LOAD_COMPOSED_FUNCTIONS=0 -``` - -# Credits - -Composure grew out of ideas taken from from Gary Bernhardt's hilarious talk [The Unix -Chainsaw](http://www.confreaks.com/videos/615-cascadiaruby2011-the-unix-chainsaw) (31 minutes), -which refers to the Elements of Programming described in MIT's [SICP -text](http://mitpress.mit.edu/sicp/full-text/book/book.html): - - * primitive expressions - * means of combination - * means of abstraction - -## Known Issues - -'glossary ()' and 'reference ()' do not support nested functions with metadata. - -`revise` works well if your editor is terminal-based, like Emacs or Vim. If you use a windowed editor like Atom, VSCode, or Sublime, you will need to check to see if your editor supports a flag argument that allows it to wait for the files to be closed before returning. If this is supported, you can create a small script to launch your editor in this mode, and specify that script path in your `EDITOR` var. See https://github.com/erichs/composure/issues/10. + + e88~~\ e88~-_ 888-~88e-~88e 888-~88e e88~-_ d88~\ 888 888 888-~\ e88~~8e + d888 d888 i 888 888 888 888 888b d888 i C888 888 888 888 d888 88b + 8888 8888 | 888 888 888 888 8888 8888 | Y88b 888 888 888 8888__888 + Y888 Y888 ' 888 888 888 888 888P Y888 ' 888D 888 888 888 Y888 , + "88__/ "88_-~ 888 888 888 888-_88" "88_-~ \_88P "88_-888 888 "88___/ + 888 + + # Composure: don't fear the Unix chainsaw + +These light-hearted functions make programming the shell easier and +more intuitive: + +* Transition organically from command, to function, to script +* Use an unobtrusive help system with arbitrary shell metadata +* Automatically version and store your shell functions with Git + +static analysis and automated tests: [![Build Status](https://travis-ci.org/erichs/composure.png?branch=master)](https://travis-ci.org/erichs/composure) + +## Demo! + +[Composing a simple network monitoring script](http://asciinema.org/a/476) (4 minutes) + +## Compatibility + +Composure is POSIX-compliant, and is known to work on ksh93, zsh, and +bash, on osx and linux. + +Please feel free to open an issue if you have any difficulties on your system. + +## Installing + +Put composure.sh where you'd like it to live and source it from your +shell's profile or rc file. + +On Bash: + +```bash + cd /your/favorite/directory + curl -L http://git.io/composure > composure.sh + chmod +x composure.sh + echo "source $(pwd)/composure.sh" >> ~/.bashrc # or, ~/.bash_profile on osx +``` + +Users upgrading from a version prior to 1.1.0 need to execute the following commands, as the directory for composure's local repo has changed: + +```bash + mkdir ~/.local 2>/dev/null + mv ~/.composure ~/.local/composure +``` + +## Craft - Draft - Revise - Write + + + +### Crafting the command line + +[REPL environments](http://repl.it) are great for trying out programming ideas +and crafting snippets of working code, aren't they? Composure helps you make +better use of the REPL environment constantly at your fingertips: the shell. + +Many Unix users I know like to iteratively build up complex commands by trying +something out, hitting the up arrow and perhaps adding a filter with a pipe: + +```bash + $ cat servers.txt + bashful: up + doc: down + + up-arrow + + $ cat servers.txt | grep down + doc: down + + up-arrow + + $ cat servers.txt | grep down | mail -s "down server(s)" admin@here.com +``` + +Composure helps by letting you quickly draft simple shell functions, breaking down +your long pipe filters and complex commands into readable and reusable chunks. + +### Draft first, ask questions later + +Once you've crafted your gem of a command, don't throw it away! Use 'draft ()' +and give it a [good name](http://martinfowler.com/bliki/TwoHardThings.html). +This stores your last command as a function you can reuse later. Think of it +like a rough draft. + +```bash + $ cat servers.txt + bashful: up + doc: down + + up-arrow + + $ cat servers.txt | grep down + doc: down + + $ draft finddown + + $ finddown | mail -s "down server(s)" admin@here.com +``` + +### Revise, revise, revise! + +Now that you've got a minimal shell function, you may want to make it better +through refactoring and revision. Use the 'revise ()' command to revise your +shell function in your favorite editor. + + * generalize functions with input parameters + * add or remove functionality + * add supporting metadata for documentation + +```bash + $ revise finddown + finddown () + { + about finds servers marked 'down' in text file + group admin + cat $1 | grep down + } + + $ finddown servers.txt + doc: down +``` + +### Get it in Writing + +When it is time to put your function or functions to use in a shell script, just call write: + +```bash + $ write finddown > finddown.sh +``` + +Edit the main() function, chmod +x, and you're ready to go! + +## Arbitrary shell metadata! + +Composure uses a simple system of dynamic keywords that allow you to add +metadata to your functions. Just call 'cite ()' to initialize your new +keyword(s), and use them freely in your functions: + +```bash + foo() + { + cite about + about perform mad script-foo + echo 'foo' + } +``` + +Retrieve your metadata later by calling 'metafor ()': + +```bash + typeset -f foo | metafor about # displays: + perform mad script-foo +``` + +By default, composure knows the keywords: about, param, group, author, and example. + +These default keywords are used by the help system: + +## Intuitive help system + +The 'glossary ()' function will automatically summarize all functions with +'about' metadata. If called with a 'group' name as a parameter, it will +summarize functions belonging to that group. + +To display apidoc-style help for a function, use 'reference ()'. + +```bash + $ glossary # displays: + cite creates a new meta keyword for use in your functions + draft wraps last command into a new function + finddown finds servers marked 'down' in text file + foo perform mad script-foo + glossary displays help summary for all functions, or summary for a group of functions + metafor prints function metadata associated with keyword + reference displays apidoc help for a specific function + revise loads function into editor for revision + write writes one or more composed function definitions to stdout + + meanwhile + + $ glossary admin # displays: + finddown finds servers marked 'down' in text file + + and + + $ reference draft # displays: + draft wraps last command into a new function + parameters: + 1: name to give function + examples: + $ ls + $ draft list + $ list +``` + +## Git integration + +If you already use git, installing composure will initialize a ~/.local/composure +repository, and store and version your functions there. Just use 'draft ()' and +'revise ()', they automatically version for you. + +Composure supports the [XDG Base Directory](http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html) +specification, and will respect your local XDG_DATA_HOME environment variable. + +Why do this? + + * the latest version of any function you've composed may always be sourced from + your composure repo + * never throw away code--keep your one-off functions in your composure 'junk + drawer', and grep through it later for long-forgotten gems + * every version of every function you write is always + available to you via basic git commands + +## Persistent access + +Draft or revise a function, and the latest version is automatically sourced into your current shell environment. By default, composure automatically sources all of your composed functions when you source the composure.sh script. If you are concerned about shell startup time, have many hundreds of versioned shell functions, or otherwise want to control which functions are loaded from your composure repository, you may disable the default behavior by adding the following line to your shell's startup script: + +```shell +export LOAD_COMPOSED_FUNCTIONS=0 +``` + +# Credits + +Composure grew out of ideas taken from from Gary Bernhardt's hilarious talk [The Unix +Chainsaw](http://www.confreaks.com/videos/615-cascadiaruby2011-the-unix-chainsaw) (31 minutes), +which refers to the Elements of Programming described in MIT's [SICP +text](http://mitpress.mit.edu/sicp/full-text/book/book.html): + + * primitive expressions + * means of combination + * means of abstraction + +## Known Issues + +'glossary ()' and 'reference ()' do not support nested functions with metadata. + +`revise` works well if your editor is terminal-based, like Emacs or Vim. If you use a windowed editor like Atom, VSCode, or Sublime, you will need to check to see if your editor supports a flag argument that allows it to wait for the files to be closed before returning. If this is supported, you can create a small script to launch your editor in this mode, and specify that script path in your `EDITOR` var. See https://github.com/erichs/composure/issues/10. diff --git a/vendor/github.com/erichs/composure/c_extras.sh b/vendor/github.com/erichs/composure/c_extras.sh index d975e20d..7c76889f 100644 --- a/vendor/github.com/erichs/composure/c_extras.sh +++ b/vendor/github.com/erichs/composure/c_extras.sh @@ -1,19 +1,20 @@ #!/bin/bash -_basename_no_extension () { +function _basename_no_extension () { sed -e 's/^.*\/\(.*\)\.inc$/\1/' } -_composure_functions () { +function _composure_functions () { _list_composure_files | _basename_no_extension } -_load_tab_completions () { +function _load_tab_completions () { # support tab completion for 'revise' command # you may disable this by adding the following line to your shell startup: # export COMPOSURE_TAB_COMPLETION=0 - if [ "$COMPOSURE_TAB_COMPLETION" = "0" ]; then + if [ "$COMPOSURE_TAB_COMPLETION" = "0" ] + then return # if you say so... fi @@ -52,7 +53,7 @@ BASHDATA # Second-order functions for composure -findgroup () +function findgroup () { about 'finds all functions belonging to group' param '1: name of group' @@ -63,13 +64,14 @@ findgroup () for func in $(_typeset_functions) do typeset group="$(typeset -f $func | metafor group)" - if [ "$group" = "$1" ]; then + if [ "$group" = "${1}" ] + then echo "$func" fi done } -overview () +function overview () { about 'gives overview of available shell functions, by group' group 'composure' @@ -81,7 +83,8 @@ overview () for func in $(_typeset_functions); do typeset group="$(typeset -f $func | metafor group)"; - if [ -z "$group" ]; then + if [ -z "$group" ] + then group='misc'; fi; typeset about="$(typeset -f $func | metafor about)"; @@ -102,7 +105,7 @@ overview () command rm $grouplist 2> /dev/null } -recompose () +function recompose () { about 'loads a stored function from ~/.composure repo' param '1: name of function' @@ -112,7 +115,7 @@ recompose () . $(_get_composure_dir)/$1.inc } -unique_metafor () +function unique_metafor () { about 'displays all unique metadata for a given keyword' param '1: keyword' @@ -127,7 +130,7 @@ unique_metafor () command rm $file 2>/dev/null } -compost () { +function compost () { about 'delete function stored in composure repo' param '1: name of function' example '$ compost myfunc' diff --git a/vendor/github.com/erichs/composure/composure.plugin.zsh b/vendor/github.com/erichs/composure/composure.plugin.zsh index 67102529..477482da 100644 --- a/vendor/github.com/erichs/composure/composure.plugin.zsh +++ b/vendor/github.com/erichs/composure/composure.plugin.zsh @@ -1,2 +1,2 @@ -#!/bin/zsh -source ${0:h}/{composure,c_extras}.sh +#!/bin/zsh +source ${0:h}/{composure,c_extras}.sh diff --git a/vendor/github.com/erichs/composure/composure.sh b/vendor/github.com/erichs/composure/composure.sh index ae11f9b3..1d1d1776 100755 --- a/vendor/github.com/erichs/composure/composure.sh +++ b/vendor/github.com/erichs/composure/composure.sh @@ -11,51 +11,55 @@ # 'plumbing' functions -_bootstrap_composure() { +_function bootstrap_composure() { _generate_metadata_functions _load_composed_functions _determine_printf_cmd } -_get_composure_dir () +function _get_composure_dir () { - if [ -n "${XDG_DATA_HOME:-}" ]; then + if [ -n "${XDG_DATA_HOME:-}" ] + then echo "$XDG_DATA_HOME/composure" else echo "$HOME/.local/composure" fi } -_get_author_name () +function _get_author_name () { typeset name localname localname="$(git --git-dir "$(_get_composure_dir)/.git" config --get user.name)" for name in "${GIT_AUTHOR_NAME:-}" "$localname"; do - if [ -n "$name" ]; then + if [ -n "$name" ] + then echo "$name" break fi done } -_composure_keywords () +function _composure_keywords () { echo "about author example group param version" } -_letterpress () +function _letterpress () { - typeset rightcol="$1" leftcol="${2:- }" leftwidth="${3:-20}" + typeset rightcol="${1}" leftcol="${2:- }" leftwidth="${3:-20}" - if [ -z "$rightcol" ]; then + if [ -z "$rightcol" ] + then return fi $_printf_cmd "%-*s%s\n" "$leftwidth" "$leftcol" "$rightcol" } -_determine_printf_cmd() { - if [ -z "${_printf_cmd:-}" ]; then +function _determine_printf_cmd() { + if [ -z "${_printf_cmd:-}" ] + then _printf_cmd=printf # prefer GNU gprintf if available [ -x "$(which gprintf 2>/dev/null)" ] && _printf_cmd=gprintf @@ -63,9 +67,9 @@ _determine_printf_cmd() { fi } -_longest_function_name_length () +function _longest_function_name_length () { - echo "$1" | awk 'BEGIN{ maxlength=0 } + echo "${1}" | awk 'BEGIN{ maxlength=0 } { for(i=1;i<=NF;i++) if (length($i)>maxlength) @@ -76,16 +80,16 @@ _longest_function_name_length () END{ print maxlength}' } -_temp_filename_for () +function _temp_filename_for () { typeset file="$(mktemp "/tmp/$1.XXXX")" command rm "$file" 2>/dev/null # ensure file is unlinked prior to use echo "$file" } -_prompt () +function _prompt () { - typeset prompt="$1" + typeset prompt="${1}" typeset result case "$(_shell)" in bash) @@ -96,27 +100,31 @@ _prompt () echo "$result" } -_add_composure_file () +function _add_composure_file () { - typeset func="$1" - typeset file="$2" - typeset operation="$3" + typeset func="${1}" + typeset file="${2}" + typeset operation="${3}" typeset comment="${4:-}" typeset composure_dir=$(_get_composure_dir) ( - if ! cd "$composure_dir"; then + if ! cd "$composure_dir" + then printf "%s\n" "Oops! Can't find $composure_dir!" return fi - if git rev-parse 2>/dev/null; then - if [ ! -f "$file" ]; then + if git rev-parse 2>/dev/null + then + if [ ! -f "$file" ] + then printf "%s\n" "Oops! Couldn't find $file to version it for you..." return fi cp "$file" "$composure_dir/$func.inc" git add --all . - if [ -z "$comment" ]; then + if [ -z "$comment" ] + then comment="$(_prompt 'Git Comment: ')" fi git commit -m "$operation $func: $comment" @@ -124,19 +132,22 @@ _add_composure_file () ) } -_transcribe () +function _transcribe () { - typeset func="$1" - typeset file="$2" - typeset operation="$3" + typeset func="${1}" + typeset file="${2}" + typeset operation="${3}" typeset comment="${4:-}" typeset composure_dir=$(_get_composure_dir) - if git --version >/dev/null 2>&1; then - if [ -d "$composure_dir" ]; then + if git --version >/dev/null 2>&1 + then + if [ -d "$composure_dir" ] + then _add_composure_file "$func" "$file" "$operation" "$comment" else - if [ "${USE_COMPOSURE_REPO:-}" = "0" ]; then + if [ "${USE_COMPOSURE_REPO:-}" = "0" ] + then return # if you say so... fi printf "%s\n" "I see you don't have a $composure_dir repo..." @@ -173,7 +184,7 @@ _transcribe () fi } -_typeset_functions () +function _typeset_functions () { # unfortunately, there does not seem to be a easy, portable way to list just the # names of the defined shell functions... @@ -189,7 +200,7 @@ _typeset_functions () esac } -_typeset_functions_about () +function _typeset_functions_about () { typeset f for f in $(_typeset_functions); do @@ -197,7 +208,7 @@ _typeset_functions_about () done } -_shell () { +function _shell () { # here's a hack I modified from a StackOverflow post: # get the ps listing for the current process ($$), and print the last column (CMD) # stripping any leading hyphens shells sometimes throw in there @@ -205,7 +216,7 @@ _shell () { echo "${this##*/}" # e.g. /bin/bash => bash } -_generate_metadata_functions() { +function _generate_metadata_functions() { typeset f for f in $(_composure_keywords) do @@ -213,17 +224,18 @@ _generate_metadata_functions() { done } -_list_composure_files () { +function _list_composure_files () { typeset composure_dir="$(_get_composure_dir)" [ -d "$composure_dir" ] && find "$composure_dir" -maxdepth 1 -name '*.inc' } -_load_composed_functions () { +function _load_composed_functions () { # load previously composed functions into shell # you may disable this by adding the following line to your shell startup: # export LOAD_COMPOSED_FUNCTIONS=0 - if [ "${LOAD_COMPOSED_FUNCTIONS:-}" = "0" ]; then + if [ "${LOAD_COMPOSED_FUNCTIONS:-}" = "0" ] + then return # if you say so... fi @@ -234,18 +246,18 @@ _load_composed_functions () { done } -_strip_trailing_whitespace () { +function _strip_trailing_whitespace () { sed -e 's/ \+$//' } -_strip_semicolons () { +function _strip_semicolons () { sed -e 's/;$//' } # 'porcelain' functions -cite () +function cite () { about 'creates one or more meta keywords for use in your functions' param 'one or more keywords' @@ -267,7 +279,8 @@ cite () # contractions, and consider single or double quoting if it contains # non-alphanumeric characters - if [ -z "$1" ]; then + if [ -z "${1}" ] + then printf '%s\n' 'missing parameter(s)' reference cite return @@ -279,7 +292,7 @@ cite () done } -draft () +function draft () { about 'wraps command from history into a new function, default is last command' param '1: name to give function' @@ -292,20 +305,23 @@ draft () typeset func=$1 typeset num=$2 - if [ -z "$func" ]; then + if [ -z "$func" ] + then printf '%s\n' 'missing parameter(s)' reference draft return fi # aliases bind tighter than function names, disallow them - if type -a "$func" 2>/dev/null | grep -q 'is.*alias'; then + if type -a "$func" 2>/dev/null | grep -q 'is.*alias' + then printf '%s\n' "sorry, $(type -a "$func"). please choose another name." return fi typeset cmd - if [ -z "$num" ]; then + if [ -z "$num" ] + then # some versions of 'fix command, fc' need corrective lenses... typeset lines=$(fc -ln -1 | grep -q draft && echo 2 || echo 1) # parse last command from fc output @@ -331,7 +347,7 @@ draft () revise "$func" } -glossary () +function glossary () { about 'displays help summary for all functions, or summary for a group of functions' param '1: optional, group name' @@ -345,9 +361,11 @@ glossary () for func in $(echo $functionlist); do - if [ "X${targetgroup}X" != "XX" ]; then + if [ "X${targetgroup}X" != "XX" ] + then typeset group="$(typeset -f -- $func | metafor group)" - if [ "$group" != "$targetgroup" ]; then + if [ "$group" != "$targetgroup" ] + then continue # skip non-matching groups, if specified fi fi @@ -360,7 +378,7 @@ glossary () done } -metafor () +function metafor () { about 'prints function metadata associated with keyword' param '1: meta keyword' @@ -369,7 +387,8 @@ metafor () typeset keyword=$1 - if [ -z "$keyword" ]; then + if [ -z "$keyword" ] + then printf '%s\n' 'missing parameter(s)' reference metafor return @@ -382,7 +401,7 @@ metafor () sed -n "/$keyword / s/['\";]*\$//;s/^[ ]*\(: _\)*$keyword ['\"]*\([^([].*\)*\$/\2/p" } -reference () +function reference () { about 'displays apidoc help for a specific function' param '1: function name' @@ -390,7 +409,8 @@ reference () group 'composure' typeset func=$1 - if [ -z "$func" ]; then + if [ -z "$func" ] + then printf '%s\n' 'missing parameter(s)' reference reference return @@ -402,16 +422,19 @@ reference () _letterpress "$about" "$func" typeset author="$(typeset -f $func | metafor author)" - if [ -n "$author" ]; then + if [ -n "$author" ] + then _letterpress "$author" 'author:' fi typeset version="$(typeset -f $func | metafor version)" - if [ -n "$version" ]; then + if [ -n "$version" ] + then _letterpress "$version" 'version:' fi - if [ -n "$(typeset -f $func | metafor param)" ]; then + if [ -n "$(typeset -f $func | metafor param)" ] + then printf "parameters:\n" typeset -f $func | metafor param | while read -r line do @@ -419,7 +442,8 @@ reference () done fi - if [ -n "$(typeset -f $func | metafor example)" ]; then + if [ -n "$(typeset -f $func | metafor example)" ] + then printf "examples:\n" typeset -f $func | metafor example | while read -r line do @@ -428,7 +452,7 @@ reference () fi } -revise () +function revise () { about 'loads function into editor for revision' param ' -e: revise version stored in ENV' @@ -439,13 +463,15 @@ revise () group 'composure' typeset source='git' - if [ "$1" = '-e' ]; then + if [ "${1}" = '-e' ] + then source='env' shift fi typeset func=$1 - if [ -z "$func" ]; then + if [ -z "$func" ] + then printf '%s\n' 'missing parameter(s)' reference revise return @@ -454,7 +480,8 @@ revise () typeset composure_dir=$(_get_composure_dir) typeset temp=$(_temp_filename_for revise) # populate tempfile... - if [ "$source" = 'env' ] || [ ! -f "$composure_dir/$func.inc" ]; then + if [ "$source" = 'env' ] || [ ! -f "$composure_dir/$func.inc" ] + then # ...with ENV if specified or not previously versioned typeset -f $func > $temp else @@ -468,7 +495,8 @@ revise () fi $EDITOR "$temp" - if [ -s "$temp" ]; then + if [ -s "$temp" ] + then typeset edit='N' # source edited file @@ -496,7 +524,7 @@ revise () command rm "$temp" } -write () +function write () { about 'writes one or more composed function definitions to stdout' param 'one or more function names' @@ -504,7 +532,8 @@ example '$ write finddown foo' example '$ write finddown' group 'composure' -if [ -z "$1" ]; then +if [ -z "${1}" ] + then printf '%s\n' 'missing parameter(s)' reference write return diff --git a/vendor/github.com/erichs/composure/test/Makefile b/vendor/github.com/erichs/composure/test/Makefile index 3117e212..b7718b52 100644 --- a/vendor/github.com/erichs/composure/test/Makefile +++ b/vendor/github.com/erichs/composure/test/Makefile @@ -1,18 +1,18 @@ - -TARGET = tests - -all: $(TARGET) - -runtests: - ./runtests.sh - -runshellcheck: - ./runshellcheck.sh - -tests: - ./wvtestrun $(MAKE) runshellcheck - -clean:: - rm -f *~ t/*~ - rm -rf composure_test - + +TARGET = tests + +all: $(TARGET) + +runtests: + ./runtests.sh + +runshellcheck: + ./runshellcheck.sh + +tests: + ./wvtestrun $(MAKE) runshellcheck + +clean:: + rm -f *~ t/*~ + rm -rf composure_test + diff --git a/vendor/github.com/erichs/composure/test/runshellcheck.sh b/vendor/github.com/erichs/composure/test/runshellcheck.sh index 6c5fdfc1..3c2bac2b 100755 --- a/vendor/github.com/erichs/composure/test/runshellcheck.sh +++ b/vendor/github.com/erichs/composure/test/runshellcheck.sh @@ -13,7 +13,8 @@ cat $metricfile # check for shellcheck.net errors cat $metricfile | grep -q error -if [ $? -eq 0 ]; then +if [ $? -eq 0 ] + then echo "! shellcheck.net:../composure.sh:0 [ errors ] FAILED" rm $metricfile exit 2 @@ -21,7 +22,8 @@ fi # check for shellcheck.net warnings cat $metricfile | grep -q warning -if [ $? -eq 0 ]; then +if [ $? -eq 0 ] + then echo "! shellcheck.net:../composure.sh:0 [ warnings ] FAILED" rm $metricfile exit 2 diff --git a/vendor/github.com/erichs/composure/test/wvtestrun b/vendor/github.com/erichs/composure/test/wvtestrun index 8a61de34..2947c394 100755 --- a/vendor/github.com/erichs/composure/test/wvtestrun +++ b/vendor/github.com/erichs/composure/test/wvtestrun @@ -1,189 +1,189 @@ -#!/usr/bin/perl -w -# -# WvTest: -# Copyright (C)2007-2012 Versabanq Innovations Inc. and contributors. -# Licensed under the GNU Library General Public License, version 2. -# See the included file named LICENSE for license information. -# You can get wvtest from: http://github.com/apenwarr/wvtest -# -use strict; -use Time::HiRes qw(time); - -# always flush -$| = 1; - -if (@ARGV < 1) { - print STDERR "Usage: $0 \n"; - exit 127; -} - -print STDERR "Testing \"all\" in @ARGV:\n"; - -my $pid = open(my $fh, "-|"); -if (!$pid) { - # child - setpgrp(); - open STDERR, '>&STDOUT' or die("Can't dup stdout: $!\n"); - exec(@ARGV); - exit 126; # just in case -} - -my $istty = -t STDOUT && $ENV{'TERM'} ne "dumb"; -my @log = (); -my ($gpasses, $gfails) = (0,0); - -sub bigkill($) -{ - my $pid = shift; - - if (@log) { - print "\n" . join("\n", @log) . "\n"; - } - - print STDERR "\n! Killed by signal FAILED\n"; - - ($pid > 0) || die("pid is '$pid'?!\n"); - - local $SIG{CHLD} = sub { }; # this will wake us from sleep() faster - kill 15, $pid; - sleep(2); - - if ($pid > 1) { - kill 9, -$pid; - } - kill 9, $pid; - - exit(125); -} - -# parent -local $SIG{INT} = sub { bigkill($pid); }; -local $SIG{TERM} = sub { bigkill($pid); }; -local $SIG{ALRM} = sub { - print STDERR "Alarm timed out! No test results for too long.\n"; - bigkill($pid); -}; - -sub colourize($) -{ - my $result = shift; - my $pass = ($result eq "ok"); - - if ($istty) { - my $colour = $pass ? "\e[32;1m" : "\e[31;1m"; - return "$colour$result\e[0m"; - } else { - return $result; - } -} - -sub mstime($$$) -{ - my ($floatsec, $warntime, $badtime) = @_; - my $ms = int($floatsec * 1000); - my $str = sprintf("%d.%03ds", $ms/1000, $ms % 1000); - - if ($istty && $ms > $badtime) { - return "\e[31;1m$str\e[0m"; - } elsif ($istty && $ms > $warntime) { - return "\e[33;1m$str\e[0m"; - } else { - return "$str"; - } -} - -sub resultline($$) -{ - my ($name, $result) = @_; - return sprintf("! %-65s %s", $name, colourize($result)); -} - -my $allstart = time(); -my ($start, $stop); - -sub endsect() -{ - $stop = time(); - if ($start) { - printf " %s %s\n", mstime($stop - $start, 500, 1000), colourize("ok"); - } -} - -while (<$fh>) -{ - chomp; - s/\r//g; - - if (/^\s*Testing "(.*)" with (.*) in (.*):\s*$/) - { - alarm(120); - my ($sect, $shell, $file) = ($1, $2, $3); - - endsect(); - - chomp($shell=`basename $shell`); - - printf("! %s %s %s: ", $shell, $file, $sect); - @log = (); - $start = $stop; - } - elsif (/^!\s*(.*?)\s+(\S+)\s*$/) - { - alarm(120); - - my ($name, $result) = ($1, $2); - my $pass = ($result eq "ok"); - - if (!$start) { - printf("\n! Startup: "); - $start = time(); - } - - push @log, resultline($name, $result); - - if (!$pass) { - $gfails++; - if (@log) { - print "\n" . join("\n", @log) . "\n"; - @log = (); - } - } else { - $gpasses++; - print "."; - } - } - else - { - push @log, $_; - } -} - -endsect(); - -my $newpid = waitpid($pid, 0); -if ($newpid != $pid) { - die("waitpid returned '$newpid', expected '$pid'\n"); -} - -my $code = $?; -my $ret = ($code >> 8); - -# return death-from-signal exits as >128. This is what bash does if you ran -# the program directly. -if ($code && !$ret) { $ret = $code | 128; } - -if ($ret && @log) { - print "\n" . join("\n", @log) . "\n"; -} - -if ($code != 0) { - print resultline("Program returned non-zero exit code ($ret)", "FAILED"); -} - -my $gtotal = $gpasses+$gfails; -printf("\nWvTest: %d test%s, %d failure%s, total time %s.\n", - $gtotal, $gtotal==1 ? "" : "s", - $gfails, $gfails==1 ? "" : "s", - mstime(time() - $allstart, 2000, 5000)); -print STDERR "\nWvTest result code: $ret\n"; -exit( $ret ? $ret : ($gfails ? 125 : 0) ); +#!/usr/bin/perl -w +# +# WvTest: +# Copyright (C)2007-2012 Versabanq Innovations Inc. and contributors. +# Licensed under the GNU Library General Public License, version 2. +# See the included file named LICENSE for license information. +# You can get wvtest from: http://github.com/apenwarr/wvtest +# +use strict; +use Time::HiRes qw(time); + +# always flush +$| = 1; + +if (@ARGV < 1) { + print STDERR "Usage: $0 \n"; + exit 127; +} + +print STDERR "Testing \"all\" in @ARGV:\n"; + +my $pid = open(my $fh, "-|"); +if (!$pid) { + # child + setpgrp(); + open STDERR, '>&STDOUT' or die("Can't dup stdout: $!\n"); + exec(@ARGV); + exit 126; # just in case +} + +my $istty = -t STDOUT && $ENV{'TERM'} ne "dumb"; +my @log = (); +my ($gpasses, $gfails) = (0,0); + +sub bigkill($) +{ + my $pid = shift; + + if (@log) { + print "\n" . join("\n", @log) . "\n"; + } + + print STDERR "\n! Killed by signal FAILED\n"; + + ($pid > 0) || die("pid is '$pid'?!\n"); + + local $SIG{CHLD} = sub { }; # this will wake us from sleep() faster + kill 15, $pid; + sleep(2); + + if ($pid > 1) { + kill 9, -$pid; + } + kill 9, $pid; + + exit(125); +} + +# parent +local $SIG{INT} = sub { bigkill($pid); }; +local $SIG{TERM} = sub { bigkill($pid); }; +local $SIG{ALRM} = sub { + print STDERR "Alarm timed out! No test results for too long.\n"; + bigkill($pid); +}; + +sub colourize($) +{ + my $result = shift; + my $pass = ($result eq "ok"); + + if ($istty) { + my $colour = $pass ? "\e[32;1m" : "\e[31;1m"; + return "$colour$result\e[0m"; + } else { + return $result; + } +} + +sub mstime($$$) +{ + my ($floatsec, $warntime, $badtime) = @_; + my $ms = int($floatsec * 1000); + my $str = sprintf("%d.%03ds", $ms/1000, $ms % 1000); + + if ($istty && $ms > $badtime) { + return "\e[31;1m$str\e[0m"; + } elsif ($istty && $ms > $warntime) { + return "\e[33;1m$str\e[0m"; + } else { + return "$str"; + } +} + +sub resultline($$) +{ + my ($name, $result) = @_; + return sprintf("! %-65s %s", $name, colourize($result)); +} + +my $allstart = time(); +my ($start, $stop); + +sub endsect() +{ + $stop = time(); + if ($start) { + printf " %s %s\n", mstime($stop - $start, 500, 1000), colourize("ok"); + } +} + +while (<$fh>) +{ + chomp; + s/\r//g; + + if (/^\s*Testing "(.*)" with (.*) in (.*):\s*$/) + { + alarm(120); + my ($sect, $shell, $file) = ($1, $2, $3); + + endsect(); + + chomp($shell=`basename $shell`); + + printf("! %s %s %s: ", $shell, $file, $sect); + @log = (); + $start = $stop; + } + elsif (/^!\s*(.*?)\s+(\S+)\s*$/) + { + alarm(120); + + my ($name, $result) = ($1, $2); + my $pass = ($result eq "ok"); + + if (!$start) { + printf("\n! Startup: "); + $start = time(); + } + + push @log, resultline($name, $result); + + if (!$pass) { + $gfails++; + if (@log) { + print "\n" . join("\n", @log) . "\n"; + @log = (); + } + } else { + $gpasses++; + print "."; + } + } + else + { + push @log, $_; + } +} + +endsect(); + +my $newpid = waitpid($pid, 0); +if ($newpid != $pid) { + die("waitpid returned '$newpid', expected '$pid'\n"); +} + +my $code = $?; +my $ret = ($code >> 8); + +# return death-from-signal exits as >128. This is what bash does if you ran +# the program directly. +if ($code && !$ret) { $ret = $code | 128; } + +if ($ret && @log) { + print "\n" . join("\n", @log) . "\n"; +} + +if ($code != 0) { + print resultline("Program returned non-zero exit code ($ret)", "FAILED"); +} + +my $gtotal = $gpasses+$gfails; +printf("\nWvTest: %d test%s, %d failure%s, total time %s.\n", + $gtotal, $gtotal==1 ? "" : "s", + $gfails, $gfails==1 ? "" : "s", + mstime(time() - $allstart, 2000, 5000)); +print STDERR "\nWvTest result code: $ret\n"; +exit( $ret ? $ret : ($gfails ? 125 : 0) ); diff --git a/vendor/github.com/gaelicWizard/bash-progcomp/.editorconfig b/vendor/github.com/gaelicWizard/bash-progcomp/.editorconfig index e1eba2cf..9a3cec35 100644 --- a/vendor/github.com/gaelicWizard/bash-progcomp/.editorconfig +++ b/vendor/github.com/gaelicWizard/bash-progcomp/.editorconfig @@ -1,40 +1,40 @@ -# EditorConfig is awesome: http://EditorConfig.org - -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -[**.md] -indent_style = space -indent_size = 2 -trim_trailing_whitespace = false - -[.git*] -indent_style = tab - -[**.*sh] -indent_style = tab -indent_size = tab - -shell_variant = bash -binary_next_line = true # like -bn -switch_case_indent = false # like -ci -space_redirects = true # like -sr -keep_padding = false # like -kp -function_next_line = true # like -fn -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -[**.bats] -indent_style = tab -indent_size = tab - -shell_variant = bash -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true +# EditorConfig is awesome: http://EditorConfig.org + +[*] +end_of_line = lf +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true + +[**.md] +indent_style = space +indent_size = 2 +trim_trailing_whitespace = false + +[.git*] +indent_style = tab + +[**.*sh] +indent_style = tab +indent_size = tab + +shell_variant = bash +binary_next_line = true # like -bn +switch_case_indent = false # like -ci +space_redirects = true # like -sr +keep_padding = false # like -kp +function_next_line = true # like -fn +end_of_line = lf +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true + +[**.bats] +indent_style = tab +indent_size = tab + +shell_variant = bash +end_of_line = lf +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true diff --git a/vendor/github.com/gaelicWizard/bash-progcomp/LICENSE b/vendor/github.com/gaelicWizard/bash-progcomp/LICENSE index cd48959a..e4bb727f 100644 --- a/vendor/github.com/gaelicWizard/bash-progcomp/LICENSE +++ b/vendor/github.com/gaelicWizard/bash-progcomp/LICENSE @@ -1,30 +1,30 @@ -BSD 3-Clause License - -Copyright (c) 2006, Playhaus -Copyright (c) 2021, gaelicWizard.LLC -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - -1. Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - -2. Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - -3. Neither the name of the copyright holder nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +BSD 3-Clause License + +Copyright (c) 2006, Playhaus +Copyright (c) 2021, gaelicWizard.LLC +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +3. Neither the name of the copyright holder nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/vendor/github.com/gaelicWizard/bash-progcomp/defaults.completion.bats b/vendor/github.com/gaelicWizard/bash-progcomp/defaults.completion.bats index 65b32dad..496a713a 100755 --- a/vendor/github.com/gaelicWizard/bash-progcomp/defaults.completion.bats +++ b/vendor/github.com/gaelicWizard/bash-progcomp/defaults.completion.bats @@ -1,184 +1,185 @@ -#!/usr/bin/env bats - -load ../test_helper - -function local_setup() { - load ../../completion/available/defaults.completion - function _known_hosts() { :; } - function defaults() { echo 'NSGlobalDomain, Bash It'; } -} - -function __check_completion() { - # Get the parameters as a single value - COMP_LINE=$* - - # Get the parameters as an array - eval set -- "$@" - COMP_WORDS=("$@") - - # Index of the cursor in the line - COMP_POINT=${#COMP_LINE} - - # Get the last character of the line that was entered - COMP_LAST=$((${COMP_POINT} - 1)) - - # If the last character was a space... - if [[ ${COMP_LINE:$COMP_LAST} = ' ' ]]; then - # ...then add an empty array item - COMP_WORDS+=('') - fi - - # Word index of the last word - COMP_CWORD=$(( ${#COMP_WORDS[@]} - 1 )) - - # Run the Bash-it completion function - _defaults - - # Return the completion output - echo "${COMPREPLY[@]}" -} - -@test "completion defaults: ensure that the _defaults function is available" { - type -a _defaults &> /dev/null - assert_success -} - -@test "completion defaults: - show verbs and options" { - run __check_completion 'defaults ' - assert_line -n 0 'delete domains export find help import read read-type rename write -currentHost -host' -} - -@test "completion defaults: r* - show matching verbs" { - run __check_completion 'defaults r' - assert_line -n 0 'read read-type rename' -} - -@test "completion defaults: R* - show matching verbs" { - run __check_completion 'defaults R' - assert_line -n 0 'read read-type rename' -} - -@test "completion defaults: -* - show matching flags" { - run __check_completion 'defaults -' - assert_line -n 0 '-currentHost -host' -} - -@test "completion defaults: -currentHost - show verbs" { - run __check_completion 'defaults -currentHost ' - assert_line -n 0 'delete domains export find help import read read-type rename write' -} - -@test "completion defaults: -host - show nothing" { - run __check_completion 'defaults -host ' - assert_line -n 0 "$(_known_hosts -a)" -} - -@test "completion defaults: -host some_computer_name - show verbs" { - run __check_completion 'defaults -host some_computer_name ' - assert_line -n 0 'delete domains export find help import read read-type rename write' -} - -@test "completion defaults: read - show all domains" { - run __check_completion 'defaults read ' - assert_line -n 0 "NSGlobalDomain Bash\ It -app" -} - -@test "completion defaults: read nsg* - show matching domains" { - run __check_completion 'defaults read nsg' - assert_line -n 0 "NSGlobalDomain" -} - -@test "completion defaults: read NSG* - show matching domains" { - run __check_completion 'defaults read NSG' - assert_line -n 0 "NSGlobalDomain" -} - -@test "completion defaults: read bash* - show matching domains" { - run __check_completion 'defaults read bash' - assert_line -n 0 "Bash\ It" -} - -@test "completion defaults: read BASH* - show matching domains" { - run __check_completion 'defaults read BASH' - assert_line -n 0 "Bash\ It" -} - -@test "completion defaults: read bash* - show matching domains (with spaces)" { - run __check_completion 'defaults read bash\ i' - assert_line -n 0 "Bash\ It" -} - -@test "completion defaults: read BASH* - show matching domains (with spaces)" { - run __check_completion 'defaults read BASH\ I' - assert_line -n 0 "Bash\ It" -} - -@test "completion defaults: -currentHost read - show all domains" { - run __check_completion 'defaults -currentHost read ' - assert_line -n 0 "NSGlobalDomain Bash\ It -app" -} - -@test "completion defaults: -currentHost read nsg* - show matching domains" { - run __check_completion 'defaults -currentHost read nsg' - assert_line -n 0 "NSGlobalDomain" -} - -@test "completion defaults: -currentHost read NSG* - show matching domains" { - run __check_completion 'defaults -currentHost read NSG' - assert_line -n 0 "NSGlobalDomain" -} - -@test "completion defaults: -currentHost read bash* - show matching domains" { - run __check_completion 'defaults -currentHost read bash' - assert_line -n 0 "Bash\ It" -} - -@test "completion defaults: -currentHost read BASH* - show matching domains" { - run __check_completion 'defaults -currentHost read BASH' - assert_line -n 0 "Bash\ It" -} - -@test "completion defaults: -currentHost read bash* - show matching domains (with spaces)" { - run __check_completion 'defaults -currentHost read bash\ i' - assert_line -n 0 "Bash\ It" -} - -@test "completion defaults: -currentHost read BASH* - show matching domains (with spaces)" { - run __check_completion 'defaults -currentHost read BASH\ I' - assert_line -n 0 "Bash\ It" -} - -@test "completion defaults: -host some.computer.name read - show all domains" { - run __check_completion 'defaults -host some.computer.name read ' - assert_line -n 0 "NSGlobalDomain Bash\ It -app" -} - -@test "completion defaults: -host some.computer.name read nsg* - show matching domains" { - run __check_completion 'defaults -host some.computer.name read nsg' - assert_line -n 0 "NSGlobalDomain" -} - -@test "completion defaults: -host some.computer.name read NSG* - show matching domains" { - run __check_completion 'defaults -host some.computer.name read NSG' - assert_line -n 0 "NSGlobalDomain" -} - -@test "completion defaults: -host some.computer.name read bash* - show matching domains" { - run __check_completion 'defaults -host some.computer.name read bash' - assert_line -n 0 "Bash\ It" -} - -@test "completion defaults: -host some.computer.name read BASH* - show matching domains" { - run __check_completion 'defaults -host some.computer.name read BASH' - assert_line -n 0 "Bash\ It" -} - -@test "completion defaults: -host some.computer.name read bash* - show matching domains (with spaces)" { - run __check_completion 'defaults -host some.computer.name read bash\ i' - assert_line -n 0 "Bash\ It" -} - -@test "completion defaults: -host some.computer.name read BASH* - show matching domains (with spaces)" { - run __check_completion 'defaults -host some.computer.name read BASH\ I' - assert_line -n 0 "Bash\ It" -} +#!/usr/bin/env bats + +load ../test_helper + +function local_setup() { + load ../../completion/available/defaults.completion + function _known_hosts() { :; } + function defaults() { echo 'NSGlobalDomain, Bash It'; } +} + +function __check_completion() { + # Get the parameters as a single value + COMP_LINE=$* + + # Get the parameters as an array + eval set -- "$@" + COMP_WORDS=("$@") + + # Index of the cursor in the line + COMP_POINT=${#COMP_LINE} + + # Get the last character of the line that was entered + COMP_LAST=$((${COMP_POINT} - 1)) + + # If the last character was a space... + if [[ ${COMP_LINE:$COMP_LAST} = ' ' ]] + then + # ...then add an empty array item + COMP_WORDS+=('') + fi + + # Word index of the last word + COMP_CWORD=$(( ${#COMP_WORDS[@]} - 1 )) + + # Run the Bash-it completion function + _defaults + + # Return the completion output + echo "${COMPREPLY[@]}" +} + +@test "completion defaults: ensure that the _defaults function is available" { + type -a _defaults &> /dev/null + assert_success +} + +@test "completion defaults: - show verbs and options" { + run __check_completion 'defaults ' + assert_line -n 0 'delete domains export find help import read read-type rename write -currentHost -host' +} + +@test "completion defaults: r* - show matching verbs" { + run __check_completion 'defaults r' + assert_line -n 0 'read read-type rename' +} + +@test "completion defaults: R* - show matching verbs" { + run __check_completion 'defaults R' + assert_line -n 0 'read read-type rename' +} + +@test "completion defaults: -* - show matching flags" { + run __check_completion 'defaults -' + assert_line -n 0 '-currentHost -host' +} + +@test "completion defaults: -currentHost - show verbs" { + run __check_completion 'defaults -currentHost ' + assert_line -n 0 'delete domains export find help import read read-type rename write' +} + +@test "completion defaults: -host - show nothing" { + run __check_completion 'defaults -host ' + assert_line -n 0 "$(_known_hosts -a)" +} + +@test "completion defaults: -host some_computer_name - show verbs" { + run __check_completion 'defaults -host some_computer_name ' + assert_line -n 0 'delete domains export find help import read read-type rename write' +} + +@test "completion defaults: read - show all domains" { + run __check_completion 'defaults read ' + assert_line -n 0 "NSGlobalDomain Bash\ It -app" +} + +@test "completion defaults: read nsg* - show matching domains" { + run __check_completion 'defaults read nsg' + assert_line -n 0 "NSGlobalDomain" +} + +@test "completion defaults: read NSG* - show matching domains" { + run __check_completion 'defaults read NSG' + assert_line -n 0 "NSGlobalDomain" +} + +@test "completion defaults: read bash* - show matching domains" { + run __check_completion 'defaults read bash' + assert_line -n 0 "Bash\ It" +} + +@test "completion defaults: read BASH* - show matching domains" { + run __check_completion 'defaults read BASH' + assert_line -n 0 "Bash\ It" +} + +@test "completion defaults: read bash* - show matching domains (with spaces)" { + run __check_completion 'defaults read bash\ i' + assert_line -n 0 "Bash\ It" +} + +@test "completion defaults: read BASH* - show matching domains (with spaces)" { + run __check_completion 'defaults read BASH\ I' + assert_line -n 0 "Bash\ It" +} + +@test "completion defaults: -currentHost read - show all domains" { + run __check_completion 'defaults -currentHost read ' + assert_line -n 0 "NSGlobalDomain Bash\ It -app" +} + +@test "completion defaults: -currentHost read nsg* - show matching domains" { + run __check_completion 'defaults -currentHost read nsg' + assert_line -n 0 "NSGlobalDomain" +} + +@test "completion defaults: -currentHost read NSG* - show matching domains" { + run __check_completion 'defaults -currentHost read NSG' + assert_line -n 0 "NSGlobalDomain" +} + +@test "completion defaults: -currentHost read bash* - show matching domains" { + run __check_completion 'defaults -currentHost read bash' + assert_line -n 0 "Bash\ It" +} + +@test "completion defaults: -currentHost read BASH* - show matching domains" { + run __check_completion 'defaults -currentHost read BASH' + assert_line -n 0 "Bash\ It" +} + +@test "completion defaults: -currentHost read bash* - show matching domains (with spaces)" { + run __check_completion 'defaults -currentHost read bash\ i' + assert_line -n 0 "Bash\ It" +} + +@test "completion defaults: -currentHost read BASH* - show matching domains (with spaces)" { + run __check_completion 'defaults -currentHost read BASH\ I' + assert_line -n 0 "Bash\ It" +} + +@test "completion defaults: -host some.computer.name read - show all domains" { + run __check_completion 'defaults -host some.computer.name read ' + assert_line -n 0 "NSGlobalDomain Bash\ It -app" +} + +@test "completion defaults: -host some.computer.name read nsg* - show matching domains" { + run __check_completion 'defaults -host some.computer.name read nsg' + assert_line -n 0 "NSGlobalDomain" +} + +@test "completion defaults: -host some.computer.name read NSG* - show matching domains" { + run __check_completion 'defaults -host some.computer.name read NSG' + assert_line -n 0 "NSGlobalDomain" +} + +@test "completion defaults: -host some.computer.name read bash* - show matching domains" { + run __check_completion 'defaults -host some.computer.name read bash' + assert_line -n 0 "Bash\ It" +} + +@test "completion defaults: -host some.computer.name read BASH* - show matching domains" { + run __check_completion 'defaults -host some.computer.name read BASH' + assert_line -n 0 "Bash\ It" +} + +@test "completion defaults: -host some.computer.name read bash* - show matching domains (with spaces)" { + run __check_completion 'defaults -host some.computer.name read bash\ i' + assert_line -n 0 "Bash\ It" +} + +@test "completion defaults: -host some.computer.name read BASH* - show matching domains (with spaces)" { + run __check_completion 'defaults -host some.computer.name read BASH\ I' + assert_line -n 0 "Bash\ It" +} diff --git a/vendor/github.com/rcaloras/bash-preexec/.travis.yml b/vendor/github.com/rcaloras/bash-preexec/.travis.yml index 4f0c8610..dee7eb58 100644 --- a/vendor/github.com/rcaloras/bash-preexec/.travis.yml +++ b/vendor/github.com/rcaloras/bash-preexec/.travis.yml @@ -1,20 +1,20 @@ -language: bash - -before_install: - # To install bats and test our shell/bash functions - - git clone -b "v1.1.0" "https://github.com/bats-core/bats-core.git" - - sudo ./bats-core/install.sh /usr/local - - rm -rf ./bats-core - - sudo apt-get install -qq zsh - -# For bats functional tests -env: - - functional_test="true" - -# command to run tests -script: - - /usr/local/bin/bats test - -notifications: - email: - on_success: never +language: bash + +before_install: + # To install bats and test our shell/bash functions + - git clone -b "v1.1.0" "https://github.com/bats-core/bats-core.git" + - sudo ./bats-core/install.sh /usr/local + - rm -rf ./bats-core + - sudo apt-get install -qq zsh + +# For bats functional tests +env: + - functional_test="true" + +# command to run tests +script: + - /usr/local/bin/bats test + +notifications: + email: + on_success: never diff --git a/vendor/github.com/rcaloras/bash-preexec/LICENSE.md b/vendor/github.com/rcaloras/bash-preexec/LICENSE.md index b4521b39..da853b5f 100644 --- a/vendor/github.com/rcaloras/bash-preexec/LICENSE.md +++ b/vendor/github.com/rcaloras/bash-preexec/LICENSE.md @@ -1,21 +1,21 @@ -The MIT License - -Copyright (c) 2017 Ryan Caloras and contributors (see https://github.com/rcaloras/bash-preexec) - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. +The MIT License + +Copyright (c) 2017 Ryan Caloras and contributors (see https://github.com/rcaloras/bash-preexec) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/vendor/github.com/rcaloras/bash-preexec/README.md b/vendor/github.com/rcaloras/bash-preexec/README.md index 3e88c844..4f67b4b1 100644 --- a/vendor/github.com/rcaloras/bash-preexec/README.md +++ b/vendor/github.com/rcaloras/bash-preexec/README.md @@ -1,107 +1,107 @@ -[![Build Status](https://travis-ci.org/rcaloras/bash-preexec.svg?branch=master)](https://travis-ci.org/rcaloras/bash-preexec) -[![GitHub version](https://badge.fury.io/gh/rcaloras%2Fbash-preexec.svg)](https://badge.fury.io/gh/rcaloras%2Fbash-preexec) - -Bash-Preexec -============ - -**preexec** and **precmd** hook functions for Bash in the style of Zsh. They aim to emulate the behavior [as described for Zsh](http://zsh.sourceforge.net/Doc/Release/Functions.html#Hook-Functions). - -Bashhub Logo - -This project is currently being used in production by [Bashhub](https://github.com/rcaloras/bashhub-client) and [iTerm2](https://github.com/gnachman/iTerm2). Hype! - -## Quick Start -```bash -# Pull down our file from GitHub and write it to our home directory as a hidden file. -curl https://raw.githubusercontent.com/rcaloras/bash-preexec/master/bash-preexec.sh -o ~/.bash-preexec.sh -# Source our file to bring it into our environment -source ~/.bash-preexec.sh -# Define a couple functions. -preexec() { echo "just typed $1"; } -precmd() { echo "printing the prompt"; } -``` - -## Install -You'll want to pull down the file and add it to your bash profile/configuration (i.e ~/.bashrc, ~/.profile, ~/.bash_profile, etc). **It must be the last thing imported in your bash profile.** -```bash -# Pull down our file from GitHub and write it to our home directory as a hidden file. -curl https://raw.githubusercontent.com/rcaloras/bash-preexec/master/bash-preexec.sh -o ~/.bash-preexec.sh -# Source our file at the end of our bash profile (e.g. ~/.bashrc, ~/.profile, or ~/.bash_profile) -echo '[[ -f ~/.bash-preexec.sh ]] && source ~/.bash-preexec.sh' >> ~/.bashrc -``` - -## Usage -Two functions **preexec** and **precmd** can now be defined and they'll be automatically invoked by bash-preexec if they exist. - -* `preexec` Executed just after a command has been read and is about to be executed. The string that the user typed is passed as the first argument. -* `precmd` Executed just before each prompt. Equivalent to PROMPT_COMMAND, but more flexible and resilient. -```bash -source ~/.bash-preexec.sh -preexec() { echo "just typed $1"; } -precmd() { echo "printing the prompt"; } -``` -Should output something like: -``` -elementz@Kashmir:~/git/bash-preexec (master)$ ls -just typed ls -bash-preexec.sh README.md test -printing the prompt -``` -#### Function Arrays -You can also define functions to be invoked by appending them to two different arrays. This is great if you want to have many functions invoked for either hook. Both preexec and precmd functions are added to these by default and don't need to be added manually. -* `$preexec_functions` Array of functions invoked by preexec. -* `$precmd_functions` Array of functions invoked by precmd. - -#### preexec -```bash -# Define some function to use preexec -preexec_hello_world() { echo "You just entered $1"; } -# Add it to the array of functions to be invoked each time. -preexec_functions+=(preexec_hello_world) -``` - -#### precmd -```bash -precmd_hello_world() { echo "This is invoked before the prompt is displayed"; } -precmd_functions+=(precmd_hello_world) -``` - -You can also define multiple functions to be invoked like so. - -```bash -precmd_hello_one() { echo "This is invoked on precmd first"; } -precmd_hello_two() { echo "This is invoked on precmd second"; } -precmd_functions+=(precmd_hello_one) -precmd_functions+=(precmd_hello_two) -``` - -You can check the functions set for each by echoing its contents. - -```bash -echo ${preexec_functions[@]} -echo ${precmd_functions[@]} -``` - -## Subshells -bash-preexec does not support invoking preexec() for subshells by default. It must be enabled by setting -`__bp_enable_subshells`. -```bash -# Enable experimental subshell support -export __bp_enable_subshells="true" -``` -This is disabled by default due to buggy situations related to to `functrace` and Bash's `DEBUG trap`. See [Issue #25](https://github.com/rcaloras/bash-preexec/issues/25) - -## Tests -You can run tests using [Bats](https://github.com/bats-core/bats-core). -```bash -bats test -``` -Should output something like: -``` -elementz@Kashmir:~/git/bash-preexec(master)$ bats test - ✓ No functions defined for preexec should simply return - ✓ precmd should execute a function once - ✓ preexec should execute a function with the last command in our history - ✓ preexec should execute multiple functions in the order added to their arrays - ✓ preecmd should execute multiple functions in the order added to their arrays -``` +[![Build Status](https://travis-ci.org/rcaloras/bash-preexec.svg?branch=master)](https://travis-ci.org/rcaloras/bash-preexec) +[![GitHub version](https://badge.fury.io/gh/rcaloras%2Fbash-preexec.svg)](https://badge.fury.io/gh/rcaloras%2Fbash-preexec) + +Bash-Preexec +============ + +**preexec** and **precmd** hook functions for Bash in the style of Zsh. They aim to emulate the behavior [as described for Zsh](http://zsh.sourceforge.net/Doc/Release/Functions.html#Hook-Functions). + +Bashhub Logo + +This project is currently being used in production by [Bashhub](https://github.com/rcaloras/bashhub-client) and [iTerm2](https://github.com/gnachman/iTerm2). Hype! + +## Quick Start +```bash +# Pull down our file from GitHub and write it to our home directory as a hidden file. +curl https://raw.githubusercontent.com/rcaloras/bash-preexec/master/bash-preexec.sh -o ~/.bash-preexec.sh +# Source our file to bring it into our environment +source ~/.bash-preexec.sh +# Define a couple functions. +preexec() { echo "just typed $1"; } +precmd() { echo "printing the prompt"; } +``` + +## Install +You'll want to pull down the file and add it to your bash profile/configuration (i.e ~/.bashrc, ~/.profile, ~/.bash_profile, etc). **It must be the last thing imported in your bash profile.** +```bash +# Pull down our file from GitHub and write it to our home directory as a hidden file. +curl https://raw.githubusercontent.com/rcaloras/bash-preexec/master/bash-preexec.sh -o ~/.bash-preexec.sh +# Source our file at the end of our bash profile (e.g. ~/.bashrc, ~/.profile, or ~/.bash_profile) +echo '[[ -f ~/.bash-preexec.sh ]] && source ~/.bash-preexec.sh' >> ~/.bashrc +``` + +## Usage +Two functions **preexec** and **precmd** can now be defined and they'll be automatically invoked by bash-preexec if they exist. + +* `preexec` Executed just after a command has been read and is about to be executed. The string that the user typed is passed as the first argument. +* `precmd` Executed just before each prompt. Equivalent to PROMPT_COMMAND, but more flexible and resilient. +```bash +source ~/.bash-preexec.sh +preexec() { echo "just typed $1"; } +precmd() { echo "printing the prompt"; } +``` +Should output something like: +``` +elementz@Kashmir:~/git/bash-preexec (master)$ ls +just typed ls +bash-preexec.sh README.md test +printing the prompt +``` +#### Function Arrays +You can also define functions to be invoked by appending them to two different arrays. This is great if you want to have many functions invoked for either hook. Both preexec and precmd functions are added to these by default and don't need to be added manually. +* `$preexec_functions` Array of functions invoked by preexec. +* `$precmd_functions` Array of functions invoked by precmd. + +#### preexec +```bash +# Define some function to use preexec +preexec_hello_world() { echo "You just entered $1"; } +# Add it to the array of functions to be invoked each time. +preexec_functions+=(preexec_hello_world) +``` + +#### precmd +```bash +precmd_hello_world() { echo "This is invoked before the prompt is displayed"; } +precmd_functions+=(precmd_hello_world) +``` + +You can also define multiple functions to be invoked like so. + +```bash +precmd_hello_one() { echo "This is invoked on precmd first"; } +precmd_hello_two() { echo "This is invoked on precmd second"; } +precmd_functions+=(precmd_hello_one) +precmd_functions+=(precmd_hello_two) +``` + +You can check the functions set for each by echoing its contents. + +```bash +echo ${preexec_functions[@]} +echo ${precmd_functions[@]} +``` + +## Subshells +bash-preexec does not support invoking preexec() for subshells by default. It must be enabled by setting +`__bp_enable_subshells`. +```bash +# Enable experimental subshell support +export __bp_enable_subshells="true" +``` +This is disabled by default due to buggy situations related to to `functrace` and Bash's `DEBUG trap`. See [Issue #25](https://github.com/rcaloras/bash-preexec/issues/25) + +## Tests +You can run tests using [Bats](https://github.com/bats-core/bats-core). +```bash +bats test +``` +Should output something like: +``` +elementz@Kashmir:~/git/bash-preexec(master)$ bats test + ✓ No functions defined for preexec should simply return + ✓ precmd should execute a function once + ✓ preexec should execute a function with the last command in our history + ✓ preexec should execute multiple functions in the order added to their arrays + ✓ preecmd should execute multiple functions in the order added to their arrays +``` diff --git a/vendor/github.com/rcaloras/bash-preexec/bash-preexec.sh b/vendor/github.com/rcaloras/bash-preexec/bash-preexec.sh index 5f1208c3..823c9834 100644 --- a/vendor/github.com/rcaloras/bash-preexec/bash-preexec.sh +++ b/vendor/github.com/rcaloras/bash-preexec/bash-preexec.sh @@ -33,12 +33,14 @@ # either of these after bash-preexec has been installed it will most likely break. # Make sure this is bash that's running and return otherwise. -if [[ -z "${BASH_VERSION:-}" ]]; then +if [[ -z "${BASH_VERSION:-}" ]] + then return 1; fi # Avoid duplicate inclusion -if [[ -n "${bash_preexec_imported:-}" ]]; then +if [[ -n "${bash_preexec_imported:-}" ]] + then return 0 fi bash_preexec_imported="defined" @@ -64,10 +66,11 @@ __bp_install_string=$'__bp_trap_string="$(trap -p DEBUG)"\ntrap - DEBUG\n__bp_in # Fails if any of the given variables are readonly # Reference https://stackoverflow.com/a/4441178 -__bp_require_not_readonly() { +function __bp_require_not_readonly() { local var for var; do - if ! ( unset "$var" 2> /dev/null ); then + if ! ( unset "$var" 2> /dev/null ) + then echo "bash-preexec requires write access to ${var}" >&2 return 1 fi @@ -77,12 +80,13 @@ __bp_require_not_readonly() { # Remove ignorespace and or replace ignoreboth from HISTCONTROL # so we can accurately invoke preexec with a command from our # history even if it starts with a space. -__bp_adjust_histcontrol() { +function __bp_adjust_histcontrol() { local histcontrol histcontrol="${HISTCONTROL:-}" histcontrol="${histcontrol//ignorespace}" # Replace ignoreboth with ignoredups - if [[ "$histcontrol" == *"ignoreboth"* ]]; then + if [[ "$histcontrol" == *"ignoreboth"* ]] + then histcontrol="ignoredups:${histcontrol//ignoreboth}" fi; export HISTCONTROL="$histcontrol" @@ -101,7 +105,7 @@ declare -a preexec_functions # Trims leading and trailing whitespace from $2 and writes it to the variable # name passed as $1 -__bp_trim_whitespace() { +function __bp_trim_whitespace() { local var=${1:?} text=${2:-} text="${text#"${text%%[![:space:]]*}"}" # remove leading whitespace characters text="${text%"${text##*[![:space:]]}"}" # remove trailing whitespace characters @@ -112,7 +116,7 @@ __bp_trim_whitespace() { # Trims whitespace and removes any leading or trailing semicolons from $2 and # writes the resulting string to the variable name passed as $1. Used for # manipulating substrings in PROMPT_COMMAND -__bp_sanitize_string() { +function __bp_sanitize_string() { local var=${1:?} text=${2:-} sanitized __bp_trim_whitespace sanitized "$text" sanitized=${sanitized%;} @@ -124,14 +128,14 @@ __bp_sanitize_string() { # This function is installed as part of the PROMPT_COMMAND; # It sets a variable to indicate that the prompt was just displayed, # to allow the DEBUG trap to know that the next command is likely interactive. -__bp_interactive_mode() { +function __bp_interactive_mode() { __bp_preexec_interactive_mode="on"; } # This function is installed as part of the PROMPT_COMMAND. # It will invoke any functions defined in the precmd_functions array. -__bp_precmd_invoke_cmd() { +function __bp_precmd_invoke_cmd() { # Save the returned value from our last command, and from each process in # its pipeline. Note: this MUST be the first thing done in this function. __bp_last_ret_value="$?" BP_PIPESTATUS=("${PIPESTATUS[@]}") @@ -139,7 +143,8 @@ __bp_precmd_invoke_cmd() { # Don't invoke precmds if we are inside an execution of an "original # prompt command" by another precmd execution loop. This avoids infinite # recursion. - if (( __bp_inside_precmd > 0 )); then + if (( __bp_inside_precmd > 0 )) + then return fi local __bp_inside_precmd=1 @@ -150,7 +155,8 @@ __bp_precmd_invoke_cmd() { # Only execute this function if it actually exists. # Test existence of functions with: declare -[Ff] - if type -t "$precmd_function" 1>/dev/null; then + if type -t "$precmd_function" 1>/dev/null + then __bp_set_ret_value "$__bp_last_ret_value" "$__bp_last_argument_prev_command" # Quote our function invocation to prevent issues with IFS "$precmd_function" @@ -161,11 +167,11 @@ __bp_precmd_invoke_cmd() { # Sets a return value in $?. We may want to get access to the $? variable in our # precmd functions. This is available for instance in zsh. We can simulate it in bash # by setting the value here. -__bp_set_ret_value() { +function __bp_set_ret_value() { return ${1:-} } -__bp_in_prompt_command() { +function __bp_in_prompt_command() { local prompt_command_array IFS=$'\n;' read -rd '' -a prompt_command_array <<< "${PROMPT_COMMAND:-}" @@ -176,7 +182,8 @@ __bp_in_prompt_command() { local command trimmed_command for command in "${prompt_command_array[@]:-}"; do __bp_trim_whitespace trimmed_command "$command" - if [[ "$trimmed_command" == "$trimmed_arg" ]]; then + if [[ "$trimmed_command" == "$trimmed_arg" ]] + then return 0 fi done @@ -188,13 +195,14 @@ __bp_in_prompt_command() { # interactive prompt display. Its purpose is to inspect the current # environment to attempt to detect if the current command is being invoked # interactively, and invoke 'preexec' if so. -__bp_preexec_invoke_exec() { +function __bp_preexec_invoke_exec() { # Save the contents of $_ so that it can be restored later on. # https://stackoverflow.com/questions/40944532/bash-preserve-in-a-debug-trap#40944702 __bp_last_argument_prev_command="${1:-}" # Don't invoke preexecs if we are inside of another preexec. - if (( __bp_inside_preexec > 0 )); then + if (( __bp_inside_preexec > 0 )) + then return fi local __bp_inside_preexec=1 @@ -202,16 +210,19 @@ __bp_preexec_invoke_exec() { # Checks if the file descriptor is not standard out (i.e. '1') # __bp_delay_install checks if we're in test. Needed for bats to run. # Prevents preexec from being invoked for functions in PS1 - if [[ ! -t 1 && -z "${__bp_delay_install:-}" ]]; then + if [[ ! -t 1 && -z "${__bp_delay_install:-}" ]] + then return fi - if [[ -n "${COMP_LINE:-}" ]]; then + if [[ -n "${COMP_LINE:-}" ]] + then # We're in the middle of a completer. This obviously can't be # an interactively issued command. return fi - if [[ -z "${__bp_preexec_interactive_mode:-}" ]]; then + if [[ -z "${__bp_preexec_interactive_mode:-}" ]] + then # We're doing something related to displaying the prompt. Let the # prompt set the title instead of me. return @@ -221,12 +232,14 @@ __bp_preexec_invoke_exec() { # In other words, if you have a subshell like # (sleep 1; sleep 2) # You want to see the 'sleep 2' as a set_command_title as well. - if [[ 0 -eq "${BASH_SUBSHELL:-}" ]]; then + if [[ 0 -eq "${BASH_SUBSHELL:-}" ]] + then __bp_preexec_interactive_mode="" fi fi - if __bp_in_prompt_command "${BASH_COMMAND:-}"; then + if __bp_in_prompt_command "${BASH_COMMAND:-}" + then # If we're executing something inside our prompt_command then we don't # want to call preexec. Bash prior to 3.1 can't detect this at all :/ __bp_preexec_interactive_mode="" @@ -240,7 +253,8 @@ __bp_preexec_invoke_exec() { ) # Sanity check to make sure we have something to invoke our function with. - if [[ -z "$this_command" ]]; then + if [[ -z "$this_command" ]] + then return fi @@ -252,12 +266,14 @@ __bp_preexec_invoke_exec() { # Only execute each function if it actually exists. # Test existence of function with: declare -[fF] - if type -t "$preexec_function" 1>/dev/null; then + if type -t "$preexec_function" 1>/dev/null + then __bp_set_ret_value ${__bp_last_ret_value:-} # Quote our function invocation to prevent issues with IFS "$preexec_function" "$this_command" preexec_function_ret_value="$?" - if [[ "$preexec_function_ret_value" != 0 ]]; then + if [[ "$preexec_function_ret_value" != 0 ]] + then preexec_ret_value="$preexec_function_ret_value" fi fi @@ -272,9 +288,10 @@ __bp_preexec_invoke_exec() { __bp_set_ret_value "$preexec_ret_value" "$__bp_last_argument_prev_command" } -__bp_install() { +function __bp_install() { # Exit if we already have this installed. - if [[ "${PROMPT_COMMAND:-}" == *"__bp_precmd_invoke_cmd"* ]]; then + if [[ "${PROMPT_COMMAND:-}" == *"__bp_precmd_invoke_cmd"* ]] + then return 1; fi @@ -283,7 +300,8 @@ __bp_install() { # Preserve any prior DEBUG trap as a preexec function local prior_trap=$(sed "s/[^']*'\(.*\)'[^']*/\1/" <<<"${__bp_trap_string:-}") unset __bp_trap_string - if [[ -n "$prior_trap" ]]; then + if [[ -n "$prior_trap" ]] + then eval '__bp_original_debug_trap() { '"$prior_trap"' }' @@ -297,7 +315,8 @@ __bp_install() { # backgrounded subshell commands (e.g. (pwd)& ). Believe this is a bug in Bash. # # Disabling this by default. It can be enabled by setting this variable. - if [[ -n "${__bp_enable_subshells:-}" ]]; then + if [[ -n "${__bp_enable_subshells:-}" ]] + then # Set so debug trap will work be invoked in subshells. set -o functrace > /dev/null 2>&1 @@ -314,7 +333,8 @@ __bp_install() { # Install our hooks in PROMPT_COMMAND to allow our trap to know when we've # actually entered something. PROMPT_COMMAND=$'__bp_precmd_invoke_cmd\n' - if [[ -n "$existing_prompt_command" ]]; then + if [[ -n "$existing_prompt_command" ]] + then PROMPT_COMMAND+=${existing_prompt_command}$'\n' fi; PROMPT_COMMAND+='__bp_interactive_mode' @@ -332,20 +352,22 @@ __bp_install() { # Sets an installation string as part of our PROMPT_COMMAND to install # after our session has started. This allows bash-preexec to be included # at any point in our bash profile. -__bp_install_after_session_init() { +function __bp_install_after_session_init() { # bash-preexec needs to modify these variables in order to work correctly # if it can't, just stop the installation __bp_require_not_readonly PROMPT_COMMAND HISTCONTROL HISTTIMEFORMAT || return local sanitized_prompt_command __bp_sanitize_string sanitized_prompt_command "${PROMPT_COMMAND:-}" - if [[ -n "$sanitized_prompt_command" ]]; then + if [[ -n "$sanitized_prompt_command" ]] + then PROMPT_COMMAND=${sanitized_prompt_command}$'\n' fi; PROMPT_COMMAND+=${__bp_install_string} } # Run our install so long as we're not delaying it. -if [[ -z "${__bp_delay_install:-}" ]]; then +if [[ -z "${__bp_delay_install:-}" ]] + then __bp_install_after_session_init fi; diff --git a/vendor/github.com/rcaloras/bash-preexec/test/README.md b/vendor/github.com/rcaloras/bash-preexec/test/README.md index fd6613c0..85fc4273 100644 --- a/vendor/github.com/rcaloras/bash-preexec/test/README.md +++ b/vendor/github.com/rcaloras/bash-preexec/test/README.md @@ -1,22 +1,22 @@ -Testing `bash-preexec` -====================== - -**Note on test conditions** - -When writing test conditions, use `[ ... ]` instead of `[[ ... ]]` since the -former are supported by Bats on Bash versions before 4.1. In particular, macOS -uses Bash 3.2, and `[[ ... ]]` tests always pass on macOS. - -In some cases, you may want to use a feature unique to `[[ ... ]]` such as -pattern matching (`[[ $name = a* ]]`) or regular expressions (`[[ $(date) =~ -^Fri\ ...\ 13 ]]`). In those cases, use the following pattern to replace “bare” -`[[ ... ]]`. - -``` -[[ ... ]] || return 1 -``` - -References: -* [Differences between `[` and `[[`](http://mywiki.wooledge.org/BashFAQ/031) -* [Problems with `[[` in Bats](https://github.com/sstephenson/bats/issues/49) -* [Using `|| return 1` instead of `|| false`](https://github.com/bats-core/bats-core/commit/e5695a673faad4d4d33446ed5c99d70dbfa6d8be) +Testing `bash-preexec` +====================== + +**Note on test conditions** + +When writing test conditions, use `[ ... ]` instead of `[[ ... ]]` since the +former are supported by Bats on Bash versions before 4.1. In particular, macOS +uses Bash 3.2, and `[[ ... ]]` tests always pass on macOS. + +In some cases, you may want to use a feature unique to `[[ ... ]]` such as +pattern matching (`[[ $name = a* ]]`) or regular expressions (`[[ $(date) =~ +^Fri\ ...\ 13 ]]`). In those cases, use the following pattern to replace “bare” +`[[ ... ]]`. + +``` +[[ ... ]] || return 1 +``` + +References: +* [Differences between `[` and `[[`](http://mywiki.wooledge.org/BashFAQ/031) +* [Problems with `[[` in Bats](https://github.com/sstephenson/bats/issues/49) +* [Using `|| return 1` instead of `|| false`](https://github.com/bats-core/bats-core/commit/e5695a673faad4d4d33446ed5c99d70dbfa6d8be) diff --git a/vendor/github.com/rcaloras/bash-preexec/test/bash-preexec.bats b/vendor/github.com/rcaloras/bash-preexec/test/bash-preexec.bats index 84a30cae..b39359d6 100644 --- a/vendor/github.com/rcaloras/bash-preexec/test/bash-preexec.bats +++ b/vendor/github.com/rcaloras/bash-preexec/test/bash-preexec.bats @@ -1,364 +1,364 @@ -#!/usr/bin/env bats - -setup() { - PROMPT_COMMAND='' # in case the invoking shell has set this - history -s fake command # preexec requires there be some history - set -o nounset # in case the user has this set - __bp_delay_install="true" - source "${BATS_TEST_DIRNAME}/../bash-preexec.sh" -} - -bp_install() { - __bp_install_after_session_init - eval "$PROMPT_COMMAND" -} - -test_echo() { - echo "test echo" -} - -test_preexec_echo() { - printf "%s\n" "$1" -} - -@test "__bp_install_after_session_init should exit with 1 if we're not using bash" { - unset BASH_VERSION - run '__bp_install_after_session_init' - [ $status -eq 1 ] - [ -z "$output" ] -} - -@test "__bp_install should exit if it's already installed" { - bp_install - - run '__bp_install' - [ $status -eq 1 ] - [ -z "$output" ] -} - -@test "__bp_install should remove trap logic and itself from PROMPT_COMMAND" { - __bp_install_after_session_init - - [[ "$PROMPT_COMMAND" == *"trap - DEBUG"* ]] || return 1 - [[ "$PROMPT_COMMAND" == *"__bp_install"* ]] || return 1 - - eval "$PROMPT_COMMAND" - - [[ "$PROMPT_COMMAND" != *"trap DEBUG"* ]] || return 1 - [[ "$PROMPT_COMMAND" != *"__bp_install"* ]] || return 1 -} - -@test "__bp_install should preserve an existing DEBUG trap" { - trap_invoked_count=0 - foo() { (( trap_invoked_count += 1 )); } - - # note setting this causes BATS to mis-report the failure line when this test fails - trap foo DEBUG - [ "$(trap -p DEBUG | cut -d' ' -f3)" == "'foo'" ] - - bp_install - trap_count_snapshot=$trap_invoked_count - - [ "$(trap -p DEBUG | cut -d' ' -f3)" == "'__bp_preexec_invoke_exec" ] - [[ "${preexec_functions[*]}" == *"__bp_original_debug_trap"* ]] || return 1 - - __bp_interactive_mode # triggers the DEBUG trap - - # ensure the trap count is still being incremented after the trap's been overwritten - (( trap_count_snapshot < trap_invoked_count )) -} - -@test "__bp_sanitize_string should remove semicolons and trim space" { - - __bp_sanitize_string output " true1; "$'\n' - [ "$output" == "true1" ] - - __bp_sanitize_string output " ; true2; " - [ "$output" == "true2" ] - - __bp_sanitize_string output $'\n'" ; true3; " - [ "$output" == "true3" ] - -} - -@test "Appending to PROMPT_COMMAND should work after bp_install" { - bp_install - - PROMPT_COMMAND="$PROMPT_COMMAND; true" - eval "$PROMPT_COMMAND" -} - -@test "Appending or prepending to PROMPT_COMMAND should work after bp_install_after_session_init" { - __bp_install_after_session_init - nl=$'\n' - PROMPT_COMMAND="$PROMPT_COMMAND; true" - PROMPT_COMMAND="$PROMPT_COMMAND $nl true" - PROMPT_COMMAND="$PROMPT_COMMAND; true" - PROMPT_COMMAND="true; $PROMPT_COMMAND" - PROMPT_COMMAND="true; $PROMPT_COMMAND" - PROMPT_COMMAND="true; $PROMPT_COMMAND" - PROMPT_COMMAND="true $nl $PROMPT_COMMAND" - eval "$PROMPT_COMMAND" -} - -# Case where a user is appending or prepending to PROMPT_COMMAND. -# This can happen after 'source bash-preexec.sh' e.g. -# source bash-preexec.sh; PROMPT_COMMAND="$PROMPT_COMMAND; other_prompt_command_hook" -@test "Adding to PROMPT_COMMAND before and after initiating install" { - PROMPT_COMMAND="echo before" - PROMPT_COMMAND="$PROMPT_COMMAND; echo before2" - __bp_install_after_session_init - PROMPT_COMMAND="$PROMPT_COMMAND"$'\n echo after' - PROMPT_COMMAND="echo after2; $PROMPT_COMMAND;" - - eval "$PROMPT_COMMAND" - - expected_result=$'__bp_precmd_invoke_cmd\necho after2; echo before; echo before2\n echo after\n__bp_interactive_mode' - [ "$PROMPT_COMMAND" == "$expected_result" ] -} - -@test "Adding to PROMPT_COMMAND after with semicolon" { - PROMPT_COMMAND="echo before" - __bp_install_after_session_init - PROMPT_COMMAND="$PROMPT_COMMAND; echo after" - - eval "$PROMPT_COMMAND" - - expected_result=$'__bp_precmd_invoke_cmd\necho before\n echo after\n__bp_interactive_mode' - [ "$PROMPT_COMMAND" == "$expected_result" ] -} - -@test "during install PROMPT_COMMAND and precmd functions should be executed each once" { - PROMPT_COMMAND="echo before" - PROMPT_COMMAND="$PROMPT_COMMAND; echo before2" - __bp_install_after_session_init - PROMPT_COMMAND="$PROMPT_COMMAND; echo after" - PROMPT_COMMAND="echo after2; $PROMPT_COMMAND;" - - precmd() { echo "inside precmd"; } - run eval "$PROMPT_COMMAND" - [ "${lines[0]}" == "after2" ] - [ "${lines[1]}" == "before" ] - [ "${lines[2]}" == "before2" ] - [ "${lines[3]}" == "inside precmd" ] - [ "${lines[4]}" == "after" ] - [ "${#lines[@]}" == '5' ] -} - -@test "No functions defined for preexec should simply return" { - __bp_interactive_mode - - run '__bp_preexec_invoke_exec' 'true' - [ $status -eq 0 ] - [ -z "$output" ] -} - -@test "precmd should execute a function once" { - precmd_functions+=(test_echo) - run '__bp_precmd_invoke_cmd' - [ $status -eq 0 ] - [ "$output" == "test echo" ] -} - -@test "precmd should set \$? to be the previous exit code" { - echo_exit_code() { - echo "$?" - } - return_exit_code() { - return $1 - } - # Helper function is necessary because Bats' run doesn't preserve $? - set_exit_code_and_run_precmd() { - return_exit_code 251 - __bp_precmd_invoke_cmd - } - - precmd_functions+=(echo_exit_code) - run 'set_exit_code_and_run_precmd' - [ $status -eq 0 ] - [ "$output" == "251" ] -} - -@test "precmd should set \$BP_PIPESTATUS to the previous \$PIPESTATUS" { - echo_pipestatus() { - echo "${BP_PIPESTATUS[*]}" - } - # Helper function is necessary because Bats' run doesn't preserve $PIPESTATUS - set_pipestatus_and_run_precmd() { - false | true - __bp_precmd_invoke_cmd - } - - precmd_functions+=(echo_pipestatus) - run 'set_pipestatus_and_run_precmd' - [ $status -eq 0 ] - [ "$output" == "1 0" ] -} - -@test "precmd should set \$_ to be the previous last arg" { - echo_last_arg() { - echo "$_" - } - precmd_functions+=(echo_last_arg) - - bats_trap=$(trap -p DEBUG) - trap DEBUG # remove the Bats stack-trace trap so $_ doesn't get overwritten - : "last-arg" - __bp_preexec_invoke_exec "$_" - eval "$bats_trap" # Restore trap - run '__bp_precmd_invoke_cmd' - [ $status -eq 0 ] - [ "$output" == "last-arg" ] -} - -@test "preexec should execute a function with the last command in our history" { - preexec_functions+=(test_preexec_echo) - __bp_interactive_mode - git_command="git commit -a -m 'committing some stuff'" - history -s $git_command - - run '__bp_preexec_invoke_exec' - [ $status -eq 0 ] - [ "$output" == "$git_command" ] -} - -@test "preexec should execute multiple functions in the order added to their arrays" { - fun_1() { echo "$1 one"; } - fun_2() { echo "$1 two"; } - preexec_functions+=(fun_1) - preexec_functions+=(fun_2) - __bp_interactive_mode - - run '__bp_preexec_invoke_exec' - [ $status -eq 0 ] - [ "${#lines[@]}" == '2' ] - [ "${lines[0]}" == "fake command one" ] - [ "${lines[1]}" == "fake command two" ] -} - -@test "preecmd should execute multiple functions in the order added to their arrays" { - fun_1() { echo "one"; } - fun_2() { echo "two"; } - precmd_functions+=(fun_1) - precmd_functions+=(fun_2) - - run '__bp_precmd_invoke_cmd' - [ $status -eq 0 ] - [ "${#lines[@]}" == '2' ] - [ "${lines[0]}" == "one" ] - [ "${lines[1]}" == "two" ] -} - -@test "preexec should execute a function with IFS defined to local scope" { - IFS=_ - name_with_underscores_1() { parts=(1_2); echo $parts; } - preexec_functions+=(name_with_underscores_1) - - __bp_interactive_mode - run '__bp_preexec_invoke_exec' - [ $status -eq 0 ] - [ "$output" == "1 2" ] -} - -@test "precmd should execute a function with IFS defined to local scope" { - IFS=_ - name_with_underscores_2() { parts=(2_2); echo $parts; } - precmd_functions+=(name_with_underscores_2) - run '__bp_precmd_invoke_cmd' - [ $status -eq 0 ] - [ "$output" == "2 2" ] -} - -@test "preexec should set \$? to be the exit code of preexec_functions" { - return_nonzero() { - return 1 - } - preexec_functions+=(return_nonzero) - - __bp_interactive_mode - - run '__bp_preexec_invoke_exec' - [ $status -eq 1 ] -} - -@test "in_prompt_command should detect if a command is part of PROMPT_COMMAND" { - - PROMPT_COMMAND=$'precmd_invoke_cmd\n something; echo yo\n __bp_interactive_mode' - run '__bp_in_prompt_command' "something" - [ $status -eq 0 ] - - run '__bp_in_prompt_command' "something_else" - [ $status -eq 1 ] - - # Should trim commands and arguments here. - PROMPT_COMMAND=" precmd_invoke_cmd ; something ; some_stuff_here;" - run '__bp_in_prompt_command' " precmd_invoke_cmd " - [ $status -eq 0 ] - - PROMPT_COMMAND=" precmd_invoke_cmd ; something ; some_stuff_here;" - run '__bp_in_prompt_command' " not_found" - [ $status -eq 1 ] - -} - -@test "__bp_adjust_histcontrol should remove ignorespace and ignoreboth" { - - # Should remove ignorespace - HISTCONTROL="ignorespace:ignoredups:*" - __bp_adjust_histcontrol - [ "$HISTCONTROL" == ":ignoredups:*" ] - - # Should remove ignoreboth and replace it with ignoredups - HISTCONTROL="ignoreboth" - __bp_adjust_histcontrol - [ "$HISTCONTROL" == "ignoredups:" ] - - # Handle a few inputs - HISTCONTROL="ignoreboth:ignorespace:some_thing_else" - __bp_adjust_histcontrol - echo "$HISTCONTROL" - [ "$HISTCONTROL" == "ignoredups:::some_thing_else" ] - -} - -@test "preexec should respect HISTTIMEFORMAT" { - preexec_functions+=(test_preexec_echo) - __bp_interactive_mode - git_command="git commit -a -m 'committing some stuff'" - HISTTIMEFORMAT='%F %T ' - history -s $git_command - - run '__bp_preexec_invoke_exec' - [ $status -eq 0 ] - [ "$output" == "$git_command" ] -} - -@test "preexec should not strip whitespace from commands" { - preexec_functions+=(test_preexec_echo) - __bp_interactive_mode - history -s " this command has whitespace " - - run '__bp_preexec_invoke_exec' - [ $status -eq 0 ] - [ "$output" == " this command has whitespace " ] -} - -@test "preexec should preserve multi-line strings in commands" { - preexec_functions+=(test_preexec_echo) - __bp_interactive_mode - history -s "this 'command contains -a multiline string'" - run '__bp_preexec_invoke_exec' - [ $status -eq 0 ] - [ "$output" == "this 'command contains -a multiline string'" ] -} - -@test "preexec should work on options to 'echo' commands" { - preexec_functions+=(test_preexec_echo) - __bp_interactive_mode - history -s -- '-n' - run '__bp_preexec_invoke_exec' - [ $status -eq 0 ] - [ "$output" == '-n' ] -} +#!/usr/bin/env bats + +setup() { + PROMPT_COMMAND='' # in case the invoking shell has set this + history -s fake command # preexec requires there be some history + set -o nounset # in case the user has this set + __bp_delay_install="true" + source "${BATS_TEST_DIRNAME}/../bash-preexec.sh" +} + +bp_install() { + __bp_install_after_session_init + eval "$PROMPT_COMMAND" +} + +test_echo() { + echo "test echo" +} + +test_preexec_echo() { + printf "%s\n" "${1}" +} + +@test "__bp_install_after_session_init should exit with 1 if we're not using bash" { + unset BASH_VERSION + run '__bp_install_after_session_init' + [ $status -eq 1 ] + [ -z "$output" ] +} + +@test "__bp_install should exit if it's already installed" { + bp_install + + run '__bp_install' + [ $status -eq 1 ] + [ -z "$output" ] +} + +@test "__bp_install should remove trap logic and itself from PROMPT_COMMAND" { + __bp_install_after_session_init + + [[ "$PROMPT_COMMAND" == *"trap - DEBUG"* ]] || return 1 + [[ "$PROMPT_COMMAND" == *"__bp_install"* ]] || return 1 + + eval "$PROMPT_COMMAND" + + [[ "$PROMPT_COMMAND" != *"trap DEBUG"* ]] || return 1 + [[ "$PROMPT_COMMAND" != *"__bp_install"* ]] || return 1 +} + +@test "__bp_install should preserve an existing DEBUG trap" { + trap_invoked_count=0 + foo() { (( trap_invoked_count += 1 )); } + + # note setting this causes BATS to mis-report the failure line when this test fails + trap foo DEBUG + [ "$(trap -p DEBUG | cut -d' ' -f3)" == "'foo'" ] + + bp_install + trap_count_snapshot=$trap_invoked_count + + [ "$(trap -p DEBUG | cut -d' ' -f3)" == "'__bp_preexec_invoke_exec" ] + [[ "${preexec_functions[*]}" == *"__bp_original_debug_trap"* ]] || return 1 + + __bp_interactive_mode # triggers the DEBUG trap + + # ensure the trap count is still being incremented after the trap's been overwritten + (( trap_count_snapshot < trap_invoked_count )) +} + +@test "__bp_sanitize_string should remove semicolons and trim space" { + + __bp_sanitize_string output " true1; "$'\n' + [ "$output" == "true1" ] + + __bp_sanitize_string output " ; true2; " + [ "$output" == "true2" ] + + __bp_sanitize_string output $'\n'" ; true3; " + [ "$output" == "true3" ] + +} + +@test "Appending to PROMPT_COMMAND should work after bp_install" { + bp_install + + PROMPT_COMMAND="$PROMPT_COMMAND; true" + eval "$PROMPT_COMMAND" +} + +@test "Appending or prepending to PROMPT_COMMAND should work after bp_install_after_session_init" { + __bp_install_after_session_init + nl=$'\n' + PROMPT_COMMAND="$PROMPT_COMMAND; true" + PROMPT_COMMAND="$PROMPT_COMMAND $nl true" + PROMPT_COMMAND="$PROMPT_COMMAND; true" + PROMPT_COMMAND="true; $PROMPT_COMMAND" + PROMPT_COMMAND="true; $PROMPT_COMMAND" + PROMPT_COMMAND="true; $PROMPT_COMMAND" + PROMPT_COMMAND="true $nl $PROMPT_COMMAND" + eval "$PROMPT_COMMAND" +} + +# Case where a user is appending or prepending to PROMPT_COMMAND. +# This can happen after 'source bash-preexec.sh' e.g. +# source bash-preexec.sh; PROMPT_COMMAND="$PROMPT_COMMAND; other_prompt_command_hook" +@test "Adding to PROMPT_COMMAND before and after initiating install" { + PROMPT_COMMAND="echo before" + PROMPT_COMMAND="$PROMPT_COMMAND; echo before2" + __bp_install_after_session_init + PROMPT_COMMAND="$PROMPT_COMMAND"$'\n echo after' + PROMPT_COMMAND="echo after2; $PROMPT_COMMAND;" + + eval "$PROMPT_COMMAND" + + expected_result=$'__bp_precmd_invoke_cmd\necho after2; echo before; echo before2\n echo after\n__bp_interactive_mode' + [ "$PROMPT_COMMAND" == "$expected_result" ] +} + +@test "Adding to PROMPT_COMMAND after with semicolon" { + PROMPT_COMMAND="echo before" + __bp_install_after_session_init + PROMPT_COMMAND="$PROMPT_COMMAND; echo after" + + eval "$PROMPT_COMMAND" + + expected_result=$'__bp_precmd_invoke_cmd\necho before\n echo after\n__bp_interactive_mode' + [ "$PROMPT_COMMAND" == "$expected_result" ] +} + +@test "during install PROMPT_COMMAND and precmd functions should be executed each once" { + PROMPT_COMMAND="echo before" + PROMPT_COMMAND="$PROMPT_COMMAND; echo before2" + __bp_install_after_session_init + PROMPT_COMMAND="$PROMPT_COMMAND; echo after" + PROMPT_COMMAND="echo after2; $PROMPT_COMMAND;" + + precmd() { echo "inside precmd"; } + run eval "$PROMPT_COMMAND" + [ "${lines[0]}" == "after2" ] + [ "${lines[1]}" == "before" ] + [ "${lines[2]}" == "before2" ] + [ "${lines[3]}" == "inside precmd" ] + [ "${lines[4]}" == "after" ] + [ "${#lines[@]}" == '5' ] +} + +@test "No functions defined for preexec should simply return" { + __bp_interactive_mode + + run '__bp_preexec_invoke_exec' 'true' + [ $status -eq 0 ] + [ -z "$output" ] +} + +@test "precmd should execute a function once" { + precmd_functions+=(test_echo) + run '__bp_precmd_invoke_cmd' + [ $status -eq 0 ] + [ "$output" == "test echo" ] +} + +@test "precmd should set \$? to be the previous exit code" { + echo_exit_code() { + echo "$?" + } + return_exit_code() { + return $1 + } + # Helper function is necessary because Bats' run doesn't preserve $? + set_exit_code_and_run_precmd() { + return_exit_code 251 + __bp_precmd_invoke_cmd + } + + precmd_functions+=(echo_exit_code) + run 'set_exit_code_and_run_precmd' + [ $status -eq 0 ] + [ "$output" == "251" ] +} + +@test "precmd should set \$BP_PIPESTATUS to the previous \$PIPESTATUS" { + echo_pipestatus() { + echo "${BP_PIPESTATUS[*]}" + } + # Helper function is necessary because Bats' run doesn't preserve $PIPESTATUS + set_pipestatus_and_run_precmd() { + false | true + __bp_precmd_invoke_cmd + } + + precmd_functions+=(echo_pipestatus) + run 'set_pipestatus_and_run_precmd' + [ $status -eq 0 ] + [ "$output" == "1 0" ] +} + +@test "precmd should set \$_ to be the previous last arg" { + echo_last_arg() { + echo "$_" + } + precmd_functions+=(echo_last_arg) + + bats_trap=$(trap -p DEBUG) + trap DEBUG # remove the Bats stack-trace trap so $_ doesn't get overwritten + : "last-arg" + __bp_preexec_invoke_exec "$_" + eval "$bats_trap" # Restore trap + run '__bp_precmd_invoke_cmd' + [ $status -eq 0 ] + [ "$output" == "last-arg" ] +} + +@test "preexec should execute a function with the last command in our history" { + preexec_functions+=(test_preexec_echo) + __bp_interactive_mode + git_command="git commit -a -m 'committing some stuff'" + history -s $git_command + + run '__bp_preexec_invoke_exec' + [ $status -eq 0 ] + [ "$output" == "$git_command" ] +} + +@test "preexec should execute multiple functions in the order added to their arrays" { + fun_1() { echo "$1 one"; } + fun_2() { echo "$1 two"; } + preexec_functions+=(fun_1) + preexec_functions+=(fun_2) + __bp_interactive_mode + + run '__bp_preexec_invoke_exec' + [ $status -eq 0 ] + [ "${#lines[@]}" == '2' ] + [ "${lines[0]}" == "fake command one" ] + [ "${lines[1]}" == "fake command two" ] +} + +@test "preecmd should execute multiple functions in the order added to their arrays" { + fun_1() { echo "one"; } + fun_2() { echo "two"; } + precmd_functions+=(fun_1) + precmd_functions+=(fun_2) + + run '__bp_precmd_invoke_cmd' + [ $status -eq 0 ] + [ "${#lines[@]}" == '2' ] + [ "${lines[0]}" == "one" ] + [ "${lines[1]}" == "two" ] +} + +@test "preexec should execute a function with IFS defined to local scope" { + IFS=_ + name_with_underscores_1() { parts=(1_2); echo $parts; } + preexec_functions+=(name_with_underscores_1) + + __bp_interactive_mode + run '__bp_preexec_invoke_exec' + [ $status -eq 0 ] + [ "$output" == "1 2" ] +} + +@test "precmd should execute a function with IFS defined to local scope" { + IFS=_ + name_with_underscores_2() { parts=(2_2); echo $parts; } + precmd_functions+=(name_with_underscores_2) + run '__bp_precmd_invoke_cmd' + [ $status -eq 0 ] + [ "$output" == "2 2" ] +} + +@test "preexec should set \$? to be the exit code of preexec_functions" { + return_nonzero() { + return 1 + } + preexec_functions+=(return_nonzero) + + __bp_interactive_mode + + run '__bp_preexec_invoke_exec' + [ $status -eq 1 ] +} + +@test "in_prompt_command should detect if a command is part of PROMPT_COMMAND" { + + PROMPT_COMMAND=$'precmd_invoke_cmd\n something; echo yo\n __bp_interactive_mode' + run '__bp_in_prompt_command' "something" + [ $status -eq 0 ] + + run '__bp_in_prompt_command' "something_else" + [ $status -eq 1 ] + + # Should trim commands and arguments here. + PROMPT_COMMAND=" precmd_invoke_cmd ; something ; some_stuff_here;" + run '__bp_in_prompt_command' " precmd_invoke_cmd " + [ $status -eq 0 ] + + PROMPT_COMMAND=" precmd_invoke_cmd ; something ; some_stuff_here;" + run '__bp_in_prompt_command' " not_found" + [ $status -eq 1 ] + +} + +@test "__bp_adjust_histcontrol should remove ignorespace and ignoreboth" { + + # Should remove ignorespace + HISTCONTROL="ignorespace:ignoredups:*" + __bp_adjust_histcontrol + [ "$HISTCONTROL" == ":ignoredups:*" ] + + # Should remove ignoreboth and replace it with ignoredups + HISTCONTROL="ignoreboth" + __bp_adjust_histcontrol + [ "$HISTCONTROL" == "ignoredups:" ] + + # Handle a few inputs + HISTCONTROL="ignoreboth:ignorespace:some_thing_else" + __bp_adjust_histcontrol + echo "$HISTCONTROL" + [ "$HISTCONTROL" == "ignoredups:::some_thing_else" ] + +} + +@test "preexec should respect HISTTIMEFORMAT" { + preexec_functions+=(test_preexec_echo) + __bp_interactive_mode + git_command="git commit -a -m 'committing some stuff'" + HISTTIMEFORMAT='%F %T ' + history -s $git_command + + run '__bp_preexec_invoke_exec' + [ $status -eq 0 ] + [ "$output" == "$git_command" ] +} + +@test "preexec should not strip whitespace from commands" { + preexec_functions+=(test_preexec_echo) + __bp_interactive_mode + history -s " this command has whitespace " + + run '__bp_preexec_invoke_exec' + [ $status -eq 0 ] + [ "$output" == " this command has whitespace " ] +} + +@test "preexec should preserve multi-line strings in commands" { + preexec_functions+=(test_preexec_echo) + __bp_interactive_mode + history -s "this 'command contains +a multiline string'" + run '__bp_preexec_invoke_exec' + [ $status -eq 0 ] + [ "$output" == "this 'command contains +a multiline string'" ] +} + +@test "preexec should work on options to 'echo' commands" { + preexec_functions+=(test_preexec_echo) + __bp_interactive_mode + history -s -- '-n' + run '__bp_preexec_invoke_exec' + [ $status -eq 0 ] + [ "$output" == '-n' ] +} diff --git a/vendor/github.com/rcaloras/bash-preexec/test/include-test.bats b/vendor/github.com/rcaloras/bash-preexec/test/include-test.bats index bd1e3b5b..f07026ea 100644 --- a/vendor/github.com/rcaloras/bash-preexec/test/include-test.bats +++ b/vendor/github.com/rcaloras/bash-preexec/test/include-test.bats @@ -1,20 +1,20 @@ -#!/usr/bin/env bats - -@test "should not import if it's already defined" { - __bp_imported="defined" - source "${BATS_TEST_DIRNAME}/../bash-preexec.sh" - [ -z $(type -t __bp_preexec_and_precmd_install) ] -} - -@test "should import if not defined" { - unset __bp_imported - source "${BATS_TEST_DIRNAME}/../bash-preexec.sh" - [ -n $(type -t __bp_install) ] -} - -@test "bp should stop installation if HISTTIMEFORMAT is readonly" { - readonly HISTTIMEFORMAT - run source "${BATS_TEST_DIRNAME}/../bash-preexec.sh" - [ $status -ne 0 ] - [[ "$output" =~ "HISTTIMEFORMAT" ]] || return 1 -} +#!/usr/bin/env bats + +@test "should not import if it's already defined" { + __bp_imported="defined" + source "${BATS_TEST_DIRNAME}/../bash-preexec.sh" + [ -z $(type -t __bp_preexec_and_precmd_install) ] +} + +@test "should import if not defined" { + unset __bp_imported + source "${BATS_TEST_DIRNAME}/../bash-preexec.sh" + [ -n $(type -t __bp_install) ] +} + +@test "bp should stop installation if HISTTIMEFORMAT is readonly" { + readonly HISTTIMEFORMAT + run source "${BATS_TEST_DIRNAME}/../bash-preexec.sh" + [ $status -ne 0 ] + [[ "$output" =~ "HISTTIMEFORMAT" ]] || return 1 +} diff --git a/vendor/github.com/rparree/jboss-bash-completion/LICENSE b/vendor/github.com/rparree/jboss-bash-completion/LICENSE index 9216224c..bf0d071f 100644 --- a/vendor/github.com/rparree/jboss-bash-completion/LICENSE +++ b/vendor/github.com/rparree/jboss-bash-completion/LICENSE @@ -1,21 +1,21 @@ -MIT License - -Copyright (c) 2020 Raphael Parree - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. +MIT License + +Copyright (c) 2020 Raphael Parree + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/vendor/github.com/rparree/jboss-bash-completion/README.md b/vendor/github.com/rparree/jboss-bash-completion/README.md index 2c1b8851..0c100d34 100644 --- a/vendor/github.com/rparree/jboss-bash-completion/README.md +++ b/vendor/github.com/rparree/jboss-bash-completion/README.md @@ -1,37 +1,37 @@ -jboss-bash-completion -===================== - -JBoss Bash Completion for JBoss 5 and 7 (EAP 6) - - - -Overview --------- - -Completion for the `run.sh` (JBoss5) and `standalone.sh`/`domain.sh` - -Some of the options available in jboss7: - - -* `--admin-only` `-h` `-help` `-version` `-V` `-v` -* `-Djboss.home.dir` -* `--server-config` (options the xml files in the configuration directory relative to -Djboss.server.base.dir) -* `-b` `-bmanagement` `-bunsecure` `-bpublic` `-Djboss.domain.master.address` `-Djboss.bind.address.*` (options: your local IP addresses and 0.0.0.0) -* `-Djboss.socket.binding.port-offset` (options: 100 200 300 400 10000 20000 30000 40000) -* `-u` (options 239.255.0.1 239.255.0.2 239.255.0.3) -* `-P` -Djboss.node.name - - -Install -------- - -Make sure you have installed bash_completion 1.3 (or higher): - -Debian/Ubuntu: `apt-get install bash-completion` -RHEL/CentOS: `yum install bash-completion` - -Copy the file(s) to your `/etc/bash_completion.d` folder: - -`sudo cp jboss* /etc/bash_completion.d` - - +jboss-bash-completion +===================== + +JBoss Bash Completion for JBoss 5 and 7 (EAP 6) + + + +Overview +-------- + +Completion for the `run.sh` (JBoss5) and `standalone.sh`/`domain.sh` + +Some of the options available in jboss7: + + +* `--admin-only` `-h` `-help` `-version` `-V` `-v` +* `-Djboss.home.dir` +* `--server-config` (options the xml files in the configuration directory relative to -Djboss.server.base.dir) +* `-b` `-bmanagement` `-bunsecure` `-bpublic` `-Djboss.domain.master.address` `-Djboss.bind.address.*` (options: your local IP addresses and 0.0.0.0) +* `-Djboss.socket.binding.port-offset` (options: 100 200 300 400 10000 20000 30000 40000) +* `-u` (options 239.255.0.1 239.255.0.2 239.255.0.3) +* `-P` -Djboss.node.name + + +Install +------- + +Make sure you have installed bash_completion 1.3 (or higher): + +Debian/Ubuntu: `apt-get install bash-completion` +RHEL/CentOS: `yum install bash-completion` + +Copy the file(s) to your `/etc/bash_completion.d` folder: + +`sudo cp jboss* /etc/bash_completion.d` + + diff --git a/vendor/github.com/rparree/jboss-bash-completion/jboss5 b/vendor/github.com/rparree/jboss-bash-completion/jboss5 index aae4ff55..84767b10 100644 --- a/vendor/github.com/rparree/jboss-bash-completion/jboss5 +++ b/vendor/github.com/rparree/jboss-bash-completion/jboss5 @@ -1,95 +1,95 @@ -# Completions for JBoss Application Server 5 -# VERSION: 1.3 -# DATE: 2012-06-21 -# rparree-at-edc4it-dot-com - - - - -_serverProfiles5(){ - # from http://unix.stackexchange.com/questions/34238/complete-files-from-a-different-directory-in-bash - if [ -d "../server" ] - then - IFS=$'\n' tmp=( $(compgen -W "$(ls "../server")" -- "$cur" )) - COMPREPLY=( "${tmp[@]// /\ }" ) - unset IFS - else - COMPREPLY=( $(compgen -W "default standard all web minimal production" -- ${cur}) ) - fi -} - -_bindingAddress5(){ - # from /etc/bash_completion.d/ssh - COMPREPLY=( "${COMPREPLY[@]}" $( compgen -W \ - "0.0.0.0 $( PATH="$PATH:/sbin" ifconfig -a | \ - sed -ne 's/.*addr:\([^[:space:]]*\).*/\1/p' \ - -ne 's/.*inet[[:space:]]\{1,\}\([^[:space:]]*\).*/\1/p' )" \ - -- "$cur" ) ) -} - -_jboss5() -{ - - local cur prev words cword - COMPREPLY=() - _get_comp_words_by_ref -n = cur prev words cword - - case $cur in - - -Djboss.service.binding.set=*) - cur=${cur#*=} - #static list of common bindings sets - local bindings="ports-01 ports-02 ports-03 ports-04" - COMPREPLY=( $(compgen -W "${bindings}" -- ${cur}) ) - return 0 - ;; - -Djboss.default.jgroups.stack=*) - cur=${cur#*=} - #static list of standard JGroups stacks - local stacks="udp udp-async udp-sync tcp tcp-sync" - COMPREPLY=( $(compgen -W "${stacks}" -- ${cur}) ) - return 0 - ;; - - -Dorg.jboss.ejb3.remoting.IsLocalInterceptor.passByRef=*|-Dcom.sun.management.jmxremote.authenticate=*|-Dcom.sun.management.jmxremote.ssl=*) - cur=${cur#*=} - local booleans="true false" - COMPREPLY=( $(compgen -W "${booleans}" -- ${cur}) ) - return 0 - ;; - esac - - - case $prev in - -u) - # a few from RFC 2365 IPv4 Local Scope () - local addresses="239.255.0.1 239.255.0.2 239.255.0.3" - COMPREPLY=( $(compgen -W "${addresses}" -- ${cur}) ) - return 0 - ;; - -l) - local loggers="log4j jdk" - COMPREPLY=( $(compgen -W "${loggers}" -- ${cur}) ) - return 0 - ;; - -b) - _bindingAddress5 - return 0 - ;; - -c) - _serverProfiles5 - return 0 - ;; - *) - ;; - esac - - - COMPREPLY=( $( compgen -W ' -u -c -m - -b -g -l -d -p -n -B -L -C -P -v -help -Djboss.platform.mbeanserver' -- "$cur" ) \ - $( compgen -W '-Djboss.Domain -Djboss.modcluster.proxyList -Djboss.service.binding.set -Djboss.jvmRoute -Djboss.messaging.ServerPeerID -Djboss.default.jgroups.stack -Dorg.jboss.ejb3.remoting.IsLocalInterceptor.passByRef -Djboss.platform.mbeanserver -Dcom.sun.management.jmxremote.port -Dcom.sun.management.jmxremote.ssl' \ - -S '=' -- "$cur" ) ) - return 0 - - -} -complete -o nospace -F _jboss5 run.sh +# Completions for JBoss Application Server 5 +# VERSION: 1.3 +# DATE: 2012-06-21 +# rparree-at-edc4it-dot-com + + + + +_serverProfiles5(){ + # from http://unix.stackexchange.com/questions/34238/complete-files-from-a-different-directory-in-bash + if [ -d "../server" ] + then + IFS=$'\n' tmp=( $(compgen -W "$(ls "../server")" -- "$cur" )) + COMPREPLY=( "${tmp[@]// /\ }" ) + unset IFS + else + COMPREPLY=( $(compgen -W "default standard all web minimal production" -- ${cur}) ) + fi +} + +_bindingAddress5(){ + # from /etc/bash_completion.d/ssh + COMPREPLY=( "${COMPREPLY[@]}" $( compgen -W \ + "0.0.0.0 $( PATH="$PATH:/sbin" ifconfig -a | \ + sed -ne 's/.*addr:\([^[:space:]]*\).*/\1/p' \ + -ne 's/.*inet[[:space:]]\{1,\}\([^[:space:]]*\).*/\1/p' )" \ + -- "$cur" ) ) +} + +_jboss5() +{ + + local cur prev words cword + COMPREPLY=() + _get_comp_words_by_ref -n = cur prev words cword + + case $cur in + + -Djboss.service.binding.set=*) + cur=${cur#*=} + #static list of common bindings sets + local bindings="ports-01 ports-02 ports-03 ports-04" + COMPREPLY=( $(compgen -W "${bindings}" -- ${cur}) ) + return 0 + ;; + -Djboss.default.jgroups.stack=*) + cur=${cur#*=} + #static list of standard JGroups stacks + local stacks="udp udp-async udp-sync tcp tcp-sync" + COMPREPLY=( $(compgen -W "${stacks}" -- ${cur}) ) + return 0 + ;; + + -Dorg.jboss.ejb3.remoting.IsLocalInterceptor.passByRef=*|-Dcom.sun.management.jmxremote.authenticate=*|-Dcom.sun.management.jmxremote.ssl=*) + cur=${cur#*=} + local booleans="true false" + COMPREPLY=( $(compgen -W "${booleans}" -- ${cur}) ) + return 0 + ;; + esac + + + case $prev in + -u) + # a few from RFC 2365 IPv4 Local Scope () + local addresses="239.255.0.1 239.255.0.2 239.255.0.3" + COMPREPLY=( $(compgen -W "${addresses}" -- ${cur}) ) + return 0 + ;; + -l) + local loggers="log4j jdk" + COMPREPLY=( $(compgen -W "${loggers}" -- ${cur}) ) + return 0 + ;; + -b) + _bindingAddress5 + return 0 + ;; + -c) + _serverProfiles5 + return 0 + ;; + *) + ;; + esac + + + COMPREPLY=( $( compgen -W ' -u -c -m - -b -g -l -d -p -n -B -L -C -P -v -help -Djboss.platform.mbeanserver' -- "$cur" ) \ + $( compgen -W '-Djboss.Domain -Djboss.modcluster.proxyList -Djboss.service.binding.set -Djboss.jvmRoute -Djboss.messaging.ServerPeerID -Djboss.default.jgroups.stack -Dorg.jboss.ejb3.remoting.IsLocalInterceptor.passByRef -Djboss.platform.mbeanserver -Dcom.sun.management.jmxremote.port -Dcom.sun.management.jmxremote.ssl' \ + -S '=' -- "$cur" ) ) + return 0 + + +} +complete -o nospace -F _jboss5 run.sh diff --git a/vendor/github.com/rparree/jboss-bash-completion/jboss7 b/vendor/github.com/rparree/jboss-bash-completion/jboss7 index 66d07179..f0d44ad9 100644 --- a/vendor/github.com/rparree/jboss-bash-completion/jboss7 +++ b/vendor/github.com/rparree/jboss-bash-completion/jboss7 @@ -1,141 +1,142 @@ -# Completions for JBoss Application Server 7 (EAP 6) -# VERSION: 0.6 -# DATE: 2012-10-30 -# rparree-at-edc4it-dot-com - - - - -_serverProfiles(){ - if [[ $COMP_WORDS == *standalone.sh* ]] - then - serverdir="../standalone/configuration/" - else - # assume is domain.sh - serverdir="../domain/configuration/" - fi - - for i in ${!COMP_WORDS[*]} - do - if [[ "${COMP_WORDS[i]}" == "-Djboss.server.base.dir" || "${COMP_WORDS[i]}" == "-Djboss.domain.base.dir" ]]; then - serverdir="${COMP_WORDS[i+2]}/configuration" - fi - - done - if [ -d "${serverdir}" ] - then - - IFS=$'\n' tmp="$(ls "${serverdir}" | grep xml)" - local fls="${tmp[@]// /\ }" - unset IFS - COMPREPLY=( $(compgen -W "${fls} initial boot last v" -- "$cur" )) - fi -} - -_bindingAddress(){ - # from /etc/bash_completion.d/ssh - COMPREPLY=( "${COMPREPLY[@]}" $( compgen -W \ - "0.0.0.0 $( PATH="$PATH:/sbin" ifconfig -a | \ - sed -ne 's/.*addr:\([^[:space:]]*\).*/\1/p' \ - -ne 's/.*inet[[:space:]]\{1,\}\([^[:space:]]*\).*/\1/p' )" \ - -- "$cur" ) ) -} - -_jboss(){ - - local cur prev words cword - COMPREPLY=() - _get_comp_words_by_ref -n = cur prev words cword - - case $cur in - - -Djboss.socket.binding.port-offset=*) - cur=${cur#*=} - #static list of common bindings sets - local bindings="100 200 300 400 10000 20000 30000 40000" - COMPREPLY=( $(compgen -W "${bindings}" -- ${cur}) ) - return 0 - ;; - -Djboss.default.jgroups.stack=*) - cur=${cur#*=} - #static list of standard JGroups stacks - local stacks="udp udp-async udp-sync tcp tcp-sync" - COMPREPLY=( $(compgen -W "${stacks}" -- ${cur}) ) - return 0 - ;; - - -Dorg.jboss.ejb3.remoting.IsLocalInterceptor.passByRef=*|-Dcom.sun.management.jmxremote.authenticate=*|-Dcom.sun.management.jmxremote.ssl=*) - cur=${cur#*=} - local booleans="true false" - COMPREPLY=( $(compgen -W "${booleans}" -- ${cur}) ) - return 0 - ;; - - -Djboss.server.base.dir=*|-Djboss.home.dir=*|-Djboss.domain.base.dir=*) - cur=${cur#*=} - _filedir -d - return 0 - ;; - - -Djboss.domain.master.address=*|-Djboss.bind.address*=*) - cur=${cur#*=} - _bindingAddress - return 0 - ;; - --server-config=*|-c=|--host-config=*) - cur=${cur#*=} - _serverProfiles - return 0 - - - esac - - - case $prev in - -u) - # a few from RFC 2365 IPv4 Local Scope () - local addresses="239.255.0.1 239.255.0.2 239.255.0.3" - COMPREPLY=( $(compgen -W "${addresses}" -- ${cur}) ) - return 0 - ;; - -b*) - _bindingAddress - return 0 - ;; - -c) - _serverProfiles - return 0 - ;; - *) - ;; - esac - # *** from jboss5 ******************** - # *** -modulepath -c -m -g -l -d -p -n -B -L -C -Djboss.platform.mbeanserver -Djboss.server.base.directory - # *** -Djboss.Domain -Djboss.modcluster.proxyList -Djboss.jvmRoute -Djboss.default.jgroups.stack -Dorg.jboss.ejb3.remoting.IsLocalInterceptor.passByRef -Djboss.platform.mbeanserver -Dcom.sun.management.jmxremote.port -Dcom.sun.management.jmxremote.ssl - # ************************************* - - # standard commands for standalone and domain mode - local commandsWithoutEqualSign='-b -bmanagement -bunsecure -bpublic --admin-only -h -help -u -version -V -v' - local commandsWithEqualSign='-P -Djboss.node.name -Djboss.home.dir -Djboss.socket.binding.port-offset -Djboss.bind.address.management -Djboss.bind.address -Djboss.bind.address.unsecure' - - if [[ $COMP_WORDS == *standalone.sh* ]] - then - commandsWithoutEqualSign="${commandsWithoutEqualSign} -c" - commandsWithEqualSign="${commandsWithEqualSign} --server-config -Djboss.server.base.dir -c" - else - # assume is domain.sh - commandsWithoutEqualSign="${commandsWithoutEqualSign} --backup --cached-dc" - commandsWithEqualSign="${commandsWithEqualSign} -Djboss.domain.master.address --host-config -Djboss.domain.master.port -Djboss.domain.base.dir " - fi - - - - - COMPREPLY=( $( compgen -W "$commandsWithoutEqualSign" -- "$cur" ) - $( compgen -W "$commandsWithEqualSign" -S '=' -- "$cur" ) ) - return 0 - - -} -complete -o nospace -F _jboss standalone.sh -complete -o nospace -F _jboss domain.sh +# Completions for JBoss Application Server 7 (EAP 6) +# VERSION: 0.6 +# DATE: 2012-10-30 +# rparree-at-edc4it-dot-com + + + + +_serverProfiles(){ + if [[ $COMP_WORDS == *standalone.sh* ]] + then + serverdir="../standalone/configuration/" + else + # assume is domain.sh + serverdir="../domain/configuration/" + fi + + for i in ${!COMP_WORDS[*]} + do + if [[ "${COMP_WORDS[i]}" == "-Djboss.server.base.dir" || "${COMP_WORDS[i]}" == "-Djboss.domain.base.dir" ]] + then + serverdir="${COMP_WORDS[i+2]}/configuration" + fi + + done + if [ -d "${serverdir}" ] + then + + IFS=$'\n' tmp="$(ls "${serverdir}" | grep xml)" + local fls="${tmp[@]// /\ }" + unset IFS + COMPREPLY=( $(compgen -W "${fls} initial boot last v" -- "$cur" )) + fi +} + +_bindingAddress(){ + # from /etc/bash_completion.d/ssh + COMPREPLY=( "${COMPREPLY[@]}" $( compgen -W \ + "0.0.0.0 $( PATH="$PATH:/sbin" ifconfig -a | \ + sed -ne 's/.*addr:\([^[:space:]]*\).*/\1/p' \ + -ne 's/.*inet[[:space:]]\{1,\}\([^[:space:]]*\).*/\1/p' )" \ + -- "$cur" ) ) +} + +_jboss(){ + + local cur prev words cword + COMPREPLY=() + _get_comp_words_by_ref -n = cur prev words cword + + case $cur in + + -Djboss.socket.binding.port-offset=*) + cur=${cur#*=} + #static list of common bindings sets + local bindings="100 200 300 400 10000 20000 30000 40000" + COMPREPLY=( $(compgen -W "${bindings}" -- ${cur}) ) + return 0 + ;; + -Djboss.default.jgroups.stack=*) + cur=${cur#*=} + #static list of standard JGroups stacks + local stacks="udp udp-async udp-sync tcp tcp-sync" + COMPREPLY=( $(compgen -W "${stacks}" -- ${cur}) ) + return 0 + ;; + + -Dorg.jboss.ejb3.remoting.IsLocalInterceptor.passByRef=*|-Dcom.sun.management.jmxremote.authenticate=*|-Dcom.sun.management.jmxremote.ssl=*) + cur=${cur#*=} + local booleans="true false" + COMPREPLY=( $(compgen -W "${booleans}" -- ${cur}) ) + return 0 + ;; + + -Djboss.server.base.dir=*|-Djboss.home.dir=*|-Djboss.domain.base.dir=*) + cur=${cur#*=} + _filedir -d + return 0 + ;; + + -Djboss.domain.master.address=*|-Djboss.bind.address*=*) + cur=${cur#*=} + _bindingAddress + return 0 + ;; + --server-config=*|-c=|--host-config=*) + cur=${cur#*=} + _serverProfiles + return 0 + + + esac + + + case $prev in + -u) + # a few from RFC 2365 IPv4 Local Scope () + local addresses="239.255.0.1 239.255.0.2 239.255.0.3" + COMPREPLY=( $(compgen -W "${addresses}" -- ${cur}) ) + return 0 + ;; + -b*) + _bindingAddress + return 0 + ;; + -c) + _serverProfiles + return 0 + ;; + *) + ;; + esac + # *** from jboss5 ******************** + # *** -modulepath -c -m -g -l -d -p -n -B -L -C -Djboss.platform.mbeanserver -Djboss.server.base.directory + # *** -Djboss.Domain -Djboss.modcluster.proxyList -Djboss.jvmRoute -Djboss.default.jgroups.stack -Dorg.jboss.ejb3.remoting.IsLocalInterceptor.passByRef -Djboss.platform.mbeanserver -Dcom.sun.management.jmxremote.port -Dcom.sun.management.jmxremote.ssl + # ************************************* + + # standard commands for standalone and domain mode + local commandsWithoutEqualSign='-b -bmanagement -bunsecure -bpublic --admin-only -h -help -u -version -V -v' + local commandsWithEqualSign='-P -Djboss.node.name -Djboss.home.dir -Djboss.socket.binding.port-offset -Djboss.bind.address.management -Djboss.bind.address -Djboss.bind.address.unsecure' + + if [[ $COMP_WORDS == *standalone.sh* ]] + then + commandsWithoutEqualSign="${commandsWithoutEqualSign} -c" + commandsWithEqualSign="${commandsWithEqualSign} --server-config -Djboss.server.base.dir -c" + else + # assume is domain.sh + commandsWithoutEqualSign="${commandsWithoutEqualSign} --backup --cached-dc" + commandsWithEqualSign="${commandsWithEqualSign} -Djboss.domain.master.address --host-config -Djboss.domain.master.port -Djboss.domain.base.dir " + fi + + + + + COMPREPLY=( $( compgen -W "$commandsWithoutEqualSign" -- "$cur" ) + $( compgen -W "$commandsWithEqualSign" -S '=' -- "$cur" ) ) + return 0 + + +} +complete -o nospace -F _jboss standalone.sh +complete -o nospace -F _jboss domain.sh diff --git a/vendor/github.com/vigo/apm-bash-completion/CODE_OF_CONDUCT.md b/vendor/github.com/vigo/apm-bash-completion/CODE_OF_CONDUCT.md index db8700e4..a82c77a9 100644 --- a/vendor/github.com/vigo/apm-bash-completion/CODE_OF_CONDUCT.md +++ b/vendor/github.com/vigo/apm-bash-completion/CODE_OF_CONDUCT.md @@ -1,76 +1,76 @@ -# Contributor Covenant Code of Conduct - -## Our Pledge - -In the interest of fostering an open and welcoming environment, we as -contributors and maintainers pledge to making participation in our project and -our community a harassment-free experience for everyone, regardless of age, body -size, disability, ethnicity, sex characteristics, gender identity and expression, -level of experience, education, socio-economic status, nationality, personal -appearance, race, religion, or sexual identity and orientation. - -## Our Standards - -Examples of behavior that contributes to creating a positive environment -include: - -* Using welcoming and inclusive language -* Being respectful of differing viewpoints and experiences -* Gracefully accepting constructive criticism -* Focusing on what is best for the community -* Showing empathy towards other community members - -Examples of unacceptable behavior by participants include: - -* The use of sexualized language or imagery and unwelcome sexual attention or - advances -* Trolling, insulting/derogatory comments, and personal or political attacks -* Public or private harassment -* Publishing others' private information, such as a physical or electronic - address, without explicit permission -* Other conduct which could reasonably be considered inappropriate in a - professional setting - -## Our Responsibilities - -Project maintainers are responsible for clarifying the standards of acceptable -behavior and are expected to take appropriate and fair corrective action in -response to any instances of unacceptable behavior. - -Project maintainers have the right and responsibility to remove, edit, or -reject comments, commits, code, wiki edits, issues, and other contributions -that are not aligned to this Code of Conduct, or to ban temporarily or -permanently any contributor for other behaviors that they deem inappropriate, -threatening, offensive, or harmful. - -## Scope - -This Code of Conduct applies both within project spaces and in public spaces -when an individual is representing the project or its community. Examples of -representing a project or community include using an official project e-mail -address, posting via an official social media account, or acting as an appointed -representative at an online or offline event. Representation of a project may be -further defined and clarified by project maintainers. - -## Enforcement - -Instances of abusive, harassing, or otherwise unacceptable behavior may be -reported by contacting the project team at ugurozyilmazel@gmail.com. All -complaints will be reviewed and investigated and will result in a response that -is deemed necessary and appropriate to the circumstances. The project team is -obligated to maintain confidentiality with regard to the reporter of an incident. -Further details of specific enforcement policies may be posted separately. - -Project maintainers who do not follow or enforce the Code of Conduct in good -faith may face temporary or permanent repercussions as determined by other -members of the project's leadership. - -## Attribution - -This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, -available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html - -[homepage]: https://www.contributor-covenant.org - -For answers to common questions about this code of conduct, see +# Contributor Covenant Code of Conduct + +## Our Pledge + +In the interest of fostering an open and welcoming environment, we as +contributors and maintainers pledge to making participation in our project and +our community a harassment-free experience for everyone, regardless of age, body +size, disability, ethnicity, sex characteristics, gender identity and expression, +level of experience, education, socio-economic status, nationality, personal +appearance, race, religion, or sexual identity and orientation. + +## Our Standards + +Examples of behavior that contributes to creating a positive environment +include: + +* Using welcoming and inclusive language +* Being respectful of differing viewpoints and experiences +* Gracefully accepting constructive criticism +* Focusing on what is best for the community +* Showing empathy towards other community members + +Examples of unacceptable behavior by participants include: + +* The use of sexualized language or imagery and unwelcome sexual attention or + advances +* Trolling, insulting/derogatory comments, and personal or political attacks +* Public or private harassment +* Publishing others' private information, such as a physical or electronic + address, without explicit permission +* Other conduct which could reasonably be considered inappropriate in a + professional setting + +## Our Responsibilities + +Project maintainers are responsible for clarifying the standards of acceptable +behavior and are expected to take appropriate and fair corrective action in +response to any instances of unacceptable behavior. + +Project maintainers have the right and responsibility to remove, edit, or +reject comments, commits, code, wiki edits, issues, and other contributions +that are not aligned to this Code of Conduct, or to ban temporarily or +permanently any contributor for other behaviors that they deem inappropriate, +threatening, offensive, or harmful. + +## Scope + +This Code of Conduct applies both within project spaces and in public spaces +when an individual is representing the project or its community. Examples of +representing a project or community include using an official project e-mail +address, posting via an official social media account, or acting as an appointed +representative at an online or offline event. Representation of a project may be +further defined and clarified by project maintainers. + +## Enforcement + +Instances of abusive, harassing, or otherwise unacceptable behavior may be +reported by contacting the project team at ugurozyilmazel@gmail.com. All +complaints will be reviewed and investigated and will result in a response that +is deemed necessary and appropriate to the circumstances. The project team is +obligated to maintain confidentiality with regard to the reporter of an incident. +Further details of specific enforcement policies may be posted separately. + +Project maintainers who do not follow or enforce the Code of Conduct in good +faith may face temporary or permanent repercussions as determined by other +members of the project's leadership. + +## Attribution + +This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, +available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html + +[homepage]: https://www.contributor-covenant.org + +For answers to common questions about this code of conduct, see https://www.contributor-covenant.org/faq \ No newline at end of file diff --git a/vendor/github.com/vigo/apm-bash-completion/LICENSE b/vendor/github.com/vigo/apm-bash-completion/LICENSE index 82871004..ad2e31c9 100644 --- a/vendor/github.com/vigo/apm-bash-completion/LICENSE +++ b/vendor/github.com/vigo/apm-bash-completion/LICENSE @@ -1,21 +1,21 @@ -The MIT License (MIT) - -Copyright (c) 2015 Uğur "vigo" Özyılmazel - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. +The MIT License (MIT) + +Copyright (c) 2015 Uğur "vigo" Özyılmazel + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/vendor/github.com/vigo/apm-bash-completion/README.md b/vendor/github.com/vigo/apm-bash-completion/README.md index 52b43a37..cbb3accb 100644 --- a/vendor/github.com/vigo/apm-bash-completion/README.md +++ b/vendor/github.com/vigo/apm-bash-completion/README.md @@ -1,70 +1,70 @@ -# Bash Completion for Atom Package Manager (apm) - -If you use [Atom](http://atom.io) editor, you'll like this completion helper. - -## Installation - -You can install via [Homebrew](http://brew.sh) - - brew install homebrew/completions/apm-bash-completion - -## Usage - -```bash -$ apm [TAB] - -clean featured ln remove unlink -config help lns rm unpublish -dedupe home login search unstar -deinstall init ls show update -delete install open star upgrade -dev link outdated starred view -develop linked publish stars -docs links rebuild test -erase list rebuild-module-cache uninstall - -$ apm publish -build major minor patch - -$ apm config -delete edit get list set -``` - -## Manual Usage - -Just get the file `apm` and call `source apm` (or add it to your bash environment) - ---- - -## What’s New? - -Well, I even don’t remember this project since I’ve got mail today about -missing LICENSE file. Feel free to contribute, add missing pieces :) - ---- - -## Contribution - -Please let me know if you need some more options. Please create an issue and -make a request. Also If you like to improve or add more features please fork -it and you know the rest :) - -1. Fork it ( https://github.com/vigo/apm-bash-completion ) -2. Create your feature branch (`git checkout -b my-new-feature`) -3. Commit your changes (`git commit -am 'Add some feature'`) -4. Push to the branch (`git push origin my-new-feature`) -5. Create a new Pull Request - ---- - -## Contributer(s) - -* [Uğur "vigo" Özyılmazel](https://github.com/vigo) - Creator, maintainer - ---- - -## License - -This project is licensed under MIT - ---- +# Bash Completion for Atom Package Manager (apm) + +If you use [Atom](http://atom.io) editor, you'll like this completion helper. + +## Installation + +You can install via [Homebrew](http://brew.sh) + + brew install homebrew/completions/apm-bash-completion + +## Usage + +```bash +$ apm [TAB] + +clean featured ln remove unlink +config help lns rm unpublish +dedupe home login search unstar +deinstall init ls show update +delete install open star upgrade +dev link outdated starred view +develop linked publish stars +docs links rebuild test +erase list rebuild-module-cache uninstall + +$ apm publish +build major minor patch + +$ apm config +delete edit get list set +``` + +## Manual Usage + +Just get the file `apm` and call `source apm` (or add it to your bash environment) + +--- + +## What’s New? + +Well, I even don’t remember this project since I’ve got mail today about +missing LICENSE file. Feel free to contribute, add missing pieces :) + +--- + +## Contribution + +Please let me know if you need some more options. Please create an issue and +make a request. Also If you like to improve or add more features please fork +it and you know the rest :) + +1. Fork it ( https://github.com/vigo/apm-bash-completion ) +2. Create your feature branch (`git checkout -b my-new-feature`) +3. Commit your changes (`git commit -am 'Add some feature'`) +4. Push to the branch (`git push origin my-new-feature`) +5. Create a new Pull Request + +--- + +## Contributer(s) + +* [Uğur "vigo" Özyılmazel](https://github.com/vigo) - Creator, maintainer + +--- + +## License + +This project is licensed under MIT + +--- diff --git a/vendor/github.com/vigo/apm-bash-completion/apm b/vendor/github.com/vigo/apm-bash-completion/apm index 0804801f..9ea66553 100644 --- a/vendor/github.com/vigo/apm-bash-completion/apm +++ b/vendor/github.com/vigo/apm-bash-completion/apm @@ -1,63 +1,69 @@ -#!/usr/bin/env bash - -# this is the modified version of bundle bash-completion. -# Copyright (c) 2011-2013 Daniel Luz (bundle bash-completion) -# -# apm bash-completion is written by Ugur Ozyilmazel -# github: @vigo, twitter: @vigobronx -# enjoy! -# -# you need to activate this via -# $ source apm - -__apm(){ - local cur prev options apm_command - COMPREPLY=() - cur="${COMP_WORDS[COMP_CWORD]}" - prev="${COMP_WORDS[COMP_CWORD-1]}" - __apm_get_command - if [[ $cur = -* ]]; then - options="--color" - if [[ -z $apm_command ]]; then - options="$options --version --help" - fi - if [[ $apm_command && $apm_command = publish ]]; then - options="--tag --rename" - fi - else - if [[ -z $apm_command || $apm_command = help ]]; then - options="help clean config dedupe deinstall delete dev develop docs erase featured home init install link linked links list ln lns login ls open outdated publish rebuild rebuild-module-cache remove rm search show star starred stars test uninstall unlink unpublish unstar update upgrade view" - fi - if [[ $apm_command && $apm_command = publish ]]; then - options="major minor patch build" - fi - if [[ $apm_command && $apm_command = config ]]; then - options="set get delete list edit" - fi - fi - COMPREPLY=($(compgen -W "$options" -- "$cur")) -} -__apm_get_command() { - local i - for ((i=1; i < $COMP_CWORD; ++i)); do - local arg=${COMP_WORDS[$i]} - case $arg in - [^-]*) - apm_command=$arg - return;; - --version) - apm_command=- - return;; - --help) - apm_command=help - return;; - publish) - apm_command=publish - return;; - config) - apm_command=config - return;; - esac - done -} -complete -F __apm -o bashdefault -o default apm +#!/usr/bin/env bash + +# this is the modified version of bundle bash-completion. +# Copyright (c) 2011-2013 Daniel Luz (bundle bash-completion) +# +# apm bash-completion is written by Ugur Ozyilmazel +# github: @vigo, twitter: @vigobronx +# enjoy! +# +# you need to activate this via +# $ source apm + +__apm(){ + local cur prev options apm_command + COMPREPLY=() + cur="${COMP_WORDS[COMP_CWORD]}" + prev="${COMP_WORDS[COMP_CWORD-1]}" + __apm_get_command + if [[ $cur = -* ]] + then + options="--color" + if [[ -z $apm_command ]] + then + options="$options --version --help" + fi + if [[ $apm_command && $apm_command = publish ]] + then + options="--tag --rename" + fi + else + if [[ -z $apm_command || $apm_command = help ]] + then + options="help clean config dedupe deinstall delete dev develop docs erase featured home init install link linked links list ln lns login ls open outdated publish rebuild rebuild-module-cache remove rm search show star starred stars test uninstall unlink unpublish unstar update upgrade view" + fi + if [[ $apm_command && $apm_command = publish ]] + then + options="major minor patch build" + fi + if [[ $apm_command && $apm_command = config ]] + then + options="set get delete list edit" + fi + fi + COMPREPLY=($(compgen -W "$options" -- "$cur")) +} +__apm_get_command() { + local i + for ((i=1; i < $COMP_CWORD; ++i)); do + local arg=${COMP_WORDS[$i]} + case $arg in + [^-]*) + apm_command=$arg + return;; + --version) + apm_command=- + return;; + --help) + apm_command=help + return;; + publish) + apm_command=publish + return;; + config) + apm_command=config + return;; + esac + done +} +complete -F __apm -o bashdefault -o default apm