diff --git a/.editorconfig b/.editorconfig old mode 100755 new mode 100644 index 4dc96bd55e..f67aa2df5a --- a/.editorconfig +++ b/.editorconfig @@ -1,14 +1,36 @@ # EditorConfig is awesome: http://EditorConfig.org -root = true - [*] indent_style = space indent_size = 2 end_of_line = lf charset = utf-8 + trim_trailing_whitespace = true insert_final_newline = true -[*.md] +[**.{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 d4c710cbd6..de622e0618 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,2 +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 diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml new file mode 100644 index 0000000000..a187422efb --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -0,0 +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. diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml new file mode 100644 index 0000000000..f33f8a3fd8 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -0,0 +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 diff --git a/.github/ISSUE_TEMPLATE/feature_request.yml b/.github/ISSUE_TEMPLATE/feature_request.yml new file mode 100644 index 0000000000..670aef64b3 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.yml @@ -0,0 +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. diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 0000000000..fd9bceb80a --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +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. diff --git a/.github/no-response.yml b/.github/no-response.yml new file mode 100644 index 0000000000..e80a98be8f --- /dev/null +++ b/.github/no-response.yml @@ -0,0 +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. diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000000..75fb9d848e --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,64 @@ +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@v4 + - 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@v4 + - name: Set up Python + uses: actions/setup-python@v4 + 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@v4 + - name: Set up Go + uses: actions/setup-go@v4 + with: + go-version: 1.21.0 + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: 3.8 + - name: Install shfmt + run: go install mvdan.cc/sh/v3/cmd/shfmt@latest + - 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 old mode 100755 new mode 100644 index 2e6fb7c0b3..8e6f12a106 --- a/.gitignore +++ b/.gitignore @@ -15,3 +15,10 @@ bats *.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 095a6a5e6f..57b46adcf5 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,12 +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/ztombol/bats-support + url = https://github.com/bats-core/bats-support + branch = tags/v0.3.0 [submodule "test_lib/bats-assert"] path = test_lib/bats-assert - url = https://github.com/ztombol/bats-assert + url = https://github.com/bats-core/bats-assert + branch = tags/v2.0.0 [submodule "test_lib/bats-file"] path = test_lib/bats-file - url = https://github.com/ztombol/bats-file + 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 new file mode 100644 index 0000000000..af5f30afe5 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +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 diff --git a/.readthedocs.yml b/.readthedocs.yml new file mode 100644 index 0000000000..751f31751d --- /dev/null +++ b/.readthedocs.yml @@ -0,0 +1,10 @@ +version: 2 + +sphinx: + builder: htmldir + configuration: docs/conf.py + +python: + version: 3.7 + install: + - requirements: docs/requirements.txt diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index b3fa2728e6..0000000000 --- a/.travis.yml +++ /dev/null @@ -1,6 +0,0 @@ -sudo: false -script: test/run -language: c -os: - - linux - - osx diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md deleted file mode 100644 index 04451473c3..0000000000 --- a/CONTRIBUTING.md +++ /dev/null @@ -1,87 +0,0 @@ -# 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 opening a new issue in the issue tracker, please include information about which _Operating System_ you're using, and which version of _Bash_. -* In many cases, it also makes sense to show which Bash-it plugins you are using. - This information can be obtained using `bash-it show plugins`. -* If the issue happens while loading Bash-it, please also include your `~/.bash_profile` or `~/.bashrc` file, - as well as the install location of Bash-it (default should be `~/.bash_it`). -* 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. - Don't create a PR consisting of 20 commits that show your work in progress. - Before you create the PR, _squash_ your changes into a single commit. - -## Code Style - -* Try to stick to the existing code style. Please don't reformat or change the syntax of existing code simply because you don't like that style. -* Indentation is using spaces, not tabs. Most of the code is indented with 2 spaces, some with 4 spaces. Please try to stick to 2 spaces. - If you're using an editor that supports [EditorConfig](http://EditorConfig.org), the editor should automatically use the settings defined in Bash-it's [.editorconfig file](.editorconfig). -* 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](plugins/available/base.plugin.bash)). -* 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 [Travis CI](https://travis-ci.org/Bash-it/bash-it), where the test suite is run on both Linux and macOS. -The Pull Request will then show the result of the Travis 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: - -```bash -test/run -``` - -This command will ensure that the [Bats Test Framework](https://github.com/bats-core/bats-core) 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](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. - -## 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 repo itself, as they will add unnecessary bloat to the repo. - The project's Wiki has a _Themes_ page where you can add a screenshot if you want. -* Ideally, each theme's folder should contain a `README.md` file describing the theme and its configuration options. diff --git a/DEVELOPMENT.md b/DEVELOPMENT.md deleted file mode 100644 index ba9efe60cf..0000000000 --- a/DEVELOPMENT.md +++ /dev/null @@ -1,45 +0,0 @@ -# Bash-it Development - -This page summarizes a couple of rules to keep in mind when developing features or making changes in Bash-it. - -## Load Order - -### General Load Order - -The main `bash_it.sh` script loads the frameworks individual components in the following order: - -* `lib/composure.bash` -* Files in `lib` with the exception of `appearance.bash` - this means that `composure.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`: - - ```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. diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000000..25b6d7fbf4 --- /dev/null +++ b/LICENSE @@ -0,0 +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. diff --git a/README.md b/README.md deleted file mode 100644 index 022ce4424f..0000000000 --- a/README.md +++ /dev/null @@ -1,439 +0,0 @@ -# Bash-it - -[![Build Status](https://travis-ci.org/Bash-it/bash-it.svg?branch=master)](https://travis-ci.org/Bash-it/bash-it) [![Join the chat at https://gitter.im/Bash-it/bash-it](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/Bash-it/bash-it?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) - -**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) on a regular basis 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. - -- [Contributing](#contributing) -- [Installation](#installation) - - [Install Options](#install-options) - - [via Docker](#install-using-docker) - - [Updating](#updating) -- [Help](#help-screens) -- [Search](#search) - - [Syntax](#syntax) - - [Searching with Negations](#searching-with-negations) - - [Using Search to Enable or Disable Components](#using-search-to-enable-or-disable-components) - - [Disabling ASCII Color](#disabling-ascii-color) -- [Custom scripts, aliases, themes, and functions](#custom-scripts-aliases-themes-and-functions) -- [Themes](#themes) -- [Uninstalling](#uninstalling) -- [Misc](#misc) -- [Help Out](#help-out) -- [Contributors](#contributors) - -## Contributing - -Please take a look at the [Contribution Guidelines](CONTRIBUTING.md) before reporting a bug or providing a new feature. - -The [Development Guidelines](DEVELOPMENT.md) 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. - -## 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` (it automatically backs up your `~/.bash_profile` or `~/.bashrc`, depending on your OS) -3. Edit your modified config (`~/.bash_profile` or `~/.bashrc`) file in order to customize Bash-it. -4. 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`). - -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 load its configuration files, -`.bash_profile` for login shells (and in macOS in terminal emulators like [Terminal.app](http://www.apple.com/osx/apps/) or -[iTerm2](https://www.iterm2.com/)) and `.bashrc` for interactive shells (default mode in most of the GNU/Linux terminal emulators), -to ensure that Bash-it is loaded correctly. -A good "practice" is sourcing `.bashrc` into `.bash_profile` to keep things working in all the scenarios. -To achieve this, you can add this snippet in your `.bash_profile`: - -``` -if [ -f ~/.bashrc ]; then - . ~/.bashrc -fi -``` - -Refer to the official [Bash documentation](https://www.gnu.org/software/bash/manual/bashref.html#Bash-Startup-Files) to get more info. - - -### Install using Docker - -You can try Bash-it in an isolated environment without changing any local files via a [Docker](https://www.docker.com/) Container. -(Bash Shell v4.4 with Bash-it, [bats](https://github.com/sstephenson/bats) and bash-completion based on [Alpine Linux](https://alpinelinux.org/)). - -`docker pull ellerbrock/bash-it` - -Have a look at our [bash-it-docker repository](https://github.com/Bash-it/bash-it-docker) for further information. - - -### Updating - -To update Bash-it to the latest version, simply run: - -```bash -bash-it update -``` - -that's all. - -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: - -```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. - -## Help Screens - -```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 -``` - -## 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 - -```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: - -```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: - -```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: - -```bash -❯ NO_COLOR=1 bash-it search ruby rake gem bundle irb rails -chruby - aliases => ✓bundler ✓rails - plugins => ✓ruby - completions => bundler gem rake -``` - -## Custom scripts, aliases, themes, and functions - -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. - -## 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. - -Examples: - -```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" -``` - -You can easily preview the themes in your own shell using `BASH_PREVIEW=true bash-it reload`. - -If you've created your own custom prompts, we'd love it if you shared with everyone else! Just submit a Pull Request. -You can see theme screenshots on [wiki/Themes](https://github.com/Bash-it/bash-it/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. - -## Uninstalling - -To uninstall Bash-it, run the `uninstall.sh` script found in the `$BASH_IT` directory: - -``` -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. - -## Misc - -### Bash Profile Aliases - -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. - -### Prompt Version Control Check - -Bash-it provides prompt themes 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. - -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 - -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. - -### 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](https://github.com/pivotal/git_scripts). -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](https://github.com/pivotal/git_scripts). -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: - -``` -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: - -``` -$ 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: - -``` -$ 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. - -### Pass function renamed to passgen - -The Bash-it `pass` function has been renamed to `passgen` in order to avoid a naming conflict with the [pass password manager](https://www.passwordstore.org/). -In order to minimize the impact on users of the legacy Bash-it `pass` function, Bash-it will create the alias `pass` that calls the new `passgen` function if the `pass` password manager command is not found on the `PATH` (default behavior). - -This behavior can be overridden with the `BASH_IT_LEGACY_PASS` flag as follows: - -Set `BASH_IT_LEGACY_PASS` to 'true' to force Bash-it to always **create** the `pass` alias to `passgen`: - -* `export BASH_IT_LEGACY_PASS=true` - -Unset `BASH_IT_LEGACY_PASS` to have Bash-it **return to default behavior**: - -* `unset BASH_IT_LEGACY_PASS` - -### 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: - -```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. - -## 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 [Contribution Guidelines](CONTRIBUTING.md) before reporting a bug or providing a new feature. - -Thanks, and happing bashing! - - -## Contributors - -* [List of contributors][contribute] - -[contribute]: https://github.com/Bash-it/bash-it/contributors -[pass password manager]: http://www.passwordstore.org/ diff --git a/aliases/available/ag.aliases.bash b/aliases/available/ag.aliases.bash index e3157f9433..7f9af7dad5 100644 --- a/aliases/available/ag.aliases.bash +++ b/aliases/available/ag.aliases.bash @@ -1,4 +1,4 @@ -cite 'about-alias' +# shellcheck shell=bash about-alias 'the silver searcher (ag) aliases' ## Summary for args to less: diff --git a/aliases/available/ansible.aliases.bash b/aliases/available/ansible.aliases.bash index 1c53a88e3f..04c5d2801a 100644 --- a/aliases/available/ansible.aliases.bash +++ b/aliases/available/ansible.aliases.bash @@ -1,4 +1,4 @@ -cite 'about-alias' +# shellcheck shell=bash about-alias 'ansible abbreviations' alias ans=ansible diff --git a/aliases/available/apt.aliases.bash b/aliases/available/apt.aliases.bash index 2f44493123..1d43ffac66 100644 --- a/aliases/available/apt.aliases.bash +++ b/aliases/available/apt.aliases.bash @@ -1,4 +1,4 @@ -#!/bin/bash +# shellcheck shell=bash # # -binaryanomaly @@ -6,9 +6,8 @@ cite 'about-alias' about-alias 'Apt and dpkg aliases for Ubuntu and Debian distros.' # set apt aliases -function _set_pkg_aliases() -{ - if [ -x $(which apt) ]; then +function _set_pkg_aliases() { + 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/atom.aliases.bash b/aliases/available/atom.aliases.bash index 8d70cffaa5..6868e2cc2e 100644 --- a/aliases/available/atom.aliases.bash +++ b/aliases/available/atom.aliases.bash @@ -1,4 +1,4 @@ -cite 'about-alias' +# shellcheck shell=bash about-alias 'Atom.io editor abbreviations' alias a='atom' diff --git a/aliases/available/bash-it.aliases.bash b/aliases/available/bash-it.aliases.bash new file mode 100644 index 0000000000..1f16638b0a --- /dev/null +++ b/aliases/available/bash-it.aliases.bash @@ -0,0 +1,23 @@ +# shellcheck shell=bash +about-alias 'Aliases for the bash-it command (these aliases are automatically included with the "general" aliases)' + +# Common misspellings of bash-it +alias shit='bash-it' +alias batshit='bash-it' +alias bashit='bash-it' +alias batbsh='bash-it' +alias babsh='bash-it' +alias bash_it='bash-it' +alias bash_ti='bash-it' + +# Additional bash-it aliases for help/show +alias bshsa='bash-it show aliases' +alias bshsc='bash-it show completions' +alias bshsp='bash-it show plugins' +alias bshha='bash-it help aliases' +alias bshhc='bash-it help completions' +alias bshhp='bash-it help plugins' +alias bshsch="bash-it search" +alias bshenp="bash-it enable plugin" +alias bshena="bash-it enable alias" +alias bshenc="bash-it enable completion" diff --git a/aliases/available/bolt.aliases.bash b/aliases/available/bolt.aliases.bash new file mode 100644 index 0000000000..556dd7fe00 --- /dev/null +++ b/aliases/available/bolt.aliases.bash @@ -0,0 +1,8 @@ +# shellcheck shell=bash +about-alias 'puppet bolt aliases' + +# Aliases +alias bolt='bolt command run --tty --no-host-key-check' +alias boltas='bolt -p -u' +alias sudobolt='bolt --run-as root --sudo-password' +alias sudoboltas='sudobolt -p -u' diff --git a/aliases/available/bundler.aliases.bash b/aliases/available/bundler.aliases.bash index fc20f4ff9d..1eb0086245 100644 --- a/aliases/available/bundler.aliases.bash +++ b/aliases/available/bundler.aliases.bash @@ -1,4 +1,4 @@ -cite 'about-alias' +# shellcheck shell=bash about-alias 'ruby bundler' # Bundler Commands diff --git a/aliases/available/clipboard.aliases.bash b/aliases/available/clipboard.aliases.bash index 528e2d0e5a..2a5c3e8c98 100644 --- a/aliases/available/clipboard.aliases.bash +++ b/aliases/available/clipboard.aliases.bash @@ -1,20 +1,16 @@ -cite 'about-alias' -about-alias 'pbcopy and pbpaste shortcuts to linux' +# shellcheck shell=bash +about-alias 'xclip shortcuts' -case $OSTYPE in - linux*) - XCLIP=$(command -v xclip) - [[ $XCLIP ]] && \ - alias pbcopy="$XCLIP -selection clipboard" && \ - alias pbpaste="$XCLIP -selection clipboard -o" - ;; -esac +alias pbcopy="xclip -selection clipboard" +alias pbpaste="xclip -selection clipboard -o" +alias xcpy="xclip -selection clipboard" +alias xpst="xclip -selection clipboard -o" # to use it just install xclip on your distribution and it would work like: -# $ echo "hello" | pbcopy -# $ pbpaste +# $ echo "hello" | xcpy +# $ xpst # hello # very useful for things like: -# cat ~/.ssh/id_rsa.pub | pbcopy +# cat ~/.ssh/id_rsa.pub | xcpy # have fun! diff --git a/aliases/available/composer.aliases.bash b/aliases/available/composer.aliases.bash new file mode 100644 index 0000000000..85401abb82 --- /dev/null +++ b/aliases/available/composer.aliases.bash @@ -0,0 +1,39 @@ +# shellcheck shell=bash +about-alias 'common composer abbreviations' + +# Aliases +alias coab='composer about' +alias coar='composer archive' +alias cob='composer browser' +alias cocpr='composer check-platform-reqs' +alias cocc='composer clear-cache' +alias cocfg='composer config' +alias cocp='composer create-project' +alias codp='composer depends' +alias codiag='composer diagnose' +alias codmp='composer dump-autoload' +alias coex='composer exec' +alias coglob='composer global' +alias coh='composer help' +alias cohome='composer home' +alias coi='composer install' +alias coinf='composer info' +alias coini='composer init' +alias coli='composer license' +alias colis='composer list' +alias coout='composer outdated' +alias cop='composer prohibits' +alias corem='composer remove' +alias coreq='composer require' +alias coreqd='composer require --dev' +alias cors='composer run-script' +alias cos='composer search' +alias cosu='composer self-update' +alias coshow='composer show' +alias costat='composer status' +alias cosugg='composer suggest' +alias coup='composer update' +alias coupg='composer upgrade' +alias coval='composer validate' +alias cowhy='composer why' +alias cowhyn='composer why-not' diff --git a/aliases/available/curl.aliases.bash b/aliases/available/curl.aliases.bash index 3ced1bb54f..a270e416d2 100644 --- a/aliases/available/curl.aliases.bash +++ b/aliases/available/curl.aliases.bash @@ -1,22 +1,19 @@ -#!/bin/bash - -cite 'about-alias' +# shellcheck shell=bash about-alias 'Curl aliases for convenience.' # set apt aliases -function _set_pkg_aliases() -{ - if [ -x $(which curl) ]; then +function _set_pkg_aliases() { + if _command_exists curl; then # follow redirects - alias cl='curl -L' - # follow redirects, download as original name - alias clo='curl -L -O' - # follow redirects, download as original name, continue - alias cloc='curl -L -C - -O' - # follow redirects, download as original name, continue, retry 5 times - alias clocr='curl -L -C - -O --retry 5' - # follow redirects, fetch banner - alias clb='curl -L -I' + alias cl='curl -L' + # follow redirects, download as original name + alias clo='curl -L -O' + # follow redirects, download as original name, continue + alias cloc='curl -L -C - -O' + # follow redirects, download as original name, continue, retry 5 times + alias clocr='curl -L -C - -O --retry 5' + # follow redirects, fetch banner + alias clb='curl -L -I' # see only response headers from a get request alias clhead='curl -D - -so /dev/null' fi diff --git a/aliases/available/dnf.aliases.bash b/aliases/available/dnf.aliases.bash new file mode 100644 index 0000000000..25007c23c7 --- /dev/null +++ b/aliases/available/dnf.aliases.bash @@ -0,0 +1,17 @@ +# shellcheck shell=bash +about-alias 'dnf aliases for fedora 22+ distros' + +alias dnfl="dnf list" # List packages +alias dnfli="dnf list installed" # List installed packages +alias dnfgl="dnf grouplist" # List package groups +alias dnfmc="dnf makecache" # Generate metadata cache +alias dnfp="dnf info" # Show package information +alias dnfs="dnf search" # Search package + +alias dnfu="sudo dnf upgrade" # Upgrade package +alias dnfi="sudo dnf install" # Install package +alias dnfri='sudo dnf reinstall' # Reinstall package +alias dnfgi="sudo dnf groupinstall" # Install package group +alias dnfr="sudo dnf remove" # Remove package +alias dnfgr="sudo dnf groupremove" # Remove package group +alias dnfc="sudo dnf clean all" # Clean cache diff --git a/aliases/available/docker-compose.aliases.bash b/aliases/available/docker-compose.aliases.bash index 01eb62fbcb..a2f637c006 100644 --- a/aliases/available/docker-compose.aliases.bash +++ b/aliases/available/docker-compose.aliases.bash @@ -1,6 +1,10 @@ -cite 'about-alias' +# shellcheck shell=bash about-alias 'docker-compose abbreviations' alias dco="docker-compose" + +# Defined in the `docker-compose` plugin, please check there for details. alias dcofresh="docker-compose-fresh" alias dcol="docker-compose logs -f --tail 100" +alias dcou="docker-compose up" +alias dcouns="dcou --no-start" diff --git a/aliases/available/docker.aliases.bash b/aliases/available/docker.aliases.bash index e3601d6f49..1c49207f49 100644 --- a/aliases/available/docker.aliases.bash +++ b/aliases/available/docker.aliases.bash @@ -1,27 +1,43 @@ -cite 'about-alias' +# shellcheck shell=bash about-alias 'docker abbreviations' -alias dklc='docker ps -l' # List last Docker container -alias dklcid='docker ps -l -q' # List last Docker container ID -alias dklcip='docker inspect -f "{{.NetworkSettings.IPAddress}}" $(docker ps -l -q)' # Get IP of last Docker container -alias dkps='docker ps' # List running Docker containers -alias dkpsa='docker ps -a' # List all Docker containers -alias dki='docker images' # List Docker images -alias dkrmac='docker rm $(docker ps -a -q)' # Delete all Docker containers -alias dkrmlc='docker-remove-most-recent-container' # Delete most recent (i.e., last) Docker container +alias dk='docker' +alias dklc='docker ps -l' # List last Docker container +alias dklcid='docker ps -l -q' # List last Docker container ID +alias dklcip='docker inspect -f "{{.NetworkSettings.IPAddress}}" $(docker ps -l -q)' # Get IP of last Docker container +alias dkps='docker ps' # List running Docker containers +alias dkpsa='docker ps -a' # List all Docker containers +alias dki='docker images' # List Docker images +alias dkrmac='docker rm $(docker ps -a -q)' # Delete all Docker containers case $OSTYPE in - darwin*|*bsd*|*BSD*) - alias dkrmui='docker images -q -f dangling=true | xargs docker rmi' # Delete all untagged Docker images - ;; - *) - alias dkrmui='docker images -q -f dangling=true | xargs -r docker rmi' # Delete all untagged Docker images - ;; + darwin* | *bsd* | *BSD*) + alias dkrmui='docker images -q -f dangling=true | xargs docker rmi' # Delete all untagged Docker images + ;; + *) + alias dkrmui='docker images -q -f dangling=true | xargs -r docker rmi' # Delete all untagged Docker images + ;; esac -alias dkrmall='docker-remove-stale-assets' # Delete all untagged images and exited containers -alias dkrmli='docker-remove-most-recent-image' # Delete most recent (i.e., last) Docker image -alias dkrmi='docker-remove-images' # Delete images for supplied IDs or all if no IDs are passed as arguments -alias dkideps='docker-image-dependencies' # Output a graph of image dependencies using Graphiz -alias dkre='docker-runtime-environment' # List environmental variables of the supplied image ID -alias dkelc='docker exec -it `dklcid` bash' # Enter last container (works with Docker 1.3 and above) +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 + alias dkrmli='docker-remove-most-recent-image' # Delete most recent (i.e., last) Docker image + alias dkrmi='docker-remove-images' # Delete images for supplied IDs or all if no IDs are passed as arguments + alias dkideps='docker-image-dependencies' # Output a graph of image dependencies using Graphiz + alias dkre='docker-runtime-environment' # List environmental variables of the supplied image ID +fi +alias dkelc='docker exec -it $(dklcid) bash --login' # Enter last container (works with Docker 1.3 and above) +alias dkrmflast='docker rm -f $(dklcid)' +alias dkbash='dkelc' +alias dkex='docker exec -it ' # Useful to run any commands into container without leaving host +alias dkri='docker run --rm -i ' +alias dkric='docker run --rm -i -v $PWD:/cwd -w /cwd ' +alias dkrit='docker run --rm -it ' +alias dkritc='docker run --rm -it -v $PWD:/cwd -w /cwd ' + +# Added more recent cleanup options from newer docker versions +alias dkip='docker image prune -a -f' +alias dkvp='docker volume prune -f' +alias dksp='docker system prune -a -f' diff --git a/aliases/available/emacs.aliases.bash b/aliases/available/emacs.aliases.bash index f8e1259b80..a4e4111ada 100644 --- a/aliases/available/emacs.aliases.bash +++ b/aliases/available/emacs.aliases.bash @@ -1,16 +1,16 @@ -cite 'about-alias' +# shellcheck shell=bash about-alias 'emacs editor' case $OSTYPE in - linux*) - alias em='emacs' - alias en='emacs -nw' - alias e='emacsclient -n' - alias et='emacsclient -t' - alias ed='emacs --daemon' - alias E='SUDO_EDITOR=emacsclient sudo -e' - ;; - darwin*) - alias em='open -a emacs' - ;; + linux*) + alias em='emacs' + alias en='emacs -nw' + alias e='emacsclient -n' + alias et='emacsclient -t' + alias ed='emacs --daemon' + alias E='SUDO_EDITOR=emacsclient sudo -e' + ;; + darwin*) + alias em='open -a emacs' + ;; esac diff --git a/aliases/available/fuck.aliases.bash b/aliases/available/fuck.aliases.bash index 54648931c3..4cfa52d81b 100644 --- a/aliases/available/fuck.aliases.bash +++ b/aliases/available/fuck.aliases.bash @@ -1,3 +1,10 @@ -# https://github.com/nvbn/thefuck -alias fuck='eval $(thefuck $(fc -ln -1))' -alias please='fuck' +# shellcheck shell=bash +about-alias 'fuck/please to retry last command with sudo' + +# Play nicely with 'thefuck' plugin +if ! _command_exists fuck; then + alias fuck='sudo $(fc -ln -1)' +fi +alias please=fuck +alias plz=please +alias fucking=sudo diff --git a/aliases/available/general.aliases.bash b/aliases/available/general.aliases.bash index c3455525fd..2511aab8a9 100644 --- a/aliases/available/general.aliases.bash +++ b/aliases/available/general.aliases.bash @@ -1,51 +1,45 @@ -cite about-alias +# shellcheck shell=bash about-alias 'general aliases' -if ls --color -d . &> /dev/null -then - alias ls="ls --color=auto" -elif ls -G -d . &> /dev/null -then - alias ls='ls -G' # Compact view, show colors +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 # List directory contents alias sl=ls -alias la='ls -AF' # Compact view, show hidden +alias la='ls -AF' # Compact view, show hidden alias ll='ls -al' alias l='ls -a' alias l1='ls -1' +alias lf='ls -F' -alias _="sudo" +alias _='sudo' # Shortcuts to edit startup files -alias vbrc="vim ~/.bashrc" -alias vbpf="vim ~/.bash_profile" +alias vbrc='${VISUAL:-vim} ~/.bashrc' +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 grep --color=auto "a" "${BASH_IT}/"*.md &> /dev/null -then - alias grep='grep --color=auto' - export GREP_COLOR='1;33' +if command grep --color=auto "a" "${BASH_IT?}"/*.md &> /dev/null; then + alias grep='grep --color=auto' fi -if which gshuf &> /dev/null -then - alias shuf=gshuf +if _command_exists gshuf; then + alias shuf=gshuf fi alias c='clear' -alias k='clear' alias cls='clear' -alias edit="$EDITOR" -alias pager="$PAGER" +alias edit='${EDITOR:-${ALTERNATE_EDITOR:-nano}}' +alias pager='${PAGER:=less}' alias q='exit' -alias irc="${IRC_CLIENT:=irc}" +alias irc='${IRC_CLIENT:=irc}' # Language aliases alias rb='ruby' @@ -66,49 +60,33 @@ alias -- -='cd -' # Go back alias h='history' # Tree -if [ ! -x "$(which tree 2>/dev/null)" ] -then - alias tree="find . -print | sed -e 's;[^/]*/;|____;g;s;____|; |;g'" +if ! _command_exists tree; then + alias tree="find . -print | sed -e 's;[^/]*/;|____;g;s;____|; |;g'" fi # Directory alias md='mkdir -p' alias rd='rmdir' -# Common misspellings of bash-it -alias shit='bash-it' -alias batshit='bash-it' -alias bashit='bash-it' -alias batbsh='bash-it' -alias babsh='bash-it' -alias bash_it='bash-it' -alias bash_ti='bash-it' - -# Additional bash-it aliases for help/show -alias bshsa='bash-it show aliases' -alias bshsc='bash-it show completions' -alias bshsp='bash-it show plugins' -alias bshha='bash-it help aliases' -alias bshhc='bash-it help completions' -alias bshhp='bash-it help plugins' -alias bshsch="bash-it search" -alias bshenp="bash-it enable plugin" -alias bshena="bash-it enable alias" -alias bshenc="bash-it enable completion" - # Shorten extract -alias xt="extract" - -# sudo vim -alias svim="sudo vim" +alias xt='extract' # Display whatever file is regular file or folder -catt() { - for i in "$@"; do - if [ -d "$i" ]; then - ls "$i" - else - cat "$i" - fi - done +function catt() { + for i in "$@"; do + if [[ -d "$i" ]]; then + ls "$i" + else + cat "$i" + fi + done } + +# The Bash-it aliases were moved to the `bash-it.aliases.bash` file. The intent of this +# is to keep the script readable and less bloated. If you don't need to use +# the `general` aliases, but you want the Bash-it aliases, you can disable the `general` +# aliases and enable just the ones for Bash-it explicitly: +# bash-it disable alias general +# bash-it enable alias bash-it +# shellcheck source-path=SCRIPTDIR +source "$BASH_IT/aliases/available/bash-it.aliases.bash" diff --git a/aliases/available/git.aliases.bash b/aliases/available/git.aliases.bash index 169fe7b8b7..5572c9322c 100644 --- a/aliases/available/git.aliases.bash +++ b/aliases/available/git.aliases.bash @@ -1,88 +1,212 @@ -cite 'about-alias' +# shellcheck shell=bash about-alias 'common git abbreviations' -# Aliases -alias gcl='git clone' +alias g='git' +alias get='git' + +# add alias ga='git add' -alias grm='git rm' -alias gap='git add -p' alias gall='git add -A' +alias gap='git add -p' +alias gav='git add -v' + +# branch +alias gb='git branch' +alias gba='git branch --all' +alias gbd='git branch -d' +alias gbD='git branch -D' +alias gbl='git branch --list' +alias gbla='git branch --list --all' +alias gblr='git branch --list --remotes' +alias gbm='git branch --move' +alias gbr='git branch --remotes' +alias gbt='git branch --track' +alias gdel='git branch -D' + +# for-each-ref +alias gbc='git for-each-ref --format="%(authorname) %09 %(if)%(HEAD)%(then)*%(else)%(refname:short)%(end) %09 %(creatordate)" refs/remotes/ --sort=authorname DESC' # FROM https://stackoverflow.com/a/58623139/10362396 + +# commit +alias gc='git commit -v' +alias gca='git commit -v -a' +alias gcaa='git commit -a --amend -C HEAD' # Add uncommitted and unstaged changes to the last commit +alias gcam='git commit -v -am' +alias gcamd='git commit --amend' +alias gcm='git commit -v -m' +alias gci='git commit --interactive' +alias gcsam='git commit -S -am' + +# checkout +alias gcb='git checkout -b' +alias gco='git checkout' +alias gcob='git checkout -b' +alias gcobu='git checkout -b ${USER}/' +alias gcom='git checkout $(get_default_branch)' +alias gcpd='git checkout $(get_default_branch); git pull; git branch -D' +alias gct='git checkout --track' + +# clone +alias gcl='git clone' + +# clean +alias gclean='git clean -fd' + +# cherry-pick +alias gcp='git cherry-pick' +alias gcpx='git cherry-pick -x' + +# diff +alias gd='git diff' +alias gds='git diff --staged' +alias gdt='git difftool' + +# archive +alias gexport='git archive --format zip --output' + +# fetch alias gf='git fetch --all --prune' alias gft='git fetch --all --prune --tags' -alias gfv='git fetch --all --prune --verbose' alias gftv='git fetch --all --prune --tags --verbose' -alias gus='git reset HEAD' -alias gpristine='git reset --hard && git clean -dfx' -alias gclean='git clean -fd' -alias gm="git merge" -alias gmv='git mv' -alias g='git' -alias get='git' -alias gst='git status' -alias gs='git status' -alias gss='git status -s' -alias gsu='git submodule update --init --recursive' -alias gl='git pull' -alias glum='git pull upstream master' -alias gpr='git pull --rebase' -alias gpp='git pull && git push' +alias gfv='git fetch --all --prune --verbose' +alias gmu='git fetch origin -v; git fetch upstream -v; git merge upstream/$(get_default_branch)' alias gup='git fetch && git rebase' + +# log +alias gg='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' +alias ggf='git log --graph --date=short --pretty=format:'\''%C(auto)%h %Cgreen%an%Creset %Cblue%cd%Creset %C(auto)%d %s'\''' +alias ggs='gg --stat' +alias ggup='git log --branches --not --remotes --no-walk --decorate --oneline' # FROM https://stackoverflow.com/questions/39220870/in-git-list-names-of-branches-with-unpushed-commits +alias gll='git log --graph --pretty=oneline --abbrev-commit' +alias gnew='git log HEAD@{1}..HEAD@{0}' # Show commits since last pull, see http://blogs.atlassian.com/2014/10/advanced-git-aliases/ +alias gwc='git whatchanged' + +# ls-files +alias gu='git ls-files . --exclude-standard --others' # Show untracked files +alias glsut='gu' +alias glsum='git diff --name-only --diff-filter=U' # Show unmerged (conflicted) files + +# gui +alias ggui='git gui' + +# home +alias ghm='cd "$(git rev-parse --show-toplevel)"' # Git home +# appendage to ghm +if ! _command_exists gh; then + alias gh='ghm' +fi + +# merge +alias gm='git merge' + +# mv +alias gmv='git mv' + +# patch +alias gpatch='git format-patch -1' + +# push alias gp='git push' -alias gpo='git push origin' +alias gpd='git push --delete' +alias gpf='git push --force' +alias gpo='git push origin HEAD' +alias gpom='git push origin $(get_default_branch)' alias gpu='git push --set-upstream' +alias gpunch='git push --force-with-lease' alias gpuo='git push --set-upstream origin' -alias gpom='git push origin master' +alias gpuoc='git push --set-upstream origin $(git symbolic-ref --short HEAD)' + +# pull +alias gl='git pull' +alias glum='git pull upstream $(get_default_branch)' +alias gpl='git pull' +alias gpp='git pull && git push' +alias gpr='git pull --rebase' + +# remote alias gr='git remote' -alias grv='git remote -v' alias gra='git remote add' -alias gd='git diff' -alias gdv='git diff -w "$@" | vim -R -' -alias gc='git commit -v' -alias gca='git commit -v -a' -alias gcm='git commit -v -m' -alias gcam="git commit -v -am" -alias gci='git commit --interactive' -alias gb='git branch' -alias gba='git branch -a' -alias gbt='git branch --track' -alias gbm='git branch -m' -alias gbd='git branch -d' -alias gbD='git branch -D' +alias grv='git remote -v' + +# rm +alias grm='git rm' + +# rebase +alias grb='git rebase' +alias grbc='git rebase --continue' +alias grm='git rebase $(get_default_branch)' +alias grmi='git rebase $(get_default_branch) -i' +alias grma='GIT_SEQUENCE_EDITOR=: git rebase $(get_default_branch) -i --autosquash' +alias gprom='git fetch origin $(get_default_branch) && git rebase origin/$(get_default_branch) && git update-ref refs/heads/$(get_default_branch) origin/$(get_default_branch)' # Rebase with latest remote + +# reset +alias gus='git reset HEAD' +alias gpristine='git reset --hard && git clean -dfx' + +# status +alias gs='git status' +alias gss='git status -s' + +# shortlog alias gcount='git shortlog -sn' -alias gcp='git cherry-pick' -alias gco='git checkout' -alias gcom='git checkout master' -alias gcb='git checkout -b' -alias gcob='git checkout -b' -alias gct='git checkout --track' -alias gexport='git archive --format zip --output' -alias gdel='git branch -D' -alias gmu='git fetch origin -v; git fetch upstream -v; git merge upstream/master' -alias gll='git log --graph --pretty=oneline --abbrev-commit' -alias gg="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" -alias ggs="gg --stat" -alias gsl="git shortlog -sn" -alias gwc="git whatchanged" -alias gt="git tag" -alias gta="git tag -a" -alias gtd="git tag -d" -alias gtl="git tag -l" -# From http://blogs.atlassian.com/2014/10/advanced-git-aliases/ -# Show commits since last pull -alias gnew="git log HEAD@{1}..HEAD@{0}" -# Add uncommitted and unstaged changes to the last commit -alias gcaa="git commit -a --amend -C HEAD" -alias ggui="git gui" -alias gcsam="git commit -S -am" -alias gstd="git stash drop" -alias gstl="git stash list" -alias gh='cd "$(git rev-parse --show-toplevel)"' +alias gsl='git shortlog -sn' + +# show +alias gsh='git show' + +# svn +alias gsd='git svn dcommit' +alias gsr='git svn rebase' # Git SVN + +# stash +alias gst='git stash' +alias gstb='git stash branch' +alias gstd='git stash drop' +alias gstl='git stash list' +alias gstp='git stash pop' # kept due to long-standing usage +alias gstpo='git stash pop' # recommended for it's symmetry with gstpu (push) + +## 'stash push' introduced in git v2.13.2 +alias gstpu='git stash push' +alias gstpum='git stash push -m' + +## 'stash save' deprecated since git v2.16.0, alias is now push +alias gsts='git stash push' +alias gstsm='git stash push -m' + +# submodules +alias gsu='git submodule update --init --recursive' + +# switch +# these aliases requires git v2.23+ +alias gsw='git switch' +alias gswc='git switch --create' +alias gswm='git switch $(get_default_branch)' +alias gswt='git switch --track' + +# tag +alias gt='git tag' +alias gta='git tag -a' +alias gtd='git tag -d' +alias gtl='git tag -l' case $OSTYPE in - darwin*) - alias gtls="git tag -l | gsort -V" - ;; - *) - alias gtls='git tag -l | sort -V' - ;; + darwin*) + alias gtls="git tag -l | gsort -V" + ;; + *) + alias gtls='git tag -l | sort -V' + ;; esac + +# functions +function gdv() { + git diff --ignore-all-space "$@" | vim -R - +} + +function get_default_branch() { + if git branch | grep -q '^. main\s*$'; then + echo main + else + echo master + fi +} diff --git a/aliases/available/gitsvn.aliases.bash b/aliases/available/gitsvn.aliases.bash index feb608beef..3c578445a7 100644 --- a/aliases/available/gitsvn.aliases.bash +++ b/aliases/available/gitsvn.aliases.bash @@ -1,4 +1,4 @@ -cite 'about-alias' +# shellcheck shell=bash about-alias 'common git-svn abbreviations' # Aliases diff --git a/aliases/available/heroku.aliases.bash b/aliases/available/heroku.aliases.bash index a749d4247d..4c82259438 100644 --- a/aliases/available/heroku.aliases.bash +++ b/aliases/available/heroku.aliases.bash @@ -1,4 +1,4 @@ -cite 'about-alias' +# shellcheck shell=bash about-alias 'heroku task abbreviations' # heroku diff --git a/aliases/available/hg.aliases.bash b/aliases/available/hg.aliases.bash index eea819ff8a..d9101a03c4 100644 --- a/aliases/available/hg.aliases.bash +++ b/aliases/available/hg.aliases.bash @@ -1,4 +1,4 @@ -cite 'about-alias' +# shellcheck shell=bash about-alias 'mercurial abbreviations' alias hs='hg status' diff --git a/aliases/available/homebrew-cask.aliases.bash b/aliases/available/homebrew-cask.aliases.bash index 090622b040..43d206d4a9 100644 --- a/aliases/available/homebrew-cask.aliases.bash +++ b/aliases/available/homebrew-cask.aliases.bash @@ -1,13 +1,10 @@ -# Some aliases for Homebrew Cask - -cite 'about-alias' -about-alias 'homebrew-cask abbreviations' +# shellcheck shell=bash +about-alias 'Some aliases for Homebrew Cask' alias bcin='brew cask install' alias bcrm='brew cask uninstall' alias bczp='brew cask zap' alias bccl='brew cask cleanup' -alias bcsr='brew cask search' alias bcls='brew cask list' alias bcinf='brew cask info' alias bcdr='brew cask doctor' diff --git a/aliases/available/homebrew.aliases.bash b/aliases/available/homebrew.aliases.bash index 239d884b1d..f35a38d382 100644 --- a/aliases/available/homebrew.aliases.bash +++ b/aliases/available/homebrew.aliases.bash @@ -1,10 +1,7 @@ -# Some aliases for Homebrew - -cite 'about-alias' -about-alias 'homebrew abbreviations' +# shellcheck shell=bash +about-alias 'Some aliases for Homebrew' alias bup='brew update && brew upgrade' -alias bupc='brew update && brew upgrade --cleanup' alias bout='brew outdated' alias bin='brew install' alias brm='brew uninstall' diff --git a/aliases/available/homesick.aliases.bash b/aliases/available/homesick.aliases.bash index 548efc3b38..00101eedb2 100644 --- a/aliases/available/homesick.aliases.bash +++ b/aliases/available/homesick.aliases.bash @@ -1,4 +1,4 @@ -cite 'about-alias' +# shellcheck shell=bash about-alias 'homesick aliases' # Aliases @@ -19,6 +19,5 @@ alias sikpsh="homesick push dotfiles" alias sikrc="homesick rc dotfiles" alias sikpth="homesick show_path dotfiles" alias sikst="homesick status dotfiles" -alias siktrk="homesick track $1 dotfiles" alias sikulnk="homesick unlink dotfiles" alias sikv="homesick version" diff --git a/aliases/available/jitsu.aliases.bash b/aliases/available/jitsu.aliases.bash index 91e96849d0..f056e74989 100644 --- a/aliases/available/jitsu.aliases.bash +++ b/aliases/available/jitsu.aliases.bash @@ -1,4 +1,4 @@ -cite 'about-alias' +# shellcheck shell=bash about-alias 'jitsu task abbreviations' # jitsu diff --git a/aliases/available/kubectl.aliases.bash b/aliases/available/kubectl.aliases.bash new file mode 100644 index 0000000000..ce01bdafcf --- /dev/null +++ b/aliases/available/kubectl.aliases.bash @@ -0,0 +1,16 @@ +# shellcheck shell=bash +about-alias 'kubectl aliases' + +if _command_exists kubectl; then + alias kc='kubectl' + alias kcgp='kubectl get pods' + alias kcgd='kubectl get deployments' + alias kcgn='kubectl get nodes' + alias kcdp='kubectl describe pod' + alias kcdd='kubectl describe deployment' + alias kcdn='kubectl describe node' + alias kcgpan='kubectl get pods --all-namespaces' + alias kcgdan='kubectl get deployments --all-namespaces' + # launches a disposable netshoot pod in the k8s cluster + alias kcnetshoot='kubectl run netshoot-$(date +%s) --rm -i --tty --image nicolaka/netshoot -- /bin/bash' +fi diff --git a/aliases/available/laravel.aliases.bash b/aliases/available/laravel.aliases.bash index 75a51a01b8..50a9749f91 100644 --- a/aliases/available/laravel.aliases.bash +++ b/aliases/available/laravel.aliases.bash @@ -1,9 +1,9 @@ -cite 'about-alias' +# shellcheck shell=bash about-alias 'laravel artisan abbreviations' # A list of useful laravel aliases -alias laravel="${HOME}/.composer/vendor/bin/laravel" +alias laravel='${HOME?}/.composer/vendor/bin/laravel' # asset alias a:apub='php artisan asset:publish' diff --git a/aliases/available/maven.aliases.bash b/aliases/available/maven.aliases.bash index 4cd89d2752..737826eb47 100644 --- a/aliases/available/maven.aliases.bash +++ b/aliases/available/maven.aliases.bash @@ -1,11 +1,14 @@ -cite 'about-alias' +# shellcheck shell=bash about-alias 'maven abbreviations' alias mci='mvn clean install' alias mi='mvn install' +alias mcp='mvn clean package' +alias mp='mvn package' alias mrprep='mvn release:prepare' alias mrperf='mvn release:perform' alias mrrb='mvn release:rollback' alias mdep='mvn dependency:tree' alias mpom='mvn help:effective-pom' alias mcisk='mci -Dmaven.test.skip=true' +alias mcpsk='mcp -Dmaven.test.skip=true' diff --git a/aliases/available/msys2.aliases.bash b/aliases/available/msys2.aliases.bash new file mode 100644 index 0000000000..da41cc82a3 --- /dev/null +++ b/aliases/available/msys2.aliases.bash @@ -0,0 +1,14 @@ +# shellcheck shell=bash +about-alias 'MSYS2 aliases' + +LS_COMMON="-hG" +LS_COMMON="$LS_COMMON --color=auto" +LS_COMMON="$LS_COMMON -I NTUSER.DAT\* -I ntuser.dat\*" + +# alias +# setup the main ls alias if we've established common args +alias ls='command ls ${LS_COMMON:-}' +alias ll="ls -l" +alias la="ls -a" +alias lal="ll -a" +alias lf="ls -F" diff --git a/aliases/available/node.aliases.bash b/aliases/available/node.aliases.bash new file mode 100644 index 0000000000..a9e29743b4 --- /dev/null +++ b/aliases/available/node.aliases.bash @@ -0,0 +1,8 @@ +# shellcheck shell=bash +about-alias 'the Node.js environment aliases' + +# alias to setup nodejs development environment +alias node-dev='export NODE_ENV=development' + +# alias to setup nodejs production environment +alias node-prod='export NODE_ENV=production' diff --git a/aliases/available/npm.aliases.bash b/aliases/available/npm.aliases.bash index 2266fe2218..27cf5c9f6a 100644 --- a/aliases/available/npm.aliases.bash +++ b/aliases/available/npm.aliases.bash @@ -1,7 +1,9 @@ -cite 'about-alias' +# shellcheck shell=bash about-alias 'common npm abbreviations' # Aliases + +# npm alias ni='npm install' alias nis='npm install --save' alias nid='npm install --save-dev' @@ -20,3 +22,22 @@ alias nud='npm update' alias nr='npm run' alias nls='npm list --depth=0 2>/dev/null' alias nlsg='npm list -g --depth=0 2>/dev/null' +alias nt='npm test' + +# npx +alias nx='npx' +alias nxplease='npx $(fc -ln -1)' +alias nxn='npx --no-install ' +alias nxp='npx -p ' +alias nxnp='npx --no-install -p ' +alias nxq='npx -q ' +alias nxnq='npx --no-install -q ' +alias nxqp='npx -q -p ' +alias nxnqp='npx --no-install -q -p ' +alias nxni='npx --no-install --ignore-existing ' +alias nxip='npx --ignore-existing -p ' +alias nxnip='npx --no-install --ignore-existing -p ' +alias nxqi='npx -q --ignore-existing ' +alias nxniq='npx --no-install --ignore-existing -q ' +alias nxiqp='npx --ignore-existing -q -p ' +alias nxniqp='npx --no-install --ignore-existing -q -p ' diff --git a/aliases/available/osx.aliases.bash b/aliases/available/osx.aliases.bash index 5e30bc7c20..0a16c06f61 100644 --- a/aliases/available/osx.aliases.bash +++ b/aliases/available/osx.aliases.bash @@ -1,27 +1,28 @@ -cite 'about-alias' +# shellcheck shell=bash about-alias 'osx-specific aliases' # Desktop Programs -alias fireworks="open -a '/Applications/Adobe Fireworks CS3/Adobe Fireworks CS3.app'" -alias photoshop="open -a '/Applications/Adobe Photoshop CS3/Adobe Photoshop.app'" -alias preview="open -a '$PREVIEW'" -alias xcode="open -a '/Applications/XCode.app'" -alias filemerge="open -a '/Developer/Applications/Utilities/FileMerge.app'" -alias safari="open -a safari" -alias firefox="open -a firefox" -alias chrome="open -a google\ chrome" -alias chromium="open -a chromium" -alias dashcode="open -a dashcode" +alias fireworks='open -a "/Applications/Adobe Fireworks CS3/Adobe Fireworks CS3.app"' +alias photoshop='open -a "/Applications/Adobe Photoshop CS3/Adobe Photoshop.app"' +alias preview='open -a "${PREVIEW?}"' +alias xcode='open -a "/Applications/XCode.app"' +alias filemerge='open -a "/Developer/Applications/Utilities/FileMerge.app"' +alias safari='open -a safari' +alias firefox='open -a firefox' +alias chrome='open -a "Google Chrome"' +alias chromium='open -a chromium' +alias brave='open -a "Brave Browser"' +alias dashcode='open -a dashcode' alias f='open -a Finder ' alias fh='open -a Finder .' alias textedit='open -a TextEdit' alias hex='open -a "Hex Fiend"' alias skype='open -a Skype' alias mou='open -a Mou' -alias subl='open -a Sublime\ Text' +alias subl='open -a "Sublime Text"' -if [ -s /usr/bin/firefox ] ; then - unalias firefox +if [[ -s /usr/bin/firefox ]]; then + unalias firefox fi # Requires growlnotify, which can be found in the Growl DMG under "Extras" @@ -37,19 +38,20 @@ alias whotunes='lsof -r 2 -n -P -F n -c iTunes -a -i TCP@`hostname`:3689' alias flush='dscacheutil -flushcache' # Show/hide hidden files (for Mac OS X Mavericks) -alias showhidden="defaults write com.apple.finder AppleShowAllFiles TRUE" -alias hidehidden="defaults write com.apple.finder AppleShowAllFiles FALSE" +alias showhidden='defaults write com.apple.finder AppleShowAllFiles TRUE' +alias hidehidden='defaults write com.apple.finder AppleShowAllFiles FALSE' # From http://apple.stackexchange.com/questions/110343/copy-last-command-in-terminal -alias copyLastCmd='fc -ln -1 | awk '\''{$1=$1}1'\'' ORS='\'''\'' | pbcopy' +# shellcheck disable=SC2142 # The quoting confuses `shellcheck`... +alias copyLastCmd="fc -ln -1 | awk '{\$1=\$1}1' ORS='' | pbcopy" # Use Finder's Quick Look on a file (^C or space to close) alias ql='qlmanage -p 2>/dev/null' # Mute/Unmute the system volume. Plays nice with all other volume settings. -alias mute="osascript -e 'set volume output muted true'" -alias unmute="osascript -e 'set volume output muted false'" +alias mute='osascript -e "set volume output muted true"' +alias unmute='osascript -e "set volume output muted false"' # Pin to the tail of long commands for an audible alert after long processes ## curl http://downloads.com/hugefile.zip; lmk -alias lmk="say 'Process complete.'" +alias lmk='say "Process complete."' diff --git a/aliases/available/phoenix.aliases.bash b/aliases/available/phoenix.aliases.bash index 2a4ec5e148..08cef4f406 100644 --- a/aliases/available/phoenix.aliases.bash +++ b/aliases/available/phoenix.aliases.bash @@ -1,9 +1,9 @@ -cite 'about-alias' +# shellcheck shell=bash about-alias 'phoenix abbreviations' # Phoenix Commands alias i='iex' -alias ips='iex -S mix phoenix.server' +alias ips='iex -S mix phx.server' alias ism='iex -S mix' alias m='mix' alias mab='mix archive.build' @@ -32,14 +32,14 @@ alias mho='mix hex.outdated' alias mlh='mix local.hex' alias mn='mix new' alias mns='mix new --sup' -alias mpgc='mix phoenix.gen.channel' -alias mpgh='mix phoenix.gen.html' -alias mpgj='mix phoenix.gen.json' -alias mpgm='mix phoenix.gen.model' -alias mpgs='mix phoenix.gen.secret' -alias mpn='mix phoenix.new' -alias mpr='mix phoenix.routes' -alias mps='mix phoenix.server' +alias mpgc='mix phx.gen.channel' +alias mpgh='mix phx.gen.html' +alias mpgj='mix phx.gen.json' +alias mpgm='mix phx.gen.model' +alias mpgs='mix phx.gen.secret' +alias mpn='mix phx.new' +alias mpr='mix phx.routes' +alias mps='mix phx.server' alias mr='mix run' alias mrnh='mix run --no-halt' alias mrl='mix release' diff --git a/aliases/available/puppet.aliases.bash b/aliases/available/puppet.aliases.bash new file mode 100644 index 0000000000..c92d13b1f7 --- /dev/null +++ b/aliases/available/puppet.aliases.bash @@ -0,0 +1,9 @@ +# shellcheck shell=bash +about-alias 'puppet aliases' + +# Aliases +alias pupval="puppet parser validate *.pp" +alias puplint="puppet-lint *.pp" +alias pupagt="puppet agent -t" +alias pupagtd="puppet agent -t --debug" +alias pupapp="puppet apply" diff --git a/aliases/available/pyrocms.aliases.bash b/aliases/available/pyrocms.aliases.bash index d19dff9149..77865a23a3 100644 --- a/aliases/available/pyrocms.aliases.bash +++ b/aliases/available/pyrocms.aliases.bash @@ -1,4 +1,4 @@ -cite 'about-alias' +# shellcheck shell=bash about-alias 'pyrocms abbreviations' ### @@ -7,146 +7,146 @@ about-alias 'pyrocms abbreviations' ### # general -alias a:cl="php artisan clear-compiled" # Remove the compiled class file -alias a:d="php artisan down" # Put the application into maintenance mode -alias a:e="php artisan env" # Display the current framework environment -alias a:h="php artisan help" # Displays help for a command -alias a:i="php artisan install" # Install the Streams Platform. -alias a:ls="php artisan list" # Lists commands -alias a:mg="php artisan migrate" # Run the database migrations -alias a:op="php artisan optimize" # Optimize the framework for better performance (deprecated) -alias a:pr="php artisan preset" # Swap the front-end scaffolding for the application -alias a:s="php artisan serve" # Serve the application on the PHP development server -alias a:u="php artisan up" # Bring the application out of maintenance mode +alias a:cl="php artisan clear-compiled" # Remove the compiled class file +alias a:d="php artisan down" # Put the application into maintenance mode +alias a:e="php artisan env" # Display the current framework environment +alias a:h="php artisan help" # Displays help for a command +alias a:i="php artisan install" # Install the Streams Platform. +alias a:ls="php artisan list" # Lists commands +alias a:mg="php artisan migrate" # Run the database migrations +alias a:op="php artisan optimize" # Optimize the framework for better performance (deprecated) +alias a:pr="php artisan preset" # Swap the front-end scaffolding for the application +alias a:s="php artisan serve" # Serve the application on the PHP development server +alias a:u="php artisan up" # Bring the application out of maintenance mode # addon -alias a:ad:i="php artisan addon:install" # Install an addon. -alias a:ad:p="php artisan addon:publish" # Publish an the configuration and translations for an addon. -alias a:ad:r="php artisan addon:reinstall" # Reinstall an addon. -alias a:ad:u="php artisan addon:uninstall" # Uninstall an addon. +alias a:ad:i="php artisan addon:install" # Install an addon. +alias a:ad:p="php artisan addon:publish" # Publish an the configuration and translations for an addon. +alias a:ad:r="php artisan addon:reinstall" # Reinstall an addon. +alias a:ad:u="php artisan addon:uninstall" # Uninstall an addon. # app -alias a:ap:n="php artisan app:name" # Set the application namespace -alias a:ap:p="php artisan app:publish" # Publish general application override files. +alias a:ap:n="php artisan app:name" # Set the application namespace +alias a:ap:p="php artisan app:publish" # Publish general application override files. # assets -alias a:as:cl="php artisan assets:clear" # Clear compiled public assets. +alias a:as:cl="php artisan assets:clear" # Clear compiled public assets. # auth -alias a:au:clrs="php artisan auth:clear-resets" # Flush expired password reset tokens +alias a:au:clrs="php artisan auth:clear-resets" # Flush expired password reset tokens # cache -alias a:ca:cl="php artisan cache:clear" # Flush the application cache -alias a:ca:f="php artisan cache:forget" # Remove an item from the cache -alias a:ca:t="php artisan cache:table" # Create a migration for the cache database table +alias a:ca:cl="php artisan cache:clear" # Flush the application cache +alias a:ca:f="php artisan cache:forget" # Remove an item from the cache +alias a:ca:t="php artisan cache:table" # Create a migration for the cache database table # config -alias a:co:ca="php artisan config:cache" # Create a cache file for faster configuration loading -alias a:co:cl="php artisan config:clear" # Remove the configuration cache file +alias a:co:ca="php artisan config:cache" # Create a cache file for faster configuration loading +alias a:co:cl="php artisan config:clear" # Remove the configuration cache file # db -alias a:db:s="php artisan db:seed" # Seed the database with records +alias a:db:s="php artisan db:seed" # Seed the database with records # env -alias a:en:s="php artisan env:set" # Set an environmental value. +alias a:en:s="php artisan env:set" # Set an environmental value. # event -alias a:ev:g="php artisan event:generate" # Generate the missing events and listeners based on registration +alias a:ev:g="php artisan event:generate" # Generate the missing events and listeners based on registration # extension -alias a:ex:i="php artisan extension:install" # Install a extension. -alias a:ex:r="php artisan extension:reinstall" # Reinstall a extension. -alias a:ex:u="php artisan extension:uninstall" # Uninstall a extension. +alias a:ex:i="php artisan extension:install" # Install a extension. +alias a:ex:r="php artisan extension:reinstall" # Reinstall a extension. +alias a:ex:u="php artisan extension:uninstall" # Uninstall a extension. # files -alias a:fi:cl="php artisan files:clean" # Clean missing files from the files table. +alias a:fi:cl="php artisan files:clean" # Clean missing files from the files table. # key -alias a:ke:g="php artisan key:generate" # Set the application key +alias a:ke:g="php artisan key:generate" # Set the application key # make -alias a:mk:ad="php artisan make:addon" # Create a new addon. -alias a:mk:au="php artisan make:auth" # Scaffold basic login and registration views and routes -alias a:mk:cm="php artisan make:command" # Create a new Artisan command -alias a:mk:ct="php artisan make:controller" # Create a new controller class -alias a:mk:ev="php artisan make:event" # Create a new event class -alias a:mk:fa="php artisan make:factory" # Create a new model factory -alias a:mk:j="php artisan make:job" # Create a new job class -alias a:mk:li="php artisan make:listener" # Create a new event listener class -alias a:mk:ma="php artisan make:mail" # Create a new email class -alias a:mk:mw="php artisan make:middleware" # Create a new middleware class -alias a:mk:mg="php artisan make:migration" # Create a new migration file -alias a:mk:md="php artisan make:model" # Create a new Eloquent model class -alias a:mk:no="php artisan make:notification" # Create a new notification class -alias a:mk:po="php artisan make:policy" # Create a new policy class -alias a:mk:pr="php artisan make:provider" # Create a new service provider class -alias a:mk:rq="php artisan make:request" # Create a new form request class -alias a:mk:rs="php artisan make:resource" # Create a new resource -alias a:mk:rl="php artisan make:rule" # Create a new validation rule -alias a:mk:sd="php artisan make:seeder" # Create a new seeder class -alias a:mk:st="php artisan make:stream" # Make a streams entity namespace. -alias a:mk:ts="php artisan make:test" # Create a new test class +alias a:mk:ad="php artisan make:addon" # Create a new addon. +alias a:mk:au="php artisan make:auth" # Scaffold basic login and registration views and routes +alias a:mk:cm="php artisan make:command" # Create a new Artisan command +alias a:mk:ct="php artisan make:controller" # Create a new controller class +alias a:mk:ev="php artisan make:event" # Create a new event class +alias a:mk:fa="php artisan make:factory" # Create a new model factory +alias a:mk:j="php artisan make:job" # Create a new job class +alias a:mk:li="php artisan make:listener" # Create a new event listener class +alias a:mk:ma="php artisan make:mail" # Create a new email class +alias a:mk:mw="php artisan make:middleware" # Create a new middleware class +alias a:mk:mg="php artisan make:migration" # Create a new migration file +alias a:mk:md="php artisan make:model" # Create a new Eloquent model class +alias a:mk:no="php artisan make:notification" # Create a new notification class +alias a:mk:po="php artisan make:policy" # Create a new policy class +alias a:mk:pr="php artisan make:provider" # Create a new service provider class +alias a:mk:rq="php artisan make:request" # Create a new form request class +alias a:mk:rs="php artisan make:resource" # Create a new resource +alias a:mk:rl="php artisan make:rule" # Create a new validation rule +alias a:mk:sd="php artisan make:seeder" # Create a new seeder class +alias a:mk:st="php artisan make:stream" # Make a streams entity namespace. +alias a:mk:ts="php artisan make:test" # Create a new test class # migrate -alias a:mg:fr="php artisan migrate:fresh" # Drop all tables and re-run all migrations -alias a:mg:i="php artisan migrate:install" # Create the migration repository -alias a:mg:rf="php artisan migrate:refresh" # Reset and re-run all migrations -alias a:mg:rs="php artisan migrate:reset" # Rollback all database migrations -alias a:mg:rl="php artisan migrate:rollback" # Rollback the last database migration -alias a:mg:st="php artisan migrate:status" # Show the status of each migration +alias a:mg:fr="php artisan migrate:fresh" # Drop all tables and re-run all migrations +alias a:mg:i="php artisan migrate:install" # Create the migration repository +alias a:mg:rf="php artisan migrate:refresh" # Reset and re-run all migrations +alias a:mg:rs="php artisan migrate:reset" # Rollback all database migrations +alias a:mg:rl="php artisan migrate:rollback" # Rollback the last database migration +alias a:mg:st="php artisan migrate:status" # Show the status of each migration # module -alias a:mo:i="php artisan module:install" # Install a module. -alias a:mo:r="php artisan module:reinstall" # Reinstall a module. -alias a:mo:u="php artisan module:uninstall" # Uninstall a module. +alias a:mo:i="php artisan module:install" # Install a module. +alias a:mo:r="php artisan module:reinstall" # Reinstall a module. +alias a:mo:u="php artisan module:uninstall" # Uninstall a module. # notifications -alias a:no:tb="php artisan notifications:table" # Create a migration for the notifications table +alias a:no:tb="php artisan notifications:table" # Create a migration for the notifications table # package -alias a:pk:d="php artisan package:discover" # Rebuild the cached package manifest +alias a:pk:d="php artisan package:discover" # Rebuild the cached package manifest # queue -alias a:qu:fa="php artisan queue:failed" # List all of the failed queue jobs -alias a:qu:ft="php artisan queue:failed-table" # Create a migration for the failed queue jobs database table -alias a:qu:fl="php artisan queue:flush" # Flush all of the failed queue jobs -alias a:qu:fg="php artisan queue:forget" # Delete a failed queue job -alias a:qu:li="php artisan queue:listen" # Listen to a given queue -alias a:qu:rs="php artisan queue:restart" # Restart queue worker daemons after their current job -alias a:qu:rt="php artisan queue:retry" # Retry a failed queue job -alias a:qu:tb="php artisan queue:table" # Create a migration for the queue jobs database table -alias a:qu:w="php artisan queue:work" # Start processing jobs on the queue as a daemon +alias a:qu:fa="php artisan queue:failed" # List all of the failed queue jobs +alias a:qu:ft="php artisan queue:failed-table" # Create a migration for the failed queue jobs database table +alias a:qu:fl="php artisan queue:flush" # Flush all of the failed queue jobs +alias a:qu:fg="php artisan queue:forget" # Delete a failed queue job +alias a:qu:li="php artisan queue:listen" # Listen to a given queue +alias a:qu:rs="php artisan queue:restart" # Restart queue worker daemons after their current job +alias a:qu:rt="php artisan queue:retry" # Retry a failed queue job +alias a:qu:tb="php artisan queue:table" # Create a migration for the queue jobs database table +alias a:qu:w="php artisan queue:work" # Start processing jobs on the queue as a daemon # route -alias a:ro:ca="php artisan route:cache" # Create a route cache file for faster route registration -alias a:ro:cl="php artisan route:clear" # Remove the route cache file -alias a:ro:ls="php artisan route:list" # List all registered routes +alias a:ro:ca="php artisan route:cache" # Create a route cache file for faster route registration +alias a:ro:cl="php artisan route:clear" # Remove the route cache file +alias a:ro:ls="php artisan route:list" # List all registered routes # schedule -alias a:sc:r="php artisan schedule:run" # Run the scheduled commands +alias a:sc:r="php artisan schedule:run" # Run the scheduled commands # scout -alias a:su:fl="php artisan scout:flush" # Flush all of the model's records from the index -alias a:su:im="php artisan scout:import" # Import the given model into the search index +alias a:su:fl="php artisan scout:flush" # Flush all of the model's records from the index +alias a:su:im="php artisan scout:import" # Import the given model into the search index # session -alias a:se:tb="php artisan session:table" # Create a migration for the session database table +alias a:se:tb="php artisan session:table" # Create a migration for the session database table # storage -alias a:sg:l="php artisan storage:link" # Create a symbolic link from "public/storage" to "storage/app/public" +alias a:sg:l="php artisan storage:link" # Create a symbolic link from "public/storage" to "storage/app/public" # streams -alias a:st:cl="php artisan streams:cleanup" # Cleanup streams entry models. -alias a:st:co="php artisan streams:compile" # Compile streams entry models. -alias a:st:d="php artisan streams:destroy" # Destroy a namespace. -alias a:st:p="php artisan streams:publish" # Publish configuration and translations for streams. -alias a:st:r="php artisan streams:refresh" # Refresh streams generated components. +alias a:st:cl="php artisan streams:cleanup" # Cleanup streams entry models. +alias a:st:co="php artisan streams:compile" # Compile streams entry models. +alias a:st:d="php artisan streams:destroy" # Destroy a namespace. +alias a:st:p="php artisan streams:publish" # Publish configuration and translations for streams. +alias a:st:r="php artisan streams:refresh" # Refresh streams generated components. # tntsearch -alias a:tn:im="php artisan tntsearch:import" # Import the given model into the search index +alias a:tn:im="php artisan tntsearch:import" # Import the given model into the search index # vendor -alias a:ve:p="php artisan vendor:publish" # Publish any publishable assets from vendor packages +alias a:ve:p="php artisan vendor:publish" # Publish any publishable assets from vendor packages # view -alias a:vi:cl="php artisan view:clear" # Clear all compiled view files +alias a:vi:cl="php artisan view:clear" # Clear all compiled view files diff --git a/aliases/available/rails.aliases.bash b/aliases/available/rails.aliases.bash index c776660eeb..4de4faff30 100644 --- a/aliases/available/rails.aliases.bash +++ b/aliases/available/rails.aliases.bash @@ -1,4 +1,4 @@ -cite 'about-alias' +# shellcheck shell=bash about-alias 'rails abbreviations' # Rails Commands @@ -14,9 +14,9 @@ alias rd='rails destroy' alias dbm='rake db:migrate' alias ss='script/server' -alias ts="thin start" # thin server +alias ts="thin start" # thin server alias sc='script/console' alias restartapp='touch tmp/restart.txt' -alias restart='touch tmp/restart.txt' # restart passenger +alias restart='touch tmp/restart.txt' # restart passenger alias devlog='tail -f log/development.log' alias taild='tail -f log/development.log' # tail dev log diff --git a/aliases/available/svn.aliases.bash b/aliases/available/svn.aliases.bash index 3d6d263e09..4d3de464c3 100644 --- a/aliases/available/svn.aliases.bash +++ b/aliases/available/svn.aliases.bash @@ -1,4 +1,4 @@ -cite 'about-alias' +# shellcheck shell=bash about-alias 'common svn abbreviations' # Aliases diff --git a/aliases/available/systemd.aliases.bash b/aliases/available/systemd.aliases.bash index 109308f1df..57351ae0b4 100644 --- a/aliases/available/systemd.aliases.bash +++ b/aliases/available/systemd.aliases.bash @@ -1,15 +1,22 @@ -cite 'about-alias' +# shellcheck shell=bash about-alias 'systemd service' case $OSTYPE in - linux*) - alias sc='systemctl' - alias scr='systemctl daemon-reload' - alias scu='systemctl --user' - alias scur='systemctl --user daemon-reload' - alias sce='systemctl stop' - alias scue='systemctl --user stop' - alias scs='systemctl start' - alias scus='systemctl --user start' - ;; + linux*) + # Improve aliases by bringing the common root `sc|scd` + `sre` for action + `u` for user + alias sc='systemctl' + alias scu='systemctl --user' + alias scdr='systemctl daemon-reload' + alias scdru='systemctl --user daemon-reload' + alias scr='systemctl restart' + alias scru='systemctl --user restart' + alias sce='systemctl stop' + alias sceu='systemctl --user stop' + alias scs='systemctl start' + alias scsu='systemctl --user start' + # Keeping previous aliases for a non-breaking change. + alias scue='sceu' + alias scus='scsu' + alias scur='scdru' + ;; esac diff --git a/aliases/available/terraform.aliases.bash b/aliases/available/terraform.aliases.bash new file mode 100644 index 0000000000..b236b5fd9f --- /dev/null +++ b/aliases/available/terraform.aliases.bash @@ -0,0 +1,10 @@ +# shellcheck shell=bash +about-alias 'Aliases for Terraform and Terragrunt' + +alias tf='terraform' +alias tfi='tf init' +alias tfv='terraform validate' +alias tfp='terraform plan' +alias tfa='terraform apply' +alias tfd='terraform destroy' +alias tfw='terraform workspace' diff --git a/aliases/available/terragrunt.aliases.bash b/aliases/available/terragrunt.aliases.bash new file mode 100644 index 0000000000..94892901f3 --- /dev/null +++ b/aliases/available/terragrunt.aliases.bash @@ -0,0 +1,13 @@ +# shellcheck shell=bash +about-alias 'Aliases for Terraform and Terragrunt' + +alias tg='terragrunt' +alias tgv='terragrunt validate' +alias tgp='terragrunt plan' +alias tga='terragrunt apply' +alias tgd='terragrunt destroy' + +alias tgva='terragrunt validate-all' +alias tgpa='terragrunt plan-all' +alias tgaa='terragrunt apply-all' +alias tgda='terragrunt destroy-all' diff --git a/aliases/available/textmate.aliases.bash b/aliases/available/textmate.aliases.bash index f0f69e4389..e53eed1a1a 100644 --- a/aliases/available/textmate.aliases.bash +++ b/aliases/available/textmate.aliases.bash @@ -1,10 +1,10 @@ -cite 'about-alias' +# shellcheck shell=bash about-alias 'textmate abbreviations' case $OSTYPE in - darwin*) - # Textmate - alias e='mate . &' - alias et='mate app config db lib public script test spec config.ru Gemfile Rakefile README &' - ;; + darwin*) + # Textmate + alias e='mate . &' + alias et='mate app config db lib public script test spec config.ru Gemfile Rakefile README &' + ;; esac diff --git a/aliases/available/tmux.aliases.bash b/aliases/available/tmux.aliases.bash index 1b07f14952..192db5b589 100644 --- a/aliases/available/tmux.aliases.bash +++ b/aliases/available/tmux.aliases.bash @@ -1,4 +1,4 @@ -cite 'about-alias' +# shellcheck shell=bash about-alias 'Tmux terminal multiplexer' alias txl='tmux ls' diff --git a/aliases/available/todo.txt-cli.aliases.bash b/aliases/available/todo.txt-cli.aliases.bash index 5bf35d0d77..359321a4b0 100644 --- a/aliases/available/todo.txt-cli.aliases.bash +++ b/aliases/available/todo.txt-cli.aliases.bash @@ -1,8 +1,8 @@ -cite 'about-alias' +# shellcheck shell=bash about-alias 'todo.txt-cli abbreviations' -alias tls="$TODO ls" -alias ta="$TODO a" -alias trm="$TODO rm" -alias tdo="$TODO do" -alias tpri="$TODO pri" +alias tls='"${TODO?}" ls' +alias ta='"${TODO?}" a' +alias trm='"${TODO?}" rm' +alias tdo='"${TODO?}" do' +alias tpri='"${TODO?}" pri' diff --git a/aliases/available/uuidgen.aliases.bash b/aliases/available/uuidgen.aliases.bash new file mode 100644 index 0000000000..45c368204f --- /dev/null +++ b/aliases/available/uuidgen.aliases.bash @@ -0,0 +1,11 @@ +# shellcheck shell=bash +about-alias 'uuidgen aliases' + +if _command_exists uuid; then # Linux + alias uuidu="uuid | tr '[:lower:]' '[:upper:]'" + alias uuidl=uuid +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 +fi diff --git a/aliases/available/vagrant.aliases.bash b/aliases/available/vagrant.aliases.bash index d479fb2b13..a949cbb3d2 100644 --- a/aliases/available/vagrant.aliases.bash +++ b/aliases/available/vagrant.aliases.bash @@ -1,4 +1,4 @@ -cite 'about-alias' +# shellcheck shell=bash about-alias 'vagrant aliases' # Aliases diff --git a/aliases/available/vault.aliases.bash b/aliases/available/vault.aliases.bash index d2ad8e74b7..4d083fb609 100644 --- a/aliases/available/vault.aliases.bash +++ b/aliases/available/vault.aliases.bash @@ -1,4 +1,4 @@ -cite 'about-alias' +# shellcheck shell=bash about-alias 'vault aliases' # Aliases diff --git a/aliases/available/vim.aliases.bash b/aliases/available/vim.aliases.bash index 2ad1e99ce3..f80687640b 100644 --- a/aliases/available/vim.aliases.bash +++ b/aliases/available/vim.aliases.bash @@ -1,19 +1,14 @@ -cite 'about-alias' +# shellcheck shell=bash about-alias 'vim abbreviations' -VIM=$(command -v vim) -GVIM=$(command -v gvim) -MVIM=$(command -v mvim) +_command_exists vim || return -[[ -n $VIM ]] && alias v=$VIM +alias v='vim' +# open the vim help in fullscreen incorporated from +# https://stackoverflow.com/a/4687513 +alias vimh='vim -c ":h | only"' # open vim in new tab is taken from # http://stackoverflow.com/questions/936501/let-gvim-always-run-a-single-instancek -case $OSTYPE in - darwin*) - [[ -n $MVIM ]] && function mvimt { command mvim --remote-tab-silent "$@" || command mvim "$@"; } - ;; - *) - [[ -n $GVIM ]] && function gvimt { command gvim --remote-tab-silent "$@" || command gvim "$@"; } - ;; -esac +_command_exists mvim && function mvimt { command mvim --remote-tab-silent "$@" || command mvim "$@"; } +_command_exists gvim && function gvimt { command gvim --remote-tab-silent "$@" || command gvim "$@"; } diff --git a/aliases/available/yarn.aliases.bash b/aliases/available/yarn.aliases.bash index b50535b9f6..a2fb6d0dc5 100644 --- a/aliases/available/yarn.aliases.bash +++ b/aliases/available/yarn.aliases.bash @@ -1,4 +1,4 @@ -cite 'about-alias' +# shellcheck shell=bash about-alias 'yarn package manager aliases' # Aliases diff --git a/bash_it.sh b/bash_it.sh index 8eea4c6acc..ddc02b708f 100755 --- a/bash_it.sh +++ b/bash_it.sh @@ -1,119 +1,110 @@ #!/usr/bin/env bash +# shellcheck source-path=SCRIPTDIR/lib source-path=SCRIPTDIR/scripts +# shellcheck disable=SC2034 +# # Initialize Bash It - -# Only set $BASH_IT if it's not already set -if [ -z "$BASH_IT" ]; -then - # Setting $BASH to maintain backwards compatibility - # TODO: warn users that they should upgrade their .bash_profile - export BASH_IT=$BASH - BASH="$(bash -c 'echo $BASH')" - export BASH -fi - -# For backwards compatibility, look in old BASH_THEME location -if [ -z "$BASH_IT_THEME" ]; -then - # TODO: warn users that they should upgrade their .bash_profile - export BASH_IT_THEME="$BASH_THEME"; - unset BASH_THEME; -fi +BASH_IT_LOG_PREFIX="core: main: " +: "${BASH_IT:=${BASH_SOURCE%/*}}" +: "${BASH_IT_CUSTOM:=${BASH_IT}/custom}" +: "${CUSTOM_THEME_DIR:="${BASH_IT_CUSTOM}/themes"}" +: "${BASH_IT_BASHRC:=${BASH_SOURCE[${#BASH_SOURCE[@]} - 1]}}" # Load composure first, so we support function metadata -# shellcheck source=./lib/composure.bash -source "${BASH_IT}/lib/composure.bash" - +# shellcheck source-path=SCRIPTDIR/vendor/github.com/erichs/composure +source "${BASH_IT}/vendor/github.com/erichs/composure/composure.sh" # support 'plumbing' metadata cite _about _param _example _group _author _version +cite about-alias about-plugin about-completion + +# Declare our end-of-main finishing hook, but don't use `declare`/`typeset` +_bash_it_library_finalize_hook=() + +# We need to load logging module early in order to be able to log +source "${BASH_IT}/lib/log.bash" # libraries, but skip appearance (themes) for now -LIB="${BASH_IT}/lib/*.bash" +_log_debug "Loading libraries(except appearance)..." APPEARANCE_LIB="${BASH_IT}/lib/appearance.bash" -for config_file in $LIB -do - if [ "$config_file" != "$APPEARANCE_LIB" ]; then - # shellcheck disable=SC1090 - source "$config_file" - fi +for _bash_it_main_file_lib in "${BASH_IT}/lib"/*.bash; do + [[ "$_bash_it_main_file_lib" == "$APPEARANCE_LIB" ]] && continue + _bash-it-log-prefix-by-path "${_bash_it_main_file_lib}" + _log_debug "Loading library file..." + # shellcheck disable=SC1090 + source "$_bash_it_main_file_lib" + BASH_IT_LOG_PREFIX="core: main: " done -# Load the global "enabled" directory -_load_global_bash_it_files - -# Load enabled aliases, completion, plugins -for file_type in "aliases" "plugins" "completion" -do - _load_bash_it_files $file_type +# Load the global "enabled" directory, then enabled aliases, completion, plugins +# "_bash_it_main_file_type" param is empty so that files get sourced in glob order +for _bash_it_main_file_type in "" "aliases" "plugins" "completion"; do + BASH_IT_LOG_PREFIX="core: reloader: " + # shellcheck disable=SC2140 + source "${BASH_IT}/scripts/reloader.bash" ${_bash_it_main_file_type:+"skip" "$_bash_it_main_file_type"} + BASH_IT_LOG_PREFIX="core: main: " done -# Load colors and helpers first so they can be used in base theme -# shellcheck source=./themes/colors.theme.bash -source "${BASH_IT}/themes/colors.theme.bash" -# shellcheck source=./themes/githelpers.theme.bash -source "${BASH_IT}/themes/githelpers.theme.bash" -# shellcheck source=./themes/p4helpers.theme.bash -source "${BASH_IT}/themes/p4helpers.theme.bash" -# shellcheck source=./themes/base.theme.bash -source "${BASH_IT}/themes/base.theme.bash" - -# appearance (themes) now, after all dependencies -# shellcheck source=./lib/appearance.bash -source "$APPEARANCE_LIB" +# Load theme, if a theme was set +# shellcheck source-path=SCRIPTDIR/themes +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" + BASH_IT_LOG_PREFIX="themes: p4helpers: " + source "${BASH_IT}/themes/p4helpers.theme.bash" + BASH_IT_LOG_PREFIX="themes: base: " + source "${BASH_IT}/themes/base.theme.bash" + + BASH_IT_LOG_PREFIX="lib: appearance: " + # appearance (themes) now, after all dependencies + # shellcheck source=SCRIPTDIR/lib/appearance.bash + source "$APPEARANCE_LIB" + BASH_IT_LOG_PREFIX="core: main: " +fi -# Load custom aliases, completion, plugins -for file_type in "aliases" "completion" "plugins" -do - if [ -e "${BASH_IT}/${file_type}/custom.${file_type}.bash" ] - then - # shellcheck disable=SC1090 - source "${BASH_IT}/${file_type}/custom.${file_type}.bash" - 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 + _bash-it-log-prefix-by-path "${_bash_it_main_file_custom}" + _log_debug "Loading component..." + # shellcheck disable=SC1090 + source "${_bash_it_main_file_custom}" + fi + BASH_IT_LOG_PREFIX="core: main: " done # Custom -CUSTOM="${BASH_IT_CUSTOM:=${BASH_IT}/custom}/*.bash ${BASH_IT_CUSTOM:=${BASH_IT}/custom}/**/*.bash" -for config_file in $CUSTOM -do - if [ -e "${config_file}" ]; then - # shellcheck disable=SC1090 - source "$config_file" - fi +_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 + _bash-it-log-prefix-by-path "${_bash_it_main_file_custom}" + _log_debug "Loading custom file..." + # shellcheck disable=SC1090 + source "$_bash_it_main_file_custom" + fi + BASH_IT_LOG_PREFIX="core: main: " done -unset config_file -if [[ $PROMPT ]]; then - export PS1="\[""$PROMPT""\]" +if [[ -n "${PROMPT:-}" ]]; then + PS1="${PROMPT}" fi # Adding Support for other OSes -PREVIEW="less" - -if [ -s /usr/bin/gloobus-preview ]; then - PREVIEW="gloobus-preview" -elif [ -s /Applications/Preview.app ]; then - # shellcheck disable=SC2034 - PREVIEW="/Applications/Preview.app" -fi - -# Load all the Jekyll stuff - -if [ -e "$HOME/.jekyllconfig" ] -then - # shellcheck disable=SC1090 - . "$HOME/.jekyllconfig" +if _command_exists gloobus-preview; then + PREVIEW="gloobus-preview" +elif [[ -d /Applications/Preview.app ]]; then + PREVIEW="/Applications/Preview.app" +else + PREVIEW="less" fi # BASH_IT_RELOAD_LEGACY is set. -if ! command -v reload &>/dev/null && [ -n "$BASH_IT_RELOAD_LEGACY" ]; then - case $OSTYPE in - darwin*) - alias reload='source ~/.bash_profile' - ;; - *) - alias reload='source ~/.bashrc' - ;; - esac +if [[ -n "${BASH_IT_RELOAD_LEGACY:-}" ]] && ! _command_exists reload; then + # shellcheck disable=SC2139 + alias reload="builtin source '${BASH_IT_BASHRC?}'" fi -# Disable trap DEBUG on subshells - https://github.com/Bash-it/bash-it/pull/1040 -set +T +for _bash_it_library_finalize_f in "${_bash_it_library_finalize_hook[@]:-}"; do + eval "${_bash_it_library_finalize_f?}" # Use `eval` to achieve the same behavior as `$PROMPT_COMMAND`. +done +unset "${!_bash_it_library_finalize_@}" "${!_bash_it_main_file_@}" diff --git a/clean_files.txt b/clean_files.txt new file mode 100644 index 0000000000..758e3b80a7 --- /dev/null +++ b/clean_files.txt @@ -0,0 +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 diff --git a/completion/available/aliases.completion.bash b/completion/available/aliases.completion.bash new file mode 100644 index 0000000000..3e45e960cf --- /dev/null +++ b/completion/available/aliases.completion.bash @@ -0,0 +1,112 @@ +# shellcheck shell=bash +about-plugin 'Automatic completion of aliases' +# Load after all aliases and completions to understand what needs to be completed +# BASH_IT_LOAD_PRIORITY: 800 + +# References: +# http://superuser.com/a/437508/119764 +# 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() { + 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 + + # create array of function completion triggers, keeping multi-word triggers together + IFS=$'\n' read -d '' -ra completions < <(complete -p) + ((${#completions[@]} == 0)) && return 0 + + completions=("${completions[@]##complete -* * -}") # strip all but last option plus trigger(s) + completions=("${completions[@]#complete -}") # strip anything missed + completions=("${completions[@]#? * }") # strip last option and arg, leaving only trigger(s) + completions=("${completions[@]#? }") # strip anything missed + #TODO: this will fail on some completions... + + # create temporary file for wrapper functions and completions + 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 + completion_loader="${BASH_REMATCH[1]}" + else + completion_loader="" + fi + + # read in " '' ''" lines from defined aliases + # some aliases do have backslashes that needs to be interpreted + # shellcheck disable=SC2162 + while read line; do + line="${line#alias -- }" + line="${line#alias }" + alias_name="${line%%=*}" + alias_defn="${line#*=\'}" # alias definition + alias_defn="${alias_defn%\'}" + alias_cmd="${alias_defn%%[[:space:]]*}" # first word of alias + if [[ ${alias_defn} == ${alias_cmd} ]]; then + alias_args='' + else + alias_args="${alias_defn#*[[:space:]]}" # everything after first word + fi + + # skip aliases to pipes, boolean control structures and other command lists + chars=$'|&;()<>\n' + 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 + # force loading of completions for the aliased command + "${completion_loader:?}" "${alias_cmd}" + # 124 means completion loader was successful + [[ $? -eq 124 ]] || continue + completions+=("$alias_cmd") + else + continue + fi + fi + new_completion="$(complete -p "$alias_cmd" 2> /dev/null)" + + # create a wrapper inserting the alias arguments if any + 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 + compl_wrapper="_${namespace}::${alias_name}" + echo "function $compl_wrapper { + local compl_word=\${2?} + local prec_word=\${3?} + # 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 + prec_word='$alias_cmd $alias_args' + prec_word=\${prec_word#* } + fi + (( COMP_CWORD += ${#alias_arg_words[@]} )) + COMP_WORDS=(\"$alias_cmd\" \"${alias_arg_words[@]}\" \"\${COMP_WORDS[@]:1}\") + (( COMP_POINT -= \${#COMP_LINE} )) + COMP_LINE=\${COMP_LINE/$alias_name/$alias_cmd $alias_args} + (( COMP_POINT += \${#COMP_LINE} )) + \"$compl_func\" \"$alias_cmd\" \"\$compl_word\" \"\$prec_word\" + }" >> "$tmp_file" + new_completion="${new_completion/ -F $compl_func / -F $compl_wrapper }" + fi + fi + + # replace completion trigger by alias + if [[ -n $new_completion ]]; then + new_completion="${new_completion% *} $alias_name" + echo "$new_completion" >> "$tmp_file" + fi + done < <(alias -p) + # shellcheck source=/dev/null + source "$tmp_file" && command rm -f "$tmp_file" +} + +_bash-it-component-completion-callback-on-init-aliases diff --git a/completion/available/apm.completion.bash b/completion/available/apm.completion.bash index a0a4e13c78..c3dcfe45f8 100644 --- a/completion/available/apm.completion.bash +++ b/completion/available/apm.completion.bash @@ -1,56 +1,4 @@ -#!/usr/bin/env bash - -# apm-bash-completion is written by Ugur Ozyilmazel -# repo: https://github.com/vigo/apm-bash-completion - -__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 +# shellcheck shell=bash +about-completion "apm completion" +# shellcheck disable=SC1090 +source "${BASH_IT}"/vendor/github.com/vigo/apm-bash-completion/apm diff --git a/completion/available/awless.completion.bash b/completion/available/awless.completion.bash index a3af393d71..98a5d38881 100644 --- a/completion/available/awless.completion.bash +++ b/completion/available/awless.completion.bash @@ -1 +1,5 @@ -[[ -x "$(which awless)" ]] && source <(awless completion bash) +# shellcheck shell=bash +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 530bdd2739..6b2c90ff5d 100644 --- a/completion/available/awscli.completion.bash +++ b/completion/available/awscli.completion.bash @@ -1 +1,5 @@ -[[ -x "$(which aws_completer)" ]] && complete -C "$(which aws_completer)" aws +# shellcheck shell=bash + +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 71ec8418eb..2259e37b17 100644 --- a/completion/available/bash-it.completion.bash +++ b/completion/available/bash-it.completion.bash @@ -1,126 +1,95 @@ -#!/usr/bin/env bash +# shellcheck shell=bash -_bash-it-comp-enable-disable() -{ - local enable_disable_args="alias completion plugin" - COMPREPLY=( $(compgen -W "${enable_disable_args}" -- ${cur}) ) -} - -_bash-it-comp-list-available-not-enabled() -{ - subdirectory="$1" - - local available_things - - available_things=$(for f in `compgen -G "${BASH_IT}/$subdirectory/available/*.bash" | sort -d`; - do - file_entity=$(basename $f) - - typeset enabled_component=$(command ls "${BASH_IT}/$subdirectory/enabled/"{[0-9]*$BASH_IT_LOAD_PRIORITY_SEPARATOR$file_entity,$file_entity} 2>/dev/null | head -1) - typeset enabled_component_global=$(command ls "${BASH_IT}/enabled/"[0-9]*$BASH_IT_LOAD_PRIORITY_SEPARATOR$file_entity 2>/dev/null | head -1) - - if [ -z "$enabled_component" ] && [ -z "$enabled_component_global" ] - then - basename $f | sed -e 's/\(.*\)\..*\.bash/\1/g' - fi - done) - - COMPREPLY=( $(compgen -W "all ${available_things}" -- ${cur}) ) -} - -_bash-it-comp-list-enabled() -{ - local subdirectory="$1" - local suffix enabled_things +function _compreply_candidates() { + local IFS=$'\n' - suffix=$(echo "$subdirectory" | sed -e 's/plugins/plugin/g') - - enabled_things=$(for f in `sort -d <(compgen -G "${BASH_IT}/$subdirectory/enabled/*.${suffix}.bash") <(compgen -G "${BASH_IT}/enabled/*.${suffix}.bash")`; - do - basename $f | sed -e 's/\(.*\)\..*\.bash/\1/g' | sed -e "s/^[0-9]*---//g" - done) - - COMPREPLY=( $(compgen -W "all ${enabled_things}" -- ${cur}) ) + read -d '' -ra COMPREPLY < <(compgen -W "${candidates[*]}" -- "${cur}") } -_bash-it-comp-list-available() -{ - subdirectory="$1" - - local enabled_things - - enabled_things=$(for f in `compgen -G "${BASH_IT}/$subdirectory/available/*.bash" | sort -d`; - do - basename $f | sed -e 's/\(.*\)\..*\.bash/\1/g' - done) - - COMPREPLY=( $(compgen -W "${enabled_things}" -- ${cur}) ) -} - -_bash-it-comp() -{ - local cur prev opts - COMPREPLY=() - cur="${COMP_WORDS[COMP_CWORD]}" - prev="${COMP_WORDS[COMP_CWORD-1]}" - chose_opt="${COMP_WORDS[1]}" - file_type="${COMP_WORDS[2]}" - opts="disable enable help migrate reload search show update version" - case "${chose_opt}" in - show) - local show_args="aliases completions plugins" - COMPREPLY=( $(compgen -W "${show_args}" -- ${cur}) ) - return 0 - ;; - help) - if [ x"${prev}" == x"aliases" ]; then - _bash-it-comp-list-available aliases - return 0 - else - local help_args="aliases completions migrate plugins update" - COMPREPLY=( $(compgen -W "${help_args}" -- ${cur}) ) - return 0 - fi - ;; - migrate | reload | search | update | version) - return 0 - ;; - enable | disable) - if [ x"${chose_opt}" == x"enable" ];then - suffix="available-not-enabled" - else - suffix="enabled" - fi - case "${file_type}" in - alias) - _bash-it-comp-list-${suffix} aliases - return 0 - ;; - plugin) - _bash-it-comp-list-${suffix} plugins - return 0 - ;; - completion) - _bash-it-comp-list-${suffix} completion - return 0 - ;; - *) - _bash-it-comp-enable-disable - return 0 - ;; - esac - ;; - esac - - COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) ) - - return 0 +function _bash-it() { + local cur prev verb file_type candidates suffix + COMPREPLY=() + cur="${COMP_WORDS[COMP_CWORD]}" + prev="${COMP_WORDS[COMP_CWORD - 1]}" + verb="${COMP_WORDS[1]}" + file_type="${COMP_WORDS[2]:-}" + candidates=('disable' 'enable' 'help' 'migrate' 'reload' 'restart' 'preview' 'profile' 'doctor' 'search' 'show' 'update' 'version') + case "${verb}" in + show) + candidates=('aliases' 'completions' 'plugins') + _compreply_candidates + ;; + help) + if [[ "${prev}" == "aliases" ]]; then + candidates=('all' "$(_bash-it-component-list "${file_type}")") + _compreply_candidates + else + candidates=('aliases' 'completions' 'migrate' 'plugins' 'update') + _compreply_candidates + fi + ;; + profile) + case "${file_type}" in + load | rm) + if [[ "${file_type}" == "$prev" ]]; then + candidates=("${BASH_IT}/profiles"/*.bash_it) + candidates=("${candidates[@]##*/}") + candidates=("${candidates[@]%%.bash_it}") + + _compreply_candidates + fi + ;; + save | list) ;; + *) + candidates=('load' 'save' 'list' 'rm') + _compreply_candidates + ;; + esac + ;; + doctor) + candidates=('errors' 'warnings' 'all') + _compreply_candidates + ;; + update) + if [[ "${cur}" == -* ]]; then + candidates=('-s' '--silent') + else + candidates=('stable' 'dev') + fi + _compreply_candidates + ;; + migrate | reload | restart | search | version) ;; + preview) + _bash-it-preview # completes itself + return 0 + ;; + enable | disable) + if [[ "${verb}" == "enable" ]]; then + suffix="disabled" + else + suffix="enabled" + fi + case "${file_type}" in + alias | completion | plugin) + candidates=('all' "$("_bash-it-component-list-${suffix}" "${file_type}")") + _compreply_candidates + ;; + *) + candidates=('alias' 'completion' 'plugin') + _compreply_candidates + ;; + esac + ;; + *) + _compreply_candidates + ;; + esac } # Activate completion for bash-it and its common misspellings -complete -F _bash-it-comp bash-it -complete -F _bash-it-comp bash-ti -complete -F _bash-it-comp shit -complete -F _bash-it-comp bashit -complete -F _bash-it-comp batshit -complete -F _bash-it-comp bash_it +complete -F _bash-it bash-it +complete -F _bash-it bash-ti +complete -F _bash-it shit +complete -F _bash-it bashit +complete -F _bash-it batshit +complete -F _bash-it bash_it diff --git a/completion/available/brew.completion.bash b/completion/available/brew.completion.bash index 5cbd1595fd..01e5d533a7 100644 --- a/completion/available/brew.completion.bash +++ b/completion/available/brew.completion.bash @@ -1,11 +1,30 @@ -if which brew >/dev/null 2>&1; then - BREW_PREFIX=$(brew --prefix) +# shellcheck shell=bash +cite "about-completion" +about-completion "brew completion" - if [ -f "$BREW_PREFIX"/etc/bash_completion.d/brew ]; then - . "$BREW_PREFIX"/etc/bash_completion.d/brew - fi +# Load late to make sure `system` completion loads first +# BASH_IT_LOAD_PRIORITY: 375 - if [ -f "$BREW_PREFIX"/Library/Contributions/brew_bash_completion.sh ]; then - . "$BREW_PREFIX"/Library/Contributions/brew_bash_completion.sh - fi +if [[ "$OSTYPE" != 'darwin'* ]]; then + _log_warning "unsupported operating system - only 'Darwin' is supported" + return 0 +fi + +# Make sure brew is installed +_bash_it_homebrew_check || return 0 + +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 + # shellcheck disable=1090,1091 + source "$BASH_IT_HOMEBREW_PREFIX/Library/Contributions/brew_bash_completion.sh" + +elif [[ -f "$BASH_IT_HOMEBREW_PREFIX/completions/bash/brew" ]]; then + # For the git-clone based installation, see here for more info: + # https://github.com/Bash-it/bash-it/issues/1458 + # https://docs.brew.sh/Shell-Completion + # shellcheck disable=1090,1091 + source "$BASH_IT_HOMEBREW_PREFIX/completions/bash/brew" fi diff --git a/completion/available/bundler.completion.bash b/completion/available/bundler.completion.bash index 274a4a36a3..663a26d2d8 100644 --- a/completion/available/bundler.completion.bash +++ b/completion/available/bundler.completion.bash @@ -1,33 +1,193 @@ #! bash # bash completion for the `bundle` command. # -# Copyright (c) 2011-2013 Daniel Luz . -# Distributed under the MIT license. -# http://mernen.com/projects/completion-ruby +# Copyright (c) 2008 Daniel Luz + +# 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. # # To use, source this file on bash: # . completion-bundle __bundle() { - local cur=$2 - local prev=$3 - local bundle_command - __bundle_get_command - COMPREPLY=() - - local options - if [[ $cur = -* ]]; then - options="--no-color --verbose" - if [[ -z $bundle_command ]]; then - options="$options --version --help" - fi - else - if [[ -z $bundle_command || $bundle_command = help ]]; then - options="help install update package exec config check list show - console open viz init gem" - fi - fi - COMPREPLY=($(compgen -W "$options" -- "$cur")) + local bundle_bin=("${_RUBY_COMMAND_PREFIX[@]}" "$1") + local cur prev + _get_comp_words_by_ref -n : cur prev + local bundle_command + local bundle_command_index + __bundle_get_command + COMPREPLY=() + + local options + if [[ $cur = -* && $bundle_command != exec ]]; then + options="-V --help --no-color --no-no-color --verbose --no-verbose" + case $bundle_command in + "") + options="$options --version";; + check) + options="$options --dry-run --gemfile --path -r --retry";; + clean) + options="$options --dry-run --force";; + config) + options="$options --local --global --delete";; + doctor) + options="$options --gemfile --quiet --no-quiet";; + gem) + options="$options -b -e -t --bin --coc --no-coc --edit --exe + --no-exe --ext --no-ext --mit --no-mit --test";; + init) + options="$options --gemspec";; + install) + options="$options --binstubs --clean --deployment --force --frozen + --full-index --gemfile --jobs --local --no-cache + --no-prune --path --quiet --retry --shebang --standalone + --system --trust-policy --with --without";; + lock) + options="$options --add-platform --conservative --full-index + --local --lockfile --major --minor --patch --print + --remove-platform --strict --update";; + package) + options="$options --all --all-platforms";; + platform) + options="$options --ruby";; + show) + options="$options --outdated --paths --no-paths";; + update) + options="$options --bundler --conservative --force --full-index + --group --jobs --local --major --minor --patch --quiet + --ruby --source --strict";; + viz) + options="$options -f -F -R -v -W --file --format --requirements + --no-requirements --version --no-version --without";; + esac + else + case $bundle_command in + "" | help) + options="help install update package exec config + check show outdated console open lock viz init gem + platform clean doctor" + ;; + check | install) + case $prev in + --binstubs | --path) + _filedir -d + return;; + --standalone | --with | --without) + __bundle_complete_groups + return;; + --trust-policy) + options="HighSecurity MediumSecurity LowSecurity + AlmostNoSecurity NoSecurity";; + esac + ;; + config) + case $prev in + config | --*) + case $cur in + local.*) + options=($(__bundle_exec_ruby 'puts Bundler.definition.specs.to_hash.keys')) + options=("${options[*]/#/local.}") + ;; + *) + options=(path frozen without bin gemfile ssl_ca_cert + ssl_client_cert cache_path disable_multisource + ignore_messages retry redirect timeout + force_ruby_platform specific_platform + disable_checksum_validation disable_version_check + allow_offline_install auto_install + cache_all_platforms cache_all clean console + disable_exec_load disable_local_branch_check + disable_shared_gems jobs major_deprecations + no_install no_prune only_update_to_newer_versions + plugins shebang silence_root_warning + ssl_verify_mode system_bindir user_agent) + # We want to suggest the options above as complete words, + # and also "local." and "mirror." as prefixes + # To achieve that, disable automatic space insertion, + # insert it manually, then add the non-spaced prefixes + compopt -o nospace + options=("${options[@]/%/ }") + # And add prefix suggestions + options+=(local. mirror.) + # Override $IFS for completion to work + local IFS=$'\n' + COMPREPLY=($(compgen -W '${options[@]}' -- "$cur")) + return + ;; + esac + ;; + path | local.*) + _filedir -d + return;; + esac + ;; + exec) + 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 + local binaries=("$bundler_bin"/*) + # If there are binaries, strip directory name and use them + [[ -f "$binaries" ]] && options="${binaries[@]##*/}" + else + # No binaries found; use full command completion + COMPREPLY=($(compgen -c -- "$cur")) + return + fi + else + local _RUBY_COMMAND_PREFIX=("${bundle_bin[@]}" exec) + _command_offset $bundle_command_index + return + fi + ;; + gem) + case $prev in + -e | --edit) + COMPREPLY=($(compgen -c -- "$cur")) + return;; + -t | --test) + options="minitest rspec";; + esac + ;; + update) + case $prev in + --group) + __bundle_complete_groups + return;; + *) + options=($(__bundle_exec_ruby 'puts Bundler.definition.specs.to_hash.keys')) + esac + ;; + viz) + case $prev in + -F | --format) + options="dot jpg png svg";; + -W | --without) + __bundle_complete_groups + return;; + esac + ;; + esac + fi + COMPREPLY=($(compgen -W "${options[*]}" -- "$cur")) } __bundle_get_command() { @@ -38,18 +198,76 @@ __bundle_get_command() { case $arg in [^-]*) bundle_command=$arg + bundle_command_index=$((i + 1)) return;; --version) - # command-killer + # Command-killer bundle_command=- return;; --help) bundle_command=help + bundle_command_index=$((i + 1)) return;; esac done } +# Provides completion for Bundler group names. +# +# 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() { + # 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 + COMPREPLY=() + return + fi + # Duplicate "default" and anything already in $prefix, so that `uniq` + # strips it; groups may be separated by ':', ' ', or '\ ' + local excluded=$'\ndefault\n'${prefix//[: \'\"\\]/$'\n'} + # Include them twice to ensure they are duplicates + groups=$groups$excluded$excluded + COMPREPLY=($(compgen -W "$(sort <<<"$groups" | uniq -u)" -- "$cur_group")) + # Prepend prefix to all entries + COMPREPLY=("${COMPREPLY[@]/#/$prefix}") + __ltrim_colon_completions "$cur" +} + +# __bundle_exec_ruby