Repository: ohmybash/oh-my-bash Branch: master Commit: 05e6d038524c Files: 304 Total size: 1.0 MB Directory structure: gitextract_1l1cb4dc/ ├── .editorconfig ├── .git-blame-ignore-revs ├── .github/ │ ├── FUNDING.yml │ └── workflows/ │ ├── format.yml │ ├── test.sh │ └── test.yml ├── .gitignore ├── .shellcheckrc ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── LICENSE.md ├── README.md ├── aliases/ │ ├── README.md │ ├── cargo.aliases.md │ ├── cargo.aliases.sh │ ├── chmod.aliases.sh │ ├── debian.aliases.bash │ ├── debian.aliases.md │ ├── docker.aliases.md │ ├── docker.aliases.sh │ ├── general.aliases.md │ ├── general.aliases.sh │ ├── ls.aliases.sh │ ├── misc.aliases.sh │ ├── package-manager.aliases.bash │ ├── package-manager.aliases.md │ ├── terraform.aliases.md │ └── terraform.aliases.sh ├── cache/ │ └── .gitkeep ├── completions/ │ ├── apm.completion.sh │ ├── asdf.completion.sh │ ├── awscli.completion.sh │ ├── brew.completion.sh │ ├── bundler.completion.sh │ ├── capistrano.completion.sh │ ├── chezmoi.completion.sh │ ├── composer.completion.sh │ ├── conda.completion.sh │ ├── crc.completion.sh │ ├── defaults.completion.sh │ ├── dirs.completion.sh │ ├── django.completion.sh │ ├── docker-compose.completion.sh │ ├── docker-machine.completion.sh │ ├── docker.completion.sh │ ├── drush.completion.sh │ ├── fabric-completion.sh │ ├── fallback/ │ │ ├── docker-compose.bash │ │ └── docker.bash │ ├── gem.completion.sh │ ├── gh.completion.sh │ ├── git.completion.bash │ ├── git_flow.completion.sh │ ├── git_flow_avh.completion.sh │ ├── go.completion.sh │ ├── gradle.completion.sh │ ├── grunt.completion.sh │ ├── gulp.completion.sh │ ├── helm.completion.sh │ ├── homesick.completion.sh │ ├── hub.completion.sh │ ├── jboss7.completion.sh │ ├── jump.completion.sh │ ├── jungle.completion.sh │ ├── kontena.completion.sh │ ├── kubectl.completion.sh │ ├── makefile.completion.sh │ ├── maven.completion.sh │ ├── minikube.completion.sh │ ├── npm.completion.sh │ ├── nvm.completion.sh │ ├── oc.completion.sh │ ├── packer.completion.sh │ ├── pip.completion.sh │ ├── pip3.completion.sh │ ├── projects.completion.sh │ ├── rake.completion.sh │ ├── salt.completion.sh │ ├── sdkman.completion.sh │ ├── ssh.completion.sh │ ├── svn.completion.sh │ ├── system.completion.sh │ ├── terraform.completion.sh │ ├── test_kitchen.completion.sh │ ├── tkn.completion.sh │ ├── tmux.completion.sh │ ├── todo.completion.sh │ ├── uv.completion.sh │ ├── vagrant.completion.sh │ ├── vault.completion.sh │ └── virtualbox.completion.sh ├── lib/ │ ├── base.sh │ ├── bourne-shell.sh │ ├── cli.bash │ ├── directories.sh │ ├── functions.sh │ ├── git.sh │ ├── grep.sh │ ├── history.sh │ ├── misc.sh │ ├── mo.sh │ ├── nvm.sh │ ├── omb-completion.sh │ ├── omb-deprecate.sh │ ├── omb-prompt-base.sh │ ├── omb-prompt-colors.sh │ ├── omb-util.sh │ ├── readlink.sh │ ├── shopt.sh │ ├── spectrum.sh │ ├── spinner.sh │ ├── theme-and-appearance.sh │ └── utils.sh ├── log/ │ └── .gitkeep ├── oh-my-bash.sh ├── plugins/ │ ├── README.md │ ├── ansible/ │ │ ├── README.md │ │ └── ansible.plugin.sh │ ├── asdf/ │ │ ├── README.md │ │ └── asdf.plugin.sh │ ├── aws/ │ │ └── aws.plugin.sh │ ├── bash-preexec/ │ │ ├── README.md │ │ └── bash-preexec.plugin.sh │ ├── bashmarks/ │ │ ├── README.md │ │ └── bashmarks.plugin.sh │ ├── battery/ │ │ ├── README.md │ │ └── battery.plugin.sh │ ├── brew/ │ │ ├── README.md │ │ └── brew.plugin.sh │ ├── bu/ │ │ └── bu.plugin.sh │ ├── cargo/ │ │ ├── README.md │ │ └── cargo.plugin.sh │ ├── chezmoi/ │ │ ├── README.md │ │ └── chezmoi.plugin.sh │ ├── colored-man-pages/ │ │ ├── README.md │ │ └── colored-man-pages.plugin.sh │ ├── dotnet/ │ │ ├── README.md │ │ └── dotnet.plugin.sh │ ├── fasd/ │ │ └── fasd.plugin.sh │ ├── fzf/ │ │ ├── README.md │ │ └── fzf.plugin.sh │ ├── gcloud/ │ │ ├── README.md │ │ └── gcloud.plugin.sh │ ├── git/ │ │ ├── README.md │ │ └── git.plugin.sh │ ├── goenv/ │ │ ├── README.md │ │ └── goenv.plugin.sh │ ├── golang/ │ │ ├── README.md │ │ └── golang.plugin.sh │ ├── jump/ │ │ ├── README.md │ │ └── jump.plugin.sh │ ├── kubectl/ │ │ ├── README.md │ │ └── kubectl.plugin.sh │ ├── npm/ │ │ ├── README.md │ │ └── npm.plugin.sh │ ├── nvm/ │ │ ├── README.md │ │ └── nvm.plugin.sh │ ├── progress/ │ │ ├── README.md │ │ └── progress.plugin.sh │ ├── pyenv/ │ │ ├── README.md │ │ └── pyenv.plugin.sh │ ├── rbenv/ │ │ ├── README.md │ │ └── rbenv.plugin.sh │ ├── sdkman/ │ │ ├── README.md │ │ └── sdkman.plugin.sh │ ├── starship/ │ │ ├── README.md │ │ └── starship.plugin.sh │ ├── sudo/ │ │ ├── README.md │ │ └── sudo.plugin.sh │ ├── tmux/ │ │ ├── README.md │ │ └── tmux.plugin.bash │ ├── tmux-autoattach/ │ │ ├── README.md │ │ └── tmux-autoattach.plugin.sh │ ├── vagrant/ │ │ ├── README.md │ │ └── vagrant.plugin.sh │ ├── virtualenvwrapper/ │ │ ├── README.md │ │ └── virtualenvwrapper.plugin.sh │ ├── xterm/ │ │ ├── README.md │ │ └── xterm.plugin.bash │ ├── zellij-autoattach/ │ │ ├── README.md │ │ └── zellij-autoattach.plugin.sh │ └── zoxide/ │ ├── README.md │ └── zoxide.plugin.sh ├── templates/ │ ├── bash_profile.osh-template │ └── bashrc.osh-template ├── themes/ │ ├── 90210/ │ │ ├── 90210.theme.sh │ │ └── README.md │ ├── THEMES.md │ ├── absimple/ │ │ ├── README.md │ │ └── absimple.theme.sh │ ├── agnoster/ │ │ ├── README.md │ │ └── agnoster.theme.sh │ ├── axin/ │ │ ├── README.md │ │ └── axin.theme.sh │ ├── bakke/ │ │ ├── README.md │ │ └── bakke.theme.sh │ ├── binaryanomaly/ │ │ ├── README.md │ │ └── binaryanomaly.theme.sh │ ├── bobby/ │ │ ├── README.md │ │ └── bobby.theme.sh │ ├── bobby-python/ │ │ └── bobby-python.theme.sh │ ├── brainy/ │ │ ├── README.md │ │ └── brainy.theme.sh │ ├── brunton/ │ │ └── brunton.theme.sh │ ├── candy/ │ │ └── candy.theme.sh │ ├── clean/ │ │ └── clean.theme.sh │ ├── cooperkid/ │ │ └── cooperkid.theme.sh │ ├── copied-duru/ │ │ ├── README.md │ │ └── copied-duru.theme.sh │ ├── cupcake/ │ │ └── cupcake.theme.sh │ ├── demula/ │ │ └── demula.theme.sh │ ├── developer/ │ │ └── developer.theme.sh │ ├── dos/ │ │ └── dos.theme.sh │ ├── doubletime/ │ │ └── doubletime.theme.sh │ ├── doubletime_multiline/ │ │ └── doubletime_multiline.theme.sh │ ├── doubletime_multiline_pyonly/ │ │ └── doubletime_multiline_pyonly.theme.sh │ ├── dulcie/ │ │ └── dulcie.theme.sh │ ├── duru/ │ │ └── duru.theme.sh │ ├── edsonarios/ │ │ └── edsonarios.theme.sh │ ├── emperor/ │ │ └── emperor.theme.sh │ ├── envy/ │ │ └── envy.theme.sh │ ├── font/ │ │ └── font.theme.sh │ ├── gallifrey/ │ │ └── gallifrey.theme.sh │ ├── garo/ │ │ └── garo.theme.sh │ ├── half-life/ │ │ └── half-life.theme.sh │ ├── hawaii50/ │ │ └── hawaii50.theme.sh │ ├── ht/ │ │ └── ht.theme.sh │ ├── iterate/ │ │ └── iterate.theme.sh │ ├── kitsune/ │ │ └── kitsune.theme.sh │ ├── lambda/ │ │ └── lambda.theme.sh │ ├── luan/ │ │ └── luan.theme.sh │ ├── lucky/ │ │ └── lucky.theme.sh │ ├── mairan/ │ │ └── mairan.theme.sh │ ├── mbriggs/ │ │ └── mbriggs.theme.sh │ ├── minimal/ │ │ └── minimal.theme.sh │ ├── minimal-gh/ │ │ └── minimal-gh.theme.sh │ ├── modern/ │ │ └── modern.theme.sh │ ├── modern-t/ │ │ └── modern-t.theme.sh │ ├── morris/ │ │ └── morris.theme.sh │ ├── n0qorg/ │ │ └── n0qorg.theme.sh │ ├── nekolight/ │ │ ├── README.md │ │ └── nekolight.theme.sh │ ├── nekonight/ │ │ ├── nekonight.base.sh │ │ └── nekonight.theme.sh │ ├── nekonight_moon/ │ │ └── nekonight_moon.theme.sh │ ├── nwinkler/ │ │ └── nwinkler.theme.sh │ ├── nwinkler_random_colors/ │ │ ├── README.md │ │ └── nwinkler_random_colors.theme.sh │ ├── pete/ │ │ └── pete.theme.sh │ ├── powerbash10k/ │ │ ├── README.md │ │ └── powerbash10k.theme.sh │ ├── powerline/ │ │ ├── README.md │ │ ├── powerline.base.sh │ │ └── powerline.theme.sh │ ├── powerline-icon/ │ │ ├── README.md │ │ ├── powerline-icon.base.sh │ │ └── powerline-icon.theme.sh │ ├── powerline-light/ │ │ ├── README.md │ │ └── powerline-light.theme.sh │ ├── powerline-multiline/ │ │ ├── README.md │ │ ├── powerline-multiline.base.sh │ │ └── powerline-multiline.theme.sh │ ├── powerline-naked/ │ │ ├── README.md │ │ ├── powerline-naked.base.sh │ │ └── powerline-naked.theme.sh │ ├── powerline-plain/ │ │ ├── README.md │ │ ├── powerline-plain.base.sh │ │ └── powerline-plain.theme.sh │ ├── powerline-wizard/ │ │ ├── README.md │ │ └── powerline-wizard.theme.sh │ ├── primer/ │ │ └── primer.theme.sh │ ├── pro/ │ │ └── pro.theme.sh │ ├── pure/ │ │ └── pure.theme.sh │ ├── purity/ │ │ └── purity.theme.sh │ ├── pzq/ │ │ └── pzq.theme.sh │ ├── rainbowbrite/ │ │ └── rainbowbrite.theme.sh │ ├── rana/ │ │ └── rana.theme.sh │ ├── random/ │ │ ├── README.md │ │ └── random.theme.bash │ ├── rjorgenson/ │ │ └── rjorgenson.theme.sh │ ├── robbyrussell/ │ │ └── robbyrussell.theme.sh │ ├── roderik/ │ │ └── roderik.theme.sh │ ├── rr/ │ │ └── rr.theme.sh │ ├── sexy/ │ │ └── sexy.theme.sh │ ├── simple/ │ │ └── simple.theme.sh │ ├── sirup/ │ │ └── sirup.theme.sh │ ├── slick/ │ │ └── slick.theme.sh │ ├── standard/ │ │ └── standard.theme.sh │ ├── tonka/ │ │ └── tonka.theme.sh │ ├── tonotdo/ │ │ └── tonotdo.theme.sh │ ├── tylenol/ │ │ └── tylenol.theme.sh │ ├── vscode/ │ │ └── vscode.theme.sh │ ├── wanelo/ │ │ └── wanelo.theme.sh │ ├── zitron/ │ │ └── zitron.theme.sh │ └── zork/ │ └── zork.theme.sh └── tools/ ├── autossh.sh ├── bash-preexec.sh ├── check_for_upgrade.sh ├── git-completion.bash ├── git-prompt.sh ├── install.sh ├── uninstall.sh ├── update-wiki-themes.sh └── upgrade.sh ================================================ FILE CONTENTS ================================================ ================================================ FILE: .editorconfig ================================================ # EditorConfig is awesome: http://EditorConfig.org # top-most EditorConfig file root = true # Unix-style newlines with a newline ending every file [*] end_of_line = lf charset = utf-8 trim_trailing_whitespace = true insert_final_newline = true # Matches multiple files with brace expansion notation [*.{sh,py,yml}] indent_style = space indent_size = 2 ================================================ FILE: .git-blame-ignore-revs ================================================ # style: Remove trailing whitespace and add missing final newlines 5cd1f0eb1668f06bf20378d6d4308fd4a1890581 ================================================ FILE: .github/FUNDING.yml ================================================ # These are supported funding model platforms github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] patreon: nntoan open_collective: # Replace with a single Open Collective username ko_fi: # Replace with a single Ko-fi username tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry liberapay: # Replace with a single Liberapay username issuehunt: # Replace with a single IssueHunt username otechie: # Replace with a single Otechie username custom: ['https://www.buymeacoffee.com/nntoan']# Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] ================================================ FILE: .github/workflows/format.yml ================================================ name: "Check EditorConfig Format" on: push: branches: - "*" pull_request: branches: - "*" jobs: lint: runs-on: "ubuntu-22.04" steps: - name: "Get Changed Files" id: "files" uses: "masesgroup/retrieve-changed-files@v2" with: format: "json" - name: Check out code. uses: actions/checkout@v2 - uses: 'actions/setup-go@v4' with: go-version: '1.20' - name: "Check EditorConfig Lint" env: EDITORCONFIG_FLAGS: '-disable-indent-size -disable-indentation' run: | sudo apt install -y jq go install 'github.com/editorconfig-checker/editorconfig-checker/cmd/editorconfig-checker@latest' readarray -t changed_files <<<"$(jq -r '.[]' <<<'${{ steps.files.outputs.added_modified }}')" ~/go/bin/editorconfig-checker ${{ env.EDITORCONFIG_FLAGS }} ${changed_files[@]} ================================================ FILE: .github/workflows/test.sh ================================================ #!/usr/bin/env bash set -e tmpdir=$(mktemp -d) export OSH="$tmpdir/path with space" export HOME="$tmpdir/home with space" mkdir -p "$HOME" OSH_REPOSITORY="$PWD" ./tools/install.sh source "$HOME/.bashrc" set | grep -aE "^OSH" if [[ "$OSH_THEME" == "font" ]]; then echo "Installation succeeded" else echo "Installation failed, \$OSH_THEME is not set to 'font'" exit 1 fi ================================================ FILE: .github/workflows/test.yml ================================================ name: Test on: push: branches: - '*' pull_request: branches: - '*' jobs: test: runs-on: ${{ matrix.os }} strategy: matrix: # ubuntu-20.04 available: https://github.com/actions/virtual-environments/issues/1816 os: [ubuntu-latest, windows-latest, macos-latest] steps: - uses: actions/checkout@v2 with: fetch-depth: 1 submodules: false - name: Upgrade bash on Mac if: runner.os == 'macOs' run: brew install bash - name: Install oh-my-bash shell: bash run: bash --noprofile --norc -i "$PWD/.github/workflows/test.sh" ================================================ FILE: .gitignore ================================================ # custom files !/custom/aliases/example.aliases.sh !/custom/completions/example.completion.sh !/custom/plugins/example/ !/custom/themes/example/ !/custom/example.sh /custom/ # temp files directories /cache/ /log/ !/cache/.gitkeep !/log/.gitkeep # disabled files *.swp *.disabled .idea/ *.tmp ================================================ FILE: .shellcheckrc ================================================ disable=SC1087 # Use braces when expanding arrays -- needed for Zsh, not Bash ================================================ FILE: CODE_OF_CONDUCT.md ================================================ # Contributor Covenant Code of Conduct ## Our Pledge In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation. ## Our Standards Examples of behavior that contributes to creating a positive environment include: * Using welcoming and inclusive language * Being respectful of differing viewpoints and experiences * Gracefully accepting constructive criticism * Focusing on what is best for the community * Showing empathy towards other community members Examples of unacceptable behavior by participants include: * The use of sexualized language or imagery and unwelcome sexual attention or advances * Trolling, insulting/derogatory comments, and personal or political attacks * Public or private harassment * Publishing others' private information, such as a physical or electronic address, without explicit permission * Other conduct which could reasonably be considered inappropriate in a professional setting ## Our Responsibilities Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior. Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful. ## Scope This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers. ## Enforcement Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at OhMyBasher@gmail.com. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately. Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership. ## Attribution This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version] [homepage]: http://contributor-covenant.org [version]: http://contributor-covenant.org/version/1/4/ ================================================ FILE: CONTRIBUTING.md ================================================ # CONTRIBUTING GUIDELINES Oh-My-Bash is a community-driven project. Contribution is welcome, encouraged and appreciated. It is also essential for the development of the project. These guidelines are an attempt at better addressing the huge amount of pending issues and pull requests. Please read them closely. Foremost, be so kind as to [search](#use-the-search-luke). This ensures any contribution you would make is not already covered. * [Issues](#reporting-issues) * [You have a problem](#you-have-a-problem) * [You have a suggestion](#you-have-a-suggestion) * [Pull Requests](#pull-requests) * [Getting started](#getting-started) * [You have a solution](#you-have-a-solution) * [New Theme](#new-theme) * [New Plugin](#new-plugin) * [Copyright and responsibility](#copyright-and-responsibility) * [Improving PR](#improving-pr) * [Information sources (_aka_ search)](#use-the-search-luke) **BONUS:** [Volunteering](#you-have-spare-time-to-volunteer) ## Reporting Issues ### You have a problem Please be so kind as to [search](#use-the-search-luke) for any open issue already covering your problem. If you find one, comment on it so we can know there are more people experiencing it. If not, look at the [Troubleshooting](https://github.com/ohmybash/oh-my-bash/wiki/Troubleshooting) page for instructions on how to gather data to better debug your problem. Then, you can go ahead and create an issue with as much detail as you can provide. It should include the data gathered as indicated above, along with: 1. How to reproduce the problem 2. What the correct behavior should be 3. What the actual behavior is Please copy to anyone relevant (e.g. plugin maintainers) by mentioning their GitHub handle (starting with `@`) in your message. We will do our very best to help you. ### You have a suggestion Please be so kind as to [search](#use-the-search-luke) for any open issue already covering your suggestion. If you find one, comment on it so we can know there are more people supporting it. If not, you can go ahead and create an issue. Please copy to anyone relevant (_eg_ plugin maintainers) by mentioning their GitHub handle (starting with `@`) in your message. ## Pull Requests The code should work with Bash 3.2. Make all the changes to be POSIX-compatible for external tools unless it is related to a plugin that clearly targets specific tools or environment such as "GNU make" or "macOS". ### Getting started Before starting to work on it, please be so kind as to [search](#use-the-search-luke) for any open issues, and any pending/merged/rejected PRs covering or related to what you are going to change. - If you try to solve a [problem](#you-have-a-problem) and a solution to the problem is already reported, try it out and +1 the pull request if the solution works OK. On the other hand, if you think your solution is better, post it with a reference to the other one so we can have both solutions to compare. - If you find an existing PR that is related, try it out and work with the author on a common solution. - If not, then go ahead and submit a PR. Please copy to anyone relevant (e.g. plugin maintainers) by mentioning their GitHub handle (starting with `@`) in your message. You should be familiar with the basics of [contributing on GitHub](https://help.github.com/articles/using-pull-requests) and have a fork [properly set up](https://github.com/ohmybash/oh-my-bash/wiki/Contribution-Technical-Practices). You MUST always create a PR with _a dedicated branch_ (i.e., a branch that is NOT `master`) based on the latest upstream tree. The commit message typically has the following form (with the first word in the verbal phrase being in the infinitive and capitalized): ```
: ``` The conventional commits are also accepted: ``` (
): ``` When you open a new PR, please make sure you do it right. Also, reference in the PR description body any issues that would be solved by the PR, [for instance](https://help.github.com/articles/closing-issues-via-commit-messages/) _"Fixes #XXXX"_ for issue number XXXX. ### You have a solution If you try to fix a problem or solve an issue in a specific plugin/theme/aliases, please also check the other modules if they have a similar issue or can be improved in a similar way. ### New Theme A new theme is often created by modifying an existing theme. In that case, please clarify from which theme the new theme is derived from. If possible, it is recommended to source the original theme file `"$OSH"/themes//.base.sh` or `"$OSH"/themes//.theme.sh` in the new theme file `"$OSH"/themes//.theme.sh` and include only the new parts in the new theme file. The theme needs to have exactly one image file. The image size needs to be height ~290px and width 600..800px to make the theme gallery aligned and also to keep the repository size small. The filename should be `-dark.png` or `-light.png` depending on the dark or light background of the terminal used to make the image. The image should be unscaled screen shot of a terminal. If the terminal size is larger than the expected image size, the image should be clipped instead of being resized and downscaled. When you add a new theme, please also update [themes/THEMES.md](https://github.com/ohmybash/oh-my-bash/blob/master/themes/THEMES.md). After your new theme is merged, the list in [Themes](https://github.com/ohmybash/oh-my-bash/wiki/Themes) in the wiki also needs to be updated. ### New Plugin A new plugin is accepted when it is needed to implement features in themes or when it provides significantly useful tools for interactive uses. To show that it is worth including in Oh My Bash, you will have to find testers to +1 your PR. When you add a new plugin, please also update [plugins/README.md](https://github.com/ohmybash/oh-my-bash/blob/master/plugins/README.md). ### Copyright and responsibility If you submit codes derived from other's work, please confirm that the license is compatible with the MIT license. Please clarify which part is your own work and which is not in the code and include **the copyright notice of the original authors**. You may also include your own copyright notice, but we may omit them because we can track them in the Git history. You can provide codes under any licenses which are compatible with the MIT license. When you submit and update a PR (*NOT when the PR is merged*), unless otherwise specified, **we assume that you provide the codes/texts under the MIT license**. If you would like to provide the codes/texts with another license, please specify it in the codes/texts. If you forgot to declare the license that is not MIT, you can later declare it for the part you contributed. Do not submit AI-generated codes/documentation unless you understand both the generated codes/documentation and the related **exiting codebase**. You are required to be responsible for requests to the changes and reports of the issues for the submitted codes/documentation. Also, please confirm that the generated codes/texts can be included in Oh My Bash **with your own copyright under the MIT license**. ### Improving PR After opening PRs, you will usually receive requests for changes. It is rare for a PR to be merged without any modifications. Please be so kind as to respond to the requests. If you have any questions, please feel free to ask further. If you become busy, please tell us that instead of ignoring our messages. You are expected to notify when you will be available again, hand over the PR to others, or to notify that you would discard the PR. After the final version of the PR is settled, the fix-up commits that fix problems introduced in earlier commits in the same PR will be squashed. Also, the commits whose purposes heavily overlap will be squashed. For this reason, a weight of one commit is not equal for different types of contributions. For the new theme/plugin/aliases, the PR is likely to be squashed into a single commit unless the changes are properly separated into commits for respective purposes. On the other hand, PRs including several minor fixes to the exiting codebase will not be squashed because each commit gives a separate fix to the exiting code. ### Naming convention of functions and global variables Initially, we haven't cared about the naming convention very much, but we now try to improve it. In particular, the new codes should follow this naming convention. The contributions to improve old codes are also welcome, but we also need to keep the backward compatibility. See [Discussion #280](https://github.com/ohmybash/oh-my-bash/discussions/280) for background. The functions/aliases that are supposed to be used as interactive commands can have arbitrary names including short ones. The functions that are used from the other functions have the names of the form `_omb_*`. * The functions defined by libraries has the form `_omb_${namespace}_${funcname}` * The functions defined by a specific plugin has the form `_omb_plugin_${plugin_name}_${funcname}` * The functions defined by a specific theme has the form `_omb_theme_${theme_name}_${funcname}` * Some important functions might have the name `_omb_${funcname}` directly put under `_omb` namespace. Public global variables that can be used to configure the behavior of oh-my-bash have the form `OMB_*`. * The settings for the main oh-my-bash behavior have the names of the form `OMB_${config^^}` * The settings for the detailed behavior have the names of the form `OMB_${namespace^^}_${config^^}` * The settings for a specific plugin has the form `OMB_PLUGIN_${plugin_name^^}_${config^^}` * The settings for a specific theme has the form `OMB_THEME_${theme_name^^}_${config^^}` Internal global variables put into global variables used by oh-my-bash has the form `_omb_*`. * The internal variables defined by libraries has the form `_omb_${namespace}_${varname}` * The internal variables used by a specific plugin has the form `_omb_plugin_${plugin_name}_${varname}` * The internal variables used by a specific theme has the form `_omb_theme_${theme_name}_${varname}` * Some important variables might have the name `_omb_${varname}` directly put under `_omb` namespace. There are no restrictions on the local variable names. A prefix like `_omb_${namespace}_` is unnecessary because the namespace of the local variables is separated for each function call. ---- ## Use the Search, Luke _May the Force (of past experiences) be with you_ GitHub offers [many search features](https://help.github.com/articles/searching-github/) to help you check whether a similar contribution to yours already exists. Please search before making any contribution, it avoids duplicates and eases maintenance. Trust me, that works 90% of the time. You can also take a look at the [FAQ](https://github.com/ohmybash/oh-my-bash/wiki/FAQ) to be sure your contribution has not already come up. If all fails, your thing has probably not been reported yet, so you can go ahead and [create an issue](#reporting-issues) or [submit a PR](#submitting-pull-requests). ---- ### You have spare time to volunteer Very nice!! :) Please have a look at the [Volunteer](https://github.com/ohmybash/oh-my-bash/wiki/Volunteers) page for instructions on where to start and more. ================================================ FILE: LICENSE.md ================================================ Copyright (c) 2009-2017 Robby Russell and contributors (https://github.com/ohmyzsh/ohmyzsh/contributors) Copyright 2017-present Toan Nguyen and contributors (https://github.com/ohmybash/oh-my-bash/graphs/contributors) 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. ================================================ FILE: README.md ================================================ Oh My Bash is an open source, community-driven framework for managing your [bash](https://www.gnu.org/software/bash/) configuration. Sounds boring. Let's try again. Oh My Bash will not make you a 10x developer...but you might feel like one. Once installed, your terminal shell will become the talk of the town or your money back! With each keystroke in your command prompt, you'll take advantage of the hundreds of powerful plugins and beautiful themes. Strangers will come up to you in cafés and ask you, "that is amazing! are you some sort of genius?" Finally, you'll begin to get the sort of attention that you have always felt you deserved. ...or maybe you'll use the time that you're saving to start flossing more often. ## Getting Started ### Prerequisites __Disclaimer:__ _Oh My Bash works best on macOS and Linux._ * Unix-like operating system (macOS or Linux) * `curl` or `wget` should be installed * `git` should be installed ### Basic Installation Oh My Bash is installed by running one of the following commands in your terminal. You can install this via the command-line with either `curl` or `wget`. #### via curl ```shell bash -c "$(curl -fsSL https://raw.githubusercontent.com/ohmybash/oh-my-bash/master/tools/install.sh)" ``` #### via wget ```shell bash -c "$(wget https://raw.githubusercontent.com/ohmybash/oh-my-bash/master/tools/install.sh -O -)" ``` This replaces `~/.bashrc` with the version provided by Oh My Bash. The original `.bashrc` is backed up with the name `~/.bashrc.omb-TIMESTAMP`. If `~/.bash_profile` does not exist, this also creates a new file `~/.bash_profile` with the default contents. ⚠️ If `~/.bash_profile` already existed before Oh My Bash is installed, please make sure that`~/.bash_profile` contains the line `source ~/.bashrc` or `. ~/.bashrc`. If not, please add the following three lines in `~/.bash_profile`: ```bash if [[ -f ~/.bashrc ]]; then source ~/.bashrc fi ``` ## Using Oh My Bash ### Plugins Oh My Bash comes with a shit load of plugins to take advantage of. You can take a look in the [plugins](https://github.com/ohmybash/oh-my-bash/tree/master/plugins) directory and/or the [wiki](https://github.com/ohmybash/oh-my-bash/wiki/Plugins) to see what's currently available. #### Enabling Plugins Once you spot a plugin (or several) that you'd like to use with Oh My Bash, you'll need to enable them in the `.bashrc` file. You'll find the bashrc file in your `$HOME` directory. Open it with your favorite text editor and you'll see a spot to list all the plugins you want to load. For example, this line might begin to look like this: ```shell plugins=(git bundler osx rake ruby) ``` ##### With Conditionals You may want to control when and/or how plugins should be enabled. For example, if you want the `tmux-autoattach` plugin to only run on SSH sessions, you could employ a trivial conditional that checks for the `$SSH_TTY` variable. Just make sure to remove the plugin from the larger plugin list. ``` bash [ "$SSH_TTY" ] && plugins+=(tmux-autoattach) ``` #### Using Plugins Most plugins (should! we're working on this) include a __README__, which documents how to use them. ### Themes We'll admit it. Early in the Oh My Bash world, we may have gotten a bit too theme happy. We have over one hundred themes now bundled. Most of them have [screenshots](https://github.com/ohmybash/oh-my-bash/wiki/Themes) on our wiki or alternatively [oh-my-zsh](https://github.com/robbyrussell/oh-my-zsh/wiki/themes) wiki. #### Selecting a Theme _The font theme is the default one. It's not the fanciest one. It's not the simplest one. It's just the right one for the original maintainer of Oh My Bash._ Once you find a theme that you want to use, you will need to edit the `~/.bashrc` file. You'll see an environment variable (all caps) in there that looks like: ```shell OSH_THEME="font" ``` To use a different theme, simply change the value to match the name of your desired theme. For example: ```shell OSH_THEME="agnoster" # (this is one of the fancy ones) # you might need to install a special Powerline font on your console's host for this to work # see https://github.com/ohmybash/oh-my-bash/wiki/Themes#agnoster ``` Open up a new terminal window and your prompt should look something like this: ![Font theme](themes/font/font-dark.png) In case you did not find a suitable theme for your needs, please have a look at the wiki for [more of them](https://github.com/ohmybash/oh-my-bash/wiki/Themes). If you're feeling feisty, you can let the computer select one randomly for you each time you open a new terminal window. ```shell OSH_THEME="random" # (...please let it be pie... please be some pie..) ``` If you want to randomly select a theme from a specified list, you can set the list in the following array: ```shell OMB_THEME_RANDOM_CANDIDATES=("font" "powerline-light" "minimal") ``` If there are themes you don't like, you can add them to an ignored list: ```shell OMB_THEME_RANDOM_IGNORED=("powerbash10k" "wanelo") ``` The selected theme name can be checked by the following command: ```shell $ echo "$OMB_THEME_RANDOM_SELECTED" ``` ## Advanced Topics If you're the type that likes to get their hands dirty, these sections might resonate. ### Advanced Installation Some users may want to change the default path, or manually install Oh My Bash. #### Custom Directory The default location is `~/.oh-my-bash` (hidden in your home directory) If you'd like to change the install directory with the `OSH` environment variable, either by running `export OSH=/your/path` before installing, or by setting it before the end of the install pipeline like this: ```shell export OSH="$HOME/.dotfiles/oh-my-bash"; bash -c "$(curl -fsSL https://raw.githubusercontent.com/ohmybash/oh-my-bash/master/tools/install.sh)" ``` #### Unattended install If you're running the Oh My Bash install script as part of an automated install, you can pass the flag `--unattended` to the `install.sh` script. This will have the effect of not trying to change the default shell, and also won't run `bash` when the installation has finished. ```sh bash -c "$(curl -fsSL https://raw.githubusercontent.com/ohmybash/oh-my-bash/master/tools/install.sh)" --unattended ``` #### System-wide installation For example, Oh My Bash can be installed to `/usr/local/share/oh-my-bash` for the system-wide installation by specifying the option `--prefix=PREFIX`. ```sh bash -c "$(curl -fsSL https://raw.githubusercontent.com/ohmybash/oh-my-bash/master/tools/install.sh)" --prefix=/usr/local ``` To enable Oh My Bash, the Bash startup file `.bashrc` needs to be manually set up by each user. The template of `.bashrc` is available in `PREFIX/share/oh-my-bash/bashrc`. The users can copy the template file to `~/.bashrc` and edit it. ```bash cp /usr/local/share/oh-my-bash/bashrc ~/.bashrc ``` #### Manual Installation ##### 1. Clone the repository: ```shell git clone https://github.com/ohmybash/oh-my-bash.git ~/.oh-my-bash ``` ##### 2. *Optionally*, backup your existing `~/.bashrc` file: ```shell cp ~/.bashrc ~/.bashrc.orig ``` ##### 3. Create a new sh configuration file You can create a new sh config file by copying the template that we have included for you. ```shell cp ~/.oh-my-bash/templates/bashrc.osh-template ~/.bashrc ``` ##### 4. Reload your .bashrc ```shell source ~/.bashrc ``` ##### 5. Initialize your new bash configuration Once you open up a new terminal window, it should load sh with Oh My Bash's configuration. ### Installation Problems If you have any hiccups installing, here are a few common fixes. * You _might_ need to modify your `PATH` in `~/.bashrc` if you're not able to find some commands after switching to `oh-my-bash`. * If you installed manually or changed the install location, check the `OSH` environment variable in `~/.bashrc`. ### Customization of Plugins and Themes If you want to override any of the default behaviors, just add a new file (ending in `.sh`) in the `custom/` directory. If you have many functions that go well together, you can put them as a `XYZ.plugin.sh` file in the `custom/plugins/XYZ` directory and then enable this plugin by adding the name to the `plugins` array in `~/.bashrc`. If you would like to modify an existing module (theme/plugin/aliases/completion) bundled with Oh My Bash, first copy the original module to `custom/` directory and modify it. It will be loaded instead of the original one when it is enabled through `OSH_THEME`/`plugins`/`aliases`/`completions` in `~/.bashrc`. ```bash $ mkdir -p "$OSH_CUSTOM/themes" $ cp -r {"$OSH","$OSH_CUSTOM"}/themes/agnoster $ EDIT "$OSH_CUSTOM/themes/agnoster/agnoster.theme.sh" ``` If you would like to track the upstream changes for your customized version of modules, you can optionally directly edit the original files and commit them. In this case, you need to handle possible conflicts with the upstream (`github.com/ohmybash/oh-my-bash`) in upgrading. If you want to replace an existing module (theme/plugin/aliases/complet) bundled with Oh My Bash, create a module of the same name in the `custom/` directory so that it will be loaded instead of the original one. ### Configuration #### Enable/disable python venv The python virtualenv/condaenv information in the prompt may be enabled by the following line in `~/.bashrc`. ```bash OMB_PROMPT_SHOW_PYTHON_VENV=true ``` Some themes turn on it by default. If you would like to turn it off, you may disable it by the following line in `~/.bashrc`: ```bash OMB_PROMPT_SHOW_PYTHON_VENV=false ``` #### Enable/disable Spack environment information To enable the Spack environment information in the prompt, please set the following shell variable in `~/.bashrc`: ```bash OMB_PROMPT_SHOW_SPACK_ENV=true ``` If the theme supports it, the information of the currently active Spack environment will be shown. If the theme you use does not support the Spack environment information, a pull request to add it is welcome. See the `font` theme as an example implementation of including the Spack environment. #### Disable internal uses of `sudo` Some plugins of oh-my-bash internally use `sudo` when it is necessary. However, this might clutter with the `sudo` log. To disable the use of `sudo` by oh-my-bash, `OMB_USE_SUDO` can be set to `false` in `~/.bashrc`. ```bash OMB_USE_SUDO=false ``` Each plugin might provides finer configuration variables to control the use of `sudo` by each plugin. ## Getting Updates By default, you will be prompted to check for upgrades every few weeks. If you would like `oh-my-bash` to automatically upgrade itself without prompting you, set the following in your `~/.bashrc`: ```shell DISABLE_UPDATE_PROMPT=true ``` To disable automatic upgrades, set the following in your `~/.bashrc`: ```shell DISABLE_AUTO_UPDATE=true ``` ### Manual Updates If you'd like to upgrade at any point in time (maybe someone just released a new plugin and you don't want to wait a week?) you just need to run: ```shell upgrade_oh_my_bash ``` Magic! ## Uninstalling Oh My Bash Oh My Bash isn't for everyone. We'll miss you, but we want to make this an easy breakup. If you want to uninstall `oh-my-bash`, just run `uninstall_oh_my_bash` from the command-line. It will remove itself and revert your previous `bash` configuration. ## Contributing Check out [`CONTRIBUTING.md`](CONTRIBUTING.md) and also [Code of Conduct](CODE_OF_CONDUCT.md). This project is initially ported from Oh My Zsh and Bash-it by `@nntoan` and has been developed in a community-driven way. Most of the contributors are far from being [Bash](https://www.gnu.org/software/bash/) experts, and there are many ways to improve the codebase. We are looking for more people with expertise in Bash scripting. If you have ideas on how to make the configuration easier to maintain (and faster), don't hesitate to fork and send pull requests! We also need people to test out pull-requests. Take a look through [the open issues](https://github.com/ohmybash/oh-my-bash/issues) and help where you can. ## Contributors Oh My Bash has a vibrant community of happy users and delightful contributors. Without all the time and help from our contributors, it wouldn't be so awesome. Thank you so much! ## License See [`LICENSE.md`](License.md). Oh My Bash is derived from [Oh My Zsh](https://github.com/ohmyzsh/ohmyzsh). Oh My Bash is released under the [MIT license](LICENSE.md). ================================================ FILE: aliases/README.md ================================================ # aliases An `aliases` module define a set of aliases closely related with each other. To activate an `aliases` module, add the name of the module in the `aliases` array in your `~/.bashrc`: ```bash aliases=(... ) ``` where `` should be related by the name of the module to activate. ## List of aliases modules See the respective pages for details. - `chmod` - [`debian`](debian.aliases.md) - [`docker`](docker.aliases.md) - [`general`](general.aliases.md) - `ls` - `misc` - [`package-manager`](package-manager.aliases.md) - [`terraform`](terraform.aliases.md) - [`cargo`](cargo.aliases.md) ================================================ FILE: aliases/cargo.aliases.md ================================================ # Aliases `cargo` | Alias | Command | Description | |-------|-------------------------|------------------------------------------------| | cg | 'cargo' | launch cargo | | cgr | 'cargo run' | run project | | cgt | 'cargo test' | run tests | | cgb | 'cargo build' | building a project | | cgbr | 'cargo build --release' | building a project with compiler optimizations | | cgi | 'cargo init' | initialize the project inside the directory | | cgn | 'cargo new' | create a new project | | cga | 'cargo add' | add a new dependency to the project | | cgf | 'cargo fmt' | start formatting linters | ================================================ FILE: aliases/cargo.aliases.sh ================================================ #! bash oh-my-bash.module alias cg='cargo' alias cgr='cargo run' alias cgt='cargo test' alias cgb='cargo build' alias cgbr='cargo build --release' alias cgi='cargo init' alias cgn='cargo new' alias cga='cargo add' alias cgf='cargo fmt' ================================================ FILE: aliases/chmod.aliases.sh ================================================ #! bash oh-my-bash.module # --------------------------------------------------------------------------- alias perm='stat --printf "%a %n \n "' # perm: Show permission of target in number alias 000='chmod 000' # ---------- (nobody) alias 640='chmod 640' # -rw-r----- (user: rw, group: r) alias 644='chmod 644' # -rw-r--r-- (user: rw, group: r, other: r) alias 755='chmod 755' # -rwxr-xr-x (user: rwx, group: rx, other: rx) alias 775='chmod 775' # -rwxrwxr-x (user: rwx, group: rwx, other: rx) alias mx='chmod a+x' # ---x--x--x (user: --x, group: --x, other: --x) alias ux='chmod u+x' # ---x------ (user: --x, group: -, other: -) ================================================ FILE: aliases/debian.aliases.bash ================================================ #!/usr/bin/env bash # Short aliases for most used debian specific commands. alias apup='sudo apt update' alias apug='sudo apt upgrade' alias apuu='sudo apt update && sudo apt upgrade' alias apfu='sudo apt full-upgrade' alias apin='sudo apt install' alias apri='sudo apt install --reinstall' alias aprm='sudo apt remove' alias apur='sudo apt purge' alias apar='sudo apt autoremove' alias apcl='sudo apt-get autoclean' alias apse='apt search' alias apsh='apt show' alias apsc='apt-get source' alias apesr='sudo apt edit-sources' alias apdl='apt-get download' alias apbd='sudo apt build-deb' alias aphst='cat /var/log/apt/history.log | less' alias drcf='sudo dpkg-reconfigure' alias upgrb='sudo update-grub' alias uirfs='sudo update-initramfs -u' ================================================ FILE: aliases/debian.aliases.md ================================================ # Aliases `debian` Shorted aliases for most used Debian specific commands. To activate it, add `debian` to `aliases=(...)` in your `.bashrc` file: ```bash aliases=(... debian)` ``` ## Basic Commands | Alias | Command | | ------ | ------------------------------------- | | `apup` | `sudo apt update` | | `apug` | `sudo apt upgrade` | | `apuu` | `sudo apt update && sudo apt upgrade` | | `apfu` | `sudo apt full-upgrade` | | `apin` | `sudo apt install` | | `apri` | `sudo apt install --reinstall ` | | `aprm` | `sudo apt remove` | | `apur` | `sudo apt purge` | | `apse` | `apt search` | | `apdl` | `apt-get download` | ## APT Maintainance & Diagnostic Commands | Alias | Command | | ------- | ------------------------------------------------------ | | `apar` | `sudo apt autoremove` | | `apcl` | `sudo apt-get autoclean` | | `apesr` | `sudo apt edit-sources` | | `apsh` | `apt show` | | `aphst` | cat /var/log/apt/history.log | less | | `drcf` | `sudo dpkg-reconfigure` | ## APT Source & Building Commands | Alias | Command | | ------ | -------------------- | | `apsc` | `apt-get source` | | `apbd` | `sudo apt build-deb` | ## Debian's update-\* commands | Alias | Command | | ------- | -------------------------- | | `upgrb` | `sudo update-grub` | | `uirfs` | `sudo update-initramfs -u` | ================================================ FILE: aliases/docker.aliases.md ================================================ # Aliases `Docker` | Alias | Command | Description | | :------ | :---------------------------- | :--------------------------------------------------------------------------------------- | | `dbl` | `docker build` | Build an image from a Dockerfile | | `dcin` | `docker container inspect` | Display detailed information on one or more containers | | `dcls` | `docker container ls` | List all the running docker containers | | `dclsa` | `docker container ls -a` | List all running and stopped containers | | `dib` | `docker image build` | Build an image from a Dockerfile (same as docker build) | | `dii` | `docker image inspect` | Display detailed information on one or more images | | `dils` | `docker image ls` | List docker images | | `dipu` | `docker image push` | Push an image or repository to a remote registry | | `dirm` | `docker image rm` | Remove one or more images | | `dit` | `docker image tag` | Add a name and tag to a particular image | | `dlo` | `docker container logs` | Fetch the logs of a docker container | | `dnc` | `docker network create` | Create a new network | | `dncn` | `docker network connect` | Connect a container to a network | | `dndcn` | `docker network disconnect` | Disconnect a container from a network | | `dni` | `docker network inspect` | Return information about one or more networks | | `dnls` | `docker network ls` | List all networks the engine daemon knows about, including those spanning multiple hosts | | `dnrm` | `docker network rm` | Remove one or more networks | | `dpo` | `docker container port` | List port mappings or a specific mapping for the container | | `dpu` | `docker pull` | Pull an image or a repository from a registry | | `dr` | `docker container run` | Create a new container and start it using the specified command | | `drit` | `docker container run -it` | Create a new container and start it in an interactive shell | | `drm` | `docker container rm` | Remove the specified container(s) | | `drm!` | `docker container rm -f` | Force the removal of a running container (uses SIGKILL) | | `dst` | `docker container start` | Start one or more stopped containers | | `drs` | `docker container restart` | Restart one or more containersa | | `dsta` | `docker stop $(docker ps -q)` | Stop all running containers | | `dstp` | `docker container stop` | Stop one or more running containers | | `dtop` | `docker top` | Display the running processes of a container | | `dvi` | `docker volume inspect` | Display detailed information about one or more volumes | | `dvls` | `docker volume ls` | List all the volumes known to docker | | `dvprune` | `docker volume prune` | Cleanup dangling volumes | | `dxc` | `docker container exec` | Run a new command in a running container | | `dxcit` | `docker container exec -it` | Run a new command in a running container in an interactive shell | ================================================ FILE: aliases/docker.aliases.sh ================================================ # This is a direct copy of https://github.com/ohmyzsh/ohmyzsh/blob/master/plugins/docker/docker.plugin.zsh alias dbl='docker build' alias dcin='docker container inspect' alias dcls='docker container ls' alias dclsa='docker container ls -a' alias dib='docker image build' alias dii='docker image inspect' alias dils='docker image ls' alias dipu='docker image push' alias dirm='docker image rm' alias dit='docker image tag' alias dlo='docker container logs' alias dnc='docker network create' alias dncn='docker network connect' alias dndcn='docker network disconnect' alias dni='docker network inspect' alias dnls='docker network ls' alias dnrm='docker network rm' alias dpo='docker container port' alias dpu='docker pull' alias dr='docker container run' alias drit='docker container run -it' alias drm='docker container rm' alias 'drm!'='docker container rm -f' alias dst='docker container start' alias drs='docker container restart' alias dsta='docker stop $(docker ps -q)' alias dstp='docker container stop' alias dtop='docker top' alias dvi='docker volume inspect' alias dvls='docker volume ls' alias dvprune='docker volume prune' alias dxc='docker container exec' alias dxcit='docker container exec -it' ================================================ FILE: aliases/general.aliases.md ================================================ # Aliases `general` This plugin provides aliases originally introduced in a blog post by Nathaniel Landau (2013-07-02) [1] and later modified: - [1] Nathaniel Landau, ["My Mac OSX Bash Profile"](https://natelandau.com/my-mac-osx-bash_profile/), 2013-07-02. ## Basic Commands | Alias | Command | Description | |----------------|----------------------------------------|------------------------------------------------------------------------------------| | `c` | `clear` | Clear terminal display | | `cic` | `bind "set completion-ignore-case on"` | Make tab-completion case-insensitive | | `cp` | `cp -iv` | `cp` with confirmation on overwriting (option `-v` is added if supported) | | `fix_stty` | `stty sane` | Restore terminal settings when screwed up | | `fix_term` | `echo -e "\033c"` | Reset the conosle. Similar to the reset command | | `less` | `less -FSRXc` | Preferred `less` implementation | | `ll` | `ls -lAFh` | Preferred `ls` implementation | | `mkdir` | `mkdir -pv` | Recursive `mkdir` if the target does not exist (option `-v` is added if supported) | | `mv` | `mv -iv` | `mv` with confirmation on overwriting (option `-v` is added if supported) | | `nano` | `nano -W` | (option `-W` is added if supported) | | `path` | `echo -e ${PATH//:/\\n}` | Echo all executable Paths | | `show_options` | `shopt` | display bash options settings | | `src` | `source ~/.bashrc` | Reload `.bashrc` file | | `wget` | `wget -c` | Preferred `wget` implementation (resume download) | ================================================ FILE: aliases/general.aliases.sh ================================================ #! bash oh-my-bash.module #------------------------------------------------------------------------------ # Note on copyright (2022-08-23): The aliases defined in this file seems to # originally come from a blog post [1]. See also the comments in lib/base.sh. # # [1] Nathaniel Landau, "My Mac OSX Bash Profile", # https://natelandau.com/my-mac-osx-bash_profile/, 2013-07-02. # #------------------------------------------------------------------------------ # Description: This file holds all general BASH aliases # # For your own benefit, we won't load all aliases in the general, we will # keep the very generic command here and enough for daily basis tasks. # # If you are looking for the more sexier aliases, we suggest you take a look # into other core alias files which installed by default. # #------------------------------------------------------------------------------ # ----------------------------- # 1. MAKE TERMINAL BETTER # ----------------------------- # Preferred 'cp' implementation. Determines the use of the option `-v' on the # first call Ref. https://github.com/ohmybash/oh-my-bash/issues/351 function _omb_util_alias_select_cp { if (tmp=$(_omb_util_mktemp); trap 'rm -f "$tmp"{,.2}' EXIT; command cp -v "$tmp" "$tmp.2" &>/dev/null); then _omb_command='cp -iv' else _omb_command='cp -i' fi } _omb_util_alias_delayed cp force # Preferred 'mv' implementation function _omb_util_alias_select_mv { if (tmp=$(_omb_util_mktemp); trap 'rm -f "$tmp.2"' EXIT; command mv -v "$tmp" "$tmp.2" &>/dev/null); then _omb_command='mv -iv' else _omb_command='mv -i' fi } _omb_util_alias_delayed mv force # Preferred 'mkdir' implementation function _omb_util_alias_select_mkdir { if command mkdir -pv . &>/dev/null; then _omb_command='mkdir -pv' else _omb_command='mkdir -p' fi } _omb_util_alias_delayed mkdir force # Preferred 'nano' implementation function _omb_util_alias_select_nano { if LANG=C command nano --help 2>/dev/null | grep -q '^[[:space:]]*[-]W'; then _omb_command='nano -W' else _omb_command='nano' fi } _omb_util_alias_delayed nano force alias ll='ls -lAFh' # Preferred 'ls' implementation alias less='less -FSRXc' # Preferred 'less' implementation alias wget='wget -c' # Preferred 'wget' implementation (resume download) alias c='clear' # c: Clear terminal display alias path='echo -e ${PATH//:/\\n}' # path: Echo all executable Paths alias show_options='shopt' # Show_options: display bash options settings alias fix_stty='stty sane' # fix_stty: Restore terminal settings when screwed up alias fix_term='echo -e "\033c"' # fix_term: Reset the conosle. Similar to the reset command alias cic='bind "set completion-ignore-case on"' # cic: Make tab-completion case-insensitive alias src='source ~/.bashrc' # src: Reload .bashrc file ================================================ FILE: aliases/ls.aliases.sh ================================================ #! bash oh-my-bash.module # --------------------------------------------------------------------------- # Directory Listing aliases alias dir='ls -hFx' alias l.='ls -d .* --color=tty' # short listing, only hidden files - .* alias l='ls -lathF' # long, sort by newest to oldest alias L='ls -latrhF' # long, sort by oldest to newest alias la='ls -Al' # show hidden files alias lc='ls -lcr' # sort by change time alias lk='ls -lSr' # sort by size alias lh='ls -lSrh' # sort by size human readable alias lm='ls -al | more' # pipe through 'more' alias lo='ls -laSFh' # sort by size largest to smallest alias lr='ls -lR' # recursive ls alias lt='ls -ltr' # sort by date alias lu='ls -lur' # sort by access time # lr: Full Recursive Directory Listing # ------------------------------------------ alias lr='ls -R | grep ":$" | sed -e '\''s/:$//'\'' -e '\''s/[^-][^\/]*\//--/g'\'' -e '\''s/^/ /'\'' -e '\''s/-/|/'\'' | less' alias dud='du -d 1 -h' # Short and human-readable directory listing alias duf='du -sh *' # Short and human-readable file listing ================================================ FILE: aliases/misc.aliases.sh ================================================ #! bash oh-my-bash.module #------------------------------------------------------------------------------ # Note on copyright (2022-08-23): The aliases defined in this file seems to # originally come from a blog post [1]. See also the comments in lib/base.sh. # # [1] Nathaniel Landau, "My Mac OSX Bash Profile", # https://natelandau.com/my-mac-osx-bash_profile/, 2013-07-02. # #------------------------------------------------------------------------------ # Description: This file holds many useful BASH aliases and save our lives! # # Sections: # 1. File and Folder Management # 2. Searching # 3. Process Management # 4. Networking # 5. System Operations & Information # 6. Date & Time Management # 7. Web Development # 8. # # X. Reminders & Notes # #------------------------------------------------------------------------------ # ------------------------------- # 1. FILE AND FOLDER MANAGEMENT # ------------------------------- alias numFiles='_omb_util_print $(ls -1 | wc -l)' # numFiles: Count of non-hidden files in current dir alias make1mb='truncate -s 1m ./1MB.dat' # make1mb: Creates a file of 1mb size (all zeros) alias make5mb='truncate -s 5m ./5MB.dat' # make5mb: Creates a file of 5mb size (all zeros) alias make10mb='truncate -s 10m ./10MB.dat' # make10mb: Creates a file of 10mb size (all zeros) # --------------------------- # 2. SEARCHING # --------------------------- alias qfind="find . -name " # qfind: Quickly search for file # --------------------------- # 3. PROCESS MANAGEMENT # --------------------------- # memHogsTop, memHogsPs: Find memory hogs # ----------------------------------------------------- alias memHogsTop='top -l 1 -o rsize | head -20' alias memHogsPs='ps wwaxm -o pid,stat,vsize,rss,time,command | head -10' # cpuHogs: Find CPU hogs # ----------------------------------------------------- alias cpu_hogs='ps wwaxr -o pid,stat,%cpu,time,command | head -10' # topForever: Continual 'top' listing (every 10 seconds) # ----------------------------------------------------- alias topForever='top -l 9999999 -s 10 -o cpu' # ttop: Recommended 'top' invocation to minimize resources # ------------------------------------------------------------ # Taken from this macosxhints article # http://www.macosxhints.com/article.php?story=20060816123853639 # ------------------------------------------------------------ alias ttop="top -R -F -s 10 -o rsize" # --------------------------- # 4. NETWORKING # --------------------------- alias netCons='lsof -i' # netCons: Show all open TCP/IP sockets alias lsock='sudo lsof -i -P' # lsock: Display open sockets alias lsockU='sudo lsof -nP | grep UDP' # lsockU: Display only open UDP sockets alias lsockT='sudo lsof -nP | grep TCP' # lsockT: Display only open TCP sockets alias openPorts='sudo lsof -i | grep LISTEN' # openPorts: All listening connections alias showBlocked='sudo ipfw list' # showBlocked: All ipfw rules inc/ blocked IPs if _omb_util_binary_exists ifconfig; then alias ipInfo0='ifconfig getpacket en0' # ipInfo0: Get info on connections for en0 alias ipInfo1='ifconfig getpacket en1' # ipInfo1: Get info on connections for en1 fi # --------------------------------------- # 5. SYSTEMS OPERATIONS & INFORMATION # --------------------------------------- alias mountReadWrite='mount -uw /' # mountReadWrite: For use when booted into single-user # --------------------------------------- # 6. DATE & TIME MANAGEMENT # --------------------------------------- alias bdate="date '+%a, %b %d %Y %T %Z'" alias cal3='cal -3' alias da='date "+%Y-%m-%d %A %T %Z"' alias daysleft='_omb_util_print "There are $(($(date +%j -d"Dec 31, $(date +%Y)")-$(date +%j))) left in year $(date +%Y)."' alias epochtime='date +%s' alias mytime='date +%H:%M:%S' alias secconvert='date -d@1234567890' alias stamp='date "+%Y%m%d%a%H%M"' alias timestamp='date "+%Y%m%dT%H%M%S"' alias today='date +"%A, %B %-d, %Y"' alias weeknum='date +%V' # --------------------------------------- # 8. WEB DEVELOPMENT # --------------------------------------- alias editHosts='sudo edit /etc/hosts' # editHosts: Edit /etc/hosts file if _omb_util_binary_exists apachectl; then alias apacheEdit='sudo edit /etc/httpd/httpd.conf' # apacheEdit: Edit httpd.conf alias apacheRestart='sudo apachectl graceful' # apacheRestart: Restart Apache alias herr='tail /var/log/httpd/error_log' # herr: Tails HTTP error logs alias apacheLogs="less +F /var/log/apache2/error_log" # Apachelogs: Shows apache error logs fi # --------------------------------------- # 9. OTHER ALIASES # --------------------------------------- # Aliases by Jacob Hrbek # Outputs List of Loadable Modules (llm) for current kernel alias llm="find /lib/modules/$(uname -r) -type f -name '*.ko*'" # Used for piping to remote pastebin from cmdline to generate a url _omb_util_binary_exists curl && ix() { curl -n -F 'f:1=<-' http://ix.io ; } # Used for piping to clipboard _omb_util_binary_exists xclip && alias xcopy="xclip -se c" ================================================ FILE: aliases/package-manager.aliases.bash ================================================ #!/usr/bin/env bash # Created by Jacob Hrbek github.com in 2019 # A local temporary variable declare _omb_tmp_sudo # Switch for the use of "sudo" _omb_tmp_sudo= if [[ ${OMB_ALIAS_PACKAGE_MANAGER_SUDO+set} ]]; then _omb_tmp_sudo=${OMB_ALIAS_PACKAGE_MANAGER_SUDO:+$OMB_ALIAS_PACKAGE_MANAGER_SUDO } elif [[ ${OMB_USE_SUDO-true} == true ]]; then if ((EUID != 0)) && _omb_util_binary_exists sudo; then _omb_tmp_sudo='sudo ' fi fi # Portage - Enoch Merge if _omb_util_binary_exists emerge; then alias em="${_omb_tmp_sudo}emerge" # Enoch Merge alias es="${_omb_tmp_sudo}emerge --search" # Enoch Search alias esync="${_omb_tmp_sudo}emerge --sync" # Enoch SYNC alias eb="${_omb_tmp_sudo}ebuild" # Enoch Build alias er="${_omb_tmp_sudo}emerge -c" # Enoch Remove alias emfu="${_omb_tmp_sudo}emerge --sync && ${_omb_tmp_sudo}emerge -uDN @world" # Enoch Update & Upgrade System alias eu="${_omb_tmp_sudo}emerge -uDN @world" # Enoch Upgrade System alias ei="${_omb_tmp_sudo}emerge --info" # Enoch Display Information alias ep="${_omb_tmp_sudo}emerge -p" # Enoch Display What Would Have Been Installed alias e1="${_omb_tmp_sudo}emerge -1" # Enoch Merge Without Adding the Packages to the World File # Deprecated, retained for backward compatibility. Use `er` instead. alias ers="${_omb_tmp_sudo}emerge -c" fi if _omb_util_binary_exists eclean; then alias ecd="${_omb_tmp_sudo}eclean-dist -d" # Enoch Clean Repository Source Files alias ecp="${_omb_tmp_sudo}eclean-pkg -d" # Enoch Clean Binary Packages fi if _omb_util_binary_exists eix; then alias elip="${_omb_tmp_sudo}eix-installed -a" # Enoch List Installed Packages fi if _omb_util_binary_exists equery; then alias eq="${_omb_tmp_sudo}equery" # Enoch Query fi # Paludis - Cave if _omb_util_binary_exists cave; then alias cave="${_omb_tmp_sudo}cave" alias cr="${_omb_tmp_sudo}cave resolve" # Cave Resolve alias cui="${_omb_tmp_sudo}cave uninstall" # Cave UnInstall alias cs="${_omb_tmp_sudo}cave show" # Cave Show alias cli="${_omb_tmp_sudo}cave print-ids --matching '*/*::/'" # Cave List Installed fi # Snap Package manager - Snap if _omb_util_binary_exists snap; then alias snap="${_omb_tmp_sudo}snap" alias snapfu="${_omb_tmp_sudo}snap refresh" # Update all installed snaps alias snapi="${_omb_tmp_sudo}snap install" # Installs the named snaps alias snaps="${_omb_tmp_sudo}snap find" # Queries the store for available packages alias snapr="${_omb_tmp_sudo}snap remove --terminate --purge" # Performs a full, clean and data remove alias snapli="${_omb_tmp_sudo}snap list --all" # List all installed snaps and revisions in the current system fi # Advanced Packaging Tool - APT if _omb_util_binary_exists apt; then alias apt="${_omb_tmp_sudo}apt" # Advanced Packaging Tool alias aptfu="${_omb_tmp_sudo}apt update -y && ${_omb_tmp_sudo}apt upgrade -y && ${_omb_tmp_sudo}apt dist-upgrade -y && ${_omb_tmp_sudo}apt autoremove -y" alias apti="${_omb_tmp_sudo}apt install -y" # Apt install alias apts="${_omb_tmp_sudo}apt-cache search" # Apt search alias aptr="${_omb_tmp_sudo}apt remove -y" # Apt remove alias aptar="${_omb_tmp_sudo}apt autoremove -y" # Apt Auto Remove alias aptli="${_omb_tmp_sudo}apt list --installed" fi # Debian PacKaGe - DPKG if _omb_util_binary_exists dpkg; then alias dpkg="${_omb_tmp_sudo}dpkg" fi # Volian - Nala if _omb_util_binary_exists nala; then alias nala="${_omb_tmp_sudo}nala" # A faster, prettier front-end for libapt-> alias nalaf="${_omb_tmp_sudo}nala fetch" # Nala Fastest Mirror alias nalau="${_omb_tmp_sudo}nala update" # Nala Update alias nalafu="${_omb_tmp_sudo}nala upgrade -y" # Nala Update & Full-Upgrade > alias nalai="${_omb_tmp_sudo}nala install -y" # Nala Install alias nalar="${_omb_tmp_sudo}nala remove -y" # Nala Remove alias nalaa="${_omb_tmp_sudo}nala autoremove -y" # Nala Auto Remove alias nalah="${_omb_tmp_sudo}nala history" # Nala History alias nalal="${_omb_tmp_sudo}nala list" # Nala List alias nalas="${_omb_tmp_sudo}nala search" # Nala Search alias nalav="${_omb_tmp_sudo}nala show" # Nala View Package Info fi # # Zypper = Zen Yast Package Program (ZYPP?) # if _omb_util_binary_exists zypper; then # # Yast = Yet Another Silly/Setup Thing/Thing # alias lcp="${_omb_tmp_sudo}zypper" # alias lcpi="${_omb_tmp_sudo}zypper install" # alias lcps="${_omb_tmp_sudo}zypper search" # alias lcpsi="${_omb_tmp_sudo}zypper source-install" # alias lcpr="${_omb_tmp_sudo}zypper remove" # if grep -q 'openSUSE Tumbleweed' /etc/os-release; then # # Zypper update kills the system - LCP # alias lcpfu="${_omb_tmp_sudo}zypper dup" # # Because Geeko uses sublime3 to call sublime_text instead of something that makes sence like 'subl'.. # alias subl="${_omb_tmp_sudo}sublime3" # fi # fi # Fedora Package - dnf if _omb_util_binary_exists dnf; then alias dnf="${_omb_tmp_sudo}dnf" # DNF Packaging Tool alias dnfl="${_omb_tmp_sudo}dnf list" # List alias dnfli="${_omb_tmp_sudo}dnf list installed" # List Installed alias dnfgl="${_omb_tmp_sudo}dnf grouplist" # Group List alias dnfmc="${_omb_tmp_sudo}dnf makecache" # Make Cache alias dnfp="${_omb_tmp_sudo}dnf info" # Show Package Info alias dnfs="${_omb_tmp_sudo}dnf search" # Search alias dnfu="${_omb_tmp_sudo}dnf upgrade" # Update alias dnfi="${_omb_tmp_sudo}dnf install" # Install alias dnfgi="${_omb_tmp_sudo}dnf group install" # Group Install alias dnfr="${_omb_tmp_sudo}dnf remove" # Remove alias dnfgr="${_omb_tmp_sudo}dnf groupremove" # Group Remove alias dnfc="${_omb_tmp_sudo}dnf clean all" # Clean All fi unset -v _omb_tmp_sudo ================================================ FILE: aliases/package-manager.aliases.md ================================================ # Aliases `package-manager` This plugin provides the set of aliases that can be used to control package managers. Here is the list of the supported aliases for each package manager. You can find the details of each alias in the source [`package-manager.aliases.bash`](package-manager.aliases.bash). - `emerge` (Portage Enoch Merge) ... `em`, `es`, `esync`, `eb`, `er`, `emfu`, `ecd`, `ecp`, `elip` - `cave` (Paludis Cave) ... `cave`, `cr`, `cui`, `cs`, `cli` - `apt` (Advanced Packaging Tool) ... `apt`, `aptfu`, `apti`, `apts`, `aptr`, `aptar`, `aptli` - `dpkg` (Debian Package) ... `dpkg` - `nala` (Nala APT Wrapper) ... `nala`, `nalaf`, `nalau`, `nalafu`, `nalai`, `nalar`, `nalaa`, `nalah`, `nalal`, `nalas`, `nalav` - `snap` (Snap Package Manager) ... `snap`, `snapfu`, `snapi`, `snaps`, `snapr`, `snapli` The command to use to call these package manager can be specified in the variable `OMB_ALIAS_PACKAGE_MANAGER_SUDO`. By default, `sudo` is used when the current use is not root and the command `sudo` is available. ```bash # Use sudo to run the package manager OMB_ALIAS_PACKAGE_MANAGER_SUDO=sudo # Do not use sudo but directly run the package manager OMB_ALIAS_PACKAGE_MANAGER_SUDO= ``` ## Emerge Package Manager | Alias | Command | Description | | ------- | ------------------------------------------------ | -------------------------------------------------------------------------------------------------------------------------------- | | `em` | `sudo emerge` | Emerge is the definitive command-line interface to the Portage system. | | `es` | `sudo emerge --search` | Searches for matches of the supplied string in the ebuild repository. | | `esync` | `sudo emerge --sync` | Updates repositories, for which auto-sync, sync-type and sync-uri attributes are set in repos.conf. | | `eb` | `sudo ebuild` | An ebuild must be, at a minimum, a valid Portage package directory name without a version or category, such as portage or python.| | `er` | `sudo emerge -c` | Cleans the system by removing packages that are not associated with explicitly merged packages. | | `emfu` | `sudo emerge --sync && sudo emerge -uDN @world` | Emerge update & upgrade system. | | `eu` | `sudo emerge -uDN @world` | Emerge upgrade system. | | `ei` | `sudo emerge --info` | Emerge display information. | | `ep` | `sudo emerge -p` | Emerge display what would have been installed. | | `e1` | `sudo emerge -1` | Emerge merge without adding the packages to the world file. | | `ecp` | `sudo eclean-pkg -d` | Cleans binary packages. | | `elip` | `sudo eix-installed -a` | Lists all installed programs. | | `ecd` | `sudo eclean-dist -d` | Cleans repository source files. | | `eq` | `sudo equery` | Package query tool. | | `ers` | `sudo emerge -c` | (Deprecated, retained for backward compatibility. Use `er` instead.) | ## Paludis Package Manager (`cave`) | Alias | Command | Description | | ------ | --------------------- | ------------------------------------------------------------------------------------------------------- | | `cave` | `sudo cave` | The Other Package Manager. | | `cr` | `sudo cave resolve` | Solve the dependencies and print out the results. Pass the `-x` option to actually install the package. | | `cui` | `sudo cave uninstall` | Uninstall a package. | | `cs` | `sudo cave show` | Show the dependencies of a package. | | `cli` | `sudo cave list` | List all available Packages. | ## APT Package Manager | Alias | Command | Description | | ------- | ------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------- | | `apt` | `sudo apt` | Advanced Packaging Tool. | | `aptfu` | `sudo apt update -y && sudo apt upgrade -y && sudo apt dist-upgrade -y && sudo apt autoremove -y` | Automatically update package lists, fully upgrade all packages, and remove any orphaned packages. | | `apti` | `sudo apt install -y` | Performs the requested action on one or more packages specified via regex(7), glob(7) or exact match. | | `apts` | `sudo apt-cache search` | Search can be used to search for the given regex(7) term(s) in the list of available packages and display matches. | | `aptr` | `sudo apt remove -y` | Performs the requested action on one or more packages specified via regex(7), glob(7) or exact match. | | `aptar` | `sudo apt autoremove -y` | Remove packages that were automatically installed for dependencies but are now no longer needed. | | `aptli` | `sudo apt list` | List is somewhat similar to dpkg-query --list in that it can display a list of packages satisfying certain criteria. | ## Debian Package Manager (`dpkg`) | Alias | Command | Description | | ------ | ----------- | --------------------------- | | `dpkg` | `sudo dpkg` | Package manager for Debian. | ## Nala Package Manager | Alias | Command | Description | | ------- | ------------------------- | -------------------------------------------------------------------------------------------------------- | | `nala` | `sudo nala` | Nala is a prettier front-end for libapt-pkg, doubles as --help. | | `nalaf` | `sudo nala fetch` | Fetch fast mirrors to improve download speed. | | `nalau` | `sudo nala update` | Update the list of available packages. | | `nalafu`| `sudo nala upgrade -y` | The equivalent of apt update && apt full-upgrade --auto-remove. | | `nalai` | `sudo nala install -y` | Takes multiple packages as arguments and will install all of them. | | `nalar` | `sudo nala remove -y` | Remove or purge packages that are no longer needed. | | `nalaa` | `sudo nala autoremove -y` | Automatically remove or purge any packages that are no longer needed. | | `nalah` | `sudo nala history` | Nala history with no subcommands will show a summary of all transactions made. | | `nalal` | `sudo nala list` | List all packages or only packages based on the provided name, glob or regex. By default will only glob. | | `nalas` | `sudo nala search` | Search package names and descriptions using a word, regex or glob. | | `nalav` | `sudo nala show` | Show information about a package such as the name, version, dependencies etc. | ## Snap Package Manager | Alias | Command | Description | | -------- | -------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------- | | `snap` | `sudo snap` | The snap command lets you install, configure, refresh and remove snaps. Snaps are packages that work across many different Linux distributions. | | `snapfu` | `sudo snap refresh` | Update all installed snaps. | | `snapi` | `sudo snap install` | Installs the named snaps. | | `snaps` | `sudo snap find` | Queries the store for available packages. | | `snapr` | `sudo snap remove --terminate --purge` | Performs a full and clean remove. Remove the snap without saving a snapshot of its data. Remove all the snap revisions without the option `--revision=`. | | `snapli` | `sudo snap list --all` | List all installed snaps and revisions in the current system. | ================================================ FILE: aliases/terraform.aliases.md ================================================ # Aliases `terraform` This defines aliases for `terraform`. | Alias | Command | | -------- | ---------------------------- | | `t` | `terraform` | | `tinit` | `terraform init` | | `tplan` | `terraform plan` | | `tapply` | `terraform apply` | | `tfmt` | `terraform fmt` | ================================================ FILE: aliases/terraform.aliases.sh ================================================ # Aliases # (sorted alphabetically) # alias t='terraform' alias tapply='terraform apply' alias tfmt='terraform fmt' alias tinit='terraform init' alias tplan='terraform plan' ================================================ FILE: cache/.gitkeep ================================================ ================================================ FILE: completions/apm.completion.sh ================================================ #! bash oh-my-bash.module # apm-bash-completion is written by Ugur Ozyilmazel # repo: https://github.com/vigo/apm-bash-completion function __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")) } function __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 ================================================ FILE: completions/asdf.completion.sh ================================================ #! bash oh-my-bash.module # Bash completion support for the `asdf` command. # Depends on the `asdf` plugin. # Only load the completions if the ASDF_DIR variable was set. if [[ ${ASDF_DIR+set} ]]; then . "$ASDF_DIR/completions/asdf.bash" fi ================================================ FILE: completions/awscli.completion.sh ================================================ #! bash oh-my-bash.module _omb_util_binary_exists aws_completer && complete -C "$(type -P aws_completer)" aws ================================================ FILE: completions/brew.completion.sh ================================================ #! bash oh-my-bash.module if _omb_util_command_exists brew; then _omb_completion_brew_prefix=$(brew --prefix) if [[ $_omb_completion_brew_prefix ]]; then if [[ -f $_omb_completion_brew_prefix/etc/bash_completion ]]; then source "$_omb_completion_brew_prefix"/etc/bash_completion fi if [[ -f $_omb_completion_brew_prefix/Library/Contributions/brew_bash_completion.sh ]]; then source "$_omb_completion_brew_prefix"/Library/Contributions/brew_bash_completion.sh fi fi unset -v _omb_completion_brew_prefix fi ================================================ FILE: completions/bundler.completion.sh ================================================ #! bash oh-my-bash.module # bash completion for the `bundle` command. # # Copyright (c) 2011-2013 Daniel Luz . # Distributed under the MIT license. # http://mernen.com/projects/completion-ruby # # To use, source this file on bash: # . completion-bundle function __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")) } function __bundle_get_command { local i for ((i=1; i < $COMP_CWORD; ++i)); do local arg=${COMP_WORDS[$i]} case $arg in [^-]*) bundle_command=$arg return;; --version) # command-killer bundle_command=- return;; --help) bundle_command=help return;; esac done } complete -F __bundle -o bashdefault -o default bundle # vim: ai ft=sh sw=4 sts=2 et ================================================ FILE: completions/capistrano.completion.sh ================================================ #! bash oh-my-bash.module # Bash completion support for Capistrano. _omb_module_require lib:omb-completion function _omb_completion_cap { local cur _omb_completion_reassemble_breaks : if [[ -f Capfile ]]; then local recent=$(ls -t .cap_tasks~ Capfile **/*.cap 2> /dev/null | head -n 1) if [[ $recent != '.cap_tasks~' ]]; then if cap --version | grep 'Capistrano v2.' > /dev/null; then # Capistrano 2.x cap --tool --verbose --tasks | cut -d " " -f 2 > .cap_tasks~ else # Capistrano 3.x cap --all --tasks | cut -d " " -f 2 > .cap_tasks~ fi fi COMPREPLY=($(compgen -W '$(< .cap_tasks)' -- "$cur")) fi _omb_completion_resolve_breaks } complete -o default -o nospace -F _omb_completion_cap cap ================================================ FILE: completions/chezmoi.completion.sh ================================================ #! bash oh-my-bash.module if _omb_util_command_exists chezmoi; then eval -- "$(chezmoi completion bash)" fi ================================================ FILE: completions/composer.completion.sh ================================================ #! bash oh-my-bash.module _composer() { local cur script coms opts com COMPREPLY=() _get_comp_words_by_ref -n : cur words # for an alias, get the real script behind it if [[ $(type -t ${words[0]}) == "alias" ]]; then script=$(alias ${words[0]} | sed -E "s/alias ${words[0]}='(.*)'/\1/") else script=${words[0]} fi # lookup for command for word in ${words[@]:1}; do if [[ $word != -* ]]; then com=$word break fi done # completing for an option if [[ ${cur} == --* ]] ; then opts="--help --quiet --verbose --version --ansi --no-ansi --no-interaction --profile --no-plugins --working-dir" case "$com" in about) opts="${opts} " ;; archive) opts="${opts} --format --dir --file" ;; browse) opts="${opts} --homepage --show" ;; clear-cache) opts="${opts} " ;; config) opts="${opts} --global --editor --auth --unset --list --file --absolute" ;; create-project) opts="${opts} --stability --prefer-source --prefer-dist --repository --repository-url --dev --no-dev --no-custom-installers --no-scripts --no-progress --no-secure-http --keep-vcs --no-install --ignore-platform-reqs" ;; depends) opts="${opts} --recursive --tree" ;; diagnose) opts="${opts} " ;; dump-autoload) opts="${opts} --no-scripts --optimize --classmap-authoritative --apcu --no-dev" ;; exec) opts="${opts} --list" ;; global) opts="${opts} " ;; help) opts="${opts} --xml --format --raw" ;; init) opts="${opts} --name --description --author --type --homepage --require --require-dev --stability --license --repository" ;; install) opts="${opts} --prefer-source --prefer-dist --dry-run --dev --no-dev --no-custom-installers --no-autoloader --no-scripts --no-progress --no-suggest --optimize-autoloader --classmap-authoritative --apcu-autoloader --ignore-platform-reqs" ;; licenses) opts="${opts} --format --no-dev" ;; list) opts="${opts} --xml --raw --format" ;; outdated) opts="${opts} --outdated --all --direct --strict" ;; prohibits) opts="${opts} --recursive --tree" ;; remove) opts="${opts} --dev --no-progress --no-update --no-scripts --update-no-dev --update-with-dependencies --no-update-with-dependencies --ignore-platform-reqs --optimize-autoloader --classmap-authoritative --apcu-autoloader" ;; require) opts="${opts} --dev --prefer-source --prefer-dist --no-progress --no-suggest --no-update --no-scripts --update-no-dev --update-with-dependencies --ignore-platform-reqs --prefer-stable --prefer-lowest --sort-packages --optimize-autoloader --classmap-authoritative --apcu-autoloader" ;; run-script) opts="${opts} --timeout --dev --no-dev --list" ;; search) opts="${opts} --only-name --type" ;; self-update) opts="${opts} --rollback --clean-backups --no-progress --update-keys --stable --preview --snapshot" ;; show) opts="${opts} --all --installed --platform --available --self --name-only --path --tree --latest --outdated --minor-only --direct --strict" ;; status) opts="${opts} " ;; suggests) opts="${opts} --by-package --by-suggestion --no-dev" ;; update) opts="${opts} --prefer-source --prefer-dist --dry-run --dev --no-dev --lock --no-custom-installers --no-autoloader --no-scripts --no-progress --no-suggest --with-dependencies --optimize-autoloader --classmap-authoritative --apcu-autoloader --ignore-platform-reqs --prefer-stable --prefer-lowest --interactive --root-reqs" ;; validate) opts="${opts} --no-check-all --no-check-lock --no-check-publish --with-dependencies --strict" ;; esac COMPREPLY=($(compgen -W "${opts}" -- ${cur})) __ltrim_colon_completions "$cur" return 0; fi # completing for a command if [[ $cur == $com ]]; then coms="about archive browse clear-cache config create-project depends diagnose dump-autoload exec global help init install licenses list outdated prohibits remove require run-script search self-update show status suggests update validate" COMPREPLY=($(compgen -W "${coms}" -- ${cur})) __ltrim_colon_completions "$cur" return 0 fi } complete -o default -F _composer composer ================================================ FILE: completions/conda.completion.sh ================================================ #! bash oh-my-bash.module if _omb_util_binary_exists register-python-argcomplete; then eval -- "$(register-python-argcomplete conda)" elif _omb_util_binary_exists register-python-argcomplete3; then eval -- "$(register-python-argcomplete3 conda)" elif _omb_util_binary_exists register-python-argcomplete2; then eval -- "$(register-python-argcomplete2 conda)" else echo "Please install argcomplete to use conda completion" >&2 fi ================================================ FILE: completions/crc.completion.sh ================================================ #! bash oh-my-bash.module if _omb_util_command_exists crc; then eval -- "$(crc completion bash)" fi ================================================ FILE: completions/defaults.completion.sh ================================================ #! bash oh-my-bash.module # # Note: I could not find the true original source of this completion, but we # can find several versions at the following places: # # * https://gist.github.com/mbauman/839902 # * https://github.com/taylanpince/wiki/blob/master/scripts/bash_completion_scripts/defaults (Version 1.0) # * https://github.com/gaelicWizard/bash-progcomp/tree/main (Version 2.0) # # The v2 script seems to be a complete rewrite of the original v1.0, though it # retains the original copyright notice. The current version is based on # Version 1.0. # #------------------------------------------------------------------------------ # defaults # Bash command line completion for defaults # # Created by Jonathon Mah on 2006-11-08. # Copyright 2006 Playhaus. All rights reserved. # # Version 1.0 (2006-11-08) function _defaults_domains { local cur COMPREPLY=() cur=${COMP_WORDS[COMP_CWORD]} local domains=$(defaults domains | sed -e 's/, /:/g' | tr : '\n' | sed -e 's/ /\\ /g' | grep -i "^$cur") _omb_util_split COMPREPLY "$domains" $'\n' if grep -q "^$cur" <<< '-app'; then COMPREPLY[${#COMPREPLY[@]}]="-app" fi return 0 } function _defaults { local cur prev host_opts cmds cmd domain keys key_index cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]} host_opts='-currentHost -host' cmds='read read-type write rename delete domains find help' if ((COMP_CWORD == 1)); then COMPREPLY=( $(compgen -W "$host_opts $cmds" -- "$cur") ) return 0 elif ((COMP_CWORD == 2)); then if [[ $prev == "-currentHost" ]]; then COMPREPLY=( $(compgen -W "$cmds" -- "$cur") ) return 0 elif [[ $prev == "-host" ]]; then if _omb_util_function_exists _known_hosts; then _known_hosts -a fi return 0 else _defaults_domains return 0 fi elif ((COMP_CWORD == 3)); then if [[ ${COMP_WORDS[1]} == "-host" ]]; then _defaults_domains return 0 fi fi # Both a domain and command have been specified if [[ ${COMP_WORDS[1]} == @(${cmds// /|}) ]]; then cmd=${COMP_WORDS[1]} domain=${COMP_WORDS[2]} key_index=3 if [[ $domain == "-app" ]]; then if ((COMP_CWORD == 3)); then # Completing application name. Can't help here, sorry return 0 fi domain="-app ${COMP_WORDS[3]}" key_index=4 fi elif [[ ${COMP_WORDS[2]} == "-currentHost" && ${COMP_WORDS[2]} == @(${cmds// /|}) ]]; then cmd=${COMP_WORDS[2]} domain=${COMP_WORDS[3]} key_index=4 if [[ "$domain" == "-app" ]]; then if [[ $COMP_CWORD -eq 4 ]]; then # Completing application name. Can't help here, sorry return 0 fi domain="-app ${COMP_WORDS[4]}" key_index=5 fi elif [[ ${COMP_WORDS[3]} == "-host" && ${COMP_WORDS[3]} == @(${cmds// /|}) ]]; then cmd=${COMP_WORDS[3]} domain=${COMP_WORDS[4]} key_index=5 if [[ $domain == "-app" ]]; then if ((COMP_CWORD == 5)); then # Completing application name. Can't help here, sorry return 0 fi domain="-app ${COMP_WORDS[5]}" key_index=6 fi fi keys=$(defaults read $domain 2>/dev/null | sed -ne '/^ [^}) ]/p' | sed -e 's/^ \([^" ]\{1,\}\) = .*$/\1/g' -e 's/^ "\([^"]\{1,\}\)" = .*$/\1/g' | sed -e 's/ /\\ /g' ) case $cmd in read|read-type) # Complete key local IFS=$'\n' COMPREPLY=( $(grep -i "^${cur//\\/\\\\}" <<< "$keys") ) ;; write) if ((key_index == COMP_CWORD)); then # Complete key local IFS=$'\n' COMPREPLY=( $(grep -i "^${cur//\\/\\\\}" <<< "$keys") ) elif ((key_index + 1 == COMP_CWORD)); then # Complete value type # Unfortunately ${COMP_WORDS[key_index]} fails on keys with spaces local value_types='-string -data -integer -float -boolean -date -array -array-add -dict -dict-add' local cur_type=$(defaults read-type $domain ${COMP_WORDS[key_index]} 2>/dev/null | sed -e 's/^Type is \(.*\)/-\1/' -e's/dictionary/dict/' | grep "^$cur") if [[ $cur_type ]]; then COMPREPLY=( $cur_type ) else COMPREPLY=( $(compgen -W "$value_types" -- "$cur") ) fi elif ((key_index + 2 == COMP_CWORD)); then # Complete value # Unfortunately ${COMP_WORDS[key_index]} fails on keys with spaces COMPREPLY=( $(defaults read $domain ${COMP_WORDS[key_index]} 2>/dev/null | grep -i "^${cur//\\/\\\\}") ) fi ;; rename) if ((key_index == COMP_CWORD || key_index + 1 == COMP_CWORD)); then # Complete source and destination keys local IFS=$'\n' COMPREPLY=( $(grep -i "^${cur//\\/\\\\}" <<< "$keys") ) fi ;; delete) if ((key_index == COMP_CWORD)); then # Complete key local IFS=$'\n' COMPREPLY=( $(grep -i "^${cur//\\/\\\\}" <<< "$keys") ) fi ;; esac return 0 } complete -F _defaults -o default defaults # This file is licensed under the BSD license, as follows: # # Copyright (c) 2006, Playhaus # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: # # * Redistributions of source code must retain the above copyright notice, this # list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright notice, # this list of conditions and the following disclaimer in the documentation # and/or other materials provided with the distribution. # * Neither the name of the Playhaus nor the names of its contributors may be # used to endorse or promote products derived from this software without # specific prior written permission. # # This software is provided by the copyright holders and contributors "as is" # and any express or implied warranties, including, but not limited to, the # implied warranties of merchantability and fitness for a particular purpose are # disclaimed. In no event shall the copyright owner or contributors be liable # for any direct, indirect, incidental, special, exemplary, or consequential # damages (including, but not limited to, procurement of substitute goods or # services; loss of use, data, or profits; or business interruption) however # caused and on any theory of liability, whether in contract, strict liability, # or tort (including negligence or otherwise) arising in any way out of the use # of this software, even if advised of the possibility of such damage. ================================================ FILE: completions/dirs.completion.sh ================================================ #! bash oh-my-bash.module # Bash completion support for the 'dirs' plugin (commands G, R). function _dirs-complete { local CURRENT_PROMPT="${COMP_WORDS[COMP_CWORD]}" # parse all defined shortcuts from ~/.dirs if [ -r "$HOME/.dirs" ]; then COMPREPLY=($(compgen -W "$(grep -v '^#' ~/.dirs | sed -e 's/\(.*\)=.*/\1/')" -- ${CURRENT_PROMPT}) ) fi return 0 } complete -o default -o nospace -F _dirs-complete G R ================================================ FILE: completions/django.completion.sh ================================================ #! bash oh-my-bash.module # Upstream: https://github.com/django/django/blob/90c59b4e12e6ff41407694a460f5f30c4688dbfd/extras/django_bash_completion # # ######################################################################### # This bash script adds tab-completion feature to django-admin and manage.py. # # Testing it out without installing # ================================= # # To test out the completion without "installing" this, just run this file # directly, like so: # # . ~/path/to/django_bash_completion # # Note: There's a dot ('.') at the beginning of that command. # # After you do that, tab completion will immediately be made available in your # current Bash shell. But it won't be available next time you log in. # # Installing # ========== # # To install this, point to this file from your .bash_profile, like so: # # . ~/path/to/django_bash_completion # # Do the same in your .bashrc if .bashrc doesn't invoke .bash_profile. # # Settings will take effect the next time you log in. # # Uninstalling # ============ # # To uninstall, just remove the line from your .bash_profile and .bashrc. function _omb_completion_django { COMPREPLY=($(COMP_WORDS="${COMP_WORDS[*]}" \ COMP_CWORD=$COMP_CWORD \ DJANGO_AUTO_COMPLETE=1 "$1")) } # When the django-admin.py deprecation ends, remove django-admin.py. complete -F _omb_completion_django -o default manage.py django-admin function _omb_completion_django_python { if ((COMP_CWORD >= 2)); then if command grep -qE "python([3-9]\.[0-9])?" <<< "${COMP_WORDS[0]##*/}"; then if command grep -qE "manage\.py|django-admin" <<< "${COMP_WORDS[1]##*/}"; then COMPREPLY=($(COMP_WORDS="${COMP_WORDS[*]:1}" \ COMP_CWORD=$((COMP_CWORD - 1)) \ DJANGO_AUTO_COMPLETE=1 "${COMP_WORDS[@]}")) fi fi fi } function _omb_completion_django_init { # Support for multiple interpreters. local -a pythons=(python) if _omb_util_command_exists whereis; then local python_interpreters _omb_util_split python_interpreters "$(whereis python | cut -d " " -f 2-)" local python for python in "${python_interpreters[@]}"; do [[ -x $python ]] || continue [[ $python == *-config ]] || continue python=${python##*/} [[ $python ]] && pythons+=("$python") done _omb_util_split pythons "$(_omb_util_print_lines "${pythons[@]}" | sort -u)" $'\n' fi complete -F _omb_completion_django_python -o default "${pythons[@]}" unset -f "$FUNCNAME" } _omb_completion_django_init ================================================ FILE: completions/docker-compose.completion.sh ================================================ #! bash oh-my-bash.module function _omb_completion_docker_compose_has_completion { local complete complete=$(complete -p docker-compose 2>/dev/null) && [[ $complete ]] || return 1 unset -f _omb_completion_docker_compose_has_completion unset -f _omb_completion_docker_compose_try return 0 } function _omb_completion_docker_compose_try { if [[ -s $1 ]]; then source "$1" _omb_completion_docker_compose_has_completion && return 0 elif [[ -s $1.sh ]]; then source "$1.sh" _omb_completion_docker_compose_has_completion && return 0 elif [[ -s $1.bash ]]; then source "$1.bash" _omb_completion_docker_compose_has_completion && return 0 fi return 1 } _omb_completion_docker_compose_has_completion && return 0 if _omb_util_function_exists _comp_load; then # bash-completion 2.12 _comp_load -- docker-compose _omb_completion_docker_compose_has_completion && return 0 elif _omb_util_function_exists __load_completion; then # bash-completion <= 2.11 __load_completion docker-compose _omb_completion_docker_compose_has_completion && return 0 fi _omb_completion_docker_compose_try /usr/share/bash-completion/completions/docker-compose && return 0 _omb_completion_docker_compose_try /etc/bash_completion.d/docker-compose && return 0 unset -f _omb_completion_docker_compose_has_completion unset -f _omb_completion_docker_compose_try source "$OSH/completions/fallback/docker-compose.bash" ================================================ FILE: completions/docker-machine.completion.sh ================================================ #! bash oh-my-bash.module # # bash completion file for docker-machine commands # # This script provides completion of: # - commands and their options # - machine names # - filepaths # # To enable the completions either: # - place this file in /etc/bash_completion.d # or # - copy this file to e.g. ~/.docker-machine-completion.sh and add the line # below to your .bashrc after bash completion features are loaded # . ~/.docker-machine-completion.sh # function _docker_machine_active { if [[ "${cur}" == -* ]]; then COMPREPLY=($(compgen -W "--help" -- "${cur}")) else COMPREPLY=() fi } function _docker_machine_config { if [[ "${cur}" == -* ]]; then COMPREPLY=($(compgen -W "--swarm --help" -- "${cur}")) else COMPREPLY=($(compgen -W "$(docker-machine ls -q)" -- "${cur}")) fi } function _docker_machine_create { # cheating, b/c there are approximately one zillion options to create COMPREPLY=($(compgen -W "$(docker-machine create --help | grep '^ -' | sed 's/^ //; s/[^a-z0-9-].*$//')" -- "${cur}")) } function _docker_machine_env { case "${prev}" in --shell) # What are the options for --shell? COMPREPLY=() ;; *) if [[ "${cur}" == -* ]]; then COMPREPLY=($(compgen -W "--swarm --shell --unset --no-proxy --help" -- "${cur}")) else COMPREPLY=($(compgen -W "$(docker-machine ls -q)" -- "${cur}")) fi esac } # See docker-machine-wrapper.bash for the use command function _docker_machine_use { if [[ "${cur}" == -* ]]; then COMPREPLY=($(compgen -W "--swarm --unset --help" -- "${cur}")) else COMPREPLY=($(compgen -W "$(docker-machine ls -q)" -- "${cur}")) fi } function _docker_machine_inspect { case "${prev}" in -f|--format) COMPREPLY=() ;; *) if [[ "${cur}" == -* ]]; then COMPREPLY=($(compgen -W "--format --help" -- "${cur}")) else COMPREPLY=($(compgen -W "$(docker-machine ls -q)" -- "${cur}")) fi ;; esac } function _docker_machine_ip { if [[ "${cur}" == -* ]]; then COMPREPLY=($(compgen -W "--help" -- "${cur}")) else COMPREPLY=($(compgen -W "$(docker-machine ls -q)" -- "${cur}")) fi } function _docker_machine_kill { if [[ "${cur}" == -* ]]; then COMPREPLY=($(compgen -W "--help" -- "${cur}")) else COMPREPLY=($(compgen -W "$(docker-machine ls -q)" -- "${cur}")) fi } function _docker_machine_ls { case "${prev}" in --filter) COMPREPLY=() ;; *) COMPREPLY=($(compgen -W "--quiet --filter --format --timeout --help" -- "${cur}")) ;; esac } function _docker_machine_regenerate_certs { if [[ "${cur}" == -* ]]; then COMPREPLY=($(compgen -W "--help --force" -- "${cur}")) else COMPREPLY=($(compgen -W "$(docker-machine ls -q)" -- "${cur}")) fi } function _docker_machine_restart { if [[ "${cur}" == -* ]]; then COMPREPLY=($(compgen -W "--help" -- "${cur}")) else COMPREPLY=($(compgen -W "$(docker-machine ls -q)" -- "${cur}")) fi } function _docker_machine_rm { if [[ "${cur}" == -* ]]; then COMPREPLY=($(compgen -W "--help --force -y" -- "${cur}")) else # For rm, it's best to be explicit COMPREPLY=() fi } function _docker_machine_ssh { if [[ "${cur}" == -* ]]; then COMPREPLY=($(compgen -W "--help" -- "${cur}")) else COMPREPLY=($(compgen -W "$(docker-machine ls -q)" -- "${cur}")) fi } function _docker_machine_scp { if [[ "${cur}" == -* ]]; then COMPREPLY=($(compgen -W "--help --recursive" -- "${cur}")) else _filedir # It would be really nice to ssh to the machine and ls to complete # remote files. COMPREPLY=($(compgen -W "$(docker-machine ls -q | sed 's/$/:/')" -- "${cur}") "${COMPREPLY[@]}") fi } function _docker_machine_start { if [[ "${cur}" == -* ]]; then COMPREPLY=($(compgen -W "--help" -- "${cur}")) else COMPREPLY=($(compgen -W "$(docker-machine ls -q)" -- "${cur}")) fi } function _docker_machine_status { if [[ "${cur}" == -* ]]; then COMPREPLY=($(compgen -W "--help" -- "${cur}")) else COMPREPLY=($(compgen -W "$(docker-machine ls -q)" -- "${cur}")) fi } function _docker_machine_stop { if [[ "${cur}" == -* ]]; then COMPREPLY=($(compgen -W "--help" -- "${cur}")) else COMPREPLY=($(compgen -W "$(docker-machine ls -q)" -- "${cur}")) fi } function _docker_machine_upgrade { if [[ "${cur}" == -* ]]; then COMPREPLY=($(compgen -W "--help" -- "${cur}")) else COMPREPLY=($(compgen -W "$(docker-machine ls -q)" -- "${cur}")) fi } function _docker_machine_url { if [[ "${cur}" == -* ]]; then COMPREPLY=($(compgen -W "--help" -- "${cur}")) else COMPREPLY=($(compgen -W "$(docker-machine ls -q)" -- "${cur}")) fi } function _docker_machine_version { if [[ "${cur}" == -* ]]; then COMPREPLY=($(compgen -W "--help" -- "${cur}")) else COMPREPLY=($(compgen -W "$(docker-machine ls -q)" -- "${cur}")) fi } function _docker_machine_help { if [[ "${cur}" == -* ]]; then COMPREPLY=($(compgen -W "--help" -- "${cur}")) else COMPREPLY=($(compgen -W "${commands[*]}" -- "${cur}")) fi } function _docker_machine_docker_machine { if [[ " ${wants_file[*]} " =~ " ${prev} " ]]; then _filedir elif [[ " ${wants_dir[*]} " =~ " ${prev} " ]]; then _filedir -d elif [[ "${cur}" == -* ]]; then COMPREPLY=($(compgen -W "${flags[*]} ${wants_dir[*]} ${wants_file[*]}" -- "${cur}")) else COMPREPLY=($(compgen -W "${commands[*]}" -- "${cur}")) fi } function _docker_machine { COMPREPLY=() local commands=(active config create env inspect ip kill ls regenerate-certs restart rm ssh scp start status stop upgrade url version help) local flags=(--debug --native-ssh --github-api-token --bugsnag-api-token --help --version) local wants_dir=(--storage-path) local wants_file=(--tls-ca-cert --tls-ca-key --tls-client-cert --tls-client-key) # Add the use subcommand, if we have an alias loaded if [[ ${DOCKER_MACHINE_WRAPPED} = true ]]; then commands=("${commands[@]}" use) fi local cur prev words cword _get_comp_words_by_ref -n : cur prev words cword local i local command=docker-machine for (( i=1; i < ${cword}; ++i)); do local word=${words[i]} if [[ " ${wants_file[*]} ${wants_dir[*]} " =~ " ${word} " ]]; then # skip the next option (( ++i )) elif [[ " ${commands[*]} " =~ " ${word} " ]]; then command=${word} fi done local completion_func=_docker_machine_"${command//-/_}" if _omb_util_function_exists "${completion_func}"; then "${completion_func}" fi return 0 } complete -F _docker_machine docker-machine ================================================ FILE: completions/docker.completion.sh ================================================ #! bash oh-my-bash.module function _omb_completion_docker_has_completion { local complete complete=$(complete -p docker 2>/dev/null) && [[ $complete ]] || return 1 # bash-completion runs $(docker completion bash) as a fallback, but the # official docker completion is not provided through $(docker completion # bash), which is automatically generated by cobra's bash completion V2. In # this case, we can instead use the completion file bundled with OMB. if [[ $complete == *__start_docker* ]]; then complete -r docker return 1 fi unset -f _omb_completion_docker_has_completion unset -f _omb_completion_docker_try return 0 } function _omb_completion_docker_try { if [[ -s $1 ]]; then source "$1" _omb_completion_docker_has_completion && return 0 elif [[ -s $1.sh ]]; then source "$1.sh" _omb_completion_docker_has_completion && return 0 elif [[ -s $1.bash ]]; then source "$1.bash" _omb_completion_docker_has_completion && return 0 fi return 1 } _omb_completion_docker_has_completion && return 0 if _omb_util_function_exists _comp_load; then # bash-completion 2.12 _comp_load -- docker-compose _omb_completion_docker_has_completion && return 0 elif _omb_util_function_exists __load_completion; then # bash-completion <= 2.11 __load_completion docker-compose _omb_completion_docker_has_completion && return 0 fi _omb_completion_docker_try /usr/share/bash-completion/completions/docker && return 0 _omb_completion_docker_try /etc/bash_completion.d/docker && return 0 unset -f _omb_completion_docker_has_completion unset -f _omb_completion_docker_try source "$OSH/completions/fallback/docker.bash" ================================================ FILE: completions/drush.completion.sh ================================================ #! bash oh-my-bash.module # # bash completion support for Drush: # https://github.com/drush-ops/drush # # Originally from: # http://github.com/drush-ops/drush/blob/master/drush.complete.sh # Ensure drush is available. _omb_util_command_exists drush || return function __drush_ps1 { f="${TMPDIR:-/tmp/}/drush-env/drush-drupal-site-$$" if [ -f $f ] then __DRUPAL_SITE=$(cat "$f") else __DRUPAL_SITE="$DRUPAL_SITE" fi [[ -n "$__DRUPAL_SITE" ]] && printf "${1:- (%s)}" "$__DRUPAL_SITE" } # Completion function, uses the "drush complete" command to retrieve # completions for a specific command line COMP_WORDS. function _drush_completion { # Set IFS to newline (locally), since we only use newline separators, and # need to retain spaces (or not) after completions. local IFS=$'\n' # The '< /dev/null' is a work around for a bug in php libedit stdin handling. # Note that libedit in place of libreadline in some distributions. See: # https://bugs.launchpad.net/ubuntu/+source/php5/+bug/322214 COMPREPLY=( $(drush --early=includes/complete.inc "${COMP_WORDS[@]}" < /dev/null 2> /dev/null) ) } # Register our completion function. We include common short aliases for Drush. complete -o bashdefault -o default -o nospace -F _drush_completion d dr drush drush5 drush6 drush6 drush.php ================================================ FILE: completions/fabric-completion.sh ================================================ #! bash oh-my-bash.module # # Bash completion support for Fabric (http://fabfile.org/) # # # Copyright (C) 2011 by Konstantin Bakulin # # 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. # # Thanks to: # - Adam Vandenberg, # https://github.com/adamv/dotfiles/blob/master/completion_scripts/fab_completion.bash # # - Enrico Batista da Luz, # https://github.com/ricobl/dotfiles/blob/master/bin/fab_bash_completion # # Use cache files for fab tasks or not. # If set to "false" command "fab --shortlist" will be executed every time. export FAB_COMPLETION_CACHE_TASKS=true # File name where tasks cache will be stored (in current dir). export FAB_COMPLETION_CACHED_TASKS_FILENAME=".fab_tasks~" # Set command to get time of last file modification as seconds since Epoch case `uname` in Darwin|FreeBSD) __FAB_COMPLETION_MTIME_COMMAND="stat -f '%m'" ;; *) __FAB_COMPLETION_MTIME_COMMAND="stat -c '%Y'" ;; esac # # Get time of last fab cache file modification as seconds since Epoch # function __fab_chache_mtime() { ${__FAB_COMPLETION_MTIME_COMMAND} \ $FAB_COMPLETION_CACHED_TASKS_FILENAME | xargs -n 1 expr } # # Get time of last fabfile file/module modification as seconds since Epoch # function __fab_fabfile_mtime() { local f="fabfile" if [[ -e "$f.py" ]]; then ${__FAB_COMPLETION_MTIME_COMMAND} "$f.py" | xargs -n 1 expr else # Suppose that it's a fabfile dir find $f/*.py -exec ${__FAB_COMPLETION_MTIME_COMMAND} {} + \ | xargs -n 1 expr | sort -n -r | head -1 fi } # # Completion for "fab" command # function __fab_completion() { # Return if "fab" command doesn't exists _omb_util_binary_exists fab || return 0 # Variables to hold the current word and possible matches local cur="${COMP_WORDS[COMP_CWORD]}" local opts=() # Generate possible matches and store them in variable "opts" case "${cur}" in -*) if [[ -z "${__FAB_COMPLETION_LONG_OPT}" ]]; then export __FAB_COMPLETION_LONG_OPT=$( fab --help | command grep -Eo "\-\-[A-Za-z_\-]+\=?" | sort -u) fi opts="${__FAB_COMPLETION_LONG_OPT}" ;; # Completion for short options is not nessary. # It's left here just for history. # -*) # if [[ -z "${__FAB_COMPLETION_SHORT_OPT}" ]]; then # export __FAB_COMPLETION_SHORT_OPT=$( # fab --help | command grep -Eo "^ +\-[A-Za-z_\]" | sort -u) # fi # opts="${__FAB_COMPLETION_SHORT_OPT}" # ;; *) # If "fabfile.py" or "fabfile" dir with "__init__.py" file exists local f="fabfile" if [[ -e "$f.py" || (-d "$f" && -e "$f/__init__.py") ]]; then # Build a list of the available tasks if $FAB_COMPLETION_CACHE_TASKS; then # If use cache if [[ ! -s ${FAB_COMPLETION_CACHED_TASKS_FILENAME} || $(__fab_fabfile_mtime) -gt $(__fab_chache_mtime) ]]; then fab --shortlist > ${FAB_COMPLETION_CACHED_TASKS_FILENAME} \ 2> /dev/null fi opts=$(cat ${FAB_COMPLETION_CACHED_TASKS_FILENAME}) else # Without cache opts=$(fab --shortlist 2> /dev/null) fi fi ;; esac # Set possible completions COMPREPLY=($(compgen -W "${opts}" -- ${cur})) } complete -o default -o nospace -F __fab_completion fab ================================================ FILE: completions/fallback/docker-compose.bash ================================================ #! bash oh-my-bash.module #------------------------------------------------------------------------------ # Note by OMB: This file is taken from the following version of Docker Compose # v1: # # https://github.com/docker/compose/blob/30fcb72cf3b136598883752edfa6ea4f3b8643d4/contrib/completion/bash/docker-compose # # Licence: Apache-2.0 license # Copyright: original authors of Docker Compose v1 #------------------------------------------------------------------------------ # # bash completion for docker-compose # # This work is based on the completion for the docker command. # # This script provides completion of: # - commands and their options # - service names # - filepaths # # To enable the completions either: # - place this file in /etc/bash_completion.d # or # - copy this file to e.g. ~/.docker-compose-completion.sh and add the line # below to your .bashrc after bash completion features are loaded # . ~/.docker-compose-completion.sh __docker_compose_previous_extglob_setting=$(shopt -p extglob) shopt -s extglob function __docker_compose_q { docker-compose 2>/dev/null "${top_level_options[@]}" "$@" } # Transforms a multiline list of strings into a single line string # with the words separated by "|". function __docker_compose_to_alternatives { local parts=( $1 ) local IFS='|' echo "${parts[*]}" } # Transforms a multiline list of options into an extglob pattern # suitable for use in case statements. function __docker_compose_to_extglob { local extglob=$( __docker_compose_to_alternatives "$1" ) echo "@($extglob)" } # Determines whether the option passed as the first argument exist on # the commandline. The option may be a pattern, e.g. `--force|-f`. function __docker_compose_has_option { local pattern="$1" for (( i=2; i < $cword; ++i)); do if [[ ${words[$i]} =~ ^($pattern)$ ]] ; then return 0 fi done return 1 } # Returns `key` if we are currently completing the value of a map option (`key=value`) # which matches the extglob passed in as an argument. # This function is needed for key-specific completions. function __docker_compose_map_key_of_current_option { local glob="$1" local key glob_pos if [ "$cur" = "=" ] ; then # key= case key="$prev" glob_pos=$((cword - 2)) elif [[ $cur == *=* ]] ; then # key=value case (OSX) key=${cur%=*} glob_pos=$((cword - 1)) elif [ "$prev" = "=" ] ; then key=${words[$cword - 2]} # key=value case glob_pos=$((cword - 3)) else return fi [ "${words[$glob_pos]}" = "=" ] && ((glob_pos--)) # --option=key=value syntax [[ ${words[$glob_pos]} == @($glob) ]] && echo "$key" } # suppress trailing whitespace function __docker_compose_nospace { # compopt is not available in ancient bash versions _omb_util_command_exists compopt && compopt -o nospace } # Outputs a list of all defined services, regardless of their running state. # Arguments for `docker-compose ps` may be passed in order to filter the service list, # e.g. `status=running`. function __docker_compose_services { __docker_compose_q ps --services "$@" } # Applies completion of services based on the current value of `$cur`. # Arguments for `docker-compose ps` may be passed in order to filter the service list, # see `__docker_compose_services`. function __docker_compose_complete_services { COMPREPLY=( $(compgen -W "$(__docker_compose_services "$@")" -- "$cur") ) } # The services for which at least one running container exists function __docker_compose_complete_running_services { local names=$(__docker_compose_services --filter status=running) COMPREPLY=( $(compgen -W "$names" -- "$cur") ) } function _docker_compose_build { case "$prev" in --build-arg) COMPREPLY=( $( compgen -e -- "$cur" ) ) __docker_compose_nospace return ;; --memory|-m) return ;; esac case "$cur" in -*) COMPREPLY=( $( compgen -W "--build-arg --compress --force-rm --help --memory -m --no-cache --no-rm --pull --parallel -q --quiet" -- "$cur" ) ) ;; *) __docker_compose_complete_services --filter source=build ;; esac } function _docker_compose_config { case "$prev" in --hash) if [[ $cur == \\* ]] ; then COMPREPLY=( '\*' ) else COMPREPLY=( $(compgen -W "$(__docker_compose_services) \\\* " -- "$cur") ) fi return ;; esac COMPREPLY=( $( compgen -W "--hash --help --no-interpolate --profiles --quiet -q --resolve-image-digests --services --volumes" -- "$cur" ) ) } function _docker_compose_create { case "$cur" in -*) COMPREPLY=( $( compgen -W "--build --force-recreate --help --no-build --no-recreate" -- "$cur" ) ) ;; *) __docker_compose_complete_services ;; esac } function _docker_compose_docker_compose { case "$prev" in --tlscacert|--tlscert|--tlskey) _filedir return ;; --file|-f) _filedir "y?(a)ml" return ;; --ansi) COMPREPLY=( $( compgen -W "never always auto" -- "$cur" ) ) return ;; --log-level) COMPREPLY=( $( compgen -W "debug info warning error critical" -- "$cur" ) ) return ;; --profile) COMPREPLY=( $( compgen -W "$(__docker_compose_q config --profiles)" -- "$cur" ) ) return ;; --project-directory) _filedir -d return ;; --env-file) _filedir return ;; $(__docker_compose_to_extglob "$daemon_options_with_args") ) return ;; esac case "$cur" in -*) COMPREPLY=( $( compgen -W "$daemon_boolean_options $daemon_options_with_args $top_level_options_with_args --help -h --no-ansi --verbose --version -v" -- "$cur" ) ) ;; *) COMPREPLY=( $( compgen -W "${commands[*]}" -- "$cur" ) ) ;; esac } function _docker_compose_down { case "$prev" in --rmi) COMPREPLY=( $( compgen -W "all local" -- "$cur" ) ) return ;; --timeout|-t) return ;; esac case "$cur" in -*) COMPREPLY=( $( compgen -W "--help --rmi --timeout -t --volumes -v --remove-orphans" -- "$cur" ) ) ;; esac } function _docker_compose_events { case "$prev" in --json) return ;; esac case "$cur" in -*) COMPREPLY=( $( compgen -W "--help --json" -- "$cur" ) ) ;; *) __docker_compose_complete_services ;; esac } function _docker_compose_exec { case "$prev" in --index|--user|-u|--workdir|-w) return ;; esac case "$cur" in -*) COMPREPLY=( $( compgen -W "-d --detach --help --index --privileged -T --user -u --workdir -w" -- "$cur" ) ) ;; *) __docker_compose_complete_running_services ;; esac } function _docker_compose_help { COMPREPLY=( $( compgen -W "${commands[*]}" -- "$cur" ) ) } function _docker_compose_images { case "$cur" in -*) COMPREPLY=( $( compgen -W "--help --quiet -q" -- "$cur" ) ) ;; *) __docker_compose_complete_services ;; esac } function _docker_compose_kill { case "$prev" in -s) COMPREPLY=( $( compgen -W "SIGHUP SIGINT SIGKILL SIGUSR1 SIGUSR2" -- "$(echo $cur | tr '[:lower:]' '[:upper:]')" ) ) return ;; esac case "$cur" in -*) COMPREPLY=( $( compgen -W "--help -s" -- "$cur" ) ) ;; *) __docker_compose_complete_running_services ;; esac } function _docker_compose_logs { case "$prev" in --tail) return ;; esac case "$cur" in -*) COMPREPLY=( $( compgen -W "--follow -f --help --no-color --no-log-prefix --tail --timestamps -t" -- "$cur" ) ) ;; *) __docker_compose_complete_services ;; esac } function _docker_compose_pause { case "$cur" in -*) COMPREPLY=( $( compgen -W "--help" -- "$cur" ) ) ;; *) __docker_compose_complete_running_services ;; esac } function _docker_compose_port { case "$prev" in --protocol) COMPREPLY=( $( compgen -W "tcp udp" -- "$cur" ) ) return; ;; --index) return; ;; esac case "$cur" in -*) COMPREPLY=( $( compgen -W "--help --index --protocol" -- "$cur" ) ) ;; *) __docker_compose_complete_services ;; esac } function _docker_compose_ps { local key=$(__docker_compose_map_key_of_current_option '--filter') case "$key" in source) COMPREPLY=( $( compgen -W "build image" -- "${cur##*=}" ) ) return ;; status) COMPREPLY=( $( compgen -W "paused restarting running stopped" -- "${cur##*=}" ) ) return ;; esac case "$prev" in --filter) COMPREPLY=( $( compgen -W "source status" -S "=" -- "$cur" ) ) __docker_compose_nospace return; ;; esac case "$cur" in -*) COMPREPLY=( $( compgen -W "--all -a --filter --help --quiet -q --services" -- "$cur" ) ) ;; *) __docker_compose_complete_services ;; esac } function _docker_compose_pull { case "$cur" in -*) COMPREPLY=( $( compgen -W "--help --ignore-pull-failures --include-deps --no-parallel --quiet -q" -- "$cur" ) ) ;; *) __docker_compose_complete_services --filter source=image ;; esac } function _docker_compose_push { case "$cur" in -*) COMPREPLY=( $( compgen -W "--help --ignore-push-failures" -- "$cur" ) ) ;; *) __docker_compose_complete_services ;; esac } function _docker_compose_restart { case "$prev" in --timeout|-t) return ;; esac case "$cur" in -*) COMPREPLY=( $( compgen -W "--help --timeout -t" -- "$cur" ) ) ;; *) __docker_compose_complete_running_services ;; esac } function _docker_compose_rm { case "$cur" in -*) COMPREPLY=( $( compgen -W "--force -f --help --stop -s -v" -- "$cur" ) ) ;; *) if __docker_compose_has_option "--stop|-s" ; then __docker_compose_complete_services else __docker_compose_complete_services --filter status=stopped fi ;; esac } function _docker_compose_run { case "$prev" in -e) COMPREPLY=( $( compgen -e -- "$cur" ) ) __docker_compose_nospace return ;; --entrypoint|--label|-l|--name|--user|-u|--volume|-v|--workdir|-w) return ;; esac case "$cur" in -*) COMPREPLY=( $( compgen -W "--detach -d --entrypoint -e --help --label -l --name --no-deps --publish -p --rm --service-ports -T --use-aliases --user -u --volume -v --workdir -w" -- "$cur" ) ) ;; *) __docker_compose_complete_services ;; esac } function _docker_compose_scale { case "$prev" in =) COMPREPLY=("$cur") return ;; --timeout|-t) return ;; esac case "$cur" in -*) COMPREPLY=( $( compgen -W "--help --timeout -t" -- "$cur" ) ) ;; *) COMPREPLY=( $(compgen -S "=" -W "$(__docker_compose_services)" -- "$cur") ) __docker_compose_nospace ;; esac } function _docker_compose_start { case "$cur" in -*) COMPREPLY=( $( compgen -W "--help" -- "$cur" ) ) ;; *) __docker_compose_complete_services --filter status=stopped ;; esac } function _docker_compose_stop { case "$prev" in --timeout|-t) return ;; esac case "$cur" in -*) COMPREPLY=( $( compgen -W "--help --timeout -t" -- "$cur" ) ) ;; *) __docker_compose_complete_running_services ;; esac } function _docker_compose_top { case "$cur" in -*) COMPREPLY=( $( compgen -W "--help" -- "$cur" ) ) ;; *) __docker_compose_complete_running_services ;; esac } function _docker_compose_unpause { case "$cur" in -*) COMPREPLY=( $( compgen -W "--help" -- "$cur" ) ) ;; *) __docker_compose_complete_services --filter status=paused ;; esac } function _docker_compose_up { case "$prev" in =) COMPREPLY=("$cur") return ;; --exit-code-from) __docker_compose_complete_services return ;; --scale) COMPREPLY=( $(compgen -S "=" -W "$(__docker_compose_services)" -- "$cur") ) __docker_compose_nospace return ;; --timeout|-t) return ;; esac case "$cur" in -*) COMPREPLY=( $( compgen -W "--abort-on-container-exit --always-recreate-deps --attach-dependencies --build -d --detach --exit-code-from --force-recreate --help --no-build --no-color --no-deps --no-log-prefix --no-recreate --no-start --renew-anon-volumes -V --remove-orphans --scale --timeout -t" -- "$cur" ) ) ;; *) __docker_compose_complete_services ;; esac } function _docker_compose_version { case "$cur" in -*) COMPREPLY=( $( compgen -W "--short" -- "$cur" ) ) ;; esac } function _docker_compose { local previous_extglob_setting=$(shopt -p extglob) shopt -s extglob local commands=( build config create down events exec help images kill logs pause port ps pull push restart rm run scale start stop top unpause up version ) # Options for the docker daemon that have to be passed to secondary calls to # docker-compose executed by this script. local daemon_boolean_options=" --skip-hostname-check --tls --tlsverify " local daemon_options_with_args=" --context -c --env-file --file -f --host -H --project-directory --project-name -p --tlscacert --tlscert --tlskey " # These options require special treatment when searching the command. local top_level_options_with_args=" --ansi --log-level --profile " COMPREPLY=() local cur prev words cword _get_comp_words_by_ref -n : cur prev words cword # search subcommand and invoke its handler. # special treatment of some top-level options local command='docker_compose' local top_level_options=() local counter=1 while [ $counter -lt $cword ]; do case "${words[$counter]}" in $(__docker_compose_to_extglob "$daemon_boolean_options") ) local opt=${words[counter]} top_level_options+=($opt) ;; $(__docker_compose_to_extglob "$daemon_options_with_args") ) local opt=${words[counter]} local arg=${words[++counter]} top_level_options+=($opt $arg) ;; $(__docker_compose_to_extglob "$top_level_options_with_args") ) (( counter++ )) ;; -*) ;; *) command="${words[$counter]}" break ;; esac (( counter++ )) done local completions_func=_docker_compose_${command//-/_} _omb_util_function_exists "$completions_func" && "$completions_func" eval "$previous_extglob_setting" return 0 } eval "$__docker_compose_previous_extglob_setting" unset __docker_compose_previous_extglob_setting complete -F _docker_compose docker-compose docker-compose.exe ================================================ FILE: completions/fallback/docker.bash ================================================ #! bash oh-my-bash.module # shellcheck disable=SC2016,SC2119,SC2155,SC2206,SC2207,SC2254 #------------------------------------------------------------------------------ # Note by OMB: This file is taken from the following version of Docker CLI: # # https://github.com/docker/cli/blob/34797d167891c11d2e10c1339b072166b77a3378/contrib/completion/bash/docker # # Licence: Apache-2.0 license # Copyright: original authors of Docker CLI #------------------------------------------------------------------------------ # # Shellcheck ignore list: # - SC2016: Expressions don't expand in single quotes, use double quotes for that. # - SC2119: Use foo "$@" if function's $1 should mean script's $1. # - SC2155: Declare and assign separately to avoid masking return values. # - SC2206: Quote to prevent word splitting, or split robustly with mapfile or read -a. # - SC2207: Prefer mapfile or read -a to split command output (or quote to avoid splitting). # - SC2254: Quote expansions in case patterns to match literally rather than as a glob. # # You can find more details for each warning at the following page: # https://github.com/koalaman/shellcheck/wiki/ # # bash completion file for core docker commands # # This script provides completion of: # - commands and their options # - container ids and names # - image repos and tags # - filepaths # # To enable the completions either: # - place this file in /etc/bash_completion.d # or # - copy this file to e.g. ~/.docker-completion.sh and add the line # below to your .bashrc after bash completion features are loaded # . ~/.docker-completion.sh # # Configuration: # # For several commands, the amount of completions can be configured by # setting environment variables. # # DOCKER_COMPLETION_SHOW_CONFIG_IDS # DOCKER_COMPLETION_SHOW_CONTAINER_IDS # DOCKER_COMPLETION_SHOW_NETWORK_IDS # DOCKER_COMPLETION_SHOW_NODE_IDS # DOCKER_COMPLETION_SHOW_PLUGIN_IDS # DOCKER_COMPLETION_SHOW_SECRET_IDS # DOCKER_COMPLETION_SHOW_SERVICE_IDS # "no" - Show names only (default) # "yes" - Show names and ids # # You can tailor completion for the "events", "history", "inspect", "run", # "rmi" and "save" commands by settings the following environment # variables: # # DOCKER_COMPLETION_SHOW_IMAGE_IDS # "none" - Show names only (default) # "non-intermediate" - Show names and ids, but omit intermediate image IDs # "all" - Show names and ids, including intermediate image IDs # # DOCKER_COMPLETION_SHOW_TAGS # "yes" - include tags in completion options (default) # "no" - don't include tags in completion options # # Note: # Currently, the completions will not work if the docker daemon is not # bound to the default communication port/socket # If the docker daemon is using a unix socket for communication your user # must have access to the socket for the completions to function correctly # # Note for developers: # Please arrange options sorted alphabetically by long name with the short # options immediately following their corresponding long form. # This order should be applied to lists, alternatives and code blocks. __docker_previous_extglob_setting=$(shopt -p extglob) shopt -s extglob function __docker_q { docker ${host:+--host "$host"} ${config:+--config "$config"} ${context:+--context "$context"} 2>/dev/null "$@" } # __docker_configs returns a list of configs. Additional options to # `docker config ls` may be specified in order to filter the list, e.g. # `__docker_configs --filter label=stage=production`. # By default, only names are returned. # Set DOCKER_COMPLETION_SHOW_CONFIG_IDS=yes to also complete IDs. # An optional first option `--id|--name` may be used to limit the # output to the IDs or names of matching items. This setting takes # precedence over the environment setting. function __docker_configs { local format if [ "${1-}" = "--id" ] ; then format='{{.ID}}' shift elif [ "${1-}" = "--name" ] ; then format='{{.Name}}' shift elif [ "${DOCKER_COMPLETION_SHOW_CONFIG_IDS-}" = yes ] ; then format='{{.ID}} {{.Name}}' else format='{{.Name}}' fi __docker_q config ls --format "$format" "$@" } # __docker_complete_configs applies completion of configs based on the current value # of `$cur` or the value of the optional first option `--cur`, if given. function __docker_complete_configs { local current="$cur" if [ "$1" = "--cur" ] ; then current="$2" shift 2 fi COMPREPLY=( $(compgen -W "$(__docker_configs "$@")" -- "$current") ) } # __docker_containers returns a list of containers. Additional options to # `docker ps` may be specified in order to filter the list, e.g. # `__docker_containers --filter status=running` # By default, only names are returned. # Set DOCKER_COMPLETION_SHOW_CONTAINER_IDS=yes to also complete IDs. # An optional first option `--id|--name` may be used to limit the # output to the IDs or names of matching items. This setting takes # precedence over the environment setting. function __docker_containers { local format if [ "${1-}" = "--id" ] ; then format='{{.ID}}' shift elif [ "${1-}" = "--name" ] ; then format='{{.Names}}' shift elif [ "${DOCKER_COMPLETION_SHOW_CONTAINER_IDS-}" = yes ] ; then format='{{.ID}} {{.Names}}' else format='{{.Names}}' fi __docker_q ps --format "$format" "$@" } # __docker_complete_containers applies completion of containers based on the current # value of `$cur` or the value of the optional first option `--cur`, if given. # Additional filters may be appended, see `__docker_containers`. function __docker_complete_containers { local current="$cur" if [ "${1-}" = "--cur" ] ; then current="$2" shift 2 fi COMPREPLY=( $(compgen -W "$(__docker_containers "$@")" -- "$current") ) } function __docker_complete_containers_all { __docker_complete_containers "$@" --all } # shellcheck disable=SC2120 function __docker_complete_containers_removable { __docker_complete_containers "$@" --filter status=created --filter status=exited } function __docker_complete_containers_running { __docker_complete_containers "$@" --filter status=running } # shellcheck disable=SC2120 function __docker_complete_containers_stoppable { __docker_complete_containers "$@" --filter status=running --filter status=paused } # shellcheck disable=SC2120 function __docker_complete_containers_stopped { __docker_complete_containers "$@" --filter status=exited } # shellcheck disable=SC2120 function __docker_complete_containers_unpauseable { __docker_complete_containers "$@" --filter status=paused } function __docker_complete_container_names { local containers=( $(__docker_q ps -aq --no-trunc) ) local names=( $(__docker_q inspect --format '{{.Name}}' "${containers[@]}") ) names=( "${names[@]#/}" ) # trim off the leading "/" from the container names COMPREPLY=( $(compgen -W "${names[*]}" -- "$cur") ) } function __docker_complete_container_ids { local containers=( $(__docker_q ps -aq) ) COMPREPLY=( $(compgen -W "${containers[*]}" -- "$cur") ) } # __docker_contexts returns a list of contexts without the special "default" context. # Completions may be added with `--add`, e.g. `--add default`. function __docker_contexts { local add=() while true ; do case "${1-}" in --add) add+=("$2") shift 2 ;; *) break ;; esac done __docker_q context ls -q echo "${add[@]}" } function __docker_complete_contexts { local contexts=( $(__docker_contexts "$@") ) COMPREPLY=( $(compgen -W "${contexts[*]}" -- "$cur") ) } # __docker_images returns a list of images. For each image, up to three representations # can be generated: the repository (e.g. busybox), repository:tag (e.g. busybox:latest) # and the ID (e.g. sha256:ee22cbbd4ea3dff63c86ba60c7691287c321e93adfc1009604eb1dde7ec88645). # # The optional arguments `--repo`, `--tag` and `--id` select the representations that # may be returned. Whether or not a particular representation is actually returned # depends on the user's customization through several environment variables: # - image IDs are only shown if DOCKER_COMPLETION_SHOW_IMAGE_IDS=all|non-intermediate. # - tags can be excluded by setting DOCKER_COMPLETION_SHOW_TAGS=no. # - repositories are always shown. # # In cases where an exact image specification is needed, `--force-tag` can be used. # It ignores DOCKER_COMPLETION_SHOW_TAGS and only lists valid repository:tag combinations, # avoiding repository names that would default to a potentially missing default tag. # # Additional arguments to `docker image ls` may be specified in order to filter the list, # e.g. `__docker_images --filter dangling=true`. # function __docker_images { local repo_format='{{.Repository}}' local tag_format='{{.Repository}}:{{.Tag}}' local id_format='{{.ID}}' local all local format if [ "${DOCKER_COMPLETION_SHOW_IMAGE_IDS-}" = "all" ] ; then all='--all' fi while true ; do case "${1-}" in --repo) format+="$repo_format\n" shift ;; --tag) if [ "${DOCKER_COMPLETION_SHOW_TAGS:-yes}" = "yes" ]; then format+="$tag_format\n" fi shift ;; --id) if [[ ${DOCKER_COMPLETION_SHOW_IMAGE_IDS-} =~ ^(all|non-intermediate)$ ]] ; then format+="$id_format\n" fi shift ;; --force-tag) # like `--tag` but ignores environment setting format+="$tag_format\n" shift ;; *) break ;; esac done __docker_q image ls --no-trunc --format "${format%\\n}" ${all-} "$@" | grep -v '$' } # __docker_complete_images applies completion of images based on the current value of `$cur` or # the value of the optional first option `--cur`, if given. # See __docker_images for customization of the returned items. function __docker_complete_images { local current="$cur" if [ "${1-}" = "--cur" ] ; then current="$2" shift 2 fi COMPREPLY=( $(compgen -W "$(__docker_images "$@")" -- "$current") ) __ltrim_colon_completions "$current" } # __docker_networks returns a list of all networks. Additional options to # `docker network ls` may be specified in order to filter the list, e.g. # `__docker_networks --filter type=custom` # By default, only names are returned. # Set DOCKER_COMPLETION_SHOW_NETWORK_IDS=yes to also complete IDs. # An optional first option `--id|--name` may be used to limit the # output to the IDs or names of matching items. This setting takes # precedence over the environment setting. function __docker_networks { local format if [ "${1-}" = "--id" ] ; then format='{{.ID}}' shift elif [ "${1-}" = "--name" ] ; then format='{{.Name}}' shift elif [ "${DOCKER_COMPLETION_SHOW_NETWORK_IDS-}" = yes ] ; then format='{{.ID}} {{.Name}}' else format='{{.Name}}' fi __docker_q network ls --format "$format" "$@" } # __docker_complete_networks applies completion of networks based on the current # value of `$cur` or the value of the optional first option `--cur`, if given. # Additional filters may be appended, see `__docker_networks`. function __docker_complete_networks { local current="$cur" if [ "${1-}" = "--cur" ] ; then current="$2" shift 2 fi COMPREPLY=( $(compgen -W "$(__docker_networks "$@")" -- "$current") ) } function __docker_complete_containers_in_network { local containers=($(__docker_q network inspect -f '{{range $i, $c := .Containers}}{{$i}} {{$c.Name}} {{end}}' "$1")) COMPREPLY=( $(compgen -W "${containers[*]}" -- "$cur") ) } # __docker_volumes returns a list of all volumes. Additional options to # `docker volume ls` may be specified in order to filter the list, e.g. # `__docker_volumes --filter dangling=true` # Because volumes do not have IDs, this function does not distinguish between # IDs and names. function __docker_volumes { __docker_q volume ls -q "$@" } # __docker_complete_volumes applies completion of volumes based on the current # value of `$cur` or the value of the optional first option `--cur`, if given. # Additional filters may be appended, see `__docker_volumes`. function __docker_complete_volumes { local current="$cur" if [ "${1-}" = "--cur" ] ; then current="$2" shift 2 fi COMPREPLY=( $(compgen -W "$(__docker_volumes "$@")" -- "$current") ) } # __docker_plugins_bundled returns a list of all plugins of a given type. # The type has to be specified with the mandatory option `--type`. # Valid types are: Network, Volume, Authorization. # Completions may be added or removed with `--add` and `--remove` # This function only deals with plugins that come bundled with Docker. # For plugins managed by `docker plugin`, see `__docker_plugins_installed`. function __docker_plugins_bundled { local type add=() remove=() while true ; do case "${1-}" in --type) type="$2" shift 2 ;; --add) add+=("$2") shift 2 ;; --remove) remove+=("$2") shift 2 ;; *) break ;; esac done local plugins=($(__docker_q info --format "{{range \$i, \$p := .Plugins.$type}}{{.}} {{end}}")) for del in "${remove[@]}" ; do plugins=(${plugins[@]/$del/}) done echo "${plugins[@]}" "${add[@]}" } # __docker_complete_plugins_bundled applies completion of plugins based on the current # value of `$cur` or the value of the optional first option `--cur`, if given. # The plugin type has to be specified with the next option `--type`. # This function only deals with plugins that come bundled with Docker. # For completion of plugins managed by `docker plugin`, see # `__docker_complete_plugins_installed`. function __docker_complete_plugins_bundled { local current="$cur" if [ "${1-}" = "--cur" ] ; then current="$2" shift 2 fi COMPREPLY=( $(compgen -W "$(__docker_plugins_bundled "$@")" -- "$current") ) } # __docker_plugins_installed returns a list of all plugins that were installed with # the Docker plugin API. # By default, only names are returned. # Set DOCKER_COMPLETION_SHOW_PLUGIN_IDS=yes to also complete IDs. # Additional options to `docker plugin ls` may be specified in order to filter the list, # e.g. `__docker_plugins_installed --filter enabled=true` # For built-in pugins, see `__docker_plugins_bundled`. function __docker_plugins_installed { local format if [ "${DOCKER_COMPLETION_SHOW_PLUGIN_IDS-}" = yes ] ; then format='{{.ID}} {{.Name}}' else format='{{.Name}}' fi __docker_q plugin ls --format "$format" "$@" } # __docker_complete_plugins_installed applies completion of plugins that were installed # with the Docker plugin API, based on the current value of `$cur` or the value of # the optional first option `--cur`, if given. # Additional filters may be appended, see `__docker_plugins_installed`. # For completion of built-in pugins, see `__docker_complete_plugins_bundled`. function __docker_complete_plugins_installed { local current="$cur" if [ "${1-}" = "--cur" ] ; then current="$2" shift 2 fi COMPREPLY=( $(compgen -W "$(__docker_plugins_installed "$@")" -- "$current") ) } function __docker_runtimes { __docker_q info | sed -n 's/^Runtimes: \(.*\)/\1/p' } function __docker_complete_runtimes { COMPREPLY=( $(compgen -W "$(__docker_runtimes)" -- "$cur") ) } # __docker_secrets returns a list of secrets. Additional options to # `docker secret ls` may be specified in order to filter the list, e.g. # `__docker_secrets --filter label=stage=production` # By default, only names are returned. # Set DOCKER_COMPLETION_SHOW_SECRET_IDS=yes to also complete IDs. # An optional first option `--id|--name` may be used to limit the # output to the IDs or names of matching items. This setting takes # precedence over the environment setting. function __docker_secrets { local format if [ "${1-}" = "--id" ] ; then format='{{.ID}}' shift elif [ "${1-}" = "--name" ] ; then format='{{.Name}}' shift elif [ "${DOCKER_COMPLETION_SHOW_SECRET_IDS-}" = yes ] ; then format='{{.ID}} {{.Name}}' else format='{{.Name}}' fi __docker_q secret ls --format "$format" "$@" } # __docker_complete_secrets applies completion of secrets based on the current value # of `$cur` or the value of the optional first option `--cur`, if given. function __docker_complete_secrets { local current="$cur" if [ "${1-}" = "--cur" ] ; then current="$2" shift 2 fi COMPREPLY=( $(compgen -W "$(__docker_secrets "$@")" -- "$current") ) } # __docker_stacks returns a list of all stacks. function __docker_stacks { __docker_q stack ls | awk 'NR>1 {print $1}' } # __docker_complete_stacks applies completion of stacks based on the current value # of `$cur` or the value of the optional first option `--cur`, if given. function __docker_complete_stacks { local current="$cur" if [ "${1-}" = "--cur" ] ; then current="$2" shift 2 fi COMPREPLY=( $(compgen -W "$(__docker_stacks "$@")" -- "$current") ) } # __docker_nodes returns a list of all nodes. Additional options to # `docker node ls` may be specified in order to filter the list, e.g. # `__docker_nodes --filter role=manager` # By default, only node names are returned. # Set DOCKER_COMPLETION_SHOW_NODE_IDS=yes to also complete node IDs. # An optional first option `--id|--name` may be used to limit the # output to the IDs or names of matching items. This setting takes # precedence over the environment setting. # Completions may be added with `--add`, e.g. `--add self`. function __docker_nodes { local format if [ "${DOCKER_COMPLETION_SHOW_NODE_IDS-}" = yes ] ; then format='{{.ID}} {{.Hostname}}' else format='{{.Hostname}}' fi local add=() while true ; do case "${1-}" in --id) format='{{.ID}}' shift ;; --name) format='{{.Hostname}}' shift ;; --add) add+=("$2") shift 2 ;; *) break ;; esac done echo "$(__docker_q node ls --format "$format" "$@")" "${add[@]}" } # __docker_complete_nodes applies completion of nodes based on the current # value of `$cur` or the value of the optional first option `--cur`, if given. # Additional filters may be appended, see `__docker_nodes`. function __docker_complete_nodes { local current="$cur" if [ "${1-}" = "--cur" ] ; then current="$2" shift 2 fi COMPREPLY=( $(compgen -W "$(__docker_nodes "$@")" -- "$current") ) } # __docker_services returns a list of all services. Additional options to # `docker service ls` may be specified in order to filter the list, e.g. # `__docker_services --filter name=xxx` # By default, only node names are returned. # Set DOCKER_COMPLETION_SHOW_SERVICE_IDS=yes to also complete IDs. # An optional first option `--id|--name` may be used to limit the # output to the IDs or names of matching items. This setting takes # precedence over the environment setting. function __docker_services { local format='{{.Name}}' # default: service name only [ "${DOCKER_COMPLETION_SHOW_SERVICE_IDS-}" = yes ] && format='{{.ID}} {{.Name}}' # ID & name if [ "${1-}" = "--id" ] ; then format='{{.ID}}' # IDs only shift elif [ "${1-}" = "--name" ] ; then format='{{.Name}}' # names only shift fi __docker_q service ls --quiet --format "$format" "$@" } # __docker_complete_services applies completion of services based on the current # value of `$cur` or the value of the optional first option `--cur`, if given. # Additional filters may be appended, see `__docker_services`. function __docker_complete_services { local current="$cur" if [ "${1-}" = "--cur" ] ; then current="$2" shift 2 fi COMPREPLY=( $(__docker_services "$@" --filter "name=$current") ) } # __docker_tasks returns a list of all task IDs. function __docker_tasks { __docker_q service ps --format '{{.ID}}' "" } # __docker_complete_services_and_tasks applies completion of services and task IDs. # shellcheck disable=SC2120 function __docker_complete_services_and_tasks { COMPREPLY=( $(compgen -W "$(__docker_services "$@") $(__docker_tasks)" -- "$cur") ) } # __docker_append_to_completions appends the word passed as an argument to every # word in `$COMPREPLY`. # Normally you do this with `compgen -S` while generating the completions. # This function allows you to append a suffix later. It allows you to use # the __docker_complete_XXX functions in cases where you need a suffix. function __docker_append_to_completions { COMPREPLY=( ${COMPREPLY[@]/%/"$1"} ) } # __docker_fetch_info fetches information about the configured Docker server and updates # several variables with the results. # The result is cached for the duration of one invocation of bash completion. function __docker_fetch_info { if [ -z "${info_fetched-}" ] ; then read -r server_experimental server_os <<< "$(__docker_q version -f '{{.Server.Experimental}} {{.Server.Os}}')" info_fetched=true fi } # __docker_server_is_experimental tests whether the currently configured Docker # server runs in experimental mode. If so, the function exits with 0 (true). # Otherwise, or if the result cannot be determined, the exit value is 1 (false). function __docker_server_is_experimental { __docker_fetch_info [ "$server_experimental" = "true" ] } # __docker_server_os_is tests whether the currently configured Docker server runs # on the operating system passed in as the first argument. # Known operating systems: linux, windows. function __docker_server_os_is { local expected_os="$1" __docker_fetch_info [ "$server_os" = "$expected_os" ] } # __docker_pos_first_nonflag finds the position of the first word that is neither # option nor an option's argument. If there are options that require arguments, # you should pass a glob describing those options, e.g. "--option1|-o|--option2" # Use this function to restrict completions to exact positions after the argument list. function __docker_pos_first_nonflag { local argument_flags=${1-} local counter=$((${subcommand_pos:-${command_pos}} + 1)) while [ "$counter" -le "$cword" ]; do if [ -n "$argument_flags" ] && eval "case '${words[$counter]}' in $argument_flags) true ;; *) false ;; esac"; then (( counter++ )) # eat "=" in case of --option=arg syntax [ "${words[$counter]}" = "=" ] && (( counter++ )) else case "${words[$counter]}" in -*) ;; *) break ;; esac fi # Bash splits words at "=", retaining "=" as a word, examples: # "--debug=false" => 3 words, "--log-opt syslog-facility=daemon" => 4 words while [ "${words[$counter + 1]}" = "=" ] ; do counter=$(( counter + 2)) done (( counter++ )) done echo "$counter" } # __docker_map_key_of_current_option returns `key` if we are currently completing the # value of a map option (`key=value`) which matches the extglob given as an argument. # This function is needed for key-specific completions. function __docker_map_key_of_current_option { local glob="$1" local key glob_pos if [ "$cur" = "=" ] ; then # key= case key="$prev" glob_pos=$((cword - 2)) elif [[ $cur == *=* ]] ; then # key=value case (OSX) key=${cur%=*} glob_pos=$((cword - 1)) elif [ "$prev" = "=" ] ; then key=${words[$cword - 2]} # key=value case glob_pos=$((cword - 3)) else return fi [ "${words[$glob_pos]}" = "=" ] && ((glob_pos--)) # --option=key=value syntax [[ ${words[$glob_pos]} == @($glob) ]] && echo "$key" } # __docker_value_of_option returns the value of the first option matching `option_glob`. # Valid values for `option_glob` are option names like `--log-level` and globs like # `--log-level|-l` # Only positions between the command and the current word are considered. function __docker_value_of_option { local option_extglob=$(__docker_to_extglob "$1") local counter=$((command_pos + 1)) while [ "$counter" -lt "$cword" ]; do case ${words[$counter]} in $option_extglob ) echo "${words[$counter + 1]}" break ;; esac (( counter++ )) done } # __docker_to_alternatives transforms a multiline list of strings into a single line # string with the words separated by `|`. # This is used to prepare arguments to __docker_pos_first_nonflag(). function __docker_to_alternatives { local parts=( $1 ) local IFS='|' echo "${parts[*]}" } # __docker_to_extglob transforms a multiline list of options into an extglob pattern # suitable for use in case statements. function __docker_to_extglob { local extglob=$( __docker_to_alternatives "$1" ) echo "@($extglob)" } # __docker_subcommands processes subcommands # Locates the first occurrence of any of the subcommands contained in the # first argument. In case of a match, calls the corresponding completion # function and returns 0. # If no match is found, 1 is returned. The calling function can then # continue processing its completion. # # TODO if the preceding command has options that accept arguments and an # argument is equal ot one of the subcommands, this is falsely detected as # a match. function __docker_subcommands { local subcommands="$1" local counter=$((command_pos + 1)) while [ "$counter" -lt "$cword" ]; do case "${words[$counter]}" in $(__docker_to_extglob "$subcommands") ) subcommand_pos=$counter local subcommand=${words[$counter]} local completions_func=_docker_${command}_${subcommand//-/_} _omb_util_function_exists "$completions_func" && "$completions_func" return 0 ;; esac (( counter++ )) done return 1 } # __docker_nospace suppresses trailing whitespace function __docker_nospace { # compopt is not available in ancient bash versions _omb_util_command_exists compopt && compopt -o nospace } function __docker_complete_resolved_hostname { _omb_util_command_exists host || return COMPREPLY=( $(host 2>/dev/null "${cur%:}" | awk '/has address/ {print $4}') ) } # __docker_local_interfaces returns a list of the names and addresses of all # local network interfaces. # If `--ip-only` is passed as a first argument, only addresses are returned. function __docker_local_interfaces { _omb_util_command_exists ip || return local format if [ "${1-}" = "--ip-only" ] ; then format='\1' shift else format='\1 \2' fi ip addr show scope global 2>/dev/null | sed -n "s| \+inet \([0-9.]\+\).* \([^ ]\+\)|$format|p" } # __docker_complete_local_interfaces applies completion of the names and addresses of all # local network interfaces based on the current value of `$cur`. # An additional value can be added to the possible completions with an `--add` argument. function __docker_complete_local_interfaces { local additional_interface if [ "${1-}" = "--add" ] ; then additional_interface="$2" shift 2 fi COMPREPLY=( $( compgen -W "$(__docker_local_interfaces "$@") $additional_interface" -- "$cur" ) ) } # __docker_complete_local_ips applies completion of the addresses of all local network # interfaces based on the current value of `$cur`. function __docker_complete_local_ips { __docker_complete_local_interfaces --ip-only } # __docker_complete_capabilities_addable completes Linux capabilities which are # not granted by default and may be added. # see https://docs.docker.com/engine/reference/run/#/runtime-privilege-and-linux-capabilities function __docker_complete_capabilities_addable { local capabilities=( ALL CAP_AUDIT_CONTROL CAP_AUDIT_READ CAP_BLOCK_SUSPEND CAP_BPF CAP_CHECKPOINT_RESTORE CAP_DAC_READ_SEARCH CAP_IPC_LOCK CAP_IPC_OWNER CAP_LEASE CAP_LINUX_IMMUTABLE CAP_MAC_ADMIN CAP_MAC_OVERRIDE CAP_NET_ADMIN CAP_NET_BROADCAST CAP_PERFMON CAP_SYS_ADMIN CAP_SYS_BOOT CAP_SYSLOG CAP_SYS_MODULE CAP_SYS_NICE CAP_SYS_PACCT CAP_SYS_PTRACE CAP_SYS_RAWIO CAP_SYS_RESOURCE CAP_SYS_TIME CAP_SYS_TTY_CONFIG CAP_WAKE_ALARM RESET ) COMPREPLY=( $( compgen -W "${capabilities[*]} ${capabilities[*]#CAP_}" -- "$cur" ) ) } # __docker_complete_capabilities_droppable completes Linux capability options which are # allowed by default and can be dropped. # see https://docs.docker.com/engine/reference/run/#/runtime-privilege-and-linux-capabilities function __docker_complete_capabilities_droppable { local capabilities=( ALL CAP_AUDIT_WRITE CAP_CHOWN CAP_DAC_OVERRIDE CAP_FOWNER CAP_FSETID CAP_KILL CAP_MKNOD CAP_NET_BIND_SERVICE CAP_NET_RAW CAP_SETFCAP CAP_SETGID CAP_SETPCAP CAP_SETUID CAP_SYS_CHROOT RESET ) COMPREPLY=( $( compgen -W "${capabilities[*]} ${capabilities[*]#CAP_}" -- "$cur" ) ) } function __docker_complete_detach_keys { case "$prev" in --detach-keys) case "$cur" in *,) COMPREPLY=( $( compgen -W "${cur}ctrl-" -- "$cur" ) ) ;; *) COMPREPLY=( $( compgen -W "ctrl-" -- "$cur" ) ) ;; esac __docker_nospace return ;; esac return 1 } function __docker_complete_isolation { COMPREPLY=( $( compgen -W "default hyperv process" -- "$cur" ) ) } function __docker_complete_log_drivers { COMPREPLY=( $( compgen -W " awslogs etwlogs fluentd gcplogs gelf journald json-file local none splunk syslog " -- "$cur" ) ) } function __docker_complete_log_options { # see https://docs.docker.com/config/containers/logging/configure/ # really global options, defined in https://github.com/moby/moby/blob/master/daemon/logger/factory.go local common_options1="max-buffer-size mode" # common options defined in https://github.com/moby/moby/blob/master/daemon/logger/loginfo.go # but not implemented in all log drivers local common_options2="env env-regex labels" # awslogs does not implement the $common_options2. local awslogs_options="$common_options1 awslogs-create-group awslogs-credentials-endpoint awslogs-datetime-format awslogs-group awslogs-multiline-pattern awslogs-region awslogs-stream tag" local fluentd_options="$common_options1 $common_options2 fluentd-address fluentd-async fluentd-buffer-limit fluentd-request-ack fluentd-retry-wait fluentd-max-retries fluentd-sub-second-precision tag" local gcplogs_options="$common_options1 $common_options2 gcp-log-cmd gcp-meta-id gcp-meta-name gcp-meta-zone gcp-project" local gelf_options="$common_options1 $common_options2 gelf-address gelf-compression-level gelf-compression-type gelf-tcp-max-reconnect gelf-tcp-reconnect-delay tag" local journald_options="$common_options1 $common_options2 tag" local json_file_options="$common_options1 $common_options2 compress max-file max-size" local local_options="$common_options1 compress max-file max-size" local splunk_options="$common_options1 $common_options2 splunk-caname splunk-capath splunk-format splunk-gzip splunk-gzip-level splunk-index splunk-insecureskipverify splunk-source splunk-sourcetype splunk-token splunk-url splunk-verify-connection tag" local syslog_options="$common_options1 $common_options2 syslog-address syslog-facility syslog-format syslog-tls-ca-cert syslog-tls-cert syslog-tls-key syslog-tls-skip-verify tag" local all_options="$fluentd_options $gcplogs_options $gelf_options $journald_options $json_file_options $syslog_options $splunk_options" case $(__docker_value_of_option --log-driver) in '') COMPREPLY=( $( compgen -W "$all_options" -S = -- "$cur" ) ) ;; awslogs) COMPREPLY=( $( compgen -W "$awslogs_options" -S = -- "$cur" ) ) ;; fluentd) COMPREPLY=( $( compgen -W "$fluentd_options" -S = -- "$cur" ) ) ;; gcplogs) COMPREPLY=( $( compgen -W "$gcplogs_options" -S = -- "$cur" ) ) ;; gelf) COMPREPLY=( $( compgen -W "$gelf_options" -S = -- "$cur" ) ) ;; journald) COMPREPLY=( $( compgen -W "$journald_options" -S = -- "$cur" ) ) ;; json-file) COMPREPLY=( $( compgen -W "$json_file_options" -S = -- "$cur" ) ) ;; local) COMPREPLY=( $( compgen -W "$local_options" -S = -- "$cur" ) ) ;; syslog) COMPREPLY=( $( compgen -W "$syslog_options" -S = -- "$cur" ) ) ;; splunk) COMPREPLY=( $( compgen -W "$splunk_options" -S = -- "$cur" ) ) ;; *) return ;; esac __docker_nospace } function __docker_complete_log_driver_options { local key=$(__docker_map_key_of_current_option '--log-opt') case "$key" in awslogs-create-group) COMPREPLY=( $( compgen -W "false true" -- "${cur##*=}" ) ) return ;; awslogs-credentials-endpoint) COMPREPLY=( $( compgen -W "/" -- "${cur##*=}" ) ) __docker_nospace return ;; compress|fluentd-async-connect) COMPREPLY=( $( compgen -W "false true" -- "${cur##*=}" ) ) return ;; fluentd-sub-second-precision) COMPREPLY=( $( compgen -W "false true" -- "${cur##*=}" ) ) return ;; gelf-address) COMPREPLY=( $( compgen -W "tcp udp" -S "://" -- "${cur##*=}" ) ) __docker_nospace return ;; gelf-compression-level) COMPREPLY=( $( compgen -W "1 2 3 4 5 6 7 8 9" -- "${cur##*=}" ) ) return ;; gelf-compression-type) COMPREPLY=( $( compgen -W "gzip none zlib" -- "${cur##*=}" ) ) return ;; line-only) COMPREPLY=( $( compgen -W "false true" -- "${cur##*=}" ) ) return ;; mode) COMPREPLY=( $( compgen -W "blocking non-blocking" -- "${cur##*=}" ) ) return ;; syslog-address) COMPREPLY=( $( compgen -W "tcp:// tcp+tls:// udp:// unix://" -- "${cur##*=}" ) ) __docker_nospace __ltrim_colon_completions "${cur}" return ;; syslog-facility) COMPREPLY=( $( compgen -W " auth authpriv cron daemon ftp kern local0 local1 local2 local3 local4 local5 local6 local7 lpr mail news syslog user uucp " -- "${cur##*=}" ) ) return ;; syslog-format) COMPREPLY=( $( compgen -W "rfc3164 rfc5424 rfc5424micro" -- "${cur##*=}" ) ) return ;; syslog-tls-ca-cert|syslog-tls-cert|syslog-tls-key) _filedir return ;; syslog-tls-skip-verify) COMPREPLY=( $( compgen -W "true" -- "${cur##*=}" ) ) return ;; splunk-url) COMPREPLY=( $( compgen -W "http:// https://" -- "${cur##*=}" ) ) __docker_nospace __ltrim_colon_completions "${cur}" return ;; splunk-gzip|splunk-insecureskipverify|splunk-verify-connection) COMPREPLY=( $( compgen -W "false true" -- "${cur##*=}" ) ) return ;; splunk-format) COMPREPLY=( $( compgen -W "inline json raw" -- "${cur##*=}" ) ) return ;; esac return 1 } function __docker_complete_log_levels { COMPREPLY=( $( compgen -W "debug info warn error fatal" -- "$cur" ) ) } function __docker_complete_restart { case "$prev" in --restart) case "$cur" in on-failure:*) ;; *) COMPREPLY=( $( compgen -W "always no on-failure on-failure: unless-stopped" -- "$cur") ) ;; esac return ;; esac return 1 } # __docker_complete_signals returns a subset of the available signals that is most likely # relevant in the context of docker containers function __docker_complete_signals { local signals=( SIGCONT SIGHUP SIGINT SIGKILL SIGQUIT SIGSTOP SIGTERM SIGUSR1 SIGUSR2 ) COMPREPLY=( $( compgen -W "${signals[*]} ${signals[*]#SIG}" -- "$( echo "$cur" | tr '[:lower:]' '[:upper:]')" ) ) } function __docker_complete_ulimits { local limits=" as chroot core cpu data fsize locks maxlogins maxsyslogins memlock msgqueue nice nofile nproc priority rss rtprio sigpending stack " if [ "${1-}" = "--rm" ] ; then COMPREPLY=( $( compgen -W "$limits" -- "$cur" ) ) else COMPREPLY=( $( compgen -W "$limits" -S = -- "$cur" ) ) __docker_nospace fi } function __docker_complete_user_group { if [[ $cur == *:* ]] ; then COMPREPLY=( $(compgen -g -- "${cur#*:}") ) else COMPREPLY=( $(compgen -u -S : -- "$cur") ) __docker_nospace fi } function __docker_plugins_path { local docker_plugins_path=$(docker info --format '{{range .ClientInfo.Plugins}}{{.Path}}:{{end}}') echo "${docker_plugins_path//:/ }" } function __docker_complete_plugin { local path=$1 local completionCommand="__completeNoDesc" local resultArray=($path $completionCommand) for value in "${words[@]:2}"; do if [ -z "$value" ]; then resultArray+=( "''" ) else resultArray+=( "$value" ) fi done local rawResult=$(eval "${resultArray[*]}" 2> /dev/null) local result=$(grep -v '^:[0-9]*$' <<< "$rawResult") # Compose V2 completions sometimes returns returns `:8` (ShellCompDirectiveFilterFileExt) # with the expected file extensions (such as `yml`, `yaml`) to indicate that the shell should # provide autocompletions for files with matching extensions local completionFlag=$(tail -1 <<< "$rawResult") if [ "$completionFlag" == ":8" ]; then # format a valid glob pattern for the provided file extensions local filePattern=$(tr '\n' '|' <<< "$result") _filedir "$filePattern" return fi # if result empty, just use filename completion as fallback if [ -z "$result" ]; then _filedir else COMPREPLY=( $(compgen -W "${result}" -- "${current-}") ) fi } function _docker_docker { # global options that may appear after the docker command local boolean_options=" $global_boolean_options --help --version -v " case "$prev" in --config) _filedir -d return ;; --context|-c) __docker_complete_contexts return ;; --log-level|-l) __docker_complete_log_levels return ;; $(__docker_to_extglob "$global_options_with_args") ) return ;; esac case "$cur" in -*) COMPREPLY=( $( compgen -W "$boolean_options $global_options_with_args" -- "$cur" ) ) ;; *) local counter=$( __docker_pos_first_nonflag "$(__docker_to_extglob "$global_options_with_args")" ) if [ "$cword" -eq "$counter" ]; then __docker_server_is_experimental && commands+=(${experimental_server_commands[*]}) COMPREPLY=( $( compgen -W "${commands[*]} help" -- "$cur" ) ) fi ;; esac } function _docker_attach { _docker_container_attach } function _docker_build { _docker_image_build } function _docker_builder { local subcommands=" build prune " __docker_subcommands "$subcommands" && return case "$cur" in -*) COMPREPLY=( $( compgen -W "--help" -- "$cur" ) ) ;; *) COMPREPLY=( $( compgen -W "$subcommands" -- "$cur" ) ) ;; esac } function _docker_builder_build { _docker_image_build } function _docker_builder_prune { case "$prev" in --filter) COMPREPLY=( $( compgen -S = -W "description id inuse parent private shared type until unused-for" -- "$cur" ) ) __docker_nospace return ;; --keep-storage) return ;; esac case "$cur" in -*) COMPREPLY=( $( compgen -W "--all -a --filter --force -f --help --keep-storage" -- "$cur" ) ) ;; esac } function _docker_checkpoint { local subcommands=" create ls rm " local aliases=" list remove " __docker_subcommands "$subcommands $aliases" && return case "$cur" in -*) COMPREPLY=( $( compgen -W "--help" -- "$cur" ) ) ;; *) COMPREPLY=( $( compgen -W "$subcommands" -- "$cur" ) ) ;; esac } function _docker_checkpoint_create { case "$prev" in --checkpoint-dir) _filedir -d return ;; esac case "$cur" in -*) COMPREPLY=( $( compgen -W "--checkpoint-dir --help --leave-running" -- "$cur" ) ) ;; *) local counter=$(__docker_pos_first_nonflag '--checkpoint-dir') if [ "$cword" -eq "$counter" ]; then __docker_complete_containers_running fi ;; esac } function _docker_checkpoint_ls { case "$prev" in --checkpoint-dir) _filedir -d return ;; esac case "$cur" in -*) COMPREPLY=( $( compgen -W "--checkpoint-dir --help" -- "$cur" ) ) ;; *) local counter=$(__docker_pos_first_nonflag '--checkpoint-dir') if [ "$cword" -eq "$counter" ]; then __docker_complete_containers_all fi ;; esac } function _docker_checkpoint_rm { case "$prev" in --checkpoint-dir) _filedir -d return ;; esac case "$cur" in -*) COMPREPLY=( $( compgen -W "--checkpoint-dir --help" -- "$cur" ) ) ;; *) local counter=$(__docker_pos_first_nonflag '--checkpoint-dir') if [ "$cword" -eq "$counter" ]; then __docker_complete_containers_all elif [ "$cword" -eq "$((counter + 1))" ]; then COMPREPLY=( $( compgen -W "$(__docker_q checkpoint ls "$prev" | sed 1d)" -- "$cur" ) ) fi ;; esac } function _docker_config { local subcommands=" create inspect ls rm " local aliases=" list remove " __docker_subcommands "$subcommands $aliases" && return case "$cur" in -*) COMPREPLY=( $( compgen -W "--help" -- "$cur" ) ) ;; *) COMPREPLY=( $( compgen -W "$subcommands" -- "$cur" ) ) ;; esac } function _docker_config_create { case "$prev" in --label|-l) return ;; --template-driver) COMPREPLY=( $( compgen -W "golang" -- "$cur" ) ) return ;; esac case "$cur" in -*) COMPREPLY=( $( compgen -W "--help --label -l --template-driver" -- "$cur" ) ) ;; *) local counter=$(__docker_pos_first_nonflag '--label|-l|--template-driver') if [ "$cword" -eq "$((counter + 1))" ]; then _filedir fi ;; esac } function _docker_config_inspect { case "$prev" in --format|-f) return ;; esac case "$cur" in -*) COMPREPLY=( $( compgen -W "--format -f --help --pretty" -- "$cur" ) ) ;; *) __docker_complete_configs ;; esac } function _docker_config_list { _docker_config_ls } function _docker_config_ls { local key=$(__docker_map_key_of_current_option '--filter|-f') case "$key" in id) __docker_complete_configs --cur "${cur##*=}" --id return ;; name) __docker_complete_configs --cur "${cur##*=}" --name return ;; esac case "$prev" in --filter|-f) COMPREPLY=( $( compgen -S = -W "id label name" -- "$cur" ) ) __docker_nospace return ;; --format) return ;; esac case "$cur" in -*) COMPREPLY=( $( compgen -W "--format --filter -f --help --quiet -q" -- "$cur" ) ) ;; esac } function _docker_config_remove { _docker_config_rm } function _docker_config_rm { case "$cur" in -*) COMPREPLY=( $( compgen -W "--help" -- "$cur" ) ) ;; *) __docker_complete_configs ;; esac } function _docker_container { local subcommands=" attach commit cp create diff exec export inspect kill logs ls pause port prune rename restart rm run start stats stop top unpause update wait " local aliases=" list ps " __docker_subcommands "$subcommands $aliases" && return case "$cur" in -*) COMPREPLY=( $( compgen -W "--help" -- "$cur" ) ) ;; *) COMPREPLY=( $( compgen -W "$subcommands" -- "$cur" ) ) ;; esac } function _docker_container_attach { __docker_complete_detach_keys && return case "$cur" in -*) COMPREPLY=( $( compgen -W "--detach-keys --help --no-stdin --sig-proxy=false" -- "$cur" ) ) ;; *) local counter=$(__docker_pos_first_nonflag '--detach-keys') if [ "$cword" -eq "$counter" ]; then __docker_complete_containers_running fi ;; esac } function _docker_container_commit { case "$prev" in --author|-a|--change|-c|--message|-m) return ;; esac case "$cur" in -*) COMPREPLY=( $( compgen -W "--author -a --change -c --help --message -m --pause=false -p=false" -- "$cur" ) ) ;; *) local counter=$(__docker_pos_first_nonflag '--author|-a|--change|-c|--message|-m') if [ "$cword" -eq "$counter" ]; then __docker_complete_containers_all return elif [ "$cword" -eq "$((counter + 1))" ]; then __docker_complete_images --repo --tag return fi ;; esac } function _docker_container_cp { case "$cur" in -*) COMPREPLY=( $( compgen -W "--archive -a --follow-link -L --help" -- "$cur" ) ) ;; *) local counter=$(__docker_pos_first_nonflag) if [ "$cword" -eq "$counter" ]; then case "$cur" in *:) return ;; *) # combined container and filename completion _filedir local files=( ${COMPREPLY[@]} ) __docker_complete_containers_all COMPREPLY=( $( compgen -W "${COMPREPLY[*]}" -S ':' ) ) local containers=( ${COMPREPLY[@]} ) COMPREPLY=( $( compgen -W "${files[*]} ${containers[*]}" -- "$cur" ) ) if [[ "${COMPREPLY[*]}" = *: ]]; then __docker_nospace fi return ;; esac fi (( counter++ )) if [ "$cword" -eq "$counter" ]; then if [ -e "$prev" ]; then __docker_complete_containers_all COMPREPLY=( $( compgen -W "${COMPREPLY[*]}" -S ':' ) ) __docker_nospace else _filedir fi return fi ;; esac } function _docker_container_create { _docker_container_run_and_create } function _docker_container_diff { case "$cur" in -*) COMPREPLY=( $( compgen -W "--help" -- "$cur" ) ) ;; *) local counter=$(__docker_pos_first_nonflag) if [ "$cword" -eq "$counter" ]; then __docker_complete_containers_all fi ;; esac } function _docker_container_exec { __docker_complete_detach_keys && return case "$prev" in --env|-e) # we do not append a "=" here because "-e VARNAME" is legal syntax, too COMPREPLY=( $( compgen -e -- "$cur" ) ) __docker_nospace return ;; --env-file) _filedir return ;; --user|-u) __docker_complete_user_group return ;; --workdir|-w) return ;; esac case "$cur" in -*) COMPREPLY=( $( compgen -W "--detach -d --detach-keys --env -e --env-file --help --interactive -i --privileged -t --tty -u --user --workdir -w" -- "$cur" ) ) ;; *) __docker_complete_containers_running ;; esac } function _docker_container_export { case "$prev" in --output|-o) _filedir return ;; esac case "$cur" in -*) COMPREPLY=( $( compgen -W "--help --output -o" -- "$cur" ) ) ;; *) local counter=$(__docker_pos_first_nonflag) if [ "$cword" -eq "$counter" ]; then __docker_complete_containers_all fi ;; esac } function _docker_container_inspect { _docker_inspect --type container } function _docker_container_kill { case "$prev" in --signal|-s) __docker_complete_signals return ;; esac case "$cur" in -*) COMPREPLY=( $( compgen -W "--help --signal -s" -- "$cur" ) ) ;; *) __docker_complete_containers_running ;; esac } function _docker_container_logs { case "$prev" in --since|--tail|-n|--until) return ;; esac case "$cur" in -*) COMPREPLY=( $( compgen -W "--details --follow -f --help --since --tail -n --timestamps -t --until" -- "$cur" ) ) ;; *) local counter=$(__docker_pos_first_nonflag '--since|--tail|-n|--until') if [ "$cword" -eq "$counter" ]; then __docker_complete_containers_all fi ;; esac } function _docker_container_list { _docker_container_ls } function _docker_container_ls { local key=$(__docker_map_key_of_current_option '--filter|-f') case "$key" in ancestor) __docker_complete_images --cur "${cur##*=}" --repo --tag --id return ;; before) __docker_complete_containers_all --cur "${cur##*=}" return ;; expose|publish) return ;; id) __docker_complete_containers_all --cur "${cur##*=}" --id return ;; health) COMPREPLY=( $( compgen -W "healthy starting none unhealthy" -- "${cur##*=}" ) ) return ;; is-task) COMPREPLY=( $( compgen -W "true false" -- "${cur##*=}" ) ) return ;; name) __docker_complete_containers_all --cur "${cur##*=}" --name return ;; network) __docker_complete_networks --cur "${cur##*=}" return ;; since) __docker_complete_containers_all --cur "${cur##*=}" return ;; status) COMPREPLY=( $( compgen -W "created dead exited paused restarting running removing" -- "${cur##*=}" ) ) return ;; volume) __docker_complete_volumes --cur "${cur##*=}" return ;; esac case "$prev" in --filter|-f) COMPREPLY=( $( compgen -S = -W "ancestor before exited expose health id is-task label name network publish since status volume" -- "$cur" ) ) __docker_nospace return ;; --format|--last|-n) return ;; esac case "$cur" in -*) COMPREPLY=( $( compgen -W "--all -a --filter -f --format --help --last -n --latest -l --no-trunc --quiet -q --size -s" -- "$cur" ) ) ;; esac } function _docker_container_pause { case "$cur" in -*) COMPREPLY=( $( compgen -W "--help" -- "$cur" ) ) ;; *) __docker_complete_containers_running ;; esac } function _docker_container_port { case "$cur" in -*) COMPREPLY=( $( compgen -W "--help" -- "$cur" ) ) ;; *) local counter=$(__docker_pos_first_nonflag) if [ "$cword" -eq "$counter" ]; then __docker_complete_containers_all fi ;; esac } function _docker_container_prune { case "$prev" in --filter) COMPREPLY=( $( compgen -W "label label! until" -S = -- "$cur" ) ) __docker_nospace return ;; esac case "$cur" in -*) COMPREPLY=( $( compgen -W "--force -f --filter --help" -- "$cur" ) ) ;; esac } function _docker_container_ps { _docker_container_ls } function _docker_container_rename { case "$cur" in -*) COMPREPLY=( $( compgen -W "--help" -- "$cur" ) ) ;; *) local counter=$(__docker_pos_first_nonflag) if [ "$cword" -eq "$counter" ]; then __docker_complete_containers_all fi ;; esac } function _docker_container_restart { case "$prev" in --time|-t) return ;; esac case "$cur" in -*) COMPREPLY=( $( compgen -W "--help --time -t" -- "$cur" ) ) ;; *) __docker_complete_containers_all ;; esac } function _docker_container_rm { case "$cur" in -*) COMPREPLY=( $( compgen -W "--force -f --help --link -l --volumes -v" -- "$cur" ) ) ;; *) for arg in "${COMP_WORDS[@]}"; do case "$arg" in --force|-f) __docker_complete_containers_all return ;; esac done __docker_complete_containers_removable ;; esac } function _docker_container_run { _docker_container_run_and_create } # _docker_container_run_and_create is the combined completion for `_docker_container_run` # and `_docker_container_create` function _docker_container_run_and_create { local options_with_args=" --add-host --annotation --attach -a --blkio-weight --blkio-weight-device --cap-add --cap-drop --cgroupns --cgroup-parent --cidfile --cpu-period --cpu-quota --cpu-rt-period --cpu-rt-runtime --cpuset-cpus --cpus --cpuset-mems --cpu-shares -c --device --device-cgroup-rule --device-read-bps --device-read-iops --device-write-bps --device-write-iops --dns --dns-option --dns-search --domainname --entrypoint --env -e --env-file --expose --gpus --group-add --health-cmd --health-interval --health-retries --health-start-period --health-timeout --hostname -h --ip --ip6 --ipc --kernel-memory --label-file --label -l --link --link-local-ip --log-driver --log-opt --mac-address --memory -m --memory-swap --memory-swappiness --memory-reservation --mount --name --network --network-alias --oom-score-adj --pid --pids-limit --platform --publish -p --pull --restart --runtime --security-opt --shm-size --stop-signal --stop-timeout --storage-opt --tmpfs --sysctl --ulimit --user -u --userns --uts --volume-driver --volumes-from --volume -v --workdir -w " __docker_server_os_is windows && options_with_args+=" --cpu-count --cpu-percent --io-maxbandwidth --io-maxiops --isolation " local boolean_options=" --disable-content-trust=false --help --init --interactive -i --no-healthcheck --oom-kill-disable --privileged --publish-all -P --quiet -q --read-only --tty -t " if [ "$command" = "run" ] || [ "$subcommand" = "run" ] ; then options_with_args="$options_with_args --detach-keys " boolean_options="$boolean_options --detach -d --rm --sig-proxy=false " __docker_complete_detach_keys && return fi local all_options="$options_with_args $boolean_options" __docker_complete_log_driver_options && return __docker_complete_restart && return local key=$(__docker_map_key_of_current_option '--security-opt') case "$key" in label) [[ $cur == *: ]] && return COMPREPLY=( $( compgen -W "user: role: type: level: disable" -- "${cur##*=}") ) if [ "${COMPREPLY[*]}" != "disable" ] ; then __docker_nospace fi return ;; seccomp) local cur=${cur##*=} _filedir COMPREPLY+=( $( compgen -W "unconfined" -- "$cur" ) ) return ;; esac case "$prev" in --add-host) case "$cur" in *:) __docker_complete_resolved_hostname return ;; esac ;; --attach|-a) COMPREPLY=( $( compgen -W 'stdin stdout stderr' -- "$cur" ) ) return ;; --cap-add) __docker_complete_capabilities_addable return ;; --cap-drop) __docker_complete_capabilities_droppable return ;; --cidfile|--env-file|--label-file) _filedir return ;; --cgroupns) COMPREPLY=( $( compgen -W "host private" -- "$cur" ) ) return ;; --device|--tmpfs|--volume|-v) case "$cur" in *:*) # TODO somehow do _filedir for stuff inside the image, if it's already specified (which is also somewhat difficult to determine) ;; '') COMPREPLY=( $( compgen -W '/' -- "$cur" ) ) __docker_nospace ;; /*) _filedir __docker_nospace ;; esac return ;; --env|-e) # we do not append a "=" here because "-e VARNAME" is legal syntax, too COMPREPLY=( $( compgen -e -- "$cur" ) ) __docker_nospace return ;; --ipc) case "$cur" in *:*) cur="${cur#*:}" __docker_complete_containers_running ;; *) COMPREPLY=( $( compgen -W 'none host private shareable container:' -- "$cur" ) ) if [ "${COMPREPLY[*]}" = "container:" ]; then __docker_nospace fi ;; esac return ;; --isolation) if __docker_server_os_is windows ; then __docker_complete_isolation return fi ;; --link) case "$cur" in *:*) ;; *) __docker_complete_containers_running COMPREPLY=( $( compgen -W "${COMPREPLY[*]}" -S ':' ) ) __docker_nospace ;; esac return ;; --log-driver) __docker_complete_log_drivers return ;; --log-opt) __docker_complete_log_options return ;; --network) case "$cur" in container:*) __docker_complete_containers_all --cur "${cur#*:}" ;; *) COMPREPLY=( $( compgen -W "$(__docker_plugins_bundled --type Network) $(__docker_networks) container:" -- "$cur") ) if [ "${COMPREPLY[*]}" = "container:" ] ; then __docker_nospace fi ;; esac return ;; --pid) case "$cur" in *:*) __docker_complete_containers_running --cur "${cur#*:}" ;; *) COMPREPLY=( $( compgen -W 'host container:' -- "$cur" ) ) if [ "${COMPREPLY[*]}" = "container:" ]; then __docker_nospace fi ;; esac return ;; --pull) COMPREPLY=( $( compgen -W 'always missing never' -- "$cur" ) ) return ;; --runtime) __docker_complete_runtimes return ;; --security-opt) COMPREPLY=( $( compgen -W "apparmor= label= no-new-privileges seccomp= systempaths=unconfined" -- "$cur") ) if [[ ${COMPREPLY[*]} = *= ]] ; then __docker_nospace fi return ;; --stop-signal) __docker_complete_signals return ;; --storage-opt) COMPREPLY=( $( compgen -W "size" -S = -- "$cur") ) __docker_nospace return ;; --ulimit) __docker_complete_ulimits return ;; --user|-u) __docker_complete_user_group return ;; --userns) COMPREPLY=( $( compgen -W "host" -- "$cur" ) ) return ;; --volume-driver) __docker_complete_plugins_bundled --type Volume return ;; --volumes-from) __docker_complete_containers_all return ;; $(__docker_to_extglob "$options_with_args") ) return ;; esac case "$cur" in -*) COMPREPLY=( $( compgen -W "$all_options" -- "$cur" ) ) ;; *) local counter=$( __docker_pos_first_nonflag "$( __docker_to_alternatives "$options_with_args" )" ) if [ "$cword" -eq "$counter" ]; then __docker_complete_images --repo --tag --id fi ;; esac } function _docker_container_start { __docker_complete_detach_keys && return case "$prev" in --checkpoint) if __docker_server_is_experimental ; then return fi ;; --checkpoint-dir) if __docker_server_is_experimental ; then _filedir -d return fi ;; esac case "$cur" in -*) local options="--attach -a --detach-keys --help --interactive -i" __docker_server_is_experimental && options+=" --checkpoint --checkpoint-dir" COMPREPLY=( $( compgen -W "$options" -- "$cur" ) ) ;; *) __docker_complete_containers_stopped ;; esac } function _docker_container_stats { case "$prev" in --format) return ;; esac case "$cur" in -*) COMPREPLY=( $( compgen -W "--all -a --format --help --no-stream --no-trunc" -- "$cur" ) ) ;; *) __docker_complete_containers_running ;; esac } function _docker_container_stop { case "$prev" in --time|-t) return ;; esac case "$cur" in -*) COMPREPLY=( $( compgen -W "--help --time -t" -- "$cur" ) ) ;; *) __docker_complete_containers_stoppable ;; esac } function _docker_container_top { case "$cur" in -*) COMPREPLY=( $( compgen -W "--help" -- "$cur" ) ) ;; *) local counter=$(__docker_pos_first_nonflag) if [ "$cword" -eq "$counter" ]; then __docker_complete_containers_running fi ;; esac } function _docker_container_unpause { case "$cur" in -*) COMPREPLY=( $( compgen -W "--help" -- "$cur" ) ) ;; *) local counter=$(__docker_pos_first_nonflag) if [ "$cword" -eq "$counter" ]; then __docker_complete_containers_unpauseable fi ;; esac } function _docker_container_update { local options_with_args=" --blkio-weight --cpu-period --cpu-quota --cpu-rt-period --cpu-rt-runtime --cpus --cpuset-cpus --cpuset-mems --cpu-shares -c --kernel-memory --memory -m --memory-reservation --memory-swap --pids-limit --restart " local boolean_options=" --help " local all_options="$options_with_args $boolean_options" __docker_complete_restart && return case "$prev" in $(__docker_to_extglob "$options_with_args") ) return ;; esac case "$cur" in -*) COMPREPLY=( $( compgen -W "$all_options" -- "$cur" ) ) ;; *) __docker_complete_containers_all ;; esac } function _docker_container_wait { case "$cur" in -*) COMPREPLY=( $( compgen -W "--help" -- "$cur" ) ) ;; *) __docker_complete_containers_all ;; esac } function _docker_context { local subcommands=" create export import inspect ls rm update use " local aliases=" list remove " __docker_subcommands "$subcommands $aliases" && return case "$cur" in -*) COMPREPLY=( $( compgen -W "--help" -- "$cur" ) ) ;; *) COMPREPLY=( $( compgen -W "$subcommands" -- "$cur" ) ) ;; esac } function _docker_context_create { case "$prev" in --description|--docker) return ;; --from) __docker_complete_contexts return ;; esac case "$cur" in -*) COMPREPLY=( $( compgen -W "--description --docker --from --help" -- "$cur" ) ) ;; esac } function _docker_context_export { case "$cur" in -*) COMPREPLY=( $( compgen -W "--help" -- "$cur" ) ) ;; *) local counter=$(__docker_pos_first_nonflag) if [ "$cword" -eq "$counter" ]; then __docker_complete_contexts elif [ "$cword" -eq "$((counter + 1))" ]; then _filedir fi ;; esac } function _docker_context_import { case "$cur" in -*) COMPREPLY=( $( compgen -W "--help" -- "$cur" ) ) ;; *) local counter=$(__docker_pos_first_nonflag) if [ "$cword" -eq "$counter" ]; then : elif [ "$cword" -eq "$((counter + 1))" ]; then _filedir fi ;; esac } function _docker_context_inspect { case "$prev" in --format|-f) return ;; esac case "$cur" in -*) COMPREPLY=( $( compgen -W "--format -f --help" -- "$cur" ) ) ;; *) __docker_complete_contexts ;; esac } function _docker_context_list { _docker_context_ls } function _docker_context_ls { case "$prev" in --format|-f) return ;; esac case "$cur" in -*) COMPREPLY=( $( compgen -W "--format -f --help --quiet -q" -- "$cur" ) ) ;; esac } function _docker_context_remove { _docker_context_rm } function _docker_context_rm { case "$cur" in -*) COMPREPLY=( $( compgen -W "--force -f --help" -- "$cur" ) ) ;; *) __docker_complete_contexts ;; esac } function _docker_context_update { case "$prev" in --description|--docker) return ;; esac case "$cur" in -*) COMPREPLY=( $( compgen -W "--description --docker --help" -- "$cur" ) ) ;; *) local counter=$(__docker_pos_first_nonflag) if [ "$cword" -eq "$counter" ]; then __docker_complete_contexts fi ;; esac } function _docker_context_use { case "$cur" in -*) COMPREPLY=( $( compgen -W "--help" -- "$cur" ) ) ;; *) local counter=$(__docker_pos_first_nonflag) if [ "$cword" -eq "$counter" ]; then __docker_complete_contexts --add default fi ;; esac } function _docker_commit { _docker_container_commit } function _docker_cp { _docker_container_cp } function _docker_create { _docker_container_create } function _docker_daemon { local boolean_options=" $global_boolean_options --experimental --help --icc=false --init --ip-forward=false --ip-masq=false --iptables=false --ip6tables --ipv6 --live-restore --no-new-privileges --raw-logs --selinux-enabled --userland-proxy=false --validate --version -v " local options_with_args=" $global_options_with_args --add-runtime --allow-nondistributable-artifacts --api-cors-header --authorization-plugin --bip --bridge -b --cgroup-parent --config-file --containerd --containerd-namespace --containerd-plugins-namespace --cpu-rt-period --cpu-rt-runtime --data-root --default-address-pool --default-gateway --default-gateway-v6 --default-runtime --default-shm-size --default-ulimit --dns --dns-search --dns-opt --exec-opt --exec-root --fixed-cidr --fixed-cidr-v6 --group -G --init-path --insecure-registry --ip --label --log-driver --log-opt --max-concurrent-downloads --max-concurrent-uploads --max-download-attempts --metrics-addr --mtu --network-control-plane-mtu --node-generic-resource --oom-score-adjust --pidfile -p --registry-mirror --seccomp-profile --shutdown-timeout --storage-driver -s --storage-opt --swarm-default-advertise-addr --userland-proxy-path --userns-remap " __docker_complete_log_driver_options && return local key=$(__docker_map_key_of_current_option '--storage-opt') case "$key" in dm.blkdiscard|dm.override_udev_sync_check|dm.use_deferred_removal|dm.use_deferred_deletion) COMPREPLY=( $( compgen -W "false true" -- "${cur##*=}" ) ) return ;; dm.directlvm_device|dm.thinpooldev) cur=${cur##*=} _filedir return ;; dm.fs) COMPREPLY=( $( compgen -W "ext4 xfs" -- "${cur##*=}" ) ) return ;; dm.libdm_log_level) COMPREPLY=( $( compgen -W "2 3 4 5 6 7" -- "${cur##*=}" ) ) return ;; esac case "$prev" in --authorization-plugin) __docker_complete_plugins_bundled --type Authorization return ;; --config-file|--containerd|--init-path|--pidfile|-p|--tlscacert|--tlscert|--tlskey|--userland-proxy-path) _filedir return ;; --default-ulimit) __docker_complete_ulimits return ;; --exec-root|--data-root) _filedir -d return ;; --log-driver) __docker_complete_log_drivers return ;; --storage-driver|-s) COMPREPLY=( $( compgen -W "btrfs overlay2 vfs zfs" -- "$(echo "$cur" | tr '[:upper:]' '[:lower:]')" ) ) return ;; --storage-opt) local btrfs_options="btrfs.min_space" local overlay2_options="overlay2.size" local zfs_options="zfs.fsname" local all_options="$btrfs_options $overlay2_options $zfs_options" case $(__docker_value_of_option '--storage-driver|-s') in '') COMPREPLY=( $( compgen -W "$all_options" -S = -- "$cur" ) ) ;; btrfs) COMPREPLY=( $( compgen -W "$btrfs_options" -S = -- "$cur" ) ) ;; overlay2) COMPREPLY=( $( compgen -W "$overlay2_options" -S = -- "$cur" ) ) ;; zfs) COMPREPLY=( $( compgen -W "$zfs_options" -S = -- "$cur" ) ) ;; *) return ;; esac __docker_nospace return ;; --log-level|-l) __docker_complete_log_levels return ;; --log-opt) __docker_complete_log_options return ;; --metrics-addr) __docker_complete_local_ips __docker_append_to_completions ":" __docker_nospace return ;; --seccomp-profile) _filedir json return ;; --swarm-default-advertise-addr) __docker_complete_local_interfaces return ;; --userns-remap) __docker_complete_user_group return ;; $(__docker_to_extglob "$options_with_args") ) return ;; esac case "$cur" in -*) COMPREPLY=( $( compgen -W "$boolean_options $options_with_args" -- "$cur" ) ) ;; esac } function _docker_diff { _docker_container_diff } function _docker_events { _docker_system_events } function _docker_exec { _docker_container_exec } function _docker_export { _docker_container_export } function _docker_help { local counter=$(__docker_pos_first_nonflag) if [ "$cword" -eq "$counter" ]; then COMPREPLY=( $( compgen -W "${commands[*]}" -- "$cur" ) ) fi } function _docker_history { _docker_image_history } function _docker_image { local subcommands=" build history import inspect load ls prune pull push rm save tag " local aliases=" images list remove rmi " __docker_subcommands "$subcommands $aliases" && return case "$cur" in -*) COMPREPLY=( $( compgen -W "--help" -- "$cur" ) ) ;; *) COMPREPLY=( $( compgen -W "$subcommands" -- "$cur" ) ) ;; esac } function _docker_image_build { local options_with_args=" --add-host --build-arg --cache-from --cgroup-parent --cpuset-cpus --cpuset-mems --cpu-shares -c --cpu-period --cpu-quota --file -f --iidfile --label --memory -m --memory-swap --network --platform --shm-size --tag -t --target --ulimit " __docker_server_os_is windows && options_with_args+=" --isolation " local boolean_options=" --disable-content-trust=false --force-rm --help --no-cache --pull --quiet -q --rm " if __docker_server_is_experimental ; then boolean_options+=" --squash " fi if [ "${DOCKER_BUILDKIT-}" = "1" ] ; then options_with_args+=" --output -o --progress --secret --ssh " else boolean_options+=" --compress " fi local all_options="$options_with_args $boolean_options" case "$prev" in --add-host) case "$cur" in *:) __docker_complete_resolved_hostname return ;; esac ;; --build-arg) COMPREPLY=( $( compgen -e -- "$cur" ) ) __docker_nospace return ;; --cache-from) __docker_complete_images --repo --tag --id return ;; --file|-f|--iidfile) _filedir return ;; --isolation) if __docker_server_os_is windows ; then __docker_complete_isolation return fi ;; --network) case "$cur" in container:*) __docker_complete_containers_all --cur "${cur#*:}" ;; *) COMPREPLY=( $( compgen -W "$(__docker_plugins_bundled --type Network) $(__docker_networks) container:" -- "$cur") ) if [ "${COMPREPLY[*]}" = "container:" ] ; then __docker_nospace fi ;; esac return ;; --progress) COMPREPLY=( $( compgen -W "auto plain tty" -- "$cur" ) ) return ;; --tag|-t) __docker_complete_images --repo --tag return ;; --target) local context_pos=$( __docker_pos_first_nonflag "$( __docker_to_alternatives "$options_with_args" )" ) local context="${words[$context_pos]}" context="${context:-.}" local file="$( __docker_value_of_option '--file|f' )" local default_file="${context%/}/Dockerfile" local dockerfile="${file:-$default_file}" local targets="$( sed -n 's/^FROM .\+ AS \(.\+\)/\1/p' "$dockerfile" 2>/dev/null )" COMPREPLY=( $( compgen -W "$targets" -- "$cur" ) ) return ;; --ulimit) __docker_complete_ulimits return ;; $(__docker_to_extglob "$options_with_args") ) return ;; esac case "$cur" in -*) COMPREPLY=( $( compgen -W "$all_options" -- "$cur" ) ) ;; *) local counter=$( __docker_pos_first_nonflag "$( __docker_to_alternatives "$options_with_args" )" ) if [ "$cword" -eq "$counter" ]; then _filedir -d fi ;; esac } function _docker_image_history { case "$prev" in --format) return ;; esac case "$cur" in -*) COMPREPLY=( $( compgen -W "--format --help --human=false -H=false --no-trunc --quiet -q" -- "$cur" ) ) ;; *) local counter=$(__docker_pos_first_nonflag '--format') if [ "$cword" -eq "$counter" ]; then __docker_complete_images --force-tag --id fi ;; esac } function _docker_image_images { _docker_image_ls } function _docker_image_import { case "$prev" in --change|-c|--message|-m|--platform) return ;; esac case "$cur" in -*) local options="--change -c --help --message -m --platform" COMPREPLY=( $( compgen -W "$options" -- "$cur" ) ) ;; *) local counter=$(__docker_pos_first_nonflag '--change|-c|--message|-m') if [ "$cword" -eq "$counter" ]; then _filedir return elif [ "$cword" -eq "$((counter + 1))" ]; then __docker_complete_images --repo --tag return fi ;; esac } function _docker_image_inspect { _docker_inspect --type image } function _docker_image_load { case "$prev" in --input|-i|"<") _filedir return ;; esac case "$cur" in -*) COMPREPLY=( $( compgen -W "--help --input -i --quiet -q" -- "$cur" ) ) ;; esac } function _docker_image_list { _docker_image_ls } function _docker_image_ls { local key=$(__docker_map_key_of_current_option '--filter|-f') case "$key" in before|since) __docker_complete_images --cur "${cur##*=}" --force-tag --id return ;; dangling) COMPREPLY=( $( compgen -W "false true" -- "${cur##*=}" ) ) return ;; label) return ;; reference) __docker_complete_images --cur "${cur##*=}" --repo --tag return ;; esac case "$prev" in --filter|-f) COMPREPLY=( $( compgen -S = -W "before dangling label reference since" -- "$cur" ) ) __docker_nospace return ;; --format) return ;; esac case "$cur" in -*) COMPREPLY=( $( compgen -W "--all -a --digests --filter -f --format --help --no-trunc --quiet -q" -- "$cur" ) ) ;; =) return ;; *) __docker_complete_images --repo --tag ;; esac } function _docker_image_prune { case "$prev" in --filter) COMPREPLY=( $( compgen -W "label label! until" -S = -- "$cur" ) ) __docker_nospace return ;; esac case "$cur" in -*) COMPREPLY=( $( compgen -W "--all -a --force -f --filter --help" -- "$cur" ) ) ;; esac } function _docker_image_pull { case "$prev" in --platform) return ;; esac case "$cur" in -*) local options="--all-tags -a --disable-content-trust=false --help --platform --quiet -q" COMPREPLY=( $( compgen -W "$options" -- "$cur" ) ) ;; *) local counter=$(__docker_pos_first_nonflag --platform) if [ "$cword" -eq "$counter" ]; then for arg in "${COMP_WORDS[@]}"; do case "$arg" in --all-tags|-a) __docker_complete_images --repo return ;; esac done __docker_complete_images --repo --tag fi ;; esac } function _docker_image_push { case "$cur" in -*) COMPREPLY=( $( compgen -W "--all-tags -a --disable-content-trust=false --help --quiet -q" -- "$cur" ) ) ;; *) local counter=$(__docker_pos_first_nonflag) if [ "$cword" -eq "$counter" ]; then __docker_complete_images --repo --tag fi ;; esac } function _docker_image_remove { _docker_image_rm } function _docker_image_rm { case "$cur" in -*) COMPREPLY=( $( compgen -W "--force -f --help --no-prune" -- "$cur" ) ) ;; *) __docker_complete_images --force-tag --id ;; esac } function _docker_image_rmi { _docker_image_rm } function _docker_image_save { case "$prev" in --output|-o|">") _filedir return ;; esac case "$cur" in -*) COMPREPLY=( $( compgen -W "--help --output -o" -- "$cur" ) ) ;; *) __docker_complete_images --repo --tag --id ;; esac } function _docker_image_tag { case "$cur" in -*) COMPREPLY=( $( compgen -W "--help" -- "$cur" ) ) ;; *) local counter=$(__docker_pos_first_nonflag) if [ "$cword" -eq "$counter" ]; then __docker_complete_images --force-tag --id return elif [ "$cword" -eq "$((counter + 1))" ]; then __docker_complete_images --repo --tag return fi ;; esac } function _docker_images { _docker_image_ls } function _docker_import { _docker_image_import } function _docker_info { _docker_system_info } function _docker_inspect { local preselected_type local type if [ "${1-}" = "--type" ] ; then preselected_type=yes type="$2" else type=$(__docker_value_of_option --type) fi case "$prev" in --format|-f) return ;; --type) if [ -z "$preselected_type" ] ; then COMPREPLY=( $( compgen -W "container image network node plugin secret service volume" -- "$cur" ) ) return fi ;; esac case "$cur" in -*) local options="--format -f --help --size -s" if [ -z "$preselected_type" ] ; then options+=" --type" fi COMPREPLY=( $( compgen -W "$options" -- "$cur" ) ) ;; *) case "$type" in '') COMPREPLY=( $( compgen -W " $(__docker_containers --all) $(__docker_images --force-tag --id) $(__docker_networks) $(__docker_nodes) $(__docker_plugins_installed) $(__docker_secrets) $(__docker_services) $(__docker_volumes) " -- "$cur" ) ) __ltrim_colon_completions "$cur" ;; container) __docker_complete_containers_all ;; image) __docker_complete_images --force-tag --id ;; network) __docker_complete_networks ;; node) __docker_complete_nodes ;; plugin) __docker_complete_plugins_installed ;; secret) __docker_complete_secrets ;; service) __docker_complete_services ;; volume) __docker_complete_volumes ;; esac esac } function _docker_kill { _docker_container_kill } function _docker_load { _docker_image_load } function _docker_login { case "$prev" in --password|-p|--username|-u) return ;; esac case "$cur" in -*) COMPREPLY=( $( compgen -W "--help --password -p --password-stdin --username -u" -- "$cur" ) ) ;; esac } function _docker_logout { case "$cur" in -*) COMPREPLY=( $( compgen -W "--help" -- "$cur" ) ) ;; esac } function _docker_logs { _docker_container_logs } function _docker_network_connect { local options_with_args=" --alias --ip --ip6 --link --link-local-ip " local boolean_options=" --help " case "$prev" in --link) case "$cur" in *:*) ;; *) __docker_complete_containers_running COMPREPLY=( $( compgen -W "${COMPREPLY[*]}" -S ':' ) ) __docker_nospace ;; esac return ;; $(__docker_to_extglob "$options_with_args") ) return ;; esac case "$cur" in -*) COMPREPLY=( $( compgen -W "$boolean_options $options_with_args" -- "$cur" ) ) ;; *) local counter=$( __docker_pos_first_nonflag "$( __docker_to_alternatives "$options_with_args" )" ) if [ "$cword" -eq "$counter" ]; then __docker_complete_networks elif [ "$cword" -eq "$((counter + 1))" ]; then __docker_complete_containers_all fi ;; esac } function _docker_network_create { case "$prev" in --aux-address|--gateway|--ip-range|--ipam-opt|--ipv6|--opt|-o|--subnet) return ;; --config-from) __docker_complete_networks return ;; --driver|-d) # remove drivers that allow one instance only, add drivers missing in `docker info` __docker_complete_plugins_bundled --type Network --remove host --remove null --add macvlan return ;; --ipam-driver) COMPREPLY=( $( compgen -W "default" -- "$cur" ) ) return ;; --label) return ;; --scope) COMPREPLY=( $( compgen -W "local swarm" -- "$cur" ) ) return ;; esac case "$cur" in -*) COMPREPLY=( $( compgen -W "--attachable --aux-address --config-from --config-only --driver -d --gateway --help --ingress --internal --ip-range --ipam-driver --ipam-opt --ipv6 --label --opt -o --scope --subnet" -- "$cur" ) ) ;; esac } function _docker_network_disconnect { case "$cur" in -*) COMPREPLY=( $( compgen -W "--help" -- "$cur" ) ) ;; *) local counter=$(__docker_pos_first_nonflag) if [ "$cword" -eq "$counter" ]; then __docker_complete_networks elif [ "$cword" -eq "$((counter + 1))" ]; then __docker_complete_containers_in_network "$prev" fi ;; esac } function _docker_network_inspect { case "$prev" in --format|-f) return ;; esac case "$cur" in -*) COMPREPLY=( $( compgen -W "--format -f --help --verbose" -- "$cur" ) ) ;; *) __docker_complete_networks esac } function _docker_network_ls { local key=$(__docker_map_key_of_current_option '--filter|-f') case "$key" in dangling) COMPREPLY=( $( compgen -W "false true" -- "${cur##*=}" ) ) return ;; driver) __docker_complete_plugins_bundled --cur "${cur##*=}" --type Network --add macvlan return ;; id) __docker_complete_networks --cur "${cur##*=}" --id return ;; name) __docker_complete_networks --cur "${cur##*=}" --name return ;; scope) COMPREPLY=( $( compgen -W "global local swarm" -- "${cur##*=}" ) ) return ;; type) COMPREPLY=( $( compgen -W "builtin custom" -- "${cur##*=}" ) ) return ;; esac case "$prev" in --filter|-f) COMPREPLY=( $( compgen -S = -W "dangling driver id label name scope type" -- "$cur" ) ) __docker_nospace return ;; --format) return ;; esac case "$cur" in -*) COMPREPLY=( $( compgen -W "--filter -f --format --help --no-trunc --quiet -q" -- "$cur" ) ) ;; esac } function _docker_network_prune { case "$prev" in --filter) COMPREPLY=( $( compgen -W "label label! until" -S = -- "$cur" ) ) __docker_nospace return ;; esac case "$cur" in -*) COMPREPLY=( $( compgen -W "--force -f --filter --help" -- "$cur" ) ) ;; esac } function _docker_network_rm { case "$cur" in -*) COMPREPLY=( $( compgen -W "--force -f --help" -- "$cur" ) ) ;; *) __docker_complete_networks --filter type=custom esac } function _docker_network { local subcommands=" connect create disconnect inspect ls prune rm " local aliases=" list remove " __docker_subcommands "$subcommands $aliases" && return case "$cur" in -*) COMPREPLY=( $( compgen -W "--help" -- "$cur" ) ) ;; *) COMPREPLY=( $( compgen -W "$subcommands" -- "$cur" ) ) ;; esac } function _docker_service { local subcommands=" create inspect logs ls rm rollback scale ps update " local aliases=" list remove " __docker_subcommands "$subcommands $aliases" && return case "$cur" in -*) COMPREPLY=( $( compgen -W "--help" -- "$cur" ) ) ;; *) COMPREPLY=( $( compgen -W "$subcommands" -- "$cur" ) ) ;; esac } function _docker_service_create { _docker_service_update_and_create } function _docker_service_inspect { case "$prev" in --format|-f) return ;; esac case "$cur" in -*) COMPREPLY=( $( compgen -W "--format -f --help --pretty" -- "$cur" ) ) ;; *) __docker_complete_services esac } function _docker_service_logs { case "$prev" in --since|--tail|-n) return ;; esac case "$cur" in -*) COMPREPLY=( $( compgen -W "--details --follow -f --help --no-resolve --no-task-ids --no-trunc --raw --since --tail -n --timestamps -t" -- "$cur" ) ) ;; *) local counter=$(__docker_pos_first_nonflag '--since|--tail|-n') if [ "$cword" -eq "$counter" ]; then __docker_complete_services_and_tasks fi ;; esac } function _docker_service_list { _docker_service_ls } function _docker_service_ls { local key=$(__docker_map_key_of_current_option '--filter|-f') case "$key" in id) __docker_complete_services --cur "${cur##*=}" --id return ;; mode) COMPREPLY=( $( compgen -W "global global-job replicated replicated-job" -- "${cur##*=}" ) ) return ;; name) __docker_complete_services --cur "${cur##*=}" --name return ;; esac case "$prev" in --filter|-f) COMPREPLY=( $( compgen -W "id label mode name" -S = -- "$cur" ) ) __docker_nospace return ;; --format) return ;; esac case "$cur" in -*) COMPREPLY=( $( compgen -W "--filter -f --format --help --quiet -q" -- "$cur" ) ) ;; esac } function _docker_service_remove { _docker_service_rm } function _docker_service_rm { case "$cur" in -*) COMPREPLY=( $( compgen -W "--help" -- "$cur" ) ) ;; *) __docker_complete_services esac } function _docker_service_rollback { case "$cur" in -*) COMPREPLY=( $( compgen -W "--detach -d --help --quit -q" -- "$cur" ) ) ;; *) local counter=$( __docker_pos_first_nonflag ) if [ "$cword" -eq "$counter" ]; then __docker_complete_services fi ;; esac } function _docker_service_scale { case "$cur" in -*) COMPREPLY=( $( compgen -W "--detach -d --help" -- "$cur" ) ) ;; *) __docker_complete_services __docker_append_to_completions "=" __docker_nospace ;; esac } function _docker_service_ps { local key=$(__docker_map_key_of_current_option '--filter|-f') case "$key" in desired-state) COMPREPLY=( $( compgen -W "accepted running shutdown" -- "${cur##*=}" ) ) return ;; name) __docker_complete_services --cur "${cur##*=}" --name return ;; node) __docker_complete_nodes --cur "${cur##*=}" --add self return ;; esac case "$prev" in --filter|-f) COMPREPLY=( $( compgen -W "desired-state id name node" -S = -- "$cur" ) ) __docker_nospace return ;; --format) return ;; esac case "$cur" in -*) COMPREPLY=( $( compgen -W "--filter -f --format --help --no-resolve --no-trunc --quiet -q" -- "$cur" ) ) ;; *) __docker_complete_services ;; esac } function _docker_service_update { _docker_service_update_and_create } # _docker_service_update_and_create is the combined completion for `docker service create` # and `docker service update` function _docker_service_update_and_create { local options_with_args=" --cap-add --cap-drop --endpoint-mode --entrypoint --health-cmd --health-interval --health-retries --health-start-period --health-timeout --hostname --isolation --limit-cpu --limit-memory --limit-pids --log-driver --log-opt --max-replicas --replicas --replicas-max-per-node --reserve-cpu --reserve-memory --restart-condition --restart-delay --restart-max-attempts --restart-window --rollback-delay --rollback-failure-action --rollback-max-failure-ratio --rollback-monitor --rollback-order --rollback-parallelism --stop-grace-period --stop-signal --update-delay --update-failure-action --update-max-failure-ratio --update-monitor --update-order --update-parallelism --user -u --workdir -w " __docker_server_os_is windows && options_with_args+=" --credential-spec " local boolean_options=" --detach -d --help --init --no-healthcheck --no-resolve-image --read-only --tty -t --with-registry-auth " __docker_complete_log_driver_options && return if [ "$subcommand" = "create" ] ; then options_with_args="$options_with_args --config --constraint --container-label --dns --dns-option --dns-search --env -e --env-file --generic-resource --group --host --label -l --mode --mount --name --network --placement-pref --publish -p --secret --sysctl --ulimit " case "$prev" in --env-file) _filedir return ;; --mode) COMPREPLY=( $( compgen -W "global global-job replicated replicated-job" -- "$cur" ) ) return ;; esac fi if [ "$subcommand" = "update" ] ; then options_with_args="$options_with_args --args --config-add --config-rm --constraint-add --constraint-rm --container-label-add --container-label-rm --dns-add --dns-option-add --dns-option-rm --dns-rm --dns-search-add --dns-search-rm --env-add --env-rm --generic-resource-add --generic-resource-rm --group-add --group-rm --host-add --host-rm --image --label-add --label-rm --mount-add --mount-rm --network-add --network-rm --placement-pref-add --placement-pref-rm --publish-add --publish-rm --rollback --secret-add --secret-rm --sysctl-add --sysctl-rm --ulimit-add --ulimit-rm " boolean_options="$boolean_options --force " case "$prev" in --env-rm) COMPREPLY=( $( compgen -e -- "$cur" ) ) return ;; --image) __docker_complete_images --repo --tag --id return ;; esac fi local strategy=$(__docker_map_key_of_current_option '--placement-pref|--placement-pref-add|--placement-pref-rm') case "$strategy" in spread) COMPREPLY=( $( compgen -W "engine.labels node.labels" -S . -- "${cur##*=}" ) ) __docker_nospace return ;; esac case "$prev" in --cap-add) __docker_complete_capabilities_addable return ;; --cap-drop) __docker_complete_capabilities_droppable return ;; --config|--config-add|--config-rm) __docker_complete_configs return ;; --endpoint-mode) COMPREPLY=( $( compgen -W "dnsrr vip" -- "$cur" ) ) return ;; --env|-e|--env-add) # we do not append a "=" here because "-e VARNAME" is legal systax, too COMPREPLY=( $( compgen -e -- "$cur" ) ) __docker_nospace return ;; --group|--group-add|--group-rm) COMPREPLY=( $(compgen -g -- "$cur") ) return ;; --host|--host-add|--host-rm) case "$cur" in *:) __docker_complete_resolved_hostname return ;; esac ;; --isolation) __docker_complete_isolation return ;; --log-driver) __docker_complete_log_drivers return ;; --log-opt) __docker_complete_log_options return ;; --network|--network-add|--network-rm) __docker_complete_networks return ;; --placement-pref|--placement-pref-add|--placement-pref-rm) COMPREPLY=( $( compgen -W "spread" -S = -- "$cur" ) ) __docker_nospace return ;; --restart-condition) COMPREPLY=( $( compgen -W "any none on-failure" -- "$cur" ) ) return ;; --rollback-failure-action) COMPREPLY=( $( compgen -W "continue pause" -- "$cur" ) ) return ;; --secret|--secret-add|--secret-rm) __docker_complete_secrets return ;; --stop-signal) __docker_complete_signals return ;; --update-failure-action) COMPREPLY=( $( compgen -W "continue pause rollback" -- "$cur" ) ) return ;; --ulimit|--ulimit-add) __docker_complete_ulimits return ;; --ulimit-rm) __docker_complete_ulimits --rm return ;; --update-order|--rollback-order) COMPREPLY=( $( compgen -W "start-first stop-first" -- "$cur" ) ) return ;; --user|-u) __docker_complete_user_group return ;; $(__docker_to_extglob "$options_with_args") ) return ;; esac case "$cur" in -*) COMPREPLY=( $( compgen -W "$boolean_options $options_with_args" -- "$cur" ) ) ;; *) local counter=$( __docker_pos_first_nonflag "$( __docker_to_alternatives "$options_with_args" )" ) if [ "$subcommand" = "update" ] ; then if [ "$cword" -eq "$counter" ]; then __docker_complete_services fi else if [ "$cword" -eq "$counter" ]; then __docker_complete_images --repo --tag --id fi fi ;; esac } function _docker_swarm { local subcommands=" ca init join join-token leave unlock unlock-key update " __docker_subcommands "$subcommands" && return case "$cur" in -*) COMPREPLY=( $( compgen -W "--help" -- "$cur" ) ) ;; *) COMPREPLY=( $( compgen -W "$subcommands" -- "$cur" ) ) ;; esac } function _docker_swarm_ca { case "$prev" in --ca-cert|--ca-key) _filedir return ;; --cert-expiry|--external-ca) return ;; esac case "$cur" in -*) COMPREPLY=( $( compgen -W "--ca-cert --ca-key --cert-expiry --detach -d --external-ca --help --quiet -q --rotate" -- "$cur" ) ) ;; esac } function _docker_swarm_init { case "$prev" in --advertise-addr) if [[ $cur == *: ]] ; then COMPREPLY=( $( compgen -W "2377" -- "${cur##*:}" ) ) else __docker_complete_local_interfaces __docker_nospace fi return ;; --availability) COMPREPLY=( $( compgen -W "active drain pause" -- "$cur" ) ) return ;; --cert-expiry|--data-path-port|--default-addr-pool|--default-addr-pool-mask-length|--dispatcher-heartbeat|--external-ca|--max-snapshots|--snapshot-interval|--task-history-limit ) return ;; --data-path-addr) __docker_complete_local_interfaces return ;; --listen-addr) if [[ $cur == *: ]] ; then COMPREPLY=( $( compgen -W "2377" -- "${cur##*:}" ) ) else __docker_complete_local_interfaces --add 0.0.0.0 __docker_nospace fi return ;; esac case "$cur" in -*) COMPREPLY=( $( compgen -W "--advertise-addr --autolock --availability --cert-expiry --data-path-addr --data-path-port --default-addr-pool --default-addr-pool-mask-length --dispatcher-heartbeat --external-ca --force-new-cluster --help --listen-addr --max-snapshots --snapshot-interval --task-history-limit " -- "$cur" ) ) ;; esac } function _docker_swarm_join { case "$prev" in --advertise-addr) if [[ $cur == *: ]] ; then COMPREPLY=( $( compgen -W "2377" -- "${cur##*:}" ) ) else __docker_complete_local_interfaces __docker_nospace fi return ;; --availability) COMPREPLY=( $( compgen -W "active drain pause" -- "$cur" ) ) return ;; --data-path-addr) __docker_complete_local_interfaces return ;; --listen-addr) if [[ $cur == *: ]] ; then COMPREPLY=( $( compgen -W "2377" -- "${cur##*:}" ) ) else __docker_complete_local_interfaces --add 0.0.0.0 __docker_nospace fi return ;; --token) return ;; esac case "$cur" in -*) COMPREPLY=( $( compgen -W "--advertise-addr --availability --data-path-addr --help --listen-addr --token" -- "$cur" ) ) ;; *:) COMPREPLY=( $( compgen -W "2377" -- "${cur##*:}" ) ) ;; esac } function _docker_swarm_join_token { case "$cur" in -*) COMPREPLY=( $( compgen -W "--help --quiet -q --rotate" -- "$cur" ) ) ;; *) local counter=$( __docker_pos_first_nonflag ) if [ "$cword" -eq "$counter" ]; then COMPREPLY=( $( compgen -W "manager worker" -- "$cur" ) ) fi ;; esac } function _docker_swarm_leave { case "$cur" in -*) COMPREPLY=( $( compgen -W "--force -f --help" -- "$cur" ) ) ;; esac } function _docker_swarm_unlock { case "$cur" in -*) COMPREPLY=( $( compgen -W "--help" -- "$cur" ) ) ;; esac } function _docker_swarm_unlock_key { case "$cur" in -*) COMPREPLY=( $( compgen -W "--help --quiet -q --rotate" -- "$cur" ) ) ;; esac } function _docker_swarm_update { case "$prev" in --cert-expiry|--dispatcher-heartbeat|--external-ca|--max-snapshots|--snapshot-interval|--task-history-limit) return ;; esac case "$cur" in -*) COMPREPLY=( $( compgen -W "--autolock --cert-expiry --dispatcher-heartbeat --external-ca --help --max-snapshots --snapshot-interval --task-history-limit" -- "$cur" ) ) ;; esac } function _docker_manifest { local subcommands=" annotate create inspect push rm " __docker_subcommands "$subcommands" && return case "$cur" in -*) COMPREPLY=( $( compgen -W "--help" -- "$cur" ) ) ;; *) COMPREPLY=( $( compgen -W "$subcommands" -- "$cur" ) ) ;; esac } function _docker_manifest_annotate { case "$prev" in --arch) COMPREPLY=( $( compgen -W " 386 amd64 arm arm64 mips64 mips64le ppc64le riscv64 s390x" -- "$cur" ) ) return ;; --os) COMPREPLY=( $( compgen -W " darwin dragonfly freebsd linux netbsd openbsd plan9 solaris windows" -- "$cur" ) ) return ;; --os-features|--variant) return ;; esac case "$cur" in -*) COMPREPLY=( $( compgen -W "--arch --help --os --os-features --variant" -- "$cur" ) ) ;; *) local counter=$( __docker_pos_first_nonflag "--arch|--os|--os-features|--variant" ) if [ "$cword" -eq "$counter" ] || [ "$cword" -eq "$((counter + 1))" ]; then __docker_complete_images --force-tag --id fi ;; esac } function _docker_manifest_create { case "$cur" in -*) COMPREPLY=( $( compgen -W "--amend -a --help --insecure" -- "$cur" ) ) ;; *) __docker_complete_images --force-tag --id ;; esac } function _docker_manifest_inspect { case "$cur" in -*) COMPREPLY=( $( compgen -W "--help --insecure --verbose -v" -- "$cur" ) ) ;; *) local counter=$( __docker_pos_first_nonflag ) if [ "$cword" -eq "$counter" ] || [ "$cword" -eq "$((counter + 1))" ]; then __docker_complete_images --force-tag --id fi ;; esac } function _docker_manifest_push { case "$cur" in -*) COMPREPLY=( $( compgen -W "--help --insecure --purge -p" -- "$cur" ) ) ;; *) local counter=$( __docker_pos_first_nonflag ) if [ "$cword" -eq "$counter" ]; then __docker_complete_images --force-tag --id fi ;; esac } function _docker_manifest_rm { case "$cur" in -*) COMPREPLY=( $( compgen -W "--help" -- "$cur" ) ) ;; *) __docker_complete_images --force-tag --id ;; esac } function _docker_node { local subcommands=" demote inspect ls promote rm ps update " local aliases=" list remove " __docker_subcommands "$subcommands $aliases" && return case "$cur" in -*) COMPREPLY=( $( compgen -W "--help" -- "$cur" ) ) ;; *) COMPREPLY=( $( compgen -W "$subcommands" -- "$cur" ) ) ;; esac } function _docker_node_demote { case "$cur" in -*) COMPREPLY=( $( compgen -W "--help" -- "$cur" ) ) ;; *) __docker_complete_nodes --filter role=manager esac } function _docker_node_inspect { case "$prev" in --format|-f) return ;; esac case "$cur" in -*) COMPREPLY=( $( compgen -W "--format -f --help --pretty" -- "$cur" ) ) ;; *) __docker_complete_nodes --add self esac } function _docker_node_list { _docker_node_ls } function _docker_node_ls { local key=$(__docker_map_key_of_current_option '--filter|-f') case "$key" in id) __docker_complete_nodes --cur "${cur##*=}" --id return ;; label|node.label) return ;; membership) COMPREPLY=( $( compgen -W "accepted pending" -- "${cur##*=}" ) ) return ;; name) __docker_complete_nodes --cur "${cur##*=}" --name return ;; role) COMPREPLY=( $( compgen -W "manager worker" -- "${cur##*=}" ) ) return ;; esac case "$prev" in --filter|-f) COMPREPLY=( $( compgen -W "id label membership name node.label role" -S = -- "$cur" ) ) __docker_nospace return ;; --format) return ;; esac case "$cur" in -*) COMPREPLY=( $( compgen -W "--filter -f --format --help --quiet -q" -- "$cur" ) ) ;; esac } function _docker_node_promote { case "$cur" in -*) COMPREPLY=( $( compgen -W "--help" -- "$cur" ) ) ;; *) __docker_complete_nodes --filter role=worker esac } function _docker_node_remove { _docker_node_rm } function _docker_node_rm { case "$cur" in -*) COMPREPLY=( $( compgen -W "--force -f --help" -- "$cur" ) ) ;; *) __docker_complete_nodes esac } function _docker_node_ps { local key=$(__docker_map_key_of_current_option '--filter|-f') case "$key" in desired-state) COMPREPLY=( $( compgen -W "accepted running shutdown" -- "${cur##*=}" ) ) return ;; name) __docker_complete_services --cur "${cur##*=}" --name return ;; esac case "$prev" in --filter|-f) COMPREPLY=( $( compgen -W "desired-state id label name" -S = -- "$cur" ) ) __docker_nospace return ;; --format) return ;; esac case "$cur" in -*) COMPREPLY=( $( compgen -W "--filter -f --format --help --no-resolve --no-trunc --quiet -q" -- "$cur" ) ) ;; *) __docker_complete_nodes --add self ;; esac } function _docker_node_update { case "$prev" in --availability) COMPREPLY=( $( compgen -W "active drain pause" -- "$cur" ) ) return ;; --role) COMPREPLY=( $( compgen -W "manager worker" -- "$cur" ) ) return ;; --label-add|--label-rm) return ;; esac case "$cur" in -*) COMPREPLY=( $( compgen -W "--availability --help --label-add --label-rm --role" -- "$cur" ) ) ;; *) local counter=$(__docker_pos_first_nonflag '--availability|--label-add|--label-rm|--role') if [ "$cword" -eq "$counter" ]; then __docker_complete_nodes fi ;; esac } function _docker_pause { _docker_container_pause } function _docker_plugin { local subcommands=" create disable enable inspect install ls push rm set upgrade " local aliases=" list remove " __docker_subcommands "$subcommands $aliases" && return case "$cur" in -*) COMPREPLY=( $( compgen -W "--help" -- "$cur" ) ) ;; *) COMPREPLY=( $( compgen -W "$subcommands" -- "$cur" ) ) ;; esac } function _docker_plugin_create { case "$cur" in -*) COMPREPLY=( $( compgen -W "--compress --help" -- "$cur" ) ) ;; *) local counter=$(__docker_pos_first_nonflag) if [ "$cword" -eq "$counter" ]; then # reponame return elif [ "$cword" -eq "$((counter + 1))" ]; then _filedir -d fi ;; esac } function _docker_plugin_disable { case "$cur" in -*) COMPREPLY=( $( compgen -W "--force -f --help" -- "$cur" ) ) ;; *) local counter=$(__docker_pos_first_nonflag) if [ "$cword" -eq "$counter" ]; then __docker_complete_plugins_installed --filter enabled=true fi ;; esac } function _docker_plugin_enable { case "$prev" in --timeout) return ;; esac case "$cur" in -*) COMPREPLY=( $( compgen -W "--help --timeout" -- "$cur" ) ) ;; *) local counter=$(__docker_pos_first_nonflag '--timeout') if [ "$cword" -eq "$counter" ]; then __docker_complete_plugins_installed --filter enabled=false fi ;; esac } function _docker_plugin_inspect { case "$prev" in --format|f) return ;; esac case "$cur" in -*) COMPREPLY=( $( compgen -W "--format -f --help" -- "$cur" ) ) ;; *) __docker_complete_plugins_installed ;; esac } function _docker_plugin_install { case "$prev" in --alias) return ;; esac case "$cur" in -*) COMPREPLY=( $( compgen -W "--alias --disable --disable-content-trust=false --grant-all-permissions --help" -- "$cur" ) ) ;; esac } function _docker_plugin_list { _docker_plugin_ls } function _docker_plugin_ls { local key=$(__docker_map_key_of_current_option '--filter|-f') case "$key" in capability) COMPREPLY=( $( compgen -W "authz ipamdriver logdriver metricscollector networkdriver volumedriver" -- "${cur##*=}" ) ) return ;; enabled) COMPREPLY=( $( compgen -W "false true" -- "${cur##*=}" ) ) return ;; esac case "$prev" in --filter|-f) COMPREPLY=( $( compgen -S = -W "capability enabled" -- "$cur" ) ) __docker_nospace return ;; --format) return ;; esac case "$cur" in -*) COMPREPLY=( $( compgen -W "--filter -f --format --help --no-trunc --quiet -q" -- "$cur" ) ) ;; esac } function _docker_plugin_push { case "$cur" in -*) COMPREPLY=( $( compgen -W "--help" -- "$cur" ) ) ;; *) local counter=$(__docker_pos_first_nonflag) if [ "$cword" -eq "$counter" ]; then __docker_complete_plugins_installed fi ;; esac } function _docker_plugin_remove { _docker_plugin_rm } function _docker_plugin_rm { case "$cur" in -*) COMPREPLY=( $( compgen -W "--force -f --help" -- "$cur" ) ) ;; *) __docker_complete_plugins_installed ;; esac } function _docker_plugin_set { case "$cur" in -*) COMPREPLY=( $( compgen -W "--help" -- "$cur" ) ) ;; *) local counter=$(__docker_pos_first_nonflag) if [ "$cword" -eq "$counter" ]; then __docker_complete_plugins_installed fi ;; esac } function _docker_plugin_upgrade { case "$cur" in -*) COMPREPLY=( $( compgen -W "--disable-content-trust --grant-all-permissions --help --skip-remote-check" -- "$cur" ) ) ;; *) local counter=$(__docker_pos_first_nonflag) if [ "$cword" -eq "$counter" ]; then __docker_complete_plugins_installed __ltrim_colon_completions "$cur" elif [ "$cword" -eq "$((counter + 1))" ]; then local plugin_images="$(__docker_plugins_installed)" COMPREPLY=( $(compgen -S : -W "${plugin_images%:*}" -- "$cur") ) __docker_nospace fi ;; esac } function _docker_port { _docker_container_port } function _docker_ps { _docker_container_ls } function _docker_pull { _docker_image_pull } function _docker_push { _docker_image_push } function _docker_rename { _docker_container_rename } function _docker_restart { _docker_container_restart } function _docker_rm { _docker_container_rm } function _docker_rmi { _docker_image_rm } function _docker_run { _docker_container_run } function _docker_save { _docker_image_save } function _docker_secret { local subcommands=" create inspect ls rm " local aliases=" list remove " __docker_subcommands "$subcommands $aliases" && return case "$cur" in -*) COMPREPLY=( $( compgen -W "--help" -- "$cur" ) ) ;; *) COMPREPLY=( $( compgen -W "$subcommands" -- "$cur" ) ) ;; esac } function _docker_secret_create { case "$prev" in --driver|-d|--label|-l) return ;; --template-driver) COMPREPLY=( $( compgen -W "golang" -- "$cur" ) ) return ;; esac case "$cur" in -*) COMPREPLY=( $( compgen -W "--driver -d --help --label -l --template-driver" -- "$cur" ) ) ;; *) local counter=$(__docker_pos_first_nonflag '--driver|-d|--label|-l|--template-driver') if [ "$cword" -eq "$((counter + 1))" ]; then _filedir fi ;; esac } function _docker_secret_inspect { case "$prev" in --format|-f) return ;; esac case "$cur" in -*) COMPREPLY=( $( compgen -W "--format -f --help --pretty" -- "$cur" ) ) ;; *) __docker_complete_secrets ;; esac } function _docker_secret_list { _docker_secret_ls } function _docker_secret_ls { local key=$(__docker_map_key_of_current_option '--filter|-f') case "$key" in id) __docker_complete_secrets --cur "${cur##*=}" --id return ;; name) __docker_complete_secrets --cur "${cur##*=}" --name return ;; esac case "$prev" in --filter|-f) COMPREPLY=( $( compgen -S = -W "id label name" -- "$cur" ) ) __docker_nospace return ;; --format) return ;; esac case "$cur" in -*) COMPREPLY=( $( compgen -W "--format --filter -f --help --quiet -q" -- "$cur" ) ) ;; esac } function _docker_secret_remove { _docker_secret_rm } function _docker_secret_rm { case "$cur" in -*) COMPREPLY=( $( compgen -W "--help" -- "$cur" ) ) ;; *) __docker_complete_secrets ;; esac } function _docker_search { local key=$(__docker_map_key_of_current_option '--filter|-f') case "$key" in is-automated) COMPREPLY=( $( compgen -W "false true" -- "${cur##*=}" ) ) return ;; is-official) COMPREPLY=( $( compgen -W "false true" -- "${cur##*=}" ) ) return ;; esac case "$prev" in --filter|-f) COMPREPLY=( $( compgen -S = -W "is-automated is-official stars" -- "$cur" ) ) __docker_nospace return ;; --format|--limit) return ;; esac case "$cur" in -*) COMPREPLY=( $( compgen -W "--filter -f --format --help --limit --no-trunc" -- "$cur" ) ) ;; esac } function _docker_stack { local subcommands=" config deploy ls ps rm services " local aliases=" down list remove up " __docker_subcommands "$subcommands $aliases" && return case "$cur" in -*) COMPREPLY=( $( compgen -W "--help" -- "$cur" ) ) ;; *) COMPREPLY=( $( compgen -W "$subcommands" -- "$cur" ) ) ;; esac } function _docker_stack_config { case "$prev" in --compose-file|-c) _filedir yml return ;; esac case "$cur" in -*) COMPREPLY=( $( compgen -W "--compose-file -c --help --skip-interpolation" -- "$cur" ) ) ;; esac } function _docker_stack_deploy { case "$prev" in --compose-file|-c) _filedir yml return ;; --resolve-image) COMPREPLY=( $( compgen -W "always changed never" -- "$cur" ) ) return ;; esac case "$cur" in -*) COMPREPLY=( $( compgen -W "--compose-file -c --help --prune --resolve-image --with-registry-auth" -- "$cur" ) ) ;; *) local counter=$(__docker_pos_first_nonflag '--compose-file|-c|--resolve-image') if [ "$cword" -eq "$counter" ]; then __docker_complete_stacks fi ;; esac } function _docker_stack_down { _docker_stack_rm } function _docker_stack_list { _docker_stack_ls } function _docker_stack_ls { case "$prev" in --format) return ;; esac case "$cur" in -*) COMPREPLY=( $( compgen -W "--format --help" -- "$cur" ) ) ;; esac } function _docker_stack_ps { local key=$(__docker_map_key_of_current_option '--filter|-f') case "$key" in desired-state) COMPREPLY=( $( compgen -W "accepted running shutdown" -- "${cur##*=}" ) ) return ;; id) __docker_complete_stacks --cur "${cur##*=}" --id return ;; name) __docker_complete_stacks --cur "${cur##*=}" --name return ;; esac case "$prev" in --filter|-f) COMPREPLY=( $( compgen -S = -W "id name desired-state" -- "$cur" ) ) __docker_nospace return ;; --format) return ;; esac case "$cur" in -*) COMPREPLY=( $( compgen -W "--filter -f --format --help --no-resolve --no-trunc --quiet -q" -- "$cur" ) ) ;; *) local counter=$(__docker_pos_first_nonflag '--filter|-f|--format') if [ "$cword" -eq "$counter" ]; then __docker_complete_stacks fi ;; esac } function _docker_stack_remove { _docker_stack_rm } function _docker_stack_rm { case "$cur" in -*) COMPREPLY=( $( compgen -W "--help" -- "$cur" ) ) ;; *) __docker_complete_stacks ;; esac } function _docker_stack_services { local key=$(__docker_map_key_of_current_option '--filter|-f') case "$key" in id) __docker_complete_services --cur "${cur##*=}" --id return ;; label) return ;; name) __docker_complete_services --cur "${cur##*=}" --name return ;; esac case "$prev" in --filter|-f) COMPREPLY=( $( compgen -S = -W "id label name" -- "$cur" ) ) __docker_nospace return ;; --format) return ;; esac case "$cur" in -*) COMPREPLY=( $( compgen -W "--filter -f --format --help --quiet -q" -- "$cur" ) ) ;; *) local counter=$(__docker_pos_first_nonflag '--filter|-f|--format') if [ "$cword" -eq "$counter" ]; then __docker_complete_stacks fi ;; esac } function _docker_stack_up { _docker_stack_deploy } function _docker_start { _docker_container_start } function _docker_stats { _docker_container_stats } function _docker_stop { _docker_container_stop } function _docker_system { local subcommands=" df events info prune " __docker_subcommands "$subcommands" && return case "$cur" in -*) COMPREPLY=( $( compgen -W "--help" -- "$cur" ) ) ;; *) COMPREPLY=( $( compgen -W "$subcommands" -- "$cur" ) ) ;; esac } function _docker_system_df { case "$prev" in --format) return ;; esac case "$cur" in -*) COMPREPLY=( $( compgen -W "--format --help --verbose -v" -- "$cur" ) ) ;; esac } function _docker_system_events { local key=$(__docker_map_key_of_current_option '-f|--filter') case "$key" in container) __docker_complete_containers_all --cur "${cur##*=}" return ;; daemon) local name=$(__docker_q info | sed -n 's/^\(ID\|Name\): //p') COMPREPLY=( $( compgen -W "$name" -- "${cur##*=}" ) ) return ;; event) COMPREPLY=( $( compgen -W " attach commit connect copy create delete destroy detach die disable disconnect enable exec_create exec_detach exec_die exec_start export health_status import install kill load mount oom pause pull push reload remove rename resize restart save start stop tag top unmount unpause untag update " -- "${cur##*=}" ) ) return ;; image) __docker_complete_images --cur "${cur##*=}" --repo --tag return ;; network) __docker_complete_networks --cur "${cur##*=}" return ;; node) __docker_complete_nodes --cur "${cur##*=}" return ;; scope) COMPREPLY=( $( compgen -W "local swarm" -- "${cur##*=}" ) ) return ;; type) COMPREPLY=( $( compgen -W "config container daemon image network node plugin secret service volume" -- "${cur##*=}" ) ) return ;; volume) __docker_complete_volumes --cur "${cur##*=}" return ;; esac case "$prev" in --filter|-f) COMPREPLY=( $( compgen -S = -W "container daemon event image label network node scope type volume" -- "$cur" ) ) __docker_nospace return ;; --since|--until) return ;; esac case "$cur" in -*) COMPREPLY=( $( compgen -W "--filter -f --help --since --until --format" -- "$cur" ) ) ;; esac } function _docker_system_info { case "$prev" in --format|-f) return ;; esac case "$cur" in -*) COMPREPLY=( $( compgen -W "--format -f --help" -- "$cur" ) ) ;; esac } function _docker_system_prune { case "$prev" in --filter) COMPREPLY=( $( compgen -W "label label! until" -S = -- "$cur" ) ) __docker_nospace return ;; esac case "$cur" in -*) COMPREPLY=( $( compgen -W "--all -a --force -f --filter --help --volumes" -- "$cur" ) ) ;; esac } function _docker_tag { _docker_image_tag } function _docker_trust { local subcommands=" inspect revoke sign " __docker_subcommands "$subcommands" && return case "$cur" in -*) COMPREPLY=( $( compgen -W "--help" -- "$cur" ) ) ;; *) COMPREPLY=( $( compgen -W "$subcommands" -- "$cur" ) ) ;; esac } function _docker_trust_inspect { case "$cur" in -*) COMPREPLY=( $( compgen -W "--help --pretty" -- "$cur" ) ) ;; *) local counter=$(__docker_pos_first_nonflag) if [ "$cword" -eq "$counter" ]; then __docker_complete_images --repo --tag fi ;; esac } function _docker_trust_revoke { case "$cur" in -*) COMPREPLY=( $( compgen -W "--help --yes -y" -- "$cur" ) ) ;; *) local counter=$(__docker_pos_first_nonflag) if [ "$cword" -eq "$counter" ]; then __docker_complete_images --repo --tag fi ;; esac } function _docker_trust_sign { case "$cur" in -*) COMPREPLY=( $( compgen -W "--help --local" -- "$cur" ) ) ;; *) local counter=$(__docker_pos_first_nonflag) if [ "$cword" -eq "$counter" ]; then __docker_complete_images --force-tag --id fi ;; esac } function _docker_unpause { _docker_container_unpause } function _docker_update { _docker_container_update } function _docker_top { _docker_container_top } function _docker_version { case "$prev" in --format|-f) return ;; esac case "$cur" in -*) COMPREPLY=( $( compgen -W "--format -f --help" -- "$cur" ) ) ;; esac } function _docker_volume_create { case "$prev" in --driver|-d) __docker_complete_plugins_bundled --type Volume return ;; --label|--opt|-o) return ;; esac case "$cur" in -*) COMPREPLY=( $( compgen -W "--driver -d --help --label --opt -o" -- "$cur" ) ) ;; esac } function _docker_volume_inspect { case "$prev" in --format|-f) return ;; esac case "$cur" in -*) COMPREPLY=( $( compgen -W "--format -f --help" -- "$cur" ) ) ;; *) __docker_complete_volumes ;; esac } function _docker_volume_list { _docker_volume_ls } function _docker_volume_ls { local key=$(__docker_map_key_of_current_option '--filter|-f') case "$key" in dangling) COMPREPLY=( $( compgen -W "true false" -- "${cur##*=}" ) ) return ;; driver) __docker_complete_plugins_bundled --cur "${cur##*=}" --type Volume return ;; name) __docker_complete_volumes --cur "${cur##*=}" return ;; esac case "$prev" in --filter|-f) COMPREPLY=( $( compgen -S = -W "dangling driver label name" -- "$cur" ) ) __docker_nospace return ;; --format) return ;; esac case "$cur" in -*) COMPREPLY=( $( compgen -W "--filter -f --format --help --quiet -q" -- "$cur" ) ) ;; esac } function _docker_volume_prune { case "$prev" in --filter) COMPREPLY=( $( compgen -W "label label!" -S = -- "$cur" ) ) __docker_nospace return ;; esac case "$cur" in -*) COMPREPLY=( $( compgen -W "--all -a --filter --force -f --help" -- "$cur" ) ) ;; esac } function _docker_volume_remove { _docker_volume_rm } function _docker_volume_rm { case "$cur" in -*) COMPREPLY=( $( compgen -W "--force -f --help" -- "$cur" ) ) ;; *) __docker_complete_volumes ;; esac } function _docker_volume { local subcommands=" create inspect ls prune rm " local aliases=" list remove " __docker_subcommands "$subcommands $aliases" && return case "$cur" in -*) COMPREPLY=( $( compgen -W "--help" -- "$cur" ) ) ;; *) COMPREPLY=( $( compgen -W "$subcommands" -- "$cur" ) ) ;; esac } function _docker_wait { _docker_container_wait } function _docker { local previous_extglob_setting=$(shopt -p extglob) shopt -s extglob local management_commands=( builder config container context image manifest network node plugin secret service stack swarm system trust volume ) local top_level_commands=( build login logout run search version ) local legacy_commands=( attach commit cp create diff events exec export history images import info inspect kill load logs pause port ps pull push rename restart rm rmi save start stats stop tag top unpause update wait ) # Create completion functions for all registered plugins local known_plugin_commands=() local plugin_name="" for plugin_path in $(__docker_plugins_path); do plugin_name=$(basename "$plugin_path" | sed 's/ *$//') plugin_name=${plugin_name#docker-} plugin_name=${plugin_name%%.*} eval "_docker_${plugin_name}() { __docker_complete_plugin \"${plugin_path}\"; }" known_plugin_commands+=(${plugin_name}) done local experimental_server_commands=( checkpoint ) local commands=(${management_commands[*]} ${top_level_commands[*]} ${known_plugin_commands[*]}) [ -z "${DOCKER_HIDE_LEGACY_COMMANDS-}" ] && commands+=(${legacy_commands[*]}) # These options are valid as global options for all client commands # and valid as command options for `docker daemon` local global_boolean_options=" --debug -D --tls --tlsverify " local global_options_with_args=" --config --context -c --host -H --log-level -l --tlscacert --tlscert --tlskey " # variables to cache server info, populated on demand for performance reasons local info_fetched server_experimental server_os local host config context COMPREPLY=() local cur prev words cword _get_comp_words_by_ref -n : cur prev words cword local command='docker' command_pos=0 subcommand_pos local counter=1 while [ "$counter" -lt "$cword" ]; do case "${words[$counter]}" in docker) return 0 ;; # save host so that completion can use custom daemon --host|-H) (( counter++ )) host="${words[$counter]}" ;; # save config so that completion can use custom configuration directories --config) (( counter++ )) config="${words[$counter]}" ;; # save context so that completion can use custom daemon --context|-c) (( counter++ )) context="${words[$counter]}" ;; $(__docker_to_extglob "$global_options_with_args") ) (( counter++ )) ;; -*) ;; =) (( counter++ )) ;; *) command="${words[$counter]}" command_pos=$counter break ;; esac (( counter++ )) done local binary="${words[0]}" if [[ $binary == ?(*/)dockerd ]] ; then # for the dockerd binary, we reuse completion of `docker daemon`. # dockerd does not have subcommands and global options. command=daemon command_pos=0 fi local completions_func=_docker_${command//-/_} _omb_util_function_exists "$completions_func" && "$completions_func" eval "$previous_extglob_setting" return 0 } eval "$__docker_previous_extglob_setting" unset __docker_previous_extglob_setting complete -F _docker docker docker.exe dockerd dockerd.exe ================================================ FILE: completions/gem.completion.sh ================================================ #! bash oh-my-bash.module # Completion for gem function _installcomp { if [ -z "$REMOTE_GEMS" ] then REMOTE_GEMS=( $(gem list --remote --no-versions | tr '\n' ' ') ) fi local cur=${COMP_WORDS[COMP_CWORD]} COMPREPLY=( $(compgen -W "${REMOTE_GEMS[*]}" -- $cur) ) } function _uninstallcomp { if [ -z "$LOCAL_GEMS" ] then LOCAL_GEMS=( $(gem list --no-versions | sed 's/\*\*\* LOCAL GEMS \*\*\*//' | tr '\n' ' ') ) fi local cur=${COMP_WORDS[COMP_CWORD]} COMPREPLY=( $(compgen -W "${LOCAL_GEMS[*]}" -- $cur) ) } function _gem { local cur=${COMP_WORDS[COMP_CWORD]} local prev=${COMP_WORDS[COMP_CWORD-1]} case $prev in install) _installcomp return 0 ;; uninstall) _uninstallcomp return 0 ;; esac local commands=(build cert check cleanup contents dependency environment fetch generate_index help install list lock outdated owner pristine push query rdoc search server sources specification stale uninstall unpack update which) COMPREPLY=( $(compgen -W "${commands[*]}" -- $cur) ) } complete -F _gem gem ================================================ FILE: completions/gh.completion.sh ================================================ #! bash oh-my-bash.module # # The current version is based on the following upstream version: # https://github.com/owenthereal/gh/blob/04a7985fa9a1c1d4d63738f4edb7b07d228bdb12/etc/gh.bash_completion.sh #------------------------------------------------------------------------------ # hub tab-completion script for bash. # This script complements the completion script that ships with git. # Check that git tab completion is available if _omb_util_function_exists _git; then # Duplicate and rename the 'list_all_commands' function eval "$(declare -f __git_list_all_commands | \ sed 's/__git_list_all_commands/__git_list_all_commands_without_hub/')" # Wrap the 'list_all_commands' function with extra hub commands function __git_list_all_commands { cat <<-EOF alias pull-request fork create browse compare ci-status release issue update EOF __git_list_all_commands_without_hub } # Ensure cached commands are cleared __git_all_commands="" ########################## # hub command completions ########################## # hub alias [-s] [SHELL] function _git_alias { local i c=2 s=-s sh shells="bash zsh sh ksh csh fish" while [ $c -lt $cword ]; do i="${words[c]}" case "$i" in -s) unset s ;; *) for sh in $shells; do if [ "$sh" = "$i" ]; then unset shells break fi done ;; esac ((c++)) done __gitcomp "$s $shells" } # hub browse [-u] [--|[USER/]REPOSITORY] [SUBPAGE] function _git_browse { local i c=2 u=-u repo subpage local subpages_="commits issues tree wiki pulls branches stargazers contributors network network/ graphs graphs/" local subpages_network="members" local subpages_graphs="commit-activity code-frequency punch-card" while [ $c -lt $cword ]; do i="${words[c]}" case "$i" in -u) unset u ;; *) if [ -z "$repo" ]; then repo=$i else subpage=$i fi ;; esac ((c++)) done if [ -z "$repo" ]; then __gitcomp "$u -- $(__hub_github_repos '\p')" elif [ -z "$subpage" ]; then case "$cur" in */*) local pfx="${cur%/*}" cur_="${cur#*/}" local subpages_var="subpages_$pfx" __gitcomp "${!subpages_var}" "$pfx/" "$cur_" ;; *) __gitcomp "$u ${subpages_}" ;; esac else __gitcomp "$u" fi } # hub compare [-u] [USER[/REPOSITORY]] [[START...]END] function _git_compare { local i c=$((cword - 1)) u=-u user remote owner repo arg_repo rev while [ $c -gt 1 ]; do i="${words[c]}" case "$i" in -u) unset u ;; *) if [ -z "$rev" ]; then # Even though the logic below is able to complete both user/repo # and revision in the right place, when there is only one argument # (other than -u) in the command, that argument will be taken as # revision. For example: # $ hub compare -u upstream # > https://github.com/USER/REPO/compare/upstream if __hub_github_repos '\p' | grep -Eqx "^$i(/[^/]+)?"; then arg_repo=$i else rev=$i fi elif [ -z "$arg_repo" ]; then arg_repo=$i fi ;; esac ((c--)) done # Here we want to find out the git remote name of user/repo, in order to # generate an appropriate revision list if [ -z "$arg_repo" ]; then user=$(__hub_github_user) if [ -z "$user" ]; then for i in $(__hub_github_repos); do remote=${i%%:*} repo=${i#*:} if [ "$remote" = origin ]; then break fi done else for i in $(__hub_github_repos); do remote=${i%%:*} repo=${i#*:} owner=${repo%%/*} if [ "$user" = "$owner" ]; then break fi done fi else for i in $(__hub_github_repos); do remote=${i%%:*} repo=${i#*:} owner=${repo%%/*} case "$arg_repo" in "$repo"|"$owner") break ;; esac done fi local pfx cur_="$cur" case "$cur_" in *..*) pfx="${cur_%%..*}..." cur_="${cur_##*..}" __gitcomp_nl "$(__hub_revlist $remote)" "$pfx" "$cur_" ;; *) if [ -z "${arg_repo}${rev}" ]; then __gitcomp "$u $(__hub_github_repos '\o\n\p') $(__hub_revlist $remote)" elif [ -z "$rev" ]; then __gitcomp "$u $(__hub_revlist $remote)" else __gitcomp "$u" fi ;; esac } # hub create [NAME] [-p] [-d DESCRIPTION] [-h HOMEPAGE] function _git_create { local i c=2 name repo flags="-p -d -h" while [ $c -lt $cword ]; do i="${words[c]}" case "$i" in -d|-h) ((c++)) flags=${flags/$i/} ;; -p) flags=${flags/$i/} ;; *) name=$i ;; esac ((c++)) done if [ -z "$name" ]; then repo=$(basename "$PWD") fi case "$prev" in -d|-h) COMPREPLY=() ;; -p|*) __gitcomp "$repo $flags" ;; esac } # hub fork [--no-remote] function _git_fork { local i c=2 remote=yes while [ $c -lt $cword ]; do i="${words[c]}" case "$i" in --no-remote) unset remote ;; esac ((c++)) done if [ -n "$remote" ]; then __gitcomp "--no-remote" fi } # hub pull-request [-f] [-m |-F |-i |] [-b ] [-h ] function _git_pull_request { local i c=2 flags="-f -m -F -i -b -h" while [ $c -lt $cword ]; do i="${words[c]}" case "$i" in -m|-F|-i|-b|-h) ((c++)) flags=${flags/$i/} ;; -f) flags=${flags/$i/} ;; esac ((c++)) done case "$prev" in -i) COMPREPLY=() ;; -b|-h) # (Doesn't seem to need this...) # Uncomment the following line when 'owner/repo:[TAB]' misbehaved #_get_comp_words_by_ref -n : cur __gitcomp_nl "$(__hub_heads)" # __ltrim_colon_completions "$cur" ;; -F) COMPREPLY=( "$cur"* ) ;; -f|*) __gitcomp "$flags" ;; esac } ################### # Helper functions ################### # __hub_github_user [HOST] # Return $GITHUB_USER or the default github user defined in hub config # HOST - Host to be looked-up in hub config. Default is "github.com" function __hub_github_user { if [ -n "$GITHUB_USER" ]; then _omb_util_print $GITHUB_USER return fi local line h k v host=${1:-github.com} config=${HUB_CONFIG:-~/.config/gh} if [ -f "$config" ]; then while read line; do if [ "$line" = "---" ]; then continue fi k=${line%%:*} v=${line#*:} if [ -z "$v" ]; then if [ "$h" = "$host" ]; then break fi h=$k continue fi k=${k#* } v=${v#* } if [ "$h" = "$host" ] && [ "$k" = "user" ]; then _omb_util_print "$v" break fi done < "$config" fi } # __hub_github_repos [FORMAT] # List all github hosted repository # FORMAT - Format string contains multiple of these: # \m remote # \p owner/repo # \o owner # escaped characters (\n, \t ...etc) work # If omitted, prints all github repos in the format of "remote:owner/repo" function __hub_github_repos { local f format=$1 if [ -z "$(__gitdir)" ]; then return fi if [ -z "$format" ]; then format='\1:\2' else format=${format//\m/\1} format=${format//\p/\2} format=${format//\o/\3} fi _omb_prompt_git config --get-regexp 'remote\.[^.]*\.url' | grep -E ' ((https?|git)://|git@)github\.com[:/][^:/]+/[^/]+$' | sed -E 's#^remote\.([^.]+)\.url +.+[:/](([^/]+)/[^.]+)(\.git)?$#'"$format"'#' } # __hub_heads # List all local "branch", and remote "owner/repo:branch" function __hub_heads { local i remote repo branch dir=$(__gitdir) if [ -d "$dir" ]; then _omb_prompt_git --git-dir="$dir" for-each-ref --format='%(refname:short)' \ "refs/heads/" for i in $(__hub_github_repos); do remote=${i%%:*} repo=${i#*:} _omb_prompt_git --git-dir="$dir" for-each-ref --format='%(refname:short)' \ "refs/remotes/${remote}/" | while read branch; do _omb_util_print "${repo}:${branch#${remote}/}" done done fi } # __hub_revlist [REMOTE] # List all tags, and branches under REMOTE, without the "remote/" prefix # REMOTE - Remote name to search branches from. Default is "origin" function __hub_revlist { local i remote=${1:-origin} dir=$(__gitdir) if [ -d "$dir" ]; then _omb_prompt_git --git-dir="$dir" for-each-ref --format='%(refname:short)' \ "refs/remotes/${remote}/" | while read i; do _omb_util_print "${i#${remote}/}" done _omb_prompt_git --git-dir="$dir" for-each-ref --format='%(refname:short)' \ "refs/tags/" fi } # Enable completion for hub even when not using the alias complete -o bashdefault -o default -o nospace -F _git gh 2>/dev/null \ || complete -o default -o nospace -F _git gh fi ================================================ FILE: completions/git.completion.bash ================================================ #! bash oh-my-bash.module # bash completion support for Git. function _omb_completion_git_initialize { if ! _omb_util_function_exists __gitdir; then local git_paths path IFS=$'\n' read -r -d '' -a git_paths <<< "$(type -aP git)" # Note: Falling back on /usr (should already be in the array) git_paths+=("/usr/bin/git") for path in "${git_paths[@]}"; do if [[ -L $path ]]; then path=$(_omb_util_readlink "$path") fi # Note: In the case of symbolic link, the true binary name can # contain prefix or suffix for architectures and versions. path="${path%/*}" local files local prefix="${path%/bin}" file _omb_util_glob_expand files '"$prefix"/share/{bash-completion/completions/git,{,doc/}git-*/contrib/completion/git-completion.bash}' for file in "${files[@]}"; do if [[ -f $file && -r $file && -s $file ]]; then source "$file" return $? fi done done source "$OSH/tools/git-completion.bash" fi } _omb_completion_git_initialize unset -f _omb_completion_git_initialize ================================================ FILE: completions/git_flow.completion.sh ================================================ #! bash oh-my-bash.module # # git-flow-completion # =================== # # Bash completion support for [git-flow](http://github.com/nvie/gitflow) # # The contained completion routines provide support for completing: # # * git-flow init and version # * feature, hotfix and release branches # * remote feature branch names (for `git-flow feature track`) # # # Installation # ------------ # # To achieve git-flow completion nirvana: # # 0. Install git-completion. # # 1. Install this file. Either: # # a. Place it in a `bash-completion.d` folder: # # * /etc/bash-completion.d # * /usr/local/etc/bash-completion.d # * ~/bash-completion.d # # b. Or, copy it somewhere (e.g. ~/.git-flow-completion.sh) and put the following line in # your .bashrc: # # source ~/.git-flow-completion.sh # # 2. If you are using Git < 1.7.1: Edit git-completion.sh and add the following line to the giant # $command case in _git: # # flow) _git_flow ;; # # # The Fine Print # -------------- # # Copyright (c) 2010 [Justin Hileman](http://justinhileman.com) # # Distributed under the [MIT License](http://creativecommons.org/licenses/MIT/) _git_flow () { local subcommands="init feature release hotfix" local subcommand="$(__git_find_subcommand "$subcommands")" if [ -z "$subcommand" ]; then __gitcomp "$subcommands" return fi case "$subcommand" in feature) __git_flow_feature return ;; release) __git_flow_release return ;; hotfix) __git_flow_hotfix return ;; *) COMPREPLY=() ;; esac } __git_flow_feature () { local subcommands="list start finish publish track diff rebase checkout pull" local subcommand="$(__git_find_subcommand "$subcommands")" if [ -z "$subcommand" ]; then __gitcomp "$subcommands" return fi case "$subcommand" in pull) __gitcomp "$(__git_remotes)" return ;; checkout|finish|diff|rebase) __gitcomp "$(__git_flow_list_features)" return ;; publish) __gitcomp "$(comm -23 <(__git_flow_list_features) <(__git_flow_list_remote_features))" return ;; track) __gitcomp "$(__git_flow_list_remote_features)" return ;; *) COMPREPLY=() ;; esac } __git_flow_list_features () { _omb_prompt_git flow feature list 2> /dev/null | tr -d ' |*' } __git_flow_list_remote_features () { _omb_prompt_git branch -r 2> /dev/null | grep "origin/$(__git_flow_feature_prefix)" | awk '{ sub(/^origin\/$(__git_flow_feature_prefix)/, "", $1); print }' } __git_flow_feature_prefix () { _omb_prompt_git config gitflow.prefix.feature 2> /dev/null || echo "feature/" } __git_flow_release () { local subcommands="list start finish" local subcommand="$(__git_find_subcommand "$subcommands")" if [ -z "$subcommand" ]; then __gitcomp "$subcommands" return fi case "$subcommand" in finish) __gitcomp "$(__git_flow_list_releases)" return ;; *) COMPREPLY=() ;; esac } __git_flow_list_releases () { _omb_prompt_git flow release list 2> /dev/null } __git_flow_hotfix () { local subcommands="list start finish" local subcommand="$(__git_find_subcommand "$subcommands")" if [ -z "$subcommand" ]; then __gitcomp "$subcommands" return fi case "$subcommand" in finish) __gitcomp "$(__git_flow_list_hotfixes)" return ;; *) COMPREPLY=() ;; esac } __git_flow_list_hotfixes () { _omb_prompt_git flow hotfix list 2> /dev/null } # temporarily wrap __git_find_on_cmdline() for backwards compatibility if [ -z "`type -t __git_find_subcommand`" ]; then alias __git_find_subcommand=__git_find_on_cmdline fi ================================================ FILE: completions/git_flow_avh.completion.sh ================================================ #! bash oh-my-bash.module # # The current version is based on the following upstream version: # https://github.com/petervanderdoes/git-flow-completion/blob/db3c032411c2d6fd897b2bfc52d15a6fc4e3bfa3/git-flow-completion.bash #------------------------------------------------------------------------------ # git-flow-completion # =================== # # Bash completion support for [git-flow (AVH Edition)](http://github.com/petervanderdoes/gitflow) # # The contained completion routines provide support for completing: # # * git-flow init and version # * feature, bugfix, hotfix and release branches # * remote feature, bugfix, hotfix and release branch names # # # Installation # ------------ # # To achieve git-flow completion nirvana: # # 0. Install git-completion. # # 1. Install this file. Either: # # a. Place it in a `bash-completion.d` folder: # # * /etc/bash-completion.d # * /usr/local/etc/bash-completion.d # * ~/bash-completion.d # # b. Or, copy it somewhere (e.g. ~/.git-flow-completion.sh) and put the following line in # your .bashrc: # # source ~/.git-flow-completion.sh # # 2. If you are using Git < 1.7.1: Edit git-completion.sh and add the following line to the giant # $command case in _git: # # flow) _git_flow ;; # # # The Fine Print # -------------- # # Author: # Copyright 2012-2013 Peter van der Does. # # Original Author: # Copyright (c) 2011 [Justin Hileman](http://justinhileman.com) # # Distributed under the [MIT License](http://creativecommons.org/licenses/MIT/) __git_flow_config_file_options=" --local --global --system --file= " _git_flow () { local subcommands="init feature bugfix release hotfix support help version config finish delete publish rebase" local subcommand="$(__git_find_on_cmdline "$subcommands")" if [ -z "$subcommand" ]; then __gitcomp "$subcommands" return fi case "$subcommand" in init) __git_flow_init return ;; feature) __git_flow_feature return ;; bugfix) __git_flow_bugfix return ;; release) __git_flow_release return ;; hotfix) __git_flow_hotfix return ;; support) __git_flow_support return ;; config) __git_flow_config return ;; *) COMPREPLY=() ;; esac } __git_flow_init () { local subcommands="help" local subcommand="$(__git_find_on_cmdline "$subcommands")" if [ -z "$subcommand" ]; then __gitcomp "$subcommands" fi case "$cur" in --*) __gitcomp " --nodefaults --defaults --noforce --force $__git_flow_config_file_options " return ;; esac } __git_flow_feature () { local subcommands="list start finish publish track diff rebase checkout pull help delete rename" local subcommand="$(__git_find_on_cmdline "$subcommands")" if [ -z "$subcommand" ]; then __gitcomp "$subcommands" return fi case "$subcommand" in pull) __gitcomp_nl "$(__git_remotes)" return ;; checkout) __gitcomp_nl "$(__git_flow_list_local_branches 'feature')" return ;; delete) case "$cur" in --*) __gitcomp " --noforce --force --noremote --remote " return ;; esac __gitcomp_nl "$(__git_flow_list_local_branches 'feature')" return ;; finish) case "$cur" in --*) __gitcomp " --nofetch --fetch --norebase --rebase --nopreserve-merges --preserve-merges --nokeep --keep --keepremote --keeplocal --noforce_delete --force_delete --nosquash --squash --no-ff " return ;; esac __gitcomp_nl "$(__git_flow_list_local_branches 'feature')" return ;; diff) __gitcomp_nl "$(__git_flow_list_local_branches 'feature')" return ;; rebase) case "$cur" in --*) __gitcomp " --nointeractive --interactive --nopreserve-merges --preserve-merges " return ;; esac __gitcomp_nl "$(__git_flow_list_local_branches 'feature')" return ;; publish) __gitcomp_nl "$(__git_flow_list_branches 'feature')" return ;; track) __gitcomp_nl "$(__git_flow_list_branches 'feature')" return ;; *) COMPREPLY=() ;; esac } __git_flow_bugfix () { local subcommands="list start finish publish track diff rebase checkout pull help delete rename" local subcommand="$(__git_find_on_cmdline "$subcommands")" if [ -z "$subcommand" ]; then __gitcomp "$subcommands" return fi case "$subcommand" in pull) __gitcomp_nl "$(__git_remotes)" return ;; checkout) __gitcomp_nl "$(__git_flow_list_local_branches 'bugfix')" return ;; delete) case "$cur" in --*) __gitcomp " --noforce --force --noremote --remote " return ;; esac __gitcomp_nl "$(__git_flow_list_local_branches 'bugfix')" return ;; finish) case "$cur" in --*) __gitcomp " --nofetch --fetch --norebase --rebase --nopreserve-merges --preserve-merges --nokeep --keep --keepremote --keeplocal --noforce_delete --force_delete --nosquash --squash --no-ff " return ;; esac __gitcomp_nl "$(__git_flow_list_local_branches 'bugfix')" return ;; diff) __gitcomp_nl "$(__git_flow_list_local_branches 'bugfix')" return ;; rebase) case "$cur" in --*) __gitcomp " --nointeractive --interactive --nopreserve-merges --preserve-merges " return ;; esac __gitcomp_nl "$(__git_flow_list_local_branches 'bugfix')" return ;; publish) __gitcomp_nl "$(__git_flow_list_branches 'bugfix')" return ;; track) __gitcomp_nl "$(__git_flow_list_branches 'bugfix')" return ;; *) COMPREPLY=() ;; esac } __git_flow_release () { local subcommands="list start finish track publish help delete" local subcommand="$(__git_find_on_cmdline "$subcommands")" if [ -z "$subcommand" ]; then __gitcomp "$subcommands" return fi case "$subcommand" in finish) case "$cur" in --*) __gitcomp " --nofetch --fetch --sign --signingkey --message --nomessagefile --messagefile= --nopush --push --nokeep --keep --keepremote --keeplocal --noforce_delete --force_delete --notag --tag --nonobackmerge --nobackmerge --nosquash --squash --squash-info " return ;; esac __gitcomp_nl "$(__git_flow_list_local_branches 'release')" return ;; rebase) case "$cur" in --*) __gitcomp " --nointeractive --interactive --nopreserve-merges --preserve-merges " return ;; esac __gitcomp_nl "$(__git_flow_list_local_branches 'release')" return ;; delete) case "$cur" in --*) __gitcomp " --noforce --force --noremote --remote " return ;; esac __gitcomp_nl "$(__git_flow_list_local_branches 'release')" return ;; publish) __gitcomp_nl "$(__git_flow_list_branches 'release')" return ;; track) __gitcomp_nl "$(__git_flow_list_branches 'release')" return ;; start) case "$cur" in --*) __gitcomp " --nofetch --fetch " return ;; esac return ;; *) COMPREPLY=() ;; esac } __git_flow_hotfix () { local subcommands="list start finish track publish help delete rename" local subcommand="$(__git_find_on_cmdline "$subcommands")" if [ -z "$subcommand" ]; then __gitcomp "$subcommands" return fi case "$subcommand" in finish) case "$cur" in --*) __gitcomp " --nofetch --fetch --sign --signingkey --message --nomessagefile --messagefile= --nopush --push --nokeep --keep --keepremote --keeplocal --noforce_delete --force_delete --notag --tag --nonobackmerge --nobackmerge --nosquash --squash --squash-info " return ;; esac __gitcomp_nl "$(__git_flow_list_local_branches 'hotfix')" return ;; rebase) case "$cur" in --*) __gitcomp " --nointeractive --interactive --nopreserve-merges --preserve-merges " return ;; esac __gitcomp_nl "$(__git_flow_list_local_branches 'hotfix')" return ;; delete) case "$cur" in --*) __gitcomp " --noforce --force --noremote --remote " return ;; esac __gitcomp_nl "$(__git_flow_list_local_branches 'hotfix')" return ;; publish) __gitcomp_nl "$(__git_flow_list_branches 'hotfix')" return ;; track) __gitcomp_nl "$(__git_flow_list_branches 'hotfix')" return ;; start) case "$cur" in --*) __gitcomp " --nofetch --fetch " return ;; esac return ;; *) COMPREPLY=() ;; esac } __git_flow_support () { local subcommands="list start help" local subcommand="$(__git_find_on_cmdline "$subcommands")" if [ -z "$subcommand" ]; then __gitcomp "$subcommands" return fi case "$subcommand" in start) case "$cur" in --*) __gitcomp " --nofetch --fetch " return ;; esac return ;; rebase) case "$cur" in --*) __gitcomp " --nointeractive --interactive --nopreserve-merges --preserve-merges " return ;; esac __gitcomp_nl "$(__git_flow_list_local_branches 'support')" return ;; *) COMPREPLY=() ;; esac } __git_flow_config () { local subcommands="list set base" local subcommand="$(__git_find_on_cmdline "$subcommands")" if [ -z "$subcommand" ]; then __gitcomp "$subcommands" return fi case "$subcommand" in set) case "$cur" in --*) __gitcomp " $__git_flow_config_file_options " return ;; esac __gitcomp " master develop feature bugfix hotfix release support versiontagprefix " return ;; base) case "$cur" in --*) __gitcomp " set get " return ;; esac __gitcomp_nl "$(__git_flow_list_local_branches)" return ;; *) COMPREPLY=() ;; esac } __git_flow_prefix () { case "$1" in feature|bugfix|release|hotfix|support) _omb_prompt_git config "gitflow.prefix.$1" 2> /dev/null || _omb_util_print "$1/" return ;; esac } __git_flow_list_local_branches () { if [ -n "$1" ]; then local prefix="$(__git_flow_prefix $1)" _omb_prompt_git for-each-ref --shell --format="ref=%(refname:short)" refs/heads/$prefix | \ while read -r entry; do eval "$entry" ref="${ref#$prefix}" _omb_util_print "$ref" done | sort else _omb_prompt_git for-each-ref --format="ref=%(refname:short)" refs/heads/ | sort fi } __git_flow_list_remote_branches () { local prefix="$(__git_flow_prefix $1)" local origin="$(_omb_prompt_git config gitflow.origin 2> /dev/null || _omb_util_print "origin")" _omb_prompt_git for-each-ref --shell --format='%(refname:short)' refs/remotes/$origin/$prefix | \ while read -r entry; do eval "$entry" ref="${ref##$prefix}" _omb_util_print "$ref" done | sort } __git_flow_list_branches () { local origin="$(_omb_prompt_git config gitflow.origin 2> /dev/null || _omb_util_print "origin")" if [ -n "$1" ]; then local prefix="$(__git_flow_prefix $1)" _omb_prompt_git for-each-ref --shell --format="ref=%(refname:short)" refs/heads/$prefix refs/remotes/$origin/$prefix | \ while read -r entry; do eval "$entry" ref="${ref##$prefix}" _omb_util_print "$ref" done | sort else _omb_prompt_git for-each-ref --format="%(refname:short)" refs/heads/ refs/remotes/$origin | sort fi } # alias __git_find_on_cmdline for backwards compatibility if [ -z "`type -t __git_find_on_cmdline`" ]; then alias __git_find_on_cmdline=__git_find_subcommand fi ================================================ FILE: completions/go.completion.sh ================================================ #! bash oh-my-bash.module # # bash completion for go tool # https://github.com/thomasf/go-bash-completion/blob/73c7543f2a295d27ae9bc71baa1ef1a858447eae/go-bash-completion.bash #------------------------------------------------------------------------------ # install in /etc/bash_completion.d/ or your personal directory complete -f -X '!*.8' 8l complete -f -X '!*.6' 6l complete -f -X '!*.5' 5l complete -f -X '!*.go' 8g 6g 5g gofmt gccgo function _go_clear_cache { unset -v _go_imports } function _go_importpath_cache { if [[ ! ${_go_imports-} ]]; then _go_imports=$(go list all 2>/dev/null) export _go_imports fi } function _go_importpath { compgen -W "$_go_imports" -- "$1" } function _go { # TODO: Only allow flags before other arguments. run already does # this. local cur=$(_get_cword) local prev=${COMP_WORDS[COMP_CWORD-1]} local cmd=${COMP_WORDS[1]} local cmds="build clean doc env fix fmt get install list run test tool version vet" local addhelp="gopath importpath remote testflag testfunc" local other="help" local env_vars="GOARCH GOBIN GOEXE GOHOSTARCH GOHOSTOS GOOS GOPATH GORACE GOROOT GOTOOLDIR GO15VENDOREXPERIMENT CC GOGCCFLAGS CXX CGO_ENABLED" if ((COMP_CWORD == 1)); then local opt for opt in $cmds; do if [[ $opt == "$cmd" ]]; then COMPREPLY=("$opt") return 0 fi done fi case $cmd in 'build') case $prev in '-o') _filedir ;; '-p') ;; *) if [[ $cur == -* ]]; then COMPREPLY=($(compgen -W "-a -n -o -p -v -x" -- "$cur")) else local found=0 i for ((i=0; i < ${#COMP_WORDS[@]}; i++)); do case $i in 0|1|"$COMP_CWORD") continue ;; esac local opt=${COMP_WORDS[i]} if [[ $opt != -* ]]; then if [[ $opt == *.go && -f $opt ]]; then found=1 break else found=2 break fi fi done case $found in 0) _filedir go _go_importpath_cache COMPREPLY+=($(_go_importpath "$cur")) ;; 1) _filedir go ;; 2) _go_importpath_cache COMPREPLY=($(_go_importpath "$cur")) ;; esac fi ;; esac ;; 'clean') if [[ $cur == -* ]]; then COMPREPLY=($(compgen -W "-i -r -n -x" -- "$cur")) else _go_importpath_cache COMPREPLY=($(_go_importpath "$cur")) fi ;; 'doc') _go_importpath_cache COMPREPLY=($(_go_importpath "$cur")) ;; 'env') COMPREPLY=($(compgen -W "$env_vars" -- "$cur")) ;; 'fix') _go_importpath_cache COMPREPLY=($(_go_importpath "$cur")) ;; 'fmt') _go_importpath_cache COMPREPLY=($(_go_importpath "$cur")) ;; 'get') case $prev in '-p') ;; *) if [[ $cur == -* ]]; then COMPREPLY=($(compgen -W "-a -d -fix -n -p -u -v -x" -- "$cur")) else _go_importpath_cache COMPREPLY=($(_go_importpath "$cur")) fi ;; esac ;; 'install') case $prev in '-p') ;; *) if [[ $cur == -* ]]; then COMPREPLY=($(compgen -W "-a -n -p -v -x" -- "$cur")) else _go_importpath_cache COMPREPLY=($(_go_importpath "$cur")) fi ;; esac ;; 'list') case $prev in '-f') ;; *) if [[ $cur == -* ]]; then COMPREPLY=($(compgen -W "-e -f -json" -- "$cur")) else _go_importpath_cache COMPREPLY=($(_go_importpath "$cur")) fi ;; esac ;; 'run') if [[ $cur == -* && $prev != *.go ]]; then COMPREPLY=($(compgen -W "-a -n -x" -- "$cur")) else _filedir fi ;; 'test') # TODO: Support for testflags. case $prev in '-file') _filedir go ;; '-p') ;; *) if [[ $cur == -* ]]; then COMPREPLY=($(compgen -W "-c -file -i -p -x" -- "$cur")) else _go_importpath_cache COMPREPLY=($(_go_importpath "$cur")) fi ;; esac ;; 'tool') if ((COMP_CWORD == 2)); then COMPREPLY=($(compgen -W "$(go tool)" -- "$cur")) else case ${COMP_WORDS[2]} in [568]a) # TODO: Implement something. #_go_tool_568a ;; [568]c) # TODO: Implement something. #_go_tool_568c ;; [568]g) # TODO: Implement something. #_go_tool_568g ;; [568]l) # TODO: Implement something. #_go_tool_568l ;; 'api') # TODO: Implement something. #_go_tool_api ;; 'cgo') # TODO: Implement something. #_go_tool_cgo ;; 'cov') # TODO: Implement something. #_go_tool_cov ;; 'dist') # TODO: Implement something. #_go_tool_dist ;; 'ebnflint') # TODO: Implement something. #_go_tool_ebnflint ;; 'fix') # TODO: Implement something. #_go_tool_fix ;; 'gotype') # TODO: Implement something. #_go_tool_gotype ;; 'nm') # TODO: Implement something. #_go_tool_nm ;; 'pack') # TODO: Implement something. #_go_tool_pack ;; 'pprof') # TODO: Implement something. #_go_tool_pprof ;; 'prof') # TODO: Implement something. #_go_tool_prof ;; 'vet') # TODO: Implement something. #_go_tool_vet ;; 'yacc') # TODO: Implement something. #_go_tool_yacc ;; esac if [[ $cur == -* ]]; then COMPREPLY=($(compgen -W "${COMPREPLY[*]} -h" -- "$cur")) fi fi ;; 'version') ;; 'vet') if [[ $cur == -* ]]; then : else _go_importpath_cache COMPREPLY=($(_go_importpath "$cur")) fi ;; 'help') if ((COMP_CWORD == 2)); then COMPREPLY=($(compgen -W "$cmds $addhelp" -- "$cur")) fi ;; *) if ((COMP_CWORD == 1)); then COMPREPLY=($(compgen -W "$cmds $other" -- "$cur")) else _filedir fi ;; esac } complete $filenames -F _go go # vim:ts=2 sw=2 et syn=sh ================================================ FILE: completions/gradle.completion.sh ================================================ #! bash oh-my-bash.module # This completion setting seems to be only found in Oh My Bash. #------------------------------------------------------------------------------ function __gradle { local cur=${COMP_WORDS[COMP_CWORD]} local tasks='' local cache_dir=$HOME/.gradle/completion_cache case $OSTYPE in darwin*) local checksum_command="find . -name build.gradle -print0 | xargs -0 md5 -q | md5 -q" ;; *) local checksum_command="find . -name build.gradle -print0 | xargs -0 md5sum | md5sum | cut -d ' ' -f 1" ;; esac local parsing_command="gradle --console=plain --quiet tasks | grep -v Rules | sed -nE -e 's/^([a-zA-Z]+)($| - .+)/\1/p'" mkdir -p "$cache_dir" local gradle_files_checksum='no_cache_file' if [[ -f build.gradle ]]; then gradle_files_checksum=$(eval "$checksum_command") if [[ -f $cache_dir/$gradle_files_checksum ]]; then newest_gradle_file=$(find . -type f -name build.gradle -newer "$cache_dir/$gradle_files_checksum") if [[ $newest_gradle_file ]]; then tasks=$(eval "$parsing_command") [[ $tasks ]] && _omb_util_print "$tasks" > "$cache_dir/$gradle_files_checksum" else tasks=$(< "$cache_dir/$gradle_files_checksum") touch "$cache_dir/$gradle_files_checksum" fi else tasks=$(eval "$parsing_command") [[ $tasks ]] && _omb_util_print "$tasks" > "$cache_dir/$gradle_files_checksum" fi else tasks=$(eval "$parsing_command") [[ $tasks ]] && _omb_util_print "$tasks" > "$cache_dir/$gradle_files_checksum" fi COMPREPLY=($(compgen -W "$tasks" -- "$cur")) } function __clear_gradle_cache { local cache_dir=$HOME/.gradle/completion_cache [[ -d $cache_dir ]] && find "$cache_dir" -type f -mtime +7 -exec rm -f {} \; } __clear_gradle_cache complete -F __gradle gradle complete -F __gradle gradlew complete -F __gradle ./gradlew ================================================ FILE: completions/grunt.completion.sh ================================================ #! bash oh-my-bash.module # # The current version is based on the following upstream version: # https://github.com/gruntjs/grunt-cli/blob/8c791efc931fa8cf80cc98d09d3e20c36501fc0f/completion/bash#L33 # # Note: The upstream version seems to have just updated the copyright year, but # that change must be wrong. Basically, the copyright year should reflect the # year of the first release. The years of later updates are optional. #------------------------------------------------------------------------------ # grunt-cli # http://gruntjs.com/ # # Copyright (c) 2012 Tyler Kellen, contributors # Licensed under the MIT license. # https://github.com/gruntjs/grunt/blob/master/LICENSE-MIT # Usage: # # To enable bash completion for grunt, add the following line (minus the # leading #, which is the bash comment character) to your ~/.bashrc file: # # eval "$(grunt --completion=bash)" # Search the current directory and all parent directories for a gruntfile. function _grunt_gruntfile { local curpath=$PWD while [[ $curpath ]]; do local gruntfile for gruntfile in "$curpath"/{G,g}runtfile.{js,coffee}; do if [[ -e $gruntfile ]]; then _omb_util_print "$gruntfile" return 0 fi done curpath=${curpath%/*} done return 1 } # Enable bash autocompletion. function _grunt_completions { # The currently-being-completed word. local cur=${COMP_WORDS[COMP_CWORD]} # The current gruntfile, if it exists. local gruntfile=$(_grunt_gruntfile) # The current grunt version, available tasks, options, etc. local gruntinfo=$(grunt --version --verbose 2>/dev/null) # Options and tasks. local opts=$(awk '/Available options: / {$1=$2=""; print $0}' <<< "$gruntinfo") local compls=$(awk '/Available tasks: / {$1=$2=""; print $0}' <<< "$gruntinfo") # Only add -- or - options if the user has started typing - [[ $cur == -* ]] && compls="$compls $opts" # Tell complete what stuff to show. COMPREPLY=($(compgen -W "$compls" -- "$cur")) } complete -o default -F _grunt_completions grunt ================================================ FILE: completions/gulp.completion.sh ================================================ #! bash oh-my-bash.module # Borrowed from grunt-cli # http://gruntjs.com/ # # Copyright (c) 2012 Tyler Kellen, contributors # Licensed under the MIT license. # https://github.com/gruntjs/grunt/blob/master/LICENSE-MIT # Usage: # # To enable bash completion for gulp, add the following line (minus the # leading #, which is the bash comment character) to your ~/.bashrc file: # # eval "$(gulp --completion=bash)" # Enable bash autocompletion. function _gulp_completions() { # The currently-being-completed word. local cur="${COMP_WORDS[COMP_CWORD]}" #Grab tasks local compls=$(gulp --tasks-simple) # Tell complete what stuff to show. COMPREPLY=($(compgen -W "$compls" -- "$cur")) } complete -o default -F _gulp_completions gulp ================================================ FILE: completions/helm.completion.sh ================================================ #! bash oh-my-bash.module if _omb_util_command_exists helm; then eval -- "$(helm completion bash)" fi ================================================ FILE: completions/homesick.completion.sh ================================================ #! bash oh-my-bash.module # Bash completion script for homesick # # The homebrew bash completion script was used as inspiration. # Originally from https://github.com/liborw/homesick-completion # https://github.com/liborw/homesick-completion/blob/904d121d1b8f81629f473915a10c9144fdd416dc/homesick_bash_completion.sh _omb_completion_homesick() { local cur=${COMP_WORDS[COMP_CWORD]} local options="--skip --force --pretend --quiet" local actions="cd clone commit destroy diff generate help list open pull push rc show_path status symlink track unlink version" local repos=$(\ls ~/.homesick/repos) # Subcommand list if ((COMP_CWORD == 1)); then COMPREPLY=( $(compgen -W "${options} ${actions}" -- "$cur") ) return fi # Find the first non-switch word local prev_index=1 local prev=${COMP_WORDS[prev_index]} while [[ $prev == -* ]]; do ((++prev_index)) prev=${COMP_WORDS[prev_index]} done # Find the number of non-"--" commands local num=0 for word in "${COMP_WORDS[@]}"; do if [[ $word != -* ]]; then ((++num)) fi done case $prev in # Commands that take a castle cd|commit|destroy|diff|open|pull|push|rc|show_path|status|symlink|unlink) COMPREPLY=( $(compgen -W "${repos}" -- "$cur") ) return ;; # Commands that take command help) COMPREPLY=( $(compgen -W "${actions}" -- "$cur") ) return ;; # Track command take file and repo track) if ((num == 2)); then COMPREPLY=( $(compgen -X -f "$cur") ) elif ((num >= 3)); then COMPREPLY=( $(compgen -W "${repos}" -- "$cur") ) fi return ;; esac } complete -o bashdefault -o default -F _omb_completion_homesick homesick ================================================ FILE: completions/hub.completion.sh ================================================ #! bash oh-my-bash.module # # The current version is based on the following upstream version: # https://github.com/mislav/hub/blob/5c547ed804368763064e51f3990851e267e88edd/etc/hub.bash_completion.sh #------------------------------------------------------------------------------ # hub tab-completion script for bash. # This script complements the completion script that ships with git. # If there is no git tab completion, but we have the _completion loader try to load it if ! _omb_util_function_exists _git && _omb_util_function_exists _completion_loader; then _completion_loader git fi # Check that git tab completion is available and we haven't already set up completion if _omb_util_function_exists _git && ! _omb_util_function_exists __git_list_all_commands_without_hub ; then # Duplicate and rename the 'list_all_commands' function eval "$(declare -f __git_list_all_commands | \ sed 's/__git_list_all_commands/__git_list_all_commands_without_hub/')" # Wrap the 'list_all_commands' function with extra hub commands function __git_list_all_commands { cat <<-EOF alias pull-request pr issue release fork create delete browse compare ci-status sync EOF __git_list_all_commands_without_hub } # Ensure cached commands are cleared __git_all_commands="" ########################## # hub command completions ########################## # hub alias [-s] [SHELL] function _git_alias { local i c=2 s=-s sh shells="bash zsh sh ksh csh fish" while [ $c -lt $cword ]; do i="${words[c]}" case "$i" in -s) unset s ;; *) for sh in $shells; do if [ "$sh" = "$i" ]; then unset shells break fi done ;; esac ((c++)) done __gitcomp "$s $shells" } # hub browse [-u] [--|[USER/]REPOSITORY] [SUBPAGE] function _git_browse { local i c=2 u=-u repo subpage local subpages_="commits issues tree wiki pulls branches stargazers contributors network network/ graphs graphs/" local subpages_network="members" local subpages_graphs="commit-activity code-frequency punch-card" while [ $c -lt $cword ]; do i="${words[c]}" case "$i" in -u) unset u ;; *) if [ -z "$repo" ]; then repo=$i else subpage=$i fi ;; esac ((c++)) done if [ -z "$repo" ]; then __gitcomp "$u -- $(__hub_github_repos '\p')" elif [ -z "$subpage" ]; then case "$cur" in */*) local pfx="${cur%/*}" cur_="${cur#*/}" local subpages_var="subpages_$pfx" __gitcomp "${!subpages_var}" "$pfx/" "$cur_" ;; *) __gitcomp "$u ${subpages_}" ;; esac else __gitcomp "$u" fi } # hub compare [-u] [USER[/REPOSITORY]] [[START...]END] function _git_compare { local i c=$((cword - 1)) u=-u user remote owner repo arg_repo rev while [ $c -gt 1 ]; do i="${words[c]}" case "$i" in -u) unset u ;; *) if [ -z "$rev" ]; then # Even though the logic below is able to complete both user/repo # and revision in the right place, when there is only one argument # (other than -u) in the command, that argument will be taken as # revision. For example: # $ hub compare -u upstream # > https://github.com/USER/REPO/compare/upstream if __hub_github_repos '\p' | command grep -Eqx "^$i(/[^/]+)?"; then arg_repo=$i else rev=$i fi elif [ -z "$arg_repo" ]; then arg_repo=$i fi ;; esac ((c--)) done # Here we want to find out the git remote name of user/repo, in order to # generate an appropriate revision list if [ -z "$arg_repo" ]; then user=$(__hub_github_user) if [ -z "$user" ]; then for i in $(__hub_github_repos); do remote=${i%%:*} repo=${i#*:} if [ "$remote" = origin ]; then break fi done else for i in $(__hub_github_repos); do remote=${i%%:*} repo=${i#*:} owner=${repo%%/*} if [ "$user" = "$owner" ]; then break fi done fi else for i in $(__hub_github_repos); do remote=${i%%:*} repo=${i#*:} owner=${repo%%/*} case "$arg_repo" in "$repo"|"$owner") break ;; esac done fi local pfx cur_="$cur" case "$cur_" in *..*) pfx="${cur_%%..*}..." cur_="${cur_##*..}" __gitcomp_nl "$(__hub_revlist $remote)" "$pfx" "$cur_" ;; *) if [ -z "${arg_repo}${rev}" ]; then __gitcomp "$u $(__hub_github_repos '\o\n\p') $(__hub_revlist $remote)" elif [ -z "$rev" ]; then __gitcomp "$u $(__hub_revlist $remote)" else __gitcomp "$u" fi ;; esac } # hub create [NAME] [-p] [-d DESCRIPTION] [-h HOMEPAGE] function _git_create { local i c=2 name repo flags="-p -d -h" while [ $c -lt $cword ]; do i="${words[c]}" case "$i" in -d|-h) ((c++)) flags=${flags/$i/} ;; -p) flags=${flags/$i/} ;; *) name=$i ;; esac ((c++)) done if [ -z "$name" ]; then repo=$(basename "$PWD") fi case "$prev" in -d|-h) COMPREPLY=() ;; -p|*) __gitcomp "$repo $flags" ;; esac } # hub fork [--no-remote] [--remote-name REMOTE] [--org ORGANIZATION] function _git_fork { local i c=2 flags="--no-remote --remote-name --org" while [ $c -lt $cword ]; do i="${words[c]}" case "$i" in --org) ((c++)) flags=${flags/$i/} ;; --remote-name) ((c++)) flags=${flags/$i/} flags=${flags/--no-remote/} ;; --no-remote) flags=${flags/$i/} flags=${flags/--remote-name/} ;; esac ((c++)) done case "$prev" in --remote-name|--org) COMPREPLY=() ;; *) __gitcomp "$flags" ;; esac } # hub pull-request [-f] [-m |-F |-i |] [-b ] [-h ] [-a ] [-M ] [-l ] function _git_pull_request { local i c=2 flags="-f -m -F -i -b -h -a -M -l" while [ $c -lt $cword ]; do i="${words[c]}" case "$i" in -m|-F|-i|-b|-h|-a|-M|-l) ((c++)) flags=${flags/$i/} ;; -f) flags=${flags/$i/} ;; esac ((c++)) done case "$prev" in -i) COMPREPLY=() ;; -b|-h|-a|-M|-l) # (Doesn't seem to need this...) # Uncomment the following line when 'owner/repo:[TAB]' misbehaved #_get_comp_words_by_ref -n : cur __gitcomp_nl "$(__hub_heads)" # __ltrim_colon_completions "$cur" ;; -F) COMPREPLY=( "$cur"* ) ;; -f|*) __gitcomp "$flags" ;; esac } ################### # Helper functions ################### # __hub_github_user [HOST] # Return $GITHUB_USER or the default github user defined in hub config # HOST - Host to be looked-up in hub config. Default is "github.com" function __hub_github_user { if [ -n "$GITHUB_USER" ]; then _omb_util_print $GITHUB_USER return fi local line h k v host=${1:-github.com} config=${HUB_CONFIG:-~/.config/hub} if [ -f "$config" ]; then while read line; do if [ "$line" = "---" ]; then continue fi k=${line%%:*} v=${line#*:} if [ -z "$v" ]; then if [ "$h" = "$host" ]; then break fi h=$k continue fi k=${k#* } v=${v#* } if [ "$h" = "$host" ] && [ "$k" = "user" ]; then _omb_util_print "$v" break fi done < "$config" fi } # __hub_github_repos [FORMAT] # List all github hosted repository # FORMAT - Format string contains multiple of these: # \m remote # \p owner/repo # \o owner # escaped characters (\n, \t ...etc) work # If omitted, prints all github repos in the format of "remote:owner/repo" function __hub_github_repos { local f format=$1 if [ -z "$(__gitdir)" ]; then return fi if [ -z "$format" ]; then format='\1:\2' else format=${format//\m/\1} format=${format//\p/\2} format=${format//\o/\3} fi _omb_prompt_git config --get-regexp 'remote\.[^.]*\.url' | command grep -E ' ((https?|git)://|git@)github\.com[:/][^:/]+/[^/]+$' | sed -E 's#^remote\.([^.]+)\.url +.+[:/](([^/]+)/[^.]+)(\.git)?$#'"$format"'#' } # __hub_heads # List all local "branch", and remote "owner/repo:branch" function __hub_heads { local i remote repo branch dir=$(__gitdir) if [ -d "$dir" ]; then _omb_prompt_git --git-dir="$dir" for-each-ref --format='%(refname:short)' \ "refs/heads/" for i in $(__hub_github_repos); do remote=${i%%:*} repo=${i#*:} _omb_prompt_git --git-dir="$dir" for-each-ref --format='%(refname:short)' \ "refs/remotes/${remote}/" | while read branch; do _omb_util_print "${repo}:${branch#${remote}/}" done done fi } # __hub_revlist [REMOTE] # List all tags, and branches under REMOTE, without the "remote/" prefix # REMOTE - Remote name to search branches from. Default is "origin" function __hub_revlist { local i remote=${1:-origin} dir=$(__gitdir) if [ -d "$dir" ]; then _omb_prompt_git --git-dir="$dir" for-each-ref --format='%(refname:short)' \ "refs/remotes/${remote}/" | while read i; do _omb_util_print "${i#${remote}/}" done _omb_prompt_git --git-dir="$dir" for-each-ref --format='%(refname:short)' \ "refs/tags/" fi } # Enable completion for hub even when not using the alias complete -o bashdefault -o default -o nospace -F _git hub 2>/dev/null \ || complete -o default -o nospace -F _git hub fi ================================================ FILE: completions/jboss7.completion.sh ================================================ #! bash oh-my-bash.module # Completions for JBoss Application Server 7 (EAP 6) # VERSION: 0.6 # DATE: 2012-10-30 # rparree-at-edc4it-dot-com function _serverProfiles { if [[ $COMP_WORDS == *standalone.sh* ]] then serverdir="../standalone/configuration/" else # assume is domain.sh serverdir="../domain/configuration/" fi for i in ${!COMP_WORDS[*]} do if [[ "${COMP_WORDS[i]}" == "-Djboss.server.base.dir" || "${COMP_WORDS[i]}" == "-Djboss.domain.base.dir" ]]; then serverdir="${COMP_WORDS[i+2]}/configuration" fi done if [ -d "${serverdir}" ] then IFS=$'\n' tmp="$(ls "${serverdir}" | grep xml)" local fls="${tmp[@]// /\ }" unset IFS COMPREPLY=( $(compgen -W "${fls} initial boot last v" -- "$cur" )) fi } function _bindingAddress { # from /etc/bash_completion.d/ssh COMPREPLY=( "${COMPREPLY[@]}" $( compgen -W \ "0.0.0.0 $( PATH="$PATH:/sbin" ifconfig -a | \ sed -ne 's/.*addr:\([^[:space:]]*\).*/\1/p' \ -ne 's/.*inet[[:space:]]\{1,\}\([^[:space:]]*\).*/\1/p' )" \ -- "$cur" ) ) } function _jboss { local cur prev words cword COMPREPLY=() _get_comp_words_by_ref -n = cur prev words cword case $cur in -Djboss.socket.binding.port-offset=*) cur=${cur#*=} #static list of common bindings sets local bindings="100 200 300 400 10000 20000 30000 40000" COMPREPLY=( $(compgen -W "${bindings}" -- ${cur}) ) return 0 ;; -Djboss.default.jgroups.stack=*) cur=${cur#*=} #static list of standard JGroups stacks local stacks="udp udp-async udp-sync tcp tcp-sync" COMPREPLY=( $(compgen -W "${stacks}" -- ${cur}) ) return 0 ;; -Dorg.jboss.ejb3.remoting.IsLocalInterceptor.passByRef=*|-Dcom.sun.management.jmxremote.authenticate=*|-Dcom.sun.management.jmxremote.ssl=*) cur=${cur#*=} local booleans="true false" COMPREPLY=( $(compgen -W "${booleans}" -- ${cur}) ) return 0 ;; -Djboss.server.base.dir=*|-Djboss.home.dir=*|-Djboss.domain.base.dir=*) cur=${cur#*=} _filedir -d return 0 ;; -Djboss.domain.master.address=*|-Djboss.bind.address*=*) cur=${cur#*=} _bindingAddress return 0 ;; --server-config=*|-c=|--host-config=*) cur=${cur#*=} _serverProfiles return 0 esac case $prev in -u) # a few from RFC 2365 IPv4 Local Scope () local addresses="239.255.0.1 239.255.0.2 239.255.0.3" COMPREPLY=( $(compgen -W "${addresses}" -- ${cur}) ) return 0 ;; -b*) _bindingAddress return 0 ;; -c) _serverProfiles return 0 ;; *) ;; esac # *** from jboss5 ******************** # *** -modulepath -c -m -g -l -d -p -n -B -L -C -Djboss.platform.mbeanserver -Djboss.server.base.directory # *** -Djboss.Domain -Djboss.modcluster.proxyList -Djboss.jvmRoute -Djboss.default.jgroups.stack -Dorg.jboss.ejb3.remoting.IsLocalInterceptor.passByRef -Djboss.platform.mbeanserver -Dcom.sun.management.jmxremote.port -Dcom.sun.management.jmxremote.ssl # ************************************* # standard commands for standalone and domain mode local commandsWithoutEqualSign='-b -bmanagement -bunsecure -bpublic --admin-only -h -help -u -version -V -v' local commandsWithEqualSign='-P -Djboss.node.name -Djboss.home.dir -Djboss.socket.binding.port-offset -Djboss.bind.address.management -Djboss.bind.address -Djboss.bind.address.unsecure' if [[ $COMP_WORDS == *standalone.sh* ]] then commandsWithoutEqualSign="${commandsWithoutEqualSign} -c" commandsWithEqualSign="${commandsWithEqualSign} --server-config -Djboss.server.base.dir -c" else # assume is domain.sh commandsWithoutEqualSign="${commandsWithoutEqualSign} --backup --cached-dc" commandsWithEqualSign="${commandsWithEqualSign} -Djboss.domain.master.address --host-config -Djboss.domain.master.port -Djboss.domain.base.dir " fi COMPREPLY=( $( compgen -W "$commandsWithoutEqualSign" -- "$cur" ) $( compgen -W "$commandsWithEqualSign" -S '=' -- "$cur" ) ) return 0 } complete -o nospace -F _jboss standalone.sh complete -o nospace -F _jboss domain.sh ================================================ FILE: completions/jump.completion.sh ================================================ #! bash oh-my-bash.module if _omb_util_command_exists jump; then function _omb_plugin_jump_completion { local JUMP_COMMANDS=$(jump 2>&1 | command grep -E '^ +' | awk '{print $1}') COMPREPLY=( $(compgen -W '$JUMP_COMMANDS' -- "${COMP_WORDS[1]}") ) } complete -F _omb_plugin_jump_completion jump fi ================================================ FILE: completions/jungle.completion.sh ================================================ #! bash oh-my-bash.module _omb_util_binary_exists jungle && eval "$(_JUNGLE_COMPLETE=source jungle)" ================================================ FILE: completions/kontena.completion.sh ================================================ #! bash oh-my-bash.module _omb_util_binary_exists kontena && . "$( kontena whoami --bash-completion-path )" ================================================ FILE: completions/kubectl.completion.sh ================================================ #! bash oh-my-bash.module # kubectl (Kubernetes CLI) completion if _omb_util_command_exists kubectl; then # Note: We set KUBECONFIG=/dev/null to disable any kubectl plugins that take # time to initialize. For example, gke-gcloud-auth-plugin provided by Google # Cloud for GKE (Google Kubernetes Engine) seems to try to connect to an auth # server every time the kubectl command is executed, regardless of whether # the kubectl subcommand requires authentication. Since the generation of the # completion script should not depend on plugins, we temporarily disable all # plugins by setting a temporary environment KUBECONFIG=/dev/null. eval -- "$(KUBECONFIG=/dev/null kubectl completion bash)" fi ================================================ FILE: completions/makefile.completion.sh ================================================ #! bash oh-my-bash.module # Add completion for Makefile # see http://stackoverflow.com/a/38415982/1472048 complete -W "\$(shopt -u nullglob; shopt -s nocaseglob; command grep -oE '^[a-zA-Z0-9_-]+:([^=]|\$)' *makefile 2>/dev/null | command sed 's/[^a-zA-Z0-9_-]*\$//')" make ================================================ FILE: completions/maven.completion.sh ================================================ #! bash oh-my-bash.module # # Bash completion support for maven inspired from: # # - https://github.com/juven/maven-bash-completion # - https://github.com/parisjug/maven-bash-completion # # The current version is based on the following upstream version. # https://github.com/juven/maven-bash-completion/blob/216cd667b6119fe200c98b1ac2d030ac002be197/bash_completion.bash #------------------------------------------------------------------------------ _omb_deprecate_function 20000 function_exists _omb_util_function_exists _omb_util_function_exists _get_comp_words_by_ref || function _get_comp_words_by_ref { local exclude cur_ words_ cword_; if [[ $1 == "-n" ]]; then exclude=$2 shift 2 fi __git_reassemble_comp_words_by_ref "$exclude" cur_=${words_[cword_]} while (($# > 0)); do case $1 in cur) cur=$cur_ ;; prev) prev=${words_[$cword_-1]} ;; words) words=("${words_[@]}") ;; cword) cword=$cword_ ;; esac; shift done } _omb_util_function_exists __ltrim_colon_completions || function __ltrim_colon_completions { if [[ $1 == *:* && $COMP_WORDBREAKS == *:* ]]; then # Remove colon-word prefix from COMPREPLY items local colon_word=${1%${1##*:}} local i=${#COMPREPLY[*]} while ((--i >= 0)); do COMPREPLY[i]=${COMPREPLY[i]#"$colon_word"} done fi } _omb_util_function_exists __find_mvn_projects || function __find_mvn_projects { find . -name 'pom.xml' -not -path '*/target/*' -prune | while read LINE; do local withoutPom=${LINE%/pom.xml} local module=${withoutPom#./} if [[ ! $module ]]; then _omb_util_print "." else _omb_util_print $module fi done } _omb_util_function_exists _realpath || function _realpath { if [[ -f $1 ]]; then # file *must* exist if cd "${1%/*}" &>/dev/null; then # file *may* not be local # exception is ./file.ext # try 'cd .; cd -;' *works!* local tmppwd=$PWD cd - &>/dev/null else # file *must* be local local tmppwd=$PWD fi else # file *cannot* exist return 1 # failure fi # suppress shell session termination messages on macOS function shell_session_save { false } # reassemble realpath _omb_util_print "$tmppwd/${1##*/}" return 1 #success } _omb_util_function_exists __pom_hierarchy || function __pom_hierarchy { local pom=$(_realpath "pom.xml") POM_HIERARCHY+=("$pom") while [[ $pom ]] && grep -q "" "$pom"; do ## look for a new relativePath for parent pom.xml local parent_pom_relative=$(grep -e ".*" "$pom" | sed 's/.*//' | sed 's/<\/relativePath>.*//g') ## is present but not defined, assume ../pom.xml if [[ ! $parent_pom_relative ]]; then parent_pom_relative=../pom.xml fi ## if pom exists continue else break parent_pom=$(_realpath "${pom%/*}/$parent_pom_relative") if [[ $parent_pom ]]; then pom=$parent_pom else break fi POM_HIERARCHY+=("$pom") done } function _mvn { local cur prev COMPREPLY=() POM_HIERARCHY=() __pom_hierarchy _get_comp_words_by_ref -n : cur prev local opts="-am|-amd|-B|-C|-c|-cpu|-D|-e|-emp|-ep|-f|-fae|-ff|-fn|-gs|-h|-l|-N|-npr|-npu|-nsu|-o|-P|-pl|-q|-rf|-s|-T|-t|-U|-up|-V|-v|-X" local long_opts="--also-make|--also-make-dependents|--batch-mode|--strict-checksums|--lax-checksums|--check-plugin-updates|--define|--errors|--encrypt-master-password|--encrypt-password|--file|--fail-at-end|--fail-fast|--fail-never|--global-settings|--help|--log-file|--non-recursive|--no-plugin-registry|--no-plugin-updates|--no-snapshot-updates|--offline|--activate-profiles|--projects|--quiet|--resume-from|--settings|--threads|--toolchains|--update-snapshots|--update-plugins|--show-version|--version|--debug" local common_clean_lifecycle="pre-clean|clean|post-clean" local common_default_lifecycle="validate|initialize|generate-sources|process-sources|generate-resources|process-resources|compile|process-classes|generate-test-sources|process-test-sources|generate-test-resources|process-test-resources|test-compile|process-test-classes|test|prepare-package|package|pre-integration-test|integration-test|post-integration-test|verify|install|deploy" local common_site_lifecycle="pre-site|site|post-site|site-deploy" local common_lifecycle_phases="${common_clean_lifecycle}|${common_default_lifecycle}|${common_site_lifecycle}" local plugin_goals_appengine="appengine:backends_configure|appengine:backends_delete|appengine:backends_rollback|appengine:backends_start|appengine:backends_stop|appengine:backends_update|appengine:debug|appengine:devserver|appengine:devserver_start|appengine:devserver_stop|appengine:endpoints_get_client_lib|appengine:endpoints_get_discovery_doc|appengine:enhance|appengine:rollback|appengine:set_default_version|appengine:start_module_version|appengine:stop_module_version|appengine:update|appengine:update_cron|appengine:update_dos|appengine:update_indexes|appengine:update_queues|appengine:vacuum_indexes" local plugin_goals_android="android:apk|android:apklib|android:clean|android:deploy|android:deploy-dependencies|android:dex|android:emulator-start|android:emulator-stop|android:emulator-stop-all|android:generate-sources|android:help|android:instrument|android:manifest-update|android:pull|android:push|android:redeploy|android:run|android:undeploy|android:unpack|android:version-update|android:zipalign|android:devices" local plugin_goals_ant="ant:ant|ant:clean" local plugin_goals_antrun="antrun:run" local plugin_goals_archetype="archetype:generate|archetype:create-from-project|archetype:crawl" local plugin_goals_assembly="assembly:single|assembly:assembly" local plugin_goals_build_helper="build-helper:add-resource|build-helper:add-source|build-helper:add-test-resource|build-helper:add-test-source|build-helper:attach-artifact|build-helper:bsh-property|build-helper:cpu-count|build-helper:help|build-helper:local-ip|build-helper:maven-version|build-helper:parse-version|build-helper:regex-properties|build-helper:regex-property|build-helper:released-version|build-helper:remove-project-artifact|build-helper:reserve-network-port|build-helper:timestamp-property" local plugin_goals_buildnumber="buildnumber:create|buildnumber:create-timestamp|buildnumber:help|buildnumber:hgchangeset" local plugin_goals_cargo="cargo:start|cargo:run|cargo:stop|cargo:deploy|cargo:undeploy|cargo:help" local plugin_goals_checkstyle="checkstyle:checkstyle|checkstyle:check" local plugin_goals_cobertura="cobertura:cobertura" local plugin_goals_findbugs="findbugs:findbugs|findbugs:gui|findbugs:help" local plugin_goals_dependency="dependency:analyze|dependency:analyze-dep-mgt|dependency:analyze-duplicate|dependency:analyze-only|dependency:analyze-report|dependency:build-classpath|dependency:copy|dependency:copy-dependencies|dependency:get|dependency:go-offline|dependency:help|dependency:list|dependency:list-repositories|dependency:properties|dependency:purge-local-repository|dependency:resolve|dependency:resolve-plugins|dependency:sources|dependency:tree|dependency:unpack|dependency:unpack-dependencies" local plugin_goals_deploy="deploy:deploy-file" local plugin_goals_ear="ear:ear|ear:generate-application-xml" local plugin_goals_eclipse="eclipse:clean|eclipse:eclipse" local plugin_goals_ejb="ejb:ejb" local plugin_goals_enforcer="enforcer:enforce|enforcer:display-info" local plugin_goals_exec="exec:exec|exec:java" local plugin_goals_failsafe="failsafe:integration-test|failsafe:verify" local plugin_goals_flyway="flyway:migrate|flyway:clean|flyway:info|flyway:validate|flyway:baseline|flyway:repair" local plugin_goals_gpg="gpg:sign|gpg:sign-and-deploy-file" local plugin_goals_grails="grails:clean|grails:config-directories|grails:console|grails:create-controller|grails:create-domain-class|grails:create-integration-test|grails:create-pom|grails:create-script|grails:create-service|grails:create-tag-lib|grails:create-unit-test|grails:exec|grails:generate-all|grails:generate-controller|grails:generate-views|grails:help|grails:init|grails:init-plugin|grails:install-templates|grails:list-plugins|grails:maven-clean|grails:maven-compile|grails:maven-functional-test|grails:maven-grails-app-war|grails:maven-test|grails:maven-war|grails:package|grails:package-plugin|grails:run-app|grails:run-app-https|grails:run-war|grails:set-version|grails:test-app|grails:upgrade|grails:validate|grails:validate-plugin|grails:war" local plugin_goals_gwt="gwt:browser|gwt:clean|gwt:compile|gwt:compile-report|gwt:css|gwt:debug|gwt:eclipse|gwt:eclipseTest|gwt:generateAsync|gwt:help|gwt:i18n|gwt:mergewebxml|gwt:resources|gwt:run|gwt:run-codeserver|gwt:sdkInstall|gwt:source-jar|gwt:soyc|gwt:test" local plugin_goals_help="help:active-profiles|help:all-profiles|help:describe|help:effective-pom|help:effective-settings|help:evaluate|help:expressions|help:help|help:system" local plugin_goals_hibernate3="hibernate3:hbm2ddl|hibernate3:help" local plugin_goals_idea="idea:clean|idea:idea" local plugin_goals_install="install:install-file" local plugin_goals_jacoco="jacoco:check|jacoco:dump|jacoco:help|jacoco:instrument|jacoco:merge|jacoco:prepare-agent|jacoco:prepare-agent-integration|jacoco:report|jacoco:report-integration|jacoco:restore-instrumented-classes" local plugin_goals_javadoc="javadoc:javadoc|javadoc:jar|javadoc:aggregate" local plugin_goals_jboss="jboss:start|jboss:stop|jboss:deploy|jboss:undeploy|jboss:redeploy" local plugin_goals_jboss_as="jboss-as:add-resource|jboss-as:deploy|jboss-as:deploy-only|jboss-as:deploy-artifact|jboss-as:redeploy|jboss-as:redeploy-only|jboss-as:undeploy|jboss-as:undeploy-artifact|jboss-as:run|jboss-as:start|jboss-as:shutdown|jboss-as:execute-commands" local plugin_goals_jetty="jetty:run|jetty:run-war|jetty:run-exploded|jetty:deploy-war|jetty:run-forked|jetty:start|jetty:stop|jetty:effective-web-xml" local plugin_goals_jxr="jxr:jxr" local plugin_goals_license="license:format|license:check" local plugin_goals_liquibase="liquibase:changelogSync|liquibase:changelogSyncSQL|liquibase:clearCheckSums|liquibase:dbDoc|liquibase:diff|liquibase:dropAll|liquibase:help|liquibase:migrate|liquibase:listLocks|liquibase:migrateSQL|liquibase:releaseLocks|liquibase:rollback|liquibase:rollbackSQL|liquibase:status|liquibase:tag|liquibase:update|liquibase:updateSQL|liquibase:updateTestingRollback" local plugin_goals_nexus_staging="nexus-staging:close|nexus-staging:deploy|nexus-staging:deploy-staged|nexus-staging:deploy-staged-repository|nexus-staging:drop|nexus-staging:help|nexus-staging:promote|nexus-staging:rc-close|nexus-staging:rc-drop|nexus-staging:rc-list|nexus-staging:rc-list-profiles|nexus-staging:rc-promote|nexus-staging:rc-release|nexus-staging:release" local plugin_goals_pmd="pmd:pmd|pmd:cpd|pmd:check|pmd:cpd-check" local plugin_goals_properties="properties:read-project-properties|properties:write-project-properties|properties:write-active-profile-properties|properties:set-system-properties" local plugin_goals_release="release:clean|release:prepare|release:rollback|release:perform|release:stage|release:branch|release:update-versions" local plugin_goals_repository="repository:bundle-create|repository:bundle-pack|repository:help" local plugin_goals_scala="scala:add-source|scala:cc|scala:cctest|scala:compile|scala:console|scala:doc|scala:doc-jar|scala:help|scala:run|scala:script|scala:testCompile" local plugin_goals_scm="scm:add|scm:checkin|scm:checkout|scm:update|scm:status" local plugin_goals_site="site:site|site:deploy|site:run|site:stage|site:stage-deploy" local plugin_goals_sonar="sonar:sonar|sonar:help" local plugin_goals_source="source:aggregate|source:jar|source:jar-no-fork" local plugin_goals_spotbugs="spotbugs:spotbugs|spotbugs:check|spotbugs:gui|spotbugs:help" local plugin_goals_surefire="surefire:test" local plugin_goals_tomcat6="tomcat6:help|tomcat6:run|tomcat6:run-war|tomcat6:run-war-only|tomcat6:stop|tomcat6:deploy|tomcat6:redeploy|tomcat6:undeploy" local plugin_goals_tomcat7="tomcat7:help|tomcat7:run|tomcat7:run-war|tomcat7:run-war-only|tomcat7:deploy|tomcat7:redeploy|tomcat7:undeploy" local plugin_goals_tomcat="tomcat:help|tomcat:start|tomcat:stop|tomcat:deploy|tomcat:undeploy" local plugin_goals_liberty="liberty:create-server|liberty:start-server|liberty:stop-server|liberty:run-server|liberty:deploy|liberty:undeploy|liberty:java-dump-server|liberty:dump-server|liberty:package-server" local plugin_goals_versions="versions:display-dependency-updates|versions:display-plugin-updates|versions:display-property-updates|versions:update-parent|versions:update-properties|versions:update-child-modules|versions:lock-snapshots|versions:unlock-snapshots|versions:resolve-ranges|versions:set|versions:use-releases|versions:use-next-releases|versions:use-latest-releases|versions:use-next-snapshots|versions:use-latest-snapshots|versions:use-next-versions|versions:use-latest-versions|versions:commit|versions:revert" local plugin_goals_vertx="vertx:init|vertx:runMod|vertx:pullInDeps|vertx:fatJar" local plugin_goals_war="war:war|war:exploded|war:inplace|war:manifest" local plugin_goals_spring_boot="spring-boot:run|spring-boot:repackage" local plugin_goals_jgitflow="jgitflow:feature-start|jgitflow:feature-finish|jgitflow:release-start|jgitflow:release-finish|jgitflow:hotfix-start|jgitflow:hotfix-finish|jgitflow:build-number" local plugin_goals_wildfly="wildfly:add-resource|wildfly:deploy|wildfly:deploy-only|wildfly:deploy-artifact|wildfly:redeploy|wildfly:redeploy-only|wildfly:undeploy|wildfly:undeploy-artifact|wildfly:run|wildfly:start|wildfly:shutdown|wildfly:execute-commands" local plugin_goals_formatter="formatter:format|formatter:help|formatter:validate" ## some plugin (like jboss-as) has '-' which is not allowed in shell var name, to use '_' then replace local common_plugins=$(compgen -v | grep "^plugin_goals_.*" | sed 's/plugin_goals_//g' | tr '_' '-' | tr '\n' '|') local options="-Dmaven.test.skip=true|-DskipTests|-DskipITs|-Dtest|-Dit.test|-DfailIfNoTests|-Dmaven.surefire.debug|-DenableCiProfile|-Dpmd.skip=true|-Dcheckstyle.skip=true|-Dtycho.mode=maven|-Dmaven.javadoc.skip=true|-Dgwt.compiler.skip|-Dcobertura.skip=true|-Dfindbugs.skip=true||-DperformRelease=true|-Dgpg.skip=true|-DforkCount" local profile_settings=$([[ -e ~/.m2/settings.xml ]] && grep -e "" -A 1 ~/.m2/settings.xml | grep -e ".*" | sed 's/.*//' | sed 's/<\/id>.*//g' | tr '\n' '|') local profiles="$profile_settings|" for item in ${POM_HIERARCHY[*]}; do local profile_pom=$([[ -e $item ]] && grep -e "" -A 1 $item | grep -e ".*" | sed 's/.*//' | sed 's/<\/id>.*//g' | tr '\n' '|') local profiles="$profiles|$profile_pom" done local IFS=$'|\n' if [[ $cur == -D* ]] ; then COMPREPLY=( $(compgen -S ' ' -W "$options" -- "$cur") ) elif [[ $prev == -P ]] ; then if [[ $cur == *,* ]] ; then COMPREPLY=( $(compgen -S ',' -W "$profiles" -P "${cur%,*}," -- ${cur##*,}) ) else COMPREPLY=( $(compgen -S ',' -W "$profiles" -- "$cur") ) fi elif [[ $cur == --* ]] ; then COMPREPLY=( $(compgen -W "$long_opts" -S ' ' -- "$cur") ) elif [[ $cur == -* ]] ; then COMPREPLY=( $(compgen -W "$opts" -S ' ' -- "$cur") ) elif [[ $prev == -pl ]] ; then if [[ $cur == *,* ]] ; then COMPREPLY=( $(compgen -W "$(__find_mvn_projects)" -S ',' -P "${cur%,*}," -- ${cur##*,}) ) else COMPREPLY=( $(compgen -W "$(__find_mvn_projects)" -S ',' -- "$cur") ) fi elif [[ $prev == -rf || $prev == --resume-from ]] ; then COMPREPLY=( $(compgen -d -S ' ' -- "$cur") ) elif [[ $cur == *:* ]] ; then local plugin for plugin in $common_plugins; do if [[ $cur == $plugin:* ]]; then ## note that here is an 'unreplace', see the comment at common_plugins var_name="plugin_goals_${plugin//-/_}" COMPREPLY=( $(compgen -W "${!var_name}" -S ' ' -- "$cur") ) fi done else if <<< "$common_lifecycle_phases" tr '|' '\n' | grep -q -e "^$cur" ; then COMPREPLY=( $(compgen -S ' ' -W "$common_lifecycle_phases" -- "$cur") ) elif <<< "$common_plugins" tr '|' '\n' | grep -q -e "^$cur"; then COMPREPLY=( $(compgen -S ':' -W "$common_plugins" -- "$cur") ) fi fi __ltrim_colon_completions "$cur" } complete -o default -F _mvn -o nospace mvn complete -o default -F _mvn -o nospace mvnDebug complete -o default -F _mvn -o nospace mvnw ================================================ FILE: completions/minikube.completion.sh ================================================ #! bash oh-my-bash.module # minikube (Kubernetes CLI) completion if _omb_util_command_exists minikube; then eval -- "$(minikube completion bash)" fi ================================================ FILE: completions/npm.completion.sh ================================================ #! bash oh-my-bash.module # npm (Node Package Manager) completion # https://docs.npmjs.com/cli/completion if _omb_util_command_exists npm; then eval -- "$(npm completion)" fi ================================================ FILE: completions/nvm.completion.sh ================================================ #! bash oh-my-bash.module # nvm (Node Version Manager) completion if [ "$NVM_DIR" ] && [ -r "$NVM_DIR"/bash_completion ]; then . "$NVM_DIR"/bash_completion fi ================================================ FILE: completions/oc.completion.sh ================================================ #! bash oh-my-bash.module if _omb_util_command_exists oc; then eval -- "$(oc completion bash)" fi ================================================ FILE: completions/packer.completion.sh ================================================ #! bash oh-my-bash.module # Packer (http://www.packer.io) bash completion # # This script provides bash completion for packer and supports: # # - template filename completion (*.json) in cwd # - support for basic options (i.e.. -debug) # - support for complex options (i.e. -parallel=[true|false] # # The scirpt has been successfully tested with packer-0.6.0 and the # following OS: # # - OS X 10.9 # - CentOS-6.5 # - Ubuntu 12.04 Server # # The script technically is heavily inspired by the git-completion.bash # script. Kudos to Shawn O. Pearce and all other # contributors for the inspiration and especially to the bash-completion # team in general. # # Copyright (c) 2014 IT Services Department, University of Bern # # This script is licensed under the MIT License (MIT) # For licsense details see the LICENSE file included in the repository # or read the license text at http://opensource.org/licenses/MIT. # # Generates completion reply, appending a space to possible completion words, # if necessary. # It accepts 2 arguments though the second is optional: # 1: List of possible completion words. # 2: Generate possible completion matches for this word (optional). __packercomp () { local cur_="${2-$cur}" case "$cur_" in -*=) ;; *) local c i=0 IFS=$' \t\n' for c in $1; do if [[ $c == "$cur_"* ]]; then case $c in -*=*|*.) ;; *) c="$c " ;; esac COMPREPLY[i++]="$c" fi done ;; esac } # Generates completion reply for template files in cwd. __packercomp_template_file () { local IFS=$'\n' COMPREPLY=($(compgen -S " " -A file -X '!*.json' -- "${cur}")) } # Generates completion for the build command. __packer_build () { local builders=" amazon-ebs amazon-instance amazon-chroot digitalocean docker googlecompute openstack parallels-iso parallels-pvm qemu virtualbox-iso virtualbox-ovf vmware-iso vmware-vmx" case "$cur" in -parallel=*) __packercomp "false true" "${cur##-parallel=}" return ;; -except=*) __packercomp "$builders" "${cur##-except=}" return ;; -only=*) __packercomp "$builders" "${cur##-only=}" return ;; -*) __packercomp "-debug -force -machine-readable -except= -only= -parallel= -var -var-file" return ;; *) esac __packercomp_template_file } # Generates completion for the fix command. __packer_fix () { __packercomp_template_file } # Generates completion for the inspect command. __packer_inspect () { case "$cur" in -*) __packercomp "-machine-readable" return ;; *) esac __packercomp_template_file } # Generates completion for the validate command. __packer_validate () { __packercomp_template_file } # Main function for packer completion. # # Searches for a command in $COMP_WORDS. If one is found # the appropriate function from above is called, if not # completion for global options is done. _packer_completion () { cur=${COMP_WORDS[COMP_CWORD]} # Words containing an equal sign get split into tokens in bash > 4, which # doesn't come in handy here. # This is handled here. bash < 4 does not split. _omb_util_function_exists _get_comp_words_by_ref && _get_comp_words_by_ref -n = cur COMPREPLY=() local i c=1 command= while [ $c -lt $COMP_CWORD ]; do i="${COMP_WORDS[c]}" case "$i" in -*) ;; *) command="$i"; break ;; esac ((c++)) done if [ -z "$command" ]; then case "$cur" in '-'*) __packercomp "-machine-readable --help --version" ;; *) __packercomp "build fix inspect validate" ;; esac return fi local completion_func="__packer_${command}" _omb_util_function_exists "$completion_func" && "$completion_func" } complete -o nospace -F _packer_completion packer ================================================ FILE: completions/pip.completion.sh ================================================ #! bash oh-my-bash.module # pip bash completion start _pip_completion() { COMPREPLY=( $( COMP_WORDS="${COMP_WORDS[*]}" \ COMP_CWORD=$COMP_CWORD \ PIP_AUTO_COMPLETE=1 $1 ) ) } complete -o default -F _pip_completion pip # pip bash completion end ================================================ FILE: completions/pip3.completion.sh ================================================ #! bash oh-my-bash.module # pip bash completion start _pip_completion() { COMPREPLY=( $( COMP_WORDS="${COMP_WORDS[*]}" \ COMP_CWORD=$COMP_CWORD \ PIP_AUTO_COMPLETE=1 $1 ) ) } complete -o default -F _pip_completion pip3 # pip bash completion end ================================================ FILE: completions/projects.completion.sh ================================================ #! bash oh-my-bash.module function _pj { [ -z "$PROJECT_PATHS" ] && return shift [ "$1" == "open" ] && shift local cur prev words cword _init_completion || return local IFS=$'\n' i j k compopt -o filenames local -r mark_dirs=$(_rl_enabled mark-directories && echo y) local -r mark_symdirs=$(_rl_enabled mark-symlinked-directories && echo y) for i in ${PROJECT_PATHS//:/$'\n'}; do # create an array of matched subdirs k="${#COMPREPLY[@]}" for j in $( compgen -d $i/$cur ); do if [[ ( $mark_symdirs && -h $j || $mark_dirs && ! -h $j ) && ! -d ${j#$i/} ]]; then j+="/" fi COMPREPLY[k++]=${j#$i/} done done if [[ ${#COMPREPLY[@]} -eq 1 ]]; then i=${COMPREPLY[0]} if [[ "$i" == "$cur" && $i != "*/" ]]; then COMPREPLY[0]="${i}/" fi fi return 0 } complete -F _pj -o nospace pj complete -F _pj -o nospace pjo ================================================ FILE: completions/rake.completion.sh ================================================ #! bash oh-my-bash.module # Bash completion support for Rake, Ruby Make. _omb_module_require lib:omb-completion function _omb_completion_rake { local cur _omb_completion_reassemble_breaks : if [[ -f Rakefile ]]; then local recent=$(ls -t .rake_tasks~ Rakefile **/*.rake 2> /dev/null | head -n 1) if [[ $recent != '.rake_tasks~' ]]; then rake --silent --tasks --all | cut -d " " -f 2 > .rake_tasks~ fi COMPREPLY=($(compgen -W '$(< .rake_tasks~)' -- "$cur")) fi _omb_completion_resolve_breaks } complete -o default -o nospace -F _omb_completion_rake rake ================================================ FILE: completions/salt.completion.sh ================================================ #! bash oh-my-bash.module # # The current version corresponds to the following upstream version: # https://github.com/saltstack/salt/blob/18ca4fdfa9e9c16fb10006f1221254707bece308/pkg/common/salt.bash #------------------------------------------------------------------------------ # written by David Pravec # - feel free to /msg alekibango on IRC if you want to talk about this file # TODO: check if --config|-c was used and use configured config file for queries # TODO: solve somehow completion for salt -G pythonversion:[tab] # (not sure what to do with lists) # TODO: --range[tab] -- how? # TODO: --compound[tab] -- how? # TODO: use history to extract some words, esp. if ${cur} is empty # TODO: TEST EVERYTHING a lot # TODO: is it ok to use '--timeout 2' ? function _salt_get_grains { if [[ $1 == 'local' ]]; then salt-call --log-level=error --out=txt -- grains.ls | sed 's/^.*\[//' | tr -d ",']" | sed 's:\([a-z0-9]\) :\1\: :g' else salt '*' --timeout 2 --hide-timeout --log-level=error --out=txt -- grains.ls | sed 's/^.*\[//' | tr -d ",']" | sed 's:\([a-z0-9]\) :\1\: :g' fi } function _salt_get_grain_values { if [[ $1 == 'local' ]]; then salt-call --log-level=error --out=txt -- grains.item $1 |sed 's/^\S*:\s//' |grep -v '^\s*$' else salt '*' --timeout 2 --hide-timeout --log-level=error --out=txt -- grains.item $1 |sed 's/^\S*:\s//' |grep -v '^\s*$' fi } function _salt_get_keys { local type for type in $*; do # remove header from data: salt-key --no-color -l "$type" | tail -n+2 done } function _salt_list_functions { # salt-call: get all functions on this minion # salt: get all functions on all minions # sed: remove all array overhead and convert to newline separated list # sort: chop out doubled entries, so overhead is minimal later during actual completion if [[ $1 == 'local' ]]; then salt-call --log-level=quiet --out=txt -- sys.list_functions | sed "s/^.*\[//;s/[],']//g;s/ /\n/g" | sort -u else salt '*' --timeout 2 --hide-timeout --log-level=quiet --out=txt -- sys.list_functions | sed "s/^.*\[//;s/[],']//g;s/ /\n/g" | sort -u fi } function _salt_get_coms { CACHE_DIR=$HOME/.cache/salt-$1-comp-cache_functions local _salt_cache_functions=${SALT_COMP_CACHE_FUNCTIONS:=$CACHE_DIR} local _salt_cache_timeout=${SALT_COMP_CACHE_TIMEOUT:='last hour'} if [[ ! -d $(dirname $_salt_cache_functions) ]]; then mkdir -p "$(dirname $_salt_cache_functions)" fi # Regenerate cache if timed out if [[ $(stat --format=%Z $_salt_cache_functions 2>/dev/null) -lt $(date --date="$_salt_cache_timeout" +%s) ]]; then _salt_list_functions $1 > "$_salt_cache_functions" fi # filter results, to only print the part to next dot (or end of function) sed 's/^\('"$cur"'\(\.\|[^.]*\)\)\?.*/\1/' "$_salt_cache_functions" | sort -u } function _salt { local cur prev opts pprev ppprev COMPREPLY=() cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]} if ((COMP_CWORD > 2)); then pprev=${COMP_WORDS[COMP_CWORD-2]} fi if ((COMP_CWORD > 3)); then ppprev=${COMP_WORDS[COMP_CWORD-3]} fi opts="-h --help -d --doc --documentation --version --versions-report -c \ --config-dir= -v --verbose -t --timeout= -s --static -b --batch= \ --batch-size= -E --pcre -L --list -G --grain --grain-pcre -N \ --nodegroup -R --range -C --compound -I --pillar \ --return= -a --auth= --eauth= --extended-auth= -T --make-token -S \ --ipcidr --out=pprint --out=yaml --out=overstatestage --out=json \ --out=raw --out=highstate --out=key --out=txt --no-color --out-indent= " if [[ $cur == -* ]] ; then COMPREPLY=($(compgen -W '$opts' -- "$cur")) return 0 fi # 2 special cases for filling up grain values case $pprev in -G|--grain|--grain-pcre) if [[ $cur == ":" ]]; then COMPREPLY=($(compgen -W '$(_salt_get_grain_values "$prev")')) return 0 fi ;; esac case $ppprev in -G|--grain|--grain-pcre) if [[ $prev == ":" ]]; then COMPREPLY=($(compgen -W '$(_salt_get_grain_values "$pprev")' -- "$cur")) return 0 fi ;; esac if [[ $cur == "=" && $prev == --* ]]; then cur="" fi if [[ $prev == "=" && $pprev == --* ]]; then prev=$pprev fi case $prev in -c|--config) COMPREPLY=($(compgen -f -- "$cur")) return 0 ;; salt) COMPREPLY=($(compgen -W "\'*\' \$opts \$(_salt_get_keys acc)" -- "$cur")) return 0 ;; -E|--pcre) COMPREPLY=($(compgen -W '$(_salt_get_keys acc)' -- "$cur")) return 0 ;; -G|--grain|--grain-pcre) COMPREPLY=($(compgen -W '$(_salt_get_grains)' -- "$cur")) return 0 ;; -C|--compound) COMPREPLY=() # TODO: finish this one? how? return 0 ;; -t|--timeout) COMPREPLY=($(compgen -W "1 2 3 4 5 6 7 8 9 10 15 20 30 40 60 90 120 180" -- "$cur")) return 0 ;; -b|--batch|--batch-size) COMPREPLY=($(compgen -W "1 2 3 4 5 6 7 8 9 10 15 20 30 40 50 60 70 80 90 100 120 150 200")) return 0 ;; -N|--nodegroup) local MASTER_CONFIG='/etc/salt/master' local all=$(awk -F ':' 'BEGIN {print_line = 0}; /^nodegroups/ {print_line = 1;getline } print_line && /^ */ {print $1} /^[^ ]/ {print_line = 0}' < "$MASTER_CONFIG") COMPREPLY=($(compgen -W '$all' -- "$cur")) return 0 ;; esac local _salt_coms=$(_salt_get_coms remote) # If there are still dots in the suggestion, do not append space grep "^$cur.*\." "$_salt_coms" &>/dev/null && compopt -o nospace local all="$opts $_salt_coms" COMPREPLY=($(compgen -W '$all' -- "$cur")) return 0 } complete -F _salt salt function _saltkey { local cur prev opts prev pprev COMPREPLY=() cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]} opts="-c --config-dir= -h --help --version --versions-report -q --quiet \ -y --yes --gen-keys= --gen-keys-dir= --keysize= --key-logfile= \ -l --list= -L --list-all -a --accept= -A --accept-all \ -r --reject= -R --reject-all -p --print= -P --print-all \ -d --delete= -D --delete-all -f --finger= -F --finger-all \ --out=pprint --out=yaml --out=overstatestage --out=json --out=raw \ --out=highstate --out=key --out=txt --no-color --out-indent= " if ((COMP_CWORD > 2)); then pprev=${COMP_WORDS[COMP_CWORD-2]} fi if ((COMP_CWORD > 3)); then ppprev=${COMP_WORDS[COMP_CWORD-3]} fi if [[ $cur == -* ]] ; then COMPREPLY=($(compgen -W '$opts' -- "$cur")) return 0 fi if [[ $cur == "=" && $prev == --* ]]; then cur="" fi if [[ $prev == "=" && $pprev == --* ]]; then prev=$pprev fi case $prev in -a|--accept) COMPREPLY=($(compgen -W '$(_salt_get_keys un rej)' -- "$cur")) return 0 ;; -r|--reject) COMPREPLY=($(compgen -W '$(_salt_get_keys acc)' -- "$cur")) return 0 ;; -d|--delete) COMPREPLY=($(compgen -W '$(_salt_get_keys acc un rej)' -- "$cur")) return 0 ;; -c|--config) COMPREPLY=($(compgen -f -- "$cur")) return 0 ;; --keysize) COMPREPLY=($(compgen -W "2048 3072 4096 5120 6144" -- "$cur")) return 0 ;; --gen-keys) return 0 ;; --gen-keys-dir) COMPREPLY=($(compgen -d -- "$cur")) return 0 ;; -p|--print) COMPREPLY=($(compgen -W '$(_salt_get_keys acc un rej)' -- "$cur")) return 0 ;; -l|--list) COMPREPLY=($(compgen -W "pre un acc accepted unaccepted rej rejected all" -- "$cur")) return 0 ;; --accept-all) return 0 ;; esac COMPREPLY=($(compgen -W '$opts' -- "$cur")) return 0 } complete -F _saltkey salt-key function _saltcall { local cur prev opts pprev ppprev COMPREPLY=() cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]} opts="-h --help -d --doc --documentation --version --versions-report \ -m --module-dirs= -g --grains --return= --local -c --config-dir= -l --log-level= \ --out=pprint --out=yaml --out=overstatestage --out=json --out=raw \ --out=highstate --out=key --out=txt --no-color --out-indent= " if ((COMP_CWORD > 2)); then pprev=${COMP_WORDS[COMP_CWORD-2]} fi if ((COMP_CWORD > 3)); then ppprev=${COMP_WORDS[COMP_CWORD-3]} fi if [[ $cur == -* ]] ; then COMPREPLY=($(compgen -W '$opts' -- "$cur")) return 0 fi if [[ $cur == "=" && $prev == --* ]]; then cur="" fi if [[ $prev == "=" && $pprev == --* ]]; then prev=$pprev fi case $prev in -m|--module-dirs) COMPREPLY=($(compgen -d -- "$cur")) return 0 ;; -l|--log-level) COMPREPLY=($(compgen -W "info none garbage trace warning error debug" -- "$cur")) return 0 ;; -g|grains) return 0 ;; salt-call) COMPREPLY=($(compgen -W '$opts' -- "$cur")) return 0 ;; esac local _salt_coms=$(_salt_get_coms local) # If there are still dots in the suggestion, do not append space grep "^$cur.*\." "$_salt_coms" &>/dev/null && compopt -o nospace COMPREPLY=($(compgen -W '$opts $_salt_coms' -- "$cur")) return 0 } complete -F _saltcall salt-call function _saltcp { local cur prev opts target prefpart postpart helper filt pprev ppprev COMPREPLY=() cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]} opts="-t --timeout= -s --static -b --batch= --batch-size= \ -h --help --version --versions-report -c --config-dir= \ -E --pcre -L --list -G --grain --grain-pcre -N --nodegroup \ -R --range -C --compound -I --pillar \ --out=pprint --out=yaml --out=overstatestage --out=json --out=raw \ --out=highstate --out=key --out=txt --no-color --out-indent= " if [[ $cur == -* ]] ; then COMPREPLY=($(compgen -W '$opts' -- "$cur")) return 0 fi if [[ $cur == "=" && $prev == --* ]]; then cur="" fi if [[ $prev == "=" && $pprev == --* ]]; then prev=$pprev fi case $prev in salt-cp) COMPREPLY=($(compgen -W '$opts $(_salt_get_keys acc)' -- "$cur")) return 0 ;; -t|--timeout) # those numbers are just a hint COMPREPLY=($(compgen -W "2 3 4 8 10 15 20 25 30 40 60 90 120 180 240 300" -- "$cur")) return 0 ;; -E|--pcre) COMPREPLY=($(compgen -W '$(_salt_get_keys acc)' -- "$cur")) return 0 ;; -L|--list) # IMPROVEMENTS ARE WELCOME prefpart=${cur%,*}, postpart=${cur##*,} filt="^\($(sed 's:,:\\|:g' <<< "$cur")\)$" helper=($(_salt_get_keys acc | grep -v "$filt" | sed "s/^/$prefpart/")) COMPREPLY=($(compgen -W '"${helper[@]}"' -- "$cur")) return 0 ;; -G|--grain|--grain-pcre) COMPREPLY=($(compgen -W '$(_salt_get_grains)' -- "$cur")) return 0 ;; # FIXME -R|--range) # FIXME ?? return 0 ;; -C|--compound) # FIXME ?? return 0 ;; -c|--config) COMPREPLY=($(compgen -f -- "$cur")) return 0 ;; esac # default is using opts: COMPREPLY=($(compgen -W '$opts' -- "$cur")) } complete -F _saltcp salt-cp ================================================ FILE: completions/sdkman.completion.sh ================================================ #! bash oh-my-bash.module # # This probably originates from Bash-it. #------------------------------------------------------------------------------ if ! declare -F __sdkman_build_version_csv &>/dev/null; then # @fn __sdkman_build_version_csv # Copyright 2021 Marco Vermeulen. # Licensed under the Apache License, Version 2.0 (the "License"); # # This function was taken from "main/bash/sdkman-list.sh @ # sdkman/sdkman-cli". # https://github.com/sdkman/sdkman-cli/blob/19e5c081297d6a8d1ce8a8b54631bb3f8e8e861b/src/main/bash/sdkman-list.sh#L51 function __sdkman_build_version_csv { local candidate=$1 local versions_csv="" if [[ -d $SDKMAN_CANDIDATES_DIR/$candidate ]]; then for version in $(find "$SDKMAN_CANDIDATES_DIR/$candidate" -maxdepth 1 -mindepth 1 \( -type l -o -type d \) -exec basename '{}' \; | sort -r); do if [[ $version != 'current' ]]; then versions_csv=$version,$versions_csv fi done versions_csv=${versions_csv%?} fi _omb_util_print "$versions_csv" } fi function _omb_completion_sdkman { local cur=${COMP_WORDS[COMP_CWORD]} COMPREPLY=() if ((COMP_CWORD == 1)); then COMPREPLY=($(compgen -W "install uninstall rm list ls use current outdated version default selfupdate broadcast offline help flush" -- "$cur")) elif ((COMP_CWORD == 2)); then case ${COMP_WORDS[COMP_CWORD-1]} in "install" | "uninstall" | "rm" | "list" | "ls" | "use" | "current" | "outdated") local candidates candidates=$(tr ',' ' ' <<< "$SDKMAN_CANDIDATES_CSV") COMPREPLY=($(compgen -W "$candidates" -- "$cur")) ;; "offline") COMPREPLY=($(compgen -W "enable disable" -- "$cur")) ;; "selfupdate") COMPREPLY=($(compgen -W "force" -P "[" -S "]" -- "$cur")) ;; "flush") COMPREPLY=($(compgen -W "candidates broadcast archives temp" -- "$cur")) ;; *) ;; esac elif ((COMP_CWORD == 3)); then case ${COMP_WORDS[COMP_CWORD-2]} in "install" | "uninstall" | "rm" | "use" | "default") local candidate_versions _omb_completion_sdkman__candidate_versions "${COMP_WORDS[COMP_CWORD-1]}" COMPREPLY=($(compgen -W "$candidate_versions" -- "$cur")) ;; *) ;; esac fi return 0 } function _omb_completion_sdkman__candidate_versions { local local_versions=$(_omb_completion_sdkman__cleanup_local_versions "$1") if [[ $SDKMAN_OFFLINE_MODE == "true" ]]; then candidate_versions=$local_versions else local online_versions=$(curl -s "$SDKMAN_SERVICE/candidates/$1" | tr ',' ' ') candidate_versions="$(printf '%s\n' $online_versions $local_versions | sort -u) " fi } function _omb_completion_sdkman__cleanup_local_versions { __sdkman_build_version_csv "$1" tr ',' ' ' <<< "$CSV" } complete -F _omb_completion_sdkman sdk ================================================ FILE: completions/ssh.completion.sh ================================================ #! bash oh-my-bash.module # Bash completion support for ssh. _omb_module_require lib:omb-completion function _omb_completion_ssh { local cur _omb_completion_reassemble_breaks : local -a options if [[ $cur == *@* ]] ; then options=(-P "${cur%%@*}@" -- "${cur#*@}") else options=(-- "$cur") fi local IFS=$'\n' local -a config_files=() local base_config_file for base_config_file in ~/.ssh/config /etc/ssh/ssh_config; do # parse all defined hosts from config file if [[ -r $base_config_file ]]; then local basedir basedir=${base_config_file%/*} config_files+=("$base_config_file") # check if config file contains Include options local -a include_patterns _omb_util_split include_patterns "$(awk -F' ' '/^Include/{print $2}' "$base_config_file" 2>/dev/null)" $'\n' local i for i in "${!include_patterns[@]}"; do # relative or absolute path, if relative transforms to absolute [[ ${include_patterns[i]} == /* ]] || include_patterns[i]=$basedir/${include_patterns[i]} done # interpret possible globbing local -a include_files _omb_util_glob_expand include_files '${include_patterns[*]}' local include_file for include_file in "${include_files[@]}";do # parse all defined hosts from that file [[ -s $include_file ]] && config_files+=("$include_file") done fi done if ((${#config_files[@]} != 0)); then COMPREPLY+=($(compgen -W "$(awk ' sub(/^[ \t]*[Hh][Oo][Ss][Tt]([Nn][Aa][Mm][Ee])?[ \t=]+/, "") { n = split($0, fields, /[ \t]+/); for (i = 1; i <= n; i++) if (fields[i] != "" && !visited[fields[i]]++) print fields[i]; }' "${config_files[@]}")" "${options[@]}") ) fi local -a known_hosts_files=() local known_hosts_file for known_hosts_file in ~/.ssh/known_hosts /etc/ssh/ssh_known_hosts; do if [[ -r $known_hosts_file ]]; then known_hosts_files+=("$known_hosts_file") fi done if ((${#known_hosts_files[@]} != 0)); then COMPREPLY+=($(compgen -W "$(awk ' $1 !~ /^\|/ { gsub(/[][]|[,:].*/, "", $1); if ($1 !~ /ssh-rsa/) print $1; }' "${known_hosts_files[@]}")" "${options[@]}")) fi # parse hosts defined in /etc/hosts if [[ -r /etc/hosts ]]; then COMPREPLY+=($(compgen -W "$(grep -v '^[[:space:]]*$' /etc/hosts | grep -v '^#' | awk '{for (i=2; i<=NF; i++) print $i}' )" "${options[@]}")) fi _omb_completion_resolve_breaks } complete -o default -o nospace -F _omb_completion_ssh ssh scp ================================================ FILE: completions/svn.completion.sh ================================================ #! bash oh-my-bash.module # # The completion settings are found in the following places: # * https://github.com/Luladjiev/Subversion-Bash-Complete # * https://svn.apache.org/repos/asf/subversion/trunk/tools/client-side/bash_completion # # Change history # * 2024-08-13 updated from svn.apache.org. # # ------------------------------------------------------------ # Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not use this file except in compliance # with the License. You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. # ------------------------------------------------------------ # Programmable completion for the Subversion svn command under bash. Source # this file (or on some systems add it to ~/.bash_completion and start a new # shell) and bash's completion mechanism will know all about svn's options! # Provides completion for the svnadmin, svndumpfilter, svnlook and svnsync # commands as well. Who wants to read man pages/help text... # Known to work with bash 3.* with programmable completion and extended # pattern matching enabled (use 'shopt -s extglob progcomp' to enable # these if they are not already enabled). shopt -s extglob # Tree helper functions which only use bash, to ease readability. # look for value associated to key from stdin in K/V hash file format # val=$(_svn_read_hashfile svn:realmstring < some/file) function _svn_read_hashfile() { local tkey=$1 key= val= while true; do read tag len [ $tag = 'END' ] && break [ $tag != 'K' ] && { #echo "unexpected tag '$tag' instead of 'K'" >&2 return } read -r -n $len key ; read read tag len [ $tag != 'V' ] && { #echo "unexpected tag '$tag' instead of 'V'" >&2 return } read -r -n $len val ; read if [[ $key = $tkey ]] ; then echo "$val" return fi done #echo "target key '$tkey' not found" >&2 } # _svn_grcut shell-regular-expression # extract filenames from 'svn status' output function _svn_grcut() { local re=$1 line= old_IFS # fix IFS, so that leading spaces are not ignored by next read. # (there is a leading space in svn status output if only a prop is changed) old_IFS="$IFS" IFS=$'\n' while read -r line ; do [[ ! $re || $line == $re ]] && echo "${line/????????/}" done IFS="$old_IFS" } # extract stuff from svn info output # _svn_info (URL|Repository Root) function _svn_info() { local what=$1 line= LANG=C LC_MESSAGES=C svn info --non-interactive 2> /dev/null | \ while read line ; do [[ $line == *"$what: "* ]] && echo ${line#*: } done } # broken since svn 1.7 | FIXME: change to svn status -v ? # _svn_lls (dir|file|all) files... # list svn-managed files from list # some 'svn status --all-files' would be welcome here? function _svn_lls() { local opt=$1 f= shift for f in "$@" ; do # could try to check in .svn/entries? hmmm... if [[ $opt == @(dir|all) && -d "$f" ]] ; then echo "$f/" elif [[ $opt == @(file|all) ]] ; then # split f in directory/file names local dn= fn="$f" [[ "$f" == */* ]] && dn=${f%\/*}/ fn=${f##*\/} # ??? this does not work for just added files, because they # do not have a content reference yet... [ -f "${dn}.svn/text-base/${fn}.svn-base" ] && echo "$f" fi done } # try to complete TARGET # 1. [nothing] lists available protocols # 2. svn+ssh:// lists servers from .ssh/known_hosts # 3. http[s]:// lists already used svn servers # 4. file:// lists files from dir # 5. ^/ or protocol except file:/ triggers svn ls # this code expects bash 4, $cur is split by : too # # $1 'all' | 'remote_only' # return true if found something function _svn_complete_target() { # echo -e "\n_svn_complete_target: [$cur] 1:[${COMP_WORDS[COMP_CWORD]}] 2:[${COMP_WORDS[COMP_CWORD-1]}] 3:[${COMP_WORDS[COMP_CWORD-2]}] | [${COMP_WORDS[@]}] [$COMP_WORDBREAKS]" local prefix=${COMP_WORDS[COMP_CWORD-2]} local colon=${COMP_WORDS[COMP_CWORD-1]} # see about COMP_WORDBREAKS workaround in prop completion if [[ $prefix == "file" && "$colon" == ":" ]] then # file completion for file:// urls COMPREPLY=( $(compgen -d -S '/' -X '*/.*' -- $cur ) ) return elif [[ ( $1 == "all" && $cur == ^/* ) || ( "$colon" == ":" && $cur == //*/* ) ]] then # we already have a protocol and host: autocomplete for svn ls ^/bla | svn ls remote_url | svn checkout remote_url local p if [ "$colon" == ":" ] ; then p="$prefix$colon" fi if [[ $cur =~ ((.*/)([^/]*)) ]] # url = everything up to the last / then local url="${BASH_REMATCH[2]}" local path="${BASH_REMATCH[3]}" local remote_files="$(svn ls --non-interactive "$p$url" 2> /dev/null )" COMPREPLY=( $(compgen -P "$url" -W "$remote_files" -- "$path" ) ) compopt -o nospace return 0 fi elif [[ "$colon" == ":" ]] then # get known servers # svn+ssh:// if [[ $prefix == "svn+ssh" && $cur =~ (^//(.*)) ]] ; then local server_start=${BASH_REMATCH[2]} # debian & suse: /usr/share/bash-completion/bash_completion local suffix=/ _known_hosts_real -p // "$server_start" else local urls= file= for file in ~/.subversion/auth/svn.simple/* ; do if [ -r $file ] ; then local url=$(_svn_read_hashfile svn:realmstring < $file) url=${url/**/} urls="$urls $url" fi done # only suggest/show possible suffixes local suffix=$cur c= choices= for c in $urls ; do [[ $c == $prefix:* ]] && choices="$choices ${c#*:}" done COMPREPLY=( $(compgen -W "$choices" -- $suffix ) ) fi compopt -o nospace return else # show schemas if [ $1 == 'all' ] ; then COMPREPLY=( $(compgen -W "^/ $urlSchemas" -- $cur) ) else COMPREPLY=( $(compgen -W "$urlSchemas" -- $cur) ) fi compopt -o nospace return fi #echo "nothing found" return 1 } # This completion guides the command/option order along the one suggested # by "svn help", although other syntaxes are allowed. # # - there is a "real" parser to check for what is available and deduce what # can be suggested further. # - the syntax should be coherent with subversion/svn/{cl.h,main.c} # - although it is not a good practice, mixed options and arguments # is supported by the completion as it is by the svn command. # - the completion works in the middle of a line, # but not really in the middle of an argument or option. # - property names are completed: see comments about issues related to handling # ":" within property names although it is a word completion separator. # - unknown properties are assumed to be simple file properties. # - --revprop and --revision options are forced to revision properties # as they are mandatory in this case. # - argument values are suggested to some other options, eg directory names # for --config-dir. # - values for some options can be extended with environment variables: # SVN_BASH_FILE_PROPS: other properties on files/directories # SVN_BASH_REV_PROPS: other properties on revisions # SVN_BASH_ENCODINGS: encodings to be suggested # SVN_BASH_MIME_TYPE: mime types to be suggested # SVN_BASH_KEYWORDS: "svn:keywords" substitutions to be suggested # SVN_BASH_USERNAME: usernames suggested for --username # SVN_BASH_COMPL_EXT: completion extensions for file arguments, based on the # current subcommand, so that for instance only modified files are # suggested for 'revert', only not svn-managed files for 'add', and so on. # Possible values are: # - username: guess usernames from ~/.subversion/auth/... # - urls: guess urls from ~/.subversion/auth/... or others # - svnstatus: use 'svn status' for completion # - recurse: allow recursion (expensive) # - externals: recurse into externals (very expensive) # Former options are reasonable, but beware that both later options # may be unadvisable if used on large working copies. # None of these costly completions are activated by default. # Argument completion outside a working copy results in an error message. # Filenames with spaces are not completed properly. # # TODO # - other options? # - obsolete options could be removed from auto-comp? (e.g. -N) # - obsolete commands could be removed? (e.g. resolved) # - completion does not work properly when editing in the middle of the line # status/previous are those at the end of the line, not at the entry position # - url completion should select more cases where it is relevant # - url completion of http:// schemas could suggest sub directories? # - add completion for experimental 'obliterate' feature? _svn() { local cur cmds cmdOpts pOpts mOpts rOpts qOpts nOpts optsParam opt COMPREPLY=() cur=${COMP_WORDS[COMP_CWORD]} # Possible expansions, without pure-prefix abbreviations such as "up". cmds='add auth blame annotate praise cat changelist cl checkout co cleanup' cmds="$cmds commit ci copy cp delete remove rm diff export help import" cmds="$cmds info list ls lock log merge mergeinfo mkdir move mv rename" cmds="$cmds patch propdel pdel propedit pedit propget pget proplist" cmds="$cmds plist propset pset relocate resolve resolved revert status" cmds="$cmds switch unlock update upgrade" cmds="$cmds x-shelf-diff x-shelf-drop x-shelf-list x-shelf-list-by-paths" cmds="$cmds x-shelf-log x-shelf-save x-shelve x-shelves x-unshelve" # help options have a strange command status... local helpOpts='--help -h' # all special options that have a command status local specOpts="--version $helpOpts" # options that require a parameter # note: continued lines must end '|' continuing lines must start '|' optsParam="-r|--revision|--username|--password|--targets" optsParam="$optsParam|-x|--extensions|-m|--message|-F|--file" optsParam="$optsParam|--encoding|--diff-cmd|--diff3-cmd|--editor-cmd" optsParam="$optsParam|--old|--new|--config-dir|--config-option" optsParam="$optsParam|--native-eol|-l|--limit|-c|--change" optsParam="$optsParam|--depth|--set-depth|--with-revprop" optsParam="$optsParam|--cl|--changelist|--accept|--show-revs" optsParam="$optsParam|--show-item" # svn:* and other (env SVN_BASH_*_PROPS) properties local svnProps revProps allProps psCmds propCmds # svn and user configured "file" (or directory) properties # the "svn:mergeinfo" prop is not included by default because it is # managed automatically, so there should be no need to edit it by hand. svnProps="svn:keywords svn:executable svn:needs-lock svn:externals svn:ignore svn:eol-style svn:mime-type $SVN_BASH_FILE_PROPS" # svn and user configured revision properties revProps="svn:author svn:log svn:date $SVN_BASH_REV_PROPS" # all properties as an array variable allProps=( $svnProps $revProps ) # subcommands that expect property names psCmds='propset|pset|ps' propCmds="$psCmds|propget|pget|pg|propedit|pedit|pe|propdel|pdel|pd" # possible URL schemas to access a subversion server local urlSchemas='file:/// http:// https:// svn:// svn+ssh://' # Parse arguments and set various variables about what was found. # # cmd: the current command if available # isPropCmd: whether it expects a property name argument # isPsCmd: whether it also expects a property value argument # isHelpCmd: whether it is about help # nExpectArgs: how many arguments are expected by the command # help: help requested about this command (if cmd=='help') # prop: property name (if appropriate) # isRevProp: is it a special revision property # val: property value (if appropriate, under pset) # options: all options encountered # hasRevPropOpt: is --revprop set # hasRevisionOpt: is --revision set # hasRelocateOpt: is --relocate set # hasReintegrateOpt: is --reintegrate set # acceptOpt: the value of --accept # nargs: how many arguments were found # stat: status of parsing at the 'current' word # # prev: previous command in the loop # last: status of last parameter analyzed # i: index local cmd= isPropCmd= isPsCmd= isHelpCmd= nExpectArgs= isCur= i=0 local prev= help= prop= val= isRevProp= last='none' nargs=0 stat= local options= hasRevPropOpt= hasRevisionOpt= hasRelocateOpt= local acceptOpt= URL= hasReintegrateOpt= for opt in "${COMP_WORDS[@]}" do # get status of current word (from previous iteration) [[ $isCur ]] && stat=$last # are we processing the current word isCur= [[ $i -eq $COMP_CWORD ]] && isCur=1 let i++ # FIRST must be the "svn" command [ $last = 'none' ] && { last='first'; continue ; } # SKIP option arguments if [[ $prev == @($optsParam) ]] ; then # record accept value [[ $prev = '--accept' ]] && acceptOpt=$opt prev='' last='skip' continue ; fi # Argh... This looks like a bash bug... # Redirections are passed to the completion function # although it is managed by the shell directly... # It matters because we want to tell the user when no more # completion is available, so it does not necessary # fallback to the default case. if [[ $prev == @(<|>|>>|[12]>|[12]>>) ]] ; then prev='' last='skip' continue ; fi prev=$opt # get the subCoMmanD if [[ ! $cmd && $opt \ && ( $opt != -* || $opt == @(${specOpts// /|}) ) ]] then cmd=$opt [[ $cmd == @($propCmds) ]] && isPropCmd=1 [[ $cmd == @($psCmds) ]] && isPsCmd=1 [[ $cmd == @(${helpOpts// /|}) ]] && cmd='help' [[ $cmd = 'help' ]] && isHelpCmd=1 # HELP about a command asked with an option if [[ $isHelpCmd && $cmd && $cmd != 'help' && ! $help ]] then help=$cmd cmd='help' fi last='cmd' continue fi # HELP about a command if [[ $isHelpCmd && ! $help && $opt && $opt != -* ]] then help=$opt last='help' continue fi # PROPerty name if [[ $isPropCmd && ! $prop && $opt && $opt != -* ]] then prop=$opt [[ $prop == @(${revProps// /|}) ]] && isRevProp=1 last='prop' continue fi # property VALue if [[ $isPsCmd && $prop && ! $val && $opt != -* ]] ; then val=$opt last='val' continue fi if [[ $last != 'onlyarg' ]] then # more OPTions case $opt in -r|--revision|--revision=*) hasRevisionOpt=1 ;; --revprop) hasRevPropOpt=1 # restrict to revision properties! allProps=( $revProps ) # on revprops, only one URL is expected nExpectArgs=1 ;; -h|--help) isHelpCmd=1 ;; -F|--file) val='-F' ;; --relocate) hasRelocateOpt=1 ;; --reintegrate) hasReintegrateOpt=1 ;; esac # no more options, only arguments, whatever they look like. if [[ $opt = '--' && ! $isCur ]] ; then last='onlyarg' continue fi # options are recorded... if [[ $opt == -* ]] ; then # but not the current one! [[ ! $isCur ]] && options="$options $opt " last='opt' continue fi else # onlyarg let nargs++ continue fi # then we have an argument if [[ $cmd = 'merge' && ! $URL ]] ; then # first argument is the source URL for the merge URL=$opt fi last='arg' let nargs++ done # end opt option processing... [[ $stat ]] || stat=$last # suggest all subcommands, including special help if [[ ! $cmd || $stat = 'cmd' ]] then COMPREPLY=( $( compgen -W "$cmds $specOpts" -- $cur ) ) return 0 fi # suggest all subcommands if [[ $stat = 'help' || ( $isHelpCmd && ! $help ) ]] then COMPREPLY=( $( compgen -W "$cmds" -- $cur ) ) return 0 fi # URL completion if [[ $cmd == @(co|checkout|ls|list) && $stat = 'arg' && \ $SVN_BASH_COMPL_EXT == *urls* ]] then if [[ $cmd == @(ls|list) ]] ; then _svn_complete_target 'all' && return else _svn_complete_target 'remote_only' && return fi fi if [[ $cmd = 'merge' || $cmd = 'mergeinfo' ]] then local here=$(_svn_info URL) # suggest a possible URL for merging if [[ ! $URL && $stat = 'arg' ]] ; then # we assume a 'standard' repos with branches and trunk if [[ "$here" == */branches/* ]] ; then # we guess that it is a merge from the trunk COMPREPLY=( $(compgen -W ${here/\/branches\/*/\/trunk} -- $cur ) ) return 0 elif [[ "$here" == */trunk* ]] ; then # we guess that it is a merge from a branch COMPREPLY=( $(compgen -W ${here/\/trunk*/\/branches\/} -- $cur ) ) compopt -o nospace return 0 else # no se, let us suggest the repository root... COMPREPLY=( $(compgen -W $(_svn_info Root)/ -- $cur ) ) compopt -o nospace return 0 fi # this part is broken with bash 4 URL contains https only elif [[ $URL == */branches/* && $here == */trunk* && \ ! $hasReintegrateOpt && $cur = '' && $stat = 'arg' ]] ; then # force --reintegrate only if the current word is empty COMPREPLY=( $(compgen -W '--reintegrate' -- $cur ) ) return 0 # autocomplete for svn merge ^/bla else _svn_complete_target 'all' && return fi fi # help about option arguments if [[ $stat = 'skip' ]] then local previous=${COMP_WORDS[COMP_CWORD-1]} local values= dirs= beep= exes= [[ $previous = '--config-dir' ]] && dirs=1 # external editor, diff, diff3... [[ $previous = --*-cmd ]] && exes=1 [[ $previous = '--native-eol' ]] && values='LF CR CRLF' # just to suggest that a number is expected. hummm. [[ $previous = '--limit' ]] && values='0 1 2 3 4 5 6 7 8 9' # some special partial help about --revision option. [[ $previous = '--revision' || $previous = '-r' ]] && \ values='HEAD BASE PREV COMMITTED 0 {' [[ $previous = '--encoding' ]] && \ values="latin1 utf8 $SVN_BASH_ENCODINGS" [[ $previous = '--extensions' || $previous = '-x' ]] && \ values="--unified --ignore-space-change \ --ignore-all-space --ignore-eol-style --show-c-functions" [[ $previous = '--depth' ]] && \ values='empty files immediates infinity' [[ $previous = '--set-depth' ]] && \ values='empty exclude files immediates infinity' [[ $previous = '--accept' ]] && \ { # the list is different for 'resolve' if [[ $cmd = 'resolve' ]] ; then # from svn help resolve values='base working mine-full theirs-full' else # checkout merge switch update values="postpone base mine-full theirs-full edit launch \ mine-conflict theirs-conflict" fi } [[ $previous = '--show-revs' ]] && values='merged eligible' [[ $previous = '--show-item' ]] && values="kind url relative-url \ repos-root-url repos-uuid revision last-changed-revision \ last-changed-date last-changed-author wc-root" if [[ $previous = '--username' ]] ; then values="$SVN_BASH_USERNAME" if [[ $SVN_BASH_COMPL_EXT == *username* ]] ; then local file= # digest? others? for file in ~/.subversion/auth/svn.simple/* ; do if [ -r $file ] ; then values="$values $(_svn_read_hashfile username < $file)" fi done fi [[ ! "$values" ]] && beep=1 fi # could look at ~/.subversion/ ? # hmmm... this option should not exist [[ $previous = '--password' ]] && beep=1 # TODO: provide help about other options such as: # --old --new --with-revprop # if the previous option required a parameter, do something # or fallback on ordinary filename expansion [[ $values ]] && COMPREPLY=( $( compgen -W "$values" -- $cur ) ) [[ $dirs ]] && COMPREPLY=( $( compgen -o dirnames -- $cur ) ) [[ $exes ]] && COMPREPLY=( $( compgen -c -- $cur ) ) [[ $beep ]] && { # 'no known completion'. hummm. echo -en "\a" COMPREPLY=( '' ) } return 0 fi # provide allowed property names after property commands if [[ $isPropCmd && ( ! $prop || $stat = 'prop' ) && $cur != -* ]] then # # Ok, this part is pretty ugly. # # The issue is that ":" is a completion word separator, # which is a good idea for file:// urls but not within # property names... # # The first idea was to remove locally ":" from COMP_WORDBREAKS # and then put it back in all cases but in property name # completion. It does not always work. There is a strange bug # where one may get "svn:svn:xxx" in some unclear cases. # # Thus the handling is reprogrammed here... # The code assumes that property names look like *:*, # but it also works reasonably well with simple names. # # This hack is broken in bash4... not sure what to do about it, # especially while keeping the bash3 compatibility:-( local choices= if [[ $cur == *:* ]] then # only suggest/show possible suffixes local prefix=${cur%:*} suffix=${cur#*:} c= for c in ${allProps[@]} ; do [[ $c == $prefix:* ]] && choices="$choices ${c#*:}" done # everything will be appended to the prefix because ':' is # a separator, so cur is restricted to the suffix part. cur=$suffix else # only one choice is fine COMPREPLY=( $( compgen -W "${allProps[*]}" -- $cur ) ) [ ${#COMPREPLY[@]} -eq 1 ] && return 0 # no ':' so only suggest prefixes? local seen= n=0 last= c= for c in ${allProps[@]%:*} ; do # do not put the same prefix twice... if [[ $c == $cur* && ( ! $seen || $c != @($seen) ) ]] then let n++ last=$c choices="$choices $c:" if [[ $seen ]] then seen="$seen|$c*" else seen="$c*" fi fi done # supply two choices to force a partial completion and a beep [[ $n -eq 1 ]] && choices="$last:1 $last:2" fi COMPREPLY=( $( compgen -W "$choices" -- $cur ) ) return 0 fi # force mandatory --revprop option on revision properties if [[ $isRevProp && ! $hasRevPropOpt ]] then COMPREPLY=( $( compgen -W '--revprop' -- $cur ) ) return 0 fi # force mandatory --revision option on revision properties if [[ $isRevProp && $hasRevPropOpt && ! $hasRevisionOpt ]] then COMPREPLY=( $( compgen -W '--revision' -- $cur ) ) return 0 fi # possible completion when setting property values if [[ $isPsCmd && $prop && ( ! $val || $stat = 'val' ) ]] then # ' is a reminder for an arbitrary value local values="\' --file" case $prop in svn:keywords) # just a subset? values="Id Rev URL Date Author Header \' $SVN_BASH_KEYWORDS" ;; svn:executable|svn:needs-lock) # hmmm... canonical value * is special to the shell. values='\\*' ;; svn:eol-style) values='native LF CR CRLF' ;; svn:mime-type) # could read /etc/mime.types if available. overkill. values="text/ text/plain text/html text/xml text/rtf image/ image/png image/gif image/jpeg image/tiff audio/ audio/midi audio/mpeg video/ video/mpeg video/mp4 application/ application/octet-stream $SVN_BASH_MIME_TYPE" ;; esac COMPREPLY=( $( compgen -W "$values" -- $cur ) ) # special case for --file... return even if within an option [[ ${COMPREPLY} ]] && return 0 fi # maximum number of additional arguments expected in various forms case $cmd in merge) nExpectArgs=3 ;; mergeinfo) nExpectArgs=1 ;; copy|cp|move|mv|rename|ren|export|import) nExpectArgs=2 ;; switch|sw) [[ ! $hasRelocateOpt ]] && nExpectArgs=2 ;; help|h) nExpectArgs=0 ;; --version) nExpectArgs=0 ;; esac # the maximum number of arguments is reached for a command if [[ $nExpectArgs && $nargs -gt $nExpectArgs ]] then # some way to tell 'no completion at all'... is there a better one? # Do not say 'file completion' here. echo -en "\a" COMPREPLY=( '' ) return 0 fi # if not typing an option, # then fallback on filename expansion... if [[ $cur != -* || $stat = 'onlyarg' ]] ; then # do we allow possible expensive completion here? if [[ $SVN_BASH_COMPL_EXT == *svnstatus* ]] ; then # build status command and options # "--quiet" removes 'unknown' files local status='svn status --non-interactive' [[ $SVN_BASH_COMPL_EXT == *recurse* ]] || \ status="$status --non-recursive" # I'm not sure that it can work with externals in call cases # the output contains translatable sentences (even with quiet) [[ $SVN_BASH_COMPL_EXT == *externals* ]] || \ status="$status --ignore-externals" local cs= files= # subtlety: must not set $cur* if $cur is empty in some cases [[ $cur ]] && cs=$cur* # 'files' is set according to the current subcommand case $cmd in st*) # status completion must include all files files=$cur* ;; ci|commit|revert|di*) # anything edited files=$($status $cs| _svn_grcut '@([MADR!]*| M*|_M*)') ;; add) # unknown files files=$($status $cs| _svn_grcut '\?*') ;; unlock) # unlock locked files files=$($status $cs| _svn_grcut '@(??L*|?????[KOTB]*)') ;; resolve*) # files in conflict files=$($status $cs| _svn_grcut '@(?C*|C*)') ;; praise|blame|ann*) # any svn file but added files=$( _svn_lls all $cur* ) ;; p*) # prop commands if [[ $cmd == @($propCmds) && \ $prop == @(svn:ignore|svn:externals) ]] ; then # directory specific props files=$( _svn_lls dir . $cur* ) else # ??? added directories appear twice: foo foo/ files="$( _svn_lls all $cur* ) $($status $cs | _svn_grcut 'A*' )" fi ;; info) # information on any file files="$( _svn_lls all $cur* ) $($status $cs | _svn_grcut 'A*' )" ;; remove|rm|del*|move|mv|rename) # changing existing files files=$( _svn_lls all $cur* ) ;; mkdir) # completion in mkdir can only be for subdirs? files=$( _svn_lls dir $cur* ) ;; log|lock|up*|cl*|switch) # misc, all but added files files=$( _svn_lls all $cur* ) ;; merge) # may do a better job? URL/WCPATH files=$( _svn_lls all $cur* ) ;; ls|list) # better job? what about URLs? files=$( _svn_lls all $cur* ) ;; *) # other commands: changelist export import cat mergeinfo local fallback=1 ;; esac # when not recursive, some relevant files may exist # within subdirectories, so they are added here. # should it be restricted to svn-managed subdirs? no?? if [[ $SVN_BASH_COMPL_EXT != *recurse* ]] ; then files="$files $( _svn_lls dir $cur* )" fi # set completion depending on computed 'files' if [[ $files ]] ; then COMPREPLY=( $( compgen -W "$files" -- $cur ) ) # if empty, set to nope? [[ "${COMPREPLY[*]}" ]] || COMPREPLY=( '' ) elif [[ ! $fallback ]] ; then # this suggests no completion... echo -en "\a" COMPREPLY=( '' ) fi fi # else fallback to ordinary filename completion... return 0 fi # otherwise build possible options for the command pOpts="--username --password --no-auth-cache --non-interactive \ --password-from-stdin \ --trust-server-cert-failures \ --force-interactive" mOpts="-m --message -F --file --encoding --force-log --with-revprop \ --editor-cmd" rOpts="-r --revision" qOpts="-q --quiet" nOpts="-N --non-recursive --depth" gOpts="-g --use-merge-history" cOpts="--cl --changelist" cmdOpts= case $cmd in --version) cmdOpts="$qOpts" ;; add) cmdOpts="--auto-props --no-auto-props --force --targets \ --no-ignore --parents $nOpts $qOpts $pOpts" ;; auth) cmdOpts="--remove --show-passwords $pOpts" ;; blame|annotate|ann|praise) cmdOpts="$rOpts $pOpts -v --verbose --incremental --xml \ -x --extensions --force $gOpts" ;; cat) cmdOpts="$rOpts $pOpts --ignore-keywords" ;; changelist|cl) cmdOpts="--targets $pOpts $qOpts $cOpts \ -R --recursive --depth --remove" ;; checkout|co) cmdOpts="$rOpts $qOpts $nOpts $pOpts --ignore-externals \ --force --store-pristine" ;; cleanup) cmdOpts="$pOpts --include-externals -q --quiet\ --remove-ignored --remove-unversioned --vacuum-pristines" ;; commit|ci) cmdOpts="$mOpts $qOpts $nOpts --targets $pOpts \ --no-unlock $cOpts --keep-changelists \ --include-externals" ;; copy|cp) cmdOpts="$mOpts $rOpts $qOpts $pOpts --parents \ --ignore-externals --pin-externals" ;; delete|del|remove|rm) cmdOpts="--force $mOpts $qOpts --targets $pOpts \ --keep-local" ;; diff|di) cmdOpts="$rOpts -x --extensions --diff-cmd --no-diff-deleted \ $nOpts $pOpts --force --old --new --notice-ancestry \ -c --change --summarize $cOpts --xml --git \ --internal-diff --show-copies-as-adds \ --ignore-properties --properties-only --no-diff-added \ --patch-compatible" ;; export) cmdOpts="$rOpts $qOpts $pOpts $nOpts --force --native-eol \ --ignore-externals --ignore-keywords" ;; help|h|\?) cmdOpts= ;; import) cmdOpts="--auto-props --no-auto-props $mOpts $qOpts $nOpts \ --no-ignore $pOpts --force" ;; info) cmdOpts="$pOpts $rOpts --targets -R --recursive --depth \ --include-externals --incremental --xml \ --show-item --no-newline $cOpts" ;; list|ls) cmdOpts="$rOpts -v --verbose -R --recursive $pOpts \ --incremental --search --xml --depth \ --include-externals" ;; lock) cmdOpts="-m --message -F --file --encoding --force-log \ $qOpts --targets --force $pOpts" ;; log) cmdOpts="$rOpts -v --verbose --targets $pOpts --stop-on-copy \ --incremental --xml $qOpts -l --limit -c --change \ $gOpts --with-all-revprops --with-revprop --depth \ --diff --diff-cmd -x --extensions --internal-diff \ --with-no-revprops --search --search-and" ;; merge) cmdOpts="$rOpts $nOpts $qOpts --force --dry-run --diff3-cmd \ $pOpts --ignore-ancestry -c --change -x --extensions \ --record-only --accept \ --allow-mixed-revisions -v --verbose" ;; mergeinfo) cmdOpts="$rOpts $pOpts --depth --show-revs -R --recursive \ $qOpts -v --verbose --incremental --log" ;; mkdir) cmdOpts="$mOpts $qOpts $pOpts --parents" ;; move|mv|rename|ren) cmdOpts="$mOpts $qOpts --force $pOpts \ --parents --allow-mixed-revisions" ;; patch) cmdOpts="$qOpts $pOpts --dry-run --ignore-whitespace \ --reverse-diff --strip" ;; propdel|pdel|pd) cmdOpts="$qOpts -R --recursive $rOpts $pOpts $cOpts \ --depth" [[ $isRevProp || ! $prop ]] && cmdOpts="$cmdOpts --revprop" ;; propedit|pedit|pe) cmdOpts="$pOpts $mOpts --force" [[ $isRevProp || ! $prop ]] && \ cmdOpts="$cmdOpts --revprop $rOpts" ;; propget|pget|pg) cmdOpts="-v --verbose -R --recursive $rOpts --no-newline \ $pOpts $cOpts --depth --xml --show-inherited-props" [[ $isRevProp || ! $prop ]] && cmdOpts="$cmdOpts --revprop" ;; proplist|plist|pl) cmdOpts="-v --verbose -R --recursive $rOpts --revprop $qOpts \ $pOpts $cOpts --depth --xml --show-inherited-props" ;; propset|pset|ps) cmdOpts="$qOpts --targets -R --recursive \ --encoding $pOpts --force $cOpts --depth" [[ $isRevProp || ! $prop ]] && \ cmdOpts="$cmdOpts --revprop $rOpts" [[ $val ]] || cmdOpts="$cmdOpts -F --file" ;; relocate) cmdOpts="--ignore-externals $pOpts" ;; resolve) cmdOpts="--targets -R --recursive $qOpts $pOpts --accept \ --depth" ;; resolved) cmdOpts="--targets -R --recursive $qOpts $pOpts --depth" ;; revert) cmdOpts="--targets -R --recursive $qOpts $cOpts \ --depth $pOpts" ;; status|stat|st) cmdOpts="-u --show-updates -v --verbose $nOpts $qOpts $pOpts \ --no-ignore --ignore-externals --incremental --xml \ $rOpts $cOpts" ;; switch|sw) cmdOpts="$rOpts $nOpts $qOpts $pOpts --diff3-cmd \ --force --accept --ignore-externals --set-depth \ --ignore-ancestry" ;; unlock) cmdOpts="$qOpts --targets --force $pOpts" ;; update|up) cmdOpts="$rOpts $nOpts $qOpts $pOpts --diff3-cmd \ --ignore-externals --force --accept $cOpts \ --parents --editor-cmd --set-depth \ --adds-as-modification" ;; upgrade) cmdOpts="$qOpts $pOpts" ;; x-shelf-list-by-paths) cmdOpts="$pOpts" ;; x-shelf-diff) cmdOpts="$pOpts --summarize" ;; x-shelf-drop) cmdOpts="$pOpts" ;; x-shelf-list|x-shelves) cmdOpts="$qOpts $pOpts" ;; x-shelf-log) cmdOpts="$qOpts $pOpts" ;; x-shelf-save) cmdOpts="--dry-run \ --depth --targets $cOpts \ $mOpts \ $qOpts $pOpts" ;; x-shelve) cmdOpts="--keep-local --dry-run \ --depth --targets $cOpts \ $mOpts \ $qOpts $pOpts" ;; x-unshelve) cmdOpts="--drop --dry-run \ $qOpts $pOpts" ;; *) ;; esac # add options that are nearly always available [[ "$cmd" != "--version" ]] && cmdOpts="$cmdOpts $helpOpts" cmdOpts="$cmdOpts --config-dir --config-option" # --accept (edit|launch) incompatible with --non-interactive if [[ $acceptOpt == @(edit|launch) ]] ; then cmdOpts=${cmdOpts/ --non-interactive / } fi # take out options already given for opt in $options do local optBase # remove leading dashes and arguments case $opt in --*) optBase=${opt/=*/} ;; -*) optBase=${opt:0:2} ;; esac cmdOpts=" $cmdOpts " cmdOpts=${cmdOpts/ ${optBase} / } # take out alternatives and mutually exclusives case $optBase in -v) cmdOpts=${cmdOpts/ --verbose / } ;; --verbose) cmdOpts=${cmdOpts/ -v / } ;; -N) cmdOpts=${cmdOpts/ --non-recursive / } ;; --non-recursive) cmdOpts=${cmdOpts/ -N / } ;; -R) cmdOpts=${cmdOpts/ --recursive / } ;; --recursive) cmdOpts=${cmdOpts/ -R / } ;; -x) cmdOpts=${cmdOpts/ --extensions / } ;; --extensions) cmdOpts=${cmdOpts/ -x / } ;; -q) cmdOpts=${cmdOpts/ --quiet / } ;; --quiet) cmdOpts=${cmdOpts/ -q / } ;; -h) cmdOpts=${cmdOpts/ --help / } ;; --help) cmdOpts=${cmdOpts/ -h / } ;; -l) cmdOpts=${cmdOpts/ --limit / } ;; --limit) cmdOpts=${cmdOpts/ -l / } ;; -r) cmdOpts=${cmdOpts/ --revision / } ;; --revision) cmdOpts=${cmdOpts/ -r / } ;; -c) cmdOpts=${cmdOpts/ --change / } ;; --change) cmdOpts=${cmdOpts/ -c / } ;; --auto-props) cmdOpts=${cmdOpts/ --no-auto-props / } ;; --no-auto-props) cmdOpts=${cmdOpts/ --auto-props / } ;; -g) cmdOpts=${cmdOpts/ --use-merge-history / } ;; --use-merge-history) cmdOpts=${cmdOpts/ -g / } ;; -m|--message|-F|--file) cmdOpts=${cmdOpts/ --message / } cmdOpts=${cmdOpts/ -m / } cmdOpts=${cmdOpts/ --file / } cmdOpts=${cmdOpts/ -F / } ;; esac # remove help options within help subcommand if [ $isHelpCmd ] ; then cmdOpts=${cmdOpts/ -h / } cmdOpts=${cmdOpts/ --help / } fi done # provide help about available options COMPREPLY=( $( compgen -W "$cmdOpts" -- $cur ) ) return 0 } complete -F _svn -o bashdefault -o default -X '@(*/.svn|*/.svn/|.svn|.svn/)' svn _svnadmin () { local cur cmds cmdOpts optsParam opt helpCmds optBase i COMPREPLY=() cur=${COMP_WORDS[COMP_CWORD]} # Possible expansions, without pure-prefix abbreviations such as "h". cmds='build-repcache crashtest create delrevprop deltify dump dump-revprops freeze \ help hotcopy info list-dblogs list-unused-dblogs \ load load-revprops lock lslocks lstxns pack recover rev-size rmlocks \ rmtxns setlog setrevprop setuuid unlock upgrade verify --version' if [[ $COMP_CWORD -eq 1 ]] ; then COMPREPLY=( $( compgen -W "$cmds" -- $cur ) ) return 0 fi # options that require a parameter # note: continued lines must end '|' continuing lines must start '|' optsParam="-r|--revision|--parent-dir|--fs-type|-M|--memory-cache-size" optsParam="$optsParam|-F|--file|--exclude|--include" # if not typing an option, or if the previous option required a # parameter, then fallback on ordinary filename expansion helpCmds='help|--help|h|\?' if [[ ${COMP_WORDS[1]} != @($helpCmds) ]] && \ [[ "$cur" != -* ]] || \ [[ ${COMP_WORDS[COMP_CWORD-1]} == @($optsParam) ]] ; then return 0 fi cmdOpts= case ${COMP_WORDS[1]} in build-repcache) cmdOpts="-r --revision -q --quiet -M --memory-cache-size" ;; create) cmdOpts="--bdb-txn-nosync --bdb-log-keep --config-dir \ --fs-type --compatible-version" ;; deltify) cmdOpts="-r --revision -q --quiet -M --memory-cache-size" ;; dump) cmdOpts="-r --revision --incremental -q --quiet --deltas \ -M --memory-cache-size -F --file \ --exclude --include --pattern" ;; dump-revprops) cmdOpts="-r --revision -q --quiet -F --file" ;; freeze) cmdOpts="-F --file" ;; help|h|\?) cmdOpts="$cmds" ;; hotcopy) cmdOpts="--clean-logs --incremental -q --quiet" ;; load) cmdOpts="--ignore-uuid --force-uuid --parent-dir -q --quiet \ --use-pre-commit-hook --use-post-commit-hook \ --bypass-prop-validation -M --memory-cache-size \ --no-flush-to-disk --normalize-props -F --file \ --ignore-dates -r --revision" ;; load-revprops) cmdOpts="-r --revision -q --quiet -F --file \ --bypass-prop-validation --normalize-props \ --force-uuid --no-flush-to-disk" ;; lstxns) cmdOpts="-r --revision" ;; lock|unlock) cmdOpts="--bypass-hooks -q --quiet" ;; pack) cmdOpts="-M --memory-cache-size -q --quiet" ;; recover) cmdOpts="--wait" ;; rev-size) cmdOpts="-r --revision -M --memory-cache-size -q --quiet" ;; rmlocks) cmdOpts="-q --quiet" ;; rmtxns) cmdOpts="-q --quiet" ;; setlog) cmdOpts="-r --revision --bypass-hooks" ;; setrevprop|delrevprop) cmdOpts="-r --revision -t --transaction \ --use-pre-revprop-change-hook \ --use-post-revprop-change-hook" ;; verify) cmdOpts="-r --revision -t --transaction -q --quiet \ --check-normalization --keep-going \ -M --memory-cache-size --metadata-only" ;; *) ;; esac cmdOpts="$cmdOpts --help -h" # take out options already given for (( i=2; i<=$COMP_CWORD-1; ++i )) ; do opt=${COMP_WORDS[$i]} case $opt in --*) optBase=${opt/=*/} ;; -*) optBase=${opt:0:2} ;; esac cmdOpts=" $cmdOpts " cmdOpts=${cmdOpts/ ${optBase} / } # take out alternatives case $optBase in -q) cmdOpts=${cmdOpts/ --quiet / } ;; --quiet) cmdOpts=${cmdOpts/ -q / } ;; -h) cmdOpts=${cmdOpts/ --help / } ;; --help) cmdOpts=${cmdOpts/ -h / } ;; -r) cmdOpts=${cmdOpts/ --revision / } ;; --revision) cmdOpts=${cmdOpts/ -r / } ;; -t) cmdOpts=${cmdOpts/ --transaction / } ;; --transaction) cmdOpts=${cmdOpts/ -t / } ;; -F) cmdOpts=${cmdOpts/ --file / } ;; --file) cmdOpts=${cmdOpts/ -F / } ;; -M) cmdOpts=${cmdOpts/ --memory-cache-size / } ;; --memory-cache-size) cmdOpts=${cmdOpts/ --M / } ;; esac # skip next option if this one requires a parameter if [[ $opt == @($optsParam) ]] ; then ((++i)) fi done COMPREPLY=( $( compgen -W "$cmdOpts" -- $cur ) ) return 0 } complete -F _svnadmin -o bashdefault -o default svnadmin _svndumpfilter () { local cur cmds cmdOpts optsParam opt helpCmds optBase i COMPREPLY=() cur=${COMP_WORDS[COMP_CWORD]} # Possible expansions, without pure-prefix abbreviations such as "h". cmds='exclude help include --version' if [[ $COMP_CWORD -eq 1 ]] ; then COMPREPLY=( $( compgen -W "$cmds" -- $cur ) ) return 0 fi # options that require a parameter # note: continued lines must end '|' continuing lines must start '|' optsParam="--targets" # if not typing an option, or if the previous option required a # parameter, then fallback on ordinary filename expansion helpCmds='help|--help|h|\?' if [[ ${COMP_WORDS[1]} != @($helpCmds) ]] && \ [[ "$cur" != -* ]] || \ [[ ${COMP_WORDS[COMP_CWORD-1]} == @($optsParam) ]] ; then return 0 fi cmdOpts= case ${COMP_WORDS[1]} in exclude|include) cmdOpts="--drop-empty-revs --drop-all-empty-revs --renumber-revs --skip-missing-merge-sources --targets --preserve-revprops --quiet --pattern" ;; help|h|\?) cmdOpts="$cmds" ;; *) ;; esac cmdOpts="$cmdOpts --help -h" # take out options already given for (( i=2; i<=$COMP_CWORD-1; ++i )) ; do opt=${COMP_WORDS[$i]} case $opt in --*) optBase=${opt/=*/} ;; -*) optBase=${opt:0:2} ;; esac cmdOpts=" $cmdOpts " cmdOpts=${cmdOpts/ ${optBase} / } # take out alternatives case $optBase in -h) cmdOpts=${cmdOpts/ --help / } ;; --help) cmdOpts=${cmdOpts/ -h / } ;; esac # skip next option if this one requires a parameter if [[ $opt == @($optsParam) ]] ; then ((++i)) fi done COMPREPLY=( $( compgen -W "$cmdOpts" -- $cur ) ) return 0 } complete -F _svndumpfilter -o bashdefault -o default svndumpfilter _svnlook () { local cur cmds cmdOpts optsParam opt helpCmds optBase i COMPREPLY=() cur=${COMP_WORDS[COMP_CWORD]} # Possible expansions, without pure-prefix abbreviations such as "h". cmds='author cat changed date diff dirs-changed filesize help history \ info lock log propget proplist tree uuid youngest --version' if [[ $COMP_CWORD -eq 1 ]] ; then COMPREPLY=( $( compgen -W "$cmds" -- $cur ) ) return 0 fi # options that require a parameter # note: continued lines must end '|' continuing lines must start '|' optsParam="-r|--revision|-t|--transaction|-l|--limit|-x|--extensions" # if not typing an option, or if the previous option required a # parameter, then fallback on ordinary filename expansion helpCmds='help|--help|h|\?' if [[ ${COMP_WORDS[1]} != @($helpCmds) ]] && \ [[ "$cur" != -* ]] || \ [[ ${COMP_WORDS[COMP_CWORD-1]} == @($optsParam) ]] ; then return 0 fi cmdOpts= case ${COMP_WORDS[1]} in author) cmdOpts="-r --revision -t --transaction" ;; cat) cmdOpts="-r --revision -t --transaction" ;; changed) cmdOpts="-r --revision -t --transaction --copy-info" ;; date) cmdOpts="-r --revision -t --transaction" ;; diff) cmdOpts="-r --revision -t --transaction --diff-copy-from \ --no-diff-added --no-diff-deleted -x --extensions" ;; dirs-changed) cmdOpts="-r --revision -t --transaction" ;; filesize) cmdOpts="-r --revision -t --transaction" ;; help|h|\?) cmdOpts="$cmds" ;; history) cmdOpts="-r --revision -l --limit --show-ids" ;; info) cmdOpts="-r --revision -t --transaction" ;; lock) cmdOpts= ;; log) cmdOpts="-r --revision -t --transaction" ;; propget|pget|pg) cmdOpts="-r --revision -t --transaction --revprop" ;; proplist|plist|pl) cmdOpts="-r --revision -t --transaction --revprop -v --verbose --xml" ;; tree) cmdOpts="-r --revision -t --transaction --full-paths -N --non-recursive --show-ids" ;; uuid) cmdOpts= ;; youngest) cmdOpts= ;; *) ;; esac cmdOpts="$cmdOpts --help -h" # take out options already given for (( i=2; i<=$COMP_CWORD-1; ++i )) ; do opt=${COMP_WORDS[$i]} case $opt in --*) optBase=${opt/=*/} ;; -*) optBase=${opt:0:2} ;; esac cmdOpts=" $cmdOpts " cmdOpts=${cmdOpts/ ${optBase} / } # take out alternatives case $optBase in -N) cmdOpts=${cmdOpts/ --non-recursive / } ;; --non-recursive) cmdOpts=${cmdOpts/ -N / } ;; -h) cmdOpts=${cmdOpts/ --help / } ;; --help) cmdOpts=${cmdOpts/ -h / } ;; -l) cmdOpts=${cmdOpts/ --limit / } ;; --limit) cmdOpts=${cmdOpts/ -l / } ;; -r) cmdOpts=${cmdOpts/ --revision / } ;; --revision) cmdOpts=${cmdOpts/ -r / } ;; -t) cmdOpts=${cmdOpts/ --transaction / } ;; --transaction) cmdOpts=${cmdOpts/ -t / } ;; -v) cmdOpts=${cmdOpts/ --verbose / } ;; --verbose) cmdOpts=${cmdOpts/ -v / } ;; -x) cmdOpts=${cmdOpts/ --extensions / } ;; --extensions) cmdOpts=${cmdOpts/ -x / } ;; esac # skip next option if this one requires a parameter if [[ $opt == @($optsParam) ]] ; then ((++i)) fi done COMPREPLY=( $( compgen -W "$cmdOpts" -- $cur ) ) return 0 } complete -F _svnlook -o bashdefault -o default svnlook _svnsync () { local cur cmds cmdOpts optsParam opt helpCmds optBase i COMPREPLY=() cur=${COMP_WORDS[COMP_CWORD]} # Possible expansions, without pure-prefix abbreviations such as "h". cmds='copy-revprops help info initialize synchronize --version' if [[ $COMP_CWORD -eq 1 ]] ; then COMPREPLY=( $( compgen -W "$cmds" -- $cur ) ) return 0 fi # options that require a parameter # note: continued lines must end '|' continuing lines must start '|' optsParam="--config-dir|--config-option|--source-username|--source-password" optsParam="$optsParam|--sync-username|--sync-password" # if not typing an option, or if the previous option required a # parameter, then fallback on ordinary filename expansion helpCmds='help|--help|h|\?' if [[ ${COMP_WORDS[1]} != @($helpCmds) ]] && \ [[ "$cur" != -* ]] || \ [[ ${COMP_WORDS[COMP_CWORD-1]} == @($optsParam) ]] ; then return 0 fi cmdOpts= case ${COMP_WORDS[1]} in copy-revprops|initialize|init|synchronize|sync) cmdOpts="--non-interactive --no-auth-cache --trust-server-cert \ --source-username --source-password --sync-username \ --sync-password --config-dir --config-option \ -q --quiet -M --memory-cache-size" ;; help|h|\?) cmdOpts="$cmds" ;; info) cmdOpts="--non-interactive --no-auth-cache --trust-server-cert \ --source-username --source-password --sync-username \ --sync-password --config-dir --config-option" ;; *) ;; esac cmdOpts="$cmdOpts --help -h" # take out options already given for (( i=2; i<=$COMP_CWORD-1; ++i )) ; do opt=${COMP_WORDS[$i]} case $opt in --*) optBase=${opt/=*/} ;; -*) optBase=${opt:0:2} ;; esac cmdOpts=" $cmdOpts " cmdOpts=${cmdOpts/ ${optBase} / } # take out alternatives case $optBase in -h) cmdOpts=${cmdOpts/ --help / } ;; --help) cmdOpts=${cmdOpts/ -h / } ;; -q) cmdOpts=${cmdOpts/ --quiet / } ;; --quiet) cmdOpts=${cmdOpts/ -q / } ;; esac # skip next option if this one requires a parameter if [[ $opt == @($optsParam) ]] ; then ((++i)) fi done COMPREPLY=( $( compgen -W "$cmdOpts" -- $cur ) ) return 0 } complete -F _svnsync -o bashdefault -o default svnsync # reasonable completion for 'svnversion' _svnversion () { local cmdOpts=" -n --no-newline -c --committed -h --help --version " local cur=${COMP_WORDS[COMP_CWORD]} COMPREPLY=() # parse current options local options= wcpath= trailurl= last='none' stat= opt= i=-1 isCur= for opt in ${COMP_WORDS[@]} do [[ $i -eq $COMP_CWORD ]] && stat=$last let i++ # are we processing the current word? isCur= [[ $i -eq $COMP_CWORD ]] && isCur=1 # skip first command, should be 'svnversion' if [ $last = 'none' ] ; then last='first' continue fi # get options if [[ $last != 'arg' && $opt == -* ]] then # if '--' is at the current position, it means that we are looking # for '--*' options, and not the end of option processing. if [[ $opt = '--' && ! $isCur ]] then last='arg' else options="$options $opt " last='opt' fi continue fi # get arguments if [[ $opt != -* ]] then last='arg' if [[ ! $wcpath ]] then wcpath=$opt elif [[ ! $trailurl ]] then trailurl=$opt fi fi done [[ $stat ]] || stat=$last # argument part if [[ $cur != -* || $stat = 'arg' ]] then [[ $wcpath && $trailurl ]] && COMPREPLY=( '' ) return 0 fi # suggest options, and take out already given options for opt in $options do # take out options cmdOpts=${cmdOpts/ $opt / } # take out alternatives case $opt in -n) cmdOpts=${cmdOpts/ --no-newline / } ;; --no-newline) cmdOpts=${cmdOpts/ -n / } ;; -h) cmdOpts=${cmdOpts/ --help / } ;; --help) cmdOpts=${cmdOpts/ -h / } ;; -c) cmdOpts=${cmdOpts/ --committed / } ;; --committed) cmdOpts=${cmdOpts/ -c / } ;; esac done COMPREPLY=( $( compgen -W "$cmdOpts" -- $cur ) ) return 0 } # -X option does not seem to work? complete -F _svnversion -o dirnames -X '*.svn*' svnversion ================================================ FILE: completions/system.completion.sh ================================================ #! bash oh-my-bash.module # Loads the system's Bash completion modules. # If Homebrew is installed (OS X), its Bash completion modules are loaded. if [ -f /etc/bash_completion ]; then . /etc/bash_completion fi # Some distribution makes use of a profile.d script to import completion. if [ -f /etc/profile.d/bash_completion.sh ]; then . /etc/profile.d/bash_completion.sh fi if [ $(uname) = "Darwin" ] && _omb_util_command_exists brew; then BREW_PREFIX=$(brew --prefix) if [ -f "$BREW_PREFIX"/etc/bash_completion ]; then . "$BREW_PREFIX"/etc/bash_completion fi # homebrew/versions/bash-completion2 (required for projects.completion.bash) is installed to this path if [ -f "$BREW_PREFIX"/share/bash-completion/bash_completion ]; then . "$BREW_PREFIX"/share/bash-completion/bash_completion fi fi ================================================ FILE: completions/terraform.completion.sh ================================================ #! bash oh-my-bash.module # Bash Terraform completion _terraform() { local cmds cur colonprefixes cmds="apply destroy fmt get graph import init \ output plan push refresh remote show taint \ untaint validate version state" COMPREPLY=() cur=${COMP_WORDS[COMP_CWORD]} # Work-around bash_completion issue where bash interprets a colon # as a separator. # Work-around borrowed from the darcs work-around for the same # issue. colonprefixes=${cur%"${cur##*:}"} COMPREPLY=( $(compgen -W '$cmds' -- $cur)) local i=${#COMPREPLY[*]} while [ $((--i)) -ge 0 ]; do COMPREPLY[$i]=${COMPREPLY[$i]#"$colonprefixes"} done return 0 } && complete -F _terraform terraform ================================================ FILE: completions/test_kitchen.completion.sh ================================================ #! bash oh-my-bash.module function __kitchen_instance_list { # cache to .kitchen.list.yml if [[ .kitchen.yml -nt .kitchen.list.yml || .kitchen.local.yml -nt .kitchen.list.yml ]]; then # update list if config has updated kitchen list --bare > .kitchen.list.yml fi cat .kitchen.list.yml } function __kitchen_options { cur="${COMP_WORDS[COMP_CWORD]}" prev="${COMP_WORDS[COMP_CWORD-1]}" COMPREPLY=() case $prev in converge|create|destroy|diagnose|list|login|setup|test|verify) COMPREPLY=( $(compgen -W "$(__kitchen_instance_list)" -- ${cur} )) return 0 ;; driver) COMPREPLY=( $(compgen -W "create discover help" -- ${cur} )) return 0 ;; *) COMPREPLY=( $(compgen -W "console converge create destroy driver help init list login setup test verify version" -- ${cur} )) return 0 ;; esac } complete -F __kitchen_options kitchen ================================================ FILE: completions/tkn.completion.sh ================================================ #! bash oh-my-bash.module if _omb_util_command_exists tkn; then eval -- "$(tkn completion bash)" fi if _omb_util_command_exists tkn-pac; then eval -- "$(tkn-pac completion bash)" fi ================================================ FILE: completions/tmux.completion.sh ================================================ #! bash oh-my-bash.module # tmux completion # See: http://www.debian-administration.org/articles/317 for how to write more. # Usage: Put "source bash_completion_tmux.sh" into your .bashrc # Based upon the example at http://paste-it.appspot.com/Pj4mLycDE function _tmux_expand { [[ $cur != "${cur%\\}" ]] && cur=$cur'\' if [[ $cur == \~*/* ]]; then eval "cur=$cur" elif [[ $cur == \~* ]]; then cur=${cur#\~} COMPREPLY=($(compgen -P '~' -u "$cur")) ((${#COMPREPLY[@]} == 0)) fi } function _tmux_filedir { local IFS=$'\n' _tmux_expand || return 0 if [[ $1 == -d ]]; then COMPREPLY=("${COMPREPLY[@]}" $(compgen -d -- "$cur")); return 0; fi; COMPREPLY=("${COMPREPLY[@]}" $(eval "compgen -f -- \"$cur\"")) } function _tmux_complete_client { local IFS=$'\n' local cur=$1 COMPREPLY=("${COMPREPLY[@]}" $(compgen -W "$(tmux -q list-clients 2>/dev/null | cut -f 1 -d ':')" -- "${cur}") ) } function _tmux_complete_session { local IFS=$'\n' local cur=$1 COMPREPLY=("${COMPREPLY[@]}" $(compgen -W "$(tmux -q list-sessions 2>/dev/null | cut -f 1 -d ':')" -- "${cur}") ) } function _tmux_complete_window { local IFS=$'\n' local cur=$1 local session_name=$(<<< "$cur" sed 's/\\//g' | cut -d ':' -f 1) local sessions sessions="$(tmux -q list-sessions 2>/dev/null | sed -re 's/([^:]+:).*$/\1/')" if [[ $session_name ]]; then sessions="$sessions $(tmux -q list-windows -t "$session_name" 2>/dev/null | sed -re 's/^([^:]+):.*$/'"$session_name"':\1/')" fi cur=$(<<< "$cur" sed -e 's/:/\\\\:/') sessions=$(<<< "$sessions" sed -e 's/:/\\\\:/') COMPREPLY=("${COMPREPLY[@]}" $(compgen -W "$sessions" -- "$cur")) } function _tmux { local cur prev local i cmd cmd_index option option_index local opts="" COMPREPLY=() cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]} if [[ $prev == -f ]]; then _tmux_filedir else # Search for the command local skip_next=0 for ((i = 1; i <= COMP_CWORD; i++)); do if ((skip_next == 1)); then #_omb_util_print "Skipping" skip_next=0; elif [[ ${COMP_WORDS[i]} != -* ]]; then cmd=${COMP_WORDS[i]} cmd_index=$i break elif [[ ${COMP_WORDS[i]} == -f ]]; then skip_next=1 fi done # Search for the last option command skip_next=0 for ((i = 1; i <= COMP_CWORD; i++)); do if ((skip_next == 1)); then #_omb_util_print "Skipping" skip_next=0 elif [[ ${COMP_WORDS[i]} == -* ]]; then option=${COMP_WORDS[i]} option_index=$i if [[ ${COMP_WORDS[i]} == -- ]]; then break fi elif [[ ${COMP_WORDS[i]} == -f ]]; then skip_next=1 fi done if ((COMP_CWORD <= cmd_index)); then # The user has not specified a command yet COMPREPLY=("${COMPREPLY[@]}" $(compgen -W "$(tmux start-server \; list-commands | cut -d' ' -f1)" -- "$cur")) else case $cmd in attach-session|attach) case $prev in -t) _tmux_complete_session "$cur" ;; *) options="-t -d" ;; esac ;; detach-client|detach) case $prev in -t) _tmux_complete_client "$cur" ;; *) options="-t" ;; esac ;; lock-client|lockc) case $prev in -t) _tmux_complete_client "$cur" ;; *) options="-t" ;; esac ;; lock-session|locks) case $prev in -t) _tmux_complete_session "$cur" ;; *) options="-t -d" ;; esac ;; new-session|new) case $prev in -t) _tmux_complete_session "$cur" ;; -[n|d|s]) options="-d -n -s -t --" ;; *) if [[ ${COMP_WORDS[option_index]} == -- ]]; then _command_offset ${option_index} else options="-d -n -s -t --" fi ;; esac ;; refresh-client|refresh) case $prev in -t) _tmux_complete_client "$cur" ;; *) options="-t" ;; esac ;; rename-session|rename) case $prev in -t) _tmux_complete_session "$cur" ;; *) options="-t" ;; esac ;; source-file|source) _tmux_filedir ;; has-session|has|kill-session) case $prev in -t) _tmux_complete_session "$cur" ;; *) options="-t" ;; esac ;; suspend-client|suspendc) case $prev in -t) _tmux_complete_client "$cur" ;; *) options="-t" ;; esac ;; switch-client|switchc) case $prev in -c) _tmux_complete_client "$cur" ;; -t) _tmux_complete_session "$cur" ;; *) options="-l -n -p -c -t" ;; esac ;; send-keys|send) case $option in -t) _tmux_complete_window "$cur" ;; *) options="-t" ;; esac ;; esac # case $cmd fi # command specified fi # not -f if [[ $options ]]; then COMPREPLY=("${COMPREPLY[@]}" $(compgen -W "$options" -- "$cur")) fi return 0 } complete -F _tmux tmux # END tmux completion ================================================ FILE: completions/todo.completion.sh ================================================ #! bash oh-my-bash.module # link: https://github.com/ginatrapani/todo.txt-cli/blob/master/todo_completion _todo() { local cur prev opts COMPREPLY=() cur="${COMP_WORDS[COMP_CWORD]}" prev="${COMP_WORDS[COMP_CWORD-1]}" local -r OPTS="-@ -@@ -+ -++ -d -f -h -p -P -PP -a -n -t -v -vv -V -x" local -r COMMANDS="\ add a addto addm append app archive command del \ rm depri dp do help list ls listaddons listall lsa listcon \ lsc listfile lf listpri lsp listproj lsprj move \ mv prepend prep pri p replace report shorthelp" local -r MOVE_COMMAND_PATTERN='^(move|mv)$' local _todo_sh=${_todo_sh:-todo.sh} local completions if [ $COMP_CWORD -eq 1 ]; then completions="$COMMANDS $(eval TODOTXT_VERBOSE=0 $_todo_sh command listaddons) $OPTS" elif [[ $COMP_CWORD -gt 2 && ( \ "${COMP_WORDS[COMP_CWORD-2]}" =~ $MOVE_COMMAND_PATTERN || \ "${COMP_WORDS[COMP_CWORD-3]}" =~ $MOVE_COMMAND_PATTERN ) ]]; then completions=$(eval TODOTXT_VERBOSE=0 $_todo_sh command listfile) else case "$prev" in command) completions=$COMMANDS;; help) completions="$COMMANDS $(eval TODOTXT_VERBOSE=0 $_todo_sh command listaddons)";; addto|listfile|lf) completions=$(eval TODOTXT_VERBOSE=0 $_todo_sh command listfile);; -*) completions="$COMMANDS $(eval TODOTXT_VERBOSE=0 $_todo_sh command listaddons) $OPTS";; *) case "$cur" in +*) completions=$(eval TODOTXT_VERBOSE=0 $_todo_sh command listproj) COMPREPLY=( $( compgen -W "$completions" -- $cur )) [ ${#COMPREPLY[@]} -gt 0 ] && return 0 completions=$(eval 'TODOTXT_VERBOSE=0 TODOTXT_SOURCEVAR=\$DONE_FILE' $_todo_sh command listproj) ;; @*) completions=$(eval TODOTXT_VERBOSE=0 $_todo_sh command listcon) COMPREPLY=( $( compgen -W "$completions" -- $cur )) [ ${#COMPREPLY[@]} -gt 0 ] && return 0 completions=$(eval 'TODOTXT_VERBOSE=0 TODOTXT_SOURCEVAR=\$DONE_FILE' $_todo_sh command listcon) ;; *) if [[ "$cur" =~ ^[0-9]+$ ]]; then local todo=$( \ eval TODOTXT_VERBOSE=0 $_todo_sh '-@ -+ -p -x command ls "^ *${cur} "' | \ sed -e 's/^ *[0-9]\{1,\} //' -e 's/^\((.) \)\{0,1\}[0-9]\{2,4\}-[0-9]\{2\}-[0-9]\{2\} /\1/' \ -e 's/^\([xX] \)\([0-9]\{2,4\}-[0-9]\{2\}-[0-9]\{2\} \)\{1,2\}/\1/' \ -e 's/[[:space:]]*$//' \ -e '1q' \ ) [ "$todo" ] && COMPREPLY[0]="$cur # $todo" return 0 else return 0 fi ;; esac ;; esac fi COMPREPLY=( $( compgen -W "$completions" -- $cur )) return 0 } complete -F _todo todo.sh complete -F _todo t ================================================ FILE: completions/uv.completion.sh ================================================ #! bash oh-my-bash.module # uv (Python package and project manager) completion # https://docs.astral.sh/uv/reference/cli/#uv-generate-shell-completion if _omb_util_command_exists uv; then eval -- "$(uv generate-shell-completion bash)" fi ================================================ FILE: completions/vagrant.completion.sh ================================================ #! bash oh-my-bash.module # # The current version is based on the following upstream version: # https://github.com/hashicorp/vagrant/blob/9df95a200280219ae5899db6eaa2e0eff4ad1a8e/contrib/bash/completion.sh #------------------------------------------------------------------------------ # (The MIT License) # # Copyright (c) 2014 Kura # # 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. function __pwdln { pwdmod=$PWD/ itr=0 until [[ ! $pwdmod ]]; do ((itr++)) pwdmod="${pwdmod#*/}" done _omb_util_put $((itr-1)) } function __vagrantinvestigate { if [[ -f $PWD/.vagrant || -d $PWD/.vagrant ]]; then _omb_util_print "$PWD/.vagrant" return 0 else pwdmod2=$PWD for ((i = 2; i <= $(__pwdln); i++)); do pwdmod2=${pwdmod2%/*} if [[ -f $pwdmod2/.vagrant || -d $pwdmod2/.vagrant ]]; then _omb_util_print "$pwdmod2/.vagrant" return 0 fi done fi return 1 } function _vagrant { local cur=${COMP_WORDS[COMP_CWORD]} local prev=${COMP_WORDS[COMP_CWORD-1]} commands="box cloud connect destroy docker-exec docker-logs docker-run global-status halt help init list-commands login package plugin provision push rdp reload resume rsync rsync-auto share snapshot ssh ssh-config status suspend up version" if ((COMP_CWORD == 1)); then COMPREPLY=($(compgen -W "$commands" -- "$cur")) return 0 fi if ((COMP_CWORD == 2)); then case $prev in "init") local box_list=$(find "${VAGRANT_HOME:-$HOME/.vagrant.d}/boxes" -mindepth 1 -maxdepth 1 -type d -exec basename {} \; | sed -e 's/-VAGRANTSLASH-/\//') COMPREPLY=($(compgen -W "$box_list" -- "$cur")) return 0 ;; "up") vagrant_state_file=$(__vagrantinvestigate) || return 1 if [[ -d $vagrant_state_file ]]; then local vm_list=$(find "$vagrant_state_file/machines" -mindepth 1 -maxdepth 1 -type d -exec basename {} \;) fi local up_commands="\ --provision \ --no-provision \ --provision-with \ --destroy-on-error \ --no-destroy-on-error \ --parallel \ --no-parallel --provider \ --install-provider \ --no-install-provider \ -h \ --help" COMPREPLY=($(compgen -W "$up_commands $vm_list" -- "$cur")) return 0 ;; "destroy"|"ssh"|"provision"|"reload"|"halt"|"suspend"|"resume"|"ssh-config") vagrant_state_file=$(__vagrantinvestigate) || return 1 if [[ -f $vagrant_state_file ]] then running_vm_list=$(grep 'active' "$vagrant_state_file" | sed -e 's/"active"://' | tr ',' '\n' | cut -d '"' -f 2 | tr '\n' ' ') else running_vm_list=$(find "$vagrant_state_file/machines" -type f -name "id" | awk -F"/" '{print $(NF-2)}') fi COMPREPLY=($(compgen -W "$running_vm_list" -- "$cur")) return 0 ;; "box") box_commands="add help list outdated prune remove repackage update" COMPREPLY=($(compgen -W "$box_commands" -- "$cur")) return 0 ;; "cloud") cloud_commands="auth box search provider publish version" COMPREPLY=($(compgen -W "$cloud_commands" -- "$cur")) return 0 ;; "plugin") plugin_commands="install license list uninstall update" COMPREPLY=($(compgen -W "$plugin_commands" -- "$cur")) return 0 ;; "help") COMPREPLY=($(compgen -W "$commands" -- "$cur")) return 0 ;; "snapshot") snapshot_commands="delete list pop push restore save" COMPREPLY=($(compgen -W "$snapshot_commands" -- "$cur")) return 0 ;; *) ;; esac fi if ((COMP_CWORD == 3)); then action=${COMP_WORDS[COMP_CWORD-2]} case $action in "up") if [[ $prev == --no-provision ]]; then if [[ -d $vagrant_state_file ]]; then local vm_list=$(find "$vagrant_state_file/machines" -mindepth 1 -maxdepth 1 -type d -exec basename {} \;) fi COMPREPLY=($(compgen -W "$vm_list" -- "$cur")) return 0 fi ;; "box") case $prev in "remove"|"repackage") local box_list=$(find "${VAGRANT_HOME:-$HOME/.vagrant.d}/boxes" -mindepth 1 -maxdepth 1 -type d -exec basename {} \; | sed -e 's/-VAGRANTSLASH-/\//') COMPREPLY=($(compgen -W "$box_list" -- "$cur")) return 0 ;; "add") local add_commands="\ --name \ --checksum \ --checksum-type \ -c --clean \ -f --force \ " if [[ $cur == -* ]]; then COMPREPLY=($(compgen -W "$add_commands" -- "$cur")) else COMPREPLY=($(compgen -o default -- "$cur")) fi return 0 ;; *) ;; esac ;; "snapshot") case $prev in "restore"|"delete") local snapshot_list=$(vagrant snapshot list) COMPREPLY=($(compgen -W "$snapshot_list" -- "$cur")) return 0 ;; esac ;; *) ;; esac fi } complete -F _vagrant vagrant ================================================ FILE: completions/vault.completion.sh ================================================ #! bash oh-my-bash.module # # Taken from https://github.com/iljaweis/vault-bash-completion # # * 2024-08-13 Confirmed that the current version is up-to-date with the # archived version: # https://github.com/iljaweis/vault-bash-completion/blob/c42047c5bd6aca9045b7945db1c41654080076e1/vault-bash-completion.sh # # --------------------------------------------------------------------------- # vault-bash-completion # # This adds bash completions for [HashiCorp Vault](https://www.vaultproject.io/) # # see https://github.com/iljaweis/vault-bash-completion # --------------------------------------------------------------------------- function _vault_mounts { ( set -euo pipefail if ! vault mounts 2> /dev/null | awk 'NR > 1 {print $1}'; then _omb_util_print "secret" fi ) } function _vault { local VAULT_COMMANDS=$(vault 2>&1 | command grep -E '^ +' | awk '{print $1}') local cur prev if ((COMP_CWORD > 0)); then cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]} fi local line=${COMP_LINE} if [[ $prev =~ ^(policies|policy-write|policy-delete) ]]; then local policies=$(vault policies 2> /dev/null) COMPREPLY=($(compgen -W "$policies" -- $cur)) elif (($(wc -w <<< "$line") <= 2)); then if [[ $line =~ ^vault\ (read|write|delete|list)\ $ ]]; then COMPREPLY=($(compgen -W "$(_vault_mounts)" -- '')) else COMPREPLY=($(compgen -W "$VAULT_COMMANDS" -- $cur)) fi elif [[ $line =~ ^vault\ (read|write|delete|list)\ (.*)$ ]]; then path=${BASH_REMATCH[2]} if [[ $path =~ ^([^ ]+)/([^ /]*)$ ]]; then list=$(vault list -format=yaml ${BASH_REMATCH[1]} 2> /dev/null | awk '{ print $2 }') COMPREPLY=($(compgen -W "$list" -P "${BASH_REMATCH[1]}/" -- ${BASH_REMATCH[2]})) else COMPREPLY=($(compgen -W "$(_vault_mounts)" -- $path)) fi fi } complete -o default -o nospace -F _vault vault ================================================ FILE: completions/virtualbox.completion.sh ================================================ #! bash oh-my-bash.module # # This completion setting seems to originate from the following repository: # https://github.com/tfmalt/bash-completion-virtualbox # # The license is unspecified. The upstream is not active for nine years (as of # 2024-08), so we would adjust the codes by ourselves. # # Change history # # * 2017-10-10 This file was added to Oh My Bash. This is probably taken from # the following version: # https://github.com/tfmalt/bash-completion-virtualbox/blob/fb9739cfe9d2a6d0076c5423dc25393bcf6a77dd/vboxmanage_completion.bash # * 2024-08-13 The file cotnent is update to the latest upstream version based on: # https://github.com/tfmalt/bash-completion-virtualbox/blob/02df30e0b8e399b8011d95aa917caf0aafe01d27/vboxmanage_completion.bash # #------------------------------------------------------------------------------ #!/usr/bin/env bash # # Attempt at autocompletion script for vboxmanage. This scripts assumes an # alias between VBoxManage and vboxmanaage. # # Copyright (c) 2012 Thomas Malt # #alias vboxmanage="VBoxManage" complete -F _vboxmanage vboxmanage # export VBOXMANAGE_NIC_TYPES function _vboxmanage { local cur prev opts COMPREPLY=() cur="${COMP_WORDS[COMP_CWORD]}" prev="${COMP_WORDS[COMP_CWORD-1]}" # _omb_util_print "cur: |$cur|" # _omb_util_print "prev: |$prev|" case $prev in -v|--version) return 0 ;; -l|--long) opts=$(__vboxmanage_list "long") COMPREPLY=($(compgen -W "${opts}" -- ${cur})) return 0 ;; --nic[1-8]) # This is part of modifyvm subcommand opts=$(__vboxmanage_nic_types) COMPREPLY=($(compgen -W "${opts}" -- ${cur})) ;; startvm|list) opts=$(__vboxmanage_$prev) COMPREPLY=($(compgen -W "${opts}" -- ${cur})) return 0 ;; --type) COMPREPLY=($(compgen -W "gui headless" -- ${cur})) return 0 ;; gui|headless) # Done. no more completion possible return 0 ;; vboxmanage) # In case current is complete command we return emmideatly. case $cur in startvm|list|controlvm|showvminfo|modifyvm) COMPREPLY=($(compgen -W "$cur ")) return 0 ;; esac # _omb_util_print "Got vboxmanage" opts=$(__vboxmanage_default) COMPREPLY=($(compgen -W "${opts}" -- ${cur})) return 0 ;; -q|--nologo) opts=$(__vboxmanage_default) COMPREPLY=($(compgen -W "${opts}" -- ${cur})) return 0 ;; controlvm|showvminfo|modifyvm) opts=$(__vboxmanage_list_vms) COMPREPLY=($(compgen -W "${opts}" -- ${cur})) return 0 ;; vrde|setlinkstate*) # vrde is a complete subcommand of controlvm opts="on off" COMPREPLY=($(compgen -W "${opts}" -- ${cur})) return 0 ;; esac for VM in $(__vboxmanage_list_vms); do if [ "$VM" == "$prev" ]; then pprev=${COMP_WORDS[COMP_CWORD-2]} # _omb_util_print "previous: $pprev" case $pprev in startvm) opts="--type" COMPREPLY=($(compgen -W "${opts}" -- ${cur})) return 0 ;; controlvm) opts=$(__vboxmanage_controlvm $VM) COMPREPLY=($(compgen -W "${opts}" -- ${cur})) return 0; ;; showvminfo) opts="--details --machinereadable --log" COMPREPLY=($(compgen -W "${opts}" -- ${cur})) return 0; ;; modifyvm) opts=$(__vboxmanage_modifyvm) COMPREPLY=($(compgen -W "${opts}" -- ${cur})) return 0 ;; esac fi done # _omb_util_print "Got to end withoug completion" } function _vboxmanage_realopts { _omb_util_print $(vboxmanage | grep -Eo "^\s{2}[a-z]+") _omb_util_print " " } function __vboxmanage_nic_types { _omb_util_print $(vboxmanage | grep ' nic<' | sed 's/.*nic<1-N> \([a-z\|]*\).*/\1/' | tr '|' ' ') } function __vboxmanage_startvm { RUNNING=$(vboxmanage list runningvms | cut -d' ' -f1 | tr -d '"') TOTAL=$(vboxmanage list vms | cut -d' ' -f1 | tr -d '"') AVAILABLE="" for VM in $TOTAL; do MATCH=0; for RUN in $RUNNING "x"; do if [ "$VM" == "$RUN" ]; then MATCH=1 fi done (( $MATCH == 0 )) && AVAILABLE="$AVAILABLE $VM " done _omb_util_print $AVAILABLE } function __vboxmanage_list { INPUT=$(vboxmanage list | tr -s '[\[\]\|\n]' ' ' | cut -d' ' -f4-) PRUNED="" if [ "$1" == "long" ]; then for WORD in $INPUT; do [ "$WORD" == "-l" ] && continue; [ "$WORD" == "--long" ] && continue; PRUNED="$PRUNED $WORD" done else PRUNED=$INPUT fi _omb_util_print $PRUNED } function __vboxmanage_list_vms { VMS="" if [ "x$1" == "x" ]; then SEPARATOR=" " else SEPARATOR=$1 fi for VM in $(vboxmanage list vms | cut -d' ' -f1 | tr -d '"'); do [ "$VMS" != "" ] && VMS="${VMS}${SEPARATOR}" VMS="${VMS}${VM}" done _omb_util_print $VMS } function __vboxmanage_list_runningvms { VMS="" if [ "$1" == "" ]; then SEPARATOR=" " else SEPARATOR=$1 fi for VM in $(vboxmanage list runningvms | cut -d' ' -f1 | tr -d '"'); do [ "$VMS" != "" ] && VMS="${VMS}${SEPARATOR}" VMS="${VMS}${VM}" done _omb_util_print $VMS } function __vboxmanage_controlvm { _omb_util_print "pause resume reset poweroff savestate acpipowerbutton" _omb_util_print "acpisleepbutton keyboardputscancode guestmemoryballoon" _omb_util_print "gueststatisticsinterval usbattach usbdetach vrde vrdeport" _omb_util_print "vrdeproperty vrdevideochannelquality setvideomodehint" _omb_util_print "screenshotpng setcredentials teleport plugcpu unplugcpu" _omb_util_print "cpuexecutioncap" # setlinkstate<1-N> activenics=$(__vboxmanage_showvminfo_active_nics $1) for nic in $(_omb_util_print "${activenics}" | tr -d 'nic'); do _omb_util_print "setlinkstate${nic}" done # nic<1-N> null|nat|bridged|intnet|hostonly|generic # [] | # nictrace<1-N> on|off # nictracefile<1-N> # nicproperty<1-N> name=[value] # natpf<1-N> [],tcp|udp,[], # ,[], # natpf<1-N> delete } function __vboxmanage_modifyvm { options=$(vboxmanage modifyvm | grep '\[--' | grep -v '\[--nic<' | sed 's/ *\[--\([a-z]*\).*/--\1/') # Exceptions for i in {1..8}; do options="$options --nic${i}" done _omb_util_print $options } function __vboxmanage_showvminfo_active_nics { nics=$(vboxmanage showvminfo $1 --machinereadable | awk '/^nic/ && ! /none/' | awk '{ split($1, names, "="); print names[1] }') _omb_util_print $nics } function __vboxmanage_default { realopts=$(_vboxmanage_realopts) opts=$realopts$(vboxmanage | grep -i vboxmanage | cut -d' ' -f2 | grep -v '\[' | sort | uniq) pruned="" # _omb_util_print "" # _omb_util_print "DEBUG: cur: $cur, prev: $prev" # _omb_util_print "DEBUG: default: |$p1|$p2|$p3|$p4|" case ${cur} in -*) _omb_util_print $opts # COMPREPLY=($(compgen -W "${opts}" -- ${cur})) return 0 ;; esac; for WORD in $opts; do MATCH=0 for OPT in ${COMP_WORDS[@]}; do # opts=$(_omb_util_print ${opts} | grep -v $OPT); if [ "$OPT" == "$WORD" ]; then MATCH=1 break; fi if [ "$OPT" == "-v" ] && [ "$WORD" == "--version" ]; then MATCH=1 break; fi if [ "$OPT" == "--version" ] && [ "$WORD" == "-v" ]; then MATCH=1 break; fi if [ "$OPT" == "-q" ] && [ "$WORD" == "--nologo" ]; then MATCH=1 break; fi if [ "$OPT" == "--nologo" ] && [ "$WORD" == "-q" ]; then MATCH=1 break; fi done (( $MATCH == 1 )) && continue; pruned="$pruned $WORD" done # COMPREPLY=($(compgen -W "${pruned}" -- ${cur})) _omb_util_print $pruned return 0 } ================================================ FILE: lib/base.sh ================================================ #! bash oh-my-bash.module #------------------------------------------------------------------------------ # Note on copyright (2022-08-23): The contents of this file seems to have been # originally introduced in a blog post [1]. The author also put it on Gist # [2]. The blog post says "feel free to take whatever", but the license is not # explicitly specified. Aliases are moved to general.aliases.sh. # # [1] Nathaniel Landau, "My Mac OSX Bash Profile", # https://natelandau.com/my-mac-osx-bash_profile/, 2013-07-02. # [2] https://gist.github.com/natelandau/10654137 # #------------------------------------------------------------------------------ # # Description: This file holds all base BASH functions # # Sections: # 1. Make Terminal Better (remapping defaults and adding functionality) # 2. File and Folder Management # 3. Searching # 4. Process Management # 5. Networking # 6. System Operations & Information # 7. Date & Time Management # 8. Web Development # 9. # # X. Reminders & Notes # #------------------------------------------------------------------------------ # ----------------------------- # 1. MAKE TERMINAL BETTER # ----------------------------- # mcd: Makes new Dir and jumps inside # -------------------------------------------------------------------- function mcd { mkdir -p -- "$*" ; cd -- "$*" || exit ; } # mans: Search manpage given in agument '1' for term given in argument '2' (case insensitive) # displays paginated result with colored search terms and two lines surrounding each hit. # Example: mans mplayer codec # -------------------------------------------------------------------- function mans { man "$1" | grep -iC2 --color=always "$2" | less ; } # showa: to remind yourself of an alias (given some part of it) # ------------------------------------------------------------ function showa { /usr/bin/grep --color=always -i -a1 "$@" ~/Library/init/bash/aliases.bash | grep -v '^\s*$' | less -FSRXc ; } # quiet: mute output of a command # ------------------------------------------------------------ function quiet { "$@" &> /dev/null & } # lsgrep: search through directory contents with grep # ------------------------------------------------------------ # shellcheck disable=SC2010 function lsgrep { ls | grep "$*" ; } # banish-cookies: redirect .adobe and .macromedia files to /dev/null # ------------------------------------------------------------ function banish-cookies { rm -r ~/.macromedia ~/.adobe ln -s /dev/null ~/.adobe ln -s /dev/null ~/.macromedia } # show the n most used commands. defaults to 10 # ------------------------------------------------------------ function hstats { if [[ $# -lt 1 ]]; then NUM=10 else NUM=${1} fi history | awk '{print $2}' | sort | uniq -c | sort -rn | head -"$NUM" } # ------------------------------- # 2. FILE AND FOLDER MANAGEMENT # ------------------------------- function zipf { zip -r "$1".zip "$1" ; } # zipf: To create a ZIP archive of a folder # extract: Extract most know archives with one command # --------------------------------------------------------- function extract { if [ -f "$1" ] ; then case "$1" in *.tar.bz2) tar xjf "$1" ;; *.tar.gz) tar xzf "$1" ;; *.bz2) bunzip2 "$1" ;; *.rar) unrar e "$1" ;; *.gz) gunzip "$1" ;; *.tar) tar xf "$1" ;; *.tbz2) tar xjf "$1" ;; *.tgz) tar xzf "$1" ;; *.zip) unzip "$1" ;; *.Z) uncompress "$1" ;; *.7z) 7z x "$1" ;; *) _omb_util_print "'$1' cannot be extracted via extract()" ;; esac else _omb_util_print "'$1' is not a valid file" fi } # buf: back up file with timestamp # --------------------------------------------------------- function buf { local filename filetime filename=$1 filetime=$(date +%Y%m%d_%H%M%S) cp -a "${filename}" "${filename}_${filetime}" } # del: move files to hidden folder in tmp, that gets cleared on each reboot # --------------------------------------------------------- function del { mkdir -p /tmp/.trash && mv "$@" /tmp/.trash; } # mkiso: creates iso from current dir in the parent dir (unless defined) # --------------------------------------------------------- function mkiso { if _omb_util_command_exists mkisofs; then if [ -z ${1+x} ]; then local isoname=${PWD##*/} else local isoname=$1 fi if [ -z ${2+x} ]; then local destpath=../ else local destpath=$2 fi if [ -z ${3+x} ]; then local srcpath=${PWD} else local srcpath=$3 fi if [ ! -f "${destpath}${isoname}.iso" ]; then _omb_util_print "writing ${isoname}.iso to ${destpath} from ${srcpath}" mkisofs -V "${isoname}" -iso-level 3 -r -o "${destpath}${isoname}.iso" "${srcpath}" else _omb_util_print "${destpath}${isoname}.iso already exists" fi else _omb_util_print "mkisofs cmd does not exist, please install cdrtools" fi } # --------------------------- # 3. SEARCHING # --------------------------- function ff { /usr/bin/find . -name "$@" ; } # ff: Find file under the current directory # shellcheck disable=SC2145 function ffs { /usr/bin/find . -name "$@"'*' ; } # ffs: Find file whose name starts with a given string # shellcheck disable=SC2145 function ffe { /usr/bin/find . -name '*'"$@" ; } # ffe: Find file whose name ends with a given string function bigfind { if [[ $# -lt 1 ]]; then echo_warn "Usage: bigfind DIRECTORY" return fi du -a "$1" | sort -n -r | head -n 10 } # --------------------------- # 4. PROCESS MANAGEMENT # --------------------------- # findPid: find out the pid of a specified process # ----------------------------------------------------- # Note that the command name can be specified via a regex # E.g. findPid '/d$/' finds pids of all processes with names ending in 'd' # Without the 'sudo' it will only find processes of the current user # ----------------------------------------------------- function findPid { lsof -t -c "$@" ; } # my_ps: List processes owned by my user: # ------------------------------------------------------------ function my_ps { ps "$@" -u "$USER" -o pid,%cpu,%mem,start,time,bsdtime,command ; } # --------------------------- # 5. NETWORKING # --------------------------- # ips: display all ip addresses for this host # ------------------------------------------------------------------- function ips { if _omb_util_command_exists ifconfig then ifconfig | awk '/inet /{ print $2 }' elif _omb_util_command_exists ip then ip addr | grep -oP 'inet \K[\d.]+' else _omb_util_print "You don't have ifconfig or ip command installed!" fi } # down4me: checks whether a website is down for you, or everybody # ------------------------------------------------------------------- function down4me { curl -s "http://www.downforeveryoneorjustme.com/$1" | sed '/just you/!d;s/<[^>]*>//g' } # myip: displays your ip address, as seen by the Internet # ------------------------------------------------------------------- function myip { res=$(curl -s checkip.dyndns.org | grep -Eo '[0-9\.]+') _omb_util_print "Your public IP is: ${_omb_term_bold_green} $res ${_omb_term_normal}" } # ii: display useful host related informaton # ------------------------------------------------------------------- function ii { _omb_util_print $'\n'"You are logged on ${_omb_term_brown}$HOST" _omb_util_print $'\n'"Additionnal information:$NC "; uname -a _omb_util_print $'\n'"${_omb_term_brown}Users logged on:$NC "; w -h _omb_util_print $'\n'"${_omb_term_brown}Current date :$NC "; date _omb_util_print $'\n'"${_omb_term_brown}Machine stats :$NC "; uptime [[ "$OSTYPE" == darwin* ]] && _omb_util_print $'\n'"${_omb_term_brown}Current network location :$NC " ; scselect _omb_util_print $'\n'"${_omb_term_brown}Public facing IP Address :$NC " ;myip [[ "$OSTYPE" == darwin* ]] && _omb_util_print $'\n'"${_omb_term_brown}DNS Configuration:$NC " ; scutil --dns _omb_util_print } # --------------------------------------- # 6. SYSTEMS OPERATIONS & INFORMATION # --------------------------------------- # batch_chmod: Batch chmod for all files & sub-directories in the current one # ------------------------------------------------------------------- function batch_chmod { _omb_util_put "${_omb_term_bold_navy}Applying 0755 permission for all directories..." (find . -type d -print0 | xargs -0 chmod 0755) & spinner _omb_util_put "${_omb_term_normal}" _omb_util_put "${_omb_term_bold_navy}Applying 0644 permission for all files..." (find . -type f -print0 | xargs -0 chmod 0644) & spinner _omb_util_put "${_omb_term_normal}" } # usage: disk usage per directory, in Mac OS X and Linux # ------------------------------------------------------------------- function usage { if [ "$(uname)" = "Darwin" ]; then if [ -n "$1" ]; then du -hd 1 "$1" else du -hd 1 fi elif [ "$(uname)" = "Linux" ]; then if [ -n "$1" ]; then du -h --max-depth=1 "$1" else du -h --max-depth=1 fi fi } # pickfrom: picks random line from file # ------------------------------------------------------------------- function pickfrom { local file=$1 [ -z "$file" ] && reference "$FUNCNAME" && return length=$(wc -l < "$file") n=$( ($RANDOM \* "$length" / 32768 + 1)) head -n "$n" "$file" | tail -1 } # passgen: generates random password from dictionary words # Note default length of generated password is 4, you can pass it to the command # E.g. passgen 15 # ------------------------------------------------------------------- # shellcheck disable=SC2046 # shellcheck disable=SC2005 # shellcheck disable=SC2034 # shellcheck disable=SC2086 function passgen { local i pass length=${1:-4} pass=$(_omb_util_print $(for ((i=1;i<=length;i++)); do pickfrom /usr/share/dict/words; done)) _omb_util_print "With spaces (easier to memorize): $pass" _omb_util_print "Without (use this as the password): $(tr -d ' ' <<< "$pass")" } # --------------------------------------- # 7. DATE & TIME MANAGEMENT # --------------------------------------- # --------------------------------------- # 8. WEB DEVELOPMENT # --------------------------------------- function httpHeaders { /usr/bin/curl -I -L "$@" ; } # httpHeaders: Grabs headers from web page # httpDebug: Download a web page and show info on what took time # ------------------------------------------------------------------- function httpDebug { /usr/bin/curl "$@" -o /dev/null -w "dns: %{time_namelookup} connect: %{time_connect} pretransfer: %{time_pretransfer} starttransfer: %{time_starttransfer} total: %{time_total}\\n" ; } # --------------------------------------- # X. REMINDERS & NOTES # --------------------------------------- # remove_disk: spin down unneeded disk # --------------------------------------- # diskutil eject /dev/disk1s3 # to change the password on an encrypted disk image: # --------------------------------------- # hdiutil chpass /path/to/the/diskimage # to mount a read-only disk image as read-write: # --------------------------------------- # hdiutil attach example.dmg -shadow /tmp/example.shadow -noverify # mounting a removable drive (of type msdos or hfs) # --------------------------------------- # mkdir /Volumes/Foo # ls /dev/disk* to find out the device to use in the mount command) # mount -t msdos /dev/disk1s1 /Volumes/Foo # mount -t hfs /dev/disk1s1 /Volumes/Foo # to create a file of a given size: /usr/sbin/mkfile or /usr/bin/hdiutil # --------------------------------------- # e.g.: mkfile 10m 10MB.dat # e.g.: hdiutil create -size 10m 10MB.dmg # the above create files that are almost all zeros - if random bytes are desired # then use: ~/Dev/Perl/randBytes 1048576 > 10MB.dat ================================================ FILE: lib/bourne-shell.sh ================================================ #! bash oh-my-bash.module # ~/.bashrc: executed by bash(1) for non-login shells. # see /usr/share/doc/bash/examples/startup-files (in the package bash-doc) # make less more friendly for non-text input files, see lesspipe(1) if [[ ! $LESSOPEN ]];then if [[ -f /etc/gentoo-release ]]; then export LESSOPEN="|lesspipe %s" else if [[ -x /usr/bin/lesspipe ]]; then eval "$(SHELL=/bin/sh /usr/bin/lesspipe)" elif [[ -x /usr/bin/lesspipe.sh ]]; then eval "$(SHELL=/bin/sh /usr/bin/lesspipe.sh)" fi fi fi # set variable identifying the chroot you work in (used in the prompt below) if [[ ! ${debian_chroot:-} && -r /etc/debian_chroot ]]; then debian_chroot=$(< /etc/debian_chroot) fi # set a fancy prompt (non-color, unless we know we "want" color) case $TERM in xterm-color|*-256color) color_prompt=yes;; esac # uncomment for a colored prompt, if the terminal has the capability; turned # off by default to not distract the user: the focus in a terminal window # should be on the output of commands, not on the prompt #force_color_prompt=yes if [[ $force_color_prompt ]]; then if [[ -x /usr/bin/tput ]] && tput setaf 1 &>/dev/null; then # We have color support; assume it's compliant with Ecma-48 # (ISO/IEC-6429). (Lack of such support is extremely rare, and such # a case would tend to support setf rather than setaf.) color_prompt=yes else color_prompt= fi fi if [[ $color_prompt == yes ]]; then PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ ' else PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ ' fi unset -v color_prompt force_color_prompt # If this is an xterm set the title to user@host:dir case $TERM in xterm*|rxvt*) PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1" ;; *) ;; esac # enable color support of ls and also add handy aliases if [[ -x /usr/bin/dircolors ]]; then if [[ -r ~/.dircolors ]]; then eval "$(dircolors -b ~/.dircolors)" else eval "$(dircolors -b)" fi #_omb_util_alias ls='dir --color=auto' #_omb_util_alias vdir='vdir --color=auto' # Note: aliases "grep", "fgrep", and "egrep" are merged in lib/grep.sh fi function _omb_util_alias_select_ls { if command ls --color=auto ~ &>/dev/null; then _omb_command='ls --color=auto' elif command ls -G ~ &>/dev/null; then _omb_command='ls -G' fi } _omb_util_alias_delayed ls # colored GCC warnings and errors #export GCC_COLORS='error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01' # ls aliases are moved to "lib/directories.sh" # Add an "alert" alias for long running commands. Use like so: # sleep 10; alert if _omb_util_binary_exists notify-send; then function _omb_alias_alert { local status=$? type command if ((status == 0)); then type=terminal else type=error fi # get the command command=$(history | command tail -n 1 | command sed -e 's/^[[:space:]]*[0-9]\{1,\}[[:space:]]*//;s/[;&|][[:space:]]*alert$//') notify-send --urgency=low -i "$type" "$command" return "$status" } _omb_util_alias alert='_omb_alias_alert "$@"' fi # Alias definitions. # You may want to put all your additions into a separate file like # ~/.bash_aliases, instead of adding them here directly. # See /usr/share/doc/bash-doc/examples in the bash-doc package. if [[ -f ~/.bash_aliases ]]; then . ~/.bash_aliases fi if [[ -f ~/.bashrc.local ]]; then . ~/.bashrc.local fi # enable programmable completion features (you don't need to enable # this, if it's already enabled in /etc/bash.bashrc and /etc/profile # sources /etc/bash.bashrc). if ! shopt -oq posix; then if [[ -f /usr/share/bash-completion/bash_completion ]]; then . /usr/share/bash-completion/bash_completion elif [[ -f /etc/bash_completion ]]; then . /etc/bash_completion fi fi ================================================ FILE: lib/cli.bash ================================================ #!/usr/bin/env bash _omb_module_require lib:utils function _omb_cmd_help { echo 'Not yet implemented' } function _omb_cmd_changelog { echo 'Not yet implemented' } function _omb_cmd_plugin { echo 'Not yet implemented' } function _omb_cmd_pull { echo 'Not yet implemented' } function _omb_cmd_reload { echo 'Not yet implemented' } function _omb_cmd_theme { echo 'Not yet implemented' } function _omb_cmd_update { echo 'Not yet implemented' } function _omb_cmd_version { echo 'Not yet implemented' } function omb { if (($# == 0)); then _omb_cmd_help return 2 fi # Subcommand functions start with _ so that they don't # appear as completion entries when looking for `omb` if ! _omb_util_function_exists "_omb_cmd_$1"; then _omb_cmd_help return 2 fi _omb_cmd_"$@" } _omb_module_require lib:utils _omb_lib_cli__init_shopt= _omb_util_get_shopt -v _omb_lib_cli__init_shopt extglob shopt -s extglob function _comp_cmd_omb__describe { eval "set -- $1 \"\${$2[@]}\"" local type=$1; shift local word desc words iword=0 for word; do desc="($type) ${word#*:}" # unused word=${word%%:*} words[iword++]=$word done local -a filtered _omb_util_split_lines filtered "$(compgen -W '"${words[@]}"' -- "${COMP_WORDS[COMP_CWORD]}")" COMPREPLY+=("${filtered[@]}") } function _comp_cmd_omb__get_available_plugins { available_plugins=() local -a plugin_files _omb_util_glob_expand plugin_files '{"$OSH","$OSH_CUSTOM"}/plugins/*/{_*,*.plugin.{bash,sh}}' local plugin for plugin in "${plugin_files[@]##*/}"; do case $plugin in *.plugin.bash) plugin=${plugin%.plugin.bash} ;; *.plugin.sh) plugin=${plugin%.plugin.sh} ;; *) plugin=${plugin#_} ;; esac _omb_util_array_contains available_plugins "$plugin" || available_plugins+=("$plugin") done } function _comp_cmd_omb__get_available_themes { available_themes=() local -a theme_files _omb_util_glob_expand theme_files '{"$OSH","$OSH_CUSTOM"}/themes/*/{_*,*.theme.{bash,sh}}' local theme for theme in "${theme_files[@]##*/}"; do case $theme in *.theme.bash) theme=${theme%.theme.bash} ;; *.theme.sh) theme=${theme%.theme.sh} ;; *) theme=${theme#_} ;; esac _omb_util_array_contains available_themes "$theme" || available_themes+=("$theme") done } ## @fn _comp_cmd_omb__get_valid_plugins type function _comp_cmd_omb__get_valid_plugins { if [[ $1 == disable ]]; then # if command is "disable", only offer already enabled plugins valid_plugins=("${plugins[@]}") else local -a available_plugins _comp_cmd_omb__get_available_plugins valid_plugins=("${available_plugins[@]}") # if command is "enable", remove already enabled plugins if [[ ${COMP_WORDS[2]} == enable ]]; then _omb_util_array_remove valid_plugins "${plugins[@]}" fi fi } function _comp_cmd_omb { local shopt _omb_util_get_shopt extglob shopt -s extglob if ((COMP_CWORD == 1)); then local -a cmds=( 'changelog:Print the changelog' 'help:Usage information' 'plugin:Manage plugins' 'pr:Manage Oh My Bash Pull Requests' 'reload:Reload the current bash session' 'theme:Manage themes' 'update:Update Oh My Bash' 'version:Show the version' ) _comp_cmd_omb__describe 'command' cmds elif ((COMP_CWORD ==2)); then case "${COMP_WORDS[1]}" in changelog) local -a refs _omb_util_split_lines refs "$(command git -C "$OSH" for-each-ref --format="%(refname:short):%(subject)" refs/heads refs/tags)" _comp_cmd_omb__describe 'command' refs ;; plugin) local -a subcmds=( 'disable:Disable plugin(s)' 'enable:Enable plugin(s)' 'info:Get plugin information' 'list:List plugins' 'load:Load plugin(s)' ) _comp_cmd_omb__describe 'command' subcmds ;; pr) local -a subcmds=( 'clean:Delete all Pull Request branches' 'test:Test a Pull Request' ) _comp_cmd_omb__describe 'command' subcmds ;; theme) local -a subcmds=( 'list:List themes' 'set:Set a theme in your .zshrc file' 'use:Load a theme' ) _comp_cmd_omb__describe 'command' subcmds ;; esac elif ((COMP_CWORD == 3)); then case "${COMP_WORDS[1]}::${COMP_WORDS[2]}" in plugin::@(disable|enable|load)) local -a valid_plugins _comp_cmd_omb__get_valid_plugins "${COMP_WORDS[2]}" _comp_cmd_omb__describe 'plugin' valid_plugins ;; plugin::info) local -a available_plugins _comp_cmd_omb__get_available_plugins _comp_cmd_omb__describe 'plugin' available_plugins ;; theme::@(set|use)) local -a available_themes _comp_cmd_omb__get_available_themes _comp_cmd_omb__describe 'theme' available_themes ;; esac elif ((COMP_CWORD > 3)); then case "${COMP_WORDS[1]}::${COMP_WORDS[2]}" in plugin::@(enable|disable|load)) local -a valid_plugins _comp_cmd_omb__get_valid_plugins "${COMP_WORDS[2]}" # Remove plugins already passed as arguments # NOTE: $((COMP_CWORD - 1)) is the last plugin argument completely passed, i.e. that which # has a space after them. This is to avoid removing plugins partially passed, which makes # the completion not add a space after the completed plugin. _omb_util_array_remove valid_plugins "${COMP_WORDS[@]:3:COMP_CWORD-3}" _comp_cmd_omb__describe 'plugin' valid_plugins ;; esac fi [[ :$shopt: == *:extglob:* ]] || shopt -u extglob return 0 } complete -F _comp_cmd_omb omb [[ :$_omb_lib_cli__init_shopt: == *:extglob:* ]] || shopt -u extglob unset -v _omb_lib_cli__init_shopt ================================================ FILE: lib/directories.sh ================================================ #! bash oh-my-bash.module # Common directories functions OMB_DIRECTORIES_CD_USE_PUSHD=false _omb_cd_dirstack=("$PWD") # A clone of the Zsh `cd' builtin command. This supports the numbered option # `-1', `-2', etc. function _omb_directories_cd { local -i index if [[ $# -eq 1 && $1 =~ ^-[1-9]+$ ]]; then index=${1#-} if ((index >= ${#_omb_cd_dirstack[@]})); then builtin echo "cd: no such entry in dir stack" >&2 return 1 fi set -- "${_omb_cd_dirstack[index]}" fi if [[ ${OMB_DIRECTORIES_CD_USE_PUSHD-} == true ]]; then local oldpwd=$OLDPWD builtin pushd . >/dev/null && OLDPWD=$oldpwd builtin cd "$@" && oldpwd=$OLDPWD && builtin pushd . >/dev/null && for ((index = ${#DIRSTACK[@]} - 1; index >= 1; index--)); do if [[ ${DIRSTACK[0]/#~/$HOME} == "${DIRSTACK[index]}" ]]; then builtin popd "+$index" >/dev/null || return 1 fi done local status=$? _omb_cd_dirstack=("${DIRSTACK[@]/#~/$HOME}") OLDPWD=$oldpwd else [[ ${_omb_cd_dirstack[0]} == "$PWD" ]] || _omb_cd_dirstack=("$PWD" "${_omb_cd_dirstack[@]}") builtin cd "$@" && _omb_cd_dirstack=("$PWD" "${_omb_cd_dirstack[@]}") local status=$? for ((index = ${#_omb_cd_dirstack[@]} - 1; index >= 1; index--)); do if [[ ${_omb_cd_dirstack[0]} == "${_omb_cd_dirstack[index]}" ]]; then unset -v '_omb_cd_dirstack[index]' fi done _omb_cd_dirstack=("${_omb_cd_dirstack[@]}") fi return "$status" } _omb_util_alias cd='_omb_directories_cd' _omb_util_alias cd..='cd ../' # Go back 1 directory level (for fast typers) _omb_util_alias ..='cd ../' # Go back 1 directory level _omb_util_alias ...='cd ../../' # Go back 2 directory levels _omb_util_alias .3='cd ../../../' # Go back 3 directory levels _omb_util_alias .4='cd ../../../../' # Go back 4 directory levels _omb_util_alias .5='cd ../../../../../' # Go back 5 directory levels _omb_util_alias .6='cd ../../../../../../' # Go back 6 directory levels _omb_util_alias -='cd -' _omb_util_alias 1='cd -' _omb_util_alias 2='cd -2' _omb_util_alias 3='cd -3' _omb_util_alias 4='cd -4' _omb_util_alias 5='cd -5' _omb_util_alias 6='cd -6' _omb_util_alias 7='cd -7' _omb_util_alias 8='cd -8' _omb_util_alias 9='cd -9' _omb_util_alias md='mkdir -p' _omb_util_alias rd='rmdir' _omb_util_alias d='dirs -v | head -10' _omb_util_alias po='popd' # List directory contents _omb_util_alias lsa='ls -lha' _omb_util_alias l='ls -lha' _omb_util_alias ll='ls -lh' _omb_util_alias la='ls -lhA' # From bourne-shell.sh (unused) #_omb_util_alias l='ls -CF' #_omb_util_alias ll='ls -laF' #_omb_util_alias la='ls -A' ================================================ FILE: lib/functions.sh ================================================ #! bash oh-my-bash.module function bash_stats() { fc -l 1 | awk '{CMD[$2]++;count++;}END { for (a in CMD)print CMD[a] " " CMD[a]/count*100 "% " a;}' | grep -v "./" | column -c3 -s " " -t | sort -nr | nl | head -n20 } function uninstall_oh_my_bash() { source "$OSH"/tools/uninstall.sh } function upgrade_oh_my_bash() { source "$OSH"/tools/upgrade.sh } function take() { mkdir -p "$1" cd "$1" || exit } function open_command() { local open_cmd # define the open command case "$OSTYPE" in darwin*) open_cmd='open' ;; cygwin*) open_cmd='cygstart' ;; linux*) open_cmd='xdg-open' ;; msys*) open_cmd='start ""' ;; *) _omb_util_print "Platform $OSTYPE not supported" return 1 ;; esac # don't use nohup on OSX if [[ "$OSTYPE" == darwin* ]]; then $open_cmd "$@" &>/dev/null else nohup $open_cmd "$@" &>/dev/null fi } # # Get the value of an alias. # # Arguments: # 1. alias - The alias to get its value from # STDOUT: # The value of alias $1 (if it has one). # Return value: # 0 if the alias was found, # 1 if it does not exist # if ((_omb_bash_version >= 40000)); then function alias_value() { [[ ${BASH_ALIASES[$1]+set} ]] && _omb_util_print "${BASH_ALIASES[$1]}" } else function alias_value() { local value= value=$(alias "$1" 2>/dev/null) && eval "value=${value#*=}" && _omb_util_print "$value" } fi # # Try to get the value of an alias, # otherwise return the input. # # Arguments: # 1. alias - The alias to get its value from # STDOUT: # The value of alias $1, or $1 if there is no alias $1. # Return value: # Always 0 # function try_alias_value() { alias_value "$1" || _omb_util_print "$1" } # # Set variable "$1" to default value "$2" if "$1" is not yet defined. # # Arguments: # 1. name - The variable to set # 2. val - The default value # Return value: # 0 if the variable exists, 3 if it was set # function default() { typeset -p "$1" &>/dev/null && return 0 typeset -g "$1"="$2" && return 3 } # # Set enviroment variable "$1" to default value "$2" if "$1" is not yet defined. # # Arguments: # 1. name - The env variable to set # 2. val - The default value # Return value: # 0 if the env variable exists, 3 if it was set # function env_default() { env | grep -q "^$1=" && return 0 export "$1=$2" && return 3 } ================================================ FILE: lib/git.sh ================================================ #! bash oh-my-bash.module # Outputs current branch info in prompt format _omb_module_require lib:omb-prompt-colors _omb_module_require lib:omb-prompt-base _omb_module_require lib:omb-deprecate : "${_omb_git_post_1_7_2:=${POST_1_7_2_GIT:-}}" _omb_deprecate_declare 20000 POST_1_7_2_GIT _omb_git_post_1_7_2 sync # # Note: The same name of a functionis defined in omb-prompt-base. We comment # # out this function for now. # function git_prompt_info { # local ref # if [[ $(_omb_prompt_git config --get oh-my-bash.hide-status 2>/dev/null) != 1 ]]; then # ref=$(_omb_prompt_git symbolic-ref HEAD 2> /dev/null) || \ # ref=$(_omb_prompt_git rev-parse --short HEAD 2> /dev/null) || return 0 # _omb_util_print "$OSH_THEME_GIT_PROMPT_PREFIX${ref#refs/heads/}$(parse_git_dirty)$OSH_THEME_GIT_PROMPT_SUFFIX" # fi # } # Checks if working tree is dirty function parse_git_dirty { local STATUS= local -a FLAGS=('--porcelain') if [[ $(_omb_prompt_git config --get oh-my-bash.hide-dirty) != 1 ]]; then if ((${_omb_git_post_1_7_2:=$(git_compare_version "1.7.2")} > 0)); then FLAGS+=('--ignore-submodules=dirty') fi if [[ $DISABLE_UNTRACKED_FILES_DIRTY == "true" ]]; then FLAGS+=('--untracked-files=no') fi STATUS=$(_omb_prompt_git status "${FLAGS[@]}" 2> /dev/null | tail -n1) fi if [[ $STATUS ]]; then _omb_util_print "$OSH_THEME_GIT_PROMPT_DIRTY" else _omb_util_print "$OSH_THEME_GIT_PROMPT_CLEAN" fi } # Gets the difference between the local and remote branches function git_remote_status { local git_remote_origin=$(_omb_prompt_git rev-parse --verify ${hook_com[branch]}@{upstream} --symbolic-full-name 2>/dev/null) local remote=${git_remote_origin/refs\/remotes\//} if [[ $remote ]]; then local ahead=$(_omb_prompt_git rev-list ${hook_com[branch]}@{upstream}..HEAD 2>/dev/null | wc -l) local behind=$(_omb_prompt_git rev-list HEAD..${hook_com[branch]}@{upstream} 2>/dev/null | wc -l) local git_remote_status git_remote_status_detailed if ((ahead == 0 && behind == 0)); then git_remote_status=$OSH_THEME_GIT_PROMPT_EQUAL_REMOTE elif ((ahead > 0 && behind == 0)); then git_remote_status=$OSH_THEME_GIT_PROMPT_AHEAD_REMOTE git_remote_status_detailed=$OSH_THEME_GIT_PROMPT_AHEAD_REMOTE_COLOR$OSH_THEME_GIT_PROMPT_AHEAD_REMOTE$((ahead))$_omb_prompt_reset_color elif ((behind > 0 && ahead == 0)); then git_remote_status=$OSH_THEME_GIT_PROMPT_BEHIND_REMOTE git_remote_status_detailed=$OSH_THEME_GIT_PROMPT_BEHIND_REMOTE_COLOR$OSH_THEME_GIT_PROMPT_BEHIND_REMOTE$((behind))$_omb_prompt_reset_color elif ((ahead > 0 && behind > 0)); then git_remote_status=$OSH_THEME_GIT_PROMPT_DIVERGED_REMOTE git_remote_status_detailed=$OSH_THEME_GIT_PROMPT_AHEAD_REMOTE_COLOR$OSH_THEME_GIT_PROMPT_AHEAD_REMOTE$((ahead))$_omb_prompt_reset_color$OSH_THEME_GIT_PROMPT_BEHIND_REMOTE_COLOR$OSH_THEME_GIT_PROMPT_BEHIND_REMOTE$((behind))$_omb_prompt_reset_color fi if [[ $OSH_THEME_GIT_PROMPT_REMOTE_STATUS_DETAILED ]]; then git_remote_status=$OSH_THEME_GIT_PROMPT_REMOTE_STATUS_PREFIX$remote$git_remote_status_detailed$OSH_THEME_GIT_PROMPT_REMOTE_STATUS_SUFFIX fi _omb_util_print "$git_remote_status" fi } # Outputs the name of the current branch # Usage example: git pull origin $(git_current_branch) # Using '--quiet' with 'symbolic-ref' will not cause a fatal error (128) if # it's not a symbolic ref, but in a Git repo. function git_current_branch { local ref ref=$(_omb_prompt_git symbolic-ref --quiet HEAD 2> /dev/null) local ret=$? if [[ $ret != 0 ]]; then [[ $ret == 128 ]] && return # no git repo. ref=$(_omb_prompt_git rev-parse --short HEAD 2> /dev/null) || return fi _omb_util_print ${ref#refs/heads/} } # Gets the number of commits ahead from remote function git_commits_ahead { if _omb_prompt_git rev-parse --git-dir &>/dev/null; then local commits=$(_omb_prompt_git rev-list --count @{upstream}..HEAD) if ((commits != 0)); then _omb_util_print "$OSH_THEME_GIT_COMMITS_AHEAD_PREFIX$commits$OSH_THEME_GIT_COMMITS_AHEAD_SUFFIX" fi fi } # Gets the number of commits behind remote function git_commits_behind { if _omb_prompt_git rev-parse --git-dir &>/dev/null; then local commits=$(_omb_prompt_git rev-list --count HEAD..@{upstream}) if ((commits != 0)); then _omb_util_print "$OSH_THEME_GIT_COMMITS_BEHIND_PREFIX$commits$OSH_THEME_GIT_COMMITS_BEHIND_SUFFIX" fi fi } # Outputs if current branch is ahead of remote function git_prompt_ahead { if [[ $(_omb_prompt_git rev-list origin/$(git_current_branch)..HEAD 2> /dev/null) ]]; then _omb_util_print "$OSH_THEME_GIT_PROMPT_AHEAD" fi } # Outputs if current branch is behind remote function git_prompt_behind { if [[ $(_omb_prompt_git rev-list HEAD..origin/$(git_current_branch) 2> /dev/null) ]]; then _omb_util_print "$OSH_THEME_GIT_PROMPT_BEHIND" fi } # Outputs if current branch exists on remote or not function git_prompt_remote { if [[ $(_omb_prompt_git show-ref origin/$(git_current_branch) 2> /dev/null) ]]; then _omb_util_print "$OSH_THEME_GIT_PROMPT_REMOTE_EXISTS" else _omb_util_print "$OSH_THEME_GIT_PROMPT_REMOTE_MISSING" fi } # Formats prompt string for current git commit short SHA function git_prompt_short_sha { local SHA SHA=$(_omb_prompt_git rev-parse --short HEAD 2> /dev/null) && _omb_util_print "$OSH_THEME_GIT_PROMPT_SHA_BEFORE$SHA$OSH_THEME_GIT_PROMPT_SHA_AFTER" } # Formats prompt string for current git commit long SHA function git_prompt_long_sha { local SHA SHA=$(_omb_prompt_git rev-parse HEAD 2> /dev/null) && _omb_util_print "$OSH_THEME_GIT_PROMPT_SHA_BEFORE$SHA$OSH_THEME_GIT_PROMPT_SHA_AFTER" } # Get the status of the working tree function git_prompt_status { local INDEX=$(_omb_prompt_git status --porcelain -b 2> /dev/null) local STATUS= if command grep -qE '^\?\? ' <<< "$INDEX"; then STATUS=$OSH_THEME_GIT_PROMPT_UNTRACKED$STATUS fi if command grep -q '^[AM] ' <<< "$INDEX"; then STATUS=$OSH_THEME_GIT_PROMPT_ADDED$STATUS fi if command grep -qE '^[ A]M |^ T ' <<< "$INDEX"; then STATUS=$OSH_THEME_GIT_PROMPT_MODIFIED$STATUS fi if command grep -q '^R ' <<< "$INDEX"; then STATUS=$OSH_THEME_GIT_PROMPT_RENAMED$STATUS fi if command grep -qE '^[ A]D |D ' <<< "$INDEX"; then STATUS=$OSH_THEME_GIT_PROMPT_DELETED$STATUS fi if _omb_prompt_git rev-parse --verify refs/stash &> /dev/null; then STATUS=$OSH_THEME_GIT_PROMPT_STASHED$STATUS fi if command grep -q '^UU ' <<< "$INDEX"; then STATUS=$OSH_THEME_GIT_PROMPT_UNMERGED$STATUS fi if command grep -q '^## [^ ]\+ .*ahead' <<< "$INDEX"; then STATUS=$OSH_THEME_GIT_PROMPT_AHEAD$STATUS fi if command grep -q '^## [^ ]\+ .*behind' <<< "$INDEX"; then STATUS=$OSH_THEME_GIT_PROMPT_BEHIND$STATUS fi if command grep -q '^## [^ ]\+ .*diverged' <<< "$INDEX"; then STATUS=$OSH_THEME_GIT_PROMPT_DIVERGED$STATUS fi _omb_util_print "$STATUS" } # Compares the provided version of git to the version installed and on path # Outputs -1, 0, or 1 if the installed version is less than, equal to, or # greater than the input version, respectively. function git_compare_version { local INPUT_GIT_VERSION INSTALLED_GIT_VERSION _omb_util_split INPUT_GIT_VERSION "$1" '.' _omb_util_split INSTALLED_GIT_VERSION "$(_omb_prompt_git --version 2>/dev/null)" _omb_util_split INSTALLED_GIT_VERSION "${INSTALLED_GIT_VERSION[2]}" '.' local i for i in {0..2}; do if ((INSTALLED_GIT_VERSION[i] > INPUT_GIT_VERSION[i])); then _omb_util_print 1 return 0 fi if ((INSTALLED_GIT_VERSION[i] < INPUT_GIT_VERSION[i])); then _omb_util_print -1 return 0 fi done _omb_util_print 0 } # Outputs the name of the current user # Usage example: $(git_current_user_name) function git_current_user_name { _omb_prompt_git config user.name 2>/dev/null } # Outputs the email of the current user # Usage example: $(git_current_user_email) function git_current_user_email { _omb_prompt_git config user.email 2>/dev/null } ================================================ FILE: lib/grep.sh ================================================ #! bash oh-my-bash.module # is x grep argument available? function _omb_grep_flag_available { echo | grep "$1" "" >/dev/null 2>&1 } _omb_grep_options=() # color grep results if _omb_grep_flag_available --color=auto; then _omb_grep_options+=( "--color=auto" ) fi # ignore VCS folders (if the necessary grep flags are available) _omb_grep_vcs_folders="{.bzr,CVS,.git,.hg,.svn}" if _omb_grep_flag_available --exclude-dir=.cvs; then _omb_grep_options+=( "--exclude-dir=$_omb_grep_vcs_folders" ) elif _omb_grep_flag_available --exclude=.cvs; then _omb_grep_options+=( "--exclude=$_omb_grep_vcs_folders" ) fi # export grep settings if ((${#_omb_grep_options[@]} > 0)); then _omb_util_alias grep="grep ${_omb_grep_options[*]}" _omb_util_alias fgrep="grep -F ${_omb_grep_options[*]}" _omb_util_alias egrep="grep -E ${_omb_grep_options[*]}" else _omb_util_alias fgrep='grep -F' _omb_util_alias egrep='grep -E' fi # clean up unset -v _omb_grep_options unset -v _omb_grep_vcs_folders unset -f _omb_grep_flag_available ================================================ FILE: lib/history.sh ================================================ #! bash oh-my-bash.module # A part of this file came from bash-sensible [1]. The current version is # based on commit eb82f9e8. # # [1] https://github.com/mrzool/bash-sensible # Copyright (c) 2015 Mattia Tezzele, provided under the MIT license. ## Command history configuration if [ -z "$HISTFILE" ]; then HISTFILE=$HOME/.bash_history fi # some moderate history controls taken from sensible.bash ## SANE HISTORY DEFAULTS ## # Append to the history file, don't overwrite it shopt -s histappend # Save multi-line commands as one command shopt -s cmdhist # Re-edit the command line for failing history expansions shopt -s histreedit # Re-edit the result of history expansions shopt -s histverify # save history with newlines instead of ; where possible shopt -s lithist # Record each line as it gets issued _omb_util_add_prompt_command 'history -a' # Unlimited history size. Doesn't appear to slow things down, so why not? # Export these variables to apply them also to the child shell sessions. # # Note: There are multiple ways to realize the unlimited history size. # # 1) A documented way is HISTSIZE=-1. However, this is only supported in bash # >= 4.3 and it causes clearing the user's history in bash < 4.3. Even if # we use HISTSIZE=-1 only when the current Bash version is 4.3 or above, it # clears the user's history file when a lower version of Bash is in the # system and it is started without setting HISTSIZE (e.g. when the Bash is # started with --norc or the specified init file is broken). One could # consider giving up making HISTSIZE and HISTFILESIZE environment variables, # but then it truncates the user's history file when a new Bash is started # without setting HISTSIZE. # # 2) Another well known trick is to set HISTSIZE and HISTFILESIZE to an empty # string. This works as unlimited history in all the Bash versions. # However, an empty HISTSIZE environment variable causes a startup error in # Mksh. One could consider giving up making HISTSIZE environment variable, # but again, this will truncate the user's history file with Bash without # configuration. One might consider defining a shell function or an alias to # start mksh without the HISTSIZE environment variable, but the users # wouldn't like it. In addition, the truncated history problem persists with # the child Bash started within persists. # # 3) We instead consider explicitly specifying to HISTSIZE a large number that # is unlikely to be reached. A typical value might be 10000 or 100000, but # that can still be reached by heavy users. We instead specify a number as # large as possible. The number shall not exceed INT_MAX, or otherwise # HISTSIZE becomes negative and clears the user's history. In case there is # a system where `int' is a 16-bit signed integer, we choose 0x7FFF7FFF so # that the lower word is 0x7FFF. This still does not ensure that the 16-bit # integer becomes 0x7FFF after overflow (since the overflow of the signed # integer causes the undefined behavior in the C standard), but it is safer # in typical implementations. # # See discussion on https://github.com/ohmybash/oh-my-bash/issues/586. export HISTSIZE=$((0x7FFF7FFF)) export HISTFILESIZE=$((0x7FFF7FFF)) # Avoid duplicate entries HISTCONTROL="erasedups:ignoreboth" # Don't record some commands HISTIGNORE="exit:ls:bg:fg:history:clear" # Enable incremental history search with up/down arrows (also Readline goodness) # Learn more about this here: https://codeinthehole.com/tips/the-most-important-command-line-tip-incremental-history-searching-with-inputrc/ # bash4 specific ?? bind '"\e[A": history-search-backward' bind '"\e[B": history-search-forward' bind '"\e[C": forward-char' bind '"\e[D": backward-char' # Use standard ISO 8601 timestamp # %F equivalent to %Y-%m-%d # %T equivalent to %H:%M:%S (24-hours format) # Show history case $HIST_STAMPS in "[mm/dd/yyyy]") HISTTIMEFORMAT=$'\033[31m[%m/%d/%Y] \033[36m[%T]\033[0m ' ;; "[dd.mm.yyyy]") HISTTIMEFORMAT=$'\033[31m[%d.%m.%Y] \033[36m[%T]\033[0m ' ;; "[yyyy-mm-dd]") HISTTIMEFORMAT=$'\033[31m[%F] \033[36m[%T]\033[0m ' ;; "mm/dd/yyyy") HISTTIMEFORMAT='%m/%d/%Y %T ' ;; "dd.mm.yyyy") HISTTIMEFORMAT='%d.%m.%Y %T ' ;; "yyyy-mm-dd"|*) HISTTIMEFORMAT='%F %T ' ;; esac ================================================ FILE: lib/misc.sh ================================================ #! bash oh-my-bash.module ## jobs #setopt long_list_jobs ## pager env_default PAGER 'less' env_default LESS '-R' ## super user alias _omb_util_alias _='sudo' _omb_util_alias please='sudo' ## more intelligent acking for ubuntu users if _omb_util_binary_exists ack-grep; then _omb_util_alias afind='ack-grep -il' else _omb_util_alias afind='ack -il' fi # only define LC_CTYPE if undefined if [[ -z "$LC_CTYPE" && -z "$LC_ALL" ]]; then export LC_CTYPE=${LANG%%:*} # pick the first entry from LANG fi # recognize comments shopt -s interactive_comments ================================================ FILE: lib/mo.sh ================================================ #! bash oh-my-bash.module # #/ Mo is a mustache template rendering software written in bash. It inserts #/ environment variables into templates. #/ #/ Simply put, mo will change {{VARIABLE}} into the value of that #/ environment variable. You can use {{#VARIABLE}}content{{/VARIABLE}} to #/ conditionally display content or iterate over the values of an array. #/ #/ Learn more about mustache templates at https://mustache.github.io/ #/ #/ Simple usage: #/ #/ mo [--false] [--help] [--source=FILE] filenames... #/ #/ --false - Treat the string "false" as empty for conditionals. #/ --help - This message. #/ --source=FILE - Load FILE into the environment before processing templates. # # Mo is under a MIT style licence with an additional non-advertising clause. # See LICENSE.md for the full text. # # This is open source! Please feel free to contribute. # # https://github.com/tests-always-included/mo # Public: Template parser function. Writes templates to stdout. # # $0 - Name of the mo file, used for getting the help message. # --false - Treat "false" as an empty value. You may set the # MO_FALSE_IS_EMPTY environment variable instead to a non-empty # value to enable this behavior. # --help - Display a help message. # --source=FILE - Source a file into the environment before processint # template files. # -- - Used to indicate the end of options. You may optionally # use this when filenames may start with two hyphens. # $@ - Filenames to parse. # # Mo uses the following environment variables: # # MO_FALSE_IS_EMPTY - When set to a non-empty value, the string "false" # will be treated as an empty value for the purposes # of conditionals. # MO_ORIGINAL_COMMAND - Used to find the `mo` program in order to generate # a help message. # # Returns nothing. function mo { # This function executes in a subshell so IFS is reset. # Namespace this variable so we don't conflict with desired values. local moContent f2source files doubleHyphens IFS=$' \n\t' files=() doubleHyphens=false if [[ $# -gt 0 ]]; then for arg in "$@"; do if $doubleHyphens; then # After we encounter two hyphens together, all the rest # of the arguments are files. files=("${files[@]}" "$arg") else case "$arg" in -h|--h|--he|--hel|--help|-\?) _moUsage "$0" exit 0 ;; --false) # shellcheck disable=SC2030 MO_FALSE_IS_EMPTY=true ;; --source=*) f2source="${arg#--source=}" if [[ -f "$f2source" ]]; then # shellcheck disable=SC1090 . "$f2source" else echo "No such file: $f2source" >&2 exit 1 fi ;; --) # Set a flag indicating we've encountered double hyphens doubleHyphens=true ;; *) # Every arg that is not a flag or a option should be a file files=("${files[@]}" "$arg") ;; esac fi done fi _moGetContent moContent "${files[@]}" _moParse "$moContent" "" true } # Internal: Scan content until the right end tag is found. Creates an array # with the following members: # # [0] = Content before end tag # [1] = End tag (complete tag) # [2] = Content after end tag # # Everything using this function uses the "standalone tags" logic. # # $1 - Name of variable for the array # $2 - Content # $3 - Name of end tag # $4 - If -z, do standalone tag processing before finishing # # Returns nothing. function _moFindEndTag { local content remaining scanned standaloneBytes tag #: Find open tags scanned="" _moSplit content "$2" '{{' '}}' while [[ "${#content[@]}" -gt 1 ]]; do _moTrimWhitespace tag "${content[1]}" #: Restore content[1] before we start using it content[1]='{{'"${content[1]}"'}}' case $tag in '#'* | '^'*) #: Start another block scanned="${scanned}${content[0]}${content[1]}" _moTrimWhitespace tag "${tag:1}" _moFindEndTag content "${content[2]}" "$tag" "loop" scanned="${scanned}${content[0]}${content[1]}" remaining=${content[2]} ;; '/'*) #: End a block - could be ours _moTrimWhitespace tag "${tag:1}" scanned="$scanned${content[0]}" if [[ "$tag" == "$3" ]]; then #: Found our end tag if [[ -z "${4-}" ]] && _moIsStandalone standaloneBytes "$scanned" "${content[2]}" true; then #: This is also a standalone tag - clean up whitespace #: and move those whitespace bytes to the "tag" element standaloneBytes=( $standaloneBytes ) content[1]="${scanned:${standaloneBytes[0]}}${content[1]}${content[2]:0:${standaloneBytes[1]}}" scanned="${scanned:0:${standaloneBytes[0]}}" content[2]="${content[2]:${standaloneBytes[1]}}" fi local "$1" && _moIndirectArray "$1" "$scanned" "${content[1]}" "${content[2]}" return 0 fi scanned="$scanned${content[1]}" remaining=${content[2]} ;; *) #: Ignore all other tags scanned="${scanned}${content[0]}${content[1]}" remaining=${content[2]} ;; esac _moSplit content "$remaining" '{{' '}}' done #: Did not find our closing tag scanned="$scanned${content[0]}" local "$1" && _moIndirectArray "$1" "${scanned}" "" "" } # Internal: Find the first index of a substring. If not found, sets the # index to -1. # # $1 - Destination variable for the index # $2 - Haystack # $3 - Needle # # Returns nothing. function _moFindString { local pos string string=${2%%$3*} [[ "$string" == "$2" ]] && pos=-1 || pos=${#string} local "$1" && _moIndirect "$1" "$pos" } # Internal: Generate a dotted name based on current context and target name. # # $1 - Target variable to store results # $2 - Context name # $3 - Desired variable name # # Returns nothing. function _moFullTagName { if [[ -z "${2-}" ]] || [[ "$2" == *.* ]]; then local "$1" && _moIndirect "$1" "$3" else local "$1" && _moIndirect "$1" "${2}.${3}" fi } # Internal: Fetches the content to parse into a variable. Can be a list of # partials for files or the content from stdin. # # $1 - Variable name to assign this content back as # $2-@ - File names (optional) # # Returns nothing. function _moGetContent { local content filename target target=$1 shift if [[ "${#@}" -gt 0 ]]; then content="" for filename in "$@"; do #: This is so relative paths work from inside template files content="$content"'{{>'"$filename"'}}' done else _moLoadFile content /dev/stdin fi local "$target" && _moIndirect "$target" "$content" } # Internal: Indent a string, placing the indent at the beginning of every # line that has any content. # # $1 - Name of destination variable to get an array of lines # $2 - The indent string # $3 - The string to reindent # # Returns nothing. function _moIndentLines { local content fragment len posN posR result trimmed result="" len=$((${#3} - 1)) #: This removes newline and dot from the workaround in _moPartial content="${3:0:$len}" if [[ -z "${2-}" ]]; then local "$1" && _moIndirect "$1" "$content" return 0 fi _moFindString posN "$content" $'\n' _moFindString posR "$content" $'\r' while [[ "$posN" -gt -1 ]] || [[ "$posR" -gt -1 ]]; do if [[ "$posN" -gt -1 ]]; then fragment="${content:0:$posN + 1}" content=${content:$posN + 1} else fragment="${content:0:$posR + 1}" content=${content:$posR + 1} fi _moTrimChars trimmed "$fragment" false true " " $'\t' $'\n' $'\r' if [[ -n "$trimmed" ]]; then fragment="$2$fragment" fi result="$result$fragment" _moFindString posN "$content" $'\n' _moFindString posR "$content" $'\r' done _moTrimChars trimmed "$content" false true " " $'\t' if [[ -n "$trimmed" ]]; then content="$2$content" fi result="$result$content" local "$1" && _moIndirect "$1" "$result" } # Internal: Send a variable up to the parent of the caller of this function. # # $1 - Variable name # $2 - Value # # Examples # # callFunc () { # local "$1" && _moIndirect "$1" "the value" # } # callFunc dest # echo "$dest" # writes "the value" # # Returns nothing. function _moIndirect { unset -v "$1" printf -v "$1" '%s' "$2" } # Internal: Send an array as a variable up to caller of a function # # $1 - Variable name # $2-@ - Array elements # # Examples # # callFunc () { # local myArray=(one two three) # local "$1" && _moIndirectArray "$1" "${myArray[@]}" # } # callFunc dest # echo "${dest[@]}" # writes "one two three" # # Returns nothing. function _moIndirectArray { unset -v "$1" # IFS must be set to a string containing space or unset in order for # the array slicing to work regardless of the current IFS setting on # bash 3. This is detailed further at # https://github.com/fidian/gg-core/pull/7 eval "$(printf "IFS= %s=(\"\${@:2}\") IFS=%q" "$1" "$IFS")" } # Internal: Determine if a given environment variable exists and if it is # an array. # # $1 - Name of environment variable # # Be extremely careful. Even if strict mode is enabled, it is not honored # in newer versions of Bash. Any errors that crop up here will not be # caught automatically. # # Examples # # var=(abc) # if _moIsArray var; then # echo "This is an array" # echo "Make sure you don't accidentally use \$var" # fi # # Returns 0 if the name is not empty, 1 otherwise. function _moIsArray { # Namespace this variable so we don't conflict with what we're testing. local moTestResult moTestResult=$(declare -p "$1" 2>/dev/null) || return 1 [[ "${moTestResult:0:10}" == "declare -a" ]] && return 0 [[ "${moTestResult:0:10}" == "declare -A" ]] && return 0 return 1 } # Internal: Determine if the given name is a defined function. # # $1 - Function name to check # # Be extremely careful. Even if strict mode is enabled, it is not honored # in newer versions of Bash. Any errors that crop up here will not be # caught automatically. # # Examples # # moo () { # echo "This is a function" # } # if _moIsFunction moo; then # echo "moo is a defined function" # fi # # Returns 0 if the name is a function, 1 otherwise. function _moIsFunction { local functionList functionName functionList=$(declare -F) functionList=( ${functionList//declare -f /} ) for functionName in "${functionList[@]}"; do if [[ "$functionName" == "$1" ]]; then return 0 fi done return 1 } # Internal: Determine if the tag is a standalone tag based on whitespace # before and after the tag. # # Passes back a string containing two numbers in the format "BEFORE AFTER" # like "27 10". It indicates the number of bytes remaining in the "before" # string (27) and the number of bytes to trim in the "after" string (10). # Useful for string manipulation: # # $1 - Variable to set for passing data back # $2 - Content before the tag # $3 - Content after the tag # $4 - true/false: is this the beginning of the content? # # Examples # # _moIsStandalone RESULT "$before" "$after" false || return 0 # RESULT_ARRAY=( $RESULT ) # echo "${before:0:${RESULT_ARRAY[0]}}...${after:${RESULT_ARRAY[1]}}" # # Returns nothing. function _moIsStandalone { local afterTrimmed beforeTrimmed char _moTrimChars beforeTrimmed "$2" false true " " $'\t' _moTrimChars afterTrimmed "$3" true false " " $'\t' char=$((${#beforeTrimmed} - 1)) char=${beforeTrimmed:$char} if [[ "$char" != $'\n' ]] && [[ "$char" != $'\r' ]]; then if [[ -n "$char" ]] || ! $4; then return 1 fi fi char=${afterTrimmed:0:1} if [[ "$char" != $'\n' ]] && [[ "$char" != $'\r' ]] && [[ -n "$char" ]]; then return 2 fi if [[ "$char" == $'\r' ]] && [[ "${afterTrimmed:1:1}" == $'\n' ]]; then char="$char"$'\n' fi local "$1" && _moIndirect "$1" "$((${#beforeTrimmed})) $((${#3} + ${#char} - ${#afterTrimmed}))" } # Internal: Join / implode an array # # $1 - Variable name to receive the joined content # $2 - Joiner # $3-$* - Elements to join # # Returns nothing. function _moJoin { local joiner part result target target=$1 joiner=$2 result=$3 shift 3 for part in "$@"; do result="$result$joiner$part" done local "$target" && _moIndirect "$target" "$result" } # Internal: Read a file into a variable. # # $1 - Variable name to receive the file's content # $2 - Filename to load # # Returns nothing. function _moLoadFile { local content len # The subshell removes any trailing newlines. We forcibly add # a dot to the content to preserve all newlines. # TODO: remove cat and replace with read loop? content=$(cat -- "$2"; echo '.') len=$((${#content} - 1)) content=${content:0:$len} # Remove last dot local "$1" && _moIndirect "$1" "$content" } # Internal: Process a chunk of content some number of times. Writes output # to stdout. # # $1 - Content to parse repeatedly # $2 - Tag prefix (context name) # $3-@ - Names to insert into the parsed content # # Returns nothing. function _moLoop { local content context contextBase content=$1 contextBase=$2 shift 2 while [[ "${#@}" -gt 0 ]]; do _moFullTagName context "$contextBase" "$1" _moParse "$content" "$context" false shift done } # Internal: Parse a block of text, writing the result to stdout. # # $1 - Block of text to change # $2 - Current name (the variable NAME for what {{.}} means) # $3 - true when no content before this, false otherwise # # Returns nothing. function _moParse { # Keep naming variables mo* here to not overwrite needed variables # used in the string replacements local moBlock moContent moCurrent moIsBeginning moTag moCurrent=$2 moIsBeginning=$3 # Find open tags _moSplit moContent "$1" '{{' '}}' while [[ "${#moContent[@]}" -gt 1 ]]; do _moTrimWhitespace moTag "${moContent[1]}" case $moTag in '#'*) # Loop, if/then, or pass content through function # Sets context _moStandaloneAllowed moContent "${moContent[@]}" "$moIsBeginning" _moTrimWhitespace moTag "${moTag:1}" _moFindEndTag moBlock "$moContent" "$moTag" _moFullTagName moTag "$moCurrent" "$moTag" if _moTest "$moTag"; then # Show / loop / pass through function if _moIsFunction "$moTag"; then #: TODO: Consider piping the output to _moGetContent #: so the lambda does not execute in a subshell? moContent=$($moTag "${moBlock[0]}") _moParse "$moContent" "$moCurrent" false moContent="${moBlock[2]}" elif _moIsArray "$moTag"; then eval "_moLoop \"\${moBlock[0]}\" \"$moTag\" \"\${!${moTag}[@]}\"" else _moParse "${moBlock[0]}" "$moCurrent" false fi fi moContent="${moBlock[2]}" ;; '>'*) # Load partial - get name of file relative to cwd _moPartial moContent "${moContent[@]}" "$moIsBeginning" "$moCurrent" ;; '/'*) # Closing tag - If hit in this loop, we simply ignore # Matching tags are found in _moFindEndTag _moStandaloneAllowed moContent "${moContent[@]}" "$moIsBeginning" ;; '^'*) # Display section if named thing does not exist _moStandaloneAllowed moContent "${moContent[@]}" "$moIsBeginning" _moTrimWhitespace moTag "${moTag:1}" _moFindEndTag moBlock "$moContent" "$moTag" _moFullTagName moTag "$moCurrent" "$moTag" if ! _moTest "$moTag"; then _moParse "${moBlock[0]}" "$moCurrent" false "$moCurrent" fi moContent="${moBlock[2]}" ;; '!'*) # Comment - ignore the tag content entirely # Trim spaces/tabs before the comment _moStandaloneAllowed moContent "${moContent[@]}" "$moIsBeginning" ;; .) # Current content (environment variable or function) _moStandaloneDenied moContent "${moContent[@]}" _moShow "$moCurrent" "$moCurrent" ;; '=') # Change delimiters # Any two non-whitespace sequences separated by whitespace. # TODO _moStandaloneAllowed moContent "${moContent[@]}" "$moIsBeginning" ;; '{'*) # Unescaped - split on }}} not }} _moStandaloneDenied moContent "${moContent[@]}" moContent="${moTag:1}"'}}'"$moContent" _moSplit moContent "$moContent" '}}}' _moTrimWhitespace moTag "${moContent[0]}" _moFullTagName moTag "$moCurrent" "$moTag" moContent=${moContent[1]} # Now show the value _moShow "$moTag" "$moCurrent" ;; '&'*) # Unescaped _moStandaloneDenied moContent "${moContent[@]}" _moTrimWhitespace moTag "${moTag:1}" _moFullTagName moTag "$moCurrent" "$moTag" _moShow "$moTag" "$moCurrent" ;; *) # Normal environment variable or function call _moStandaloneDenied moContent "${moContent[@]}" _moFullTagName moTag "$moCurrent" "$moTag" _moShow "$moTag" "$moCurrent" ;; esac moIsBeginning=false _moSplit moContent "$moContent" '{{' '}}' done echo -n "${moContent[0]}" } # Internal: Process a partial. # # Indentation should be applied to the entire partial # # Prefix all variables. # # $1 - Name of destination "content" variable. # $2 - Content before the tag that was not yet written # $3 - Tag content # $4 - Content after the tag # $5 - true/false: is this the beginning of the content? # $6 - Current context name # # Returns nothing. function _moPartial { # Namespace variables here to prevent conflicts. local moContent moFilename moIndent moPartial moStandalone if _moIsStandalone moStandalone "$2" "$4" "$5"; then moStandalone=( $moStandalone ) echo -n "${2:0:${moStandalone[0]}}" moIndent=${2:${moStandalone[0]}} moContent=${4:${moStandalone[1]}} else moIndent="" echo -n "$2" moContent=$4 fi _moTrimWhitespace moFilename "${3:1}" # Execute in subshell to preserve current cwd and environment ( # TODO: Remove dirname and use a function instead cd "$(dirname -- "$moFilename")" || exit 1 _moIndentLines moPartial "$moIndent" "$( _moLoadFile moPartial "${moFilename##*/}" # Fix bash handling of subshells # The extra dot is removed in _moIndentLines echo -n "${moPartial}." )" _moParse "$moPartial" "$6" true ) local "$1" && _moIndirect "$1" "$moContent" } # Internal: Show an environment variable or the output of a function to # stdout. # # Limit/prefix any variables used. # # $1 - Name of environment variable or function # $2 - Current context # # Returns nothing. function _moShow { # Namespace these variables local moJoined moNameParts if _moIsFunction "$1"; then CONTENT=$($1 "") _moParse "$CONTENT" "$2" false return 0 fi _moSplit moNameParts "$1" "." if [[ -z "${moNameParts[1]}" ]]; then if _moIsArray "$1"; then eval _moJoin moJoined "," "\${$1[@]}" echo -n "$moJoined" else echo -n "${!1}" fi else # Further subindexes are disallowed eval "echo -n \"\${${moNameParts[0]}[${moNameParts[1]%%.*}]}\"" fi } # Internal: Split a larger string into an array. # # $1 - Destination variable # $2 - String to split # $3 - Starting delimiter # $4 - Ending delimiter (optional) # # Returns nothing. function _moSplit { local pos result result=( "$2" ) _moFindString pos "${result[0]}" "$3" if [[ "$pos" -ne -1 ]]; then # The first delimiter was found result[1]=${result[0]:$pos + ${#3}} result[0]=${result[0]:0:$pos} if [[ -n "${4-}" ]]; then _moFindString pos "${result[1]}" "$4" if [[ "$pos" -ne -1 ]]; then # The second delimiter was found result[2]="${result[1]:$pos + ${#4}}" result[1]="${result[1]:0:$pos}" fi fi fi local "$1" && _moIndirectArray "$1" "${result[@]}" } # Internal: Handle the content for a standalone tag. This means removing # whitespace (not newlines) before a tag and whitespace and a newline after # a tag. That is, assuming, that the line is otherwise empty. # # $1 - Name of destination "content" variable. # $2 - Content before the tag that was not yet written # $3 - Tag content (not used) # $4 - Content after the tag # $5 - true/false: is this the beginning of the content? # # Returns nothing. function _moStandaloneAllowed { local bytes if _moIsStandalone bytes "$2" "$4" "$5"; then bytes=( $bytes ) echo -n "${2:0:${bytes[0]}}" local "$1" && _moIndirect "$1" "${4:${bytes[1]}}" else echo -n "$2" local "$1" && _moIndirect "$1" "$4" fi } # Internal: Handle the content for a tag that is never "standalone". No # adjustments are made for newlines and whitespace. # # $1 - Name of destination "content" variable. # $2 - Content before the tag that was not yet written # $3 - Tag content (not used) # $4 - Content after the tag # # Returns nothing. function _moStandaloneDenied { echo -n "$2" local "$1" && _moIndirect "$1" "$4" } # Internal: Determines if the named thing is a function or if it is a # non-empty environment variable. When MO_FALSE_IS_EMPTY is set to a # non-empty value, then "false" is also treated is an empty value. # # Do not use variables without prefixes here if possible as this needs to # check if any name exists in the environment # # $1 - Name of environment variable or function # $2 - Current value (our context) # MO_FALSE_IS_EMPTY - When set to a non-empty value, this will say the # string value "false" is empty. # # Returns 0 if the name is not empty, 1 otherwise. When MO_FALSE_IS_EMPTY # is set, this returns 1 if the name is "false". function _moTest { # Test for functions _moIsFunction "$1" && return 0 if _moIsArray "$1"; then # Arrays must have at least 1 element eval "[[ \"\${#${1}[@]}\" -gt 0 ]]" && return 0 else # If MO_FALSE_IS_EMPTY is set, then return 1 if the value of # the variable is "false". # shellcheck disable=SC2031 [[ -n "${MO_FALSE_IS_EMPTY-}" ]] && [[ "${!1-}" == "false" ]] && return 1 # Environment variables must not be empty [[ -n "${!1}" ]] && return 0 fi return 1 } # Internal: Trim the leading whitespace only. # # $1 - Name of destination variable # $2 - The string # $3 - true/false - trim front? # $4 - true/false - trim end? # $5-@ - Characters to trim # # Returns nothing. function _moTrimChars { local back current front last target varName target=$1 current=$2 front=$3 back=$4 last="" shift 4 # Remove target, string, trim front flag, trim end flag while [[ "$current" != "$last" ]]; do last=$current for varName in "$@"; do $front && current="${current/#$varName}" $back && current="${current/%$varName}" done done local "$target" && _moIndirect "$target" "$current" } # Internal: Trim leading and trailing whitespace from a string. # # $1 - Name of variable to store trimmed string # $2 - The string # # Returns nothing. function _moTrimWhitespace { local result _moTrimChars result "$2" true true $'\r' $'\n' $'\t' " " local "$1" && _moIndirect "$1" "$result" } # Internal: Displays the usage for mo. Pulls this from the file that # contained the `mo` function. Can only work when the right filename # comes is the one argument, and that only happens when `mo` is called # with `$0` set to this file. # # $1 - Filename that has the help message # # Returns nothing. function _moUsage { grep '^#/' "${MO_ORIGINAL_COMMAND}" | cut -c 4- } # Save the original command's path for usage later MO_ORIGINAL_COMMAND="$(cd "${BASH_SOURCE[0]%/*}" || exit 1; pwd)/${BASH_SOURCE[0]##*/}" # If sourced, load all functions. # If executed, perform the actions as expected. if [[ "$0" == "${BASH_SOURCE[0]}" ]] || [[ -z "${BASH_SOURCE[0]}" ]]; then mo "$@" fi ================================================ FILE: lib/nvm.sh ================================================ #! bash oh-my-bash.module # get the node.js version function nvm_prompt_info() { [[ -f "$NVM_DIR/nvm.sh" ]] || return local nvm_prompt nvm_prompt=$(node -v 2>/dev/null) [[ "${nvm_prompt}x" == "x" ]] && return nvm_prompt=${nvm_prompt:1} _omb_util_print "${OSH_THEME_NVM_PROMPT_PREFIX}${nvm_prompt}${OSH_THEME_NVM_PROMPT_SUFFIX}" } ================================================ FILE: lib/omb-completion.sh ================================================ #! bash oh-my-bash.module # Copyright 2023 Koichi Murase. # # Helper functions for completions # ## @fn _omb_completion_reassemble_breaks exclude ## @param[in] $1 exclude Characters to exclude from COMP_WORDSBREAKS ## @var[out] cur[0] Current word after reassembly ## @var[out] cur[1] Part of ${cur[0]} that was originally in previous words ## in COMP_WORDS. ## @arr[out] COMPREPLY This functions empties the array COMPREPLY. function _omb_completion_reassemble_breaks { local exclude=$1 local line=$COMP_LINE point=$COMP_POINT local breaks=${COMP_WORDBREAKS//[\"\'$exclude]} COMPREPLY=() cur=("${COMP_WORDS[COMP_CWORD]}" '') local word rprefix= rword= for word in "${COMP_WORDS[@]::COMP_CWORD+1}"; do local space=${line%%"$word"*} if [[ $space == "$line" ]]; then # error: COMP_LINE does not contain enough words return 1 fi word=${word::point - ${#space}} if [[ $space || $rword == *["$breaks"] || $word == ["$breaks"]* ]]; then rprefix= rword=$word else rprefix=$rword rword+=$word fi line=${line:${#space}+${#word}} ((point -= ${#space} + ${#word})) ((point >= 0)) || break done cur=("$rword" "$rprefix") } ## @fn _omb_completion_resolve_breaks ## Adjust completions generated for the reassembled word ## @var[out] cur[1] Prefix to remove set by _omb_completion_reassemble_breaks ## @arr[out] COMPREPLY This functions empties the array COMPREPLY. function _omb_completion_resolve_breaks { if [[ ${cur[1]} ]]; then local i for i in "${!COMPREPLY[@]}"; do if [[ ${COMPREPLY[i]} == "$cur_prefix"* ]]; then COMPREPLY[i]=${COMPREPLY[i]#"$cur_prefix"} else unset -v 'COMPREPLY[i]' fi done COMPREPLY=("${COMPREPLY[@]}") fi } ================================================ FILE: lib/omb-deprecate.sh ================================================ #! bash oh-my-bash.module function _omb_deprecate_warning { local level=$1 msg=$2 local sep=$_omb_term_teal: local src=$_omb_term_purple${BASH_SOURCE[level+1]} local line=$_omb_term_green${BASH_LINENO[level]} local func=${FUNCNAME[level+1]} if [[ $func && $func != source ]]; then func=" $_omb_term_teal($_omb_term_navy$func$_omb_term_teal)" else func= fi _omb_util_print "$src$sep$line$func$sep$_omb_term_reset $msg" } function _omb_deprecate_function__notify { local old=$1 new=$2 local v=__omb_deprecate_Function_$old; v=${v//[!a-zA-Z0-9_]/'_'} [[ ${!v+set} ]] && return 0 local esc_old=$_omb_term_bold_brown$old$_omb_term_reset local esc_new=$_omb_term_bold_navy$new$_omb_term_reset _omb_deprecate_warning 2 "The function '$esc_old' is deprecated. Please use '$esc_new'." >&2 printf -v "$v" notified } function _omb_deprecate_function { local version=$1 old=$2 new=$3 local warning= ((_omb_version >= version)) && warning="_omb_deprecate_function__notify '$old' '$new'; " builtin eval -- "function $old { $warning$new \"\$@\"; }" } function _omb_deprecate_defun_print { local version=$1 old=$2 new=$3 var=${4:-REPLY} local warning= ((_omb_version >= version)) && warning="_omb_deprecate_function__notify '$old' '$new'; " builtin eval -- "function $old { ${warning}local $var; $new \"\$@\"; _omb_util_print \"\$$var\"; }" } function _omb_deprecate_defun_put { local version=$1 old=$2 new=$3 var=${4:-REPLY} local warning= ((_omb_version >= version)) && warning="_omb_deprecate_function__notify '$old' '$new'; " builtin eval -- "function $old { ${warning}local $var; $new \"\$@\"; _omb_util_put \"\$$var\"; }" } ## @fn _omb_deprecate_declare version old_name new_name opts arg ## @param[in] version ## The OMB version starting warning messages. ## ## @param[in] old_name new_name ## old and new variable names. The empty value of new_name indicates that ## the old_name is just deprecated, or there is no unique corresponding new ## variable. ## ## @param[in] opts ## a colon-separated list of the following fields: ## ## sync ## detect changes in either of old variable and new variable, and apply ## the change to the other. ## track ## copy from the new variable to the old variable when the value is ## changed. ## ## @param[in] arg ## When new_name is not specified, arg contains an error message that will ## be shown when the old_name is accessed. ## ## @fn _omb_deprecate_declare__init ## @var[in] __ver __old __new __opts __msg function _omb_deprecate_declare__init { if [[ ${!__old+set} ]]; then __opts=$__opts:notified if ((_omb_version >= __ver)); then if [[ $__new ]]; then _omb_util_print "oh-my-bash: The variable '$__old' is set but has been renamed to '$__new'. Please use '$__new'." else _omb_util_print "oh-my-bash: The variable '$__old' is set but has been deprecated.${__msg+ $__msg}" fi >/dev/tty fi if [[ $__new && ! ${!__new+set} ]]; then printf -v "$__new" '%s' "${!__old}" fi fi } if ((_omb_bash_version >= 40300)); then _omb_deprecate_declare=() declare -gA _omb_deprecate_declare_counter=() function _omb_deprecate_declare { local __ver=$1 __old=$2 __new=$3 __opts=$4 __msg=$5 _omb_deprecate_declare__init unset -n "$__old" unset -v "$__old" if ((_omb_version >= __ver)); then local __index=${#_omb_deprecate_declare[@]} _omb_deprecate_declare[__index]=$__old:$__new:$__msg eval "declare -gn $__old='$__new[_omb_deprecate_declare_counter[$__index,\$BASH_SOURCE,\$LINENO]+=\$(_omb_deprecate_declare__notify $__index),0]'" else eval "declare -gn $__old='$__new'" fi } function _omb_deprecate_declare__notify { local __index=$1 data=${_omb_deprecate_declare[__index]} local __old=${data%%:*}; data=${data#*:} local __new=${data%%:*}; data=${data#*:} local __msg=$data local count=${_omb_deprecate_declare_counter[$__index,${BASH_SOURCE[1]},${BASH_LINENO[0]}]:-0} if ((count == 0)); then local esc_old=$_omb_term_bold_brown$__old$_omb_term_reset local esc_new=$_omb_term_bold_navy$__new$_omb_term_reset if [[ $__new ]]; then _omb_deprecate_warning 1 "The variable '$esc_old' has been renamed to '$esc_new'. Please use '$esc_new'." else _omb_deprecate_warning 1 "The variable '$esc_old' has been deprecated.${__msg+ $__msg}" fi >/dev/tty fi _omb_util_print 1 } else _omb_deprecate_declare=() _omb_deprecate_declare_notify=() _omb_deprecate_declare_value=() function _omb_deprecate_declare { local __ver=$1 __old=$2 __new=$3 __opts=$4 __msg=$5 _omb_deprecate_declare__init if [[ ! $__new ]]; then # (show warning when used) nothing can be done for bash <= 4.2 return 0 fi local __notify= if ((_omb_version >= __ver)) && [[ :$__opts: != *:notified:* ]]; then __notify=1 fi printf -v "$__old" %s "${!__new-}" if [[ :$__opts: == *:track:* ]]; then local __index=${#_omb_deprecate_declare[@]} _omb_deprecate_declare[__index]=track:$__old:$__new:$__msg _omb_deprecate_declare_notify[__index]=$__notify elif [[ :$__opts: == *:sync:* ]]; then local __index=${#_omb_deprecate_declare[@]} _omb_deprecate_declare[__index]=sync:$__old:$__new:$__msg _omb_deprecate_declare_notify[__index]=$__notify _omb_deprecate_declare_value[__index]=${__new} fi } function _omb_deprecate_declare__sync { local __index __pair __type __old __new __msg for __index in "${!_omb_util_deprecate[@]}"; do __pair=${_omb_util_deprecate[__index]} __type=${__pair%%:*} __pair=${__pair#*:} __old=${__pair%%:*} __pair=${__pair#*:} __new=${_pair%%:*} __msg=${__pair#*:} [[ ${!__new} != "$__value" || ${!__old} != "$__value" ]] || continue # Notify deprecation when the variable 'old_name' has been first changed. if [[ ${!__old+set} && ${!__old} != "$__value" && ${_omb_deprecate_declare_notify[__index]} ]]; then _omb_deprecate_declare_notify[__index]= local esc_old=$_omb_term_bold_brown$__old$_omb_term_reset local esc_new=$_omb_term_bold_navy$__new$_omb_term_reset if [[ $__new ]]; then _omb_util_print "oh-my-bash: The variable '$esc_old' is changed but has been renamed to '$esc_new'. Please use '$esc_new'." else _omb_util_print "oh-my-bash: The variable '$esc_old' is changed but has been deprecated.${__msg+ $__msg}" fi >/dev/tty fi case $__type in (sync) local __value=${_omb_util_deprecate_value[__index]} __event= if [[ ! ${!__new+set} || ! ${!__old+set} ]]; then __value=${!__new-${!__old-}} __event=change elif [[ ${!__new} != "$__value" ]]; then __value=${!__new} __event=change elif [[ ${!__old} != "$__value" ]]; then __value=${!__old} __event=change fi if [[ $__event ]]; then _omb_util_deprecate_value[__index]=$__value printf -v "$__new" %s "$__value" printf -v "$__old" %s "$__value" fi ;; (track) printf -v "$__old" %s "${!__new-}" ;; esac done } _omb_util_add_prompt_command _omb_deprecate_declare__sync fi if ((_omb_bash_version >= 40300)); then _omb_deprecate_const=() _omb_deprecate_const_value=() declare -gA _omb_deprecate_const_counter=() function _omb_deprecate_const { local __ver=$1 __old=$2 __value=$3 __msg=$4 if [[ ${!__old+set} ]]; then return 0 fi if ((_omb_version >= __ver)); then local __index=${#_omb_deprecate_const[@]} _omb_deprecate_const[__index]=$__old:$__msg _omb_deprecate_const_value[__index]=$__value printf -v "_omb_deprecate_Const_$__old" %s "$__value" eval "declare -gn $__old='_omb_deprecate_Const_$__old[_omb_deprecate_const_counter[$__index,\$BASH_SOURCE,\$LINENO]+=\$(_omb_deprecate_const__notify $__index),0]'" else printf -v "$__old" %s "$__value" fi } function _omb_deprecate_const__notify { local __index=$1 local __old=${_omb_deprecate_const[__index]%%:*} local __msg=${_omb_deprecate_const[__index]#*:} local __value=${_omb_deprecate_const_value[__index]} local __ref=_omb_deprecate_Const_$__old if [[ ${!__ref-} == "$__value" ]]; then local count=${_omb_deprecate_const_counter[$__index,${BASH_SOURCE[1]},${BASH_LINENO[0]}]:-0} if ((count == 0)); then local esc_old=$_omb_term_bold_brown$__old$_omb_term_reset _omb_deprecate_warning 1 "The variable '$esc_old' has been deprecated.${__msg+ $__msg}" >&2 fi fi _omb_util_print 1 } function _omb_deprecate_const__sync { local __index __old __curval __compaction= for __index in "${!_omb_deprecate_const[@]}"; do __old=${_omb_deprecate_const[__index]%%:*} [[ $__old ]] || continue __ref=_omb_deprecate_Const_$__old __curval=${!__ref-} if [[ $__curval != "${_omb_deprecate_const_value[__index]}" ]]; then _omb_deprecate_const[__index]= _omb_deprecate_const_value[__index]= unset -n "$__old" printf -v "$__old" %s "$__curval" fi done } _omb_util_add_prompt_command _omb_deprecate_const__sync else function _omb_deprecate_const { local __ver=$1 __old=$2 __value=$3 __msg=$4 if [[ ${!__old+set} ]]; then return 0 fi printf -v "$__old" %s "$__value" } fi _omb_deprecate_msg_please_use="Please use '$_omb_term_bold_navy%s$_omb_term_reset'." #------------------------------------------------------------------------------ # deprecate functions and variables # oh-my-bash.sh -- These functions were originally used to find # "fpath" directories, which are not supported by Bash. function is_plugin { local base_dir=$1 name=$2 [[ -f $base_dir/plugins/$name/$name.plugin.sh || -f $base_dir/plugins/$name/_$name ]] } function is_completion { local base_dir=$1 name=$2 [[ -f $base_dir/completions/$name/$name.completion.sh ]] } function is_alias { local base_dir=$1 name=$2 [[ -f $base_dir/aliases/$name/$name.aliases.sh ]] } # lib/utils.sh -- Logging functions _omb_deprecate_function 20000 type_exists _omb_util_binary_exists _omb_deprecate_const 20000 ncolors "$_omb_term_colors" "${_omb_deprecate_msg_please_use/'%s'/_omb_term_colors}" _omb_deprecate_const 20000 bold "$_omb_term_bold" "${_omb_deprecate_msg_please_use/'%s'/_omb_term_bold}" _omb_deprecate_const 20000 underline "$_omb_term_underline" "${_omb_deprecate_msg_please_use/'%s'/_omb_term_underline}" _omb_deprecate_const 20000 reset "$_omb_term_reset" "${_omb_deprecate_msg_please_use/'%s'/_omb_term_reset}" _omb_deprecate_const 20000 tan "$_omb_term_olive" "${_omb_deprecate_msg_please_use/'%s'/_omb_term_olive}" _omb_deprecate_red=${_omb_term_brown:+$'\1'$_omb_term_brown$'\2'} _omb_deprecate_green=${_omb_term_green:+$'\1'$_omb_term_green$'\2'} _omb_deprecate_yellow=${_omb_term_olive:+$'\1'$_omb_term_olive$'\2'} _omb_deprecate_blue=${_omb_term_navy:+$'\1'$_omb_term_navy$'\2'} _omb_deprecate_magenta=${_omb_term_purple:+$'\1'$_omb_term_purple$'\2'} _omb_deprecate_const 20000 red "$_omb_deprecate_red" "Please use '${_omb_term_bold_navy}_omb_term_brown$_omb_term_reset' or '${_omb_term_bold_navy}_omb_prompt_brown$_omb_term_reset'." _omb_deprecate_const 20000 green "$_omb_deprecate_green" "Please use '${_omb_term_bold_navy}_omb_term_green$_omb_term_reset' or '${_omb_term_bold_navy}_omb_prompt_green$_omb_term_reset'." _omb_deprecate_const 20000 yellow "$_omb_deprecate_yellow" "Please use '${_omb_term_bold_navy}_omb_term_olive$_omb_term_reset' or '${_omb_term_bold_navy}_omb_prompt_olive$_omb_term_reset'." _omb_deprecate_const 20000 blue "$_omb_deprecate_blue" "Please use '${_omb_term_bold_navy}_omb_term_navy$_omb_term_reset' or '${_omb_term_bold_navy}_omb_prompt_navy$_omb_term_reset'." _omb_deprecate_const 20000 purple "$_omb_deprecate_magenta" "Please use '${_omb_term_bold_navy}_omb_term_purple$_omb_term_reset' or '${_omb_term_bold_navy}_omb_prompt_purple$_omb_term_reset'." _omb_deprecate_function 20000 e_header _omb_log_header _omb_deprecate_function 20000 e_arrow _omb_log_arrow _omb_deprecate_function 20000 e_success _omb_log_success _omb_deprecate_function 20000 e_error _omb_log_error _omb_deprecate_function 20000 e_warning _omb_log_warning _omb_deprecate_function 20000 e_underline _omb_log_underline _omb_deprecate_function 20000 e_bold _omb_log_bold _omb_deprecate_function 20000 e_note _omb_log_note # plugins/bashmarks/bashmarks.plugin.sh [ This anyway conflicts with # variables defined by themes (axin, mairan, sexy, etc.) so do not # define fallbacks and warnings. ] #_omb_deprecate_const RED "0;31m" "${_omb_deprecate_msg_please_use/'%s'/\${_omb_term_brown:2}}" #_omb_deprecate_const GREEN "0;33m" "${_omb_deprecate_msg_please_use/'%s'/\${_omb_term_green:2}}" # themes/* _omb_deprecate_function 20000 prompt_command _omb_theme_PROMPT_COMMAND _omb_deprecate_function 20000 prompt _omb_theme_PROMPT_COMMAND _omb_deprecate_function 20000 prompt_setter _omb_theme_PROMPT_COMMAND _omb_deprecate_function 20000 pure_setter _omb_theme_PROMPT_COMMAND # pure, gallifrey _omb_deprecate_function 20000 dulcie_setter _omb_theme_PROMPT_COMMAND # dulcie _omb_deprecate_function 20000 _brainy_setter _omb_theme_PROMPT_COMMAND # brainy _omb_deprecate_function 20000 set_bash_prompt _omb_theme_PROMPT_COMMAND # agnoster ================================================ FILE: lib/omb-prompt-base.sh ================================================ #! bash oh-my-bash.module _omb_module_require lib:omb-util _omb_module_require lib:omb-deprecate _omb_module_require lib:omb-prompt-colors CLOCK_CHAR_THEME_PROMPT_PREFIX='' CLOCK_CHAR_THEME_PROMPT_SUFFIX='' CLOCK_THEME_PROMPT_PREFIX='' CLOCK_THEME_PROMPT_SUFFIX='' THEME_PROMPT_HOST='\H' SCM_CHECK=${SCM_CHECK:=true} SCM_THEME_PROMPT_DIRTY=' ✗' SCM_THEME_PROMPT_CLEAN=' ✓' SCM_THEME_PROMPT_PREFIX=' |' SCM_THEME_PROMPT_SUFFIX='|' SCM_THEME_BRANCH_PREFIX='' SCM_THEME_TAG_PREFIX='tag:' SCM_THEME_DETACHED_PREFIX='detached:' SCM_THEME_BRANCH_TRACK_PREFIX=' → ' SCM_THEME_BRANCH_GONE_PREFIX=' ⇢ ' SCM_THEME_CURRENT_USER_PREFFIX=' ☺︎ ' SCM_THEME_CURRENT_USER_SUFFIX='' SCM_THEME_CHAR_PREFIX='' SCM_THEME_CHAR_SUFFIX='' THEME_BATTERY_PERCENTAGE_CHECK=${THEME_BATTERY_PERCENTAGE_CHECK:=true} SCM_GIT_SHOW_DETAILS=${SCM_GIT_SHOW_DETAILS:=true} SCM_GIT_SHOW_REMOTE_INFO=${SCM_GIT_SHOW_REMOTE_INFO:=auto} SCM_GIT_DISABLE_UNTRACKED_DIRTY=${SCM_GIT_DISABLE_UNTRACKED_DIRTY:=false} SCM_GIT_IGNORE_UNTRACKED=${SCM_GIT_IGNORE_UNTRACKED:=false} SCM_GIT_SHOW_CURRENT_USER=${SCM_GIT_SHOW_CURRENT_USER:=false} SCM_GIT_SHOW_MINIMAL_INFO=${SCM_GIT_SHOW_MINIMAL_INFO:=false} SCM_GIT='git' SCM_GIT_CHAR='±' SCM_GIT_DETACHED_CHAR='⌿' SCM_GIT_AHEAD_CHAR="↑" SCM_GIT_BEHIND_CHAR="↓" SCM_GIT_UNTRACKED_CHAR="?:" SCM_GIT_UNSTAGED_CHAR="U:" SCM_GIT_STAGED_CHAR="S:" SCM_HG='hg' SCM_HG_CHAR='☿' SCM_SVN='svn' SCM_SVN_CHAR='⑆' SCM_NONE='NONE' SCM_NONE_CHAR='○' THEME_SHOW_USER_HOST=${THEME_SHOW_USER_HOST:=false} USER_HOST_THEME_PROMPT_PREFIX='' USER_HOST_THEME_PROMPT_SUFFIX='' # #new # OMB_PROMPT_RBFU_FORMAT=' |%s|' # OMB_PROMPT_RBENV_FORMAT=' |%s|' # OMB_PROMPT_RVM_FORMAT=' |%s|' # OMB_PROMPT_CHRUBY_FORMAT=' |%s|' # deprecate RBFU_THEME_PROMPT_PREFIX=' |' RBFU_THEME_PROMPT_SUFFIX='|' RBENV_THEME_PROMPT_PREFIX=' |' RBENV_THEME_PROMPT_SUFFIX='|' RVM_THEME_PROMPT_PREFIX=' |' RVM_THEME_PROMPT_SUFFIX='|' CHRUBY_THEME_PROMPT_PREFIX=' |' CHRUBY_THEME_PROMPT_SUFFIX='|' # # new # OMB_PROMPT_VIRTUALENV_FORMAT=' |%s|' # OMB_PROMPT_CONDAENV_FORMAT=' |%s|' # OMB_PROMPT_CONDAENV_USE_BASENAME=true # OMB_PROMPT_PYTHON_VERSION_FORMAT=' |%s|' # OMB_PROMPT_SHOW_PYTHON_VENV=true OMB_PROMPT_SPACK_ENV_FORMAT='[%s] ' # deprecate VIRTUALENV_THEME_PROMPT_PREFIX=' |' VIRTUALENV_THEME_PROMPT_SUFFIX='|' CONDAENV_THEME_PROMPT_PREFIX=' |' CONDAENV_THEME_PROMPT_SUFFIX='|' PYTHON_THEME_PROMPT_PREFIX=' |' PYTHON_THEME_PROMPT_SUFFIX='|' ## @fn _omb_prompt_format var value fmt_prefix[:deprecated] ## @param[in] var ## @param[in] value ## @param[in] fmt_prefix ## @param[in,opt] deprecated ## @var[out] $var function _omb_prompt_format { local __format=${3%%:*}_FORMAT; __format=${!__format-} if [[ ! $__format ]]; then local __prefix=${3#*:}_PREFIX; __prefix=${!__prefix-} # deprecate name local __suffix=${3#*:}_SUFFIX; __suffix=${!__suffix-} # deprecate name __format=${__prefix//'%'/'%%'}%s${__suffix//'%'/'%%'} fi local REPLY _omb_string_escape_prompt "$2" printf -v "$1" "$__format" "$REPLY" } function _omb_prompt_git { command git "$@" } function _omb_prompt_git_status_enabled { [[ $(_omb_prompt_git config --get-regexp '^(oh-my-zsh|bash-it|oh-my-bash)\.hide-status$' | awk '$2== "1" {hide_status = 1;} END { print hide_status; }') != "1" ]] } function scm { if [[ "$SCM_CHECK" = false ]]; then SCM=$SCM_NONE elif [[ -f .git/HEAD ]]; then SCM=$SCM_GIT elif _omb_util_binary_exists git && [[ -n "$(_omb_prompt_git rev-parse --is-inside-work-tree 2> /dev/null)" ]]; then SCM=$SCM_GIT elif [[ -d .hg ]]; then SCM=$SCM_HG elif _omb_util_binary_exists hg && [[ -n "$(command hg root 2> /dev/null)" ]]; then SCM=$SCM_HG elif [[ -d .svn ]]; then SCM=$SCM_SVN else SCM=$SCM_NONE fi } function scm_prompt_char { if [[ -z $SCM ]]; then scm; fi if [[ $SCM == $SCM_GIT ]]; then SCM_CHAR=$SCM_GIT_CHAR elif [[ $SCM == $SCM_HG ]]; then SCM_CHAR=$SCM_HG_CHAR elif [[ $SCM == $SCM_SVN ]]; then SCM_CHAR=$SCM_SVN_CHAR else SCM_CHAR=$SCM_NONE_CHAR fi } function scm_prompt_vars { scm scm_prompt_char SCM_DIRTY=0 SCM_STATE='' [[ $SCM == $SCM_GIT ]] && git_prompt_vars && return [[ $SCM == $SCM_HG ]] && hg_prompt_vars && return [[ $SCM == $SCM_SVN ]] && svn_prompt_vars && return } function scm_prompt_info { scm scm_prompt_char scm_prompt_info_common } function scm_prompt_char_info { scm_prompt_char echo -ne "${SCM_THEME_CHAR_PREFIX}${SCM_CHAR}${SCM_THEME_CHAR_SUFFIX}" scm_prompt_info_common } function scm_prompt_info_common { SCM_DIRTY=0 SCM_STATE='' if [[ ${SCM} == ${SCM_GIT} ]]; then if [[ ${SCM_GIT_SHOW_MINIMAL_INFO} == true ]]; then # user requests minimal git status information git_prompt_minimal_info else # more detailed git status git_prompt_info fi return fi # TODO: consider adding minimal status information for hg and svn [[ ${SCM} == ${SCM_HG} ]] && hg_prompt_info && return [[ ${SCM} == ${SCM_SVN} ]] && svn_prompt_info && return } # This is added to address bash shell interpolation vulnerability described # here: https://github.com/njhartwell/pw3nage function git_clean_branch { local unsafe_ref=$(_omb_prompt_git symbolic-ref -q HEAD 2> /dev/null) local stripped_ref=${unsafe_ref##refs/heads/} local clean_ref=${stripped_ref//[\$\`\\]/-} clean_ref=${clean_ref//[^[:print:]]/-} # strip escape sequences, etc. _omb_util_print $clean_ref } function git_prompt_minimal_info { local ref status local git_status_flags=('--porcelain') local clean_symbol="${SCM_THEME_PROMPT_CLEAN:-✔}" local dirty_symbol="${SCM_THEME_PROMPT_DIRTY:-✘}" SCM_STATE=${clean_symbol} if _omb_prompt_git_status_enabled; then # Get the branch reference ref=$(git_clean_branch) || ref=$(_omb_prompt_git rev-parse --short HEAD 2> /dev/null) || return 0 SCM_BRANCH=${SCM_THEME_BRANCH_PREFIX}${ref} # Get the status [[ "${SCM_GIT_IGNORE_UNTRACKED}" = "true" ]] && git_status_flags+=('--untracked-files=no') status=$(_omb_prompt_git status "${git_status_flags[@]}" 2> /dev/null | tail -n1) if [[ -n ${status} ]]; then SCM_DIRTY=1 SCM_STATE=${dirty_symbol} fi # Output the git prompt SCM_PREFIX=${SCM_THEME_PROMPT_PREFIX} SCM_SUFFIX=${SCM_THEME_PROMPT_SUFFIX} echo -e "${SCM_PREFIX}${SCM_BRANCH}${SCM_STATE}${SCM_SUFFIX}" fi } function git_status_summary { awk ' BEGIN { untracked=0; unstaged=0; staged=0; } { if (!after_first && $0 ~ /^##.+/) { print $0 seen_header = 1 } else if ($0 ~ /^\?\? .+/) { untracked += 1 } else { if ($0 ~ /^.[^ ] .+/) { unstaged += 1 } if ($0 ~ /^[^ ]. .+/) { staged += 1 } } after_first = 1 } END { if (!seen_header) { print } print untracked "\t" unstaged "\t" staged }' } function git_prompt_vars { local details='' local git_status_flags='' [[ "$(_omb_prompt_git rev-parse --is-inside-work-tree 2> /dev/null)" == "true" ]] || return 1 SCM_STATE=${GIT_THEME_PROMPT_CLEAN:-$SCM_THEME_PROMPT_CLEAN} if _omb_prompt_git_status_enabled; then [[ "${SCM_GIT_IGNORE_UNTRACKED}" = "true" ]] && git_status_flags='-uno' local status_lines=$((_omb_prompt_git status --porcelain ${git_status_flags} -b 2> /dev/null || _omb_prompt_git status --porcelain ${git_status_flags} 2> /dev/null) | git_status_summary) local status=$(awk 'NR==1' <<< "$status_lines") local counts=$(awk 'NR==2' <<< "$status_lines") IFS=$'\t' read -r untracked_count unstaged_count staged_count <<< "$counts" if [[ "${untracked_count}" -gt 0 || "${unstaged_count}" -gt 0 || "${staged_count}" -gt 0 ]]; then if [[ "${SCM_GIT_SHOW_DETAILS}" = "true" ]]; then [[ "${staged_count}" -gt 0 ]] && details+=" ${SCM_GIT_STAGED_CHAR}${staged_count}" && SCM_DIRTY=3 [[ "${unstaged_count}" -gt 0 ]] && details+=" ${SCM_GIT_UNSTAGED_CHAR}${unstaged_count}" && SCM_DIRTY=2 [[ "${untracked_count}" -gt 0 ]] && details+=" ${SCM_GIT_UNTRACKED_CHAR}${untracked_count}" && [[ "$SCM_GIT_DISABLE_UNTRACKED_DIRTY" != "true" ]] && SCM_DIRTY=1 fi [[ "$SCM_GIT_DISABLE_UNTRACKED_DIRTY" != "true" || "${unstaged_count}" -gt 0 || "${staged_count}" -gt 0 ]] && SCM_STATE=${GIT_THEME_PROMPT_DIRTY:-$SCM_THEME_PROMPT_DIRTY} fi fi [[ "${SCM_GIT_SHOW_CURRENT_USER}" == "true" ]] && details+="$(git_user_info)" SCM_CHANGE=$(_omb_prompt_git rev-parse --short HEAD 2>/dev/null) local ref=$(git_clean_branch) if [[ -n "$ref" ]]; then SCM_BRANCH="${SCM_THEME_BRANCH_PREFIX}${ref}" local tracking_info="$(grep -- "${SCM_BRANCH}\.\.\." <<< "${status}")" if [[ -n "${tracking_info}" ]]; then [[ "${tracking_info}" =~ .+\[gone\]$ ]] && local branch_gone="true" tracking_info=${tracking_info#\#\# ${SCM_BRANCH}...} tracking_info=${tracking_info% [*} local remote_name=${tracking_info%%/*} local remote_branch=${tracking_info#${remote_name}/} local remote_info="" local num_remotes=$(_omb_prompt_git remote | wc -l 2> /dev/null) [[ "${SCM_BRANCH}" = "${remote_branch}" ]] && local same_branch_name=true if ([[ "${SCM_GIT_SHOW_REMOTE_INFO}" = "auto" ]] && [[ "${num_remotes}" -ge 2 ]]) || [[ "${SCM_GIT_SHOW_REMOTE_INFO}" = "true" ]]; then remote_info="${remote_name}" [[ "${same_branch_name}" != "true" ]] && remote_info+="/${remote_branch}" elif [[ ${same_branch_name} != "true" ]]; then remote_info="${remote_branch}" fi if [[ -n "${remote_info}" ]];then if [[ "${branch_gone}" = "true" ]]; then SCM_BRANCH+="${SCM_THEME_BRANCH_GONE_PREFIX}${remote_info}" else SCM_BRANCH+="${SCM_THEME_BRANCH_TRACK_PREFIX}${remote_info}" fi fi fi SCM_GIT_DETACHED="false" else local detached_prefix="" ref=$(_omb_prompt_git describe --tags --exact-match 2> /dev/null) if [[ -n "$ref" ]]; then detached_prefix=${SCM_THEME_TAG_PREFIX} else ref=$(_omb_prompt_git describe --contains --all HEAD 2> /dev/null) ref=${ref#remotes/} [[ -z "$ref" ]] && ref=${SCM_CHANGE} detached_prefix=${SCM_THEME_DETACHED_PREFIX} fi SCM_BRANCH=${detached_prefix}${ref} SCM_GIT_DETACHED="true" fi local ahead_re='.+ahead ([0-9]+).+' local behind_re='.+behind ([0-9]+).+' [[ "${status}" =~ ${ahead_re} ]] && SCM_BRANCH+=" ${SCM_GIT_AHEAD_CHAR}${BASH_REMATCH[1]}" [[ "${status}" =~ ${behind_re} ]] && SCM_BRANCH+=" ${SCM_GIT_BEHIND_CHAR}${BASH_REMATCH[1]}" local stash_count="$(_omb_prompt_git stash list 2> /dev/null | wc -l | tr -d ' ')" [[ "${stash_count}" -gt 0 ]] && SCM_BRANCH+=" {${stash_count}}" SCM_BRANCH+=${details} SCM_PREFIX=${GIT_THEME_PROMPT_PREFIX:-$SCM_THEME_PROMPT_PREFIX} SCM_SUFFIX=${GIT_THEME_PROMPT_SUFFIX:-$SCM_THEME_PROMPT_SUFFIX} } function svn_prompt_vars { if [[ -n $(command svn status 2> /dev/null) ]]; then SCM_DIRTY=1 SCM_STATE=${SVN_THEME_PROMPT_DIRTY:-$SCM_THEME_PROMPT_DIRTY} else SCM_DIRTY=0 SCM_STATE=${SVN_THEME_PROMPT_CLEAN:-$SCM_THEME_PROMPT_CLEAN} fi SCM_PREFIX=${SVN_THEME_PROMPT_PREFIX:-$SCM_THEME_PROMPT_PREFIX} SCM_SUFFIX=${SVN_THEME_PROMPT_SUFFIX:-$SCM_THEME_PROMPT_SUFFIX} SCM_BRANCH=$(command svn info 2> /dev/null | awk -F/ '/^URL:/ { for (i=0; i<=NF; i++) { if ($i == "branches" || $i == "tags" ) { print $(i+1); break }; if ($i == "trunk") { print $i; break } } }') || return SCM_CHANGE=$(command svn info 2> /dev/null | sed -ne 's#^Revision: ##p' ) } # this functions returns absolute location of .hg directory if one exists # It starts in the current directory and moves its way up until it hits /. # If we get to / then no Mercurial repository was found. # Example: # - lets say we cd into ~/Projects/Foo/Bar # - .hg is located in ~/Projects/Foo/.hg # - get_hg_root starts at ~/Projects/Foo/Bar and sees that there is no .hg directory, so then it goes into ~/Projects/Foo function get_hg_root { local CURRENT_DIR=$PWD while [ "$CURRENT_DIR" != "/" ]; do if [ -d "$CURRENT_DIR/.hg" ]; then _omb_util_print "$CURRENT_DIR/.hg" return fi CURRENT_DIR=$(dirname "$CURRENT_DIR") done } function hg_prompt_vars { if [[ -n $(command hg status 2> /dev/null) ]]; then SCM_DIRTY=1 SCM_STATE=${HG_THEME_PROMPT_DIRTY:-$SCM_THEME_PROMPT_DIRTY} else SCM_DIRTY=0 SCM_STATE=${HG_THEME_PROMPT_CLEAN:-$SCM_THEME_PROMPT_CLEAN} fi SCM_PREFIX=${HG_THEME_PROMPT_PREFIX:-$SCM_THEME_PROMPT_PREFIX} SCM_SUFFIX=${HG_THEME_PROMPT_SUFFIX:-$SCM_THEME_PROMPT_SUFFIX} HG_ROOT=$(get_hg_root) if [ -f "$HG_ROOT/branch" ]; then # Mercurial holds it's current branch in .hg/branch file SCM_BRANCH=$(cat "$HG_ROOT/branch") else SCM_BRANCH=$(command hg summary 2> /dev/null | grep branch: | awk '{print $2}') fi if [ -f "$HG_ROOT/dirstate" ]; then # Mercurial holds various information about the working directory in .hg/dirstate file. More on http://mercurial.selenic.com/wiki/DirState SCM_CHANGE=$(hexdump -n 10 -e '1/1 "%02x"' "$HG_ROOT/dirstate" | cut -c-12) else SCM_CHANGE=$(command hg summary 2> /dev/null | grep parent: | awk '{print $2}') fi } ## @fn _omb_prompt_get_rbfu ## @var[out] rbfu ## @exit function _omb_prompt_get_rbfu { rbfu=$RBFU_RUBY_VERSION [[ $rbfu ]] || return 1 _omb_prompt_format rbfu "$rbfu" OMB_PROMPT_RBFU:RBFU_THEME_PROMPT } ## @fn _omb_prompt_get_rbenv ## @var[out] rbenv ## @exit function _omb_prompt_get_rbenv { rbenv= _omb_util_command_exists rbenv || return 1 rbenv=$(rbenv version-name) rbenv commands | command grep -q gemset && gemset=$(rbenv gemset active 2> /dev/null) && rbenv="$rbenv@${gemset%% *}" [[ $rbenv != system ]] || return 1 _omb_prompt_format rbenv "$rbenv" OMB_PROMPT_RBENV:RBENV_THEME_PROMPT } ## @fn _omb_prompt_get_rvm ## @var[out] rvm ## @exit function _omb_prompt_get_rvm { rvm= if _omb_util_command_exists rvm-prompt; then rvm=$(rvm-prompt) elif _omb_util_command_exists rvm; then local rvm_current=$(rvm tools identifier) local rvm_default=$(rvm strings default) [[ $rvm_current && $rvm_default && $rvm_current != "$rvm_default" ]] || return 1 rvm=$rvm_current fi [[ $rvm ]] || return 1 _omb_prompt_format rvm "$rvm" OMB_PROMPT_RVM:RVM_THEME_PROMPT } ## @fn _omb_prompt_get_chruby ## @var[out] chruby ## @exit function _omb_prompt_get_chruby { chruby= _omb_util_function_exists chruby || return 1 _omb_util_function_exists chruby_auto && chruby=$(chruby_auto) local ruby_version ruby_version=$(ruby --version | command awk '{print $1, $2;}') || return chruby | command grep -q '\*' || ruby_version="${ruby_version} (system)" _omb_prompt_format ruby_version "$ruby_version" OMB_PROMPT_CHRUBY:CHRUBY_THEME_PROMPT chruby+=$ruby_version } ## @fn _omb_prompt_get_ruby_env ## @var[out] ruby_env ## @exit function _omb_prompt_get_ruby_env { local rbfu rbenv rvm chruby _omb_prompt_get_rbfu _omb_prompt_get_rbenv _omb_prompt_get_rvm _omb_prompt_get_chruby ruby_env=$rbfu$rbenv$rvm$chruby [[ $ruby_env ]] } _omb_util_defun_print _omb_prompt_{print,get}_rbfu rbfu _omb_util_defun_print _omb_prompt_{print,get}_rbenv rbenv _omb_util_defun_print _omb_prompt_{print,get}_rvm rvm _omb_util_defun_print _omb_prompt_{print,get}_chruby chruby _omb_util_defun_print _omb_prompt_{print,get}_ruby_env ruby_env _omb_deprecate_function 20000 rbfu_version_prompt _omb_prompt_print_rbfu _omb_deprecate_function 20000 rbenv_version_prompt _omb_prompt_print_rbenv _omb_deprecate_function 20000 rvm_version_prompt _omb_prompt_print_rvm _omb_deprecate_function 20000 chruby_version_prompt _omb_prompt_print_chruby _omb_deprecate_function 20000 ruby_version_prompt _omb_prompt_print_ruby_env ## @fn _omb_prompt_get_virtualenv ## @var[out] virtualenv ## @exit function _omb_prompt_get_virtualenv { virtualenv= [[ ${VIRTUAL_ENV-} ]] || return 1 virtualenv=${VIRTUAL_ENV_PROMPT:-$(basename "$VIRTUAL_ENV")} _omb_prompt_format virtualenv "$virtualenv" OMB_PROMPT_VIRTUALENV:VIRTUALENV_THEME_PROMPT } ## @fn _omb_prompt_get_condaenv ## @var[out] condaenv ## @exit function _omb_prompt_get_condaenv { condaenv= [[ ${CONDA_DEFAULT_ENV-} && ${CONDA_SHLVL-} != 0 ]] || return 1 condaenv=$CONDA_DEFAULT_ENV if [[ ${OMB_PROMPT_CONDAENV_USE_BASENAME-} == true ]]; then condaenv=$(basename "$condaenv") fi _omb_prompt_format condaenv "$condaenv" OMB_PROMPT_CONDAENV:CONDAENV_THEME_PROMPT } ## @fn _omb_prompt_get_python_version ## @var[out] python_version ## @exit function _omb_prompt_get_python_version { python_version=$(python --version 2>&1 | command awk '{print "py-"$2;}') [[ $python_version ]] || return 1 _omb_prompt_format python_version "$python_version" OMB_PROMPT_PYTHON_VERSION:PYTHON_THEME_PROMPT } ## @fn _omb_prompt_get_python_venv ## @var[out] python_venv ## @exit function _omb_prompt_get_python_venv { python_venv= [[ ${OMB_PROMPT_SHOW_PYTHON_VENV-} == true ]] || return 1 local virtualenv condaenv _omb_prompt_get_virtualenv _omb_prompt_get_condaenv python_venv=$virtualenv$condaenv [[ $python_venv ]] } ## @fn _omb_prompt_get_python_env ## @var[out] python_env ## @exit function _omb_prompt_get_python_env { local virtualenv condaenv python_version _omb_prompt_get_virtualenv _omb_prompt_get_condaenv _omb_prompt_get_python_version python_env=$virtualenv$condaenv$python_version [[ $python_env ]] } ## @fn _omb_prompt_get_spack_env ## @var[out] spack_env ## @exit function _omb_prompt_get_spack_env { spack_env= [[ ${OMB_PROMPT_SHOW_SPACK_ENV-} == true ]] || return 1 [[ ${SPACK_ENV-} ]] || return 1 _omb_prompt_format spack_env "$(basename "$SPACK_ENV")" OMB_PROMPT_SPACK_ENV } _omb_util_defun_print _omb_prompt_{print,get}_virtualenv virtualenv _omb_util_defun_print _omb_prompt_{print,get}_condaenv condaenv _omb_util_defun_print _omb_prompt_{print,get}_python_version python_version _omb_util_defun_print _omb_prompt_{print,get}_python_venv python_venv _omb_util_defun_print _omb_prompt_{print,get}_python_env python_env _omb_deprecate_function 20000 virtualenv_prompt _omb_prompt_print_virtualenv _omb_deprecate_function 20000 condaenv_prompt _omb_prompt_print_condaenv _omb_deprecate_function 20000 py_interp_prompt _omb_prompt_print_python_version _omb_deprecate_function 20000 python_version_prompt _omb_prompt_print_python_env function git_user_info { # support two or more initials, set by 'git pair' plugin SCM_CURRENT_USER=$(_omb_prompt_git config user.initials | sed 's% %+%') # if `user.initials` weren't set, attempt to extract initials from `user.name` [[ -z "${SCM_CURRENT_USER}" ]] && SCM_CURRENT_USER=$(printf "%s" $(for word in $(_omb_prompt_git config user.name | tr 'A-Z' 'a-z'); do printf "%1.1s" $word; done)) [[ -n "${SCM_CURRENT_USER}" ]] && printf "%s" "$SCM_THEME_CURRENT_USER_PREFFIX$SCM_CURRENT_USER$SCM_THEME_CURRENT_USER_SUFFIX" } function clock_char { CLOCK_CHAR=${THEME_CLOCK_CHAR:-"⌚"} CLOCK_CHAR_COLOR=${THEME_CLOCK_CHAR_COLOR:-"$_omb_prompt_normal"} SHOW_CLOCK_CHAR=${THEME_SHOW_CLOCK_CHAR:-"true"} if [[ "${SHOW_CLOCK_CHAR}" = "true" ]]; then echo -e "${CLOCK_CHAR_COLOR}${CLOCK_CHAR_THEME_PROMPT_PREFIX}${CLOCK_CHAR}${CLOCK_CHAR_THEME_PROMPT_SUFFIX}" fi } function clock_prompt { CLOCK_COLOR=${THEME_CLOCK_COLOR:-"$_omb_prompt_normal"} CLOCK_FORMAT=${THEME_CLOCK_FORMAT:-"%H:%M:%S"} [ -z $THEME_SHOW_CLOCK ] && THEME_SHOW_CLOCK=${THEME_CLOCK_CHECK:-"true"} SHOW_CLOCK=$THEME_SHOW_CLOCK if [[ "${SHOW_CLOCK}" = "true" ]]; then CLOCK_STRING=$(date +"${CLOCK_FORMAT}") echo -e "${CLOCK_COLOR}${CLOCK_THEME_PROMPT_PREFIX}${CLOCK_STRING}${CLOCK_THEME_PROMPT_SUFFIX}" fi } function user_host_prompt { if [[ "${THEME_SHOW_USER_HOST}" = "true" ]]; then echo -e "${USER_HOST_THEME_PROMPT_PREFIX}\u@\h${USER_HOST_THEME_PROMPT_SUFFIX}" fi } # backwards-compatibility function git_prompt_info { git_prompt_vars echo -e "${SCM_PREFIX}${SCM_BRANCH}${SCM_STATE}${SCM_SUFFIX}" } function svn_prompt_info { svn_prompt_vars echo -e "${SCM_PREFIX}${SCM_BRANCH}${SCM_STATE}${SCM_SUFFIX}" } function hg_prompt_info() { hg_prompt_vars echo -e "${SCM_PREFIX}${SCM_BRANCH}:${SCM_CHANGE#*:}${SCM_STATE}${SCM_SUFFIX}" } function scm_char { scm_prompt_char echo -e "${SCM_THEME_CHAR_PREFIX}${SCM_CHAR}${SCM_THEME_CHAR_SUFFIX}" } function prompt_char { scm_char } function battery_char { if [[ "${THEME_BATTERY_PERCENTAGE_CHECK}" = true ]]; then echo -e "${_omb_prompt_bold_brown}$(battery_percentage)%" fi } if ! _omb_util_command_exists 'battery_charge' ; then # if user has installed battery plugin, skip this... function battery_charge (){ # no op _omb_util_put } fi # The battery_char function depends on the presence of the battery_percentage function. # If battery_percentage is not defined, then define battery_char as a no-op. if ! _omb_util_command_exists 'battery_percentage' ; then function battery_char (){ # no op _omb_util_put } fi function aws_profile { if [[ $AWS_DEFAULT_PROFILE ]]; then _omb_util_print "$AWS_DEFAULT_PROFILE" else _omb_util_print "default" fi } # Returns true if $1 is a shell function. _omb_deprecate_function 20000 fn_exists _omb_util_function_exists _omb_deprecate_function 20000 safe_append_prompt_command _omb_util_add_prompt_command ================================================ FILE: lib/omb-prompt-colors.sh ================================================ #! bash oh-my-bash.module # # 2022-01-20 Koichi Murase: renamed from "themes/colours.theme.sh" to "lib/omb-prompt-colors.sh" _omb_module_require lib:omb-deprecate function _omb_theme__construct_sgr { out= local reset= while (($#)); do local next=$1; shift case $next in reset) reset=0 ;; bold) out=${out:+$out;}1 ;; faint) out=${out:+$out;}2 ;; italic) out=${out:+$out;}3 ;; underline) out=${out:+$out;}4 ;; negative) out=${out:+$out;}7 ;; crossed) out=${out:+$out;}8 ;; color) local color=$1; shift local side=fg mode=normal case $1 in fg | bg) side=$1; shift ;; esac case $1 in normal | bright) mode=$1; shift ;; esac local prefix=3 case $side:$mode in fg:normal) prefix=3 ;; bg:normal) prefix=4 ;; fg:bright) prefix=9 ;; bg:bright) prefix=10 ;; esac case $color in black) color=0 ;; red) color=1 ;; green) color=2 ;; yellow) color=3 ;; blue) color=4 ;; magenta) color=5 ;; cyan) color=6 ;; white) color=7 ;; rgb) local r=$1 g=$2 b=$3; shift 3 if ((r == g && g == b)); then # gray range above 232 color=$((232 + r / 11)) else color="8;5;$(((r * 36 + b * 6 + g) / 51 + 16))" fi ;; *) _omb_util_print "_omb_theme_color: unknown color '$color'" >&2 continue ;; esac out=${out:+$out;}$prefix$color ;; '') out="${out:+$out;}$*" ;; *) _omb_util_print "_omb_theme_color: unknown token '$next'" >&2 ;; esac done if [[ $reset ]]; then out=$reset${out:+;$out} fi } function _omb_theme_color_prompt { local out _omb_theme__construct_sgr "$@" _omb_util_print "\[\e[${out}m\]" } function _omb_theme_color_echo { local out _omb_theme__construct_sgr "$@" _omb_util_print "\033[${out}m" } function _omb_prompt_color_initialize { _omb_prompt_normal='\[\e[0m\]' _omb_prompt_reset_color='\[\e[39m\]' # used by themes/gallifrey _omb_prompt_bold='\[\e[1m\]' local -a normal_colors=(black brown green olive navy purple teal silver) local -a bright_colors=(gray red lime yellow blue magenta cyan white) local bright_fg_prefix=9 bright_bg_prefix=10 ((_omb_term_colors >= 16)) || bright_fg_prefix=3 bright_bg_prefix=4 local index for ((index = 0; index < 8; index++)); do printf -v "_omb_prompt_${normal_colors[index]}" %s '\[\e[0;3'"$index"'m\]' printf -v "_omb_prompt_bold_${normal_colors[index]}" %s '\[\e[3'"$index"';1m\]' printf -v "_omb_prompt_underline_${normal_colors[index]}" %s '\[\e[3'"$index"';4m\]' printf -v "_omb_prompt_background_${normal_colors[index]}" %s '\[\e[4'"$index"'m\]' printf -v "_omb_prompt_${bright_colors[index]}" %s '\[\e[0;'"$bright_fg_prefix$index"'m\]' printf -v "_omb_prompt_bold_${bright_colors[index]}" %s '\[\e['"$bright_fg_prefix$index"';1m\]' printf -v "_omb_prompt_underline_${bright_colors[index]}" %s '\[\e['"$bright_fg_prefix$index"';4m\]' printf -v "_omb_prompt_background_${bright_colors[index]}" %s '\[\e['"$bright_bg_prefix$index"'m\]' done } _omb_prompt_color_initialize _omb_deprecate_function 20000 color _omb_theme_color_prompt _omb_deprecate_function 20000 echo_color _omb_theme_color_echo _omb_deprecate_const 20000 black "$_omb_prompt_black" "${_omb_deprecate_msg_please_use/'%s'/_omb_prompt_black}" _omb_deprecate_const 20000 cyan "$_omb_prompt_teal" "${_omb_deprecate_msg_please_use/'%s'/_omb_prompt_teal}" _omb_deprecate_const 20000 white "$_omb_prompt_white" "${_omb_deprecate_msg_please_use/'%s'/_omb_prompt_white}" _omb_deprecate_const 20000 orange "$_omb_prompt_red" "${_omb_deprecate_msg_please_use/'%s'/_omb_prompt_red}" _omb_deprecate_const 20000 bold_black "$_omb_prompt_bold_black" "${_omb_deprecate_msg_please_use/'%s'/_omb_prompt_bold_black}" _omb_deprecate_const 20000 bold_red "$_omb_prompt_bold_brown" "${_omb_deprecate_msg_please_use/'%s'/_omb_prompt_bold_brown}" _omb_deprecate_const 20000 bold_green "$_omb_prompt_bold_green" "${_omb_deprecate_msg_please_use/'%s'/_omb_prompt_bold_green}" _omb_deprecate_const 20000 bold_yellow "$_omb_prompt_bold_olive" "${_omb_deprecate_msg_please_use/'%s'/_omb_prompt_bold_olive}" _omb_deprecate_const 20000 bold_blue "$_omb_prompt_bold_navy" "${_omb_deprecate_msg_please_use/'%s'/_omb_prompt_bold_navy}" _omb_deprecate_const 20000 bold_purple "$_omb_prompt_bold_purple" "${_omb_deprecate_msg_please_use/'%s'/_omb_prompt_bold_purple}" _omb_deprecate_const 20000 bold_cyan "$_omb_prompt_bold_teal" "${_omb_deprecate_msg_please_use/'%s'/_omb_prompt_bold_teal}" _omb_deprecate_const 20000 bold_white "$_omb_prompt_bold_white" "${_omb_deprecate_msg_please_use/'%s'/_omb_prompt_bold_white}" _omb_deprecate_const 20000 bold_orange "$_omb_prompt_bold_red" "${_omb_deprecate_msg_please_use/'%s'/_omb_prompt_bold_red}" _omb_deprecate_const 20000 underline_black "$_omb_prompt_underline_black" "${_omb_deprecate_msg_please_use/'%s'/_omb_prompt_underline_black}" _omb_deprecate_const 20000 underline_red "$_omb_prompt_underline_brown" "${_omb_deprecate_msg_please_use/'%s'/_omb_prompt_underline_brown}" _omb_deprecate_const 20000 underline_green "$_omb_prompt_underline_green" "${_omb_deprecate_msg_please_use/'%s'/_omb_prompt_underline_green}" _omb_deprecate_const 20000 underline_yellow "$_omb_prompt_underline_olive" "${_omb_deprecate_msg_please_use/'%s'/_omb_prompt_underline_olive}" _omb_deprecate_const 20000 underline_blue "$_omb_prompt_underline_navy" "${_omb_deprecate_msg_please_use/'%s'/_omb_prompt_underline_navy}" _omb_deprecate_const 20000 underline_purple "$_omb_prompt_underline_purple" "${_omb_deprecate_msg_please_use/'%s'/_omb_prompt_underline_purple}" _omb_deprecate_const 20000 underline_cyan "$_omb_prompt_underline_teal" "${_omb_deprecate_msg_please_use/'%s'/_omb_prompt_underline_teal}" _omb_deprecate_const 20000 underline_white "$_omb_prompt_underline_white" "${_omb_deprecate_msg_please_use/'%s'/_omb_prompt_underline_white}" _omb_deprecate_const 20000 underline_orange "$_omb_prompt_underline_red" "${_omb_deprecate_msg_please_use/'%s'/_omb_prompt_underline_red}" _omb_deprecate_const 20000 background_black "$_omb_prompt_background_black" "${_omb_deprecate_msg_please_use/'%s'/_omb_prompt_background_black}" _omb_deprecate_const 20000 background_red "$_omb_prompt_background_brown" "${_omb_deprecate_msg_please_use/'%s'/_omb_prompt_background_brown}" _omb_deprecate_const 20000 background_green "$_omb_prompt_background_green" "${_omb_deprecate_msg_please_use/'%s'/_omb_prompt_background_green}" _omb_deprecate_const 20000 background_yellow "$_omb_prompt_background_olive" "${_omb_deprecate_msg_please_use/'%s'/_omb_prompt_background_olive}" _omb_deprecate_const 20000 background_blue "$_omb_prompt_background_navy" "${_omb_deprecate_msg_please_use/'%s'/_omb_prompt_background_navy}" _omb_deprecate_const 20000 background_purple "$_omb_prompt_background_purple" "${_omb_deprecate_msg_please_use/'%s'/_omb_prompt_background_purple}" _omb_deprecate_const 20000 background_cyan "$_omb_prompt_background_teal" "${_omb_deprecate_msg_please_use/'%s'/_omb_prompt_background_teal}" _omb_deprecate_const 20000 background_white "$_omb_prompt_background_white" "${_omb_deprecate_msg_please_use/'%s'/_omb_prompt_background_white}" _omb_deprecate_const 20000 background_orange "$_omb_prompt_background_red" "${_omb_deprecate_msg_please_use/'%s'/_omb_prompt_background_red}" _omb_deprecate_const 20000 normal "$_omb_prompt_normal" "${_omb_deprecate_msg_please_use/'%s'/_omb_prompt_normal}" _omb_deprecate_const 20000 reset_color "$_omb_prompt_reset_color" "${_omb_deprecate_msg_please_use/'%s'/_omb_prompt_reset_color}" _omb_deprecate_const 20000 echo_black "$_omb_term_black" "${_omb_deprecate_msg_please_use/'%s'/_omb_term_black}" _omb_deprecate_const 20000 echo_red "$_omb_term_brown" "${_omb_deprecate_msg_please_use/'%s'/_omb_term_brown}" _omb_deprecate_const 20000 echo_green "$_omb_term_green" "${_omb_deprecate_msg_please_use/'%s'/_omb_term_green}" _omb_deprecate_const 20000 echo_yellow "$_omb_term_olive" "${_omb_deprecate_msg_please_use/'%s'/_omb_term_olive}" _omb_deprecate_const 20000 echo_blue "$_omb_term_navy" "${_omb_deprecate_msg_please_use/'%s'/_omb_term_navy}" _omb_deprecate_const 20000 echo_purple "$_omb_term_purple" "${_omb_deprecate_msg_please_use/'%s'/_omb_term_purple}" _omb_deprecate_const 20000 echo_cyan "$_omb_term_teal" "${_omb_deprecate_msg_please_use/'%s'/_omb_term_teal}" _omb_deprecate_const 20000 echo_white "$_omb_term_white" "${_omb_deprecate_msg_please_use/'%s'/_omb_term_white}" _omb_deprecate_const 20000 echo_orange "$_omb_term_red" "${_omb_deprecate_msg_please_use/'%s'/_omb_term_red}" _omb_deprecate_const 20000 echo_bold_black "$_omb_term_bold_black" "${_omb_deprecate_msg_please_use/'%s'/_omb_term_bold_black}" _omb_deprecate_const 20000 echo_bold_red "$_omb_term_bold_brown" "${_omb_deprecate_msg_please_use/'%s'/_omb_term_bold_brown}" _omb_deprecate_const 20000 echo_bold_green "$_omb_term_bold_green" "${_omb_deprecate_msg_please_use/'%s'/_omb_term_bold_green}" _omb_deprecate_const 20000 echo_bold_yellow "$_omb_term_bold_olive" "${_omb_deprecate_msg_please_use/'%s'/_omb_term_bold_olive}" _omb_deprecate_const 20000 echo_bold_blue "$_omb_term_bold_navy" "${_omb_deprecate_msg_please_use/'%s'/_omb_term_bold_navy}" _omb_deprecate_const 20000 echo_bold_purple "$_omb_term_bold_purple" "${_omb_deprecate_msg_please_use/'%s'/_omb_term_bold_purple}" _omb_deprecate_const 20000 echo_bold_cyan "$_omb_term_bold_teal" "${_omb_deprecate_msg_please_use/'%s'/_omb_term_bold_teal}" _omb_deprecate_const 20000 echo_bold_white "$_omb_term_bold_white" "${_omb_deprecate_msg_please_use/'%s'/_omb_term_bold_white}" _omb_deprecate_const 20000 echo_bold_orange "$_omb_term_bold_red" "${_omb_deprecate_msg_please_use/'%s'/_omb_term_bold_red}" _omb_deprecate_const 20000 echo_underline_black "$_omb_term_underline_black" "${_omb_deprecate_msg_please_use/'%s'/_omb_term_underline_black}" _omb_deprecate_const 20000 echo_underline_red "$_omb_term_underline_brown" "${_omb_deprecate_msg_please_use/'%s'/_omb_term_underline_brown}" _omb_deprecate_const 20000 echo_underline_green "$_omb_term_underline_green" "${_omb_deprecate_msg_please_use/'%s'/_omb_term_underline_green}" _omb_deprecate_const 20000 echo_underline_yellow "$_omb_term_underline_olive" "${_omb_deprecate_msg_please_use/'%s'/_omb_term_underline_olive}" _omb_deprecate_const 20000 echo_underline_blue "$_omb_term_underline_navy" "${_omb_deprecate_msg_please_use/'%s'/_omb_term_underline_navy}" _omb_deprecate_const 20000 echo_underline_purple "$_omb_term_underline_purple" "${_omb_deprecate_msg_please_use/'%s'/_omb_term_underline_purple}" _omb_deprecate_const 20000 echo_underline_cyan "$_omb_term_underline_teal" "${_omb_deprecate_msg_please_use/'%s'/_omb_term_underline_teal}" _omb_deprecate_const 20000 echo_underline_white "$_omb_term_underline_white" "${_omb_deprecate_msg_please_use/'%s'/_omb_term_underline_white}" _omb_deprecate_const 20000 echo_underline_orange "$_omb_term_underline_red" "${_omb_deprecate_msg_please_use/'%s'/_omb_term_underline_red}" _omb_deprecate_const 20000 echo_background_black "$_omb_term_background_black" "${_omb_deprecate_msg_please_use/'%s'/_omb_term_background_black}" _omb_deprecate_const 20000 echo_background_red "$_omb_term_background_brown" "${_omb_deprecate_msg_please_use/'%s'/_omb_term_background_brown}" _omb_deprecate_const 20000 echo_background_green "$_omb_term_background_green" "${_omb_deprecate_msg_please_use/'%s'/_omb_term_background_green}" _omb_deprecate_const 20000 echo_background_yellow "$_omb_term_background_olive" "${_omb_deprecate_msg_please_use/'%s'/_omb_term_background_olive}" _omb_deprecate_const 20000 echo_background_blue "$_omb_term_background_navy" "${_omb_deprecate_msg_please_use/'%s'/_omb_term_background_navy}" _omb_deprecate_const 20000 echo_background_purple "$_omb_term_background_purple" "${_omb_deprecate_msg_please_use/'%s'/_omb_term_background_purple}" _omb_deprecate_const 20000 echo_background_cyan "$_omb_term_background_teal" "${_omb_deprecate_msg_please_use/'%s'/_omb_term_background_teal}" _omb_deprecate_const 20000 echo_background_white "$_omb_term_background_white" "${_omb_deprecate_msg_please_use/'%s'/_omb_term_background_white}" _omb_deprecate_const 20000 echo_background_orange "$_omb_term_background_red" "${_omb_deprecate_msg_please_use/'%s'/_omb_term_background_red}" _omb_deprecate_const 20000 echo_normal "$_omb_term_normal" "${_omb_deprecate_msg_please_use/'%s'/_omb_term_normal}" _omb_deprecate_const 20000 echo_reset_color "$_omb_term_reset_color" "${_omb_deprecate_msg_please_use/'%s'/_omb_term_reset_color}" ================================================ FILE: lib/omb-util.sh ================================================ #! bash oh-my-bash.module function _omb_util_put { printf '%s' "$@" } function _omb_util_print { local IFS=$' \t\n' printf '%s\n' "$*" } function _omb_util_print_lines { if (($#)); then printf '%s\n' "$@" fi } function _omb_string_escape_prompt { REPLY=$1 local specialchars='\`$' if [[ $REPLY == ["$specialchars"] ]]; then local i n=${#specialchars} a b for ((i=0;i. ## ## @fn _omb_util_readlink filename ## print the real path of the filename which is possibly a symbolic link. ## # use _omb_util_print _omb_module_require lib:omb-util # use _omb_util_function_exists, _omb_util_binary_exists _omb_module_require lib:utils if ((_omb_bash_version >= 40000)); then _omb_util_readlink_visited_init='local -A visited=()' function _omb_util_readlink__visited { [[ ${visited[$1]+set} ]] && return 0 visited[$1]=1 return 1 } else _omb_util_readlink_visited_init="local -a visited=()" function _omb_util_readlink__visited { local key for key in "${visited[@]}"; do [[ $1 == "$key" ]] && return 0 done visited=("$1" "${visited[@]}") return 1 } fi ## @fn _omb_util_readlink__readlink path ## @var[out] link function _omb_util_readlink__readlink { local path=$1 if _omb_util_function_exists readlink; then link=$(readlink -- "$path") [[ $link ]] elif _omb_util_binary_exists ls; then link=$(ls -ld -- "$path") && [[ $link == *" $path -> "?* ]] && link=${link#*" $path -> "} else false fi } 2>/dev/null ## @fn _omb_util_readlink__resolve_physical_directory ## @var[in,out] path function _omb_util_readlink__resolve_physical_directory { [[ $path == */?* ]] || return 0 local PWD=$PWD OLDPWD=$OLDPWD CDPATH= builtin cd -L . && local pwd=$PWD && builtin cd -P "${path%/*}/" && path=${PWD%/}/${path##*/} builtin cd -L "$pwd" return 0 } function _omb_util_readlink__resolve_loop { local path=$1 builtin eval -- "$_omb_util_readlink_visited_init" while [[ -h $path ]]; do local link _omb_util_readlink__visited "$path" && break _omb_util_readlink__readlink "$path" || break if [[ $link == /* || $path != */* ]]; then path=$link else _omb_util_readlink__resolve_physical_directory path=${path%/}/$link fi while [[ $path == ?*/ ]]; do path=${path%/}; done done _omb_util_print "$path" } function _omb_util_readlink__resolve { # Select implementation on the first call _omb_util_readlink_type= case $OSTYPE in (cygwin | msys | linux-gnu) # These systems provide "readlink -f". local readlink readlink=$(type -P readlink) case $readlink in (/bin/readlink | /usr/bin/readlink) # shellcheck disable=SC2100 _omb_util_readlink_type=readlink-f function _omb_util_readlink__resolve { readlink -f -- "$1"; } ;; esac ;; esac if [[ ! $_omb_util_readlink_type ]]; then _omb_util_readlink_type=loop function _omb_util_readlink__resolve { _omb_util_readlink__resolve_loop "$1"; } fi _omb_util_readlink__resolve "$1" } function _omb_util_readlink { if [[ -h $1 ]]; then _omb_util_readlink__resolve "$1" else _omb_util_print "$1" fi } ================================================ FILE: lib/shopt.sh ================================================ #! bash oh-my-bash.module # This file originally came from bash-sensible [1]. Some of the settings # related to history is separated into "lib/history.sh". The current version # is based on commit eb82f9e8. # # [1] https://github.com/mrzool/bash-sensible # Copyright (c) 2015 Mattia Tezzele, provided under the MIT license. # Various shell options collected in single file # taken from bash-sensible and other sources ## GENERAL OPTIONS ## # Prevent file overwrite on stdout redirection # Use `>|` to force redirection to an existing file set -o noclobber # Update window size after every command shopt -s checkwinsize # Automatically trim long paths in the prompt (requires Bash 4.x) PROMPT_DIRTRIM=${PROMPT_DIRTRIM:-2} # Enable history expansion with space # E.g. typing !! will replace the !! with your last command bind Space:magic-space # Turn on extended glob patterns such as @(...), *(...), ?(...), and +(...) shopt -s extglob # Turn on recursive globbing (enables ** to recurse all directories) shopt -s globstar 2> /dev/null # Case-sensitive globbing (used in pathname expansion) # # Note: We do not turn "nocaseglob" on by default. We have been turning on the # nocaseglob option for a long time, but this conflicts with users' # expectations that the pathname expansions are case-sensitive. This might # cause an unexpected destructive result e.g. with "rm ". Also, # the option OMB_CASE_SENSITIVE is originally for the case-(in)sensitive # completion and should not be mixed with the option for the pathname # expansion. See a discussion in Ref. [2]. A consistent change was also # applied to the upstream bash-sensible [3]. # # [2] https://github.com/ohmybash/oh-my-bash/issues/623 # [3] https://github.com/mrzool/bash-sensible/commit/eb82f9e87728ea10423a2a2b039a4b491d10c733 # #shopt -s nocaseglob ## SMARTER TAB-COMPLETION (Readline bindings) ## # Conditionally perform file completion in a case insensitive fashion. # Setting OMB_CASE_SENSITIVE to 'true' will switch from the default, # case insensitive, matching to the case-sensitive one # # Note: CASE_SENSITIVE is the compatibility name if [[ ${OMB_CASE_SENSITIVE:-${CASE_SENSITIVE:-}} == true ]]; then bind "set completion-ignore-case off" else # By default, case sensitivity is disabled. bind "set completion-ignore-case on" # Treat hyphens and underscores as equivalent # CASE_SENSITIVE must be off if [[ ! ${OMB_HYPHEN_SENSITIVE-} && ${HYPHEN_INSENSITIVE} ]]; then case $HYPHEN_INSENSITIVE in (true) OMB_HYPHEN_SENSITIVE=true ;; (false) OMB_HYPHEN_SENSITIVE=false ;; esac fi if [[ ${OMB_HYPHEN_SENSITIVE-} == false ]]; then bind "set completion-map-case on" fi fi # Display matches for ambiguous patterns at first tab press bind "set show-all-if-ambiguous on" # Immediately add a trailing slash when autocompleting symlinks to directories bind "set mark-symlinked-directories on" ## BETTER DIRECTORY NAVIGATION ## # Prepend cd to directory names automatically shopt -s autocd 2> /dev/null # Correct spelling errors during tab-completion shopt -s dirspell 2> /dev/null # Correct spelling errors in arguments supplied to cd shopt -s cdspell 2> /dev/null # This defines where cd looks for targets # Add the directories you want to have fast access to, separated by colon # Ex: CDPATH=".:~:~/projects" will look for targets in the current working directory, in home and in the ~/projec CDPATH="." # This allows you to bookmark your favorite places across the file system # Define a variable containing a path and you will be able to cd into it regardless of the directory you're in shopt -s cdable_vars ================================================ FILE: lib/spectrum.sh ================================================ #! bash oh-my-bash.module # A script to make using 256 colors in bash less painful. # P.C. Shyamshankar # Copied from http://github.com/sykora/etc/blob/master/zsh/functions/spectrum/ _omb_module_require lib:omb-deprecate _omb_module_require lib:omb-prompt-colors # typeset in bash does not have associative arrays, declare does in bash 4.0+ # https://stackoverflow.com/a/6047948 # This library only works for BASH 4.x to keep the minimum compatibility for macOS. # shellcheck disable=SC2034 if # shellcheck disable=SC2168 if ((_omb_bash_version >= 40200)); then declare -gA _omb_spectrum_fx=() declare -gA _omb_spectrum_fg=() declare -gA _omb_spectrum_bg=() declare -gA FX FG BG elif ((_omb_bash_version >= 40000)) && ! local _omb_local_test 2>/dev/null; then declare -A _omb_spectrum_fx=() declare -A _omb_spectrum_fg=() declare -A _omb_spectrum_bg=() declare -A FX FG BG else false fi then function _omb_spectrum__initialize() { _omb_spectrum_fx=( [reset]=$'\e[00m' [bold]=$'\e[01m' [no-bold]=$'\e[22m' [italic]=$'\e[03m' [no-italic]=$'\e[23m' [underline]=$'\e[04m' [no-underline]=$'\e[24m' [blink]=$'\e[05m' [no-blink]=$'\e[25m' [reverse]=$'\e[07m' [no-reverse]=$'\e[27m' ) local color for color in {000..255}; do _omb_spectrum_fg[$color]=$'\e[38;5;'${color}'m' _omb_spectrum_bg[$color]=$'\e[48;5;'${color}'m' done } _omb_spectrum__initialize _omb_deprecate_const 20000 _RED "$_omb_term_brown" "${_omb_deprecate_msg_please_use/'%s'/_omb_term_brown}" _omb_deprecate_const 20000 _NC "$_omb_term_reset" "${_omb_deprecate_msg_please_use/'%s'/_omb_term_reset}" function _omb_spectrum__deprecate() { local key for key in "${!_omb_spectrum_fx[@]}"; do FX[$key]=${_omb_spectrum_fx[$key]}; done for key in "${!_omb_spectrum_fg[@]}"; do FG[$key]=${_omb_spectrum_fg[$key]}; done for key in "${!_omb_spectrum_bg[@]}"; do BG[$key]=${_omb_spectrum_bg[$key]}; done } _omb_spectrum__deprecate fi OSH_SPECTRUM_TEXT=${OSH_SPECTRUM_TEXT:-Arma virumque cano Troiae qui primus ab oris} # Show all 256 colors with color number function spectrum_ls() { local code for code in {000..255}; do printf '%s: \e[38;5;%sm%s%s\n' "$code" "$code" "$OSH_SPECTRUM_TEXT" "$_omb_term_reset" done } # Show all 256 colors where the background is set to specific color function spectrum_bls() { local code for code in {000..255}; do printf '%s: \e[48;5;%sm%s%s\n' "$code" "$code" "$OSH_SPECTRUM_TEXT" "$_omb_term_reset" done } ================================================ FILE: lib/spinner.sh ================================================ #! bash oh-my-bash.module # # Move a process to background and track its progress in a smoothier way. # Could be use if $TERM not set. # # Examples # # echo -ne "${_omb_term_brown}I am running..." # ( my_long_task_running ) & # spinner # echo -ne "...${_omb_term_reset} ${_omb_term_green}DONE${_omb_term_reset}" # # This spinner is used when there is a terminal. function term_spinner { local pid=$! local delay=0.1 local spinstr='|/-\' while [ "$(ps a | awk '{print $1}' | grep $pid)" ]; do local temp=${spinstr#?} printf " [%c] " "$spinstr" local spinstr=$temp${spinstr%"$temp"} sleep $delay printf "\b\b\b\b\b\b" done printf " \b\b\b\b" } function no_term_spinner { local pid=$! local delay=0.1 local spinstr='|/-\' while [ "$(ps a | awk '{print $1}' | grep $pid)" ]; do printf "." sleep 2 done echo " ✓ " } function spinner { if [[ -z "$TERM" ]]; then no_term_spinner else term_spinner fi } ================================================ FILE: lib/theme-and-appearance.sh ================================================ #! bash oh-my-bash.module # colored ls export LSCOLORS='Gxfxcxdxdxegedabagacad' ================================================ FILE: lib/utils.sh ================================================ #! bash oh-my-bash.module ############################---Description---################################### # # # Summary : A collection of handy utilities and functions for bash # # Support : destro.nnt@gmail.com # # Created date : Mar 18,2017 # # Latest Modified date : Mar 18,2017 # # # ################################################################################ ############################---Usage---######################################### # source ~/path/to/directory/utils.sh ########################## Styled text output ################################## # e_header "I am a sample script" # e_success "I am a success message" # e_error "I am an error message" # e_warning "I am a warning message" # e_underline "I am underlined text" # e_bold "I am bold text" # e_note "I am a note" ################# Performing simple Yes/No confirmations ####################### # seek_confirmation "Do you want to print a success message?" # if is_confirmed; then # e_success "Here is a success message" # else # e_error "You did not ask for a success message" # fi ############ Testing if packages, apps, gems, etc. are installed ############### # if _omb_util_command_exists 'git'; then # e_success "Git good to go" # else # e_error "Git should be installed. It isn't. Aborting." # exit 1 # fi # if is_os "darwin"; then # e_success "You are on a mac" # else # e_error "You are not on a mac" # exit 1 # fi ##################### Sending notifications to Pushover ######################## # pushover "We just finished performing a lengthy task." ############################### Comparing A List ############################### # recipes=( # A-random-package # bash # Another-random-package # git # ) # list="$(to_install "${recipes[*]}" "$(brew list)")" # if [[ "$list" ]]; then # for item in ${list[@]} # do # echo "$item is not on the list" # done # else # e_arrow "Nothing to install. You've already got them all." # fi ################################################################################ function _omb_util_setexit { return "$1" } function _omb_util_defun_print { builtin eval -- "function $1 { local $3; $2 \"\$@\" && _omb_util_print \"\${$3}\"; }" } # # Test whether a command---either an alias, a keyword, a function, a builtin, # or a file---is defined. # # $1 = cmd to test # # Usage: # # if _omb_util_command_exists 'git'; then # some action # else # some other action # fi # if ((_omb_bash_version >= 40000)); then function _omb_util_command_exists { type -t -- "$@" &>/dev/null # bash-4.0 } function _omb_util_binary_exists { type -P -- "$@" &>/dev/null # bash-4.0 } else function _omb_util_command_exists { while (($#)); do type -t -- "$1" &>/dev/null || return 1 shift done } function _omb_util_binary_exists { while (($#)); do type -P -- "$1" &>/dev/null || return 1 shift done } fi function _omb_util_function_exists { declare -F "$@" &>/dev/null # bash-3.2 } # # Set Colors # # Use colors, but only if connected to a terminal, and that terminal # supports them. These colors are intended to be used with `echo` # function _omb_term_color_initialize { local name local -a normal_colors=(black brown green olive navy purple teal silver) local -a bright_colors=(gray red lime yellow blue magenta cyan white) if [[ ! -t 1 ]]; then _omb_term_colors= _omb_term_bold= _omb_term_underline= _omb_term_reset= _omb_term_normal= _omb_term_reset_color= for name in "${normal_colors[@]}" "${bright_colors[@]}" violet; do printf -v "_omb_term_$name" '' printf -v "_omb_term_background_$name" '' printf -v "_omb_term_bold_$name" '' printf -v "_omb_term_underline_$name" '' done return 0 fi if [[ ${BLE_VERSION-} ]]; then # Import terminfo cache of ble.sh (https://github.com/akinomyoga/ble.sh) _omb_term_colors=$_ble_term_colors _omb_term_bold=$_ble_term_bold _omb_term_underline=$_ble_term_smul _omb_term_reset=$_ble_term_sgr0 _omb_term_normal=$_ble_term_sgr0 _omb_term_reset_color=$'\e[39m' local index for ((index = 0; index < 8; index++)); do printf -v "_omb_term_${normal_colors[index]}" %s "${_ble_term_setaf[index]}" printf -v "_omb_term_background_${normal_colors[index]}" %s "${_ble_term_setab[index]}" printf -v "_omb_term_${bright_colors[index]}" %s "${_ble_term_setaf[index+8]}" printf -v "_omb_term_background_${bright_colors[index]}" %s "${_ble_term_setab[index+8]}" done else if [[ ${OMB_TERM_USE_TPUT-} != no ]] && _omb_util_binary_exists tput; then _omb_term_colors=$(tput colors 2>/dev/null || tput Co 2>/dev/null) _omb_term_bold=$(tput bold 2>/dev/null || tput md 2>/dev/null) _omb_term_underline=$(tput smul 2>/dev/null || tput ul 2>/dev/null) _omb_term_reset=$(tput sgr0 2>/dev/null || tput me 2>/dev/null) else _omb_term_colors= _omb_term_bold=$'\e[1m' _omb_term_underline=$'\e[4m' _omb_term_reset=$'\e[0m' fi _omb_term_normal=$'\e[0m' _omb_term_reset_color=$'\e[39m' # normal colors if ((_omb_term_colors >= 8)); then local index for ((index = 0; index < 8; index++)); do local fg=$(tput setaf "$index" 2>/dev/null || tput AF "$index" 2>/dev/null) [[ $fg ]] || fg=$'\e[3'$index'm' printf -v "_omb_term_${normal_colors[index]}" %s "$fg" printf -v "_omb_term_background_${normal_colors[index]}" '\e[4%sm' "$index" done else local index for ((index = 0; index < 8; index++)); do printf -v "_omb_term_${normal_colors[index]}" '\e[3%sm' "$index" printf -v "_omb_term_background_${normal_colors[index]}" '\e[4%sm' "$index" done fi # bright colors if ((_omb_term_colors >= 16)); then local index for ((index = 0; index < 8; index++)); do local fg=$(tput setaf $((index+8)) 2>/dev/null || tput AF $((index+8)) 2>/dev/null) [[ $fg ]] || fg=$'\e[9'$index'm' local refbg=_omb_term_background_${normal_colors[index]} local bg=${!refbg}$'\e[10'$index'm' printf -v "_omb_term_${bright_colors[index]}" %s "$fg" printf -v "_omb_term_background_${bright_colors[index]}" %s "$bg" done else # copy normal colors to bright colors (with bold) local index for ((index = 0; index < 8; index++)); do local reffg=_omb_term_${normal_colors[index]} local refbg=_omb_term_background_${normal_colors[index]} printf -v "_omb_term_${bright_colors[index]}" %s "$_omb_term_bold${!reffg}" printf -v "_omb_term_background_${bright_colors[index]}" %s "$_omb_term_bold${!refbg}" done fi fi # index colors if ((_omb_term_colors == 256)); then _omb_term_violet=$'\e[38;5;171m' _omb_term_background_violet=$'\e[48;5;171m' else _omb_term_violet=$_omb_term_purple _omb_term_background_violet=$_omb_term_background_purple fi # bold / underline versions for name in "${normal_colors[@]}" "${bright_colors[@]}" violet; do local ref=_omb_term_$name printf -v "_omb_term_bold_$name" %s "$_omb_term_bold${!ref}" printf -v "_omb_term_underline_$name" %s "$_omb_term_underline${!ref}" done } _omb_term_color_initialize # # Headers and Logging # function _omb_log_header { printf "\n${_omb_term_bold}${_omb_term_violet}========== %s ==========${_omb_term_reset}\n" "$@"; } function _omb_log_arrow { printf "➜ %s\n" "$@"; } function _omb_log_success { printf "${_omb_term_green}✔ %s${_omb_term_reset}\n" "$@"; } function _omb_log_error { printf "${_omb_term_brown}✖ %s${_omb_term_reset}\n" "$@"; } function _omb_log_warning { printf "${_omb_term_olive}➜ %s${_omb_term_reset}\n" "$@"; } function _omb_log_underline { printf "${_omb_term_underline}${_omb_term_bold}%s${_omb_term_reset}\n" "$@"; } function _omb_log_bold { printf "${_omb_term_bold}%s${_omb_term_reset}\n" "$@"; } function _omb_log_note { printf "${_omb_term_underline}${_omb_term_bold}${_omb_term_navy}Note:${_omb_term_reset} ${_omb_term_olive}%s${_omb_term_reset}\n" "$@"; } # # USAGE FOR SEEKING CONFIRMATION # seek_confirmation "Ask a question" # Credit: https://github.com/kevva/dotfiles # # if is_confirmed; then # some action # else # some other action # fi # function seek_confirmation { printf "\\n${_omb_term_bold}%s${_omb_term_reset}" "$@" read -rp " (y/n) " -n 1 printf "\\n" } # Test whether the result of an 'ask' is a confirmation function is_confirmed { [[ $REPLY =~ ^[Yy]$ ]] } # # Test which OS the user runs # $1 = OS to test # Usage: if is_os 'darwin'; then # function is_os { [[ $OSTYPE == $1* ]] } # # Pushover Notifications # Usage: pushover "Title Goes Here" "Message Goes Here" # Credit: http://ryonsherman.blogspot.com/2012/10/shell-script-to-send-pushover.html # function pushover { PUSHOVERURL="https://api.pushover.net/1/messages.json" API_KEY=$PUSHOVER_API_KEY USER_KEY=$PUSHOVER_USER_KEY DEVICE=$PUSHOVER_DEVICE TITLE="${1}" MESSAGE="${2}" curl \ -F "token=${API_KEY}" \ -F "user=${USER_KEY}" \ -F "device=${DEVICE}" \ -F "title=${TITLE}" \ -F "message=${MESSAGE}" \ "${PUSHOVERURL}" > /dev/null 2>&1 } ## @fn _omb_util_get_shopt optnames... ## @var[out] __shopt if ((_omb_bash_version >= 40100)); then function _omb_util_get_shopt() { if [[ $1 == -v ]]; then [[ $2 == __shopt ]] || local __shopt _omb_util_get_shopt "${@:3}" [[ $2 == __shopt ]] || printf -v "$2" '%s' "$__shopt" else __shopt=$BASHOPTS fi } else function _omb_util_get_shopt { if [[ $1 == -v ]]; then [[ $2 == __shopt ]] || local __shopt _omb_util_get_shopt "${@:3}" [[ $2 == __shopt ]] || printf -v "$2" '%s' "$__shopt" else __shopt= local opt for opt; do if shopt -q "$opt" &>/dev/null; then __shopt=${__shopt:+$__shopt:}$opt fi done fi } fi _omb_util_unload_hook=() function _omb_util_unload { local hook for hook in "${_omb_util_unload_hook[@]}"; do eval -- "$hook" done } _omb_util_original_PS1=$PS1 # shellcheck disable=SC2016 _omb_util_unload_hook+=('PS1=$_omb_util_original_PS1') _omb_util_prompt_command=() function _omb_util_prompt_command_hook { local status=$? lastarg=$_ hook for hook in "${_omb_util_prompt_command[@]}"; do _omb_util_setexit "$status" "$lastarg" eval -- "$hook" done _omb_util_setexit "$status" } _omb_util_unload_hook+=('_omb_util_prompt_command=()') : "${_omb_util_prompt_command_setup=}" function _omb_util_add_prompt_command { local other for other in "${_omb_util_prompt_command[@]}"; do [[ $1 == "$other" ]] && return 0 done _omb_util_prompt_command+=("$1") if [[ ! $_omb_util_prompt_command_setup ]]; then _omb_util_prompt_command_setup=1 local hook=_omb_util_prompt_command_hook # See if we need to use the overriden version if _omb_util_function_exists append_prompt_command_override; then append_prompt_command_override "$hook" return fi # Set OS dependent exact match regular expression local prompt_re if [[ $OSTYPE == darwin* ]]; then # macOS prompt_re='[[:<:]]'$hook'[[:>:]]' else # Linux, FreeBSD, etc. prompt_re='\<'$hook'\>' fi [[ $PROMPT_COMMAND =~ $prompt_re ]] && return 0 if ((_omb_bash_version >= 50100)); then local other for other in "${PROMPT_COMMAND[@]}"; do [[ $hook == "$other" ]] && return 0 done PROMPT_COMMAND+=("$hook") else PROMPT_COMMAND="$hook${PROMPT_COMMAND:+;$PROMPT_COMMAND}" fi fi } ## @fn _omb_util_split array str [sep] ## Split STR with SEP in a safe way and store the result in ARRAY. ## @param[out] array ## The name of an array variable to which the split result is stored. ## @param[in] str ## The string to split ## @param[in,opt] ## The set of separator characters. The default is ' '. function _omb_util_split { local __set=$- IFS=${3:-$' \t\n'} set -f eval -- "$1=(\$2)" [[ $__set == *f* ]] || set +f return 0 } ## @fn _omb_util_glob_expand array glob ## Perform the pathname expansion of a glob pattern GLOB in a safe way and ## store the filenames in ARRAY. ## @param[out] array ## The name of an array variable to which the filenames are stored. ## @param[in] glob ## The glob pattern that is attempted to match filenames function _omb_util_glob_expand { local __set=$- __shopt __gignore=$GLOBIGNORE _omb_util_get_shopt failglob nullglob extglob shopt -u failglob shopt -s nullglob shopt -s extglob set +f GLOBIGNORE= eval -- "$1=($2)" GLOBIGNORE=$__gignore # Note: dotglob is changed by GLOBIGNORE if [[ :$__shopt: == *:dotglob:* ]]; then shopt -s dotglob else shopt -u dotglob fi [[ $__set == *f* ]] && set -f [[ :$__shopt: != *:extglob:* ]] && shopt -u extglob [[ :$__shopt: != *:nullglob:* ]] && shopt -u nullglob [[ :$__shopt: == *:failglob:* ]] && shopt -s failglob return 0 } ## @fn _omb_util_split_lines array_name string function _omb_util_split_lines { local __set=$- IFS=$'\n' set -f eval "$1=(\$2)" [[ $__set == *f* ]] || set +f return 0 } ## @fn _omb_util_array_contains array_name value function _omb_util_array_contains { # When the array does not have any elements, we always fail. eval "((\${#$1[@]}))" || return 1 [[ $1 == ret ]] || eval "local -a ret=(\"\${$1[@]}\")" local value for value in "${ret[@]}"; do if [[ $value == "$2" ]]; then return 0 fi done return 1 } ## @fn _omb_util_array_remove array_name values... function _omb_util_array_remove { local __script=' local iA yA for iA in ${!A[@]}; do for yA in "${@:2}"; do if [[ ${A[iA]} == "$yA" ]]; then unset -v '\''A[iA]'\'' continue 2 fi done done A=("${A[@]}") # compaction '; eval -- "${__script//A/$1}" } function _omb_util_alias { case ${OMB_DEFAULT_ALIASES:-enable} in (disable) return 0 ;; (check) alias -- "${1%%=*}" &>/dev/null && return 0 ;; (enable) ;; (*) _omb_log_error "invalid value: OMB_DEFAULT_ALIASES='${OMB_DEFAULT_ALIASES-}' (expect: enable|disable|check)" >&2 return 2 esac alias -- "$1" } function _omb_util_alias_delayed__init { local _omb_name=$1 _omb_init=${FUNCNAME[1]} local _omb_command=$_omb_name "_omb_util_alias_select_$_omb_name" if [[ ! $_omb_command || $_omb_command == "$_omb_name" ]]; then unalias "$_omb_name" else alias "$_omb_name=$_omb_command" fi || return 1 eval -- "function $_omb_init { command ${_omb_command:-$_omb_name} \"\$@\"; }" && "$_omb_init" "${@:2}" } function _omb_util_alias_delayed { local name=$1 opts=${2-} local func=_omb_util_alias_init_$name eval -- "function $func { _omb_util_alias_delayed__init $name \"\$@\"; }" if [[ :$opts: == *:force:* ]]; then alias "$name=$func" else _omb_util_alias "$name=$func" fi } function _omb_util_mktemp { local template=tmp.oh-my-bash.XXXXXXXXXX if _omb_util_command_exists mktemp; then mktemp -t "$template" else m4 -D template="${TMPDIR:-/tmp}/$template" <<< 'mkstemp(template)' fi } ================================================ FILE: log/.gitkeep ================================================ ================================================ FILE: oh-my-bash.sh ================================================ #!/usr/bin/env bash # Bail out early if non-interactive # # Note: We cannot produce any error messages here because, in some systems, # /etc/gdm3/Xsession sources ~/.profile and checks stderr. If there is any # stderr ourputs, it refuses to start the session. case $- in *i*) ;; *) return;; esac if [ -z "${BASH_VERSION-}" ]; then printf '%s\n' 'oh-my-bash: This is not a Bash. Use OMB with Bash 3.2 or higher.' >&2 return 1 fi _omb_bash_version=$((BASH_VERSINFO[0] * 10000 + BASH_VERSINFO[1] * 100 + BASH_VERSINFO[2])) if ((_omb_bash_version < 30200)); then printf '%s\n' "oh-my-bash: OMB does not support this version of Bash ($BASH_VERSION)" >&2 printf '%s\n' "oh-my-bash: Use OMB with Bash 3.2 or higher" >&2 return 1 fi OMB_VERSINFO=(1 0 0 0 master noarch) OMB_VERSION="${OMB_VERSINFO[0]}.${OMB_VERSINFO[1]}.${OMB_VERSINFO[2]}(${OMB_VERSINFO[3]})-${OMB_VERSINFO[4]} (${OMB_VERSINFO[5]})" _omb_version=$((OMB_VERSINFO[0] * 10000 + OMB_VERSINFO[1] * 100 + OMB_VERSINFO[2])) # Check for updates on initial load... if [[ $DISABLE_AUTO_UPDATE != true ]]; then source "$OSH"/tools/check_for_upgrade.sh fi # Initializes Oh My Bash # Set OSH_CUSTOM to the path where your custom config files # and plugins exist, or else we will use the default custom/ if [[ ! ${OSH_CUSTOM-} ]]; then OSH_CUSTOM=$OSH/custom [[ -d $OSH_CUSTOM && -O $OSH_CUSTOM ]] || OSH_CUSTOM=${XDG_DATA_HOME:-$HOME/.local/share}/oh-my-bash/custom fi # Set OSH_CACHE_DIR to the path where cache files should be created # or else we will use the default cache/ if [[ ! ${OSH_CACHE_DIR-} ]]; then OSH_CACHE_DIR=$OSH/cache [[ -d $OSH_CACHE_DIR && -O $OSH_CACHE_DIR ]] || OSH_CACHE_DIR=${XDG_STATE_HOME:-$HOME/.local/state}/oh-my-bash/cache fi _omb_module_loaded= function _omb_module_require { local status=0 local -a files=() modules=() while (($#)); do local type=lib name=$1; shift [[ $name == *:* ]] && type=${name%%:*} name=${name#*:} name=${name%.bash} name=${name%.sh} local module=$type:$name [[ ' '$_omb_module_loaded' ' == *" $module "* ]] && continue local -a locations=() case $type in lib) locations=({"$OSH_CUSTOM","$OSH"}/lib/"$name".{bash,sh}) ;; plugin) locations=({"$OSH_CUSTOM","$OSH"}/plugins/"$name"/"$name".plugin.{bash,sh}) ;; alias) locations=({"$OSH_CUSTOM","$OSH"}/aliases/"$name".aliases.{bash,sh}) ;; completion) locations=({"$OSH_CUSTOM","$OSH"}/completions/"$name".completion.{bash,sh}) ;; theme) locations=({"$OSH_CUSTOM"{,/themes},"$OSH"/themes}/"$name"/"$name".theme.{bash,sh}) ;; *) printf '%s\n' "oh-my-bash (module_require): unknown module type '$type'." >&2 status=2 continue ;; esac local path for path in "${locations[@]}"; do if [[ -f $path ]]; then files+=("$path") modules+=("$module") continue 2 fi done printf '%s\n' "oh-my-bash (module_require): module '$type:$name' not found." >&2 status=127 done if ((status == 0)); then local i for i in "${!files[@]}"; do local path=${files[i]} module=${modules[i]} if [[ $module != theme:* ]]; then [[ ' '$_omb_module_loaded' ' == *" $module "* ]] && continue _omb_module_loaded="$_omb_module_loaded $module" fi source "$path" || status=$? done fi return "$status" } function _omb_module_require_lib { _omb_module_require "${@/#/lib:}"; } function _omb_module_require_plugin { _omb_module_require "${@/#/plugin:}"; } function _omb_module_require_alias { _omb_module_require "${@/#/alias:}"; } function _omb_module_require_completion { _omb_module_require "${@/#/completion:}"; } function _omb_module_require_theme { _omb_module_require "${@/#/theme:}"; } # Load all of the config files in ~/.oh-my-bash/lib that end in .sh # TIP: Add files you don't want in git to .gitignore _omb_module_require_lib omb-util _omb_module_require_lib utils _omb_util_glob_expand _omb_init_files '{"$OSH","$OSH_CUSTOM"}/lib/*.{bash,sh}' _omb_init_files=("${_omb_init_files[@]##*/}") _omb_init_files=("${_omb_init_files[@]%.bash}") _omb_init_files=("${_omb_init_files[@]%.sh}") _omb_module_require_lib "${_omb_init_files[@]}" unset -v _omb_init_files # Figure out the SHORT hostname if [[ $OSTYPE = darwin* ]]; then # macOS's $HOST changes with dhcp, etc. Use ComputerName if possible. SHORT_HOST=$(scutil --get ComputerName 2>/dev/null) || SHORT_HOST=${HOST/.*} else SHORT_HOST=${HOST/.*} fi # Load all of the plugins that were defined in ~/.bashrc _omb_module_require_plugin "${plugins[@]}" # Load all of the aliases that were defined in ~/.bashrc _omb_module_require_alias "${aliases[@]}" # Load all of the completions that were defined in ~/.bashrc _omb_module_require_completion "${completions[@]}" # Load all of your custom configurations from custom/ _omb_util_glob_expand _omb_init_files '"$OSH_CUSTOM"/*.{sh,bash}' for _omb_init_file in "${_omb_init_files[@]}"; do [[ -f $_omb_init_file ]] && source "$_omb_init_file" done unset -v _omb_init_files _omb_init_file # Load the theme if [[ $OSH_THEME ]]; then _omb_module_require_theme "$OSH_THEME" fi if [[ $PROMPT ]]; then export PS1='\['$PROMPT'\]' fi if ! _omb_util_command_exists '__git_ps1'; then source "$OSH/tools/git-prompt.sh" fi # Adding Support for other OSes if [[ -s /usr/bin/gloobus-preview ]]; then PREVIEW="gloobus-preview" elif [[ -s /Applications/Preview.app ]]; then PREVIEW="/Applications/Preview.app" else PREVIEW="less" fi ================================================ FILE: plugins/README.md ================================================ # Oh-My-Bash Plugins: Enhancing Your Development Experience "Oh My Bash won't make you a tenfold developer... but it might make you feel like one." _Embracing a suite of plugins can significantly boost your coding efficiency by automating repetitive tasks, thereby making them less monotonous and easier to execute._ **What is a Plugin?** A plugin is a type of software that augments the functionality of an existing program or system. These additions can range from simple to complex features and are intended to extend or customize the core functionality without modifying the codebase. **Plugin Enablement:** Once you identify the plugins you wish to utilize with Oh My Bash, you'll need to enable them in the `.bashrc` file located in your `$HOME` directory. Open this file with your preferred text editor and specify the plugins you want to load. For instance: ```bash plugins=(git bundler osx rake ruby) ``` **Conditional Enablement:** You may wish to control when or how plugins are activated. For instance, to ensure the `tmux-autoattach` plugin runs only in SSH sessions, you can employ a conditional statement checking for the `$SSH_TTY` variable. Make sure to remove the plugin from the main plugin list and use a conditional like this: ```bash [[ $SSH_TTY ]] && plugins+=(tmux-autoattach) ``` By leveraging these plugins, you can streamline your workflow and tackle coding challenges with greater efficiency. | Plugin | Description | |-------------------|-----------------------------------------------------------------------------------------------------------------------------| | ansible | Configuration management tool used to automate the provisioning, configuration, and management of computer systems. | | [asdf](asdf) | [asdf](https://asdf-vm.com) is a tool version manager to allow installing different versions of Node.js, Ruby, Golang, etc. | | aws | Tools for interacting with Amazon Web Services (AWS) | | bash-preexec | Tool allowing execution of commands before they are executed in Bash. | | bashmarks | Utility facilitating directory navigation via bookmarks in Bash. | | battery | Plugin related to monitoring and managing battery on computer systems. | | brew | Package manager for macOS and Linux facilitating software installation and management. | | bu | Insufficient information provided to give a precise description. | | cargo | Plugin to initialize CARGO_HOME and PATH for cargo | | colored-man-pages | Adds a few colors to `man` pages. | | chezmoi | Dotfile management tool enabling management of user environment configuration. | | dotnet | This plugin provides completion and useful aliases for .NET Core CLI. | | fasd | Utility easing filesystem navigation through shortcuts and abbreviated commands. | | fzf | A command-line fuzzy finder. | | gcloud | Command-line tools for interacting with Google Cloud Platform (GCP). | | git | Distributed version control system for managing the history of changes in software projects. | | goenv | Tool for managing Go versions within a development environment. | | golang | The Go programming language, along with its tools and standard libraries. | | jump | Jump helps you navigate faster by learning your habits. | | kubectl | Command-line tool for interacting with Kubernetes clusters. | | npm | Package manager for Node.js facilitating installation and management of project dependencies. | | nvm | Node.js version manager allowing easy switching between different Node.js versions. | | progress | Insufficient information provided to give a precise description. | | pyenv | Tool for managing multiple Python versions within a system. | | rbenv | Tool for managing your app's Ruby environment. | | sdkman | Version and package manager for development tools such as Java, Kotlin, and Gradle. | | sudo | Utility for executing commands with superuser privileges on Unix and Unix-like systems. | | tmux | Aliases for tmux, the terminal multiplexer. | | tmux-autoattach | Plugin related to session management in the tmux terminal multiplexer. | | vagrant | Tool for creating and managing virtual development environments. | | virtualenvwrapper | A set of extensions to the virtualenv tool. | | xterm | Terminal emulator for X Window systems providing a graphical user interface for accessing the command line. | | zellij-autoattach | Plugin related to session management in the zellij terminal multiplexer. | | zoxide | Utility for quickly navigating the filesystem based on visited directory history. | ================================================ FILE: plugins/ansible/README.md ================================================ # ansible plugin ## Introduction The `ansible plugin` adds several aliases for useful [ansible](https://docs.ansible.com/ansible/latest/index.html) commands and [aliases](#aliases). To use it, add `ansible` to the plugins array of your bashrc file: ``` plugins=(... ansible) ``` ## Aliases | Command | Description | |:-------------------------------------------|:--------------------------------------------------------------------| | `ansible-version` / `aver` | Show the version on ansible installed in this host | | `ansible-role-init ` / `arinit` | Creates the Ansible Role as per Ansible Galaxy standard | | `a` | command `ansible` | | `aconf` | command `ansible-config` | | `acon` | command `ansible-console` | | `ainv` | command `ansible-inventory` | | `aplaybook` | command `ansible-playbook` | | `adoc` | command `ansible-doc` | | `agal` | command `ansible-galaxy` | | `apull` | command `ansible-pull` | | `aval` | command `ansible-vault` | ================================================ FILE: plugins/ansible/ansible.plugin.sh ================================================ #! bash oh-my-bash.module # Functions function ansible-version(){ ansible --version } function ansible-role-init(){ if ! [ -z $1] ; then _omb_util_print "Ansible Role : $1 Creating...." ansible-galaxy init $1 tree $1 else _omb_util_print "Usage : ansible-role-init " _omb_util_print "Example : ansible-role-init role1" fi } # Aliases alias a='ansible ' alias aconf='ansible-config ' alias acon='ansible-console ' alias aver='ansible-version' alias arinit='ansible-role-init' alias aplaybook='ansible-playbook ' alias ainv='ansible-inventory ' alias adoc='ansible-doc ' alias agal='ansible-galaxy ' alias apull='ansible-pull ' alias aval='ansible-vault' ================================================ FILE: plugins/asdf/README.md ================================================ # asdf plugin Add [oh-my-bash](https://ohmybash.github.io) integration with [asdf](https://github.com/asdf-vm/asdf), the extendable version manager, with support for Ruby, Node.js, Elixir, Erlang and more. ## Installation 1. [Install asdf](https://github.com/asdf-vm/asdf#setup) by running the following: ``` bash git clone https://github.com/asdf-vm/asdf.git ~/.asdf ``` 2. Enable the plugin by adding it to your oh-my-bash `plugins` definition in `~/.bashrc`. ``` sh plugins=(asdf) ``` 2. Enable the completions by adding it to your oh-my-bash `completions` definition in `~/.bashrc`. ``` sh completions=(asdf) ``` ## Usage See the [asdf usage documentation](https://github.com/asdf-vm/asdf#usage) for information on how to use asdf: ``` bash asdf plugin add nodejs asdf install nodejs latest ``` ================================================ FILE: plugins/asdf/asdf.plugin.sh ================================================ #! bash oh-my-bash.module # asdf.plugin.sh: asdf plugin for oh-my-bash. # Author: @RobLoach (https://github.com/robloach) # Author: @prodrigues1912 (https://github.com/prodrigues1912) # Originally suggested in https://github.com/ohmybash/oh-my-bash/pull/310 # Fork of the oh-my-zsh asdf plugin # Custom ASDF_DIR location if [[ ${ASDF_DIR+set} ]]; then . "$ASDF_DIR/asdf.sh" # Home elif [[ -f "$HOME/.asdf/asdf.sh" ]]; then ASDF_DIR="$HOME/.asdf" . "${ASDF_DIR}/asdf.sh" # Config elif [[ -f "${XDG_CONFIG_HOME:-$HOME/.config}/asdf/asdf.sh" ]]; then ASDF_DIR="${XDG_CONFIG_HOME:-$HOME/.config}/asdf" . "${ASDF_DIR}/asdf.sh" # Arch Linux / AUR Package elif [[ -f "/opt/asdf-vm/asdf.sh" ]]; then ASDF_DIR="/opt/asdf-vm" . /opt/asdf-vm/asdf.sh # Homebrew elif _omb_util_command_exists brew; then _omb_plugin_asdf__prefix="$(brew --prefix asdf)" if [[ -f "$_omb_plugin_asdf__prefix/libexec/asdf.sh" ]]; then ASDF_DIR="$_omb_plugin_asdf__prefix/libexec" . "$ASDF_DIR/asdf.sh" fi unset -v _omb_plugin_asdf__prefix fi ================================================ FILE: plugins/aws/aws.plugin.sh ================================================ #! bash oh-my-bash.module # aws.plugin.sh # Author: Michael Anckaert # Based on oh-my-zsh AWS plugin # # command 'agp' returns the selected AWS profile (aws get profile) # command 'asp' sets the AWS profile to use (aws set profile) # export AWS_HOME=~/.aws function agp { _omb_util_print $AWS_DEFAULT_PROFILE } function asp { local rprompt=${RPROMPT//} export AWS_DEFAULT_PROFILE=$1 export AWS_PROFILE=$1 } ================================================ FILE: plugins/bash-preexec/README.md ================================================ # bash preexec This plugin loads `bash-preexec.sh` bundled with OMB if necessary. ================================================ FILE: plugins/bash-preexec/bash-preexec.plugin.sh ================================================ #! bash oh-my-bash.module if [[ ! ${bash_preexec_imported:-${__bp_imported:-}} ]]; then source "$OSH/tools/bash-preexec.sh" fi ================================================ FILE: plugins/bashmarks/README.md ================================================ # Bashmarks plugin The Bashmarks plugin allows you to create and use bookmarks for directories on your filesystems. This plugin is derived from the project https://github.com/huyng/bashmarks but contains improvements. This plugin is licensed under the 3-Clause BSD license. ## Quickstart Create a new bookmark using the *bm -a* command: ```bash $ bm -a mydir ``` The command above creates a bookmark for the current directory with the name *mydir*. You can navigate to the location of a bookmark using the *bm -g* command: ```bash $ bm -g mydir ``` You can also supply just any bookmark name and the *-g* option will be assumed: ```bash $ bm mydir ``` Tab completion is available when you need to enter a bookmark name in a command, such as when using *bm -g* Easily list all bookmarks you have set up using the *bm -l* command: ```bash $ bm -l ``` ## Configuration - **`BASHMARKS_SDIR`**: This variable contains the path to the file that stores the information of bookmarks of directory names. The default path is `~/.sdirs`. The old interface `SDIRS` is now deprecated. ## Commands - **`bm -h`**: Print short help text - **`bm -a bookmarkname`**: Save the current directory as bookmarkname - **`bm [-g] bookmarkname`**: Go to the specified bookmark - **`bm -p bookmarkname`**: Print the bookmark - **`bm -d bookmarkname`**: Delete a bookmark - **`bm -l`**: List all bookmarks ## Valid bookmark names A bookmark name can contain lower and upper case characters (A-Z), numbers and underscore characters. No periods, semicolons, spaces or other characters are allowed in a bookmark name. ================================================ FILE: plugins/bashmarks/bashmarks.plugin.sh ================================================ #! bash oh-my-bash.module # Copyright (c) 2010, Huy Nguyen, https://everyhue.me # Copyright (c) 2015, Toan Nguyen, https://nntoan.github.io # All rights reserved. # # This plugin is derived from the project https://github.com/huing/bashmarks. # This version is based on the following commit in the upstream project: # # https://github.com/huyng/bashmarks/commit/264952f2225691b5f99a498e4834e2c69bf4f5f5 # # This plugin is licensed under the BSD-3 License. #------------------------------------------------------------------------------ # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: # # * Redistributions of source code must retain the above copyright notice, # this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # * Neither the name of Huy Nguyen nor the names of contributors may be # used to endorse or promote products derived from this software without # specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # POSSIBILITY OF SUCH DAMAGE. #------------------------------------------------------------------------------ # USAGE: # bm -a bookmarkname - saves the curr dir as bookmarkname # bm -g bookmarkname - jumps to the that bookmark # bm -g b[TAB] - tab completion is available # bm -p bookmarkname - prints the bookmark # bm -p b[TAB] - tab completion is available # bm -d bookmarkname - deletes the bookmark # bm -d [TAB] - tab completion is available # bm -l - list all bookmarks # Default configurations if [[ ! ${BASHMARKS_SDIRS-} ]]; then BASHMARKS_SDIRS=${SDIRS:-$HOME/.sdirs} fi # Deprecated interfaces (2023-10-12) _omb_deprecate_declare 20000 SDIRS BASHMARKS_SDIRS sync _omb_deprecate_function 20000 _echo_usage _bashmarks_usage _omb_deprecate_function 20000 _save_bookmark _bashmarks_save _omb_deprecate_function 20000 _delete_bookmark _bashmarks_delete _omb_deprecate_function 20000 _goto_bookmark _bashmarks_goto _omb_deprecate_function 20000 _list_bookmark _bashmarks_list _omb_deprecate_function 20000 _print_bookmark _bashmarks_print _omb_deprecate_function 20000 _l _bashmarks_list_names _omb_deprecate_function 20000 _bookmark_name_valid _bashmarks_is_valid_bookmark_name _omb_deprecate_function 20000 _comp _bashmarks_comp_cmd_bm _omb_deprecate_function 20000 _compzsh _bashmarks_compzsh_cmd_bm _omb_deprecate_function 20000 _purge_line _bashmarks_purge_line # setup file to store bookmarks if [[ ! -e $BASHMARKS_SDIRS ]]; then touch "$BASHMARKS_SDIRS" fi # main function function bm { local option=$1 case $option in # save current directory to bookmarks [ bm -a BOOKMARK_NAME ] -a) _bashmarks_save "$2" ;; # delete bookmark [ bm -d BOOKMARK_NAME ] -d) _bashmarks_delete "$2" ;; # jump to bookmark [ bm -g BOOKMARK_NAME ] -g) _bashmarks_goto "$2" ;; # print bookmark [ bm -p BOOKMARK_NAME ] -p) _bashmarks_print "$2" ;; # show bookmark list [ bm -l ] -l) _bashmarks_list ;; # help [ bm -h ] -h) _bashmarks_usage ;; *) if [[ $1 == -* ]]; then # unrecognized option. echo error message and usage [ bm -X ] _omb_util_print "Unknown option '$1'" _bashmarks_usage kill -SIGINT $$ exit 1 elif [[ $1 == "" ]]; then # no args supplied - echo usage [ bm ] _bashmarks_usage else # non-option supplied as first arg. assume goto [ bm BOOKMARK_NAME ] _bashmarks_goto "$1" fi ;; esac } # print usage information function _bashmarks_usage { _omb_util_print 'USAGE:' _omb_util_print "bm -h - Prints this usage info" _omb_util_print 'bm -a - Saves the current directory as "bookmark_name"' _omb_util_print 'bm [-g] - Goes (cd) to the directory associated with "bookmark_name"' _omb_util_print 'bm -p - Prints the directory associated with "bookmark_name"' _omb_util_print 'bm -d - Deletes the bookmark' _omb_util_print 'bm -l - Lists all available bookmarks' } # save current directory to bookmarks function _bashmarks_save { if _bashmarks_is_valid_bookmark_name "$@"; then _bashmarks_purge_line "$BASHMARKS_SDIRS" "export DIR_$1=" CURDIR=$(sed "s#^$HOME#\$HOME#g" <<< "$PWD") _omb_util_print "export DIR_$1=\"$CURDIR\"" >> "$BASHMARKS_SDIRS" fi } # delete bookmark function _bashmarks_delete { if _bashmarks_is_valid_bookmark_name "$@"; then _bashmarks_purge_line "$BASHMARKS_SDIRS" "export DIR_$1=" unset "DIR_$1" fi } # jump to bookmark function _bashmarks_goto { source "$BASHMARKS_SDIRS" local target_varname=DIR_$1 local target=${!target_varname-} if [[ -d $target ]]; then cd "$target" elif [[ ! $target ]]; then _omb_util_print "${_omb_term_brown}WARNING: '${1}' bashmark does not exist${_omb_term_reset}" else _omb_util_print "${_omb_term_brown}WARNING: '${target}' does not exist${_omb_term_reset}" fi } # list bookmarks with dirname function _bashmarks_list { source "$BASHMARKS_SDIRS" # if color output is not working for you, comment out the line below '\033[1;32m' == "red" env | sort | awk '/^DIR_.+/{split(substr($0,5),parts,"="); printf("\033[0;33m%-20s\033[0m %s\n", parts[1], parts[2]);}' # uncomment this line if color output is not working with the line above # env | grep "^DIR_" | cut -c5- | sort |grep "^.*=" } # print bookmark function _bashmarks_print { source "$BASHMARKS_SDIRS" local var=DIR_$1 _omb_util_print "${!var}" } # list bookmarks without dirname function _bashmarks_list_names { source "$BASHMARKS_SDIRS" env | grep "^DIR_" | cut -c5- | sort | grep "^.*=" | cut -f1 -d "=" } # validate bookmark name # @var[out] exit_message function _bashmarks_is_valid_bookmark_name { local exit_message="" if [[ ! $1 ]]; then exit_message="bookmark name required" _omb_util_print "$exit_message" >&2 return 1 elif [[ $1 == *[!A-Za-z0-9_]* ]]; then exit_message="bookmark name is not valid" _omb_util_print "$exit_message" >&2 return 1 fi } # completion command function _bashmarks_comp_cmd_bm { COMPREPLY=() # bm, g, p, d, bm -[gpd] if ((COMP_CWORD == 1)) || { ((COMP_CWORD >= 2)) && [[ ${COMP_WORDS[1]} == -[gpd] ]]; }; then local cur=${COMP_WORDS[COMP_CWORD]} COMPREPLY=($(compgen -W '$(_bashmarks_list_names)' -- "$cur")) fi return 0 } # ZSH completion command function _bashmarks_compzsh_cmd_bm { reply=($(_bashmarks_list_names)) } # safe delete line from sdirs function _bashmarks_purge_line { if [[ -s $1 ]]; then # safely create a temp file. To atomically rewrite the target file with # "mv", we create the temporary file in the same directory as the target of # the symbolic link. local dest tmpdir t dest=$(_omb_util_readlink "$1" 2>/dev/null) tmpdir=$(dirname -- "$dest") t=$(mktemp "${tmpdir%/}/bashmarks.XXXXXX") || exit 1 trap "/bin/rm -f -- '$t'" EXIT # purge line sed "/$2/d" "$1" >| "$t" && /bin/mv -f -- "$t" "$dest" # cleanup temp file /bin/rm -f -- "$t" trap - EXIT fi } # bind completion command for g,p,d to _bashmarks_comp_cmd_bm if [[ ${ZSH_VERSION-} ]]; then compctl -K _bashmarks_compzsh_cmd_bm bm -g compctl -K _bashmarks_compzsh_cmd_bm bm -p compctl -K _bashmarks_compzsh_cmd_bm bm -d compctl -K _bashmarks_compzsh_cmd_bm g compctl -K _bashmarks_compzsh_cmd_bm p compctl -K _bashmarks_compzsh_cmd_bm d else shopt -s progcomp complete -F _bashmarks_comp_cmd_bm bm complete -F _bashmarks_comp_cmd_bm g complete -F _bashmarks_comp_cmd_bm p complete -F _bashmarks_comp_cmd_bm d fi alias s='bm -a' # Save a bookmark [bookmark_name] alias g='bm -g' # Go to bookmark [bookmark_name] alias p='bm -p' # Print bookmark of a path [path] alias d='bm -d' # Delete a bookmark [bookmark_name] ================================================ FILE: plugins/battery/README.md ================================================ # Battery Plugin for Oh My Bash ## Overview This custom plugin for Oh My Bash enhances your terminal experience by providing functions to monitor and display battery status and information. ## Functions ### 1. `ac_adapter_connected` - **Description:** Checks if the AC adapter is currently connected. - **Returns:** - `0` if the adapter is connected. - Non-zero exit status otherwise. ### 2. `ac_adapter_disconnected` - **Description:** Checks if the AC adapter is currently disconnected. - **Returns:** - `0` if the adapter is disconnected. - Non-zero exit status otherwise. ### 3. `battery_percentage` - **Description:** Retrieves and displays the current battery charge as a percentage of full (100%). - **Standard Output:** - Battery percentage as an integer. ### 4. `battery_charge` - **Description:** Presents a graphical representation of the battery charge using ASCII characters. - **Stanard Output:** - Graphical representation of the battery charge. ## Usage Add the plugin name `battery` in the `plugins` array in `~/.bashrc`. ```shell # bashrc plugins=(... battery) ``` You can use the functions from the interactive settings with Oh My Bash. _⚠️ if you want to add only the plugin and not Oh My Bash, you can copy the file `battery.plugin.sh` and `lib/utils.sh` to a place you like and source them in `~/.basrhc` (for interactive uses) or in a shell script (for a standalone shell program). You may instead copy and paste the functions directly into a script file, in which case the plugin will not receive updates and possible errors will have to be solved by you_ ## Dependencies This plugin relies on several utilities for retrieving battery information: - `upower`: Primary tool for battery information retrieval. - `acpi`, `pmset`, `ioreg`, `WMIC`: Fallback options for battery information retrieval. - `/sys/class/power_supply/`: Fallback option for battery information retrieval. This plugin file also depends on the following module in Oh My Bash: - `lib/utils.sh` ================================================ FILE: plugins/battery/battery.plugin.sh ================================================ #! bash oh-my-bash.module function _omb_plugin_battery__upower_print_info { upower -i "$(upower -e | sed -n '/BAT/{p;q;}')" } ## @fn ac_adapter_connected ## @exit 0 if the adapter is disconnected, or non-zero exit status ## otherwise. function ac_adapter_connected { if _omb_util_command_exists upower; then _omb_plugin_battery__upower_print_info | grep -qE 'state[:[:blank:]]*(charging|fully-charged)' elif _omb_util_command_exists acpi; then acpi -a | grep -q "on-line" elif _omb_util_command_exists pmset; then pmset -g batt | grep -q 'AC Power' elif _omb_util_command_exists ioreg; then ioreg -n AppleSmartBattery -r | grep -q '"ExternalConnected" = Yes' elif _omb_util_command_exists WMIC; then WMIC Path Win32_Battery Get BatteryStatus /Format:List | grep -q 'BatteryStatus=2' elif [[ -r /sys/class/power_supply/ADP0/online ]]; then [[ $(< /sys/class/power_supply/ADP0/online) == 1 ]] fi } ## @fn ac_adapter_disconnected ## @exit 0 if the adapter is disconnected, or non-zero exit status ## otherwise. function ac_adapter_disconnected { if _omb_util_command_exists upower; then _omb_plugin_battery__upower_print_info | grep -qE 'state[:[:blank:]]*discharging' elif _omb_util_command_exists acpi; then acpi -a | grep -q "off-line" elif _omb_util_command_exists pmset; then pmset -g batt | grep -q 'Battery Power' elif _omb_util_command_exists ioreg; then ioreg -n AppleSmartBattery -r | grep -q '"ExternalConnected" = No' elif _omb_util_command_exists WMIC; then WMIC Path Win32_Battery Get BatteryStatus /Format:List | grep -q 'BatteryStatus=1' elif [[ -r /sys/class/power_supply/ADP0/online ]]; then [[ $(< /sys/class/power_supply/ADP0/online) == 0 ]] fi } ## @fn battery_percentage ## @about 'displays battery charge as a percentage of full (100%)' ## @group 'battery' function battery_percentage { if _omb_util_command_exists upower; then local UPOWER_OUTPUT=$(_omb_plugin_battery__upower_print_info | sed -n 's/.*percentage[:[:blank:]]*\([0-9%]\{1,\}\)$/\1/p') [[ $UPOWER_OUTPUT ]] && _omb_util_print "${UPOWER_OUTPUT::-1}" elif _omb_util_command_exists acpi; then local ACPI_OUTPUT=$(acpi -b) case $ACPI_OUTPUT in *" Unknown"*) local PERC_OUTPUT=$(head -c 22 <<< "$ACPI_OUTPUT" | tail -c 2) case $PERC_OUTPUT in *%) head -c 2 <<< "0${PERC_OUTPUT}" ;; *) _omb_util_print ${PERC_OUTPUT} ;; esac ;; *" Charging"* | *" Discharging"*) local PERC_OUTPUT=$(awk -F, '/,/{gsub(/ /, "", $0); gsub(/%/,"", $0); print $2}' <<< "$ACPI_OUTPUT") _omb_util_print ${PERC_OUTPUT} ;; *" Full"*) _omb_util_print '100' ;; *) _omb_util_print '-1' ;; esac elif _omb_util_command_exists pmset; then local PMSET_OUTPUT=$(pmset -g ps | sed -n 's/.*[[:blank:]]+*\(.*%\).*/\1/p') case $PMSET_OUTPUT in 100*) _omb_util_print '100' ;; *) head -c 2 <<< "$PMSET_OUTPUT" ;; esac elif _omb_util_command_exists ioreg; then local IOREG_OUTPUT=$(ioreg -n AppleSmartBattery -r | awk '$1~/Capacity/{c[$1]=$3} END{OFMT="%05.2f%%"; max=c["\"MaxCapacity\""]; print (max>0? 100*c["\"CurrentCapacity\""]/max: "?")}') case $IOREG_OUTPUT in 100*) _omb_util_print '100' ;; *) head -c 2 <<< "$IOREG_OUTPUT" ;; esac elif _omb_util_command_exists WMIC; then local WINPC=$(grep -o '[0-9]*' <<< "porcent=$(WMIC PATH Win32_Battery Get EstimatedChargeRemaining /Format:List)") case $WINPC in 100*) _omb_util_print '100' ;; *) _omb_util_print $WINPC ;; esac elif [[ -r /sys/class/power_supply/BAT0/capacity ]]; then _omb_util_print "$(< /sys/class/power_supply/BAT0/capacity)" fi } ## @fn battery_charge ## @about 'graphical display of your battery charge' ## @group 'battery' function battery_charge { # Full char local F_C='▸' # Depleted char local D_C='▹' local DEPLETED_COLOR="${_omb_prompt_normal}" local FULL_COLOR="${_omb_prompt_green}" local HALF_COLOR="${_omb_prompt_olive}" local DANGER_COLOR="${_omb_prompt_brown}" local BATTERY_OUTPUT="${DEPLETED_COLOR}${D_C}${D_C}${D_C}${D_C}${D_C}" local BATTERY_PERC=$(battery_percentage) case $BATTERY_PERC in no) _omb_util_print "" ;; 9*) _omb_util_print "${FULL_COLOR}${F_C}${F_C}${F_C}${F_C}${F_C}${_omb_prompt_normal}" ;; 8*) _omb_util_print "${FULL_COLOR}${F_C}${F_C}${F_C}${F_C}${HALF_COLOR}${F_C}${_omb_prompt_normal}" ;; 7*) _omb_util_print "${FULL_COLOR}${F_C}${F_C}${F_C}${F_C}${DEPLETED_COLOR}${D_C}${_omb_prompt_normal}" ;; 6*) _omb_util_print "${FULL_COLOR}${F_C}${F_C}${F_C}${HALF_COLOR}${F_C}${DEPLETED_COLOR}${D_C}${_omb_prompt_normal}" ;; 5*) _omb_util_print "${FULL_COLOR}${F_C}${F_C}${F_C}${DEPLETED_COLOR}${D_C}${D_C}${_omb_prompt_normal}" ;; 4*) _omb_util_print "${FULL_COLOR}${F_C}${F_C}${HALF_COLOR}${F_C}${DEPLETED_COLOR}${D_C}${D_C}${_omb_prompt_normal}" ;; 3*) _omb_util_print "${FULL_COLOR}${F_C}${F_C}${DEPLETED_COLOR}${D_C}${D_C}${D_C}${_omb_prompt_normal}" ;; 2*) _omb_util_print "${FULL_COLOR}${F_C}${HALF_COLOR}${F_C}${DEPLETED_COLOR}${D_C}${D_C}${D_C}${_omb_prompt_normal}" ;; 1*) _omb_util_print "${FULL_COLOR}${F_C}${DEPLETED_COLOR}${D_C}${D_C}${D_C}${D_C}${_omb_prompt_normal}" ;; 05) _omb_util_print "${DANGER_COLOR}${F_C}${DEPLETED_COLOR}${D_C}${D_C}${D_C}${D_C}${_omb_prompt_normal}" ;; 04) _omb_util_print "${DANGER_COLOR}${F_C}${DEPLETED_COLOR}${D_C}${D_C}${D_C}${D_C}${_omb_prompt_normal}" ;; 03) _omb_util_print "${DANGER_COLOR}${F_C}${DEPLETED_COLOR}${D_C}${D_C}${D_C}${D_C}${_omb_prompt_normal}" ;; 02) _omb_util_print "${DANGER_COLOR}${F_C}${DEPLETED_COLOR}${D_C}${D_C}${D_C}${D_C}${_omb_prompt_normal}" ;; 0*) _omb_util_print "${HALF_COLOR}${F_C}${DEPLETED_COLOR}${D_C}${D_C}${D_C}${D_C}${_omb_prompt_normal}" ;; *) _omb_util_print "${DANGER_COLOR}UNPLG${_omb_prompt_normal}" ;; esac } ================================================ FILE: plugins/brew/README.md ================================================ # brew plugin The plugin adds several aliases for common [brew](https://brew.sh) commands. To use it, add `brew` to the plugins array of your bashrc file: ```bash plugins=(... brew) ``` ## Aliases | Alias | Command | Description | |--------|----------------------|---------------| | brewp | `brew pin` | Pin a specified formulae, preventing them from being upgraded when issuing the brew upgrade command. | | brews | `brew list -1` | List installed formulae, one entry per line, or the installed files for a given formulae. | | brewsp | `brew list --pinned` | Show the versions of pinned formulae, or only the specified (pinned) formulae if formulae are given. | | bubo | `brew update && brew outdated` | Fetch the newest version of Homebrew and all formulae, then list outdated formulae. | | bubc | `brew upgrade && brew cleanup` | Upgrade outdated, unpinned brews (with existing install options), then removes stale lock files and outdated downloads for formulae and casks, and removes old versions of installed formulae. | | bubu | `bubo && bubc` | Updates Homebrew, lists outdated formulae, upgrades oudated and unpinned formulae, and removes stale and outdated downloads and versions. | | bcubo | `brew update && brew cask outdated` | Fetch the newest version of Homebrew and all formulae, then list outdated casks. | | bcubc | `brew cask reinstall $(brew cask outdated) && brew cleanup` | Updates outdated casks, then runs cleanup. | ================================================ FILE: plugins/brew/brew.plugin.sh ================================================ #! bash oh-my-bash.module alias brewp='brew pin' alias brews='brew list -1' alias brewsp='brew list --pinned' alias bubo='brew update && brew outdated' alias bubc='brew upgrade && brew cleanup' alias bubu='bubo && bubc' alias bcubo='brew update && brew cask outdated' alias bcubc='brew cask reinstall $(brew cask outdated) && brew cleanup' ================================================ FILE: plugins/bu/bu.plugin.sh ================================================ #! bash oh-my-bash.module # bu.plugin.sh # Author: Taleeb Midi # Based on oh-my-zsh AWS plugin # # command 'bu [N]' Change directory up N times # function _omb_plugin_bu_usage { cat </dev/null)" if [ $? -ne 0 ]; then completions="" fi COMPREPLY=( $(compgen -W "$completions" -- "$word") ) } complete -f -F _dotnet_bash_complete dotnet # Aliases bellow are here for backwards compatibility # added by Shaun Tabone (https://github.com/xontab) #Create a new .NET project or file. alias dn='dotnet new' #Build and run a .NET project output. alias dr='dotnet run' #Run unit tests using the test runner specified in a .NET project. alias dt='dotnet test' #Watch for source file changes and restart the dotnet command. alias dw='dotnet watch' #Watch for source file changes and restart the `run` command. alias dwr='dotnet watch run' #Watch for source file changes and restart the `test` command. alias dwt='dotnet watch test' #Modify Visual Studio solution files. alias ds='dotnet sln' #Add a package or reference to a .NET project. alias da='dotnet add' #Create a NuGet package. alias dp='dotnet pack' #Provides additional NuGet commands. alias dng='dotnet nuget' #Build a .NET project alias db='dotnet build' # Aliases added by Chris Lebron (https://github.com/clebron949) #List dotnet sdk versions installed alias dls='dotnet --list-sdks' #List dotnet runtimes installed alias dlr='dotnet --list-runtimes' ================================================ FILE: plugins/fasd/fasd.plugin.sh ================================================ #! bash oh-my-bash.module # Initialize fasd, without setting up the prompt hook, which # we want to be handled by oh-my-bash. function _omb_plugin_fasd_prompt_func { local sink=${OMB_PLUGIN_FASD_SINK:-/dev/null} [[ $sink == /dev/null ]] && return 0 fasd --proc "$(fasd --sanitize "$(history 1 | command sed 's/^[ ]*[0-9]*[ ]*//')")" >> "$sink" 2>&1 } function _omb_plugin_fasd_initialize { if _omb_util_command_exists fasd; then eval -- "$(fasd --init posix-alias bash-ccomp bash-ccomp-install)" _omb_util_add_prompt_command _omb_plugin_fasd_prompt_func else _omb_util_print 'fasd not found, plugin not activated.' >&2 fi } _omb_plugin_fasd_initialize ================================================ FILE: plugins/fzf/README.md ================================================ # fzf plugin The fzf plugin enables fzf keybindings and completions on bash. To use it, install [fzf](https://github.com/junegunn/fzf?tab=readme-ov-file#installation) and add fzf to the plugins array of your bashrc file: ```bash plugins=(... fzf) ``` ================================================ FILE: plugins/fzf/fzf.plugin.sh ================================================ #! bash oh-my-bash.module # Check if fzf is installed if _omb_util_command_exists fzf; then # Set up fzf key bindings and fuzzy completion eval -- "$(fzf --bash)" else _omb_util_print '[oh-my-bash] fzf not found, please install it from https://github.com/junegunn/fzf' >&2 fi ================================================ FILE: plugins/gcloud/README.md ================================================ # gcloud This plugin provides completion support for the [Google Cloud SDK CLI](https://cloud.google.com/sdk/gcloud/). Based on [gcloud plugin for oh-my-zsh](https://github.com/ohmyzsh/ohmyzsh/tree/master/plugins/gcloud). To use it, add `gcloud` to the plugins array in your bashrc file. ```bash plugins=(... gcloud) ``` It relies on you having installed the SDK using one of the supported options listed [here](https://cloud.google.com/sdk/install). ## Plugin Options * Set `OMB_PLUGIN_GCLOUD_HOME` in your `bashrc` file before you load oh-my-bash if you have your GCloud SDK installed in a non-standard location. The plugin will use this as the base for your SDK if it finds it set already. * If you do not have a `python2` in your `PATH` you'll also need to set the `CLOUDSDK_PYTHON` environment variable at the end of your `.bashrc`. This is used by the SDK to call a compatible interpreter when you run one of the SDK commands. ================================================ FILE: plugins/gcloud/gcloud.plugin.sh ================================================ #!/bin/bash oh-my-bash.module # gcloud.plugin.sh # Author: Ian Chesal (github.com/ianchesal) -- ohmyzsh/gloud.plugin.zsh # Author: Antonino Cangialosi (github.com/ninoCan) # Fork of oh-my-zsh gcloud plugin function _omb_plugin_gcloud_set_home_var() { if [[ ! ${OMB_PLUGIN_GCLOUD_HOME-} ]]; then local -a search_locations=( "$HOME/google-cloud-sdk" "/usr/local/Caskroom/google-cloud-sdk/latest/google-cloud-sdk" "/opt/homebrew/Caskroom/google-cloud-sdk/latest/google-cloud-sdk" "/usr/share/google-cloud-sdk" "/snap/google-cloud-sdk/current" "/usr/lib/google-cloud-sdk" "/usr/lib64/google-cloud-sdk" "/opt/google-cloud-sdk" "/opt/local/libexec/google-cloud-sdk" ) local gcloud_sdk_location for gcloud_sdk_location in "${search_locations[@]}"; do if [[ -d $gcloud_sdk_location ]]; then OMB_PLUGIN_GCLOUD_HOME=$gcloud_sdk_location break fi done fi } function _omb_plugin_gcloud_set_completions() { if [[ ${OMB_PLUGIN_GCLOUD_HOME-} ]]; then # Only source this if gcloud isn't already on the path if _omb_util_binary_exists gcloud; then if [[ -f $OMB_PLUGIN_GCLOUD_HOME/path.bash.inc ]]; then source "$OMB_PLUGIN_GCLOUD_HOME/path.bash.inc" fi # Look for completion file in different paths local -a completion_filepath_candidates=( "${OMB_PLUGIN_GCLOUD_HOME}/completion.bash.inc" # default location "/usr/share/google-cloud-sdk/completion.bash.inc" # apt-based location ) local comp_file for comp_file in "${completion_filepath_candidates[@]}"; do if [[ -f $comp_file ]]; then source "$comp_file" break fi done fi fi } _omb_plugin_gcloud_set_home_var _omb_plugin_gcloud_set_completions ================================================ FILE: plugins/git/README.md ================================================ # Git Plugin The git plugin defines a number of useful aliases for you. [Consult the complete list](git.plugin.sh#L34) # How to Use Aliases and Shell Functions for Git with Oh My Bash This README provides instructions on how to use the provided aliases and shell functions for Git with Oh My Bash. These aliases and functions can significantly improve your Git workflow by simplifying common Git commands and providing useful shortcuts. ## Aliases ### General Git Commands - `g`: Shortcut for `git`. - `ga`: Shortcut for `git add`. Adds specified files to the staging area. - `gaa`: Shortcut for `git add --all`. Adds all changes, including untracked files, to the staging area. - `gc`: Shortcut for `git commit`. Commits changes to the repository. - `gca`: Shortcut for `git commit --all`. Commits all changes to the repository. - `gcmsg`: Shortcut for `git commit --message`. Commits changes with a specified message. - `gd`: Shortcut for `git diff`. Shows changes between commits, commit and working tree, etc. - `gdca`: Shortcut for `git diff --cached`. Shows changes between staged and last commit. - `gf`: Shortcut for `git fetch`. Downloads objects and refs from another repository. - `gg`: Shortcut for `git gui citool`. Launches Git GUI. - `gl`: Shortcut for `git pull`. Fetches from and integrates with another repository or a local branch. - `gpr`: Shortcut for `git pull --rebase`. Fetches and rebases changes from another repository. - `gp`: Shortcut for `git push`. Pushes changes to a remote repository. - `gs`: Shortcut for `git status`. Shows the working tree status. ### Branching and Merging - `gcb`: Shortcut for `git checkout -b`. Creates a new branch and switches to it. - `gco`: Shortcut for `git checkout`. Switches branches or restores working tree files. - `gm`: Shortcut for `git merge`. Joins two or more development histories together. - `grb`: Shortcut for `git rebase`. Reapplies commits on top of another base tip. - `grbi`: Shortcut for `git rebase --interactive`. Reapplies commits interactively. - `grbd`: Shortcut for `git rebase develop`. Reapplies commits onto the develop branch. - `gsw`: Shortcut for `git switch`. Switches branches. ### Tagging - `gta`: Shortcut for `git tag --annotate`. Creates an annotated tag. - `gts`: Shortcut for `git tag --sign`. Creates a signed tag. - `gtv`: Shortcut for `git tag`. Lists tags. ### Miscellaneous - `gclean`: Shortcut for `git clean`. Removes untracked files from the working tree. - `gunwip`: Undo last commit if marked as work in progress. - `gignore`: Ignores changes to tracked files. - `gunignore`: Stops ignoring changes to tracked files. - `gcount`: Shows commit count by author. - `gk`: Opens Git GUI. - `gke`: Opens extended Git GUI. ## Shell Functions - `current_branch`: Get the name of the current branch. - `current_repository`: Get the list of remotes for the current repository. - `work_in_progress`: Warn if the current branch is a work in progress. - `git_develop_branch`: Check for develop and similarly named branches. - `git_main_branch`: Check if main exists and use instead of master. ## Usage Example To add all changes and commit with a message, you can use: ```bash gaa && gcmsg "Your commit message" ``` ================================================ FILE: plugins/git/git.plugin.sh ================================================ #! bash oh-my-bash.module _omb_module_require completion:git # # Functions # # The name of the current branch # Back-compatibility wrapper for when this function was defined here in # the plugin, before being pulled in to core lib/git.zsh as git_current_branch() # to fix the core -> git plugin dependency. function current_branch() { git_current_branch } # The list of remotes function current_repository() { if ! $_omb_git_git_cmd rev-parse --is-inside-work-tree &> /dev/null; then return fi _omb_util_print $($_omb_git_git_cmd remote -v | cut -d':' -f 2) } # Warn if the current branch is a WIP function work_in_progress() { if $(git log -n 1 2>/dev/null | grep -q -c "\-\-wip\-\-"); then _omb_util_print "WIP!!" fi } # Check for develop and similarly named branches function git_develop_branch() { command git rev-parse --git-dir &>/dev/null || return local branch for branch in dev devel development; do if command git show-ref -q --verify refs/heads/"$branch"; then _omb_util_print "$branch" return fi done _omb_util_print develop } # Check if main exists and use instead of master function git_main_branch() { command git rev-parse --git-dir &>/dev/null || return local ref for ref in refs/{heads,remotes/{origin,upstream}}/{main,trunk,mainline,default}; do if command git show-ref -q --verify "$ref"; then _omb_util_print "${ref##*/}" return fi done _omb_util_print master } # # Aliases # # From Oh-My-Zsh: # https://github.com/ohmyzsh/ohmyzsh/blob/f36c6db0eac17b022eee87411e6996a5f5fc8457/plugins/git/git.plugin.zsh # alias g='command git' __git_complete g _git alias ga='command git add' __git_complete ga _git_add alias gaa='command git add --all' __git_complete gaa _git_add alias gapa='command git add --patch' __git_complete gapa _git_add alias gau='command git add --update' __git_complete gau _git_add alias gav='command git add --verbose' __git_complete gav _git_add alias gwip='command git add -A; command git rm $(git ls-files --deleted) 2> /dev/null; command git commit --no-verify --no-gpg-sign --message "--wip-- [skip ci]"' alias gam='command git am' __git_complete gam _git_am alias gama='command git am --abort' __git_complete gama _git_am alias gamc='command git am --continue' __git_complete gamc _git_am alias gamscp='command git am --show-current-patch' __git_complete gamscp _git_am alias gams='command git am --skip' __git_complete gams _git_am alias gap='command git apply' __git_complete gap _git_apply alias gapt='command git apply --3way' __git_complete gapt _git_apply alias gbl='command git blame -b -w' alias gb='command git branch' __git_complete gb _git_branch alias gbD='command git branch --delete --force' __git_complete gbD _git_branch alias gba='command git branch -a' __git_complete gba _git_branch alias gbd='command git branch -d' __git_complete gbd _git_branch alias gbda='command git branch --no-color --merged | command grep -vE "^([+*]|\s*($(git_main_branch)|$(git_develop_branch))\s*$)" | command xargs git branch --delete 2>/dev/null' alias gbg='LANG=C command git branch -vv | grep ": gone\]"' alias gbgD='LANG=C command git branch --no-color -vv | grep ": gone\]" | awk '"'"'{print $1}'"'"' | command xargs git branch -D' alias gbgd='LANG=C command git branch --no-color -vv | grep ": gone\]" | awk '"'"'{print $1}'"'"' | command xargs git branch -d' alias gbm='command git branch --move' __git_complete gbm _git_branch alias gbnm='command git branch --no-merged' __git_complete gbnm _git_branch alias gbr='command git branch --remote' __git_complete gbr _git_branch alias gbsc='command git branch --show-current' __git_complete gbsc _git_branch alias ggsup='command git branch --set-upstream-to="origin/$(git_current_branch)"' __git_complete ggsup _git_branch alias gbs='command git bisect' __git_complete gbs _git_bisect alias gbsb='command git bisect bad' __git_complete gbsb _git_bisect alias gbsg='command git bisect good' __git_complete gbsg _git_bisect alias gbsn='command git bisect new' __git_complete gbsn _git_bisect alias gbso='command git bisect old' __git_complete gbso _git_bisect alias gbsr='command git bisect reset' __git_complete gbsr _git_bisect alias gbss='command git bisect start' __git_complete gbss _git_bisect alias gcb='command git checkout -b' __git_complete gcb _git_checkout alias gcd='command git checkout "$(git_develop_branch)"' __git_complete gcd _git_checkout alias gcm='command git checkout "$(git_main_branch)"' __git_complete gcm _git_checkout alias gco='command git checkout' __git_complete gco _git_checkout alias gcor='command git checkout --recurse-submodules' __git_complete gcor _git_checkout alias gcp='command git cherry-pick' __git_complete gcp _git_cherry_pick alias gcpa='command git cherry-pick --abort' __git_complete gcpa _git_cherry_pick alias gcpc='command git cherry-pick --continue' __git_complete gcpc _git_cherry_pick alias gcps='command git cherry-pick -s' __git_complete gcps _git_cherry_pick alias gcl='command git clone --recursive' __git_complete gcl _git_clone function gccd() { command git clone --recurse-submodules "$@" local lastarg=$_ [[ -d $lastarg ]] && cd "$lastarg" && return lastarg=${lastarg##*/} cd "${lastarg%.git}" } #compdef _git gccd=git-clone __git_complete gccd _git_clone alias gclean='command git clean -fd' __git_complete gclean _git_clean alias gc!='command git commit --verbose --amend' __git_complete gc! _git_commit alias gc='command git commit --verbose' __git_complete gc _git_commit alias gca!='command git commit --verbose --all --amend' __git_complete gca! _git_commit alias gca='command git commit --verbose --all' __git_complete gca _git_commit alias gcam='command git commit --all --message' __git_complete gcam _git_commit alias gcan!='command git commit --verbose --all --no-edit --amend' __git_complete gcan! _git_commit alias gcans!='command git commit --verbose --all --signoff --no-edit --amend' __git_complete gcans! _git_commit alias gcas='command git commit --all --signoff' __git_complete gcas _git_commit alias gcasm='command git commit --all --signoff --message' __git_complete gcasm _git_commit alias gcmsg='command git commit --message' __git_complete gcmsg _git_commit alias gcn!='command git commit --verbose --no-edit --amend' __git_complete gcn! _git_commit alias gcs='command git commit --gpg-sign' __git_complete gcs _git_commit alias gcsm='command git commit --signoff --message' __git_complete gcsm _git_commit alias gcss='command git commit --gpg-sign --signoff' __git_complete gcss _git_commit alias gcssm='command git commit --gpg-sign --signoff --message' __git_complete gcssm _git_commit alias gcf='command git config --list' __git_complete gcf _git_config alias gdct='command git describe --tags `git rev-list --tags --max-count=1`' alias gd='command git diff' __git_complete gd _git_diff alias gdca='command git diff --cached' __git_complete gdca _git_diff alias gdcw='command git diff --cached --word-diff' __git_complete gdcw _git_diff alias gds='command git diff --staged' __git_complete gds _git_diff alias gdw='command git diff --word-diff' __git_complete gdw _git_diff alias gdup='command git diff @{upstream}' __git_complete gdup _git_diff function gdnolock() { command git diff "$@" ":(exclude)package-lock.json" ":(exclude)*.lock" } #compdef _git gdnolock=git-diff __git_complete gdnolock _git_diff function gdv { command git diff -w "$@" | view - } #compdef _git gdv=git-diff __git_complete gdv _git_diff alias gdt='command git diff-tree --no-commit-id --name-only -r' __git_complete gdt _git_diff alias gdtool='command git difftool -d' __git_complete gdtool _git_difftool alias gf='command git fetch' __git_complete gf _git_fetch alias gfa='command git fetch --all --prune' __git_complete gfa _git_fetch alias gfo='command git fetch origin' # jobs= was added in git 2.8 # alias gfa='git fetch --all --prune --jobs=10' \ __git_complete gfo _git_fetch alias gg='command git gui citool' alias gga='command git gui citool --amend' alias ghh='command git help' __git_complete ghh _git_help alias glg='command git log --stat' __git_complete glg _git_log alias glgg='command git log --graph' __git_complete glgg _git_log alias glgga='command git log --graph --decorate --all' __git_complete glgga _git_log alias glgm='command git log --graph --max-count=10' __git_complete glgm _git_log alias glgp='command git log --stat -p' __git_complete glgp _git_log alias glo='command git log --oneline --decorate' __git_complete glo _git_log alias glod='command git log --graph --pretty="%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ad) %C(bold blue)<%an>%Creset"' __git_complete glod _git_log alias glods='command git log --graph --pretty="%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ad) %C(bold blue)<%an>%Creset" --date=short' __git_complete glods _git_log alias glog='command git log --oneline --decorate --graph' __git_complete glog _git_log alias gloga='command git log --oneline --decorate --graph --all' __git_complete gloga _git_log alias glol='command git log --graph --pretty="%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ar) %C(bold blue)<%an>%Creset"' __git_complete glol _git_log alias glola='command git log --graph --pretty="%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ar) %C(bold blue)<%an>%Creset" --all' __git_complete glola _git_log alias glols='command git log --graph --pretty="%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ar) %C(bold blue)<%an>%Creset" --stat' __git_complete glols _git_log # Pretty log messages function _git_log_prettily(){ if [[ $1 ]]; then command git log --pretty="$1" fi } alias glp='_git_log_prettily' #compdef _git glp=git-log __git_complete glp _git_log alias gignored='command git ls-files -v | grep "^[[:lower:]]"' alias gfg='command git ls-files | grep' alias gm='command git merge' __git_complete gm _git_merge alias gma='command git merge --abort' __git_complete gma _git_merge alias gmom='command git merge "origin/$(git_main_branch)"' __git_complete gmom _git_merge alias gms='command git merge --squash' __git_complete gms _git_merge alias gmum='command git merge "upstream/$(git_main_branch)"' __git_complete gmum _git_merge alias gmt='command git mergetool --no-prompt' # deprecate? __git_complete gmt _git_mergetool alias gmtvim='command git mergetool --no-prompt --tool=vimdiff' # deprecate? __git_complete gmtvim _git_mergetool alias gmtl='command git mergetool --no-prompt' __git_complete gmtl _git_mergetool alias gmtlvim='command git mergetool --no-prompt --tool=vimdiff' __git_complete gmtlvim _git_mergetool alias ggpull='command git pull origin "$(git_current_branch)"' __git_complete ggpull _git_pull alias ggpur='ggu' alias gl='command git pull' __git_complete gl _git_pull alias gluc='command git pull upstream "$(git_current_branch)"' __git_complete gluc _git_pull alias glum='command git pull upstream "$(git_main_branch)"' __git_complete glum _git_pull alias gpr='command git pull --rebase' __git_complete gpr _git_pull alias gup='command git pull --rebase' __git_complete gup _git_pull alias gupa='command git pull --rebase --autostash' __git_complete gupa _git_pull alias gupav='command git pull --rebase --autostash --verbose' __git_complete gupav _git_pull alias gupom='command git pull --rebase origin "$(git_main_branch)"' __git_complete gupom _git_pull alias gupomi='command git pull --rebase=interactive origin "$(git_main_branch)"' __git_complete gupomi _git_pull alias gupv='command git pull --rebase --verbose' __git_complete gupv _git_pull function ggl { if (($# != 0 && $# != 1)); then command git pull origin "$*" else local b= (($# == 0)) && b=$(git_current_branch) command git pull origin "${b:-$1}" fi } __git_complete ggl _git_pull function ggu { local b= (($# != 1)) && b=$(git_current_branch) command git pull --rebase origin "${b:-$1}" } #compdef _git ggl=git-checkout #compdef _git ggpull=git-checkout #compdef _git ggpur=git-checkout #compdef _git ggu=git-checkout __git_complete ggu _git_pull alias ggpush='command git push origin "$(git_current_branch)"' __git_complete ggpush _git_push alias gp='command git push' __git_complete gp _git_push alias gpd='command git push --dry-run' __git_complete gpd _git_push alias gpf!='command git push --force' __git_complete gpf! _git_push alias gpf='command git push --force-with-lease' __git_complete gpf _git_push alias gpoat='command git push origin --all && command git push origin --tags' __git_complete gpoat _git_push alias gpod='command git push origin --delete' __git_complete gpod _git_push alias gpsup='command git push --set-upstream origin "$(git_current_branch)"' __git_complete gpsup _git_push alias gpsupf='command git push --set-upstream origin "$(git_current_branch)" --force-with-lease' __git_complete gpsupf _git_push alias gpu='command git push upstream' __git_complete gpu _git_push alias gpv='command git push --verbose' __git_complete gpv _git_push #is-at-least 2.30 "$git_version" && alias gpf='git push --force-with-lease --force-if-includes' #is-at-least 2.30 "$git_version" && alias gpsupf='git push --set-upstream origin "$(git_current_branch)" --force-with-lease --force-if-includes' function ggf { (($# != 1)) && local b=$(git_current_branch) command git push --force origin "${b:=$1}" } __git_complete ggf _git_push function ggfl { (($# != 1)) && local b=$(git_current_branch) command git push --force-with-lease origin "${b:=$1}" } __git_complete ggfl _git_push function ggp { if (($# != 0 && $# != 1)); then command git push origin "$*" else (($# == 0)) && local b=$(git_current_branch) command git push origin "${b:=$1}" fi } __git_complete ggp _git_push function ggpnp { if (($# == 0)); then ggl && ggp else ggl "$*" && ggp "$*" fi } __git_complete ggpnp _git_push #compdef _git ggf=git-checkout #compdef _git ggfl=git-checkout #compdef _git ggp=git-checkout #compdef _git ggpnp=git-checkout #compdef _git ggpush=git-checkout #compdef _git gpoat=git-push alias grb='command git rebase' __git_complete grb _git_rebase alias grba='command git rebase --abort' __git_complete grba _git_rebase alias grbc='command git rebase --continue' __git_complete grbc _git_rebase alias grbi='command git rebase --interactive' __git_complete grbi _git_rebase alias grbo='command git rebase --onto' __git_complete grbo _git_rebase alias grbs='command git rebase --skip' __git_complete grbs _git_rebase alias grbd='command git rebase "$(git_develop_branch)"' __git_complete grbd _git_rebase alias grbm='command git rebase "$(git_main_branch)"' __git_complete grbm _git_rebase alias grbom='command git rebase "origin/$(git_main_branch)"' __git_complete grbom _git_rebase alias gr='command git remote' __git_complete gr _git_remote alias gra='command git remote add' __git_complete gra _git_remote alias grmv='command git remote rename' __git_complete grmv _git_remote alias grrm='command git remote remove' __git_complete grrm _git_remote alias grset='command git remote set-url' __git_complete grset _git_remote alias grup='command git remote update' __git_complete grup _git_remote alias grv='command git remote --verbose' __git_complete grv _git_remote alias gpristine='command git reset --hard && command git clean --force -dfx' alias grh='command git reset' __git_complete grh _git_reset alias grhh='command git reset --hard' __git_complete grhh _git_reset alias grhk='command git reset --keep' __git_complete grhk _git_reset alias grhs='command git reset --soft' __git_complete grhs _git_reset alias groh='command git reset "origin/$(git_current_branch)" --hard' __git_complete groh _git_reset alias grt='cd $(command git rev-parse --show-toplevel || _omb_util_print ".")' alias gru='command git reset --' __git_complete gru _git_reset alias grs='command git restore' __git_complete grs _git_restore alias grss='command git restore --source' __git_complete grss _git_restore alias grst='command git restore --staged' __git_complete grst _git_restore alias gunwip='command git rev-list --max-count=1 --format="%s" HEAD | grep -q "\--wip--" && command git reset HEAD~1' alias grev='command git revert' __git_complete grev _git_revert alias grm='command git rm' __git_complete grm _git_rm alias grmc='command git rm --cached' __git_complete grmc _git_rm alias gcount='command git shortlog --summary --numbered' __git_complete gcount _git_shortlog #compdef _git gcount complete -F _git gcount alias gsh='command git show' __git_complete gsh _git_show alias gsps='command git show --pretty=short --show-signature' __git_complete gsps _git_show alias gsta='command git stash save' __git_complete gsta _git_stash alias gstaa='command git stash apply' __git_complete gstaa _git_stash alias gstall='command git stash --all' __git_complete gstall _git_stash alias gstc='command git stash clear' __git_complete gstc _git_stash alias gstd='command git stash drop' __git_complete gstd _git_stash alias gstl='command git stash list' __git_complete gstl _git_stash alias gstp='command git stash pop' __git_complete gstp _git_stash alias gsts='command git stash show' __git_complete gsts _git_stash alias gstu='gsta --include-untracked' __git_complete gstu _git_stash #is-at-least 2.13 "$git_version" && alias gsta='command git stash push' alias gsb='command git status --short --branch' __git_complete gsb _git_status alias gss='command git status --short' __git_complete gss _git_status alias gst='command git status' __git_complete gst _git_status alias gsi='command git submodule init' __git_complete gsi _git_submodule alias gsu='command git submodule update' __git_complete gsu _git_submodule alias git-svn-dcommit-push='command git svn dcommit && command git push github "$(git_main_branch):svntrunk"' alias gsd='command git svn dcommit' __git_complete gsd _git_svn alias gsr='command git svn rebase' __git_complete gsr _git_svn #compdef _git git-svn-dcommit-push=git alias gsw='command git switch' __git_complete gsw _git_switch alias gswc='command git switch --create' __git_complete gswc _git_switch alias gswd='command git switch "$(git_develop_branch)"' __git_complete gswd _git_switch alias gswm='command git switch "$(git_main_branch)"' __git_complete gswm _git_switch alias gta='command git tag --annotate' __git_complete gta _git_tag alias gts='command git tag --sign' __git_complete gts _git_tag alias gtv='command git tag | sort -V' __git_complete gtv _git_tag function gtl { command git tag --sort=-v:refname -n --list "$1*" } __git_complete gtl _git_tag #compdef _git gtl=git-tag alias gignore='command git update-index --assume-unchanged' alias gunignore='command git update-index --no-assume-unchanged' alias gwch='command git whatchanged -p --abbrev-commit --pretty=medium' __git_complete gwch _git_whatchanged alias gwt='command git worktree' __git_complete gwt _git_worktree alias gwta='command git worktree add' __git_complete gwta _git_worktree alias gwtls='command git worktree list' __git_complete gwtls _git_worktree alias gwtmv='command git worktree move' __git_complete gwtmv _git_worktree alias gwtrm='command git worktree remove' __git_complete gwtrm _git_worktree alias gk='\gitk --all --branches' alias gke='\gitk --all $(git log --walk-reflogs --pretty=%h)' # alias gk='\gitk --all --branches &!' # alias gke='\gitk --all $(git log --walk-reflogs --pretty=%h) &!' #compdef _git gk='command gitk' #compdef _git gke='command gitk' ================================================ FILE: plugins/goenv/README.md ================================================ # goenv plugin The goenv plugin will configure goenv paths and configure goenv to manage GOROOT and GOHOME. ================================================ FILE: plugins/goenv/goenv.plugin.sh ================================================ #! bash oh-my-bash.module # @chopnico 2021 if [[ -d ~/.goenv ]]; then # goenv exported variables export GOENV_ROOT=~/.goenv export PATH=$GOENV_ROOT/bin${PATH:+:$PATH} # Enables goenv shims eval -- "$(goenv init -)" # Allows goenv to manage GOPATH and GOROOT export PATH=$GOROOT/bin:$PATH export PATH=$PATH:$GOPATH/bin fi ================================================ FILE: plugins/golang/README.md ================================================ # Golang plugin The `golang plugin` plugin adds some aliases for common [Golang](https://golang.org/) commands. To use it, add `golang` to the plugins array of your bashrc file: ``` plugins=(... golang) ``` ## Aliases | Alias | Command | Description | | ------- | ----------------------- | ------------------------------------------------------------- | | gob | `go build` | Build your code | | goc | `go clean` | Removes object files from package source directories | | god | `go doc` | Prints documentation comments | | gof | `go fmt` | Gofmt formats (aligns and indents) Go programs. | | gofa | `go fmt ./...` | Run go fmt for all packages in current directory, recursively | | gog | `go get` | Downloads packages and then installs them to $GOPATH | | goi | `go install` | Compiles and installs packages to $GOPATH | | gol | `go list` | Lists Go packages | | gom | `go mod` | Access to operations on modules | | gop | `cd $GOPATH` | Takes you to $GOPATH | | gopb | `cd $GOPATH/bin` | Takes you to $GOPATH/bin | | gops | `cd $GOPATH/src` | Takes you to $GOPATH/src | | gor | `go run` | Compiles and runs your code | | got | `go test` | Runs tests | | gov | `go vet` | Vet examines Go source code and reports suspicious constructs | ================================================ FILE: plugins/golang/golang.plugin.sh ================================================ #! bash oh-my-bash.module alias gob='go build' alias goc='go clean' alias god='go doc' alias gof='go fmt' alias gofa='go fmt ./...' alias gog='go get' alias goi='go install' alias gol='go list' alias gom='go mod' alias gop='cd $GOPATH' alias gopb='cd $GOPATH/bin' alias gops='cd $GOPATH/src' alias gor='go run' alias got='go test' alias gov='go vet' ================================================ FILE: plugins/jump/README.md ================================================ # jump plugin The jump plugin enables jump on bash. Jump integrates with your shell and learns about your navigational habits by keeping track of the directories you visit. It gives you the most visited directory for the shortest search term you type. ## Installation 1. [Install jump](https://github.com/gsamokovarov/jump?tab=readme-ov-file#installation) 2. Enable the plugin by adding it to the plugins array of your bashrc file: ```bash plugins=(... jump) ``` 3. (Optional) Enable the completions by adding it to the completions array of bashrc file: ```bash completions=(... jump) ``` ## Usage See the [jump usage documentation](https://github.com/gsamokovarov/jump?tab=readme-ov-file#usage) for information on how to use jump. ================================================ FILE: plugins/jump/jump.plugin.sh ================================================ #! bash oh-my-bash.module # Check if jump is installed if _omb_util_command_exists jump; then eval -- "$(jump shell bash)" else _omb_util_print '[oh-my-bash] jump not found, please install it from https://github.com/gsamokovarov/jump' >&2 fi ================================================ FILE: plugins/kubectl/README.md ================================================ # Kubectl plugin This plugin adds completion for the [Kubernetes cluster manager](https://kubernetes.io/docs/reference/kubectl/kubectl/), as well as some aliases for common kubectl commands. To use it, add `kubectl` to the plugins array in your bashrc file: ```bash plugins=(... kubectl) ``` ## Aliases | Alias | Command | Description | |:--------|:------------------------------------|:-------------------------------------------------------------------------------------------------| | k | `kubectl` | The kubectl command | | kca | `kubectl --all-namespaces` | The kubectl command targeting all namespaces | | kaf | `kubectl apply -f` | Apply a YML file | | keti | `kubectl exec -ti` | Drop into an interactive terminal on a container | | | | **Manage configuration quickly to switch contexts between local, dev and staging** | | kcuc | `kubectl config use-context` | Set the current-context in a kubeconfig file | | kcsc | `kubectl config set-context` | Set a context entry in kubeconfig | | kcdc | `kubectl config delete-context` | Delete the specified context from the kubeconfig | | kccc | `kubectl config current-context` | Display the current-context | | kcgc | `kubectl config get-contexts` | List of contexts available | | | **General aliases** | | kdel | `kubectl delete` | Delete resources by filenames, stdin, resources and names, or by resources and label selector | | kdelf | `kubectl delete -f` | Delete a pod using the type and name specified in -f argument | | | | **Pod management** | | kgp | `kubectl get pods` | List all pods in ps output format | | kgpw | `kgp --watch` | After listing/getting the requested object, watch for changes | | kgpwide | `kgp -o wide` | Output in plain-text format with any additional information. For pods, the node name is included | | kep | `kubectl edit pods` | Edit pods from the default editor | | kdp | `kubectl describe pods` | Describe all pods | | kdelp | `kubectl delete pods` | Delete all pods matching passed arguments | | kgpl | `kgp -l` | Get pod by label. Example: `kgpl "app=myapp" -n myns` | | | | **Service management** | | kgs | `kubectl get svc` | List all services in ps output format | | kgsw | `kgs --watch` | After listing all services, watch for changes | | kgswide | `kgs -o wide` | After listing all services, output in plain-text format with any additional information | | kes | `kubectl edit svc` | Edit services(svc) from the default editor | | kds | `kubectl describe svc` | Describe all services in detail | | kdels | `kubectl delete svc` | Delete all services matching passed argument | | | | **Ingress management** | | kgi | `kubectl get ingress` | List ingress resources in ps output format | | kei | `kubectl edit ingress` | Edit ingress resource from the default editor | | kdi | `kubectl describe ingress` | Describe ingress resource in detail | | kdeli | `kubectl delete ingress` | Delete ingress resources matching passed argument | | | | **Namespace management** | | kgns | `kubectl get namespaces` | List the current namespaces in a cluster | | kcn | `kubectl config set-context ...` | Change current namespace | | kens | `kubectl edit namespace` | Edit namespace resource from the default editor | | kdns | `kubectl describe namespace` | Describe namespace resource in detail | | kdelns | `kubectl delete namespace` | Delete the namespace. WARNING! This deletes everything in the namespace | | | | **ConfigMap management** | | kgcm | `kubectl get configmaps` | List the configmaps in ps output format | | kecm | `kubectl edit configmap` | Edit configmap resource from the default editor | | kdcm | `kubectl describe configmap` | Describe configmap resource in detail | | kdelcm | `kubectl delete configmap` | Delete the configmap | | | | **Secret management** | | kgsec | `kubectl get secret` | Get secret for decoding | | kdsec | `kubectl describe secret` | Describe secret resource in detail | | kdelsec | `kubectl delete secret` | Delete the secret | | | | **Deployment management** | | kgd | `kubectl get deployment` | Get the deployment | | kgdw | `kgd --watch` | After getting the deployment, watch for changes | | kgdwide | `kgd -o wide` | After getting the deployment, output in plain-text format with any additional information | | ked | `kubectl edit deployment` | Edit deployment resource from the default editor | | kdd | `kubectl describe deployment` | Describe deployment resource in detail | | kdeld | `kubectl delete deployment` | Delete the deployment | | ksd | `kubectl scale deployment` | Scale a deployment | | krsd | `kubectl rollout status deployment` | Check the rollout status of a deployment | | kres | `kubectl set env $@ REFRESHED_AT=...` | Recreate all pods in deployment with zero-downtime | | | | **Rollout management** | | kgrs | `kubectl get rs` | To see the ReplicaSet `rs` created by the deployment | | krh | `kubectl rollout history` | Check the revisions of this deployment | | kru | `kubectl rollout undo` | Rollback to the previous revision | | | | **Port forwarding** | | kpf | `kubectl port-forward` | Forward one or more local ports to a pod | | | | **Tools for accessing all information** | | kga | `kubectl get all` | List all resources in ps format | | kgaa | `kubectl get all --all-namespaces` | List the requested object(s) across all namespaces | | | | **Logs** | | kl | `kubectl logs` | Print the logs for a container or resource | | klf | `kubectl logs -f` | Stream the logs for a container or resource (follow) | | | | **File copy** | | kcp | `kubectl cp` | Copy files and directories to and from containers | | | | **Node management** | | kgno | `kubectl get nodes` | List the nodes in ps output format | | keno | `kubectl edit node` | Edit nodes resource from the default editor | | kdno | `kubectl describe node` | Describe node resource in detail | | kdelno | `kubectl delete node` | Delete the node | | | | **Persistent Volume Claim management** | | kgpvc | `kubectl get pvc` | List all PVCs | | kgpvcw | `kgpvc --watch` | After listing/getting the requested object, watch for changes | | kepvc | `kubectl edit pvc` | Edit pvcs from the default editor | | kdpvc | `kubectl describe pvc` | Descirbe all pvcs | | kdelpvc | `kubectl delete pvc` | Delete all pvcs matching passed arguments | | | | | | kgss | `kubectl get statefulset` | List the statefulsets in ps format | | kgssw | `kgss --watch` | After getting the list of statefulsets, watch for changes | | kgsswide| `kgss -o wide` | After getting the statefulsets, output in plain-text format with any additional information | | kess | `kubectl edit statefulset` | Edit statefulset resource from the default editor | | kdss | `kubectl describe statefulset` | Describe statefulset resource in detail | | kdelss | `kubectl delete statefulset` | Delete the statefulset | | ksss | `kubectl scale statefulset` | Scale a statefulset | | krsss | `kubectl rollout status statefulset`| Check the rollout status of a deployment | ================================================ FILE: plugins/kubectl/kubectl.plugin.sh ================================================ #! bash oh-my-bash.module # This command is used a LOT both below and in daily life alias k=kubectl # Execute a kubectl command against all namespaces function kca { kubectl "$@" --all-namespaces } # Apply a YML file alias kaf='kubectl apply -f' # Drop into an interactive terminal on a container alias keti='kubectl exec -ti' # Manage configuration quickly to switch contexts between local, dev ad staging. alias kcuc='kubectl config use-context' alias kcsc='kubectl config set-context' alias kcdc='kubectl config delete-context' alias kccc='kubectl config current-context' # List all contexts alias kcgc='kubectl config get-contexts' # General aliases alias kdel='kubectl delete' alias kdelf='kubectl delete -f' # Pod management. alias kgp='kubectl get pods' alias kgpw='kgp --watch' alias kgpwide='kgp -o wide' alias kep='kubectl edit pods' alias kdp='kubectl describe pods' alias kdelp='kubectl delete pods' # get pod by label: kgpl "app=myapp" -n myns alias kgpl='kgp -l' # Service management. alias kgs='kubectl get svc' alias kgsw='kgs --watch' alias kgswide='kgs -o wide' alias kes='kubectl edit svc' alias kds='kubectl describe svc' alias kdels='kubectl delete svc' # Ingress management alias kgi='kubectl get ingress' alias kei='kubectl edit ingress' alias kdi='kubectl describe ingress' alias kdeli='kubectl delete ingress' # Namespace management alias kgns='kubectl get namespaces' alias kens='kubectl edit namespace' alias kdns='kubectl describe namespace' alias kdelns='kubectl delete namespace' alias kcn='kubectl config set-context $(kubectl config current-context) --namespace' # ConfigMap management alias kgcm='kubectl get configmaps' alias kecm='kubectl edit configmap' alias kdcm='kubectl describe configmap' alias kdelcm='kubectl delete configmap' # Secret management alias kgsec='kubectl get secret' alias kdsec='kubectl describe secret' alias kdelsec='kubectl delete secret' # Deployment management. alias kgd='kubectl get deployment' alias kgdw='kgd --watch' alias kgdwide='kgd -o wide' alias ked='kubectl edit deployment' alias kdd='kubectl describe deployment' alias kdeld='kubectl delete deployment' alias ksd='kubectl scale deployment' alias krsd='kubectl rollout status deployment' function kres { kubectl set env "$@" "REFRESHED_AT=$(date +%Y%m%d%H%M%S)" } # Rollout management. alias kgrs='kubectl get rs' alias krh='kubectl rollout history' alias kru='kubectl rollout undo' # Statefulset management. alias kgss='kubectl get statefulset' alias kgssw='kgss --watch' alias kgsswide='kgss -o wide' alias kess='kubectl edit statefulset' alias kdss='kubectl describe statefulset' alias kdelss='kubectl delete statefulset' alias ksss='kubectl scale statefulset' alias krsss='kubectl rollout status statefulset' # Port forwarding alias kpf="kubectl port-forward" # Tools for accessing all information alias kga='kubectl get all' alias kgaa='kubectl get all --all-namespaces' # Logs alias kl='kubectl logs' alias klf='kubectl logs -f' # File copy alias kcp='kubectl cp' # Node Management alias kgno='kubectl get nodes' alias keno='kubectl edit node' alias kdno='kubectl describe node' alias kdelno='kubectl delete node' # PVC management. alias kgpvc='kubectl get pvc' alias kgpvcw='kgpvc --watch' alias kepvc='kubectl edit pvc' alias kdpvc='kubectl describe pvc' alias kdelpvc='kubectl delete pvc' ================================================ FILE: plugins/npm/README.md ================================================ # npm plugin The npm plugin provides completion as well as adding many useful aliases. To use it, add npm to the plugins array of your bashrc file: ```bash plugins=(... npm) ``` ## Aliases | Alias | Command | Descripton | |:------ |:-----------------------------|:----------------------------------------------------------------| | `npmg` | `npm i -g` | Install dependencies globally | | `npmS` | `npm i -S` | Install and save to dependencies in your package.json | | `npmD` | `npm i -D` | Install and save to dev-dependencies in your package.json | | `npmE` | `PATH="$(npm bin)":"$PATH"` | Run command from node_modules folder based on current directory | | `npmO` | `npm outdated` | Check which npm modules are outdated | | `npmV` | `npm -v` | Check package versions | | `npmL` | `npm list` | List installed packages | | `npmL0` | `npm ls --depth=0` | List top-level installed packages | | `npmst` | `npm start` | Run npm start | | `npmt` | `npm test` | Run npm test | | `npmR` | `npm run` | Run npm scripts | | `npmP` | `npm publish` | Run npm publish | | `npmI` | `npm init` | Run npm init | ================================================ FILE: plugins/npm/npm.plugin.sh ================================================ #! bash oh-my-bash.module # Install dependencies globally alias npmg="npm i -g " # npm package names are lowercase # Thus, we've used camelCase for the following aliases: # Install and save to dependencies in your package.json # npms is used by https://www.npmjs.com/package/npms alias npmS="npm i -S " # Install and save to dev-dependencies in your package.json # npmd is used by https://github.com/dominictarr/npmd alias npmD="npm i -D " # Execute command from node_modules folder based on current directory # i.e npmE gulp alias npmE='PATH="$(npm bin)":"$PATH"' # Check which npm modules are outdated alias npmO="npm outdated" # Check package versions alias npmV="npm -v" # List packages alias npmL="npm list" # List top-level installed packages alias npmL0="npm ls --depth=0" # Run npm start alias npmst="npm start" # Run npm test alias npmt="npm test" # Run npm scripts alias npmR="npm run" # Run npm publish alias npmP="npm publish" # Run npm init alias npmI="npm init" ================================================ FILE: plugins/nvm/README.md ================================================ # nvm plugin This plugin automatically source nvm[1] ## Installation ### Install nvm Lets install[2] the nvm without updaing shell config! ```bash export NVM_DIR="$HOME/.nvm" && ( git clone https://github.com/nvm-sh/nvm.git "$NVM_DIR" cd "$NVM_DIR" git checkout `git describe --abbrev=0 --tags --match "v[0-9]*" $(git rev-list --tags --max-count=1)` ) && \. "$NVM_DIR/nvm.sh" ``` ### Include nvm as plugin ```bash plugins=( git nvm ) ``` ## nvm completion configuration ```bash completions=( git composer ssh nvm ) ``` ## `.nvmrc` autoload If set, the plugin will automatically load a node version when it finds a `.nvmrc` file[3] in the current working directory indicating which node version to load. This can be done by adding the following to your `.bashrc`: ```bash OMB_PLUGIN_NVM_AUTO_USE=true ``` [1]: https://github.com/nvm-sh/nvm [2]: https://github.com/nvm-sh/nvm#manual-install [3]: https://github.com/nvm-sh/nvm#nvmrc ================================================ FILE: plugins/nvm/nvm.plugin.sh ================================================ #! bash oh-my-bash.module # Description: automatically load nvm # # @var[opt] OMB_PLUGIN_NVM_AUTO_USE enable .nvmrc autoload # Set NVM_DIR if it isn't already defined [[ -z "$NVM_DIR" ]] && export NVM_DIR="$HOME/.nvm" # Try to load nvm only if command not already available if ! _omb_util_command_exists nvm; then # shellcheck source=/dev/null [[ -s $NVM_DIR/nvm.sh ]] && source "$NVM_DIR/nvm.sh" fi #------------------------------------------------------------------------------ # Optional .nvmrc autoload # # This part is originally from the official nvm documentation (README.md). The # current version is based on the following lines: # # https://github.com/nvm-sh/nvm/blob/99352a64d25ce27d49ff6a449663ce3d7c12e5b5/README.md?plain=1#L686-L726 # # Here is the license of the original project: # # The MIT License (MIT) # # Copyright (c) 2010 Tim Caswell # Copyright (c) 2014 Jordan Harband # # 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. # if _omb_util_command_exists nvm && [[ ${OMB_PLUGIN_NVM_AUTO_USE-} == true ]]; then function _omb_plugin_nvm_find_up { local path=$PWD while [[ $path && ! -e $path/$1 ]]; do path=${path%/*} done _omb_util_print "$path" } function _omb_plugin_nvm_cd { command cd "$@" || return "$?" local nvm_path=$(_omb_plugin_nvm_find_up .nvmrc) # If there are no .nvmrc file, use the default nvm version if [[ $nvm_path != *[^[:space:]]* ]]; then local default_version default_version=$(nvm version default) # If there is no default version, set it to `node` # This will use the latest version on your machine if [[ $default_version == "N/A" ]]; then nvm alias default node default_version=$(nvm version default) fi # If the current version is not the default version, set it to use the default version if [[ $(nvm current) != "$default_version" ]]; then nvm use default fi elif [[ -s $nvm_path/.nvmrc && -r $nvm_path/.nvmrc ]]; then local nvm_version nvm_version=$(< "$nvm_path"/.nvmrc) local locally_resolved_nvm_version # `nvm ls` will check all locally-available versions. If there are # multiple matching versions, take the latest one. Remove the `->` and # `*` characters and spaces. `locally_resolved_nvm_version` will be # `N/A` if no local versions are found. locally_resolved_nvm_version=$(nvm ls --no-colors "$nvm_version" | command sed -n '${s/->//g;s/[*[:space:]]//g;p;}') # If it is not already installed, install it if [[ $locally_resolved_nvm_version == N/A ]]; then nvm install "$nvm_version" elif [[ $(nvm current) != "$locally_resolved_nvm_version" ]]; then nvm use "$nvm_version" fi fi } alias cd='_omb_plugin_nvm_cd' fi #------------------------------------------------------------------------------ ================================================ FILE: plugins/progress/README.md ================================================ # Using the Progress Bar Script ## Description This script provides a simple progress bar TUI for the terminal platform. It allows you to visualize the progress of a task being executed in your shell script. ## Usage You can use the function `progress` from the interactive settings with Oh My Bash. The function handles printing of the progress bar. 1. **Enable plugin:** - Add the plugin name `progress` in the `plugins` array in `~/.bashrc`. ```shell # bashrc plugins=(... progress) ``` 2. **Invoke `progress` Function:** - Within a shell function, call the `progress` function whenever you want to display the progress bar. - Pass two parameters to the `progress` function: - `value`: The progress percentage (0-100) of the task. Passing 0 will reset the progress bar status. - `message`: Optional. A status message to display alongside the progress bar. ```bash # Example usage: progress 25 "Processing data..." # Displays a 25% progress bar with the status "Processing data..." ``` To change the delay of the progress bar, please overwrite the `delay` function. ```bash # Example: change the delay to 0.1 sec function delay { sleep 0.1; } ``` _⚠️ if you want to add only the plugin and not Oh My Bash, you can copy the file `progress.plugin.sh` to a place you like and source it in `~/.basrhc` (for interactive uses) or in a shell script (for a standalone shell program). You may instead copy and paste the functions directly into a script file, in which case the plugin will not receive updates and possible errors will have to be solved by you_ ## Example ```bash # bashrc function example { # Example: Your code for the shell function here: Invoke the progress # function to display the progress bar as your function progresses. This # displays a 25% progress bar with the status "Processing data...": progress 25 "Processing data..." ``` This will visually represent the progress of your function's execution in the terminal. Adjust the `progress` function calls according to the progress of your task. ================================================ FILE: plugins/progress/progress.plugin.sh ================================================ #! bash oh-my-bash.module ############################---Description---################################### # # # Summary : Show a progress bar GUI on terminal platform # # Support : destro.nnt@gmail.com # # Created date : Aug 12,2014 # # Latest Modified date : Dec 19,2024 # # # ################################################################################ ############################---Usage---######################################### # Copy below functions (delay and progress fuctions) into your shell script directly # Then invoke progress function to show progress bar # In other way, you could import source indirectly then using. Nothing different ################################################################################ # Global variable to store progress value _omb_plugin_progress_value=0 _omb_plugin_progress_clear_line= # # Description : delay executing script # function delay { sleep 0.2 } # # Description : print out executing progress # function progress { local value=$1 local message=$2 if [[ ! $value ]]; then _omb_util_print_lines \ 'Usage: progress [message]' \ '' \ 'Options:' \ ' value The value for the progress bar. Use 0 to reset.' \ ' message The optional message to display next to the progress bar.' return 2 fi if ((value < 0)); then _omb_log_error "invalid value: value' (expect: 0-100)" >&2 return 2 fi # Reset the progress value if ((value == 0)); then _omb_plugin_progress_value=0 return 0 fi # Get a clear line escape sequence local clear_line=$_omb_plugin_progress_clear_line if [[ ! $clear_line ]]; then clear_line=$(tput el 2>/dev/null || tput ce 2>/dev/null) if [[ ! $clear_line ]]; then clear_line=$'\e[K' fi _omb_plugin_progress_clear_line=$clear_line fi if ((_omb_plugin_progress_value <= 0 && value >= 0)); then printf "%s[............................] (0%%) %s\r" "$clear_line" "$message"; delay; fi if ((_omb_plugin_progress_value <= 5 && value >= 5)); then printf "%s[#...........................] (5%%) %s\r" "$clear_line" "$message"; delay; fi if ((_omb_plugin_progress_value <= 10 && value >= 10)); then printf "%s[##..........................] (10%%) %s\r" "$clear_line" "$message"; delay; fi if ((_omb_plugin_progress_value <= 15 && value >= 15)); then printf "%s[###.........................] (15%%) %s\r" "$clear_line" "$message"; delay; fi if ((_omb_plugin_progress_value <= 20 && value >= 20)); then printf "%s[####........................] (20%%) %s\r" "$clear_line" "$message"; delay; fi if ((_omb_plugin_progress_value <= 25 && value >= 25)); then printf "%s[#####.......................] (25%%) %s\r" "$clear_line" "$message"; delay; fi if ((_omb_plugin_progress_value <= 30 && value >= 30)); then printf "%s[######......................] (30%%) %s\r" "$clear_line" "$message"; delay; fi if ((_omb_plugin_progress_value <= 35 && value >= 35)); then printf "%s[#######.....................] (35%%) %s\r" "$clear_line" "$message"; delay; fi if ((_omb_plugin_progress_value <= 40 && value >= 40)); then printf "%s[########....................] (40%%) %s\r" "$clear_line" "$message"; delay; fi if ((_omb_plugin_progress_value <= 45 && value >= 45)); then printf "%s[#########...................] (45%%) %s\r" "$clear_line" "$message"; delay; fi if ((_omb_plugin_progress_value <= 50 && value >= 50)); then printf "%s[##########..................] (50%%) %s\r" "$clear_line" "$message"; delay; fi if ((_omb_plugin_progress_value <= 55 && value >= 55)); then printf "%s[###########.................] (55%%) %s\r" "$clear_line" "$message"; delay; fi if ((_omb_plugin_progress_value <= 60 && value >= 60)); then printf "%s[############................] (60%%) %s\r" "$clear_line" "$message"; delay; fi if ((_omb_plugin_progress_value <= 65 && value >= 65)); then printf "%s[#############...............] (65%%) %s\r" "$clear_line" "$message"; delay; fi if ((_omb_plugin_progress_value <= 70 && value >= 70)); then printf "%s[##############..............] (70%%) %s\r" "$clear_line" "$message"; delay; fi if ((_omb_plugin_progress_value <= 75 && value >= 75)); then printf "%s[################............] (75%%) %s\r" "$clear_line" "$message"; delay; fi if ((_omb_plugin_progress_value <= 80 && value >= 80)); then printf "%s[##################..........] (80%%) %s\r" "$clear_line" "$message"; delay; fi if ((_omb_plugin_progress_value <= 85 && value >= 85)); then printf "%s[#####################.......] (85%%) %s\r" "$clear_line" "$message"; delay; fi if ((_omb_plugin_progress_value <= 90 && value >= 90)); then printf "%s[########################....] (90%%) %s\r" "$clear_line" "$message"; delay; fi if ((_omb_plugin_progress_value <= 95 && value >= 95)); then printf "%s[###########################.] (95%%) %s\r" "$clear_line" "$message"; delay; fi if ((_omb_plugin_progress_value <= 100 && value >= 100)); then # Display the finished progress bar, and then clear with a new line. printf "%s[############################] (100%%) %s\r" "$clear_line" "$message" delay printf 'Done!%s\n' "$clear_line" value=0 fi _omb_plugin_progress_value=$value } ================================================ FILE: plugins/pyenv/README.md ================================================ # pyenv plugin The pyenv plugin will configure pyenv paths. ================================================ FILE: plugins/pyenv/pyenv.plugin.sh ================================================ #! bash oh-my-bash.module # @chopnico 2021 if [[ -d ~/.pyenv ]]; then export PYENV_ROOT=~/.pyenv export PATH=$PYENV_ROOT/bin${PATH:+:$PATH} eval -- "$(pyenv init --path)" eval -- "$(pyenv init -)" fi ================================================ FILE: plugins/rbenv/README.md ================================================ # rbenv plugin The rbenv plugin will configure rbenv paths. ## List of aliases | Alias | Command | Description | |--------|------------------|--------------------------------------| | rubies | 'rbenv versions' | shows all installed versions of ruby | ================================================ FILE: plugins/rbenv/rbenv.plugin.sh ================================================ #! bash oh-my-bash.module if [[ -d ~/.rbenv ]]; then export RBENV_ROOT=~/.rbenv export PATH=$RBENV_ROOT/bin:$PATH eval -- "$(rbenv init - bash)" alias rubies='rbenv versions' fi ================================================ FILE: plugins/sdkman/README.md ================================================ # sdkman plugin This plugin will automatically source [sdkman](https://sdkman.io/). ## Installation ### Install sdkman Let's [install the sdkman](https://sdkman.io/install) without updating shell config! ```bash $ curl -s "https://get.sdkman.io?rcupdate=false" | bash ``` ### Include sdkman as plugin ```bash plugins=( git sdkman ) ``` ================================================ FILE: plugins/sdkman/sdkman.plugin.sh ================================================ #! bash oh-my-bash.module # Set SDKMAN_DIR if it isn't already defined [[ ${SDKMAN_DIR-} ]] || export SDKMAN_DIR=~/.sdkman # Try to load sdk only if the command is not available if ! _omb_util_command_exists sdk && [[ -s $SDKMAN_DIR/bin/sdkman-init.sh ]]; then source "$SDKMAN_DIR/bin/sdkman-init.sh" fi ================================================ FILE: plugins/starship/README.md ================================================ # starship plugin Initializes [starship](https://github.com/starship/starship), the minimal, blazing-fast, and infinitely customizable prompt for any shell! To use it, add `starship` to the plugins array in your `.bashrc` file: ```bash plugins=(... starship) ``` **Note:** you have to [install starship](https://github.com/starship/starship?tab=readme-ov-file#step-1-install-starship) first. ## ⚠️ ENABLING THIS PLUGIN WILL UNSET YOUR OSH_THEME VARIABLE ================================================ FILE: plugins/starship/starship.plugin.sh ================================================ #! bash oh-my-bash.module # Check if starship is installed if _omb_util_command_exists starship; then # ignore oh-my-bash theme unset -v OSH_THEME eval -- "$(starship init bash)" else _omb_util_print '[oh-my-bash] starship not found, please install it from https://github.com/starship/starship' >&2 fi ================================================ FILE: plugins/sudo/README.md ================================================ # sudo Easily prefix your current or previous commands with `sudo` by pressing esc twice. To use it, add `sudo` to the plugins array in your bashrc file: ```bash plugins=(... sudo) ``` ## Usage ### Current typed commands Say you have typed a long command and forgot to add `sudo` in front: ```console $ apt-get install build-essential ``` By pressing the esc key twice, you will have the same command with `sudo` prefixed without typing: ```console $ sudo apt-get install build-essential ``` ### Previous executed commands Say you want to delete a system file and denied: ```console $ rm some-system-file.txt -su: some-system-file.txt: Permission denied $ ``` By pressing the esc key twice, you will have the same command with `sudo` prefixed without typing: ```console $ rm some-system-file.txt -su: some-system-file.txt: Permission denied $ sudo rm some-system-file.txt Password: $ ``` ## Credits Inspired by ohmyzsh sudo plugin. ================================================ FILE: plugins/sudo/sudo.plugin.sh ================================================ #! bash oh-my-bash.module function _omb_plugin_sudo__is_inserted { [[ $READLINE_LINE = 'sudo '* ]] } function _omb_plugin_sudo_add_sudo { if [[ ! $READLINE_LINE ]]; then READLINE_LINE=$(fc -ln -1 | command sed 's/^[[:space:]]\{1,\}//') READLINE_POINT=${#READLINE_LINE} _omb_plugin_sudo__is_inserted && return fi if _omb_plugin_sudo__is_inserted; then READLINE_LINE=${READLINE_LINE#sudo } ((READLINE_POINT -= 5)) else READLINE_LINE="sudo $READLINE_LINE" ((READLINE_POINT += 5)) fi ((READLINE_POINT < 0)) && READLINE_POINT=0 } bind -m emacs -x '"\e\e": _omb_plugin_sudo_add_sudo' bind -m vi-insert -x '"\e\e": _omb_plugin_sudo_add_sudo' bind -m vi-command -x '"\e\e": _omb_plugin_sudo_add_sudo' ================================================ FILE: plugins/tmux/README.md ================================================ # tmux This plugin provides aliases for [tmux](https://github.com/tmux/tmux), the terminal multiplexer. To use it, add `tmux` to the plugins array in your `.bashrc` file: ```bash plugins=(... tmux) ``` ## Aliases | Alias | Command | Description | | ---------- | -------------------------------------| ----------------------------------------------------------- | | `ta` | `tmux attach -t` | Attach to a named tmux session | | `tad` | `tmux attach -d -t` | Detach and attach to a named tmux session | | `tds` | `_omb_plugin_tmux_directory_session` | Create or attach to a session named after current directory | | `tkss` | `tmux kill-session -t` | Terminate a named running tmux session | | `tksv` | `tmux kill-server` | Terminate all running tmux sessions | | `tl` | `tmux list-sessions` | List running tmux sessions | | `to` | `tmux new-session -A -s` | Create or attach to a named tmux session | | `ts` | `tmux new-session -s` | Create a new named tmux session | | `tmuxconf` | `$EDITOR ~/.tmux.conf` | Open the tmux config file in your editor | ================================================ FILE: plugins/tmux/tmux.plugin.bash ================================================ #! bash oh-my-bash.module # tmux plugin: aliases for tmux, the terminal multiplexer. # Last reference implementation link: # https://github.com/ohmyzsh/ohmyzsh/blob/5c4f27b7166360bd23709f24642b247eac30a147/plugins/tmux/tmux.plugin.zsh # # Dropped features from upstream: # - alias tmux -> _zsh_tmux_plugin_run (tmux wrapper with autostart/autoconnect) # - function _zsh_tmux_plugin_run (autostart, autoconnect, autoquit, TERM fixing) # - function _zsh_tmux_plugin_preexec (refresh tmux environment variables) # - function _build_tmux_alias (zsh completion wiring) # - ZSH_TMUX_* configuration variables (AUTOSTART, AUTOCONNECT, AUTOQUIT, # AUTONAME_SESSION, AUTOREFRESH, CONFIG, DEFAULT_SESSION_NAME, DETACHED, # FIXTERM, FIXTERM_WITHOUT_256COLOR, FIXTERM_WITH_256COLOR, ITERM2, UNICODE) # - tmux.extra.conf, tmux.only.conf (TERM fix config files) if ! _omb_util_command_exists tmux; then _omb_util_print '[oh-my-bash] tmux not found, please install it from https://github.com/tmux/tmux' >&2 return 0 fi # Aliases alias ta='tmux attach -t' alias tad='tmux attach -d -t' alias tkss='tmux kill-session -t' alias tksv='tmux kill-server' alias tl='tmux list-sessions' alias ts='tmux new-session -s' alias to='tmux new-session -A -s' alias tmuxconf='${EDITOR:-vim} ~/.tmux.conf' # Create or attach to a tmux session named after the current directory. function _omb_plugin_tmux_directory_session { local dir=${PWD##*/} local md5 if _omb_util_command_exists md5sum; then md5=$(printf '%s' "$PWD" | md5sum | cut -d ' ' -f 1) elif _omb_util_command_exists md5; then md5=$(printf '%s' "$PWD" | md5) else _omb_util_print '[oh-my-bash] tmux plugin: md5sum or md5 not found, tds requires one of them' >&2 return 1 fi local session_name="${dir}-${md5:0:6}" tmux new-session -As "$session_name" } alias tds='_omb_plugin_tmux_directory_session' ================================================ FILE: plugins/tmux-autoattach/README.md ================================================ # tmux-autoattach.plugin This tmux plugin will automatically attach a tmux session to your shell session. ## Variables #### OSH_PLUGIN_TMUX_AUTOATTACH_BEHAVIOR | Setting | Description | |--------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------| | `detach` (default) | This will allow you to detach from the tmux screen without closing the terminal or shell session. | | `exit` | This will completely close out your shell session, including your terminal, but keep your tmux sessions intact. This will also close your session if you detach. | ## Common Enable Conditions *Note* If you prefer to manually start your desktop session using tools like `startx`, you may run into problems starting your desktop session inside of a tmux terminal. You can employ conditionals to control when this plugin should be enabled. **SSH** ```bash [[ ${SSH_TTY-} ]] && plugins+=(tmux-autoattach) ``` **Wayland** ```bash [[ ${DISPLAY_WAYLAND-} ]] && plugins+=(tmux-autoattach) ``` **X11** ```bash [[ ${DISPLAY-} ]] && plugins+=(tmux-autoattach) ``` **Multiple** ```bash if [[ ${DISPLAY-} || ${SSH-} ]]; then plugins+=(tmux-autoattach) fi ``` ================================================ FILE: plugins/tmux-autoattach/tmux-autoattach.plugin.sh ================================================ #! bash oh-my-bash.module # @chopnico 2021 # # tmux-autoattach.plugin.sh # # A tmux plugin that will automatically attach itself to a bash session. [[ ${OSH_PLUGIN_TMUX_AUTOATTACH_BEHAVIOR-} ]] || OSH_PLUGIN_TMUX_AUTOATTACH_BEHAVIOR="detach" # Note on the option "-As0": tmux-3.0a and before does not attach to a session # as far as the session name is not given by "-s SESSION_NAME" [1]. From # tmux-3.1, it attaches to an existing session, if any, without specifying the # session. Here, we assume the session name to be "0", which is the default # name for the first session. # # [1] https://github.com/ohmybash/oh-my-bash/pull/332 function _osh_plugin_tmux_autoattach_exit { [[ ! ${TMUX-} ]] && tmux -2u new -As0 && exit } function _osh_plugin_tmux_autoattach_detach { [[ ! ${TMUX-} ]] && tmux -2u new -As0 } case $OSH_PLUGIN_TMUX_AUTOATTACH_BEHAVIOR in 'exit') _osh_plugin_tmux_autoattach_exit ;; 'detach' | *) _osh_plugin_tmux_autoattach_detach ;; esac ================================================ FILE: plugins/vagrant/README.md ================================================ # vagrant plugin ## Introduction The `vagrant plugin` adds several useful aliases for [vagrant](https://www.vagrantup.com/downloads) commands and [aliases](#aliases). To use them, add `vagrant` to the `plugins` array of your bashrc file: ```bash plugins=(... vagrant) ``` ## Aliases | Command | Description | |:-------------------|:-------------------------------------------------------------| | `va` | command `vagrant` | | `vaver` | Show the vagrant version in this host | | `vaconf` | command `vagrant ssh-config` | | `vastat` | command `vagrant global-status` | | `vacheck` | command `vagrant validate` | | `vaport` | command `vagrant port` | | `vapvm` | command `vagrant plugin install *[ virtualbox \| libvirt ]*` | | `vapi` | command `vagrant plugin install *[ package ]*` | | `vapr` | command `vagrant plugin uninstall *[ package ]*` | | `vau` | command `vagrant up *[ virtualbox \| libvirt ]*` | | `vah` | command `vagrant halt` | | `vat` | command `vagrant destroy -f` | | `vai` | command `vagrant init -m *[ centos/7 ]*` | | `varel` | command `vagrant reload` | | `vassh` | command `vagrant ssh *[ machine1 ]*` | | `vaba` | command `vagrant box add` | | `vabr` | command `vagrant box remove` | | `vabl` | command `vagrant box list` | ================================================ FILE: plugins/vagrant/vagrant.plugin.sh ================================================ #! bash oh-my-bash.module # Author: Enzo Arroyo # Functions function vagrant-version() { vagrant --version } function vagrant-init() { if [[ $1 ]]; then _omb_util_print "Vagrant init for : $1 Creating...." vagrant init -m "$1" else _omb_util_print "Usage : vai " >&2 _omb_util_print "Example : vai centos/7" >&2 return 2 fi } function vagrant-up() { if [[ $1 ]]; then _omb_util_print "Vagrant up for provider : $1 Running...." vagrant up --provider "$1" else _omb_util_print "Vagrant up for provider : virtualbox Running...." vagrant up fi } function vagrant-plugin-vm() { case "$1" in "virtualbox") _omb_util_print "Vagrant plugin install for provider : $1 Running...." vagrant plugin install vagrant-vbguest ;; "libvirt") _omb_util_print "Vagrant plugin install for provider : $1 Running...." vagrant plugin install vagrant-libvirt ;; *) _omb_util_print "Usage : vapvm " >&2 _omb_util_print "Example : vapvm virtualbox" >&2 return 2 ;; esac } function vagrant-status() { if [[ -f Vagrantfile ]]; then vagrant status else vagrant global-status fi } function vagrant-ssh() { local VMCOUNT VMCOUNT=$(vagrant status | grep -c running) local VMDEFAULT VMDEFAULT=$(vagrant status | grep -w default | grep -c running) if ((VMDEFAULT == 1)); then if [[ $1 ]]; then _omb_util_print "SKIP : $1 Server...." fi _omb_util_print "Login to : default Server...." vagrant ssh elif [[ $1 ]] && ((VMCOUNT > 1)); then _omb_util_print "Login to : $1 Server...." vagrant ssh "$1" elif ((VMCOUNT == 0)); then _omb_util_print "Seems like that not there running servers" >&2 return 1 else _omb_util_put $'Please choose a server from this list:\n\n' vagrant status | awk '/running/{print $1}' _omb_util_put $'\nThen fill: vagrant ssh [ option ]\n' fi } # Aliases alias va='vagrant' alias vaver='vagrant-version' alias vaconf='vagrant ssh-config' alias vastat='vagrant-status' alias vacheck='vagrant validate' alias vaport='vagrant port' alias vapvm='vagrant-plugin-vm' alias vapi='vagrant plugin install' alias vapr='vagrant plugin uninstall' alias vau='vagrant-up' alias vah='vagrant halt' alias vat='vagrant destroy -f' alias vai='vagrant-init' alias varel='vagrant reload' alias vassh='vagrant-ssh' alias vaba='vagrant box add' alias vabr='vagrant box remove' alias vavl='vagrant box list' ================================================ FILE: plugins/virtualenvwrapper/README.md ================================================ # virtualenvwrapper plugin The virtualenvwrapper plugin enables virtualenvwrapper functions in bash. To use it, install [virtualenvwrapper](https://github.com/python-virtualenvwrapper/virtualenvwrapper) and add virtualenvwrapper to the plugins array of your bashrc file: ```bash plugins=(... virtualenvwrapper) ``` ================================================ FILE: plugins/virtualenvwrapper/virtualenvwrapper.plugin.sh ================================================ #! bash oh-my-bash.module # Check if virtualenvwrapper is installed if _omb_util_command_exists virtualenvwrapper.sh; then # Source the virtualenvwrapper script source virtualenvwrapper.sh else _omb_util_print '[oh-my-bash] virtualenvwrapper not found, please install it from https://github.com/python-virtualenvwrapper/virtualenvwrapper' >&2 fi ================================================ FILE: plugins/xterm/README.md ================================================ # Xterm Plugin ## Description This script automatically sets your xterm title with host and location information. It dynamically updates the title to reflect the current user, host, directory, and command being executed. ## Source You can find the original source of this script [here](https://github.com/Bash-it/bash-it/blob/bf2034d13d/plugins/available/xterm.plugin.bash). ## Variables - `PROMPT_CHAR` (optional): This variable is shared with powerline. - `OMB_PLUGIN_XTERM_SHORT_TERM_LINE` (optional): Controls whether to shorten the directory name in the title. - `OMB_PLUGIN_XTERM_SHORT_USER` (optional): Overrides the default user name. - `OMB_PLUGIN_XTERM_SHORT_HOSTNAME` (optional): Overrides the default hostname. ## Functions 1. **`set_xterm_title`** - Sets the xterm title with the provided string. ## Usage 1. **Enable plugin:** - Add the plugin name `xterm` in the `plugins` array in `~/.bashrc`. ```shell # bashrc plugins=(... xterm) ``` 2. **Customization:** - Modify the variables and functions as needed to fit your preferences. The xterm title will be automatically updated based on your commands and directory changes. _⚠️ if you want to add only this plugin and not Oh My Bash, you can copy the file `xterm.plugin.bash` in a place you like and edit the file to comment out the line `_omb_module_require plugin:bash-preexec`. Then, source `xterm.plugin.bash` in `~/.basrhc` (for interactive uses) or in a shell script (for a standalone shell program). To make the xterm title be automatically updated, you also need to get a copy of `bash-preexec.sh` (a not up-to-date one is found in the repository of Oh My Bash at `tools/bash-preexec.sh`) and source it as well. You may instead copy and paste the functions directly into a script file, in which case the plugin will not receive updates and possible errors will have to be solved by you_ ## Dependencies This plugin relies on `bash-preexec.sh` for the preexec and precmd hooks. ================================================ FILE: plugins/xterm/xterm.plugin.bash ================================================ #! bash oh-my-bash.module # Description: automatically set your xterm title with host and location info' # Source: https://github.com/Bash-it/bash-it/blob/bf2034d13d/plugins/available/xterm.plugin.bash # # @var[opt] PROMPT_CHAR ... This variable is shared with powerline # @var[opt] OMB_PLUGIN_XTERM_SHORT_TERM_LINE # @var[opt] OMB_PLUGIN_XTERM_SHORT_USER # @var[opt] OMB_PLUGIN_XTERM_SHORT_HOSTNAME # _omb_module_require plugin:bash-preexec function _omb_plugin_xterm_short_dirname { local dir_name=${PWD/~/\~} if [[ ${OMB_PLUGIN_XTERM_SHORT_TERM_LINE-} == true ]] && ((${#dir_name} > 8)); then dir_name=${dir_name##*/} fi _omb_util_print "$dir_name" } function _omb_plugin_xterm_short_command { local input_command="$*" if [[ ${OMB_PLUGIN_XTERM_SHORT_TERM_LINE-} == true ]] && ((${#input_command} > 8)); then input_command=${input_command%% *} fi _omb_util_print "$input_command" } function _omb_plugin_xterm_set_title { local title=${1:-terminal} printf '\e]0;%s\e\\' "$title" } function _omb_plugin_xterm_precmd_title { local user=${OMB_PLUGIN_XTERM_SHORT_USER:-$USER} local host=${OMB_PLUGIN_XTERM_SHORT_HOSTNAME:-$HOSTNAME} _omb_plugin_xterm_set_title "$user@$host $(_omb_plugin_xterm_short_dirname) ${PROMPT_CHAR:-\$}" } function _omb_plugin_xterm_preexec_title { local command_line=${BASH_COMMAND:-${1:-}} local directory_name=$(_omb_plugin_xterm_short_dirname) local short_command=$(_omb_plugin_xterm_short_command "$command_line") local user=${OMB_PLUGIN_XTERM_SHORT_USER:-$USER} local host=${OMB_PLUGIN_XTERM_SHORT_HOSTNAME:-$HOSTNAME} _omb_plugin_xterm_set_title "$short_command {$directory_name} ($user@$host)" } function set_xterm_title { _omb_plugin_xterm_set_title "$@"; } precmd_functions+=(_omb_plugin_xterm_precmd_title) preexec_functions+=(_omb_plugin_xterm_preexec_title) ================================================ FILE: plugins/zellij-autoattach/README.md ================================================ # zellij-autoattach.plugin This zellij plugin will automatically attach a zellij session to your shell session. ## Variables #### OSH_PLUGIN_ZELLIJ_AUTOATTACH_BEHAVIOR | Setting | Description | |--------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------| | `detach` (default) | This will allow you to detach from the zellij screen without closing the terminal or shell session. | | `exit` | This will completely close out your shell session, including your terminal, but keep your zellij sessions intact. This will also close your session if you detach. | ## Common Enable Conditions *Note* If you prefer to manually start your desktop session using tools like `startx`, you may run into problems starting your desktop session inside of a zellij terminal. You can employ conditionals to control when this plugin should be enabled. **SSH** ```bash [[ ${SSH_TTY-} ]] && plugins+=(zellij-autoattach) ``` **Wayland** ```bash [[ ${DISPLAY_WAYLAND-} ]] && plugins+=(zellij-autoattach) ``` **X11** ```bash [[ ${DISPLAY-} ]] && plugins+=(zellij-autoattach) ``` **Multiple** ```bash if [[ ${DISPLAY-} || ${SSH-} ]]; then plugins+=(zellij-autoattach) fi ``` ================================================ FILE: plugins/zellij-autoattach/zellij-autoattach.plugin.sh ================================================ #! bash oh-my-bash.module # @chopnico 2021 # @NN--- 2025 # # zellij-autoattach.plugin.sh # # A zellij plugin that will automatically attach itself to a bash session. # This plugin is derived from tmux-autoattach.plugin.sh. [[ ${OSH_PLUGIN_ZELLIJ_AUTOATTACH_BEHAVIOR-} ]] || OSH_PLUGIN_ZELLIJ_AUTOATTACH_BEHAVIOR="detach" function _osh_plugin_zellij_autoattach_exit { [[ ! ${ZELLIJ-} ]] && zellij attach --create default && exit } function _osh_plugin_zellij_autoattach_detach { [[ ! ${ZELLIJ-} ]] && zellij attach --create default } case $OSH_PLUGIN_ZELLIJ_AUTOATTACH_BEHAVIOR in 'exit') _osh_plugin_zellij_autoattach_exit ;; 'detach' | *) _osh_plugin_zellij_autoattach_detach ;; esac ================================================ FILE: plugins/zoxide/README.md ================================================ # zoxide plugin Initializes [zoxide](https://github.com/ajeetdsouza/zoxide), a smarter cd command for your terminal. ![Tutorial](https://raw.githubusercontent.com/ajeetdsouza/zoxide/97dc08347d9dbf5b5a4516b79e0ac27366b962ce/contrib/tutorial.webp) To use it, add `zoxide` to the plugins array in your `.bashrc` file: ```bash plugins=(... zoxide) ``` **Note:** you have to [install zoxide](https://github.com/ajeetdsouza/zoxide#step-1-install-zoxide) first. ================================================ FILE: plugins/zoxide/zoxide.plugin.sh ================================================ #! bash oh-my-bash.module # Check if zoxide is installed if _omb_util_command_exists zoxide; then eval -- "$(zoxide init bash)" else _omb_util_print '[oh-my-bash] zoxide not found, please install it from https://github.com/ajeetdsouza/zoxide' >&2 fi ================================================ FILE: templates/bash_profile.osh-template ================================================ # .bash_profile -*- mode: sh -*- # Load login settings and environment variables if [[ -f ~/.profile ]]; then source ~/.profile fi # Load interactive settings if [[ -f ~/.bashrc ]]; then source ~/.bashrc fi ================================================ FILE: templates/bashrc.osh-template ================================================ # Enable the subsequent settings only in interactive sessions case $- in *i*) ;; *) return;; esac # Path to your oh-my-bash installation. export OSH=~/.oh-my-bash # Set name of the theme to load. Optionally, if you set this to "random" # it'll load a random theme each time that oh-my-bash is loaded. OSH_THEME="font" # If you set OSH_THEME to "random", you can ignore themes you don't like. # OMB_THEME_RANDOM_IGNORED=("powerbash10k" "wanelo") # You can also specify the list from which a theme is randomly selected: # OMB_THEME_RANDOM_CANDIDATES=("font" "powerline-light" "minimal") # Uncomment the following line to use case-sensitive completion. # OMB_CASE_SENSITIVE="true" # Uncomment the following line to use hyphen-insensitive completion. Case # sensitive completion must be off. _ and - will be interchangeable. # OMB_HYPHEN_SENSITIVE="false" # Uncomment the following line to disable bi-weekly auto-update checks. # DISABLE_AUTO_UPDATE="true" # Uncomment the following line to change how often to auto-update (in days). # export UPDATE_OSH_DAYS=13 # Uncomment the following line to disable colors in ls. # DISABLE_LS_COLORS="true" # Uncomment the following line to disable auto-setting terminal title. # DISABLE_AUTO_TITLE="true" # Uncomment the following line to enable command auto-correction. # ENABLE_CORRECTION="true" # Uncomment the following line to display red dots whilst waiting for completion. # COMPLETION_WAITING_DOTS="true" # Uncomment the following line if you want to disable marking untracked files # under VCS as dirty. This makes repository status check for large repositories # much, much faster. # DISABLE_UNTRACKED_FILES_DIRTY="true" # Uncomment the following line if you don't want the repository to be considered dirty # if there are untracked files. # SCM_GIT_DISABLE_UNTRACKED_DIRTY="true" # Uncomment the following line if you want to completely ignore the presence # of untracked files in the repository. # SCM_GIT_IGNORE_UNTRACKED="true" # Uncomment the following line if you want to change the command execution time # stamp shown in the history command output. One of the following values can # be used to specify the timestamp format. # * 'mm/dd/yyyy' # mm/dd/yyyy + time # * 'dd.mm.yyyy' # dd.mm.yyyy + time # * 'yyyy-mm-dd' # yyyy-mm-dd + time # * '[mm/dd/yyyy]' # [mm/dd/yyyy] + [time] with colors # * '[dd.mm.yyyy]' # [dd.mm.yyyy] + [time] with colors # * '[yyyy-mm-dd]' # [yyyy-mm-dd] + [time] with colors # If not set, the default value is 'yyyy-mm-dd'. # HIST_STAMPS='yyyy-mm-dd' # Uncomment the following line if you do not want OMB to overwrite the existing # aliases by the default OMB aliases defined in lib/*.sh # OMB_DEFAULT_ALIASES="check" # Would you like to use another custom folder than $OSH/custom? # OSH_CUSTOM=/path/to/new-custom-folder # To disable the uses of "sudo" by oh-my-bash, please set "false" to # this variable. The default behavior for the empty value is "true". OMB_USE_SUDO=true # To enable/disable display of Python virtualenv and condaenv # OMB_PROMPT_SHOW_PYTHON_VENV=true # enable # OMB_PROMPT_SHOW_PYTHON_VENV=false # disable # To enable/disable Spack environment information # OMB_PROMPT_SHOW_SPACK_ENV=true # enable # OMB_PROMPT_SHOW_SPACK_ENV=false # disable # Which completions would you like to load? (completions can be found in ~/.oh-my-bash/completions/*) # Custom completions may be added to ~/.oh-my-bash/custom/completions/ # Example format: completions=(ssh git bundler gem pip pip3) # Add wisely, as too many completions slow down shell startup. completions=( git composer ssh ) # Which aliases would you like to load? (aliases can be found in ~/.oh-my-bash/aliases/*) # Custom aliases may be added to ~/.oh-my-bash/custom/aliases/ # Example format: aliases=(vagrant composer git-avh) # Add wisely, as too many aliases slow down shell startup. aliases=( general ) # Which plugins would you like to load? (plugins can be found in ~/.oh-my-bash/plugins/*) # Custom plugins may be added to ~/.oh-my-bash/custom/plugins/ # Example format: plugins=(rails git textmate ruby lighthouse) # Add wisely, as too many plugins slow down shell startup. plugins=( git bashmarks ) # Which plugins would you like to conditionally load? (plugins can be found in ~/.oh-my-bash/plugins/*) # Custom plugins may be added to ~/.oh-my-bash/custom/plugins/ # Example format: # if [ "$DISPLAY" ] || [ "$SSH" ]; then # plugins+=(tmux-autoattach) # fi # If you want to reduce the initialization cost of the "tput" command to # initialize color escape sequences, you can uncomment the following setting. # This disables the use of the "tput" command, and the escape sequences are # initialized to be the ANSI version: # #OMB_TERM_USE_TPUT=no source "$OSH"/oh-my-bash.sh # User configuration # export MANPATH="/usr/local/man:$MANPATH" # You may need to manually set your language environment # export LANG=en_US.UTF-8 # Preferred editor for local and remote sessions # if [[ -n $SSH_CONNECTION ]]; then # export EDITOR='vim' # else # export EDITOR='mvim' # fi # Compilation flags # export ARCHFLAGS="-arch x86_64" # ssh # export SSH_KEY_PATH="~/.ssh/rsa_id" # Set personal aliases, overriding those provided by oh-my-bash libs, # plugins, and themes. Aliases can be placed here, though oh-my-bash # users are encouraged to define aliases within the OSH_CUSTOM folder. # For a full list of active aliases, run `alias`. # # Example aliases # alias bashconfig="mate ~/.bashrc" # alias ohmybash="mate ~/.oh-my-bash" ================================================ FILE: themes/90210/90210.theme.sh ================================================ #! bash oh-my-bash.module SCM_THEME_PROMPT_DIRTY=" ${_omb_prompt_brown}✗" SCM_THEME_PROMPT_CLEAN=" ${_omb_prompt_bold_green}✓" SCM_THEME_PROMPT_PREFIX=" |" SCM_THEME_PROMPT_SUFFIX="${_omb_prompt_green}|" GIT_THEME_PROMPT_DIRTY=" ${_omb_prompt_brown}✗" GIT_THEME_PROMPT_CLEAN=" ${_omb_prompt_bold_green}✓" GIT_THEME_PROMPT_PREFIX=" ${_omb_prompt_green}|" GIT_THEME_PROMPT_SUFFIX="${_omb_prompt_green}|" OMB_PROMPT_SHOW_PYTHON_VENV=${OMB_PROMPT_SHOW_PYTHON_VENV:=false} # Nicely formatted terminal prompt function _omb_theme_PROMPT_COMMAND(){ local python_venv _omb_prompt_get_python_venv PS1="\n${_omb_prompt_bold_gray}[${_omb_prompt_navy}\@${_omb_prompt_bold_gray}]-" PS1+="${_omb_prompt_bold_gray}[${_omb_prompt_green}\u${_omb_prompt_olive}@${_omb_prompt_green}\h${_omb_prompt_bold_gray}]-" PS1+="${_omb_prompt_bold_gray}[${_omb_prompt_purple}\w${_omb_prompt_bold_gray}]-${python_venv}" PS1+="$(scm_prompt_info)\n${_omb_prompt_reset_color}\$ " } _omb_util_add_prompt_command _omb_theme_PROMPT_COMMAND ================================================ FILE: themes/90210/README.md ================================================ # 90210 💜 ![theme 90210](90210-dark.png) - **Brown**: Used to indicate a dirty state in source control management (SCM) and Git prompts. - **Bold Green**: Signifies a clean state in SCM and Git prompts. - **Green**: Used as a prefix and suffix in SCM and Git prompts. - **Bold Gray**: Forms the main structure of the prompt, displaying time, user, host, and current working directory. - **Navy**: Represents the time in the prompt. - **Green (again)**: Denotes the user and host in the prompt. - **Olive**: Marks the separation between the username and hostname. - **Purple**: Indicates the current working directory in the prompt. These colors help provide visual clues about the status of the source control repository and organize information effectively within the terminal prompt. ================================================ FILE: themes/THEMES.md ================================================ ## `90210` [![](90210/90210-dark.png)](90210/90210-dark.png) ## `ab+simple` [![](absimple/absimple-bash.png)](absimple/absimple-bash.png) ## `agnoster` [![](agnoster/agnoster-bash-sshot.png)](agnoster/agnoster-bash-sshot.png) [![](agnoster/agnoster-dark.png)](agnoster/agnoster-dark.png) ## `axin` [![](axin/axin-dark.png)](axin/axin-dark.png) ## `bakke` [![](bakke/bakke-dark.png)](bakke/bakke-dark.png) ## `binaryanomaly` [![](binaryanomaly/binaryanomaly-dark.png)](binaryanomaly/binaryanomaly-dark.png) ## `bobby` [![](bobby/bobby-dark.png)](bobby/bobby-dark.png) ## `bobby-python` [![](bobby-python/bobby-python-dark.png)](bobby-python/bobby-python-dark.png) ## `brainy` [![](brainy/brainy-dark.png)](brainy/brainy-dark.png) ## `brunton` [![](brunton/brunton-dark.png)](brunton/brunton-dark.png) ## `candy` [![](candy/candy-dark.png)](candy/candy-dark.png) ## `clean` [![](clean/clean-dark.png)](clean/clean-dark.png) ## `cooperkid` [![](cooperkid/cooperkid-dark.png)](cooperkid/cooperkid-dark.png) ## `copied-duru` [![](copied-duru/copied-duru-dark.png)](copied-duru/copied-duru-dark.png) ## `cupcake` [![](cupcake/cupcake-dark.png)](cupcake/cupcake-dark.png) ## `demula` [![](demula/demula-dark.png)](demula/demula-dark.png) ## `developer` [![](developer/developer_theme_2024_02_09.png)](developer/developer_theme_2024_02_09.png) ## `dos` [![](dos/dos-dark.png)](dos/dos-dark.png) ## `doubletime` [![](doubletime/doubletime-dark.png)](doubletime/doubletime-dark.png) ## `doubletime_multiline` [![](doubletime_multiline/doubletime_multiline-dark.png)](doubletime_multiline/doubletime_multiline-dark.png) ## `doubletime_multiline_pyonly` [![](doubletime_multiline_pyonly/doubletime_multiline_pyonly-dark.png)](doubletime_multiline_pyonly/doubletime_multiline_pyonly-dark.png) ## `dulcie` [![](dulcie/dulcie-dark.png)](dulcie/dulcie-dark.png) ## `duru` [![](duru/duru-dark.png)](duru/duru-dark.png) ## `edsonarios` [![](edsonarios/edsonarios-dark.png)](edsonarios/edsonarios-dark.png) ## `emperor` [![](emperor/emperor-dark.png)](emperor/emperor-dark.png) ## `envy` [![](envy/envy-dark.png)](envy/envy-dark.png) ## `font` [![](font/font-dark.png)](font/font-dark.png) ## `gallifrey` [![](gallifrey/gallifrey-dark.png)](gallifrey/gallifrey-dark.png) ## `half-life` [![](half-life/half-life.theme.png)](half-life/half-life.theme.png) ## `hawaii50` [![](hawaii50/hawaii50-dark.png)](hawaii50/hawaii50-dark.png) ## `ht` [![](ht/ht-dark.png)](ht/ht-dark.png) ## `iterate` [![](iterate/iterate-dark.png)](iterate/iterate-dark.png) ## `kitsune` [![](kitsune/kitsune-dark.png)](kitsune/kitsune-dark.png) ## `lambda` [![](lambda/lambda-dark.png)](lambda/lambda-dark.png) ## `luan` [![](luan/luan-dark.png)](luan/luan-dark.png) ## `lucky` [![](lucky/lucky-dark.png)](lucky/lucky-dark.png) ## `mairan` [![](mairan/mairan-dark.png)](mairan/mairan-dark.png) ## `mbriggs` [![](mbriggs/mbriggs-dark.png)](mbriggs/mbriggs-dark.png) ## `minimal` [![](minimal/minimal-dark.png)](minimal/minimal-dark.png) ## `minimal-gh` [![](minimal-gh/minimal-gh-dark.png)](minimal-gh/minimal-gh-dark.png) ## `modern` [![](modern/modern-dark.png)](modern/modern-dark.png) ## `modern-t` [![](modern-t/modern-t-dark.png)](modern-t/modern-t-dark.png) ## `morris` [![](morris/morris-dark.png)](morris/morris-dark.png) ## `n0qorg` [![](n0qorg/n0qorg-dark.png)](n0qorg/n0qorg-dark.png) ## `nekolight` [![](nekolight/nekolight-dark.jpg)](nekolight/nekolight-dark.jpg) ## `nekonight` [![](nekonight/nekonight-dark.jpg)](nekonight/nekonight-dark.jpg) ## `nekonight_moon` [![](nekonight_moon/nekonight_moon-dark.jpg)](nekonight_moon/nekonight_moon-dark.jpg) ## `nwinkler` [![](nwinkler/nwinkler-dark.png)](nwinkler/nwinkler-dark.png) ## `nwinkler_random_colors` [![](nwinkler_random_colors/screenshot.png)](nwinkler_random_colors/screenshot.png) [![](nwinkler_random_colors/nwinkler_random_colors-dark.png)](nwinkler_random_colors/nwinkler_random_colors-dark.png) ## `pete` [![](pete/pete-dark.png)](pete/pete-dark.png) ## `powerbash10k` [![](powerbash10k/powerbash10k-dark.png)](powerbash10k/powerbash10k-dark.png) ## `powerline` [![](powerline/powerline-dark.png)](powerline/powerline-dark.png) ## `powerline-icon` [![](powerline-icon/powerline-icon-dark.png)](powerline-icon/powerline-icon-dark.png) ## `powerline-light` [![](powerline-light/powerline-light.png)](powerline-light/powerline-light.png) ## `powerline-multiline` [![](powerline-multiline/powerline-multiline-dark.png)](powerline-multiline/powerline-multiline-dark.png) ## `powerline-naked` [![](powerline-naked/powerline-naked-dark.png)](powerline-naked/powerline-naked-dark.png) ## `powerline-plain` [![](powerline-plain/powerline-plain-dark.png)](powerline-plain/powerline-plain-dark.png) ## `powerline-wizard` [![](powerline-wizard/powerline-wizard-dark.png)](powerline-wizard/powerline-wizard-dark.png) ## `primer` [![](primer/primer-dark.png)](primer/primer-dark.png) ## `pro` [![](pro/pro-dark.png)](pro/pro-dark.png) ## `pure` [![](pure/pure-dark.png)](pure/pure-dark.png) ## `purity` [![](purity/purity-dark.png)](purity/purity-dark.png) ## `pzq` [![](pzq/pzq-dark.png)](pzq/pzq-dark.png) ## `rainbowbrite` [![](rainbowbrite/rainbowbrite-dark.png)](rainbowbrite/rainbowbrite-dark.png) ## `rana` [![](rana/rana-dark.png)](rana/rana-dark.png) ## `rjorgenson` [![](rjorgenson/rjorgenson-dark.png)](rjorgenson/rjorgenson-dark.png) ## `robbyrussell` [![](robbyrussell/robbyrussell-dark.png)](robbyrussell/robbyrussell-dark.png) ## `roderik` [![](roderik/roderik-dark.png)](roderik/roderik-dark.png) ## `rr` [![](rr/rr-dark.png)](rr/rr-dark.png) ## `sexy` [![](sexy/sexy-dark.png)](sexy/sexy-dark.png) ## `simple` [![](simple/simple-dark.png)](simple/simple-dark.png) ## `sirup` [![](sirup/sirup-dark.png)](sirup/sirup-dark.png) ## `slick` [![](slick/slick-dark.png)](slick/slick-dark.png) ## `standard` [![](standard/standard-dark.png)](standard/standard-dark.png) ## `tonka` [![](tonka/tonka-dark.png)](tonka/tonka-dark.png) ## `tonotdo` [![](tonotdo/tonotdo-dark.png)](tonotdo/tonotdo-dark.png) ## `tylenol` [![](tylenol/tylenol-dark.png)](tylenol/tylenol-dark.png) ## `vscode` [![](vscode/vscode-dark.png)](vscode/vscode-dark.png) ## `wanelo` [![](wanelo/wanelo-dark.png)](wanelo/wanelo-dark.png) ## `zitron` [![](zitron/zitron-dark.png)](zitron/zitron-dark.png) ## `zork` [![](zork/zork-dark.png)](zork/zork-dark.png) ================================================ FILE: themes/absimple/README.md ================================================ # ab+simple theme This theme needs a Powerline-patched font to be rendered correctly. The original author of the theme recommends https://github.com/adi1090x/termux-style This is a colorful theme based on the agnoster theme, made shorter and simpler. The aim of this theme is to only show you relevant information: The git information will only be shown in a git working directory. Similarly, everything will be displayed automatically when appropriate, including the current user and the hostname, whether the last call exited with an error, and whether background jobs are running in this shell. ![bash screenshot](absimple-bash.png) ================================================ FILE: themes/absimple/absimple.theme.sh ================================================ #!/usr/bin/env bash # vim: ft=bash ts=2 sw=2 sts=2 # # absimple theme: a fork of the agnoster theme # # Tested on Termux in Android 2022-02-15 # # The aim of this theme is to only show you relevant information: The # git information will only be shown in a git working directory. # Similarly, everything will be displayed automatically when # appropriate, including the current user and the hostname, whether # the last call exited with an error, and whether background jobs are # running in this shell. # Note: a most part of this theme is the same as "agnoster", so let us source # the original theme "agnoster" and just override its functions. In this way, # the maintenance becomes easier. source "$OSH/themes/agnoster/agnoster.theme.sh" ###################################################################### ### Segment drawing # A few utility functions to make it easy and re-usable to draw segmented prompts # prints history followed by HH:MM, useful for remembering what # we did previously function prompt_histdt { prompt_segment black default "\!" # \A" } # Dir: current working directory function prompt_dir { prompt_segment blue black '\W' } ###################################################################### # quick right prompt I grabbed to test things. function __command_rprompt { local times= n=$COLUMNS tz for tz in ZRH:Europe/Zurich PIT:US/Eastern \ MTV:US/Pacific TOK:Asia/Tokyo; do ((n > 40)) || break times="$times ${tz%%:*}\e[30;1m:\e[0;36;1m" times="$times$(TZ=${tz#*:} date +%H:%M:%S)\e[0m" n=$((n - 10)) done [[ ! $times ]] || printf '%*s%s\r' "$n" '' "$times" } ###################################################################### ## Main prompt function build_prompt { [[ ! -z ${AG_EMACS_DIR+x} ]] && prompt_emacsdir prompt_status [[ -z ${AG_NO_HIST+x} ]] && prompt_histdt #[[ -z ${AG_NO_CONTEXT+x} ]] && prompt_context if [[ ${OMB_PROMPT_SHOW_PYTHON_VENV-} ]]; then prompt_virtualenv prompt_condaenv fi prompt_dir prompt_git prompt_end } # from orig... # export PS1='$(ansi_single $(text_effect reset)) $(build_prompt) ' # this doesn't work... new model: create a prompt via a PR variable and # use that. function _omb_theme_PROMPT_COMMAND { local RETVAL=$? local PRIGHT="" local CURRENT_BG=NONE local REPLY _omb_theme_agnoster_text_effect reset _omb_theme_agnoster_ansi_single "$REPLY" local PR=$REPLY build_prompt PS1="" # date randomly or once per hour if (( $(shuf -i 1-20 -n 1 --random-source=/dev/urandom) == 1 )) ; then #TK || (($PSDATE != $(date +%H))) ; then PS1+="\$(date +%a) $(date +%Y-%m-%d) " fi PSDATE=$(date +%H) # ... and time PS1+="$(date +%H:%M:%S) " # uncomment below to use right prompt # PS1='\[$(tput sc; printf "%*s" $COLUMNS "$PRIGHT"; tput rc)\]'$PR PS1+=$PR } _omb_util_add_prompt_command _omb_theme_PROMPT_COMMAND ================================================ FILE: themes/agnoster/README.md ================================================ # agnoster In order for this theme to render correctly, you will need a [Powerline-patched font](https://gist.github.com/1595572). I recommend: https://github.com/powerline/fonts.git ``` git clone https://github.com/powerline/fonts.git fonts cd fonts sh install.sh ``` The aim of this theme is to only show you *relevant* information. Like most prompts, it will only show git information when in a git working directory. However, it goes a step further: everything from the current user and hostname to whether the last call exited with an error to whether background jobs are running in this shell will all be displayed automatically when appropriate. Generally speaking, this script has limited support for right prompts (ala powerlevel9k on zsh), but it's pretty problematic in Bash. The general pattern is to write out the right prompt, hit \r, then write the left. This is problematic for the following reasons: - Doesn't properly resize dynamically when you resize the terminal - Changes to the prompt (like clearing and re-typing, super common) deletes the prompt - Getting the right alignment via columns / tput cols is pretty problematic (and is a bug in this version) - Bash prompt escapes (like \h or \w) don't get interpolated all in all, if you really, really want right-side prompts without a ton of work, recommend going to zsh for now. If you know how to fix this, would appreciate it! ![ScreenShot](agnoster-bash-sshot.png) The direct upstream of the theme is [agnoster-bash](https://github.com/speedenator/agnoster-bash). The current base is [`1165d1b3`](https://github.com/speedenator/agnoster-bash/commit/1165d1b3f125f52e7d4df953166d3c62774638fc). New updates in the upstream can be found [here](https://github.com/speedenator/agnoster-bash/compare/1165d1b3f125f52e7d4df953166d3c62774638fc...master). ================================================ FILE: themes/agnoster/agnoster.theme.sh ================================================ #! bash oh-my-bash.module #------------------------------------------------------------------------------ # MIT License # # Copyright (c) 2012-2014 Isaac Wolkerstorfer (@agnoster) and contributors. # Copyright (c) 2014 Kenny Root (@kruton). # Copyright (c) 2017-2021 Erik Selberg and contributors (https://github.com/speedenator/agnoster-bash/contributors). # Copyright (c) 2019-present Toan Nguyen and contributors (https://github.com/ohmybash/oh-my-bash/graphs/contributors). # # 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. # # # Remarks: # # * Copyright 2012-2014 Isaac Wolkerstorfer (@agnoster) and contributors. # # The agnoster theme originates from @agnoster's Zsh theme [1]. The version # in OMB can be traced back to [1] (updates were stopped in 2014), but the # latest version of the Zsh theme is found in [2]. # # [1] https://gist.github.com/agnoster/3712874 # [2] https://github.com/agnoster/agnoster-zsh-theme # # The original theme does not seem to specify the license, so strictly # speaking, we are not explicitly allowed to modify and redistribute the # agnoster theme. The MIT license is proposed [3], but no action has appeard # to that. # # [3] https://github.com/agnoster/agnoster-zsh-theme/pull/152 # # * Copyright 2014 Kenny Root (@kruton) # # Then the theme was translated to Bash by @kruton [4]. The license does not # seem to be specified again. # # [4] https://gist.github.com/kruton/8345450 # # * Copyright 2017-2021 Erik Selberg (@speedenator) # # Then @speedenator has updated the theme by @kruton [5]. # # [5] https://github.com/speedenator/agnoster-bash # # At this time, the MIT license is specified. However, @speedenator seem to # claim the copyright for the work from 2012, which is actually the copyright # infringement. The user @speedenator seems to have started to contribute # only from 2017. # # * Copyright 2019-present Toan Nguyen (@nntoan) and contributors. # # The theme is imported into OMB by PR #54 [6]. # # [6] https://github.com/ohmybash/oh-my-bash/pull/54. # #------------------------------------------------------------------------------ # vim: ft=bash ts=2 sw=2 sts=2 # # agnoster's Theme - https://gist.github.com/3712874 # A Powerline-inspired theme for BASH # # (Converted from ZSH theme by Kenny Root) # https://gist.github.com/kruton/8345450 # # Updated & fixed by Erik Selberg erik@selberg.org 1/14/17 # Tested on MacOSX, Ubuntu, Amazon Linux # Bash v3 and v4 # # # README # # In order for this theme to render correctly, you will need a # [Powerline-patched font](https://gist.github.com/1595572). # I recommend: https://github.com/powerline/fonts.git # > git clone https://github.com/powerline/fonts.git fonts # > cd fonts # > install.sh # In addition, I recommend the # [Solarized theme](https://github.com/altercation/solarized/) and, if you're # using it on Mac OS X, [iTerm 2](http://www.iterm2.com/) over Terminal.app - # it has significantly better color fidelity. # Install: # I recommend the following: # $ cd home # $ mkdir -p .bash/themes/agnoster-bash # $ git clone https://github.com/speedenator/agnoster-bash.git .bash/themes/agnoster-bash # then add the following to your .bashrc: # export THEME=$HOME/.bash/themes/agnoster-bash/agnoster.bash # if [[ -f $THEME ]]; then # export DEFAULT_USER=$(whoami) # source "$THEME" # fi # # # Goals # # The aim of this theme is to only show you *relevant* information. Like most # prompts, it will only show git information when in a git working directory. # However, it goes a step further: everything from the current user and # hostname to whether the last call exited with an error to whether background # jobs are running in this shell will all be displayed automatically when # appropriate. # Generally speaking, this script has limited support for right # prompts (ala powerlevel9k on zsh), but it's pretty problematic in Bash. # The general pattern is to write out the right prompt, hit \r, then # write the left. This is problematic for the following reasons: # - Doesn't properly resize dynamically when you resize the terminal # - Changes to the prompt (like clearing and re-typing, super common) deletes the prompt # - Getting the right alignment via columns / tput cols is pretty problematic (and is a bug in this version) # - Bash prompt escapes (like \h or \w) don't get interpolated # # all in all, if you really, really want right-side prompts without a # ton of work, recommend going to zsh for now. If you know how to fix this, # would appreciate it! # note: requires bash v4+... Mac users - you often have bash3. # 'brew install bash' will set you free PROMPT_DIRTRIM=${PROMPT_DIRTRIM:-2} # bash4 and above ###################################################################### ## Configurations in Oh My Bash OMB_PROMPT_SHOW_PYTHON_VENV=${OMB_PROMPT_SHOW_PYTHON_VENV:=true} ###################################################################### DEBUG=0 function debug { if [[ ${DEBUG} -ne 0 ]]; then >&2 echo -e "$@" fi } ###################################################################### ### Segment drawing # A few utility functions to make it easy and re-usable to draw segmented prompts CURRENT_BG='NONE' CURRENT_RBG='NONE' SEGMENT_SEPARATOR='' RIGHT_SEPARATOR='' LEFT_SUBSEG='' RIGHT_SUBSEG='' function _omb_theme_agnoster_text_effect { REPLY= case $1 in reset) REPLY=0 ;; bold) REPLY=1 ;; underline) REPLY=4 ;; esac } # to add colors, see # http://bitmote.com/index.php?post/2012/11/19/Using-ANSI-Color-Codes-to-Colorize-Your-Bash-Prompt-on-Linux # under the "256 (8-bit) Colors" section, and follow the example for orange below function _omb_theme_agnoster_fg_color { REPLY= case $1 in black) REPLY=30 ;; red) REPLY=31 ;; green) REPLY=32 ;; yellow) REPLY=33 ;; blue) REPLY=34 ;; magenta) REPLY=35 ;; cyan) REPLY=36 ;; white) REPLY=37 ;; orange) REPLY='38;5;166' ;; esac } function _omb_theme_agnoster_bg_color { REPLY= case $1 in black) REPLY=40 ;; red) REPLY=41 ;; green) REPLY=42 ;; yellow) REPLY=43 ;; blue) REPLY=44 ;; magenta) REPLY=45 ;; cyan) REPLY=46 ;; white) REPLY=47 ;; orange) REPLY='48;5;166' ;; esac } # TIL: declare is global not local, so best use a different name # for codes (mycodes) as otherwise it'll clobber the original. # this changes from BASH v3 to BASH v4. function _omb_theme_agnoster_ansi_r { # this doesn't wrap code in \[ \] local seq local -a mycodes=("${!1}") debug "ansi: ${!1} all: $* aka ${mycodes[@]}" seq="" local i for ((i = 0; i < ${#mycodes[@]}; i++)); do if [[ $seq ]]; then seq=$seq';' fi seq=$seq${mycodes[i]} done debug 'ansi debug: \\[\\033['"$seq"'m\\]' REPLY='\e['$seq'm' } function _omb_theme_agnoster_ansi { _omb_theme_agnoster_ansi_r "$@" REPLY='\['$REPLY'\]' # PR=$PR'\['$REPLY'\]' } function _omb_theme_agnoster_ansi_single { REPLY='\[\e['$1'm\]' } _omb_deprecate_defun_print 20000 text_effect _omb_theme_agnoster_text_effect _omb_deprecate_defun_print 20000 fg_color _omb_theme_agnoster_fg_color _omb_deprecate_defun_print 20000 bg_color _omb_theme_agnoster_bg_color _omb_deprecate_defun_put 20000 ansi _omb_theme_agnoster_ansi _omb_deprecate_defun_put 20000 ansi_r _omb_theme_agnoster_ansi_r _omb_deprecate_defun_put 20000 ansi_single _omb_theme_agnoster_ansi_single # Begin a segment # Takes two arguments, background and foreground. Both can be omitted, # rendering default background/foreground. function prompt_segment { local REPLY local -a codes debug "Prompting $1 $2 $3" # > if commented out from kruton's original... I'm not clear if it did # > anything, but it messed up things like prompt_status - Erik 1/14/17 # # I think ( -z $2 && $2 != default ) has been a mistake of ( $2 && $2 != # default ) because ( -z $2 && $2 != default ) is equivalent to ( -z $2 ). I # fixed it, so we may turn this on again, but I keep it inside the comment # because I'm not sure if there is any other side effect - Koichi 4/27/25 # # See also the same code in the function "prompt_right_segment". # # if [[ ! $1 || ( $2 && $2 != default ) ]]; then _omb_theme_agnoster_text_effect reset [[ $REPLY ]] && codes+=("$REPLY") # fi if [[ $1 ]]; then _omb_theme_agnoster_bg_color "$1" [[ $REPLY ]] && codes+=("$REPLY") debug "Added $REPLY as background to codes" fi if [[ $2 ]]; then _omb_theme_agnoster_fg_color "$2" [[ $REPLY ]] && codes+=("$REPLY") debug "Added $REPLY as foreground to codes" fi debug "Codes: " # local -p codes if [[ $CURRENT_BG != NONE && $1 != $CURRENT_BG ]]; then local -a intermediate=() _omb_theme_agnoster_fg_color "$CURRENT_BG" [[ $REPLY ]] && intermediate+=("$REPLY") _omb_theme_agnoster_bg_color "$1" [[ $REPLY ]] && intermediate+=("$REPLY") _omb_theme_agnoster_ansi 'intermediate[@]' debug "pre prompt $REPLY" PR="$PR $REPLY$SEGMENT_SEPARATOR" _omb_theme_agnoster_ansi 'codes[@]' debug "post prompt $REPLY" PR="$PR$REPLY " else debug "no current BG, codes are (${codes[*]})" _omb_theme_agnoster_ansi 'codes[@]' PR="$PR$REPLY " fi CURRENT_BG=$1 [[ $3 ]] && PR=$PR$3 } # End the prompt, closing any open segments function prompt_end { local REPLY if [[ $CURRENT_BG ]]; then local -a codes=() _omb_theme_agnoster_text_effect reset [[ $REPLY ]] && codes+=("$REPLY") _omb_theme_agnoster_fg_color "$CURRENT_BG" [[ $REPLY ]] && codes+=("$REPLY") _omb_theme_agnoster_ansi 'codes[@]' PR="$PR $REPLY$SEGMENT_SEPARATOR" fi _omb_theme_agnoster_text_effect reset local -a reset=(${REPLY:+"$REPLY"}) _omb_theme_agnoster_ansi 'reset[@]' PR="$PR $REPLY" CURRENT_BG='' } ### virtualenv prompt function prompt_virtualenv { # Exclude pyenv [[ $PYENV_VIRTUALENV_INIT == 1 ]] && _omb_util_binary_exists pyenv && return 0 if [[ -d $VIRTUAL_ENV ]]; then # Python could output the version information in both stdout and # stderr (e.g. if using pyenv, the output goes to stderr). local VERSION_OUTPUT=$("$VIRTUAL_ENV"/bin/python --version 2>&1) # The last word of the output of `python --version` # corresponds to the version number. local VENV_VERSION=$(awk '{print $NF}' <<< "$VERSION_OUTPUT") prompt_segment cyan white "[v] ${VIRTUAL_ENV_PROMPT:+$VIRTUAL_ENV_PROMPT }$(basename "$VENV_VERSION")" fi } ### pyenv prompt function prompt_pyenv { if [[ $PYENV_VIRTUALENV_INIT == 1 ]] && _omb_util_binary_exists pyenv; then # Priority is shell > local > global # When pyenv shell is set, the environment variable $PYENV_VERSION is set with the value we want if [[ ! ${PYENV_VERSION-} ]]; then # If not set, fall back to pyenv local/global to get the version local PYENV_VERSION=$(pyenv local 2>/dev/null || pyenv global 2>/dev/null) fi # If it is not the system's python, then display additional info if [[ "$PYENV_VERSION" != "system" ]]; then # It's a pyenv virtualenv, get the version number if [[ -d $PYENV_VIRTUAL_ENV ]]; then local VERSION_OUTPUT=$("$PYENV_VIRTUAL_ENV"/bin/python --version 2>&1) local PYENV_VENV_VERSION=$(awk '{print $NF}' <<< "$VERSION_OUTPUT") prompt_segment cyan white "[$PYENV_VERSION] $(basename "$PYENV_VENV_VERSION")" else prompt_segment cyan white "$PYENV_VERSION" fi fi fi } ### conda env prompt function prompt_condaenv { if [[ -d $CONDA_PREFIX ]]; then if [[ ! $CONDA_PROMPT_MODIFIER ]]; then CONDA_PROMPT_MODIFIER=$(basename "$CONDA_PREFIX") fi local CONDA_PYTHON_VERSION=$("$CONDA_PREFIX"/bin/python -c 'import platform;print(platform.python_version())') prompt_segment cyan white "[c] $CONDA_PROMPT_MODIFIER $CONDA_PYTHON_VERSION" fi } ### Prompt components # Each component will draw itself, and hide itself if no information needs to be shown # Context: user@hostname (who am I and where am I) function prompt_context { local user=$(whoami) if [[ $user != $DEFAULT_USER || -n $SSH_CLIENT ]]; then prompt_segment black default "$user@\h" fi } # prints history followed by HH:MM, useful for remembering what # we did previously function prompt_histdt { prompt_segment black default "\! [\A]" } function git_status_dirty { dirty=$(_omb_prompt_git status -s 2> /dev/null | tail -n 1) [[ $dirty ]] && _omb_util_print " ●" } function git_stash_dirty { stash=$(_omb_prompt_git stash list 2> /dev/null | tail -n 1) [[ $stash ]] && _omb_util_print " ⚑" } # Git: branch/detached head, dirty status function prompt_git { local ref dirty if _omb_prompt_git rev-parse --is-inside-work-tree &>/dev/null; then ZSH_THEME_GIT_PROMPT_DIRTY='±' dirty=$(git_status_dirty) stash=$(git_stash_dirty) ref=$(_omb_prompt_git symbolic-ref HEAD 2> /dev/null) || ref="➦ $(_omb_prompt_git describe --exact-match --tags HEAD 2> /dev/null)" || ref="➦ $(_omb_prompt_git show-ref --head -s --abbrev | head -n1 2> /dev/null)" if [[ -n $dirty ]]; then prompt_segment yellow black else prompt_segment green black fi PR="$PR${ref/refs\/heads\// }$stash$dirty" fi } # Mercurial: clean, modified and uncomitted files function prompt_hg { local rev st branch if hg id &>/dev/null; then if hg prompt &>/dev/null; then if [[ $(hg prompt "{status|unknown}") == '?' ]]; then # if files are not added prompt_segment red white st='±' elif [[ $(hg prompt "{status|modified}") ]]; then # if any modification prompt_segment yellow black st='±' else # if working copy is clean prompt_segment green black $CURRENT_FG fi PR="$PR$(hg prompt "☿ {rev}@{branch}") $st" else st="" rev=$(hg id -n 2>/dev/null | sed 's/[^-0-9]//g') branch=$(hg id -b 2>/dev/null) if hg st | grep -q "^\?"; then prompt_segment red white st='±' elif hg st | grep -q "^[MA]"; then prompt_segment yellow black st='±' else prompt_segment green black $CURRENT_FG fi PR="$PR☿ $rev@$branch $st" fi fi } # Dir: current working directory function prompt_dir { prompt_segment blue black '\w' } # Status: # - was there an error # - am I root # - are there background jobs? function prompt_status { local symbols REPLY symbols=() if ((RETVAL != 0)); then _omb_theme_agnoster_fg_color red _omb_theme_agnoster_ansi_single "$REPLY" symbols+=$REPLY'✘' fi if ((UID == 0)); then _omb_theme_agnoster_fg_color yellow _omb_theme_agnoster_ansi_single "$REPLY" symbols+=$REPLY'⚡' fi if compgen -j &>/dev/null; then _omb_theme_agnoster_fg_color cyan _omb_theme_agnoster_ansi_single "$REPLY" symbols+=$REPLY'⚙' fi [[ $symbols ]] && prompt_segment black default "$symbols" } ###################################################################### # # experimental right prompt stuff # requires setting prompt_foo to use PRIGHT vs PR # doesn't quite work per above function rightprompt { printf "%*s" $COLUMNS "$PRIGHT" } # quick right prompt I grabbed to test things. function __command_rprompt { local times= n=$COLUMNS tz for tz in ZRH:Europe/Zurich PIT:US/Eastern \ MTV:US/Pacific TOK:Asia/Tokyo; do ((n > 40)) || break times="$times ${tz%%:*}\e[30;1m:\e[0;36;1m" times="$times$(TZ=${tz#*:} date +%H:%M)\e[0m" n=$((n - 10)) done [[ ! $times ]] || printf '%*s%s\r' "$n" '' "$times" } # Begin a segment on the right # Takes two arguments, background and foreground. Both can be omitted, # rendering default background/foreground. function prompt_right_segment { local REPLY local -a codes debug "Prompt right" debug "Prompting $1 $2 $3" # if [[ ! $1 || ( $2 && $2 != default ) ]]; then _omb_theme_agnoster_text_effect reset [[ $REPLY ]] && codes+=("$REPLY") # fi if [[ $1 ]]; then _omb_theme_agnoster_bg_color "$1" [[ $REPLY ]] && codes+=("$REPLY") debug "Added $REPLY as background to codes" fi if [[ $2 ]]; then _omb_theme_agnoster_fg_color "$2" [[ $REPLY ]] && codes+=("$REPLY") debug "Added $REPLY as foreground to codes" fi debug "Right Codes: " # local -p codes # right always has a separator # if [[ $CURRENT_RBG != NONE && $1 != $CURRENT_RBG ]]; then # $CURRENT_RBG= # fi local -a intermediate2=() _omb_theme_agnoster_fg_color "$1" [[ $REPLY ]] && intermediate2+=("$REPLY") _omb_theme_agnoster_bg_color "$CURRENT_RBG" [[ $REPLY ]] && intermediate2+=("$REPLY") # PRIGHT="$PRIGHT---" _omb_theme_agnoster_ansi_r 'intermediate2[@]' debug "pre prompt $REPLY" PRIGHT="$PRIGHT$REPLY$RIGHT_SEPARATOR" _omb_theme_agnoster_ansi_r 'codes[@]' debug "post prompt $REPLY" PRIGHT="$PRIGHT$REPLY " # else # debug "no current BG, codes are (${codes[*]})" # _omb_theme_agnoster_ansi 'codes[@]' # PRIGHT="$PRIGHT$REPLY " # fi CURRENT_RBG=$1 [[ $3 ]] && PRIGHT=$PRIGHT$3 } ###################################################################### ## Emacs prompt --- for dir tracking # stick the following in your .emacs if you use this: # (setq dirtrack-list '(".*DIR *\\([^ ]*\\) DIR" 1 nil)) # (defun dirtrack-filter-out-pwd-prompt (string) # "dirtrack-mode doesn't remove the PWD match from the prompt. This does." # ;; TODO: support dirtrack-mode's multiline regexp. # (if (and (stringp string) (string-match (first dirtrack-list) string)) # (replace-match "" t t string 0) # string)) # (add-hook 'shell-mode-hook # #'(lambda () # (dirtrack-mode 1) # (add-hook 'comint-preoutput-filter-functions # 'dirtrack-filter-out-pwd-prompt t t))) function prompt_emacsdir { # no color or other setting... this will be deleted per above PR="DIR \w DIR$PR" } ###################################################################### ## Main prompt function build_prompt { [[ ! -z ${AG_EMACS_DIR+x} ]] && prompt_emacsdir prompt_status #[[ -z ${AG_NO_HIST+x} ]] && prompt_histdt [[ -z ${AG_NO_CONTEXT+x} ]] && prompt_context if [[ ${OMB_PROMPT_SHOW_PYTHON_VENV-} ]]; then prompt_virtualenv prompt_pyenv prompt_condaenv fi prompt_dir prompt_git prompt_hg prompt_end } # from orig... # export PS1='$(ansi_single $(text_effect reset)) $(build_prompt) ' # this doesn't work... new model: create a prompt via a PR variable and # use that. function _omb_theme_PROMPT_COMMAND { local RETVAL=$? local PRIGHT="" local CURRENT_BG=NONE local REPLY _omb_theme_agnoster_text_effect reset _omb_theme_agnoster_ansi_single "$REPLY" local PR=$REPLY build_prompt # uncomment below to use right prompt # PS1='\[$(tput sc; printf "%*s" $COLUMNS "$PRIGHT"; tput rc)\]'$PR PS1=$PR } _omb_util_add_prompt_command _omb_theme_PROMPT_COMMAND ================================================ FILE: themes/axin/README.md ================================================ # Axin ![Theme Axin](axin-dark.png) Axin Bash Prompt, inspired by theme "Sexy" and "Bobby" ================================================ FILE: themes/axin/axin.theme.sh ================================================ #! bash oh-my-bash.module # Axin Bash Prompt, inspired by theme "Sexy" and "Bobby" # thanks to them if [[ $COLORTERM = gnome-* && $TERM = xterm ]] && infocmp gnome-256color &>/dev/null; then export TERM=gnome-256color elif [[ $TERM != dumb ]] && infocmp xterm-256color &>/dev/null; then export TERM=xterm-256color fi MAGENTA=$_omb_prompt_bold_red WHITE=$_omb_prompt_bold_silver ORANGE=$_omb_prompt_bold_olive GREEN=$_omb_prompt_bold_green PURPLE=$_omb_prompt_bold_purple RESET=$_omb_prompt_normal if ((_omb_term_colors >= 256)); then ORANGE=$_omb_prompt_bold'\['$(tput setaf 172)'\]' GREEN=$_omb_prompt_bold'\['$(tput setaf 190)'\]' PURPLE=$_omb_prompt_bold'\['$(tput setaf 141)'\]' fi OMB_PROMPT_VIRTUALENV_FORMAT='( %s ) ' OMB_PROMPT_CONDAENV_FORMAT='( %s ) ' OMB_PROMPT_CONDAENV_USE_BASENAME=true OMB_PROMPT_SHOW_PYTHON_VENV=${OMB_PROMPT_SHOW_PYTHON_VENV:=false} function _omb_theme_PROMPT_COMMAND() { local python_venv _omb_prompt_get_python_venv PS1="$python_venv${MAGENTA}\u ${WHITE}@ ${ORANGE}\h ${WHITE}in ${GREEN}\w${WHITE}$SCM_THEME_PROMPT_PREFIX$(clock_prompt) ${PURPLE}\$(scm_prompt_info) \n\$ ${RESET}" } THEME_CLOCK_COLOR=${THEME_CLOCK_COLOR:-"${_omb_prompt_white}"} _omb_util_add_prompt_command _omb_theme_PROMPT_COMMAND ================================================ FILE: themes/bakke/README.md ================================================ # Bakke ![theme Bakke](bakke-dark.png) - **Version Control State Indicators:** It uses brown to indicate a dirty state and bold green for a clean state in version control-related prompts such as Git. - **Prompt Prefix and Suffix:** It uses green as a prefix and suffix in version control-related prompts. - **Virtual Environments:** It displays information about Python virtual environments, such as virtualenv and condaenv, in parentheses and with specific colors. - **Main Prompt Structure:** It uses bold gray to form the main structure of the prompt, which includes the username, host, and current working directory. - **Additional Features:** It allows displaying additional information, such as the Ruby environment if present, and the use of RVM. Overall, this theme offers a pleasant and functional user experience when working in the terminal, with a focus on clarity and relevant information for the user. ================================================ FILE: themes/bakke/bakke.theme.sh ================================================ #! bash oh-my-bash.module SCM_THEME_PROMPT_DIRTY=" ${_omb_prompt_brown}✗" SCM_THEME_PROMPT_CLEAN=" ${_omb_prompt_bold_green}✓" SCM_THEME_PROMPT_PREFIX=" |" SCM_THEME_PROMPT_SUFFIX="${_omb_prompt_green}|" GIT_THEME_PROMPT_DIRTY=" ${_omb_prompt_brown}✗" GIT_THEME_PROMPT_CLEAN=" ${_omb_prompt_bold_green}✓" GIT_THEME_PROMPT_PREFIX=" ${_omb_prompt_green}|" GIT_THEME_PROMPT_SUFFIX="${_omb_prompt_green}|" RVM_THEME_PROMPT_PREFIX="|" RVM_THEME_PROMPT_SUFFIX="|" OMB_PROMPT_SHOW_PYTHON_VENV=${OMB_PROMPT_SHOW_PYTHON_VENV:-false} OMB_PROMPT_VIRTUALENV_FORMAT="${_omb_prompt_bold_gray}(%s)${_omb_prompt_reset_color}" OMB_PROMPT_CONDAENV_FORMAT="${_omb_prompt_bold_gray}(%s)${_omb_prompt_reset_color}" function _omb_theme_PROMPT_COMMAND() { #PS1="${_omb_prompt_bold_teal}$(scm_char)${_omb_prompt_green}$(scm_prompt_info)${_omb_prompt_purple}$(_omb_prompt_print_ruby_env) ${_omb_prompt_olive}\h ${_omb_prompt_reset_color}in ${_omb_prompt_green}\w ${_omb_prompt_reset_color}\n${_omb_prompt_green}→${_omb_prompt_reset_color} " #PS1="\n${_omb_prompt_purple}\h: ${_omb_prompt_reset_color} ${_omb_prompt_green}\w\n${_omb_prompt_bold_teal}$(scm_char)${_omb_prompt_green}$(scm_prompt_info) ${_omb_prompt_green}→${_omb_prompt_reset_color} " #PS1="\n${_omb_prompt_teal}\h: ${_omb_prompt_reset_color} ${_omb_prompt_olive}\w\n${_omb_prompt_brown}$(scm_char)${_omb_prompt_brown}$(scm_prompt_info) ${_omb_prompt_green}→${_omb_prompt_reset_color} " local python_venv _omb_prompt_get_python_venv PS1="\n${python_venv:+$python_venv }${_omb_prompt_teal}\h: ${_omb_prompt_reset_color} ${_omb_prompt_olive}\w ${_omb_prompt_green}$(scm_prompt_info)\n${_omb_prompt_reset_color}→ " } _omb_util_add_prompt_command _omb_theme_PROMPT_COMMAND ================================================ FILE: themes/binaryanomaly/README.md ================================================ # Binary Anomaly ![Binaryanomaly Theme](binaryanomaly-dark.png) - **Reboot Required Detection:** - If a system reboot is required, a warning message will be displayed in bright yellow, indicating "Reboot required!". - **Color Assignment:** - The color of the hostname changes based on the connection: - Lime green for remote sessions via SSH. - Light orange for local sessions. - The color of the username changes based on the user's status: - Brown for root users. - Teal green for regular users. - **Version Control Information:** - Git-related prompts display a dirty or clean state indicator: - Brown for dirty state. - Bold green for clean state. - The prefix and suffix of the version control are in light gray to highlight this information clearly in the prompt. ================================================ FILE: themes/binaryanomaly/binaryanomaly.theme.sh ================================================ #! bash oh-my-bash.module # Set term to 256color mode, if 256color is not supported, colors won't work properly if [[ $COLORTERM = gnome-* && $TERM = xterm ]] && infocmp gnome-256color >/dev/null 2>&1; then export TERM=gnome-256color elif infocmp xterm-256color >/dev/null 2>&1; then export TERM=xterm-256color fi # Detect whether a rebbot is required function show_reboot_required() { if [ ! -z "$_bf_prompt_reboot_info" ]; then if [ -f /var/run/reboot-required ]; then _omb_util_put "Reboot required!" fi fi } # Set different host color for local and remote sessions function set_host_color() { # Detect if connection is through SSH if [[ ! -z $SSH_CLIENT ]]; then _omb_util_put "${lime_yellow}" else _omb_util_put "${light_orange}" fi } # Set different username color for users and root function set_user_color() { case $(id -u) in 0) _omb_util_put "${_omb_prompt_brown}" ;; *) _omb_util_put "${_omb_prompt_teal}" ;; esac } function scm_prompt { CHAR=$(scm_char) if [ $CHAR = $SCM_NONE_CHAR ] then return else _omb_util_print "[$(scm_char)$(scm_prompt_info)]" fi } # Define custom colors we need # non-printable bytes in PS1 need to be contained within \[ \]. # Otherwise, bash will count them in the length of the prompt function set_custom_colors() { dark_grey="\[$(tput setaf 8)\]" light_grey="\[$(tput setaf 248)\]" light_orange="\[$(tput setaf 172)\]" bright_yellow="\[$(tput setaf 220)\]" lime_yellow="\[$(tput setaf 190)\]" powder_blue="\[$(tput setaf 153)\]" } function __ps_time { _omb_util_print "$(clock_prompt)${_omb_prompt_normal}\n" } function _omb_theme_PROMPT_COMMAND() { ps_reboot="${bright_yellow}$(show_reboot_required)${_omb_prompt_normal}\n" ps_username="$(set_user_color)\u${_omb_prompt_normal}" ps_uh_separator="${dark_grey}@${_omb_prompt_normal}" ps_hostname="$(set_host_color)\h${_omb_prompt_normal}" ps_path="${_omb_prompt_olive}\w${_omb_prompt_normal}" ps_scm_prompt="${light_grey}$(scm_prompt)" ps_user_mark="${_omb_prompt_normal} ${_omb_prompt_normal}" ps_user_input="${_omb_prompt_normal}" # Set prompt PS1="$ps_reboot$(__ps_time)$ps_username$ps_uh_separator$ps_hostname $ps_path $ps_scm_prompt$ps_user_mark$ps_user_input" } # Initialize custom colors set_custom_colors THEME_CLOCK_COLOR=${THEME_CLOCK_COLOR:-"$dark_grey"} # scm theming SCM_THEME_PROMPT_PREFIX="" SCM_THEME_PROMPT_SUFFIX="" SCM_THEME_PROMPT_DIRTY=" ${_omb_prompt_bold_brown}✗${light_grey}" SCM_THEME_PROMPT_CLEAN=" ${_omb_prompt_green}✓${light_grey}" SCM_GIT_CHAR="${_omb_prompt_green}±${light_grey}" SCM_SVN_CHAR="${_omb_prompt_bold_teal}⑆${light_grey}" SCM_HG_CHAR="${_omb_prompt_bold_brown}☿${light_grey}" _omb_util_add_prompt_command _omb_theme_PROMPT_COMMAND ================================================ FILE: themes/bobby/README.md ================================================ # Bobby ![theme Bobby](bobby-dark.png) ## Styles and Colors This repository presents a custom Bash prompt configuration utilizing various styles and colors to enhance the visual appearance and usability of the terminal. ## Color Assignments - **Brown**: Used to indicate a dirty state in source control management (SCM) and Git prompts. - **Bold Green**: Signifies a clean state in SCM and Git prompts. - **Green**: Used as a prefix and suffix in SCM and Git prompts. - **Olive**: Represents the current working directory in the prompt. - **Purple**: Denotes the hostname in the prompt. - **Teal**: Used to display version control information in SCM prompts. - **Light Gray**: Forms the main structure of the prompt, displaying time, user, host, and current working directory. - **Bright Yellow**: Indicates a warning message, such as a required system reboot. ## Styles and Functions - **SCM Themes**: Customized themes for source control management (SCM) prompts, displaying indicators for dirty and clean states. - **Clock Display**: Incorporates a clock function to show the current time in the prompt, with the option to display a clock character. - **Battery Status**: Includes a battery function to show battery status in the prompt. Feel free to customize the color assignments and styles according to your preferences by modifying the relevant sections in the Bash prompt configuration file. Adjust the colors, prompt structure, and additional functions to suit your needs. ================================================ FILE: themes/bobby/bobby.theme.sh ================================================ #! bash oh-my-bash.module SCM_THEME_PROMPT_DIRTY=" ${_omb_prompt_brown}✗" SCM_THEME_PROMPT_CLEAN=" ${_omb_prompt_bold_green}✓" SCM_THEME_PROMPT_PREFIX=" ${_omb_prompt_green}|" SCM_THEME_PROMPT_SUFFIX="${_omb_prompt_green}|" GIT_THEME_PROMPT_DIRTY=" ${_omb_prompt_brown}✗" GIT_THEME_PROMPT_CLEAN=" ${_omb_prompt_bold_green}✓" GIT_THEME_PROMPT_PREFIX=" ${_omb_prompt_green}|" GIT_THEME_PROMPT_SUFFIX="${_omb_prompt_green}|" RVM_THEME_PROMPT_PREFIX="|" RVM_THEME_PROMPT_SUFFIX="|" function __bobby_clock { _omb_util_put "$(clock_prompt) " if [ "${THEME_SHOW_CLOCK_CHAR}" == "true" ]; then _omb_util_put "$(clock_char) " fi } function _omb_theme_PROMPT_COMMAND() { #PS1="${_omb_prompt_bold_teal}$(scm_char)${_omb_prompt_green}$(scm_prompt_info)${_omb_prompt_purple}$(_omb_prompt_print_ruby_env) ${_omb_prompt_olive}\h ${_omb_prompt_reset_color}in ${_omb_prompt_green}\w ${_omb_prompt_reset_color}\n${_omb_prompt_green}→${_omb_prompt_reset_color} " PS1="\n$(battery_char) $(__bobby_clock)${_omb_prompt_olive}$(_omb_prompt_print_ruby_env) ${_omb_prompt_purple}\h ${_omb_prompt_reset_color}in ${_omb_prompt_green}\w\n${_omb_prompt_bold_teal}$(scm_prompt_char_info) ${_omb_prompt_green}→${_omb_prompt_reset_color} " } THEME_SHOW_CLOCK_CHAR=${THEME_SHOW_CLOCK_CHAR:-"true"} THEME_CLOCK_CHAR_COLOR=${THEME_CLOCK_CHAR_COLOR:-"$_omb_prompt_brown"} THEME_CLOCK_COLOR=${THEME_CLOCK_COLOR:-"$_omb_prompt_bold_teal"} THEME_CLOCK_FORMAT=${THEME_CLOCK_FORMAT:-"%Y-%m-%d %H:%M:%S"} _omb_util_add_prompt_command _omb_theme_PROMPT_COMMAND ================================================ FILE: themes/bobby-python/bobby-python.theme.sh ================================================ #! bash oh-my-bash.module SCM_THEME_PROMPT_DIRTY=" ${_omb_prompt_brown}✗" SCM_THEME_PROMPT_CLEAN=" ${_omb_prompt_bold_green}✓" SCM_THEME_PROMPT_PREFIX=" |" SCM_THEME_PROMPT_SUFFIX="${_omb_prompt_green}|" GIT_THEME_PROMPT_DIRTY=" ${_omb_prompt_brown}✗" GIT_THEME_PROMPT_CLEAN=" ${_omb_prompt_bold_green}✓" GIT_THEME_PROMPT_PREFIX=" ${_omb_prompt_green}|" GIT_THEME_PROMPT_SUFFIX="${_omb_prompt_green}|" CONDAENV_THEME_PROMPT_SUFFIX="|" function _omb_theme_PROMPT_COMMAND() { #PS1="${_omb_prompt_bold_teal}$(scm_char)${_omb_prompt_green}$(scm_prompt_info)${_omb_prompt_purple}$(_omb_prompt_print_ruby_env) ${_omb_prompt_olive}\h ${_omb_prompt_reset_color}in ${_omb_prompt_green}\w ${_omb_prompt_reset_color}\n${_omb_prompt_green}→${_omb_prompt_reset_color} " PS1="\n${_omb_prompt_olive}$(python_version_prompt) ${_omb_prompt_purple}\h ${_omb_prompt_reset_color}in ${_omb_prompt_green}\w\n${_omb_prompt_bold_teal}$(scm_char)${_omb_prompt_green}$(scm_prompt_info) ${_omb_prompt_green}→${_omb_prompt_reset_color} " } _omb_util_add_prompt_command _omb_theme_PROMPT_COMMAND ================================================ FILE: themes/brainy/README.md ================================================ # Brainy theme Simple colorful terminal prompt theme (inspired by a number of themes). ## Features ### Prompt Segments - Username & Hostname - Current Directory - SCM Information - Battery Charge - Clock - [Todo.txt](https://github.com/ginatrapani/todo.txt-cli) status - Ruby Environment - Python Environment - Exit Code ### Others - Indicator for cached `sudo` credential - Indicator for ssh login - `brainy` command for showing/hiding various prompt segments on-the-fly ## Configuration Various prompt segments can be shown/hidden or modified according to your choice. There are two ways for doing that: 1. On-the-fly using `brainy` command 2. Theme Environment Variables ### On-the-fly using `brainy` command This theme provides a command for showing/hiding prompt segments. `brainy show ` `brainy hide ` Tab-completion for this command is enabled by default. Configuration specified by this command will only be applied to current and subsequent child shells. ### Theme Environment Variables This is used for permanent settings that apply to all terminal sessions. You have to define the value of specific theme variables in your `bashrc` (or equivalent) file. The name of the variables are listed below along with their default values. #### User Information Indicator for cached `sudo` credential (see `sudo` manpage for more information): `THEME_SHOW_SUDO=true` #### SCM Information Information about SCM repository status: `THEME_SHOW_SCM=true` #### Ruby Environment Ruby environment version information: `THEME_SHOW_RUBY=false` #### Python Environment Python version and virtual environment information: `THEME_SHOW_PYTHON=false` #### ToDo.txt status [Todo.txt](https://github.com/ginatrapani/todo.txt-cli) status: `THEME_SHOW_TODO=false` #### Clock `THEME_SHOW_CLOCK=true` `THEME_CLOCK_COLOR=$bold_cyan` Format of the clock (see `date` manpage for more information): `THEME_CLOCK_FORMAT="%H:%M:%S"` #### Battery Charge Battery charge percentage: `THEME_SHOW_BATTERY=false` #### Exit Code Exit code of the last command: `THEME_SHOW_EXITCODE=true` ## Prompt Segments Order Currently available prompt segments are: - battery - char - clock - dir - exitcode - python - ruby - scm - todo - user_info Three environment variables can be defined to rearrange the segments order. The default values are: `___BRAINY_TOP_LEFT="user_info dir scm"` `___BRAINY_TOP_RIGHT="python ruby todo clock battery"` `___BRAINY_BOTTOM="exitcode char"` ================================================ FILE: themes/brainy/brainy.theme.sh ================================================ #! bash oh-my-bash.module # Brainy Bash Prompt for Bash-it # by MunifTanjim ############# ## Parsers ## ############# function ____brainy_top_left_parse { local args _omb_util_split args "$1" '|' if [[ ${args[3]} ]]; then _TOP_LEFT+=${args[2]}${args[3]} fi _TOP_LEFT+=${args[0]}${args[1]} if [[ ${args[4]} ]]; then _TOP_LEFT+=${args[2]}${args[4]} fi _TOP_LEFT+=" " } function ____brainy_top_right_parse { local args _omb_util_split args "$1" '|' _TOP_RIGHT+=" " if [[ ${args[3]} ]]; then _TOP_RIGHT+=${args[2]}${args[3]} fi _TOP_RIGHT+=${args[0]}${args[1]} if [[ ${args[4]} ]]; then _TOP_RIGHT+=${args[2]}${args[4]} fi __TOP_RIGHT_LEN=$((__TOP_RIGHT_LEN + ${#args[1]} + ${#args[3]} + ${#args[4]} + 1)) ((__SEG_AT_RIGHT += 1)) } function ____brainy_bottom_parse { local args _omb_util_split args "$1" '|' _BOTTOM+=${args[0]}${args[1]} ((${#args[1]} > 0)) && _BOTTOM+=" " } function ____brainy_top { local _TOP_LEFT="" local _TOP_RIGHT="" local __TOP_RIGHT_LEN=0 local __SEG_AT_RIGHT=0 local seg info for seg in ${___BRAINY_TOP_LEFT}; do info=$(___brainy_prompt_"$seg") [[ $info ]] && ____brainy_top_left_parse "$info" done local ___cursor_right='\033[500C' _TOP_LEFT+=$___cursor_right for seg in ${___BRAINY_TOP_RIGHT}; do info=$(___brainy_prompt_"$seg") [[ $info ]] && ____brainy_top_right_parse "$info" done ((__TOP_RIGHT_LEN > 0)) && ((__TOP_RIGHT_LEN--)) local ___cursor_adjust="\033[${__TOP_RIGHT_LEN}D" _TOP_LEFT+=$___cursor_adjust printf "%s%s" "$_TOP_LEFT" "$_TOP_RIGHT" } function ____brainy_bottom { local _BOTTOM="" seg for seg in $___BRAINY_BOTTOM; do local info=$(___brainy_prompt_"$seg") [[ $info ]] && ____brainy_bottom_parse "$info" done printf "\n%s" "$_BOTTOM" } ############## ## Segments ## ############## function ___brainy_prompt_user_info { local color=$_omb_prompt_bold_navy if [[ $THEME_SHOW_SUDO == true ]]; then if [[ $(sudo -n id -u 2>&1) == 0 ]]; then color=$_omb_prompt_bold_brown fi fi local box="[|]" local info="\u@\H" if [[ $SSH_CLIENT ]]; then printf "%s|%s|%s|%s" "$color" "$info" "$_omb_prompt_bold_white" "$box" else printf "%s|%s" "$color" "$info" fi } function ___brainy_prompt_dir { local color=$_omb_prompt_bold_olive local box="[|]" local info="\w" printf "%s|%s|%s|%s" "$color" "$info" "$_omb_prompt_bold_white" "$box" } function ___brainy_prompt_scm { [[ $THEME_SHOW_SCM != true ]] && return local color=$_omb_prompt_bold_green local box="$(scm_char) " local info="$(scm_prompt_info)" printf "%s|%s|%s|%s" "$color" "$info" "$_omb_prompt_bold_white" "$box" } function ___brainy_prompt_python { [[ $THEME_SHOW_PYTHON != true ]] && return local color=$_omb_prompt_bold_olive local box="[|]" local python_env _omb_prompt_get_python_env || return 0 printf "%s|%s|%s|%s" "$color" "${python_env}" "$_omb_prompt_bold_navy" "$box" } function ___brainy_prompt_ruby { [[ $THEME_SHOW_RUBY != true ]] && return local color=$_omb_prompt_bold_white local box="[|]" local info="rb-$(_omb_prompt_print_ruby_env)" printf "%s|%s|%s|%s" "$color" "$info" "$_omb_prompt_bold_brown" "$box" } function ___brainy_prompt_todo { [[ $THEME_SHOW_TODO != true ]] && return _omb_util_binary_exists todo.sh || return local color=$_omb_prompt_bold_white local box="[|]" local info="t:$(todo.sh ls | command grep -E "TODO: [0-9]+ of ([0-9]+)" | awk '{ print $4 }' )" printf "%s|%s|%s|%s" "$color" "$info" "$_omb_prompt_bold_green" "$box" } function ___brainy_prompt_clock { [[ $THEME_SHOW_CLOCK != true ]] && return local color=$THEME_CLOCK_COLOR local box="[|]" local info="$(date +"${THEME_CLOCK_FORMAT}")" printf "%s|%s|%s|%s" "$color" "$info" "$_omb_prompt_bold_purple" "$box" } function ___brainy_prompt_battery { [[ -e $OSH/plugins/battery/battery.plugin.sh ]] || return 0 [[ $THEME_SHOW_BATTERY != true ]] && return local info=$(battery_percentage) local color=$_omb_prompt_bold_green if ((info < 50)); then color=$_omb_prompt_bold_olive elif ((info < 25)); then color=$_omb_prompt_bold_brown fi local box="[|]" ac_adapter_connected && info+="+" [[ $info == 100+ ]] && info="AC" printf "%s|%s|%s|%s" "$color" "$info" "$_omb_prompt_bold_white" "$box" } function ___brainy_prompt_exitcode { [[ $THEME_SHOW_EXITCODE != true ]] && return local color=$_omb_prompt_bold_purple ((exitcode != 0)) && printf "%s|%s" "$color" "$exitcode" } function ___brainy_prompt_char { local color=$_omb_prompt_bold_white local prompt_char="${__BRAINY_PROMPT_CHAR_PS1}" printf "%s|%s" "$color" "${prompt_char}" } ######### ## cli ## ######### function __brainy_show { local _seg=${1:-} export "THEME_SHOW_${_seg}=true" } function __brainy_hide { local _seg=${1:-} export "THEME_SHOW_${_seg}=false" } function _brainy_completion { COMPREPLY=() local cur=${COMP_WORDS[COMP_CWORD]} local _action=${COMP_WORDS[1]} local actions="show hide" local segments="battery clock exitcode python ruby scm sudo todo" case $_action in show | hide) _omb_util_split COMPREPLY "$(compgen -W "$segments" -- "$cur")" $'\n' ;; *) _omb_util_split COMPREPLY "$(compgen -W "$actions" -- "$cur")" $'\n' ;; esac return 0 } function brainy { local action=${1:-} shift local segs IFS=$' \t\n' _omb_util_split segs "$*" local func case $action in show) func=__brainy_show;; hide) func=__brainy_hide;; *) printf 'brainy: %s: unrecognized action\n' "$action" >&2 return 1 ;; esac local seg for seg in "${segs[@]}"; do seg=$(printf "%s" "$seg" | tr '[:lower:]' '[:upper:]') "$func" "$seg" done } complete -F _brainy_completion brainy ############### ## Variables ## ############### export SCM_THEME_PROMPT_PREFIX="" export SCM_THEME_PROMPT_SUFFIX="" export RBENV_THEME_PROMPT_PREFIX="" export RBENV_THEME_PROMPT_SUFFIX="" export RBFU_THEME_PROMPT_PREFIX="" export RBFU_THEME_PROMPT_SUFFIX="" export RVM_THEME_PROMPT_PREFIX="" export RVM_THEME_PROMPT_SUFFIX="" export SCM_THEME_PROMPT_DIRTY=" ${_omb_prompt_bold_brown}✗${_omb_prompt_normal}" export SCM_THEME_PROMPT_CLEAN=" ${_omb_prompt_bold_green}✓${_omb_prompt_normal}" THEME_SHOW_SUDO=${THEME_SHOW_SUDO:-"true"} THEME_SHOW_SCM=${THEME_SHOW_SCM:-"true"} THEME_SHOW_RUBY=${THEME_SHOW_RUBY:-"false"} THEME_SHOW_PYTHON=${THEME_SHOW_PYTHON:-"false"} THEME_SHOW_CLOCK=${THEME_SHOW_CLOCK:-"true"} THEME_SHOW_TODO=${THEME_SHOW_TODO:-"false"} THEME_SHOW_BATTERY=${THEME_SHOW_BATTERY:-"false"} THEME_SHOW_EXITCODE=${THEME_SHOW_EXITCODE:-"true"} THEME_CLOCK_COLOR=${THEME_CLOCK_COLOR:-"$_omb_prompt_bold_white"} THEME_CLOCK_FORMAT=${THEME_CLOCK_FORMAT:-"%H:%M:%S"} __BRAINY_PROMPT_CHAR_PS1=${THEME_PROMPT_CHAR_PS1:-">"} __BRAINY_PROMPT_CHAR_PS2=${THEME_PROMPT_CHAR_PS2:-"\\"} ___BRAINY_TOP_LEFT=${___BRAINY_TOP_LEFT:-"user_info dir scm"} ___BRAINY_TOP_RIGHT=${___BRAINY_TOP_RIGHT:-"python ruby todo clock battery"} ___BRAINY_BOTTOM=${___BRAINY_BOTTOM:-"exitcode char"} ############ ## Prompt ## ############ function __brainy_ps1 { printf "%s%s%s" "$(____brainy_top)" "$(____brainy_bottom)" "$_omb_prompt_normal" } function __brainy_ps2 { local color=$_omb_prompt_bold_white printf "%s%s%s" "$color" "${__BRAINY_PROMPT_CHAR_PS2} " "$_omb_prompt_normal" } function _omb_theme_PROMPT_COMMAND { local exitcode=$? # used by segment "exitcode" PS1=$(__brainy_ps1) PS2=$(__brainy_ps2) } _omb_util_add_prompt_command _omb_theme_PROMPT_COMMAND ================================================ FILE: themes/brunton/brunton.theme.sh ================================================ #! bash oh-my-bash.module SCM_THEME_PROMPT_PREFIX="" SCM_THEME_PROMPT_SUFFIX="" SCM_THEME_PROMPT_DIRTY=" ${_omb_prompt_bold_brown}✗${_omb_prompt_normal}" SCM_THEME_PROMPT_CLEAN=" ${_omb_prompt_bold_green}✓${_omb_prompt_normal}" SCM_GIT_CHAR="${_omb_prompt_bold_green}±${_omb_prompt_normal}" SCM_SVN_CHAR="${_omb_prompt_bold_teal}⑆${_omb_prompt_normal}" SCM_HG_CHAR="${_omb_prompt_bold_brown}☿${_omb_prompt_normal}" function is_vim_shell { if [ ! -z "$VIMRUNTIME" ] then _omb_util_print "[${_omb_prompt_teal}vim shell${_omb_prompt_normal}]" fi } function scm_prompt { CHAR=$(scm_char) if [ $CHAR = $SCM_NONE_CHAR ] then return else _omb_util_print " $(scm_char) (${_omb_prompt_white}$(scm_prompt_info)${_omb_prompt_normal})" fi } function _omb_theme_PROMPT_COMMAND { PS1="${_omb_prompt_white}${_omb_prompt_background_navy} \u${_omb_prompt_normal}" PS1+="${_omb_prompt_background_navy}@${_omb_prompt_brown}${_omb_prompt_background_navy}\h $(clock_prompt) ${_omb_prompt_reset_color}" PS1+="${_omb_prompt_normal} $(battery_charge)\n" PS1+="${_omb_prompt_bold_black}${_omb_prompt_background_white} \w " PS1+="${_omb_prompt_normal}$(scm_prompt)$(is_vim_shell)\n" PS1+="${_omb_prompt_white}>${_omb_prompt_normal} " } THEME_CLOCK_COLOR=${THEME_CLOCK_COLOR:-"$_omb_prompt_navy$_omb_prompt_background_white"} THEME_CLOCK_FORMAT=${THEME_CLOCK_FORMAT:-" %H:%M:%S"} _omb_util_add_prompt_command _omb_theme_PROMPT_COMMAND ================================================ FILE: themes/candy/candy.theme.sh ================================================ #! bash oh-my-bash.module function _omb_theme_PROMPT_COMMAND() { PS1="${_omb_prompt_green}\u@\h $(clock_prompt) ${_omb_prompt_reset_color}${_omb_prompt_white}\w${_omb_prompt_reset_color}$(scm_prompt_info)${_omb_prompt_navy} →${_omb_prompt_bold_navy} ${_omb_prompt_reset_color} "; } THEME_CLOCK_COLOR=${THEME_CLOCK_COLOR:-"$_omb_prompt_navy"} THEME_CLOCK_FORMAT=${THEME_CLOCK_FORMAT:-"%I:%M:%S"} _omb_util_add_prompt_command _omb_theme_PROMPT_COMMAND ================================================ FILE: themes/clean/clean.theme.sh ================================================ #! bash oh-my-bash.module # git theming ZSH_THEME_GIT_PROMPT_PREFIX="${_omb_prompt_bold_navy}(${_omb_prompt_olive}%B" ZSH_THEME_GIT_PROMPT_SUFFIX="%b${_omb_prompt_bold_navy})${_omb_prompt_reset_color} " ZSH_THEME_GIT_PROMPT_CLEAN="" ZSH_THEME_GIT_PROMPT_DIRTY="${_omb_prompt_bold_brown}✗" # LS colors, made with http://geoff.greer.fm/lscolors/ export LSCOLORS="Gxfxcxdxbxegedabagacad" export LS_COLORS='no=00:fi=00:di=01;34:ln=00;36:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=41;33;01:ex=00;32:*.cmd=00;32:*.exe=01;32:*.com=01;32:*.bat=01;32:*.btm=01;32:*.dll=01;32:*.tar=00;31:*.tbz=00;31:*.tgz=00;31:*.rpm=00;31:*.deb=00;31:*.arj=00;31:*.taz=00;31:*.lzh=00;31:*.lzma=00;31:*.zip=00;31:*.zoo=00;31:*.z=00;31:*.Z=00;31:*.gz=00;31:*.bz2=00;31:*.tb2=00;31:*.tz2=00;31:*.tbz2=00;31:*.avi=01;35:*.bmp=01;35:*.fli=01;35:*.gif=01;35:*.jpg=01;35:*.jpeg=01;35:*.mng=01;35:*.mov=01;35:*.mpg=01;35:*.pcx=01;35:*.pbm=01;35:*.pgm=01;35:*.png=01;35:*.ppm=01;35:*.tga=01;35:*.tif=01;35:*.xbm=01;35:*.xpm=01;35:*.dl=01;35:*.gl=01;35:*.wmv=01;35:*.aiff=00;32:*.au=00;32:*.mid=00;32:*.mp3=00;32:*.ogg=00;32:*.voc=00;32:*.wav=00;32:' function _omb_theme_PROMPT_COMMAND() { if [ "$(whoami)" = root ]; then no_color=$_omb_prompt_brown; else no_color=$_omb_prompt_white; fi PS1="${no_color}\u${_omb_prompt_reset_color}:${_omb_prompt_navy}\W/${_omb_prompt_reset_color} \[\$(scm_prompt_info)\]$ " RPROMPT='[\t]' } _omb_util_add_prompt_command _omb_theme_PROMPT_COMMAND ================================================ FILE: themes/cooperkid/cooperkid.theme.sh ================================================ #! bash oh-my-bash.module # ------------------------------------------------------------------# # FILE: cooperkid.zsh-theme # # BY: Alfredo Bejarano # # BASED ON: Mr Briggs by Matt Brigg (matt@mattbriggs.net) # # ------------------------------------------------------------------# SCM_THEME_PROMPT_DIRTY="${_omb_prompt_brown} ✗${_omb_prompt_reset_color}" SCM_THEME_PROMPT_AHEAD="${_omb_prompt_olive} ↑${_omb_prompt_reset_color}" SCM_THEME_PROMPT_CLEAN="${_omb_prompt_green} ✓${_omb_prompt_reset_color}" SCM_THEME_PROMPT_PREFIX=" " SCM_THEME_PROMPT_SUFFIX="" GIT_SHA_PREFIX="${_omb_prompt_navy}" GIT_SHA_SUFFIX="${_omb_prompt_reset_color}" function git_short_sha() { SHA=$(_omb_prompt_git rev-parse --short HEAD 2> /dev/null) && _omb_util_print "$GIT_SHA_PREFIX$SHA$GIT_SHA_SUFFIX" } function _omb_theme_PROMPT_COMMAND() { local return_status="" local ruby="${_omb_prompt_brown}$(_omb_prompt_print_ruby_env)${_omb_prompt_reset_color}" local user_host="${_omb_prompt_green}\h @ \w${_omb_prompt_reset_color}" local git_branch="$(git_short_sha)${_omb_prompt_teal}$(scm_prompt_info)${_omb_prompt_reset_color}" local prompt_symbol=' ' local prompt_char="${_omb_prompt_purple}>_${_omb_prompt_reset_color} " PS1="\n${user_host}${prompt_symbol}${ruby} ${git_branch} ${return_status}\n${prompt_char}" } _omb_util_add_prompt_command _omb_theme_PROMPT_COMMAND ================================================ FILE: themes/copied-duru/README.md ================================================ # Copied-Duru Theme This theme is heavily inspired by the "Sexy" and "Duru" themes. The goal was to combine the color scheme of "Sexy" with the style of "Duru", and that is exactly what this theme achieves! ## Features - **Colorful Prompt:** Utilizes the vibrant color scheme from the "Sexy" theme. - **Informative Prompt:** Displays useful information such as the current time, user, host, current directory, Git branch, and Python virtual environment. ## Usage - **Python Virtual Environment**Displayed in magenta - **User and Host:** Displayed in purple and white - **Current Time:** Displayed in Yellow - **Current Directory:** Displayed in purple - **Git Branch** Displayed in magenta ================================================ FILE: themes/copied-duru/copied-duru.theme.sh ================================================ #! bash oh-my-bash.module # "Copied-Duru" Prompt, inspired by "Sexy" and obviously "Duru" source "$OSH/themes/sexy/sexy.theme.sh" if [[ $COLORTERM == gnome-* && $TERM == xterm ]] && infocmp gnome-256color &>/dev/null; then export TERM=gnome-256color elif [[ $TERM != dumb ]] && infocmp xterm-256color &>/dev/null; then export TERM=xterm-256color fi function _omb_theme_PROMPT_COMMAND { local current_time='\D{%H:%M:%S}' local python_venv= local just_a_format=' '$MAGENTA'(%s)' if [[ $VIRTUAL_ENV ]]; then printf -v python_venv "$just_a_format" "${VIRTUAL_ENV##*/}" elif [[ $CONDA_DEFAULT_ENV ]]; then printf -v python_venv "$just_a_format" "${CONDA_DEFAULT_ENV##*/}" fi local git_prefix= [[ $(_omb_prompt_git branch 2> /dev/null) ]] && git_prefix=' on ' PS1=$GREEN'#'$python_venv' '$PURPLE'\u@'$WHITE'\h'$GREEN PS1+=' '$current_time'>'$RESET PS1+=' '$PURPLE'<\w'$WHITE$git_prefix$MAGENTA$(parse_git_branch) PS1+=$PURPLE'>'$RESET'\n'$GREEN'$ '$RESET } _omb_util_add_prompt_command _omb_theme_PROMPT_COMMAND ================================================ FILE: themes/cupcake/cupcake.theme.sh ================================================ #! bash oh-my-bash.module # Emoji-based theme to display source control management and # virtual environment info beside the ordinary bash prompt. # Theme inspired by: # - Naming your Terminal tabs in OSX Lion - http://thelucid.com/2012/01/04/naming-your-terminal-tabs-in-osx-lion/ # - Bash_it sexy theme # Demo: # ┌ⓔ virtualenv 💁user @ 💻 host in 📁directory on 🌿branch {1} ↑1 ↓1 +1 •1 ⌀1 ✗ # └❯ cd .bash-it/themes/cupcake # virtualenv prompts VIRTUALENV_CHAR="ⓔ " OMB_PROMPT_VIRTUALENV_FORMAT='%s' OMB_PROMPT_SHOW_PYTHON_VENV=${OMB_PROMPT_SHOW_PYTHON_VENV:=true} # SCM prompts SCM_NONE_CHAR="" SCM_GIT_CHAR="[±] " SCM_GIT_BEHIND_CHAR="${_omb_prompt_brown}↓${_omb_prompt_normal}" SCM_GIT_AHEAD_CHAR="${_omb_prompt_bold_green}↑${_omb_prompt_normal}" SCM_GIT_UNTRACKED_CHAR="⌀" SCM_GIT_UNSTAGED_CHAR="${_omb_prompt_bold_olive}•${_omb_prompt_normal}" SCM_GIT_STAGED_CHAR="${_omb_prompt_bold_green}+${_omb_prompt_normal}" SCM_THEME_PROMPT_DIRTY="" SCM_THEME_PROMPT_CLEAN="" SCM_THEME_PROMPT_PREFIX="" SCM_THEME_PROMPT_SUFFIX="" # Git status prompts GIT_THEME_PROMPT_DIRTY=" ${_omb_prompt_brown}✗${_omb_prompt_normal}" GIT_THEME_PROMPT_CLEAN=" ${_omb_prompt_bold_green}✓${_omb_prompt_normal}" GIT_THEME_PROMPT_PREFIX="" GIT_THEME_PROMPT_SUFFIX="" # ICONS ======================================================================= icon_start="┌" icon_user="💁 " icon_host=" @ 💻 " icon_directory=" in 📁 " icon_branch="🌿" icon_end="└❯ " # extra spaces ensure legiblity in prompt # FUNCTIONS =================================================================== # Rename tab function tabname { printf '\e]1;%s\a' "$1" } # Rename window function winname { printf '\e]2;%s\a' "$1" } # PROMPT OUTPUT =============================================================== # Displays the current prompt function _omb_theme_PROMPT_COMMAND() { PS1='\n'$icon_start$(_omb_prompt_print_python_venv) PS1+=$icon_user$_omb_prompt_bold_brown'\u' PS1+=$_omb_prompt_normal$icon_host$_omb_prompt_bold_teal'\h' PS1+=$_omb_prompt_normal$icon_directory$_omb_prompt_bold_purple'\W' PS1+=$_omb_prompt_normal$([[ -n $(_omb_prompt_git branch 2> /dev/null) ]] && _omb_util_print " on $icon_branch ") PS1+=$_omb_prompt_white$(scm_prompt_info)$_omb_prompt_normal'\n'$icon_end PS2=$icon_end } # Runs prompt (this bypasses oh-my-bash $PROMPT setting) _omb_util_add_prompt_command _omb_theme_PROMPT_COMMAND ================================================ FILE: themes/demula/demula.theme.sh ================================================ #! bash oh-my-bash.module # Theme inspired on: # - Ronacher's dotfiles (mitsuhikos) - http://github.com/mitsuhiko/dotfiles/tree/master/bash/ # - Glenbot - http://theglenbot.com/custom-bash-shell-for-development/ # - My extravagant zsh - http://stevelosh.com/blog/2010/02/my-extravagant-zsh-prompt/ # - Monokai colors - http://monokai.nl/blog/2006/07/15/textmate-color-theme/ # - Bash_it modern theme # # Screenshot: http://goo.gl/VCmX5 # by Jesus de Mula # For the real Monokai colors you should add these to your .XDefaults or # terminal configuration: #! ----------------------------------------------------------- TERMINAL COLORS #! monokai - http://www.monokai.nl/blog/2006/07/15/textmate-color-theme/ #*background: #272822 #*foreground: #E2DA6E #*color0: black #! mild red #*color1: #CD0000 #! light green #*color2: #A5E02D #! orange (yellow) #*color3: #FB951F #! "dark" blue #*color4: #076BCC #! hot pink #*color5: #F6266C #! cyan #*color6: #64D9ED #! gray #*color7: #E5E5E5 # ----------------------------------------------------------------- COLOR CONF D_DEFAULT_COLOR="${_omb_prompt_normal}" D_INTERMEDIATE_COLOR="${_omb_prompt_white}" D_USER_COLOR="${_omb_prompt_purple}" D_SUPERUSER_COLOR="${_omb_prompt_brown}" D_MACHINE_COLOR="${_omb_prompt_teal}" D_DIR_COLOR="${_omb_prompt_green}" D_SCM_COLOR="${_omb_prompt_olive}" D_BRANCH_COLOR="${_omb_prompt_olive}" D_CHANGES_COLOR="${_omb_prompt_white}" D_CMDFAIL_COLOR="${_omb_prompt_brown}" D_VIMSHELL_COLOR="${_omb_prompt_teal}" # ------------------------------------------------------------------ FUNCTIONS case $TERM in xterm*) TITLEBAR="\033]0;\w\007" ;; *) TITLEBAR="" ;; esac function is_vim_shell { if [ ! -z "$VIMRUNTIME" ]; then _omb_util_print "${D_INTERMEDIATE_COLOR}on ${D_VIMSHELL_COLOR}\ vim shell${D_DEFAULT_COLOR} " fi } function mitsuhikos_lastcommandfailed { code=$? if [ $code != 0 ]; then _omb_util_print "${D_INTERMEDIATE_COLOR}exited ${D_CMDFAIL_COLOR}\ $code ${D_DEFAULT_COLOR}" fi } # vcprompt for scm instead of oh-my-bash default function demula_vcprompt { if [ ! -z "$VCPROMPT_EXECUTABLE" ]; then local D_VCPROMPT_FORMAT="on ${D_SCM_COLOR}%s${D_INTERMEDIATE_COLOR}:\ ${D_BRANCH_COLOR}%b %r ${D_CHANGES_COLOR}%m%u ${D_DEFAULT_COLOR}" $VCPROMPT_EXECUTABLE -f "$D_VCPROMPT_FORMAT" fi } # checks if the plugin is installed before calling battery_charge function safe_battery_charge { if [ -e "${OSH}/plugins/battery/battery.plugin.sh" ]; then battery_charge fi } # -------------------------------------------------------------- PROMPT OUTPUT function _omb_theme_PROMPT_COMMAND { local LAST_COMMAND_FAILED=$(mitsuhikos_lastcommandfailed) local SAVE_CURSOR='\033[s' local RESTORE_CURSOR='\033[u' local MOVE_CURSOR_RIGHTMOST='\033[500C' local MOVE_CURSOR_5_LEFT='\033[5D' if [ $(uname) = "Linux" ]; then PS1="${TITLEBAR} ${SAVE_CURSOR}${MOVE_CURSOR_RIGHTMOST}${MOVE_CURSOR_5_LEFT}\ $(safe_battery_charge)${RESTORE_CURSOR}\ ${D_USER_COLOR}\u ${D_INTERMEDIATE_COLOR}\ at ${D_MACHINE_COLOR}\h ${D_INTERMEDIATE_COLOR}\ in ${D_DIR_COLOR}\w ${D_INTERMEDIATE_COLOR}\ ${LAST_COMMAND_FAILED}\ $(demula_vcprompt)\ $(is_vim_shell) ${D_INTERMEDIATE_COLOR}$ ${D_DEFAULT_COLOR}" else PS1="${TITLEBAR} ${D_USER_COLOR}\u ${D_INTERMEDIATE_COLOR}\ at ${D_MACHINE_COLOR}\h ${D_INTERMEDIATE_COLOR}\ in ${D_DIR_COLOR}\w ${D_INTERMEDIATE_COLOR}\ ${LAST_COMMAND_FAILED}\ $(demula_vcprompt)\ $(is_vim_shell)\ $(safe_battery_charge) ${D_INTERMEDIATE_COLOR}$ ${D_DEFAULT_COLOR}" fi PS2="${D_INTERMEDIATE_COLOR}$ ${D_DEFAULT_COLOR}" } # Runs prompt (this bypasses oh-my-bash $PROMPT setting) _omb_util_add_prompt_command _omb_theme_PROMPT_COMMAND ================================================ FILE: themes/developer/developer.theme.sh ================================================ #! bash oh-my-bash.module SCM_THEME_PROMPT_DIRTY=" ${_omb_prompt_brown}✗" SCM_THEME_PROMPT_CLEAN=" ${_omb_prompt_bold_green}✓" SCM_THEME_PROMPT_PREFIX=" $_omb_prompt_green|" SCM_THEME_PROMPT_SUFFIX="$_omb_prompt_green|" GIT_THEME_PROMPT_DIRTY=" ${_omb_prompt_brown}✗" GIT_THEME_PROMPT_CLEAN=" ${_omb_prompt_bold_green}✓" GIT_THEME_PROMPT_PREFIX=" $_omb_prompt_green|" GIT_THEME_PROMPT_SUFFIX="$_omb_prompt_green|" RVM_THEME_PROMPT_PREFIX='|' RVM_THEME_PROMPT_SUFFIX='|' function __bobby_clock { _omb_util_put "$(clock_prompt) " if [[ $THEME_SHOW_CLOCK_CHAR == true ]]; then _omb_util_put "$(clock_char) " fi } ## @var[out] REPLY function _omb_theme_developer__readNodeVersion { local val_node=$(node --version 2>/dev/null) if _omb_util_command_exists nvm; then val_node="nvm $val_node" else # Si nvm no está instalado, utilizar "njs" val_node="njs $val_node" fi REPLY=$val_node } ## @var[out] REPLY function _omb_theme_developer__readGoVersion { local val_go=$(go version 2>/dev/null | cut -d ' ' -f 3 | cut -d 'o' -f 2) REPLY="go $val_go" } ## @var[out] REPLY function _omb_theme_developer__read_ruby_version { local val_rb=$(ruby --version 2>/dev/null | cut -d ' ' -f 2) if _omb_util_command_exists rvm; then val_rb="rvm $val_rb" else # Si nvm no está instalado, utilizar "njs" val_rb="rb $val_rb" fi REPLY=$val_rb } ## @var[out] REPLY function _omb_theme_developer__readPyVersion { local val_py=$(python --version 2>/dev/null | cut -d ' ' -f 2) if _omb_util_command_exists conda; then local condav=$(conda env list | awk '$2 == "*" {print $1}') val_py="conda<$condav> $val_py" else # Si nvm no está instalado, utilizar "njs" val_py="py $val_py" fi REPLY=$val_py } ## @var[out] REPLY function _omb_theme_developer__readCpuLoad__cpuLoad { # Ejecutar el comando top en modo batch, filtrar por el nombre de usuario # actual. Extraer el porcentaje de carga de la CPU excluyendo el estado # "idle" usando awk local cpu_load=$(top -b -n 1 -u "$USER" | awk -F ',' '/Cpu\(s\)/ {gsub(/[^.0-9]/,"",$4);printf("%d", 100.0 - $4)}') # Almacenar la carga de la CPU en la variable 'REPLY' REPLY=$cpu_load } ## @var[out] REPLY function _omb_theme_developer__readCpuLoad { _omb_theme_developer__readCpuLoad__cpuLoad local current_cpu_load=$REPLY local color=$_omb_prompt_reset_color # Condicional para verificar los rangos if ((current_cpu_load <= 40)); then color=$_omb_prompt_teal elif ((current_cpu_load >= 41 && current_cpu_load <= 50)); then color=$_omb_prompt_reset_color elif ((current_cpu_load >= 51 && current_cpu_load <= 60)); then color=$_omb_prompt_olive elif ((current_cpu_load >= 61 && current_cpu_load <= 75)); then color=$_omb_prompt_red elif ((current_cpu_load >= 76)); then color=$_omb_prompt_red'!' fi REPLY=$color$current_cpu_load } ## @var[out] REPLY function _omb_theme_developer__readCpuTemp_genericLinuxTemp { local file=${1:-/sys/class/thermal/thermal_zone0/temp} if [[ ! -e $file ]]; then REPLY= return 1 fi local temp_linux=$(< "$file") local temp_in_c=$((temp_linux / 1000)) REPLY=$temp_in_c } ## @var[out] REPLY function _omb_theme_developer__readCpuTemp_OPi5pTemp { _omb_theme_developer__readCpuTemp_genericLinuxTemp /sys/class/thermal/thermal_zone4/temp } # if is a specific platfor use spacific configuration otherwise use default # linux configuration. ## @var[out] REPLY function _omb_theme_developer__readCpuTemp_currentPlatform { # 2 ways to detect the platform 1) use a env var 2) some scrapping from the # current system info (this is bash so just linux is considered) env var is # $PROMPT_THEME_PLATFORM # TODO: this is a first basic implementation this could be better but for now # is ok local platform_according_env=$PROMPT_THEME_PLATFORM # if opi5 -> search for rk3588 tag in kernel and ... local opi5p_kernel_tag=$(uname --kernel-release 2>/dev/null | cut -d '-' -f 3) if [[ $platform_according_env == OPI5P || $opi5p_kernel_tag == rk3588 ]]; then REPLY=OPI5P else REPLY=linux fi } ## @var[out] REPLY function _omb_theme_developer__readCpuTemp { _omb_theme_developer__readCpuTemp_currentPlatform local currentPlatform=$REPLY if [[ $currentPlatform == linux ]]; then _omb_theme_developer__readCpuTemp_genericLinuxTemp elif [[ $currentPlatform == OPI5P ]]; then _omb_theme_developer__readCpuTemp_OPi5pTemp fi local temp_in_c=$REPLY [[ $REPLY ]] || return 0 local color # Condicional para verificar los rangos if ((temp_in_c >= 1 && temp_in_c <= 40)); then color=$_omb_prompt_teal elif ((temp_in_c >= 41 && temp_in_c <= 50)); then color=$_omb_prompt_reset_color elif ((temp_in_c >= 51 && temp_in_c <= 60)); then color=$_omb_prompt_olive elif ((temp_in_c >= 61 && temp_in_c <= 75)); then color=$_omb_prompt_red elif ((temp_in_c >= 76 && temp_in_c)); then color=$_omb_prompt_red! fi REPLY="$color${temp_in_c}°" } ## @var[out] REPLY function _omb_theme_developer__readDefaultIp { # this should work on every "new" linux distro # Obtiene el nombre de la interfaz de red activa local interface=$(ip -o -4 route show to default 2>/dev/null | awk '{print $5}') # Obtiene la dirección IP de la interfaz de red activa local ip_address=$(ip -o -4 address show dev "$interface" 2>/dev/null | awk '{split($4, a, "/"); print a[1]}') REPLY=$ip_address } # prompt constructor function _omb_theme_PROMPT_COMMAND { local REPLY _omb_theme_developer__readCpuTemp local cputemp=$REPLY _omb_theme_developer__readCpuLoad # this is very slow local cpuload=$REPLY _omb_theme_developer__readPyVersion local pyversion=$REPLY _omb_theme_developer__readNodeVersion local nodeversion=$REPLY _omb_theme_developer__readGoVersion local goversion=$REPLY _omb_theme_developer__readDefaultIp local defaultip=$REPLY local tech_versions=$nodeversion [[ $pyversion ]] && tech_versions+=${tech_versions:+$RVM_THEME_PROMPT_PREFIX}$pyversion [[ $goversion ]] && tech_versions+=${tech_versions:+$RVM_THEME_PROMPT_PREFIX}$goversion [[ $tech_versions ]] && tech_versions=$_omb_prompt_reset_color$tech_versions local top_bar="\n$(battery_char)$(__bobby_clock)$tech_versions${cputemp:+ $cputemp}${cpuload:+ $cpuload%} $_omb_prompt_purple\h${defaultip:+ ($defaultip)} ${_omb_prompt_reset_color}in $_omb_prompt_green\w\n" local prompt_line="$_omb_prompt_bold_teal$(scm_prompt_char_info) $_omb_prompt_green→$_omb_prompt_reset_color " # defining the final prompt PS1="$top_bar$prompt_line" } THEME_SHOW_CLOCK_CHAR=${THEME_SHOW_CLOCK_CHAR:-"true"} THEME_CLOCK_CHAR_COLOR=${THEME_CLOCK_CHAR_COLOR:-"$_omb_prompt_brown"} THEME_CLOCK_COLOR=${THEME_CLOCK_COLOR:-"$_omb_prompt_bold_teal"} THEME_CLOCK_FORMAT=${THEME_CLOCK_FORMAT:-"%Y-%m-%d %H:%M"} _omb_util_add_prompt_command _omb_theme_PROMPT_COMMAND ================================================ FILE: themes/dos/dos.theme.sh ================================================ #! bash oh-my-bash.module PROMPT="\w>>" ================================================ FILE: themes/doubletime/doubletime.theme.sh ================================================ #! bash oh-my-bash.module SCM_THEME_PROMPT_DIRTY='' SCM_THEME_PROMPT_CLEAN='' SCM_GIT_CHAR="${_omb_prompt_bold_teal}±${_omb_prompt_normal}" SCM_SVN_CHAR="${_omb_prompt_bold_teal}⑆${_omb_prompt_normal}" SCM_HG_CHAR="${_omb_prompt_bold_brown}☿${_omb_prompt_normal}" SCM_THEME_PROMPT_PREFIX="" SCM_THEME_PROMPT_SUFFIX="" if [[ $RVM_THEME_PROMPT_COLOR ]]; then RVM_THEME_PROMPT_COLOR=$(printf "${RVM_THEME_PROMPT_COLOR//%/%%}"); else RVM_THEME_PROMPT_COLOR=$_omb_prompt_brown fi RVM_THEME_PROMPT_PREFIX="(${RVM_THEME_PROMPT_COLOR}rb${_omb_prompt_normal}: " RVM_THEME_PROMPT_SUFFIX=") " if [[ $VIRTUALENV_THEME_PROMPT_COLOR ]]; then VIRTUALENV_THEME_PROMPT_COLOR=$(printf "${VIRTUALENV_THEME_PROMPT_COLOR//%/%%}"); else VIRTUALENV_THEME_PROMPT_COLOR=$_omb_prompt_green fi OMB_PROMPT_VIRTUALENV_FORMAT="(${VIRTUALENV_THEME_PROMPT_COLOR}py${_omb_prompt_normal}: %s) " OMB_PROMPT_SHOW_PYTHON_VENV=${OMB_PROMPT_SHOW_PYTHON_VENV:=true} if [[ $THEME_PROMPT_HOST_COLOR ]]; then THEME_PROMPT_HOST_COLOR=$(printf "${THEME_PROMPT_HOST_COLOR//%/%%}"); else THEME_PROMPT_HOST_COLOR=$_omb_prompt_navy fi function doubletime_scm_prompt { CHAR=$(scm_char) if [[ $CHAR == "$SCM_NONE_CHAR" ]]; then return elif [[ $CHAR == "$SCM_GIT_CHAR" ]]; then _omb_util_print "$(git_prompt_status)" else _omb_util_print "[$(scm_prompt_info)]" fi } function _omb_theme_PROMPT_COMMAND() { # Save history history -a history -c history -r PS1=" $(clock_prompt) $(scm_char) [${THEME_PROMPT_HOST_COLOR}\u@${THEME_PROMPT_HOST}$_omb_prompt_reset_color] $(_omb_prompt_print_python_venv)$(_omb_prompt_print_ruby_env)\w $(doubletime_scm_prompt)$_omb_prompt_reset_color $ " PS2='> ' PS4='+ ' } _omb_util_add_prompt_command _omb_theme_PROMPT_COMMAND function git_prompt_status { local git_status_output git_status_output=$(_omb_prompt_git status 2> /dev/null ) if grep -q 'Changes not staged' <<< "$git_status_output"; then git_status="${_omb_prompt_bold_brown}$(scm_prompt_info) ✗" elif grep -q 'Changes to be committed' <<< "$git_status_output"; then git_status="${_omb_prompt_bold_olive}$(scm_prompt_info) ^" elif grep -q 'Untracked files' <<< "$git_status_output"; then git_status="${_omb_prompt_bold_teal}$(scm_prompt_info) +" elif grep -q 'nothing to commit' <<< "$git_status_output"; then git_status="${_omb_prompt_bold_green}$(scm_prompt_info) ${_omb_prompt_green}✓" else git_status=$(scm_prompt_info) fi _omb_util_print "[$git_status${_omb_prompt_normal}]" } ================================================ FILE: themes/doubletime_multiline/doubletime_multiline.theme.sh ================================================ #! bash oh-my-bash.module source "$OSH/themes/doubletime/doubletime.theme.sh" function _omb_theme_PROMPT_COMMAND() { # Save history history -a history -c history -r PS1=" $(clock_prompt) $(scm_char) [$THEME_PROMPT_HOST_COLOR\u@${THEME_PROMPT_HOST}$_omb_prompt_reset_color] $(_omb_prompt_print_python_venv)$(_omb_prompt_print_ruby_env) \w $(doubletime_scm_prompt)$_omb_prompt_reset_color $ " PS2='> ' PS4='+ ' } _omb_util_add_prompt_command _omb_theme_PROMPT_COMMAND ================================================ FILE: themes/doubletime_multiline_pyonly/doubletime_multiline_pyonly.theme.sh ================================================ #! bash oh-my-bash.module source "$OSH/themes/doubletime/doubletime.theme.sh" function _omb_theme_PROMPT_COMMAND() { # Save history history -a history -c history -r PS1=" $(clock_prompt) $(scm_char) [$THEME_PROMPT_HOST_COLOR\u@${THEME_PROMPT_HOST}$_omb_prompt_reset_color] $(_omb_prompt_print_python_venv) \w $(doubletime_scm_prompt)$_omb_prompt_reset_color $ " PS2='> ' PS4='+ ' } _omb_util_add_prompt_command _omb_theme_PROMPT_COMMAND ================================================ FILE: themes/dulcie/dulcie.theme.sh ================================================ #! bash oh-my-bash.module # Simplistic one-liner theme to display source control management info beside # the ordinary Linux bash prompt. # # Demo: # # [ritola@localhost ~]$ cd .bash-it/themes/dulcie # [ritola@localhost |master ✓| dulcie]$ # This is single line mode # |bash-it|± master ✓| # [ritola@localhost dulcie]$ # In multi line, the SCM info is in the separate line # # Configuration. Change these by adding them in your .bash_profile DULCIE_COLOR=${DULCIE_COLOR:=1} # 0 = monochrome, 1 = colorful DULCIE_MULTILINE=${DULCIE_MULTILINE:=1} # 0 = Single line, 1 = SCM in separate line function dulcie_color { echo -en "\[\e[38;5;${1}m\]" } function dulcie_background { echo -en "\[\e[48;5;${1}m\]" } function _omb_theme_PROMPT_COMMAND { color_user_root=$(dulcie_color 169) color_user_nonroot="${_omb_prompt_green}" color_host_local=$(dulcie_color 230) color_host_remote=$(dulcie_color 214) color_rootdir=$(dulcie_color 117) color_workingdir=$(dulcie_color 117) background_scm=$(dulcie_background 238) SCM_THEME_ROOT_SUFFIX="|$(scm_char) " # Set colors if [ "${DULCIE_COLOR}" -eq "1" ]; then if [[ $EUID -ne 0 ]]; then color_user="${color_user_nonroot}" else color_user="${color_user_root}" fi if [[ -n "${SSH_CLIENT}" ]]; then color_host="${color_host_remote}" else color_host="${color_host_local}" fi DULCIE_USER="${color_user}\u${_omb_prompt_reset_color}" DULCIE_HOST="${color_host}\h${_omb_prompt_reset_color}" DULCIE_WORKINGDIR="${color_workingdir}\W${_omb_prompt_reset_color}" DULCIE_PROMPTCHAR="${color_user}"'\$'"${_omb_prompt_reset_color}" SCM_THEME_PROMPT_DIRTY=" ${_omb_prompt_brown}✗${_omb_prompt_reset_color}" SCM_THEME_PROMPT_CLEAN=" ${_omb_prompt_bold_green}✓${_omb_prompt_normal}" DULCIE_SCM_BACKGROUND="${background_scm}" DULCIE_SCM_DIR_COLOR="${color_rootdir}" SCM_THEME_ROOT_SUFFIX="${_omb_prompt_reset_color}${SCM_THEME_ROOT_SUFFIX}" SCM_THEME_PROMPT_DIRTY=" $(dulcie_color 1)✗${_omb_prompt_reset_color}" SCM_THEME_PROMPT_CLEAN=" $(dulcie_color 10)✓${_omb_prompt_reset_color}" else DULCIE_USER='\u' DULCIE_HOST='\h' DULCIE_WORKINGDIR='\W' DULCIE_PROMPTCHAR='\$' DULCIE_SCM_BACKGROUND="" DULCIE_SCM_DIR_COLOR="" SCM_THEME_DIR_COLOR="" SCM_THEME_PROMPT_DIRTY=" ✗" SCM_THEME_PROMPT_CLEAN=" ✓" fi # Change terminal title printf "\033]0;%s@%s:%s\007" "${USER}" "${HOSTNAME%%.*}" "${PWD/#$HOME/\~}" # Open the new terminal in the same directory _omb_util_function_exists __vte_osc7 && __vte_osc7 PS1="${_omb_prompt_reset_color}[${DULCIE_USER}@${DULCIE_HOST}$(scm_prompt_info)${_omb_prompt_reset_color} ${DULCIE_WORKINGDIR}]" if [[ "${DULCIE_MULTILINE}" -eq "1" ]]; then PS1="${_omb_prompt_reset_color}[${DULCIE_USER}@${DULCIE_HOST}${_omb_prompt_reset_color} ${DULCIE_WORKINGDIR}]" if [[ "$(scm_prompt_info)" ]]; then SCM_THEME_PROMPT_PREFIX="${DULCIE_SCM_BACKGROUND}|${DULCIE_SCM_DIR_COLOR}" SCM_THEME_PROMPT_SUFFIX="|${_omb_prompt_normal}" PS1="$(scm_prompt_info)\n${PS1}" fi else SCM_THEME_PROMPT_PREFIX=" ${DULCIE_SCM_BACKGROUND}|${DULCIE_SCM_DIR_COLOR}" SCM_THEME_PROMPT_SUFFIX="|${_omb_prompt_normal}" PS1="${_omb_prompt_reset_color}[${DULCIE_USER}@${DULCIE_HOST}$(scm_prompt_info)${_omb_prompt_reset_color} ${DULCIE_WORKINGDIR}]" fi PS1="${PS1}${DULCIE_PROMPTCHAR} " } _omb_util_add_prompt_command _omb_theme_PROMPT_COMMAND ================================================ FILE: themes/duru/duru.theme.sh ================================================ #! bash oh-my-bash.module SCM_THEME_PROMPT_PREFIX="${_omb_prompt_teal} on ${_omb_prompt_green}" SCM_THEME_PROMPT_SUFFIX="" SCM_THEME_PROMPT_DIRTY=" ${_omb_prompt_brown}with changes" SCM_THEME_PROMPT_CLEAN="" function venv { if [ -n "$VIRTUAL_ENV" ] then local env=$VIRTUAL_ENV _omb_util_print "${gray} in ${_omb_prompt_red}${env##*/} " fi } function last_two_dirs { pwd|rev|awk -F / '{print $1,$2}'|rev|sed s_\ _/_|sed "s|$(sed 's,\/,,'<<<"$HOME")|~|g" } function _omb_theme_PROMPT_COMMAND { PS1="${_omb_prompt_olive}# ${_omb_prompt_reset_color}$(last_two_dirs)$(scm_prompt_info)${_omb_prompt_reset_color}$(venv)${_omb_prompt_reset_color} ${_omb_prompt_teal}\n> ${_omb_prompt_reset_color}" } _omb_util_add_prompt_command _omb_theme_PROMPT_COMMAND ================================================ FILE: themes/edsonarios/edsonarios.theme.sh ================================================ #! bash oh-my-bash.module # If you want the same background color that the screenshot, modify the # background option in your terminal with the code: #333333 # For unstaged(*) and staged(+) values next to branch name in __git_ps1 GIT_PS1_SHOWDIRTYSTATE="enabled" OMB_PROMPT_VIRTUALENV_FORMAT=' [%s]' OMB_PROMPT_CONDAENV_FORMAT=' [%s]' OMB_THEME_EDSONARIOS_STATUS_BAD="${_omb_prompt_bold_brown}❯_${_omb_prompt_normal} " OMB_THEME_EDSONARIOS_STATUS_OK="${_omb_prompt_bold_green}❯_${_omb_prompt_normal} " function _omb_theme_PROMPT_COMMAND { if (($? == 0)); then local ret_status=${OMB_THEME_EDSONARIOS_STATUS_OK-} else local ret_status=${OMB_THEME_EDSONARIOS_STATUS_BAD-} fi # If the current directory is the same as HOME, will just show "~/". If not, # show the complete route unlike \w. if [[ $PWD == "$HOME" ]]; then local directory='\W/' else local directory="$PWD/" fi local python_venv _omb_prompt_get_python_venv PS1="\n⚡ \t $_omb_prompt_bold_teal${directory}$_omb_prompt_bold_purple$python_venv$_omb_prompt_bold_green$(__git_ps1 " (%s)") \n${ret_status}" } _omb_util_add_prompt_command _omb_theme_PROMPT_COMMAND ================================================ FILE: themes/emperor/emperor.theme.sh ================================================ #! bash oh-my-bash.module SCM_THEME_PROMPT_DIRTY=" ${_omb_prompt_brown}✗" SCM_THEME_PROMPT_CLEAN=" ${_omb_prompt_bold_green}✓" SCM_THEME_PROMPT_PREFIX=" |" SCM_THEME_PROMPT_SUFFIX="${_omb_prompt_green}|" GIT_THEME_PROMPT_DIRTY=" ${_omb_prompt_brown}✗" GIT_THEME_PROMPT_CLEAN=" ${_omb_prompt_bold_green}✓" GIT_THEME_PROMPT_PREFIX=" ${_omb_prompt_green}|" GIT_THEME_PROMPT_SUFFIX="${_omb_prompt_green}|" RVM_THEME_PROMPT_PREFIX="|" RVM_THEME_PROMPT_SUFFIX="|" function get_hour_color { hour_color=$_omb_prompt_brown min=$(date +%M) if [ "$min" -lt "15" ]; then hour_color=$_omb_prompt_white elif [ "$min" -lt "30" ]; then hour_color=$_omb_prompt_green elif [ "$min" -lt "45" ]; then hour_color=$_omb_prompt_olive else hour_color=$_omb_prompt_brown fi _omb_util_print "$hour_color" } function __emperor_clock { THEME_CLOCK_COLOR=$(get_hour_color) clock_prompt } function _omb_theme_PROMPT_COMMAND() { PS1="\n$(__emperor_clock)${_omb_prompt_purple}\h ${_omb_prompt_reset_color}in ${prompt_color}\w\n${_omb_prompt_bold_teal}$(scm_char)${_omb_prompt_green}$(scm_prompt_info) ${_omb_prompt_green}→${_omb_prompt_reset_color} " } THEME_CLOCK_FORMAT=${THEME_CLOCK_FORMAT:-"%H "} _omb_util_add_prompt_command _omb_theme_PROMPT_COMMAND ================================================ FILE: themes/envy/envy.theme.sh ================================================ #! bash oh-my-bash.module SCM_THEME_PROMPT_DIRTY=" ${_omb_prompt_brown}✗" SCM_THEME_PROMPT_CLEAN=" ${_omb_prompt_bold_green}✓" SCM_THEME_PROMPT_PREFIX=" |" SCM_THEME_PROMPT_SUFFIX="${_omb_prompt_green}|" GIT_THEME_PROMPT_DIRTY=" ${_omb_prompt_brown}✗" GIT_THEME_PROMPT_CLEAN=" ${_omb_prompt_bold_green}✓" GIT_THEME_PROMPT_PREFIX=" ${_omb_prompt_green}|" GIT_THEME_PROMPT_SUFFIX="${_omb_prompt_green}|" function _omb_theme_PROMPT_COMMAND() { PS1="\n${_omb_prompt_olive}$(_omb_prompt_print_ruby_env) ${_omb_prompt_purple}\h ${_omb_prompt_reset_color}in ${_omb_prompt_green}\w\n${_omb_prompt_bold_teal}$(scm_char)${_omb_prompt_green}$(scm_prompt_info) ${_omb_prompt_green}→${_omb_prompt_reset_color} " } _omb_util_add_prompt_command _omb_theme_PROMPT_COMMAND ================================================ FILE: themes/font/font.theme.sh ================================================ #! bash oh-my-bash.module # # One line prompt showing the following configurable information # for git: # time (virtual_env) username@hostname pwd git_char|git_branch git_dirty_status|→ # # The → arrow shows the exit status of the last command: # - bold green: 0 exit status # - bold red: non-zero exit status # # Example outside git repo: # 07:45:05 user@host ~ → # # Example inside clean git repo: # 07:45:05 user@host .oh-my-bash ±|master|→ # # Example inside dirty git repo: # 07:45:05 user@host .oh-my-bash ±|master ✗|→ # # Example with virtual environment: # 07:45:05 (venv) user@host ~ → # SCM_NONE_CHAR='' SCM_THEME_PROMPT_DIRTY=" ${_omb_prompt_brown}✗" SCM_THEME_PROMPT_CLEAN="" SCM_THEME_PROMPT_PREFIX="${_omb_prompt_green}|" SCM_THEME_PROMPT_SUFFIX="${_omb_prompt_green}|" SCM_GIT_SHOW_MINIMAL_INFO=true CLOCK_THEME_PROMPT_PREFIX='' CLOCK_THEME_PROMPT_SUFFIX=' ' THEME_SHOW_CLOCK=${THEME_SHOW_CLOCK:-"true"} THEME_CLOCK_COLOR=${THEME_CLOCK_COLOR:-"$_omb_prompt_bold_navy"} THEME_CLOCK_FORMAT=${THEME_CLOCK_FORMAT:-"%I:%M:%S"} OMB_PROMPT_VIRTUALENV_FORMAT='(%s) ' OMB_PROMPT_CONDAENV_FORMAT='(%s) ' OMB_PROMPT_SHOW_PYTHON_VENV=${OMB_PROMPT_SHOW_PYTHON_VENV:=true} function _omb_theme_PROMPT_COMMAND() { # This needs to be first to save last command return code local RC="$?" local hostname="${_omb_prompt_bold_gray}\u@\h" local python_venv; _omb_prompt_get_python_venv python_venv=$_omb_prompt_white$python_venv local spack_env; _omb_prompt_get_spack_env spack_env=$_omb_prompt_white$spack_env # Set return status color if [[ ${RC} == 0 ]]; then ret_status="${_omb_prompt_bold_green}" else ret_status="${_omb_prompt_bold_brown}" fi # Append new history lines to history file history -a PS1="$(clock_prompt)$spack_env$python_venv${hostname} ${_omb_prompt_bold_teal}\W $(scm_prompt_char_info)${ret_status}→ ${_omb_prompt_normal}" } _omb_util_add_prompt_command _omb_theme_PROMPT_COMMAND ================================================ FILE: themes/gallifrey/gallifrey.theme.sh ================================================ #! bash oh-my-bash.module # scm theming SCM_THEME_PROMPT_PREFIX="${_omb_prompt_olive}(" SCM_THEME_PROMPT_SUFFIX=")${_omb_prompt_normal}" SCM_THEME_PROMPT_DIRTY="*" SCM_THEME_PROMPT_CLEAN="" SCM_GIT_CHAR="g" SCM_SVN_CHAR="s" SCM_HG_CHAR="h" ### TODO: openSUSE has already colors enabled, check if those differs from stock # LS colors, made with http://geoff.greer.fm/lscolors/ # export LSCOLORS="Gxfxcxdxbxegedabagacad" # export LS_COLORS='no=00:fi=00:di=01;34:ln=00;36:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=41;33;01:ex=00;32:*.cmd=00;32:*.exe=01;32:*.com=01;32:*.bat=01;32:*.btm=01;32:*.dll=01;32:*.tar=00;31:*.tbz=00;31:*.tgz=00;31:*.rpm=00;31:*.deb=00;31:*.arj=00;31:*.taz=00;31:*.lzh=00;31:*.lzma=00;31:*.zip=00;31:*.zoo=00;31:*.z=00;31:*.Z=00;31:*.gz=00;31:*.bz2=00;31:*.tb2=00;31:*.tz2=00;31:*.tbz2=00;31:*.avi=01;35:*.bmp=01;35:*.fli=01;35:*.gif=01;35:*.jpg=01;35:*.jpeg=01;35:*.mng=01;35:*.mov=01;35:*.mpg=01;35:*.pcx=01;35:*.pbm=01;35:*.pgm=01;35:*.png=01;35:*.ppm=01;35:*.tga=01;35:*.tif=01;35:*.xbm=01;35:*.xpm=01;35:*.dl=01;35:*.gl=01;35:*.wmv=01;35:*.aiff=00;32:*.au=00;32:*.mid=00;32:*.mp3=00;32:*.ogg=00;32:*.voc=00;32:*.wav=00;32:' function scm_prompt { CHAR=$(scm_char) if [ $CHAR = $SCM_NONE_CHAR ] then return else _omb_util_print "$(scm_prompt_info) " fi } function _omb_theme_PROMPT_COMMAND { ps_host="${_omb_prompt_green}\h${_omb_prompt_normal}"; ps_user_mark="${_omb_prompt_bold}\$${_omb_prompt_normal}"; ps_root_mark="${_omb_prompt_normal}§" ps_path="${_omb_prompt_normal}\w"; # make it work case $(id -u) in 0) PS1="$ps_host $ps_path $(scm_prompt)$ps_root_mark " ;; *) PS1="$ps_host $ps_path $(scm_prompt)$ps_user_mark " ;; esac } _omb_util_add_prompt_command _omb_theme_PROMPT_COMMAND ================================================ FILE: themes/garo/garo.theme.sh ================================================ #! bash oh-my-bash.module # # One line prompt showing the following configurable information # for git: # (virtual_env) username pwd git_char|git_branch git_dirty_status|→ # # The → arrow shows the exit status of the last command: # - bold green: 0 exit status # - bold red: non-zero exit status # # Example outside git repo: # 07:45:05 user@host ~ → # # Example inside clean git repo: # 07:45:05 user@host ~/.oh-my-bash ±|master|→ # # Example inside dirty git repo: # 07:45:05 user@host ~/.oh-my-bash ±|master ✗|→ # # Example with virtual environment: # 07:45:05 (venv) user@host ~ → # SCM_NONE_CHAR='' SCM_THEME_PROMPT_DIRTY=" ${_omb_prompt_brown}✗" SCM_THEME_PROMPT_CLEAN="" SCM_THEME_PROMPT_PREFIX="${_omb_prompt_green}|" SCM_THEME_PROMPT_SUFFIX="${_omb_prompt_green}|" SCM_GIT_SHOW_MINIMAL_INFO=true OMB_PROMPT_VIRTUALENV_FORMAT='(%s) ' OMB_PROMPT_SHOW_PYTHON_VENV=${OMB_PROMPT_SHOW_PYTHON_VENV:=true} function _omb_theme_PROMPT_COMMAND() { # This needs to be first to save last command return code local RC="$?" local hostname="${_omb_prompt_bold_gray}\u" local python_venv; _omb_prompt_get_python_venv python_venv=$_omb_prompt_white$python_venv # Set return status color if [[ ${RC} == 0 ]]; then ret_status="${_omb_prompt_bold_green}" else ret_status="${_omb_prompt_bold_brown}" fi # Append new history lines to history file history -a PS1="$python_venv${hostname} ${_omb_prompt_bold_teal}\w $(scm_prompt_char_info)${ret_status}→ ${_omb_prompt_normal}" } _omb_util_add_prompt_command _omb_theme_PROMPT_COMMAND ================================================ FILE: themes/half-life/half-life.theme.sh ================================================ #! bash oh-my-bash.module OSH_THEME_GIT_PROMPT_DIRTY="✗" OSH_THEME_GIT_PROMPT_CLEAN="✓" # Nicely formatted terminal prompt function _omb_theme_half_way_prompt_scm { local CHAR=$(scm_char) if [[ $CHAR != "$SCM_NONE_CHAR" ]]; then printf '%s' " on ${_omb_prompt_navy}$(git_current_branch)$(parse_git_dirty)${_omb_prompt_normal} " fi } function _omb_theme_PROMPT_COMMAND { local ps_username="${_omb_prompt_purple}\u${_omb_prompt_normal}" local ps_path="${_omb_prompt_green}\w${_omb_prompt_normal}" local ps_user_mark="${_omb_prompt_red}λ${_omb_prompt_normal}" local python_venv _omb_prompt_get_python_venv PS1="$ps_username in $python_venv$ps_path$(_omb_theme_half_way_prompt_scm) $ps_user_mark " } OMB_PROMPT_SHOW_PYTHON_VENV=${OMB_PROMPT_SHOW_PYTHON_VENV:-false} OMB_PROMPT_VIRTUALENV_FORMAT="${_omb_prompt_olive}(%s)${_omb_prompt_reset_color} " _omb_util_add_prompt_command _omb_theme_PROMPT_COMMAND ================================================ FILE: themes/hawaii50/hawaii50.theme.sh ================================================ #! bash oh-my-bash.module # # This theme was obviously inspired a lot by # # - Demula theme # # which in itself was inspired by : # # - Ronacher's dotfiles (mitsuhikos) - http://github.com/mitsuhiko/dotfiles/tree/master/bash/ # - Glenbot - http://theglenbot.com/custom-bash-shell-for-development/ # - My extravagant zsh - http://stevelosh.com/blog/2010/02/my-extravagant-zsh-prompt/ # - Monokai colors - http://monokai.nl/blog/2006/07/15/textmate-color-theme/ # - Bash_it modern theme # # Hawaii50 theme supports : # # - configurable directory length # - hg, svn, git detection (I work in all of them) # - virtualenv, rvm + gemsets # # Screenshot: http://i.imgur.com/4IAMJ.png # # by Ryan Kanno # # And yes, we code out in Hawaii. :D # # Note: I also am really new to this bash scripting game, so if you see things # that are flat out wrong, or if you think of something neat, just send a pull # request. This probably only works on a Mac - as some functions are OS # specific like getting ip, etc. # # IMPORTANT THINGS TO CHANGE ================================================== # Show IP in prompt # One thing to be weary about if you have slow Internets IP_ENABLED=1 # virtual prompts VIRTUAL_PROMPT_ENABLED=1 # COLORS ====================================================================== ORANGE='\[\e[0;33m\]' DEFAULT_COLOR="${_omb_prompt_white}" USER_COLOR="${_omb_prompt_purple}" SUPERUSER_COLOR="${_omb_prompt_brown}" MACHINE_COLOR=$ORANGE IP_COLOR=$ORANGE DIRECTORY_COLOR="${_omb_prompt_green}" VE_COLOR="${_omb_prompt_teal}" RVM_COLOR="${_omb_prompt_teal}" REF_COLOR="${_omb_prompt_purple}" # SCM prompts SCM_THEME_PROMPT_DIRTY=" ${_omb_prompt_bold_brown}✗${_omb_prompt_normal}" SCM_THEME_PROMPT_CLEAN=" ${_omb_prompt_bold_green}✓${_omb_prompt_normal}" SCM_THEME_PROMPT_PREFIX=' on ' SCM_THEME_PROMPT_SUFFIX='' # rvm prompts RVM_THEME_PROMPT_PREFIX='' RVM_THEME_PROMPT_SUFFIX='' # virtualenv prompts OMB_PROMPT_VIRTUALENV_FORMAT='%s' OMB_PROMPT_SHOW_PYTHON_VENV=${OMB_PROMPT_SHOW_PYTHON_VENV:=true} VIRTUAL_THEME_PROMPT_PREFIX=' using ' VIRTUAL_THEME_PROMPT_SUFFIX='' # Max length of PWD to display MAX_PWD_LENGTH=20 # Max length of Git Hex to display MAX_GIT_HEX_LENGTH=5 # IP address IP_SEPARATOR=', ' # FUNCS ======================================================================= function get_ip_info { local myip=$(curl -s checkip.dyndns.org | grep -Eo '[0-9\.]+') echo -e "$(ips | sed -e :a -e '$!N;s/\n/${IP_SEPARATOR}/;ta' | sed -e 's/127\.0\.0\.1\${IP_SEPARATOR}//g'), ${myip}" } # Displays ip prompt function ip_prompt_info() { if [[ $IP_ENABLED == 1 ]]; then echo -e " ${DEFAULT_COLOR}(${IP_COLOR}$(get_ip_info)${DEFAULT_COLOR})" fi } # Displays virtual info prompt (virtualenv/rvm) function virtual_prompt_info() { local python_venv; _omb_prompt_get_python_venv local ruby_env; _omb_prompt_get_ruby_env local virtual_prompt="" local prefix=${VIRTUAL_THEME_PROMPT_PREFIX} local suffix=${VIRTUAL_THEME_PROMPT_SUFFIX} # If no virtual info, just return [[ $python_venv$ruby_env ]] || return # If virtual_env info present, append to prompt [[ $python_venv ]] && virtual_prompt="virtualenv: ${VE_COLOR}$python_venv${DEFAULT_COLOR}" if [[ $ruby_env ]]; then virtual_prompt="${virtual_prompt:+$virtual_prompt, }rvm: ${RVM_COLOR}$ruby_env${DEFAULT_COLOR}" fi echo -e "$prefix$virtual_prompt$suffix" } # Parse git info function git_prompt_info() { if [[ -n $(_omb_prompt_git status -s 2> /dev/null |grep -v ^# |grep -v "working directory clean") ]]; then local state=${GIT_THEME_PROMPT_DIRTY:-$SCM_THEME_PROMPT_DIRTY} else local state=${GIT_THEME_PROMPT_CLEAN:-$SCM_THEME_PROMPT_CLEAN} fi local prefix=${GIT_THEME_PROMPT_PREFIX:-$SCM_THEME_PROMPT_PREFIX} local suffix=${GIT_THEME_PROMPT_SUFFIX:-$SCM_THEME_PROMPT_SUFFIX} local ref=$(_omb_prompt_git symbolic-ref HEAD 2> /dev/null) || return local commit_id=$(_omb_prompt_git rev-parse HEAD 2>/dev/null) || return echo -e "$prefix${REF_COLOR}${ref#refs/heads/}${DEFAULT_COLOR}:${commit_id:0:$MAX_GIT_HEX_LENGTH}$state$suffix" } # Parse hg info function hg_prompt_info() { if [[ -n $(command hg status 2> /dev/null) ]]; then local state=${HG_THEME_PROMPT_DIRTY:-$SCM_THEME_PROMPT_DIRTY} else local state=${HG_THEME_PROMPT_CLEAN:-$SCM_THEME_PROMPT_CLEAN} fi local prefix=${HG_THEME_PROMPT_PREFIX:-$SCM_THEME_PROMPT_PREFIX} local suffix=${HG_THEME_PROMPT_SUFFIX:-$SCM_THEME_PROMPT_SUFFIX} local branch=$(command hg summary 2> /dev/null | grep branch | awk '{print $2}') local changeset=$(command hg summary 2> /dev/null | grep parent | awk '{print $2}') echo -e "$prefix${REF_COLOR}${branch}${DEFAULT_COLOR}:${changeset#*:}$state$suffix" } # Parse svn info function svn_prompt_info() { if [[ -n $(command svn status --ignore-externals -q 2> /dev/null) ]]; then local state=${SVN_THEME_PROMPT_DIRTY:-$SCM_THEME_PROMPT_DIRTY} else local state=${SVN_THEME_PROMPT_CLEAN:-$SCM_THEME_PROMPT_CLEAN} fi local prefix=${SVN_THEME_PROMPT_PREFIX:-$SCM_THEME_PROMPT_PREFIX} local suffix=${SVN_THEME_PROMPT_SUFFIX:-$SCM_THEME_PROMPT_SUFFIX} local ref=$(command svn info 2> /dev/null | awk -F/ '/^URL:/ { for (i=0; i<=NF; i++) { if ($i == "branches" || $i == "tags" ) { print $(i+1); break }; if ($i == "trunk") { print $i; break } } }') || return [[ -z $ref ]] && return local revision=$(command svn info 2> /dev/null | sed -ne 's#^Revision: ##p' ) echo -e "$prefix${REF_COLOR}$ref${DEFAULT_COLOR}:$revision$state$suffix" } # Displays last X characters of pwd function limited_pwd() { # Replace $HOME with ~ if possible local RELATIVE_PWD=${PWD/#$HOME/\~} local offset=$((${#RELATIVE_PWD}-MAX_PWD_LENGTH)) if ((offset > 0)); then local truncated_symbol="..." local TRUNCATED_PWD=${RELATIVE_PWD:$offset:$MAX_PWD_LENGTH} echo -e "${truncated_symbol}/${TRUNCATED_PWD#*/}" else echo -e "${RELATIVE_PWD}" fi } # Displays the current prompt function _omb_theme_PROMPT_COMMAND() { local UC=$USER_COLOR ((UID == 0)) && UC=$SUPERUSER_COLOR if [[ $VIRTUAL_PROMPT_ENABLED == 1 ]]; then PS1="$(scm_char) ${UC}\u ${DEFAULT_COLOR}at ${MACHINE_COLOR}\h$(ip_prompt_info) ${DEFAULT_COLOR}in ${DIRECTORY_COLOR}$(limited_pwd)${DEFAULT_COLOR}$(virtual_prompt_info)$(scm_prompt_info)${_omb_prompt_reset_color} \$ " else PS1="$(scm_char) ${UC}\u ${DEFAULT_COLOR}at ${MACHINE_COLOR}\h$(ip_prompt_info) ${DEFAULT_COLOR}in ${DIRECTORY_COLOR}$(limited_pwd)${DEFAULT_COLOR}$(scm_prompt_info)${_omb_prompt_reset_color} \$ " fi PS2='> ' PS4='+ ' } _omb_util_add_prompt_command _omb_theme_PROMPT_COMMAND ================================================ FILE: themes/ht/ht.theme.sh ================================================ #! bash oh-my-bash.module # Harrison's Theme (ht) # Description: # Simple prompt that shows basic working directory and exit code info # Works with 8 color terminals # Example prompt: # ● [harrison@ubN2] in src ± |dev ✗| # OMB SCM Prompt overrides SCM_GIT_SHOW_MINIMAL_INFO="true" SCM_THEME_PROMPT_DIRTY=" ${_omb_prompt_red}✗${_omb_prompt_normal}" SCM_THEME_PROMPT_CLEAN=" ${_omb_prompt_green}✓${_omb_prompt_normal}" SCM_NONE_CHAR="" function _omb_theme_ht_exit_color { case $1 in 0) _omb_util_print "$_omb_prompt_green" ;; 1) _omb_util_print "$_omb_prompt_red" ;; 2) _omb_util_print "$_omb_prompt_gray" ;; 126) _omb_util_print "$_omb_prompt_cyan" ;; 127) _omb_util_print "$_omb_prompt_magenta" ;; 130) _omb_util_print "$_omb_prompt_black" ;; 148) _omb_util_print "$_omb_prompt_yellow" ;; *) _omb_util_print "$_omb_prompt_blue" ;; esac } # Displays the current prompt function _omb_theme_PROMPT_COMMAND { # Capture exit code # NOTE: DO NOT MOVE local EXIT_CODE=$? # Start prompt blank PS1="" # Exit code indicator PS1+="$(_omb_theme_ht_exit_color "$EXIT_CODE")●$_omb_prompt_reset_color" # Environment info local rbenv virtualenv _omb_prompt_get_rbenv && PS1+=$_omb_prompt_red$rbenv$_omb_prompt_reset_color _omb_prompt_get_virtualenv && PS1+=$_omb_prompt_green$virtualenv$_omb_prompt_reset_color # User and host local user_host_prefix=" $_omb_prompt_reset_color[" local user_host_suffix="$_omb_prompt_reset_color]" local user="$_omb_prompt_blue\u" local host="$_omb_prompt_cyan\H" local at="$_omb_prompt_reset_color@" PS1+="$user_host_prefix$user$at$host$user_host_suffix" # Working directory PS1+=" in $_omb_prompt_magenta\W$_omb_prompt_reset_color" # SCM PS1+=" $(scm_prompt_char_info)" # End prompt PS1+="\n${_omb_prompt_green}➜ $_omb_prompt_normal" } # Runs prompt (this bypasses oh-my-bash $PROMPT setting) _omb_util_add_prompt_command _omb_theme_PROMPT_COMMAND ================================================ FILE: themes/iterate/iterate.theme.sh ================================================ #! bash oh-my-bash.module SCM_GIT_CHAR="± " SCM_HG_CHAR="☿ " SCM_SVN_CHAR="⑆ " SCM_NONE_CHAR="" SCM_THEME_PROMPT_DIRTY=" ${_omb_prompt_brown}✗" SCM_THEME_PROMPT_CLEAN=" ${_omb_prompt_bold_green}✓" SCM_THEME_PROMPT_PREFIX="|" SCM_THEME_PROMPT_SUFFIX="${_omb_prompt_green}| " SCM_GIT_AHEAD_CHAR="${_omb_prompt_green}+" SCM_GIT_BEHIND_CHAR="${_omb_prompt_brown}-" GIT_THEME_PROMPT_DIRTY=" ${_omb_prompt_bold_brown}✗" GIT_THEME_PROMPT_CLEAN=" ${_omb_prompt_bold_green}✓" GIT_THEME_PROMPT_PREFIX="${_omb_prompt_teal}|" GIT_THEME_PROMPT_SUFFIX="${_omb_prompt_teal}| " RVM_THEME_PROMPT_PREFIX="|" RVM_THEME_PROMPT_SUFFIX="| " VIRTUALENV_THEME_PROMPT_PREFIX="|" VIRTUALENV_THEME_PROMPT_SUFFIX="| " RBENV_THEME_PROMPT_PREFIX="|" RBENV_THEME_PROMPT_SUFFIX="| " RBFU_THEME_PROMPT_PREFIX="|" RBFU_THEME_PROMPT_SUFFIX="| " function git_prompt_info { git_prompt_vars echo -e "$SCM_PREFIX$SCM_BRANCH$SCM_STATE$SCM_GIT_AHEAD$SCM_GIT_BEHIND$SCM_GIT_STASH$SCM_SUFFIX" } LAST_PROMPT="" function _omb_theme_PROMPT_COMMAND() { local new_PS1="${_omb_prompt_bold_teal}$(scm_char)${_omb_prompt_olive}$(_omb_prompt_print_ruby_env)${_omb_prompt_green}\w $(scm_prompt_info)" local new_prompt=$(PS1="$new_PS1" "$BASH" --norc -i &1 | sed -n '${s/^\(.*\)exit$/\1/p;}') if [ "$LAST_PROMPT" = "$new_prompt" ]; then new_PS1="" else LAST_PROMPT="$new_prompt" fi local wrap_char="" [[ ${#new_PS1} -gt $(($COLUMNS/1)) ]] && wrap_char="\n" PS1="${new_PS1}${_omb_prompt_green}${wrap_char}→${_omb_prompt_reset_color} " } _omb_util_add_prompt_command _omb_theme_PROMPT_COMMAND ================================================ FILE: themes/kitsune/kitsune.theme.sh ================================================ #! bash oh-my-bash.module # This is combination of works from two different people which I combined for my requirement. # Original PS1 was from reddit user /u/Allevil669 which I found in thread: https://www.reddit.com/r/linux/comments/1z33lj/linux_users_whats_your_favourite_bash_prompt/ # I used that PS1 to the bash-it theme 'morris', and customized it to my liking. All credits to /u/Allevil669 and morris. # # prompt theming _omb_module_require plugin:battery function _omb_theme_PROMPT_COMMAND() { local status=$? # added TITLEBAR for updating the tab and window titles with the pwd local TITLEBAR case $TERM in xterm* | screen) TITLEBAR=$'\1\e]0;'$USER@${HOSTNAME%%.*}:${PWD/#$HOME/~}$'\e\\\2' ;; *) TITLEBAR= ;; esac local SC if ((status == 0)); then SC="$_omb_prompt_teal-$_omb_prompt_bold_green(${_omb_prompt_green}^_^$_omb_prompt_bold_green)"; else SC="$_omb_prompt_teal-$_omb_prompt_bold_green(${_omb_prompt_brown}T_T$_omb_prompt_bold_green)"; fi local BC=$(battery_percentage) [[ $BC == no && $BC == -1 ]] && BC= BC=${BC:+${_omb_prompt_teal}-${_omb_prompt_green}($BC%)} local python_venv _omb_prompt_get_python_venv PS1=$TITLEBAR"\n${_omb_prompt_teal}┌─${_omb_prompt_bold_white}[\u@\h]${_omb_prompt_teal}─${_omb_prompt_bold_olive}(\w)$(scm_prompt_info)$python_venv\n${_omb_prompt_teal}└─${_omb_prompt_bold_green}[\A]$SC$BC${_omb_prompt_teal}-${_omb_prompt_bold_teal}[${_omb_prompt_green}${_omb_prompt_bold_green}\$${_omb_prompt_bold_teal}]${_omb_prompt_green} " } # scm theming SCM_THEME_PROMPT_DIRTY=" ${_omb_prompt_brown}✗" SCM_THEME_PROMPT_CLEAN=" ${_omb_prompt_bold_green}✓" SCM_THEME_PROMPT_PREFIX="${_omb_prompt_bold_teal}(" SCM_THEME_PROMPT_SUFFIX="${_omb_prompt_bold_teal})${_omb_prompt_reset_color}" OMB_PROMPT_SHOW_PYTHON_VENV=${OMB_PROMPT_SHOW_PYTHON_VENV:-false} OMB_PROMPT_VIRTUALENV_FORMAT="${_omb_prompt_bold_gray}(%s)${_omb_prompt_reset_color}" OMB_PROMPT_CONDAENV_FORMAT="${_omb_prompt_bold_gray}(%s)${_omb_prompt_reset_color}" _omb_util_add_prompt_command _omb_theme_PROMPT_COMMAND ================================================ FILE: themes/lambda/lambda.theme.sh ================================================ #! bash oh-my-bash.module # Emoji-based theme to display source control management and # virtual environment info beside the ordinary bash prompt. # Theme inspired by: # - Bash_it cupcake theme # Demo: # ╭─ⓔ virtualenv 💁user at 💻 host in 📁directory on (🌿branch {1} ↑1 ↓1 +1 •1 ⌀1 ✗) # ╰λ cd .bash-it/themes/lambda # virtualenv prompts VIRTUALENV_CHAR="ⓔ " OMB_PROMPT_VIRTUALENV_FORMAT='%s' OMB_PROMPT_SHOW_PYTHON_VENV=${OMB_PROMPT_SHOW_PYTHON_VENV:=true} # SCM prompts SCM_NONE_CHAR="" SCM_GIT_CHAR="[±] " SCM_GIT_BEHIND_CHAR="${_omb_prompt_brown}↓${_omb_prompt_normal}" SCM_GIT_AHEAD_CHAR="${_omb_prompt_bold_green}↑${_omb_prompt_normal}" SCM_GIT_UNTRACKED_CHAR="⌀" SCM_GIT_UNSTAGED_CHAR="${_omb_prompt_bold_olive}•${_omb_prompt_normal}" SCM_GIT_STAGED_CHAR="${_omb_prompt_bold_green}+${_omb_prompt_normal}" SCM_THEME_PROMPT_DIRTY="" SCM_THEME_PROMPT_CLEAN="" SCM_THEME_PROMPT_PREFIX="" SCM_THEME_PROMPT_SUFFIX=")" # Git status prompts GIT_THEME_PROMPT_DIRTY=" ${_omb_prompt_brown}✗${_omb_prompt_normal}" GIT_THEME_PROMPT_CLEAN=" ${_omb_prompt_bold_green}✓${_omb_prompt_normal}" GIT_THEME_PROMPT_PREFIX="" GIT_THEME_PROMPT_SUFFIX="" # ICONS ======================================================================= icon_start="╭─" icon_user=" 💁 " icon_host=" at 💻 " icon_directory=" in 📁 " icon_branch="🌿" icon_end="╰λ " # extra spaces ensure legiblity in prompt # FUNCTIONS =================================================================== # Rename tab function tabname { printf '\e]1;%s\a' "$1" } # Rename window function winname { printf '\e]2;%s\a' "$1" } # PROMPT OUTPUT =============================================================== # Displays the current prompt function _omb_theme_PROMPT_COMMAND() { PS1=$icon_start$(_omb_prompt_print_python_venv) PS1+=$icon_user$_omb_prompt_bold_brown'\u' PS1+=$_omb_prompt_normal$icon_host$_omb_prompt_bold_teal'\h' PS1+=$_omb_prompt_normal$icon_directory$_omb_prompt_bold_purple'\w' PS1+=$_omb_prompt_normal$([[ -n $(_omb_prompt_git branch 2> /dev/null) ]] && _omb_util_print " on (${icon_branch} ") PS1+=$_omb_prompt_white$(scm_prompt_info)$_omb_prompt_normal'\n'$icon_end PS2=$icon_end } # Runs prompt (this bypasses oh-my-bash $PROMPT setting) _omb_util_add_prompt_command _omb_theme_PROMPT_COMMAND ================================================ FILE: themes/luan/luan.theme.sh ================================================ #! bash oh-my-bash.module SCM_THEME_PROMPT_DIRTY=" ${_omb_prompt_brown}✗" SCM_THEME_PROMPT_CLEAN=" ${_omb_prompt_bold_green}✓" SCM_THEME_PROMPT_PREFIX="(${_omb_prompt_olive}" SCM_THEME_PROMPT_SUFFIX="${_omb_prompt_normal})" GIT_THEME_PROMPT_DIRTY=" ${_omb_prompt_brown}✗" GIT_THEME_PROMPT_CLEAN=" ${_omb_prompt_bold_green}✓" GIT_THEME_PROMPT_PREFIX="(${_omb_prompt_olive}" GIT_THEME_PROMPT_SUFFIX="${_omb_prompt_normal})" OMB_PROMPT_RVM_FORMAT="%s" OMB_PROMPT_VIRTUALENV_FORMAT='(%s) ' OMB_PROMPT_SHOW_PYTHON_VENV=${OMB_PROMPT_SHOW_PYTHON_VENV:=false} function _omb_theme_PROMPT_COMMAND() { local dtime="$(clock_prompt)" local user_host="${_omb_prompt_green}\u@${_omb_prompt_teal}\h${_omb_prompt_normal}" local current_dir="${_omb_prompt_bold_navy}\w${_omb_prompt_normal}" local ruby_env python_venv _omb_prompt_get_ruby_env && ruby_env="$_omb_prompt_bold_brown$ruby_env$_omb_prompt_normal " _omb_prompt_get_python_venv local git_branch="$(scm_prompt_info)${_omb_prompt_normal}" local prompt="${_omb_prompt_bold_green}\$${_omb_prompt_normal} " local arrow="${_omb_prompt_bold_white}▶${_omb_prompt_normal} " local prompt="${_omb_prompt_bold_green}\$${_omb_prompt_normal} " PS1="${dtime}${user_host}:${current_dir} ${python_venv}${ruby_env}${git_branch} $arrow $prompt" } THEME_CLOCK_COLOR=${THEME_CLOCK_COLOR:-"$_omb_prompt_olive"} THEME_CLOCK_FORMAT=${THEME_TIME_FORMAT:-"%I:%M:%S "} _omb_util_add_prompt_command _omb_theme_PROMPT_COMMAND ================================================ FILE: themes/lucky/lucky.theme.sh ================================================ #! bash oh-my-bash.module # Oh My Bash Theme: lucky # Author: meizikeai@163.com # Description: A minimal theme with Git status, Python venv, and hostname info. SCM_GIT_SHOW_MINIMAL_INFO=${SCM_GIT_SHOW_MINIMAL_INFO:-true} SCM_THEME_PROMPT_CLEAN=$_omb_prompt_green${SCM_THEME_PROMPT_CLEAN:-'✔'} SCM_THEME_PROMPT_DIRTY=$_omb_prompt_brown${SCM_THEME_PROMPT_DIRTY:-'✘'} SCM_THEME_BRANCH_PREFIX=${SCM_THEME_BRANCH_PREFIX:-:} SCM_THEME_PROMPT_PREFIX=' '$_omb_prompt_white'on '$_omb_prompt_navy'git'$_omb_prompt_purple SCM_THEME_PROMPT_SUFFIX=$_omb_prompt_normal function _omb_theme_PROMPT_COMMAND() { local python_venv _omb_prompt_get_python_venv PS1=$python_venv PS1+=$_omb_prompt_teal'\u '$_omb_prompt_white'@ '$_omb_prompt_green'\h ' PS1+=$_omb_prompt_white'in '$_omb_prompt_bold_olive'\w' PS1+=$(scm_prompt_info) PS1+=$_omb_prompt_white' ['$(clock_prompt)$_omb_prompt_white']\n' PS1+=$_omb_prompt_bold_brown'\$ '$_omb_prompt_normal } _omb_util_add_prompt_command _omb_theme_PROMPT_COMMAND ================================================ FILE: themes/mairan/mairan.theme.sh ================================================ #! bash oh-my-bash.module # Mairan Bash Prompt, inspired by "Zork" if tput setaf 1 &> /dev/null; then if [[ $(tput colors) -ge 256 ]] 2>/dev/null; then MAGENTA=$(tput setaf 9) ORANGE=$(tput setaf 172) GREEN=$(tput setaf 190) PURPLE=$(tput setaf 141) WHITE=$(tput setaf 0) else MAGENTA=$(tput setaf 5) ORANGE=$(tput setaf 4) GREEN=$(tput setaf 2) PURPLE=$(tput setaf 1) WHITE=$(tput setaf 7) fi BOLD=$(tput bold) RESET=$(tput sgr0) else MAGENTA="\033[1;31m" ORANGE="\033[1;33m" GREEN="\033[1;32m" PURPLE="\033[1;35m" WHITE="\033[1;37m" BOLD="" RESET="\033[m" fi # prompt_symbol='λ' # prompt_symbol='⚡' prompt_symbol='' BRACKET_COLOR=$ORANGE SCM_THEME_PROMPT_PREFIX="" SCM_THEME_PROMPT_SUFFIX="" SCM_THEME_PROMPT_DIRTY=" ${_omb_prompt_bold_brown}✗${_omb_prompt_normal}" SCM_THEME_PROMPT_CLEAN=" ${_omb_prompt_bold_green}✓${_omb_prompt_normal}" SCM_GIT_CHAR="${_omb_prompt_bold_green}±${_omb_prompt_normal}" SCM_SVN_CHAR="${_omb_prompt_bold_teal}⑆${_omb_prompt_normal}" SCM_HG_CHAR="${_omb_prompt_bold_brown}☿${_omb_prompt_normal}" #Mysql Prompt export MYSQL_PS1="(\u@\h) [\d]> " case $TERM in xterm*) TITLEBAR="\[\033]0;\w\007\]" ;; *) TITLEBAR="" ;; esac PS3=">> " function __my_rvm_ruby_version { local gemset=$(awk -F'@' '{print $2}' <<< "$GEM_HOME") [[ $gemset ]] && gemset=@$gemset local version=$(awk -F'-' '{print $2}' <<< "$MY_RUBY_HOME") local full=$version$gemset [[ $full ]] && _omb_util_print "[$full]" } function is_vim_shell { if [[ $VIMRUNTIME ]]; then _omb_util_print "[${_omb_prompt_teal}vim shell${_omb_prompt_normal}]" fi } function modern_scm_prompt { local CHAR=$(scm_char) if [[ $CHAR == "$SCM_NONE_CHAR" ]]; then return else _omb_util_print "[$(scm_char)][$GREEN$(scm_prompt_info)]" fi } # show chroot if exist function chroot { if [[ $debian_chroot ]]; then local my_ps_chroot=$_omb_prompt_bold_teal$debian_chroot$_omb_prompt_normal _omb_util_print "($my_ps_chroot)" fi } # show virtualenvwrapper function my_ve { if [[ $VIRTUAL_ENV ]]; then local ve=$(basename "$VIRTUAL_ENV") local my_ps_ve=$_omb_prompt_bold_purple$ve$_omb_prompt_normal _omb_util_print "($my_ps_ve)" fi _omb_util_print "" } function _omb_theme_PROMPT_COMMAND { local my_ps_host="$BOLD$ORANGE\h${_omb_prompt_normal}" # yes, these are the the same for now ... local my_ps_host_root="$ORANGE\h${_omb_prompt_normal}" local my_ps_user="$BOLD$GREEN\u${_omb_prompt_normal}" local my_ps_root="${_omb_prompt_bold_brown}\u${_omb_prompt_normal}" # nice prompt case $(id -u) in 0) PS1="\n${TITLEBAR}${BRACKET_COLOR}┌─${_omb_prompt_normal}$(my_ve)$(chroot)[$my_ps_root][$my_ps_host_root]$(modern_scm_prompt)$(__my_rvm_ruby_version)[${_omb_prompt_green}\w${_omb_prompt_normal}]$(is_vim_shell)${BRACKET_COLOR} └─▪ ${prompt_symbol} ${_omb_prompt_normal}" ;; *) PS1="\n${TITLEBAR}${BRACKET_COLOR}┌─${_omb_prompt_normal}$(my_ve)$(chroot)[$my_ps_user][$my_ps_host]$(modern_scm_prompt)${_omb_prompt_normal}$(__my_rvm_ruby_version)[${_omb_prompt_green}\w${_omb_prompt_normal}]$(is_vim_shell)${BRACKET_COLOR} └─▪ ${prompt_symbol} ${_omb_prompt_normal}" ;; esac } PS2="└─▪ " _omb_util_add_prompt_command _omb_theme_PROMPT_COMMAND ================================================ FILE: themes/mbriggs/mbriggs.theme.sh ================================================ #! bash oh-my-bash.module # ------------------------------------------------------------------# # FILE: mbriggs.zsh-theme # # BY: Matt Briggs (matt@mattbriggs.net) # # BASED ON: smt by Stephen Tudor (stephen@tudorstudio.com) # # ------------------------------------------------------------------# SCM_THEME_PROMPT_DIRTY="${_omb_prompt_brown}⚡${_omb_prompt_reset_color}" SCM_THEME_PROMPT_AHEAD="${_omb_prompt_brown}!${_omb_prompt_reset_color}" SCM_THEME_PROMPT_CLEAN="${_omb_prompt_green}✓${_omb_prompt_reset_color}" SCM_THEME_PROMPT_PREFIX=" " SCM_THEME_PROMPT_SUFFIX="" GIT_SHA_PREFIX=" ${_omb_prompt_olive}" GIT_SHA_SUFFIX="${_omb_prompt_reset_color}" function git_short_sha() { SHA=$(_omb_prompt_git rev-parse --short HEAD 2> /dev/null) && _omb_util_print "$GIT_SHA_PREFIX$SHA$GIT_SHA_SUFFIX" } function _omb_theme_PROMPT_COMMAND() { local return_status="" local ruby="${_omb_prompt_brown}$(_omb_prompt_print_ruby_env)${_omb_prompt_reset_color}" local user_host="${_omb_prompt_green}\h${_omb_prompt_reset_color}" local current_path="\w" local n_commands="\!" local git_branch="$(git_short_sha)$(scm_prompt_info)" local prompt_symbol='λ' local open='(' local close=')' local prompt_char=' \$ ' PS1="\n${n_commands} ${user_host} ${prompt_symbol} ${ruby} ${open}${current_path}${git_branch}${close}${return_status}\n${prompt_char}" } _omb_util_add_prompt_command _omb_theme_PROMPT_COMMAND ================================================ FILE: themes/minimal/minimal.theme.sh ================================================ #! bash oh-my-bash.module SCM_THEME_PROMPT_PREFIX="${_omb_prompt_teal}(${_omb_prompt_green}" SCM_THEME_PROMPT_SUFFIX="${_omb_prompt_teal})" SCM_THEME_PROMPT_DIRTY=" ${_omb_prompt_brown}✗" SCM_THEME_PROMPT_CLEAN=" ${_omb_prompt_green}✓" function _omb_theme_PROMPT_COMMAND { PS1="$(scm_prompt_info)${_omb_prompt_reset_color} ${_omb_prompt_teal}\W${_omb_prompt_reset_color} " } _omb_util_add_prompt_command _omb_theme_PROMPT_COMMAND ================================================ FILE: themes/minimal-gh/minimal-gh.theme.sh ================================================ #! bash oh-my-bash.module # #======================================================================================== # # ### ### ## ## ## ## ### ### ### ## #### ## ## # ## # # ## ## #### ## ## ## # # ## ## ## ## ## ## ## # ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ### ####### # ## ## ## ## ### ## ## ## ####### ## ## ## ## ## # ## ## ## ## ## ## ## ## ## ## ###### #### ## ## # #======================================================================================== # # Un tema creado por @AlexGh12 para el proyecto de @ohmybash en CDMX 🇲🇽 # function _omb_theme_PROMPT_COMMAND() { # Obtenemos IP segun el sistema operativo local IP case $OSTYPE in linux-gnu) # 2025-09-21 hostname is not a part of GNU/Linux. In fact, Arch Linux # does not include "hostname" by default. # https://www.reddit.com/r/arch/comments/1nlv59f/bash_hostname_commend_not_found/ { IP=$(ip addr 2>/dev/null | awk '$1 == "inet" {sub(/\/.*/, "", $2); if ($2 == "127.0.0.1") next; print $2; exit}'); [[ $IP ]]; } || { IP=$(ip addr 2>/dev/null | awk '$1 == "inet6" {sub(/\/.*/, "", $2); if ($2 == "::1") next; print $2; exit}'); [[ $IP ]]; } || IP=$(hostname -I 2>/dev/null | awk '{print $1}') ;; darwin*) IP=$(ifconfig en0 | awk '$1=="inet" {print $2}') ;; esac [[ $IP ]] || IP="127.0.0.1" # Default to localhost if OS is not recognized local HORA=$(date +%H) local MERIDIANO if ((10#$HORA > 12)); then MERIDIANO="pm"; else MERIDIANO="am"; fi PS1="\n${_omb_prompt_gray}\T${MERIDIANO} ${_omb_prompt_green}\u@$IP ${_omb_prompt_gray}\h ${_omb_prompt_olive}\${PWD} $(scm_prompt_info)\n${_omb_prompt_gray}\$ ${_omb_prompt_normal}" } SCM_THEME_PROMPT_DIRTY=" ${_omb_prompt_brown}✗" SCM_THEME_PROMPT_CLEAN=" ${_omb_prompt_bold_green}✓" SCM_THEME_PROMPT_PREFIX="${_omb_prompt_white}- ${_omb_prompt_bold_teal}" SCM_THEME_PROMPT_SUFFIX="" OMB_PROMPT_VIRTUALENV_FORMAT="${_omb_prompt_bold_gray}(%s)${_omb_prompt_reset_color}" OMB_PROMPT_CONDAENV_FORMAT="${_omb_prompt_bold_gray}(%s)${_omb_prompt_reset_color}" _omb_util_add_prompt_command _omb_theme_PROMPT_COMMAND ================================================ FILE: themes/modern/modern.theme.sh ================================================ #! bash oh-my-bash.module SCM_THEME_PROMPT_PREFIX="" SCM_THEME_PROMPT_SUFFIX="" SCM_THEME_PROMPT_DIRTY=" ${_omb_prompt_bold_brown}✗${_omb_prompt_normal}" SCM_THEME_PROMPT_CLEAN=" ${_omb_prompt_bold_green}✓${_omb_prompt_normal}" SCM_GIT_CHAR="${_omb_prompt_bold_green}±${_omb_prompt_normal}" SCM_SVN_CHAR="${_omb_prompt_bold_teal}⑆${_omb_prompt_normal}" SCM_HG_CHAR="${_omb_prompt_bold_brown}☿${_omb_prompt_normal}" case $TERM in xterm*) TITLEBAR="\[\033]0;\w\007\]" ;; *) TITLEBAR="" ;; esac PS3=">> " function is_vim_shell { if [[ $VIMRUNTIME ]]; then _omb_util_print "[${_omb_prompt_teal}vim shell${_omb_prompt_normal}]" fi } function modern_scm_prompt { local CHAR=$(scm_char) if [[ $CHAR == "$SCM_NONE_CHAR" ]]; then return else _omb_util_print "[$(scm_char)][$(scm_prompt_info)]" fi } function _omb_theme_PROMPT_COMMAND { local last_exit=$? border_color if ((last_exit != 0)); then border_color=$_omb_prompt_bold_brown else border_color=$_omb_prompt_normal fi PS1=$TITLEBAR PS1=$PS1$border_color'┌─'$_omb_prompt_normal PS1=$PS1$(modern_scm_prompt)[$_omb_prompt_teal'\W'$_omb_prompt_normal][$(battery_charge)]$(is_vim_shell)$'\n' PS1=$PS1$border_color'└─▪'$_omb_prompt_normal' ' } PS2="└─▪ " _omb_util_add_prompt_command _omb_theme_PROMPT_COMMAND ================================================ FILE: themes/modern-t/modern-t.theme.sh ================================================ #! bash oh-my-bash.module SCM_THEME_PROMPT_PREFIX="" SCM_THEME_PROMPT_SUFFIX="" SCM_THEME_PROMPT_DIRTY=" ${_omb_prompt_bold_brown}✗${_omb_prompt_normal}" SCM_THEME_PROMPT_CLEAN=" ${_omb_prompt_bold_green}✓${_omb_prompt_normal}" SCM_GIT_CHAR="${_omb_prompt_bold_green}±${_omb_prompt_normal}" SCM_SVN_CHAR="${_omb_prompt_bold_teal}⑆${_omb_prompt_normal}" SCM_HG_CHAR="${_omb_prompt_bold_brown}☿${_omb_prompt_normal}" case $TERM in xterm*) TITLEBAR="\[\033]0;\w\007\]" ;; *) TITLEBAR="" ;; esac PS3=">> " function is_vim_shell { if [[ $VIMRUNTIME ]]; then _omb_util_print "[${_omb_prompt_teal}vim shell${_omb_prompt_normal}]" fi } function modern_scm_prompt { local CHAR=$(scm_char) if [[ $CHAR == "$SCM_NONE_CHAR" ]]; then return else _omb_util_print "[$(scm_char)][$(scm_prompt_info)]" fi } function _omb_theme_PROMPT_COMMAND { if (($? != 0)); then local border_color=$_omb_prompt_bold_brown else local border_color=$_omb_prompt_normal fi local todo_count= _omb_util_binary_exists t && todo_count=[${_omb_prompt_teal}$(command t | wc -l | sed -e's/ *//')${_omb_prompt_reset_color}] PS1="${TITLEBAR}${border_color}┌─$todo_count${_omb_prompt_normal}$(modern_scm_prompt)[${_omb_prompt_teal}\W${_omb_prompt_normal}]$(is_vim_shell)" PS1+="\n${border_color}└─▪${_omb_prompt_normal} " } PS2="└─▪ " _omb_util_add_prompt_command _omb_theme_PROMPT_COMMAND if [[ -t 2 ]] && ! _omb_util_binary_exists t; then _omb_util_print "${_omb_term_bold_navy}oh-my-bash (theme:modern-t)${_omb_term_normal}: command \"t\" not found. The theme \"Modern T\" depends on a todo-list manager \"t\" (${_omb_term_underline}https://github.com/sjl/t${_omb_term_normal})." >&2 fi ================================================ FILE: themes/morris/morris.theme.sh ================================================ #! bash oh-my-bash.module # prompt theming # added TITLEBAR for updating the tab and window titles with the pwd case $TERM in xterm*) TITLEBAR=$(printf "\033]0;%s@%s:%s\007" "${USER}" "${HOSTNAME%%.*}" "${PWD/#$HOME/~}") ;; screen) TITLEBAR=$(printf "\033]0;%s@%s:%s\033\\" "${USER}" "${HOSTNAME%%.*}" "${PWD/#$HOME/~}") ;; *) TITLEBAR="" ;; esac function _omb_theme_PROMPT_COMMAND() { PS1="${TITLEBAR}[\u@\h \W $(scm_prompt_info)]\$ " } # scm theming SCM_THEME_PROMPT_DIRTY=" ${_omb_prompt_brown}✗" SCM_THEME_PROMPT_CLEAN=" ${_omb_prompt_bold_green}✓" SCM_THEME_PROMPT_PREFIX="${_omb_prompt_green}(" SCM_THEME_PROMPT_SUFFIX="${_omb_prompt_green})${_omb_prompt_reset_color}" _omb_util_add_prompt_command _omb_theme_PROMPT_COMMAND ================================================ FILE: themes/n0qorg/n0qorg.theme.sh ================================================ #! bash oh-my-bash.module # n0qorg theme by Florian Baumann ## look-a-like # host directory (branch*)» # for example: # ananas ~/Code/bash-it/themes (master*)» function _omb_theme_PROMPT_COMMAND() { PS1="${_omb_prompt_bold_navy}[$(hostname)]${_omb_prompt_normal} \w${_omb_prompt_normal} ${_omb_prompt_bold_white}[$(git_prompt_info)]${_omb_prompt_normal}» " } _omb_util_add_prompt_command _omb_theme_PROMPT_COMMAND ## git-theme # feel free to change git chars. GIT_THEME_PROMPT_DIRTY="${_omb_prompt_bold_navy}*${_omb_prompt_bold_white}" GIT_THEME_PROMPT_CLEAN="" GIT_THEME_PROMPT_PREFIX="${_omb_prompt_bold_navy}(${_omb_prompt_bold_white}" GIT_THEME_PROMPT_SUFFIX="${_omb_prompt_bold_navy})" ## alternate chars SCM_THEME_PROMPT_DIRTY="*" SCM_THEME_PROMPT_CLEAN="" SCM_THEME_PROMPT_PREFIX="(" SCM_THEME_PROMPT_SUFFIX=")" ================================================ FILE: themes/nekolight/README.md ================================================ # NekoLight prompt theme Nekolight is an Oh-My-Bash prompt theme inspired by Starship and designed to be simple and lightweight. ![Nekolight theme](nekolight-dark.jpg) ## 🚀 Installation Prerequisites - A Nerd Font or Powerline Font installed and enabled in your terminal (for example, try the FiraCode Nerd Font). After installing the Nerd Fonts font, just modify the following line in your ~/.bashrc ```shell OSH_THEME="nekolight" ``` and then to load the theme in your terminal you must type `source ~/.bashrc`. ================================================ FILE: themes/nekolight/nekolight.theme.sh ================================================ #! bash oh-my-bash.module _omb_theme_nekolight_version='1.0.0' _omb_theme_nekolight_symbol="" function _omb_theme_nekolight_git_info() { if _omb_prompt_git rev-parse --is-inside-work-tree &>/dev/null; then local branch=$(_omb_prompt_git symbolic-ref --short HEAD 2>/dev/null || _omb_prompt_git rev-parse --short HEAD 2>/dev/null) if _omb_prompt_git diff --quiet 2>/dev/null && _omb_prompt_git diff --cached --quiet 2>/dev/null; then _omb_util_print "on ${_omb_prompt_bold_green} ${_omb_theme_nekolight_symbol} ${branch} ${_omb_prompt_normal}" else _omb_util_print "on ${_omb_prompt_bold_red} ${_omb_theme_nekolight_symbol} ${branch}${_omb_prompt_normal}" fi fi } function _omb_theme_PROMPT_COMMAND() { local display_dir="${_omb_prompt_bold_blue}\w${_omb_prompt_normal}" local git_status=$(_omb_theme_nekolight_git_info) PS1="${display_dir} ${git_status}\n❯ " } _omb_util_add_prompt_command _omb_theme_PROMPT_COMMAND ================================================ FILE: themes/nekonight/nekonight.base.sh ================================================ #! bash oh-my-bash.module icon_start="╭─" icon_user=" ${_omb_theme_nekonight_icon_emoji} ${_omb_prompt_bold_olive}\u${_omb_prompt_normal}" icon_host=" at ${_omb_theme_nekonight_icon_emoji} ${_omb_prompt_bold_cyan}\h${_omb_prompt_normal}" icon_directory=" in ${_omb_theme_nekonight_icon_emoji} ${_omb_prompt_bold_magenta}\w${_omb_prompt_normal}" icon_end="╰─${_omb_prompt_bold_white}λ${_omb_prompt_normal}" function _omb_theme_nekonight_git_prompt_info() { local branch_name branch_name=$(_omb_prompt_git symbolic-ref --short HEAD 2>&-) local git_status="" local icon_emoji="${_omb_theme_nekonight_icon_emoji:-🐱}" if [[ -n $branch_name ]]; then git_status="${_omb_prompt_bold_white} (${icon_emoji} $branch_name $(_omb_theme_nekonight_scm_git_status))${_omb_prompt_normal}" fi echo -n "$git_status" } function _omb_theme_nekonight_scm_git_status() { local git_status="" if _omb_prompt_git rev-list --count --left-right @{upstream}...HEAD 2>&- | grep -Eq '^[0-9]+[[:blank:]][0-9]+$'; then git_status+="${_omb_prompt_brown}↓${_omb_prompt_normal} " fi if [[ -n $(_omb_prompt_git diff --cached --name-status 2>&-) ]]; then git_status+="${_omb_prompt_green}+${_omb_prompt_normal}" fi if [[ -n $(_omb_prompt_git diff --name-status 2>&-) ]]; then git_status+="${_omb_prompt_yellow}•${_omb_prompt_normal}" fi if [[ -n $(_omb_prompt_git ls-files --others --exclude-standard 2>&-) ]]; then git_status+="${_omb_prompt_red}⌀${_omb_prompt_normal}" fi echo -n "$git_status" } ================================================ FILE: themes/nekonight/nekonight.theme.sh ================================================ #! bash oh-my-bash.module # nekonight Bash prompt with source control management # Author: Bruno Ciccarino # # Theme inspired by: # - Bash_it cupcake theme # Demo: # ╭─🐱 virtualenv 🐱user at 🐱host in 🐱directory on (🐱branch {1} ↑1 ↓1 +1 •1 ⌀1 ✗) # ╰λ cd ~/path/to/your-directory _omb_theme_nekonight_icon_emoji="🐱" source "$OSH/themes/nekonight/nekonight.base.sh" function _omb_theme_PROMPT_COMMAND() { PS1="${icon_start}${icon_user}${icon_host}${icon_directory} in $(_omb_theme_nekonight_git_prompt_info)\n${icon_end} " } _omb_util_add_prompt_command _omb_theme_PROMPT_COMMAND ================================================ FILE: themes/nekonight_moon/nekonight_moon.theme.sh ================================================ #! bash oh-my-bash.module # nekonight-moon Bash prompt with source control management # Author: Bruno Ciccarino # # Theme inspired by: # - Bash_it cupcake theme # Demo: # ╭─🌙 virtualenv 🌙user at 🌙host in 🌙directory on (🌙branch {1} ↑1 ↓1 +1 •1 ⌀1 ✗) # ╰λ cd ~/path/to/your-directory _omb_theme_nekonight_icon_emoji="🌙" source "$OSH/themes/nekonight/nekonight.base.sh" function _omb_theme_PROMPT_COMMAND() { PS1="${icon_start}${icon_user}${icon_host}${icon_directory} in $(_omb_theme_nekonight_git_prompt_info)\n${icon_end} " } _omb_util_add_prompt_command _omb_theme_PROMPT_COMMAND ================================================ FILE: themes/nwinkler/nwinkler.theme.sh ================================================ #! bash oh-my-bash.module # Two line prompt showing the following information: # (time) SCM [username@hostname] pwd (SCM branch SCM status) # → # # Example: # (14:00:26) ± [foo@bar] ~/.oh-my-bash (master ✓) # → # # The arrow on the second line is showing the exit status of the last command: # * Green: 0 exit status # * Red: non-zero exit status # # The exit code functionality currently doesn't work if you are using the 'fasd' plugin, # since 'fasd' is messing with the $PROMPT_COMMAND PROMPT_END_CLEAN="${_omb_prompt_green}→${_omb_prompt_reset_color}" PROMPT_END_DIRTY="${_omb_prompt_brown}→${_omb_prompt_reset_color}" function prompt_end() { echo -e "$PROMPT_END" } function _omb_theme_PROMPT_COMMAND { local exit_status=$? if [[ $exit_status -eq 0 ]]; then PROMPT_END=$PROMPT_END_CLEAN else PROMPT_END=$PROMPT_END_DIRTY fi # Save history #history -a #history -c #history -r PS1="($(clock_prompt)) $(scm_char) [${_omb_prompt_navy}\u${_omb_prompt_reset_color}@${_omb_prompt_green}\H${_omb_prompt_reset_color}] ${_omb_prompt_olive}\w${_omb_prompt_reset_color}$(scm_prompt_info) ${_omb_prompt_reset_color}\n$(prompt_end) " PS2='> ' PS4='+ ' } _omb_util_add_prompt_command _omb_theme_PROMPT_COMMAND SCM_THEME_PROMPT_DIRTY=" ${_omb_prompt_bold_brown}✗${_omb_prompt_normal}" SCM_THEME_PROMPT_CLEAN=" ${_omb_prompt_bold_green}✓${_omb_prompt_normal}" SCM_THEME_PROMPT_PREFIX=" (" SCM_THEME_PROMPT_SUFFIX=")" RVM_THEME_PROMPT_PREFIX=" (" RVM_THEME_PROMPT_SUFFIX=")" ================================================ FILE: themes/nwinkler_random_colors/README.md ================================================ # Nwinkler Random Color Theme ## Description The *Nwinkler Random Color* Theme is based on the [nwinkler theme](https://github.com/Bash-it/bash-it/wiki/Themes#nwinkler), but it randomizes the colors for: * time * username * hostname * path The random colors are chosen the first time this theme is used and saved to the `~/.nwinkler_random_colors` file. So, the next time you connect to the same machine, you will get the same colors. To force new random colors to be selected, run the command: ```sh randomize_nwinkler ``` ## Screenshot Here it is in action: ![alt text](screenshot.png "Nwinkler Random Color Theme in Action!") ## Usage Scenario This theme is especially useful when connecting to many different machines and switching between them often. Yes, the hostname *is* present in the prompt. But I argue that it's a lot faster to get a "feel" of what machine you are currently on because of the custom colors on that machine's prompt than by reading the hostname. ================================================ FILE: themes/nwinkler_random_colors/nwinkler_random_colors.theme.sh ================================================ #! bash oh-my-bash.module # Two line prompt showing the following information: # (time) SCM [username@hostname] pwd (SCM branch SCM status) # → # # Example: # (14:00:26) ± [foo@bar] ~/.oh-my-bash (master ✓) # → # # The arrow on the second line is showing the exit status of the last command: # * Green: 0 exit status # * Red: non-zero exit status # # The exit code functionality currently doesn't work if you are using the 'fasd' plugin, # since 'fasd' is messing with the $PROMPT_COMMAND RANDOM_COLOR_FILE=$HOME/.nwinkler_random_colors function randomize_nwinkler { declare -a AVAILABLE_COLORS AVAILABLE_COLORS=( "$_omb_prompt_black" "$_omb_prompt_brown" "$_omb_prompt_green" "$_omb_prompt_olive" "$_omb_prompt_navy" "$_omb_prompt_purple" "$_omb_prompt_teal" "$_omb_prompt_white" "$_omb_prompt_red" "$_omb_prompt_bold_black" "$_omb_prompt_bold_brown" "$_omb_prompt_bold_green" "$_omb_prompt_bold_olive" "$_omb_prompt_bold_navy" "$_omb_prompt_bold_purple" "$_omb_prompt_bold_teal" "$_omb_prompt_bold_white" "$_omb_prompt_bold_red" # # Uncomment these to allow underlines: # "$_omb_prompt_underline_black" # "$_omb_prompt_underline_brown" # "$_omb_prompt_underline_green" # "$_omb_prompt_underline_olive" # "$_omb_prompt_underline_navy" # "$_omb_prompt_underline_purple" # "$_omb_prompt_underline_teal" # "$_omb_prompt_underline_white" # "$_omb_prompt_underline_red" ) USERNAME_COLOR=${AVAILABLE_COLORS[$RANDOM % ${#AVAILABLE_COLORS[@]} ]} HOSTNAME_COLOR=${AVAILABLE_COLORS[$RANDOM % ${#AVAILABLE_COLORS[@]} ]} TIME_COLOR=${AVAILABLE_COLORS[$RANDOM % ${#AVAILABLE_COLORS[@]} ]} THEME_CLOCK_COLOR=$TIME_COLOR PATH_COLOR=${AVAILABLE_COLORS[$RANDOM % ${#AVAILABLE_COLORS[@]} ]} _omb_util_print "$USERNAME_COLOR,$HOSTNAME_COLOR,$TIME_COLOR,$PATH_COLOR," > $RANDOM_COLOR_FILE } if [ -f $RANDOM_COLOR_FILE ]; then # read the colors already stored in the file IFS=',' read -ra COLORS < $RANDOM_COLOR_FILE USERNAME_COLOR=${COLORS[0]} HOSTNAME_COLOR=${COLORS[1]} TIME_COLOR=${COLORS[2]} THEME_CLOCK_COLOR=$TIME_COLOR PATH_COLOR=${COLORS[3]} else # No colors stored yet. Generate them! randomize_nwinkler _omb_util_print _omb_util_print "Looks like you are using the nwinkler_random_color bashit theme for the first time." _omb_util_print "Random colors have been generated to be used in your prompt." _omb_util_print "If you don't like them, run the command:" _omb_util_print " randomize_nwinkler" _omb_util_print "until you get a combination that you like." _omb_util_print fi PROMPT_END_CLEAN="${_omb_prompt_green}→${_omb_prompt_reset_color}" PROMPT_END_DIRTY="${_omb_prompt_brown}→${_omb_prompt_reset_color}" function prompt_end() { echo -e "$PROMPT_END" } function _omb_theme_PROMPT_COMMAND { local exit_status=$? if [[ $exit_status -eq 0 ]]; then PROMPT_END=$PROMPT_END_CLEAN else PROMPT_END=$PROMPT_END_DIRTY fi # Save history history -a history -c history -r PS1="($(clock_prompt)${_omb_prompt_reset_color}) $(scm_char) [${USERNAME_COLOR}\u${_omb_prompt_reset_color}@${HOSTNAME_COLOR}\H${_omb_prompt_reset_color}] ${PATH_COLOR}\w${_omb_prompt_reset_color}$(scm_prompt_info) ${_omb_prompt_reset_color}\n$(prompt_end) " PS2='> ' PS4='+ ' } _omb_util_add_prompt_command _omb_theme_PROMPT_COMMAND SCM_THEME_PROMPT_DIRTY=" ${_omb_prompt_bold_brown}✗${_omb_prompt_normal}" SCM_THEME_PROMPT_CLEAN=" ${_omb_prompt_bold_green}✓${_omb_prompt_normal}" SCM_THEME_PROMPT_PREFIX=" (" SCM_THEME_PROMPT_SUFFIX=")" RVM_THEME_PROMPT_PREFIX=" (" RVM_THEME_PROMPT_SUFFIX=")" ================================================ FILE: themes/pete/pete.theme.sh ================================================ #! bash oh-my-bash.module function _omb_theme_PROMPT_COMMAND { # Save history history -a history -c history -r PS1="($(clock_prompt)) $(scm_char) [$_omb_prompt_navy\u$_omb_prompt_reset_color@$_omb_prompt_green\H$_omb_prompt_reset_color] $_omb_prompt_olive\w${_omb_prompt_reset_color}$(scm_prompt_info)$(_omb_prompt_print_ruby_env) $_omb_prompt_reset_color " PS2='> ' PS4='+ ' } _omb_util_add_prompt_command _omb_theme_PROMPT_COMMAND SCM_THEME_PROMPT_DIRTY=" ✗" SCM_THEME_PROMPT_CLEAN=" ✓" SCM_THEME_PROMPT_PREFIX=" (" SCM_THEME_PROMPT_SUFFIX=")" RVM_THEME_PROMPT_PREFIX=" (" RVM_THEME_PROMPT_SUFFIX=")" ================================================ FILE: themes/powerbash10k/README.md ================================================ # powerbash10k theme Simple colorful terminal prompt theme (inspired by powerlevel10k zsh theme, based on Brainy theme). ## Prerequisites - **Nerd Fonts** ... This theme uses symbols from Nerd Fonts. You need to install a Nerd Font and then configure your terminal to use the Nerd Font. ## Features ### Prompt Segments - Username & Hostname - Current Directory - SCM Information - Battery Charge - Clock - Command duration - [Todo.txt](https://github.com/ginatrapani/todo.txt-cli) status - Ruby Environment - Python Environment - Exit Code ### Others - Indicator for cached `sudo` credential - Indicator for ssh login - `pb10k` command for showing/hiding various prompt segments on-the-fly ## Configuration Various prompt segments can be shown/hidden or modified according to your choice. There are two ways for doing that: 1. On-the-fly using `pb10k` command 2. Theme Environment Variables ### On-the-fly using `pb10k` command This theme provides a command for showing/hiding prompt segments. `pb10k show ` `pb10k hide ` Tab-completion for this command is enabled by default. Configuration specified by this command will only be applied to current and subsequent child shells. ### Theme Environment Variables This is used for permanent settings that apply to all terminal sessions. You have to define the value of specific theme variables in your `bashrc` (or equivalent) file. The name of the variables are listed below along with their default values. #### User Information Indicator for cached `sudo` credential (see `sudo` manpage for more information): `THEME_SHOW_SUDO=true` Hide user info for local user (show only in SSH sessions): `__PB10K_PROMPT_LOCAL_USER_INFO=false` #### SCM Information Information about SCM repository status: `THEME_SHOW_SCM=true` #### Ruby Environment Ruby environment version information: `THEME_SHOW_RUBY=false` #### Python Environment Python environment version information: `THEME_SHOW_PYTHON=false` #### ToDo.txt status [Todo.txt](https://github.com/ginatrapani/todo.txt-cli) status: `THEME_SHOW_TODO=false` #### Clock `THEME_SHOW_CLOCK=true` `THEME_CLOCK_COLOR=$bold_cyan` Format of the clock (see `date` manpage for more information): `THEME_CLOCK_FORMAT="%H:%M:%S"` #### Battery Charge Battery charge percentage: `THEME_SHOW_BATTERY=false` #### Exit Code Exit code of the last command: `THEME_SHOW_EXITCODE=true` ## Prompt Segments Order Currently available prompt segments are: - battery - char - clock - cmd_duration - dir - exitcode - python - ruby - scm - todo - user_info Three environment variables can be defined to rearrange the segments order. The default values are: `__PB10K_TOP_LEFT="dir scm"` `__PB10K_TOP_RIGHT="exitcode cmd_duration user_info python ruby todo clock battery"` `__PB10K_BOTTOM="char"` ================================================ FILE: themes/powerbash10k/powerbash10k.theme.sh ================================================ #! bash oh-my-bash.module # powerbash10k theme for oh-my-bash, inspired by powerlevel10k zsh theme # made by awerebea, based on brainy theme by MunifTanjim # Helpers function __pb10k_remove_empty_elements { local origin_array new_array element trimmed _omb_util_split origin_array "$1" '|' new_array=() for element in "${origin_array[@]}"; do trimmed=${element#"${element%%[![:space:]]*}"} trimmed=${trimmed%"${trimmed##*[![:space:]]}"} [[ $trimmed ]] && new_array+=("$element") done _omb_util_print "${new_array[*]}" } function __pb10k_format_duration { local duration=$1 local seconds=$((duration % 60)) local minutes=$((duration / 60 % 60)) local hours=$((duration / 3600)) if ((hours > 0)); then _omb_util_print "${hours}h ${minutes}m ${seconds}s" elif ((minutes > 0)); then _omb_util_print "${minutes}m ${seconds}s" else _omb_util_print "${seconds}s" fi } # Last command duration function __pb10k_timer_start { __pb10k_timer=${__pb10k_timer:-$SECONDS} } function __pb10k_timer_stop { __pb10k_timer_show=$((SECONDS - __pb10k_timer)) unset -v __pb10k_timer } trap '__pb10k_timer_start' DEBUG # Parsers function __pb10k_top_left_parse { local args _omb_util_split args "$1" '|' if [[ ${args[3]} ]]; then __TOP_LEFT+=${args[2]}${args[3]} fi __TOP_LEFT+=${args[0]}${args[1]} if [[ ${args[4]} ]]; then __TOP_LEFT+=${args[2]}${args[4]} fi __TOP_LEFT+=" " } function __pb10k_top_right_parse { local args _omb_util_split args "$1" '|' __TOP_RIGHT+=" " if [[ ${args[3]} ]]; then __TOP_RIGHT+=${args[2]}${args[3]} fi __TOP_RIGHT+=${args[0]}${args[1]} if [[ ${args[4]} ]]; then __TOP_RIGHT+=${args[2]}${args[4]} fi __TOP_RIGHT_LEN=$((__TOP_RIGHT_LEN + ${#args[1]} + ${#args[3]} + ${#args[4]} + 1)) ((__SEG_AT_RIGHT += 1)) } function __pb10k_bottom_parse { local args _omb_util_split args "$1" '|' __BOTTOM+=${args[0]}${args[1]} ((${#args[1]} > 0)) && __BOTTOM+=" " } function __pb10k_top { local __TOP_LEFT="" local __TOP_RIGHT="" local __TOP_RIGHT_LEN=0 local __SEG_AT_RIGHT=0 local segments _omb_util_split segments "$__PB10K_TOP_LEFT" local seg info for seg in "${segments[@]}"; do info=$(__pb10k_prompt_"$seg") [[ $info ]] && __pb10k_top_left_parse "$info" done local terminal_width=$(tput cols) local filler_character="·" __TOP_LEFT+=$_omb_prompt_black __TOP_LEFT+="$(for ((i = 0; i < terminal_width; i++)); do printf "%s" "$filler_character"; done)" __TOP_LEFT+="\033[${terminal_width}G\033[1K\033[1A" _omb_util_split segments "$__PB10K_TOP_RIGHT" for seg in "${segments[@]}"; do info=$(__pb10k_prompt_"$seg") [[ $info ]] && __pb10k_top_right_parse "$info" done ((__TOP_RIGHT_LEN > 0)) && ((__TOP_RIGHT_LEN--)) local cursor_adjust="\033[${__TOP_RIGHT_LEN}D" __TOP_LEFT+=$cursor_adjust printf "%s%s" "$__TOP_LEFT" "$__TOP_RIGHT" } function __pb10k_bottom { local seg segments info local __BOTTOM="" _omb_util_split segments "$__PB10K_BOTTOM" for seg in "${segments[@]}"; do info=$(__pb10k_prompt_"$seg") [[ $info ]] && __pb10k_bottom_parse "$info" done printf "\n%s" "$__BOTTOM" } # Segments function __pb10k_prompt_user_info { local color=$_omb_prompt_bold_olive if [[ $THEME_SHOW_SUDO == true ]]; then if [[ $(sudo -n id -u 2>&1) == 0 ]]; then color=$_omb_prompt_bold_brown fi fi local box="" local info=$USER@$(hostname | cut -d'.' -f1) if [[ $SSH_CLIENT ]]; then printf "%s|%s|%s|%s" "$color" "$info" "$_omb_prompt_bold_white" "$box" elif [[ $__PB10K_PROMPT_LOCAL_USER_INFO == true ]]; then printf "%s|%s" "$color" "$info" fi } function __pb10k_prompt_dir { local color=$_omb_prompt_bold_navy local box="" local info=" \w" printf "%s|%s|%s|%s" "$color" "$info" "$_omb_prompt_bold_white" "$box" } function __pb10k_prompt_scm { [[ $THEME_SHOW_SCM != true ]] && return 0 local color=$_omb_prompt_bold_green scm local box="" local info="$(if [ "$SCM" == "git" ]; then _omb_util_print " "; fi)" info+="$(if [ "$SCM" != "NONE" ]; then _omb_util_print " $(scm_prompt_info)"; fi)" [[ $info ]] || return 0 printf "%s|%s|%s|%s" "$color" "$info" "$_omb_prompt_bold_green" "$box" } function __pb10k_prompt_python { [[ $THEME_SHOW_PYTHON != true ]] && return 0 local color=$_omb_prompt_bold_olive local box="" local response_array _omb_util_split response_array "$(_omb_prompt_get_python_env; __pb10k_remove_empty_elements "$python_env")" local info=${response_array[${#response_array[@]}-1]} if ((${#response_array[@]} > 1)); then # Print all elements except the last one, separated by commas local venvs=$(printf "%s," "${response_array[@]:0:${#response_array[@]}-1}") # Remove the trailing comma venvs=${venvs%,} info="$info ($venvs)" fi info="${info/#py-/ }" ((${#response_array[@]} < 2)) && return 0 printf "%s|%s|%s|%s" "$color" "$info" "$_omb_prompt_bold_navy" "$box" } function __pb10k_prompt_ruby { [[ $THEME_SHOW_RUBY != true ]] && return 0 local color=$_omb_prompt_bold_white local box="[|]" local info=rb-$(_omb_prompt_print_ruby_env) printf "%s|%s|%s|%s" "$color" "$info" "$_omb_prompt_bold_brown" "$box" } function __pb10k_prompt_todo { [[ $THEME_SHOW_TODO != true ]] && return 0 _omb_util_binary_exists todo.sh || return 0 local color=$_omb_prompt_bold_white local box="[|]" local info=t:$(todo.sh ls | command grep -E "TODO: [0-9]+ of ([0-9]+)" | awk '{ print $4 }' ) printf "%s|%s|%s|%s" "$color" "$info" "$_omb_prompt_bold_green" "$box" } function __pb10k_prompt_clock { [[ $THEME_SHOW_CLOCK != true ]] && return 0 local color=$THEME_CLOCK_COLOR local box="" local info=" $(date +"$THEME_CLOCK_FORMAT")" printf "%s|%s|%s|%s" "$color" "$info" "$_omb_prompt_bold_purple" "$box" } function __pb10k_prompt_battery { [[ -e $OSH/plugins/battery/battery.plugin.sh ]] || return 0 [[ $THEME_SHOW_BATTERY != true ]] && return 0 local info=$(battery_percentage) local color=$_omb_prompt_bold_green if ((info < 50)); then color=$_omb_prompt_bold_olive elif ((info < 25)); then color=$_omb_prompt_bold_brown fi local box="[|]" ac_adapter_connected && info+="+" [[ $info == 100+ ]] && info="AC" printf "%s|%s|%s|%s" "$color" "$info" "$_omb_prompt_bold_white" "$box" } function __pb10k_prompt_exitcode { [[ $THEME_SHOW_EXITCODE != true ]] && return 0 local color=$_omb_prompt_bold_red ((exitcode != 0)) && printf "%s|%s" "$color" "✘ $exitcode" } function __pb10k_prompt_char { local color=$( if ((exitcode != 0)); then _omb_util_print "$_omb_prompt_bold_red" else _omb_util_print "$_omb_prompt_bold_green" fi ) printf "%s|%s" "$color" "$__PB10K_PROMPT_CHAR_PS1" } function __pb10k_prompt_cmd_duration { local color=$_omb_prompt_bold_navy local box="" local info=$( if ((__pb10k_timer_show > 0)); then printf " %s" "$(__pb10k_format_duration "$__pb10k_timer_show")" fi ) [[ $info ]] || return 0 printf "%s|%s|%s|%s" "$color" "$info" "$_omb_prompt_bold_white" "$box" } # cli function __pb10k_show { local seg=${1:-} export "THEME_SHOW_$seg=true" } function __pb10k_hide { local seg=${1:-} export "THEME_SHOW_$seg=false" } function __pb10k_completion { COMPREPLY=() local cur=${COMP_WORDS[COMP_CWORD]} local action=${COMP_WORDS[1]} local actions='show hide' local segments='battery clock exitcode python ruby scm sudo todo' case $action in show | hide ) _omb_util_split COMPREPLY "$(compgen -W "$segments" -- "$cur")" $'\n' ;; *) _omb_util_split COMPREPLY "$(compgen -W "$actions" -- "$cur")" $'\n' ;; esac return 0 } function pb10k { local action=${1:-} shift local segments IFS=$' \t\n' _omb_util_split segments "${*:-}" local func= case $action in show) func=__pb10k_show;; hide) func=__pb10k_hide;; *) printf 'pb10k: %s: unrecognized action\n' "$action" >&2 return 1 esac local seg for seg in "${segments[@]}"; do seg=$(printf "%s" "$seg" | tr '[:lower:]' '[:upper:]') "$func" "$seg" done } complete -F __pb10k_completion pb10k # Variables export SCM_THEME_PROMPT_PREFIX="" export SCM_THEME_PROMPT_SUFFIX="" export RBENV_THEME_PROMPT_PREFIX="" export RBENV_THEME_PROMPT_SUFFIX="" export RBFU_THEME_PROMPT_PREFIX="" export RBFU_THEME_PROMPT_SUFFIX="" export RVM_THEME_PROMPT_PREFIX="" export RVM_THEME_PROMPT_SUFFIX="" export SCM_THEME_PROMPT_DIRTY=" ${_omb_prompt_bold_brown}✗${_omb_prompt_normal}" export SCM_THEME_PROMPT_CLEAN=" ${_omb_prompt_bold_green}✓${_omb_prompt_normal}" THEME_SHOW_SUDO=${THEME_SHOW_SUDO:-"true"} THEME_SHOW_SCM=${THEME_SHOW_SCM:-"true"} THEME_SHOW_RUBY=${THEME_SHOW_RUBY:-"false"} THEME_SHOW_PYTHON=${THEME_SHOW_PYTHON:-"false"} THEME_SHOW_CLOCK=${THEME_SHOW_CLOCK:-"true"} THEME_SHOW_TODO=${THEME_SHOW_TODO:-"false"} THEME_SHOW_BATTERY=${THEME_SHOW_BATTERY:-"false"} THEME_SHOW_EXITCODE=${THEME_SHOW_EXITCODE:-"true"} THEME_CLOCK_COLOR=${THEME_CLOCK_COLOR:-"$_omb_prompt_bold_white"} THEME_CLOCK_FORMAT=${THEME_CLOCK_FORMAT:-"%H:%M:%S"} __PB10K_PROMPT_CHAR_PS1=${THEME_PROMPT_CHAR_PS1:-"❯"} __PB10K_PROMPT_CHAR_PS2=${THEME_PROMPT_CHAR_PS2:-"\\"} __PB10K_TOP_LEFT=${__PB10K_TOP_LEFT:-"dir scm"} __PB10K_TOP_RIGHT=${__PB10K_TOP_RIGHT:-"exitcode cmd_duration user_info python ruby todo clock battery"} __PB10K_BOTTOM=${__PB10K_BOTTOM:-"char"} __PB10K_PROMPT_LOCAL_USER_INFO=${__PB10K_PROMPT_LOCAL_USER_INFO:-"true"} # Prompt function __pb10k_ps1 { printf "%s%s%s" "$(__pb10k_top)" "$(__pb10k_bottom)" "$_omb_prompt_normal" } function __pb10k_ps2 { local color color=$_omb_prompt_bold_white printf "%s%s%s" "$color" "$__PB10K_PROMPT_CHAR_PS2 " "$_omb_prompt_normal" } function _omb_theme_PROMPT_COMMAND { local exitcode=$? PS1=$(__pb10k_ps1) PS2=$(__pb10k_ps2) } _omb_util_add_prompt_command __pb10k_timer_stop _omb_util_add_prompt_command _omb_theme_PROMPT_COMMAND ================================================ FILE: themes/powerline/README.md ================================================ # Powerline Theme A colorful theme, where shows a lot information about your shell session. **IMPORTANT:** This theme requires that [a font with the Powerline symbols](https://github.com/powerline/fonts) needs to be used in your terminal emulator, otherwise the prompt won't be displayed correctly, i.e. some of the additional icons and characters will be missing. Please follow your operating system's instructions to install one of the fonts from the above link and select it in your terminal emulator. **NOTICE:** The default behavior of this theme assumes that you have sudo privileges on your workstation. If that is not the case (e.g. if you are running on a corporate network where `sudo` usage is tracked), you can set the flag 'export THEME_CHECK_SUDO=false' in your `~/.bashrc` or `~/.bash_profile` to disable the Powerline theme's `sudo` check. This will apply to all `powerline*` themes. ## Provided Information * Current path * Current username and hostname * Current time * An indicator when connected by SSH * An indicator when `sudo` has the credentials cached (see the `sudo` manpage for more info about this) * An indicator when the current shell is inside the Vim editor * Battery charging status (depends on the [../../plugins/battery/battery.plugin.sh](battery plugin)) * SCM Repository status (e.g. Git, SVN) * The current Python environment (Virtualenv, venv, and Conda are supported) in use * The current Ruby environment (rvm and rbenv are supported) in use * Last command exit code (only shown when the exit code is greater than 0) ## Configuration This theme is pretty configurable, all the configuration is done by setting environment variables. ### User Information By default, the username and hostname are shown, but you can change this behavior by setting the value of the following variable: POWERLINE_PROMPT_USER_INFO_MODE="sudo" For now, the only supported value is `sudo`, which hides the username and hostname, and shows an indicator when `sudo` has the credentials cached. Other values have no effect at this time. ### Clock Format You can change the format using the following variable: THEME_CLOCK_FORMAT="%H:%M:%S" The time/date is printed by the `date` command, so refer to its man page to change the format. ### Segment Order The contents of the prompt can be "reordered", all the "segments" (every piece of information) can take any place. The currently available segments are: * battery * clock * cwd * in_vim * python_venv * ruby * scm * user_info A variables can be defined to set the order of the prompt segments: POWERLINE_PROMPT="user_info scm python_venv ruby cwd" The example values above are the current default values, but if you want to remove anything from the prompt, simply remove the "string" that represents the segment from the variable. ================================================ FILE: themes/powerline/powerline.base.sh ================================================ #! bash oh-my-bash.module # Define this here so it can be used by all of the Powerline themes THEME_CHECK_SUDO=${THEME_CHECK_SUDO:=false} function _omb_theme_powerline_hex_to_rgb { local hex_color="$1" local r g b r=$((16#${hex_color:1:2})) g=$((16#${hex_color:3:2})) b=$((16#${hex_color:5:2})) REPLY="${r};${g};${b}" } function set_color { local fg="" bg="" if [[ "${1}" != "-" ]]; then if [[ ${1} =~ ^[0-9]+$ ]]; then fg="38;5;${1}" # ANSI 256-color code elif [[ ${1} =~ ^[0-9]{1,3}(\;[0-9]{1,3}){2}$ ]]; then fg="38;2;${1}" # RGB color code elif [[ ${1} =~ ^#[0-9A-Fa-f]{6}$ ]]; then local REPLY _omb_theme_powerline_hex_to_rgb "${1}" fg="38;2;${REPLY}" # Hex color code converted to RGB fi fi if [[ "${2}" != "-" ]]; then if [[ ${2} =~ ^[0-9]+$ ]]; then bg="48;5;${2}" # ANSI 256-color code elif [[ ${2} =~ ^[0-9]{1,3}(\;[0-9]{1,3}){2}$ ]]; then bg="48;2;${2}" # RGB color code elif [[ ${2} =~ ^#[0-9A-Fa-f]{6}$ ]]; then local REPLY _omb_theme_powerline_hex_to_rgb "${2}" bg="48;2;${REPLY}" # Hex color code converted to RGB fi fi echo -e "\[\033[${fg}${fg:+${bg:+;}}${bg}m\]" } function __powerline_user_info_prompt { local user_info="" local color=${USER_INFO_THEME_PROMPT_COLOR} local secondary_color="${USER_INFO_THEME_PROMPT_SECONDARY_COLOR}" if [[ "${THEME_CHECK_SUDO}" = true ]]; then # check whether sudo is active for no-password executions if sudo -n cat <<< c3bcc5c 2>&1 | grep -q c3bcc5c; then color=${USER_INFO_THEME_PROMPT_COLOR_SUDO} fi fi case "${POWERLINE_PROMPT_USER_INFO_MODE}" in "sudo") if [[ "${color}" == "${USER_INFO_THEME_PROMPT_COLOR_SUDO}" ]]; then user_info="!" fi ;; *) if [[ -n "${SSH_CLIENT}" ]]; then user_info="${USER_INFO_SSH_CHAR}${USER}@${HOSTNAME}" else user_info="${USER}" fi ;; esac [[ -n "${user_info}" ]] && _omb_util_print "${user_info}|${color}|${secondary_color}" } function __powerline_ruby_prompt { local ruby_version="" if _omb_util_command_exists 'rvm'; then ruby_version="$(rvm_version_prompt)" elif _omb_util_command_exists 'rbenv'; then ruby_version=$(rbenv_version_prompt) fi [[ -n "${ruby_version}" ]] && _omb_util_print "${RUBY_CHAR}${ruby_version}|${RUBY_THEME_PROMPT_COLOR}" } function __powerline_python_venv_prompt { local python_venv="" if [[ -n "${CONDA_DEFAULT_ENV}" ]]; then python_venv="${CONDA_DEFAULT_ENV}" PYTHON_VENV_CHAR=${CONDA_PYTHON_VENV_CHAR} elif [[ -n "${VIRTUAL_ENV}" ]]; then python_venv=$(basename "${VIRTUAL_ENV}") fi [[ -n "${python_venv}" ]] && _omb_util_print "${PYTHON_VENV_CHAR}${python_venv}|${PYTHON_VENV_THEME_PROMPT_COLOR}" } function __powerline_scm_prompt { local color="" local scm_prompt="" scm_prompt_vars if [[ "${SCM_NONE_CHAR}" != "${SCM_CHAR}" ]]; then if [[ "${SCM_DIRTY}" -eq 3 ]]; then color=${SCM_THEME_PROMPT_STAGED_COLOR} elif [[ "${SCM_DIRTY}" -eq 2 ]]; then color=${SCM_THEME_PROMPT_UNSTAGED_COLOR} elif [[ "${SCM_DIRTY}" -eq 1 ]]; then color=${SCM_THEME_PROMPT_DIRTY_COLOR} else color=${SCM_THEME_PROMPT_CLEAN_COLOR} fi if [[ "${SCM_GIT_CHAR}" == "${SCM_CHAR}" ]]; then scm_prompt+="${SCM_CHAR}${SCM_BRANCH}${SCM_STATE}" fi _omb_util_print "${scm_prompt}${scm}|${color}" fi } function __powerline_cwd_prompt { _omb_util_print "$(pwd | sed "s|^${HOME}|~|")|${CWD_THEME_PROMPT_COLOR}" } function __powerline_clock_prompt { _omb_util_print "$(date +"${THEME_CLOCK_FORMAT}")|${CLOCK_THEME_PROMPT_COLOR}" } function __powerline_battery_prompt { local color="" local battery_status="$(battery_percentage 2> /dev/null)" if [[ -z "${battery_status}" ]] || [[ "${battery_status}" = "-1" ]] || [[ "${battery_status}" = "no" ]]; then true else if [[ "$((10#${battery_status}))" -le 5 ]]; then color="${BATTERY_STATUS_THEME_PROMPT_CRITICAL_COLOR}" elif [[ "$((10#${battery_status}))" -le 25 ]]; then color="${BATTERY_STATUS_THEME_PROMPT_LOW_COLOR}" else color="${BATTERY_STATUS_THEME_PROMPT_GOOD_COLOR}" fi ac_adapter_connected && battery_status="${BATTERY_AC_CHAR}${battery_status}" _omb_util_print "${battery_status}%|${color}" fi } function __powerline_in_vim_prompt { if [ -n "$VIMRUNTIME" ]; then _omb_util_print "${IN_VIM_THEME_PROMPT_TEXT}|${IN_VIM_THEME_PROMPT_COLOR}" fi } function __powerline_left_segment { local OLD_IFS="${IFS}"; IFS="|" local params=( $1 ) IFS="${OLD_IFS}" local separator_char="${POWERLINE_LEFT_SEPARATOR}" local separator="" local text_color=${params[2]:-"-"} if [[ "${SEGMENTS_AT_LEFT}" -gt 0 ]]; then separator="$(set_color ${LAST_SEGMENT_COLOR} ${params[1]})${separator_char}${_omb_prompt_normal}" fi LEFT_PROMPT+="${separator}$(set_color ${text_color} ${params[1]}) ${params[0]} ${_omb_prompt_normal}" LAST_SEGMENT_COLOR=${params[1]} (( SEGMENTS_AT_LEFT += 1 )) } function __powerline_last_status_prompt { [[ "$1" -ne 0 ]] && _omb_util_print "${1}|${LAST_STATUS_THEME_PROMPT_COLOR}" } function __powerline_prompt_command { local last_status="$?" ## always the first local separator_char="${POWERLINE_PROMPT_CHAR}" LEFT_PROMPT="" SEGMENTS_AT_LEFT=0 LAST_SEGMENT_COLOR="" # The IFS (internal field seperator) may have been changed outside to not contain # the space character ' ' whence we need to make sure that the space separated list # stored in POWERLINE_PROMPT is converted into an array correctly. IFS=' ' read -r -a POWERLINE_PROMPT_ARRAY <<< "${POWERLINE_PROMPT}" ## left prompt ## for segment in ${POWERLINE_PROMPT_ARRAY[@]}; do local info="$(__powerline_${segment}_prompt)" [[ -n "${info}" ]] && __powerline_left_segment "${info}" done ## info status prompt ## local info="$(__powerline_last_status_prompt ${last_status})" [[ -n "${info}" ]] && __powerline_left_segment "${info}" [[ -n "${LEFT_PROMPT}" ]] && LEFT_PROMPT+="$(set_color ${LAST_SEGMENT_COLOR} -)${separator_char}${_omb_prompt_normal}" PS1="${LEFT_PROMPT} " ## cleanup ## unset LAST_SEGMENT_COLOR \ LEFT_PROMPT \ SEGMENTS_AT_LEFT } ================================================ FILE: themes/powerline/powerline.theme.sh ================================================ #! bash oh-my-bash.module source "$OSH/themes/powerline/powerline.base.sh" PROMPT_CHAR=${POWERLINE_PROMPT_CHAR:=""} POWERLINE_LEFT_SEPARATOR=${POWERLINE_LEFT_SEPARATOR:=""} USER_INFO_SSH_CHAR=${POWERLINE_USER_INFO_SSH_CHAR:=" "} USER_INFO_THEME_PROMPT_COLOR=32 USER_INFO_THEME_PROMPT_SECONDARY_COLOR="-" USER_INFO_THEME_PROMPT_COLOR_SUDO=202 PYTHON_VENV_CHAR=${POWERLINE_PYTHON_VENV_CHAR:="❲p❳ "} CONDA_PYTHON_VENV_CHAR=${POWERLINE_CONDA_PYTHON_VENV_CHAR:="❲c❳ "} PYTHON_VENV_THEME_PROMPT_COLOR=35 SCM_NONE_CHAR="" SCM_GIT_CHAR=${POWERLINE_SCM_GIT_CHAR:=" "} SCM_THEME_PROMPT_CLEAN="" SCM_THEME_PROMPT_DIRTY="" SCM_THEME_PROMPT_CLEAN_COLOR=25 SCM_THEME_PROMPT_DIRTY_COLOR=88 SCM_THEME_PROMPT_STAGED_COLOR=30 SCM_THEME_PROMPT_UNSTAGED_COLOR=92 SCM_THEME_PROMPT_COLOR=${SCM_THEME_PROMPT_CLEAN_COLOR} RVM_THEME_PROMPT_PREFIX="" RVM_THEME_PROMPT_SUFFIX="" RBENV_THEME_PROMPT_PREFIX="" RBENV_THEME_PROMPT_SUFFIX="" RUBY_THEME_PROMPT_COLOR=161 RUBY_CHAR=${POWERLINE_RUBY_CHAR:="❲r❳ "} CWD_THEME_PROMPT_COLOR=240 LAST_STATUS_THEME_PROMPT_COLOR=52 CLOCK_THEME_PROMPT_COLOR=240 BATTERY_AC_CHAR=${BATTERY_AC_CHAR:="⚡"} BATTERY_STATUS_THEME_PROMPT_GOOD_COLOR=70 BATTERY_STATUS_THEME_PROMPT_LOW_COLOR=208 BATTERY_STATUS_THEME_PROMPT_CRITICAL_COLOR=160 THEME_CLOCK_FORMAT=${THEME_CLOCK_FORMAT:="%H:%M:%S"} IN_VIM_THEME_PROMPT_COLOR=245 IN_VIM_THEME_PROMPT_TEXT="vim" POWERLINE_PROMPT=${POWERLINE_PROMPT:="user_info scm python_venv ruby cwd"} function _omb_theme_PROMPT_COMMAND { __powerline_prompt_command "$@"; } _omb_util_add_prompt_command _omb_theme_PROMPT_COMMAND ================================================ FILE: themes/powerline-icon/README.md ================================================ # Powerline Icon Theme A theme derived from Powerline with emoji icons. This is based on the Powerline theme. Please see also [the documentation of the powerline theme](../powerline/README.md). ![Screenshot](./powerline-icon-dark.png?raw=true) ## Segments The `powerline-icon` theme modifies the segments `user_info` and `cwd` of the original Powerline theme so that they include icons. This theme also inserts a date string in `user_info`. ## Configuration Icons can be configured by setting values to the following shell variables. ``` OMB_THEME_POWERLINE_ICON_USER OMB_THEME_POWERLINE_ICON_HOME OMB_THEME_POWERLINE_ICON_EXIT_FAILURE OMB_THEME_POWERLINE_ICON_EXIT_SUCCESS ``` The time format shown in the `user_info` segment can be configured by the following shell variable: ``` OMB_THEME_POWERLINE_ICON_CLOCK ``` The default value is `%X %D`. ================================================ FILE: themes/powerline-icon/powerline-icon.base.sh ================================================ #! bash oh-my-bash.module source "$OSH/themes/powerline/powerline.base.sh" : "${OMB_THEME_POWERLINE_ICON_USER=🐧}" : "${OMB_THEME_POWERLINE_ICON_HOME=🏠}" : "${OMB_THEME_POWERLINE_ICON_EXIT_FAILURE=❌}" : "${OMB_THEME_POWERLINE_ICON_EXIT_SUCCESS=✅}" function __powerline_user_info_prompt { local user_info="" local color=$USER_INFO_THEME_PROMPT_COLOR local secondary_color=$USER_INFO_THEME_PROMPT_SECONDARY_COLOR if [[ $THEME_CHECK_SUDO == true ]]; then # check whether sudo is active for no-password executions if sudo -n cat <<< c3bcc5c 2>&1 | grep -q c3bcc5c; then color=${USER_INFO_THEME_PROMPT_COLOR_SUDO} fi fi case $POWERLINE_PROMPT_USER_INFO_MODE in "sudo") if [[ $color == "$USER_INFO_THEME_PROMPT_COLOR_SUDO" ]]; then user_info="!" fi ;; *) if [[ $SSH_CLIENT ]]; then user_info=$USER_INFO_SSH_CHAR$USER@$HOSTNAME else user_info=$USER fi ;; esac if [[ $user_info ]]; then local clock=$(date +"${OMB_THEME_POWERLINE_ICON_CLOCK-%X %D}") _omb_util_print "$OMB_THEME_POWERLINE_ICON_USER $user_info${clock:+ $clock}|$color|$secondary_color" fi } function __powerline_cwd_prompt { _omb_util_print "$(pwd | sed "s|^$HOME|$OMB_THEME_POWERLINE_ICON_HOME|")|$CWD_THEME_PROMPT_COLOR" } function __powerline_last_status_prompt { if (($1 != 0)); then _omb_util_print "$OMB_THEME_POWERLINE_ICON_EXIT_FAILURE${1}|${LAST_STATUS_THEME_PROMPT_COLOR}" else _omb_util_print "$OMB_THEME_POWERLINE_ICON_EXIT_SUCCESS|${LAST_STATUS_THEME_PROMPT_COLOR_SUCCESS}" fi } ================================================ FILE: themes/powerline-icon/powerline-icon.theme.sh ================================================ #! bash oh-my-bash.module source "$OSH/themes/powerline-icon/powerline-icon.base.sh" PROMPT_CHAR=${POWERLINE_PROMPT_CHAR:=""} POWERLINE_LEFT_SEPARATOR=${POWERLINE_LEFT_SEPARATOR:=""} USER_INFO_SSH_CHAR=${POWERLINE_USER_INFO_SSH_CHAR:=" "} USER_INFO_THEME_PROMPT_COLOR=0 USER_INFO_THEME_PROMPT_SECONDARY_COLOR="-" USER_INFO_THEME_PROMPT_COLOR_SUDO=202 PYTHON_VENV_CHAR=${POWERLINE_PYTHON_VENV_CHAR:="❲🐍❳ "} CONDA_PYTHON_VENV_CHAR=${POWERLINE_CONDA_PYTHON_VENV_CHAR:="❲c❳ "} PYTHON_VENV_THEME_PROMPT_COLOR=35 SCM_NONE_CHAR="" SCM_GIT_CHAR=${POWERLINE_SCM_GIT_CHAR:=" "} SCM_THEME_PROMPT_CLEAN="" SCM_THEME_PROMPT_DIRTY="" SCM_THEME_PROMPT_CLEAN_COLOR=25 SCM_THEME_PROMPT_DIRTY_COLOR=88 SCM_THEME_PROMPT_STAGED_COLOR=30 SCM_THEME_PROMPT_UNSTAGED_COLOR=92 SCM_THEME_PROMPT_COLOR=${SCM_THEME_PROMPT_CLEAN_COLOR} RVM_THEME_PROMPT_PREFIX="" RVM_THEME_PROMPT_SUFFIX="" RBENV_THEME_PROMPT_PREFIX="" RBENV_THEME_PROMPT_SUFFIX="" RUBY_THEME_PROMPT_COLOR=161 RUBY_CHAR=${POWERLINE_RUBY_CHAR:="❲r❳ "} CWD_THEME_PROMPT_COLOR=30 LAST_STATUS_THEME_PROMPT_COLOR=52 LAST_STATUS_THEME_PROMPT_COLOR_SUCCESS=42 CLOCK_THEME_PROMPT_COLOR=240 BATTERY_AC_CHAR=${BATTERY_AC_CHAR:="⚡"} BATTERY_STATUS_THEME_PROMPT_GOOD_COLOR=70 BATTERY_STATUS_THEME_PROMPT_LOW_COLOR=208 BATTERY_STATUS_THEME_PROMPT_CRITICAL_COLOR=160 THEME_CLOCK_FORMAT=${THEME_CLOCK_FORMAT:="%H:%M:%S"} IN_VIM_THEME_PROMPT_COLOR=245 IN_VIM_THEME_PROMPT_TEXT="vim" POWERLINE_PROMPT=${POWERLINE_PROMPT:="user_info scm python_venv ruby cwd"} OMB_THEME_POWERLINE_ICON_USER='🐧' OMB_THEME_POWERLINE_ICON_HOME='🏠' OMB_THEME_POWERLINE_ICON_EXIT_FAILURE='❌' OMB_THEME_POWERLINE_ICON_EXIT_SUCCESS='✅' function _omb_theme_PROMPT_COMMAND { __powerline_prompt_command "$@"; } _omb_util_add_prompt_command _omb_theme_PROMPT_COMMAND ================================================ FILE: themes/powerline-light/README.md ================================================ # Powerline Light Theme A Powerline-derived theme for light backgrounds aiming to balance bling and utility. Created by [Imran Chaudhry](https://imranchaudhry.com/) / April 2023. The colours were set using some experimentation and consulting an xterm 256 colour chart like [this](https://github.com/gawin/bash-colors-256) This is based on the Powerline theme. Please see also [the documentation of the powerline theme](../powerline/README.md). ![Screenshot](./powerline-light.png?raw=true) ================================================ FILE: themes/powerline-light/powerline-light.theme.sh ================================================ #! bash oh-my-bash.module source "$OSH/themes/powerline/powerline.base.sh" PROMPT_CHAR=${POWERLINE_PROMPT_CHAR:=""} POWERLINE_LEFT_SEPARATOR=${POWERLINE_LEFT_SEPARATOR:=""} USER_INFO_SSH_CHAR=${POWERLINE_USER_INFO_SSH_CHAR:=" "} USER_INFO_THEME_PROMPT_COLOR=45 USER_INFO_THEME_PROMPT_SECONDARY_COLOR="-" USER_INFO_THEME_PROMPT_COLOR_SUDO=1 PYTHON_VENV_CHAR=${POWERLINE_PYTHON_VENV_CHAR:="❲p❳ "} CONDA_PYTHON_VENV_CHAR=${POWERLINE_CONDA_PYTHON_VENV_CHAR:="❲c❳ "} PYTHON_VENV_THEME_PROMPT_COLOR=35 SCM_NONE_CHAR="" SCM_GIT_CHAR=${POWERLINE_SCM_GIT_CHAR:=" "} SCM_THEME_PROMPT_CLEAN="" SCM_THEME_PROMPT_DIRTY="" SCM_THEME_PROMPT_CLEAN_COLOR=40 SCM_THEME_PROMPT_DIRTY_COLOR=208 SCM_THEME_PROMPT_STAGED_COLOR=14 SCM_THEME_PROMPT_UNSTAGED_COLOR=220 SCM_THEME_PROMPT_COLOR=${SCM_THEME_PROMPT_CLEAN_COLOR} RVM_THEME_PROMPT_PREFIX="" RVM_THEME_PROMPT_SUFFIX="" RBENV_THEME_PROMPT_PREFIX="" RBENV_THEME_PROMPT_SUFFIX="" RUBY_THEME_PROMPT_COLOR=161 RUBY_CHAR=${POWERLINE_RUBY_CHAR:="❲r❳ "} CWD_THEME_PROMPT_COLOR=7 LAST_STATUS_THEME_PROMPT_COLOR=6 CLOCK_THEME_PROMPT_COLOR=240 BATTERY_AC_CHAR=${BATTERY_AC_CHAR:="⚡"} BATTERY_STATUS_THEME_PROMPT_GOOD_COLOR=70 BATTERY_STATUS_THEME_PROMPT_LOW_COLOR=208 BATTERY_STATUS_THEME_PROMPT_CRITICAL_COLOR=160 THEME_CLOCK_FORMAT=${THEME_CLOCK_FORMAT:="%H:%M:%S"} IN_VIM_THEME_PROMPT_COLOR=245 IN_VIM_THEME_PROMPT_TEXT="vim" POWERLINE_PROMPT=${POWERLINE_PROMPT:="user_info scm python_venv ruby cwd"} function _omb_theme_PROMPT_COMMAND { __powerline_prompt_command "$@"; } _omb_util_add_prompt_command _omb_theme_PROMPT_COMMAND ================================================ FILE: themes/powerline-multiline/README.md ================================================ # Powerline Multiline Theme A colorful multiline theme, where the first line shows information about your shell session (divided into two parts, left and right), and the second one is where the shell commands are introduced. **IMPORTANT:** This theme requires that [a font with the Powerline symbols](https://github.com/powerline/fonts) needs to be used in your terminal emulator, otherwise the prompt won't be displayed correctly, i.e. some of the additional icons and characters will be missing. Please follow your operating system's instructions to install one of the fonts from the above link and select it in your terminal emulator. ## Provided Information * Current path * Current username and hostname * Current time * An indicator when connected by SSH * An indicator when `sudo` has the credentials cached (see the `sudo` manpage for more info about this) * An indicator when the current shell is inside the Vim editor * Battery charging status (depends on the [../../plugins/battery/battery.plugin.sh](battery plugin)) * SCM Repository status (e.g. Git, SVN) * The current Python environment (Virtualenv, venv, and Conda are supported) in use * The current Ruby environment (rvm and rbenv are supported) in use * Last command exit code (only shown when the exit code is greater than 0) ## Configuration This theme is pretty configurable, all the configuration is done by setting environment variables. ### User Information By default, the username and hostname are shown on the right hand side, but you can change this behavior by setting the value of the following variable: POWERLINE_PROMPT_USER_INFO_MODE="sudo" For now, the only supported value is `sudo`, which hides the username and hostname, and shows an indicator when `sudo` has the credentials cached. Other values have no effect at this time. ### Clock Format By default, the current time is shown on the right hand side, you can change the format using the following variable: THEME_CLOCK_FORMAT="%H:%M:%S" The time/date is printed by the `date` command, so refer to its man page to change the format. ### Segment Order The contents of both prompt sides can be "reordered", all the "segments" (every piece of information) can take any place. The currently available segments are: * battery * clock * cwd * in_vim * python_venv * ruby * scm * user_info Two variables can be defined to set the order of the prompt segments: POWERLINE_LEFT_PROMPT="scm python_venv ruby cwd" POWERLINE_RIGHT_PROMPT="in_vim clock battery user_info" The example values above are the current default values, but if you want to remove anything from the prompt, simply remove the "string" that represents the segment from the corresponding variable. ================================================ FILE: themes/powerline-multiline/powerline-multiline.base.sh ================================================ #! bash oh-my-bash.module source "$OSH/themes/powerline/powerline.base.sh" function __powerline_last_status_prompt { (($1 != 0)) && _omb_util_print "$(set_color $LAST_STATUS_THEME_PROMPT_COLOR -) $1 $_omb_prompt_normal" } function __powerline_right_segment { local OLD_IFS=$IFS; IFS='|' local params=( $1 ) IFS=$OLD_IFS local separator_char=$POWERLINE_RIGHT_SEPARATOR local padding=2 local separator_color="" local text_color=${params[2]:-'-'} if ((SEGMENTS_AT_RIGHT == 0)); then separator_color=$(set_color ${params[1]} -) else separator_color=$(set_color ${params[1]} $LAST_SEGMENT_COLOR) ((padding += 1)) fi RIGHT_PROMPT+="$separator_color$separator_char$_omb_prompt_normal$(set_color $text_color ${params[1]}) ${params[0]} $_omb_prompt_normal$(set_color - $COLOR)$_omb_prompt_normal" RIGHT_PROMPT_LENGTH=$((${#params[0]} + RIGHT_PROMPT_LENGTH + padding)) LAST_SEGMENT_COLOR=${params[1]} ((SEGMENTS_AT_RIGHT += 1)) } function __powerline_prompt_command { local last_status=$? ## always the first local separator_char=$POWERLINE_LEFT_SEPARATOR local move_cursor_rightmost='\033[500C' local LEFT_PROMPT="" local RIGHT_PROMPT="" local RIGHT_PROMPT_LENGTH=0 local SEGMENTS_AT_LEFT=0 local SEGMENTS_AT_RIGHT=0 local LAST_SEGMENT_COLOR="" ## left prompt ## for segment in $POWERLINE_LEFT_PROMPT; do local info=$(__powerline_"$segment"_prompt) [[ $info ]] && __powerline_left_segment "$info" done [[ $LEFT_PROMPT ]] && LEFT_PROMPT+=$(set_color ${LAST_SEGMENT_COLOR} -)${separator_char}${_omb_prompt_normal} ## right prompt ## if [[ $POWERLINE_RIGHT_PROMPT ]]; then LEFT_PROMPT+=$move_cursor_rightmost for segment in $POWERLINE_RIGHT_PROMPT; do local info=$(__powerline_"$segment"_prompt) [[ $info ]] && __powerline_right_segment "$info" done LEFT_PROMPT+="\033[${RIGHT_PROMPT_LENGTH}D" fi PS1="$LEFT_PROMPT$RIGHT_PROMPT\n$(__powerline_last_status_prompt $last_status)$PROMPT_CHAR " } ================================================ FILE: themes/powerline-multiline/powerline-multiline.theme.sh ================================================ #! bash oh-my-bash.module source "$OSH/themes/powerline-multiline/powerline-multiline.base.sh" PROMPT_CHAR=${POWERLINE_PROMPT_CHAR:="❯"} POWERLINE_LEFT_SEPARATOR=${POWERLINE_LEFT_SEPARATOR:=""} POWERLINE_RIGHT_SEPARATOR=${POWERLINE_RIGHT_SEPARATOR:=""} USER_INFO_SSH_CHAR=${POWERLINE_USER_INFO_SSH_CHAR:=" "} USER_INFO_THEME_PROMPT_COLOR=32 USER_INFO_THEME_PROMPT_SECONDARY_COLOR="-" USER_INFO_THEME_PROMPT_COLOR_SUDO=202 PYTHON_VENV_CHAR=${POWERLINE_PYTHON_VENV_CHAR:="❲p❳ "} CONDA_PYTHON_VENV_CHAR=${POWERLINE_CONDA_PYTHON_VENV_CHAR:="❲c❳ "} PYTHON_VENV_THEME_PROMPT_COLOR=35 SCM_NONE_CHAR="" SCM_GIT_CHAR=${POWERLINE_SCM_GIT_CHAR:=" "} SCM_THEME_PROMPT_CLEAN="" SCM_THEME_PROMPT_DIRTY="" SCM_THEME_PROMPT_CLEAN_COLOR=25 SCM_THEME_PROMPT_DIRTY_COLOR=88 SCM_THEME_PROMPT_STAGED_COLOR=30 SCM_THEME_PROMPT_UNSTAGED_COLOR=92 SCM_THEME_PROMPT_COLOR=${SCM_THEME_PROMPT_CLEAN_COLOR} RVM_THEME_PROMPT_PREFIX="" RVM_THEME_PROMPT_SUFFIX="" RBENV_THEME_PROMPT_PREFIX="" RBENV_THEME_PROMPT_SUFFIX="" RUBY_THEME_PROMPT_COLOR=161 RUBY_CHAR=${POWERLINE_RUBY_CHAR:="❲r❳ "} CWD_THEME_PROMPT_COLOR=240 LAST_STATUS_THEME_PROMPT_COLOR=196 CLOCK_THEME_PROMPT_COLOR=240 BATTERY_AC_CHAR=${BATTERY_AC_CHAR:="⚡"} BATTERY_STATUS_THEME_PROMPT_GOOD_COLOR=70 BATTERY_STATUS_THEME_PROMPT_LOW_COLOR=208 BATTERY_STATUS_THEME_PROMPT_CRITICAL_COLOR=160 THEME_CLOCK_FORMAT=${THEME_CLOCK_FORMAT:="%H:%M:%S"} IN_VIM_THEME_PROMPT_COLOR=245 IN_VIM_THEME_PROMPT_TEXT="vim" POWERLINE_LEFT_PROMPT=${POWERLINE_LEFT_PROMPT:="scm python_venv ruby cwd"} POWERLINE_RIGHT_PROMPT=${POWERLINE_RIGHT_PROMPT:="in_vim clock battery user_info"} function _omb_theme_PROMPT_COMMAND { __powerline_prompt_command "$@"; } _omb_util_add_prompt_command _omb_theme_PROMPT_COMMAND ================================================ FILE: themes/powerline-naked/README.md ================================================ # Powerline Naked Theme A simple theme derived from the Powerline theme. This is based on the Powerline theme. Please see also [the documentation of the powerline theme](../powerline/README.md). ![Screenshot](./powerline-naked-dark.png?raw=true) ================================================ FILE: themes/powerline-naked/powerline-naked.base.sh ================================================ #! bash oh-my-bash.module source "$OSH/themes/powerline/powerline.base.sh" function __powerline_left_segment { local OLD_IFS=$IFS; IFS='|' local params=( $1 ) IFS=$OLD_IFS local separator_char="" local separator="" local background_color=${params[2]:-'-'} if ((SEGMENTS_AT_LEFT > 0)); then separator=$separator_char fi LEFT_PROMPT+="${separator}$(set_color ${params[1]} ${background_color}) ${params[0]} ${_omb_prompt_normal}" ((SEGMENTS_AT_LEFT += 1)) } ================================================ FILE: themes/powerline-naked/powerline-naked.theme.sh ================================================ #! bash oh-my-bash.module source "$OSH/themes/powerline-naked/powerline-naked.base.sh" PROMPT_CHAR=${POWERLINE_PROMPT_CHAR:=""} POWERLINE_LEFT_SEPARATOR=${POWERLINE_LEFT_SEPARATOR:=""} USER_INFO_SSH_CHAR=${POWERLINE_USER_INFO_SSH_CHAR:=" "} USER_INFO_THEME_PROMPT_COLOR=240 USER_INFO_THEME_PROMPT_SECONDARY_COLOR="-" USER_INFO_THEME_PROMPT_COLOR_SUDO=202 PYTHON_VENV_CHAR=${POWERLINE_PYTHON_VENV_CHAR:="❲p❳ "} CONDA_PYTHON_VENV_CHAR=${POWERLINE_CONDA_PYTHON_VENV_CHAR:="❲c❳ "} PYTHON_VENV_THEME_PROMPT_COLOR=35 SCM_NONE_CHAR="" SCM_GIT_CHAR=${POWERLINE_SCM_GIT_CHAR:=" "} SCM_THEME_PROMPT_CLEAN="" SCM_THEME_PROMPT_DIRTY="" SCM_THEME_PROMPT_COLOR=238 SCM_THEME_PROMPT_CLEAN_COLOR=25 SCM_THEME_PROMPT_DIRTY_COLOR=88 SCM_THEME_PROMPT_STAGED_COLOR=30 SCM_THEME_PROMPT_UNSTAGED_COLOR=92 SCM_THEME_PROMPT_COLOR=${SCM_THEME_PROMPT_CLEAN_COLOR} RVM_THEME_PROMPT_PREFIX="" RVM_THEME_PROMPT_SUFFIX="" RBENV_THEME_PROMPT_PREFIX="" RBENV_THEME_PROMPT_SUFFIX="" RUBY_THEME_PROMPT_COLOR=161 RUBY_CHAR=${POWERLINE_RUBY_CHAR:="❲r❳ "} CWD_THEME_PROMPT_COLOR=254 LAST_STATUS_THEME_PROMPT_COLOR=124 CLOCK_THEME_PROMPT_COLOR=240 BATTERY_AC_CHAR=${BATTERY_AC_CHAR:="⚡"} BATTERY_STATUS_THEME_PROMPT_GOOD_COLOR=70 BATTERY_STATUS_THEME_PROMPT_LOW_COLOR=208 BATTERY_STATUS_THEME_PROMPT_CRITICAL_COLOR=160 THEME_CLOCK_FORMAT=${THEME_CLOCK_FORMAT:="%H:%M:%S"} IN_VIM_THEME_PROMPT_COLOR=245 IN_VIM_THEME_PROMPT_TEXT="vim" POWERLINE_PROMPT=${POWERLINE_PROMPT:="user_info scm python_venv ruby cwd"} function _omb_theme_PROMPT_COMMAND { __powerline_prompt_command "$@"; } _omb_util_add_prompt_command _omb_theme_PROMPT_COMMAND ================================================ FILE: themes/powerline-plain/README.md ================================================ # Powerline Plain Theme A simplified version of the Powerline theme. This is based on the Powerline theme. Please see also [the documentation of the powerline theme](../powerline/README.md). This theme does not require a font with the Powerline symbols as required in the original Powerline theme. ![Screenshot](./powerline-plain-dark.png?raw=true) ================================================ FILE: themes/powerline-plain/powerline-plain.base.sh ================================================ #! bash oh-my-bash.module source "$OSH/themes/powerline/powerline.base.sh" function __powerline_left_segment { local OLD_IFS=$IFS; IFS='|' local params=( $1 ) IFS=$OLD_IFS local text_color=${params[2]:-'-'} LEFT_PROMPT+="$separator$(set_color $text_color ${params[1]}) ${params[0]} $_omb_prompt_normal" LAST_SEGMENT_COLOR=${params[1]} } function __powerline_prompt_command { local last_status=$? ## always the first local LEFT_PROMPT="" ## left prompt ## for segment in $POWERLINE_PROMPT; do local info=$(__powerline_"$segment"_prompt) [[ $info ]] && __powerline_left_segment "$info" done ((last_status != 0)) && __powerline_left_segment $(__powerline_last_status_prompt $last_status) [[ $LEFT_PROMPT ]] && LEFT_PROMPT+="$(set_color $LAST_SEGMENT_COLOR -) $_omb_prompt_normal" PS1="$LEFT_PROMPT " } ================================================ FILE: themes/powerline-plain/powerline-plain.theme.sh ================================================ #! bash oh-my-bash.module source "$OSH/themes/powerline-plain/powerline-plain.base.sh" USER_INFO_SSH_CHAR=${POWERLINE_USER_INFO_SSH_CHAR:="⌁ "} USER_INFO_THEME_PROMPT_COLOR=32 USER_INFO_THEME_PROMPT_SECONDARY_COLOR="-" USER_INFO_THEME_PROMPT_COLOR_SUDO=202 PYTHON_VENV_CHAR=${POWERLINE_PYTHON_VENV_CHAR:="ⓔ "} CONDA_PYTHON_VENV_CHAR=${POWERLINE_CONDA_PYTHON_VENV_CHAR:="ⓔ "} PYTHON_VENV_THEME_PROMPT_COLOR=35 SCM_NONE_CHAR="" SCM_GIT_CHAR=${POWERLINE_SCM_GIT_CHAR:="⎇ "} SCM_THEME_PROMPT_CLEAN="" SCM_THEME_PROMPT_DIRTY="" SCM_THEME_PROMPT_CLEAN_COLOR=25 SCM_THEME_PROMPT_DIRTY_COLOR=88 SCM_THEME_PROMPT_STAGED_COLOR=30 SCM_THEME_PROMPT_UNSTAGED_COLOR=92 SCM_THEME_PROMPT_COLOR=${SCM_THEME_PROMPT_CLEAN_COLOR} RVM_THEME_PROMPT_PREFIX="" RVM_THEME_PROMPT_SUFFIX="" RBENV_THEME_PROMPT_PREFIX="" RBENV_THEME_PROMPT_SUFFIX="" RUBY_THEME_PROMPT_COLOR=161 RUBY_CHAR=${POWERLINE_RUBY_CHAR:="ⓔ "} CWD_THEME_PROMPT_COLOR=240 LAST_STATUS_THEME_PROMPT_COLOR=52 CLOCK_THEME_PROMPT_COLOR=240 BATTERY_AC_CHAR=${BATTERY_AC_CHAR:="+ "} BATTERY_STATUS_THEME_PROMPT_GOOD_COLOR=70 BATTERY_STATUS_THEME_PROMPT_LOW_COLOR=208 BATTERY_STATUS_THEME_PROMPT_CRITICAL_COLOR=160 THEME_CLOCK_FORMAT=${THEME_CLOCK_FORMAT:="%H:%M:%S"} IN_VIM_THEME_PROMPT_COLOR=245 IN_VIM_THEME_PROMPT_TEXT="vim" POWERLINE_PROMPT=${POWERLINE_PROMPT:="user_info scm python_venv ruby cwd"} function _omb_theme_PROMPT_COMMAND { __powerline_prompt_command "$@"; } _omb_util_add_prompt_command _omb_theme_PROMPT_COMMAND ================================================ FILE: themes/powerline-wizard/README.md ================================================ # 🧙 Powerline-Wizard 🔮 ### Powerline-Wizard is a modified version of Powerline-Icon theme for Oh My Bash 🧑‍💻 ## 📸 Screenshots ![Screenshot](./powerline-wizard-dark.png?raw=true) ================================================ FILE: themes/powerline-wizard/powerline-wizard.theme.sh ================================================ #! bash oh-my-bash.module source "$OSH/themes/powerline-icon/powerline-icon.base.sh" PROMPT_CHAR=${POWERLINE_PROMPT_CHAR:=""} POWERLINE_LEFT_SEPARATOR=${POWERLINE_LEFT_SEPARATOR:=""} USER_INFO_SSH_CHAR=${POWERLINE_USER_INFO_SSH_CHAR:=" "} USER_INFO_THEME_PROMPT_COLOR=0 USER_INFO_THEME_PROMPT_SECONDARY_COLOR="-" USER_INFO_THEME_PROMPT_COLOR_SUDO=202 PYTHON_VENV_CHAR=${POWERLINE_PYTHON_VENV_CHAR:="❲🐍❳ "} CONDA_PYTHON_VENV_CHAR=${POWERLINE_CONDA_PYTHON_VENV_CHAR:="❲c❳ "} PYTHON_VENV_THEME_PROMPT_COLOR=35 SCM_NONE_CHAR="" SCM_GIT_CHAR=${POWERLINE_SCM_GIT_CHAR:=" "} SCM_THEME_PROMPT_CLEAN="" SCM_THEME_PROMPT_DIRTY="" SCM_THEME_PROMPT_CLEAN_COLOR=237 SCM_THEME_PROMPT_DIRTY_COLOR=142 SCM_THEME_PROMPT_STAGED_COLOR=237 SCM_THEME_PROMPT_UNSTAGED_COLOR=92 SCM_THEME_PROMPT_COLOR=${SCM_THEME_PROMPT_CLEAN_COLOR} RVM_THEME_PROMPT_PREFIX="" RVM_THEME_PROMPT_SUFFIX="" RBENV_THEME_PROMPT_PREFIX="" RBENV_THEME_PROMPT_SUFFIX="" RUBY_THEME_PROMPT_COLOR=161 RUBY_CHAR=${POWERLINE_RUBY_CHAR:="❲r❳ "} CWD_THEME_PROMPT_COLOR=236 LAST_STATUS_THEME_PROMPT_COLOR=52 LAST_STATUS_THEME_PROMPT_COLOR_SUCCESS=238 CLOCK_THEME_PROMPT_COLOR=240 BATTERY_AC_CHAR=${BATTERY_AC_CHAR:="⚡"} BATTERY_STATUS_THEME_PROMPT_GOOD_COLOR=70 BATTERY_STATUS_THEME_PROMPT_LOW_COLOR=208 BATTERY_STATUS_THEME_PROMPT_CRITICAL_COLOR=160 THEME_CLOCK_FORMAT=${THEME_CLOCK_FORMAT:="%H:%M:%S"} IN_VIM_THEME_PROMPT_COLOR=245 IN_VIM_THEME_PROMPT_TEXT="vim" POWERLINE_PROMPT=${POWERLINE_PROMPT:="user_info scm python_venv ruby cwd"} OMB_THEME_POWERLINE_ICON_USER='🧙' OMB_THEME_POWERLINE_ICON_HOME='🔮' OMB_THEME_POWERLINE_ICON_EXIT_FAILURE='🔥' OMB_THEME_POWERLINE_ICON_EXIT_SUCCESS='🌀' function _omb_theme_PROMPT_COMMAND { __powerline_prompt_command "$@"; } _omb_util_add_prompt_command _omb_theme_PROMPT_COMMAND ================================================ FILE: themes/primer/primer.theme.sh ================================================ #! bash oh-my-bash.module # based of the candy theme, but minimized by odbol function _omb_theme_PROMPT_COMMAND() { PS1="$(clock_prompt) ${_omb_prompt_reset_color}${_omb_prompt_white}\w${_omb_prompt_reset_color}$(scm_prompt_info)${_omb_prompt_navy} →${_omb_prompt_bold_navy} ${_omb_prompt_reset_color} "; } THEME_CLOCK_COLOR=${THEME_CLOCK_COLOR:-"$_omb_prompt_navy"} THEME_CLOCK_FORMAT=${THEME_CLOCK_FORMAT:-"%I:%M:%S"} _omb_util_add_prompt_command _omb_theme_PROMPT_COMMAND ================================================ FILE: themes/pro/pro.theme.sh ================================================ #! bash oh-my-bash.module SCM_THEME_PROMPT_DIRTY=" ${_omb_prompt_brown}✗" SCM_THEME_PROMPT_CLEAN=" ${_omb_prompt_green}✓" SCM_THEME_PROMPT_PREFIX=" ${_omb_prompt_navy}scm:( " SCM_THEME_PROMPT_SUFFIX="${_omb_prompt_navy} )" GIT_THEME_PROMPT_DIRTY=" ${_omb_prompt_brown}✗" GIT_THEME_PROMPT_CLEAN=" ${_omb_prompt_green}✓" GIT_THEME_PROMPT_PREFIX="${_omb_prompt_green}git:( " GIT_THEME_PROMPT_SUFFIX="${_omb_prompt_green} )" function git_prompt_info { git_prompt_vars echo -e "$SCM_PREFIX$SCM_BRANCH$SCM_STATE$SCM_SUFFIX" } function _omb_theme_PROMPT_COMMAND() { PS1="\h: \W $(scm_prompt_info)${_omb_prompt_reset_color} $ " } _omb_util_add_prompt_command _omb_theme_PROMPT_COMMAND ================================================ FILE: themes/pure/pure.theme.sh ================================================ #! bash oh-my-bash.module # scm theming SCM_THEME_PROMPT_PREFIX="|" SCM_THEME_PROMPT_SUFFIX="" SCM_THEME_PROMPT_DIRTY=" ${_omb_prompt_bold_brown}✗${_omb_prompt_normal}" SCM_THEME_PROMPT_CLEAN=" ${_omb_prompt_green}✓${_omb_prompt_normal}" SCM_GIT_CHAR="${_omb_prompt_green}±${_omb_prompt_normal}" SCM_SVN_CHAR="${_omb_prompt_bold_teal}⑆${_omb_prompt_normal}" SCM_HG_CHAR="${_omb_prompt_bold_brown}☿${_omb_prompt_normal}" ### TODO: openSUSE has already colors enabled, check if those differs from stock # LS colors, made with http://geoff.greer.fm/lscolors/ # export LSCOLORS="Gxfxcxdxbxegedabagacad" # export LS_COLORS='no=00:fi=00:di=01;34:ln=00;36:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=41;33;01:ex=00;32:*.cmd=00;32:*.exe=01;32:*.com=01;32:*.bat=01;32:*.btm=01;32:*.dll=01;32:*.tar=00;31:*.tbz=00;31:*.tgz=00;31:*.rpm=00;31:*.deb=00;31:*.arj=00;31:*.taz=00;31:*.lzh=00;31:*.lzma=00;31:*.zip=00;31:*.zoo=00;31:*.z=00;31:*.Z=00;31:*.gz=00;31:*.bz2=00;31:*.tb2=00;31:*.tz2=00;31:*.tbz2=00;31:*.avi=01;35:*.bmp=01;35:*.fli=01;35:*.gif=01;35:*.jpg=01;35:*.jpeg=01;35:*.mng=01;35:*.mov=01;35:*.mpg=01;35:*.pcx=01;35:*.pbm=01;35:*.pgm=01;35:*.png=01;35:*.ppm=01;35:*.tga=01;35:*.tif=01;35:*.xbm=01;35:*.xpm=01;35:*.dl=01;35:*.gl=01;35:*.wmv=01;35:*.aiff=00;32:*.au=00;32:*.mid=00;32:*.mp3=00;32:*.ogg=00;32:*.voc=00;32:*.wav=00;32:' function scm_prompt { CHAR=$(scm_char) if [ $CHAR = $SCM_NONE_CHAR ] then return else _omb_util_print "[$(scm_char)$(scm_prompt_info)]" fi } function _omb_theme_PROMPT_COMMAND { ps_host="${_omb_prompt_bold_navy}\h${_omb_prompt_normal}"; ps_user="${_omb_prompt_green}\u${_omb_prompt_normal}"; ps_user_mark="${_omb_prompt_green} $ ${_omb_prompt_normal}"; ps_root="${_omb_prompt_brown}\u${_omb_prompt_brown}"; ps_root_mark="${_omb_prompt_brown} # ${_omb_prompt_normal}" ps_path="${_omb_prompt_olive}\w${_omb_prompt_normal}"; # make it work case $(id -u) in 0) PS1="$ps_root@$ps_host$(scm_prompt):$ps_path$ps_root_mark" ;; *) PS1="$ps_user@$ps_host$(scm_prompt):$ps_path$ps_user_mark" ;; esac } _omb_util_add_prompt_command _omb_theme_PROMPT_COMMAND ================================================ FILE: themes/purity/purity.theme.sh ================================================ #! bash oh-my-bash.module SCM_THEME_PROMPT_DIRTY=" ${_omb_prompt_bold_brown}⊘${_omb_prompt_normal}" SCM_THEME_PROMPT_CLEAN=" ${_omb_prompt_bold_green}✓${_omb_prompt_normal}" SCM_THEME_PROMPT_PREFIX="${_omb_prompt_reset_color}( " SCM_THEME_PROMPT_SUFFIX=" ${_omb_prompt_reset_color})" GIT_THEME_PROMPT_DIRTY=" ${_omb_prompt_bold_brown}⊘${_omb_prompt_normal}" GIT_THEME_PROMPT_CLEAN=" ${_omb_prompt_bold_green}✓${_omb_prompt_normal}" GIT_THEME_PROMPT_PREFIX="${_omb_prompt_reset_color}( " GIT_THEME_PROMPT_SUFFIX=" ${_omb_prompt_reset_color})" OMB_THEME_PURITY_STATUS_BAD="${_omb_prompt_bold_brown}❯${_omb_prompt_reset_color}${_omb_prompt_normal} " OMB_THEME_PURITY_STATUS_OK="${_omb_prompt_bold_green}❯${_omb_prompt_reset_color}${_omb_prompt_normal} " _omb_deprecate_declare 20000 STATUS_THEME_PROMPT_BAD OMB_THEME_PURITY_STATUS_BAD sync _omb_deprecate_declare 20000 STATUS_THEME_PROMPT_OK OMB_THEME_PURITY_STATUS_OK sync function _omb_theme_PROMPT_COMMAND { if (($? == 0)); then local ret_status=${STATUS_THEME_PROMPT_OK:-${OMB_THEME_PURITY_STATUS_OK-}} else local ret_status=${STATUS_THEME_PROMPT_BAD:-${OMB_THEME_PURITY_STATUS_BAD-}} fi PS1="\n${_omb_prompt_navy}\w $(scm_prompt_info)\n${ret_status} " } _omb_util_add_prompt_command _omb_theme_PROMPT_COMMAND ================================================ FILE: themes/pzq/pzq.theme.sh ================================================ #!/usr/bin/env bash # Theme inspired by: # - ys theme - https://github.com/ohmyzsh/ohmyzsh/blob/master/themes/ys.zsh-theme # - rana theme - https://github.com/ohmybash/oh-my-bash/blob/master/themes/rana/rana.theme.sh # # by Ziqiang Pei OMB_PROMPT_CONDAENV_FORMAT='(%s)' OMB_PROMPT_VIRTUALENV_FORMAT='(%s)' OMB_PROMPT_SHOW_PYTHON_VENV=${OMB_PROMPT_SHOW_PYTHON_VENV:=true} # ----------------------------------------------------------------- COLOR CONF D_DEFAULT_COLOR="$_omb_prompt_white" D_INTERMEDIATE_COLOR="$_omb_prompt_bold_white" D_NUMBER_COLOR="$_omb_prompt_bold_navy" D_USER_COLOR="$_omb_prompt_teal" D_SUPERUSER_COLOR="$_omb_prompt_brown" D_MACHINE_COLOR="$_omb_prompt_green" D_DIR_COLOR="$_omb_prompt_bold_olive" D_GIT_DEFAULT_COLOR="$_omb_prompt_white" D_GIT_BRANCH_COLOR="$_omb_prompt_teal" D_GIT_PROMPT_COLOR="$_omb_prompt_brown" D_SCM_COLOR="$_omb_prompt_bold_olive" D_BRANCH_COLOR="$_omb_prompt_teal" D_CHANGES_COLOR="$_omb_prompt_white" D_TIME_COLOR="$_omb_prompt_white" D_DOLLOR_COLOR="$_omb_prompt_bold_brown" D_CMDFAIL_COLOR="$_omb_prompt_brown" D_VIMSHELL_COLOR="$_omb_prompt_teal" # ------------------------------------------------------------------ FUNCTIONS case $TERM in xterm*) TITLEBAR='\[\e]0;\w\e\\\]' ;; *) TITLEBAR="" ;; esac function is_vim_shell { if [[ ${VIMRUNTIME-} ]]; then _omb_util_print "${D_INTERMEDIATE_COLOR}on ${D_VIMSHELL_COLOR}vim shell${D_DEFAULT_COLOR} " fi } function mitsuhikos_lastcommandfailed { local status=$? if ((status != 0)); then _omb_util_print " ${D_DEFAULT_COLOR}C:${D_CMDFAIL_COLOR}$status ${D_DEFAULT_COLOR}" fi } # vcprompt for scm instead of oh-my-bash default function demula_vcprompt { if [[ ${VCPROMPT_EXECUTABLE-} ]]; then local D_VCPROMPT_FORMAT="on ${D_SCM_COLOR}%s${D_INTERMEDIATE_COLOR}:${D_BRANCH_COLOR}%b %r ${D_CHANGES_COLOR}%m%u ${D_DEFAULT_COLOR}" $VCPROMPT_EXECUTABLE -f "$D_VCPROMPT_FORMAT" fi } # checks if the plugin is installed before calling battery_charge function safe_battery_charge { if _omb_util_function_exists battery_charge; then battery_charge fi } function prompt_git { local branchName='' # Check if the current directory is in a Git repository. if _omb_prompt_git rev-parse --is-inside-work-tree &>/dev/null; then # Get the short symbolic ref. # If HEAD isn’t a symbolic ref, get the short SHA for the latest commit # Otherwise, just give up. branchName=$( _omb_prompt_git symbolic-ref --quiet --short HEAD 2> /dev/null || _omb_prompt_git rev-parse --short HEAD 2> /dev/null || _omb_util_print '(unknown)'); _omb_util_print "${D_GIT_DEFAULT_COLOR}on ${D_GIT_BRANCH_COLOR}${branchName} " else return fi } function limited_pwd { # Max length of PWD to display local MAX_PWD_LENGTH=20 # Replace $HOME with ~ if possible local RELATIVE_PWD=${PWD/#$HOME/\~} local offset=$((${#RELATIVE_PWD}-MAX_PWD_LENGTH)) if ((offset > 0)); then local truncated_symbol='...' local TRUNCATED_PWD=${RELATIVE_PWD:offset:MAX_PWD_LENGTH} _omb_util_put "${truncated_symbol}/${TRUNCATED_PWD#*/}" else _omb_util_put "${RELATIVE_PWD}" fi } # -------------------------------------------------------------- PROMPT OUTPUT function _omb_theme_PROMPT_COMMAND { local LAST_COMMAND_FAILED=$(mitsuhikos_lastcommandfailed) local SAVE_CURSOR='\[\e7' local RESTORE_CURSOR='\e8\]' local MOVE_CURSOR_RIGHTMOST='\e['${COLUMNS:-9999}'C' local MOVE_CURSOR_5_LEFT='\e[5D' local THEME_CLOCK_FORMAT="%H:%M:%S %y-%m-%d" # Replace $HOME with ~ if possible local RELATIVE_PWD=${PWD/#$HOME/\~} local python_venv _omb_prompt_get_python_venv PS1=${TITLEBAR}$python_venv$'\n' if [[ $OSTYPE == linux-gnu ]]; then PS1+="${SAVE_CURSOR}${MOVE_CURSOR_RIGHTMOST}${MOVE_CURSOR_5_LEFT}" PS1+="$(safe_battery_charge)${RESTORE_CURSOR}" PS1+="${D_NUMBER_COLOR}# ${D_USER_COLOR}\u ${D_DEFAULT_COLOR}" else PS1+="${D_NUMBER_COLOR}# ${D_USER_COLOR}\u ${D_DEFAULT_COLOR}" fi PS1+="@ ${D_MACHINE_COLOR}\h ${D_DEFAULT_COLOR}" PS1+="in ${D_DIR_COLOR}${RELATIVE_PWD} ${D_INTERMEDIATE_COLOR}" PS1+=$(prompt_git) PS1+=${D_TIME_COLOR}[$(clock_prompt)] PS1+=${LAST_COMMAND_FAILED} PS1+=$(demula_vcprompt) PS1+=$(is_vim_shell) if [[ $OSTYPE != linux-gnu ]]; then PS1+=$(safe_battery_charge) fi PS1+=$'\n'"${D_DOLLOR_COLOR}$ ${D_DEFAULT_COLOR}" PS2="${D_INTERMEDIATE_COLOR}$ ${D_DEFAULT_COLOR}" } # Runs prompt (this bypasses oh-my-bash $PROMPT setting) _omb_util_add_prompt_command _omb_theme_PROMPT_COMMAND ================================================ FILE: themes/rainbowbrite/rainbowbrite.theme.sh ================================================ #! bash oh-my-bash.module # based off of n0qorg # looks like, if you're in a git repo: # ± ~/path/to (branch ✓) $ # in glorious red / blue / yellow color scheme function _omb_theme_PROMPT_COMMAND { # Save history history -a history -c history -r # displays user@server in purple # PS1="$_omb_prompt_brown$(scm_char) $_omb_prompt_purple\u@\h$_omb_prompt_reset_color:$_omb_prompt_navy\w$_omb_prompt_olive$(scm_prompt_info)$(_omb_prompt_print_ruby_env) $_omb_prompt_gray\$$_omb_prompt_reset_color " # no user@server PS1="$_omb_prompt_brown$(scm_char) $_omb_prompt_navy\w$_omb_prompt_olive$(scm_prompt_info)$(_omb_prompt_print_ruby_env) $_omb_prompt_gray\$$_omb_prompt_reset_color " PS2='> ' PS4='+ ' } _omb_util_add_prompt_command _omb_theme_PROMPT_COMMAND SCM_NONE_CHAR='·' SCM_THEME_PROMPT_DIRTY=" ${_omb_prompt_brown}✗" SCM_THEME_PROMPT_CLEAN=" ${_omb_prompt_green}✓" SCM_THEME_PROMPT_PREFIX=" (" SCM_THEME_PROMPT_SUFFIX="${_omb_prompt_olive})" RVM_THEME_PROMPT_PREFIX=" (" RVM_THEME_PROMPT_SUFFIX=")" ================================================ FILE: themes/rana/rana.theme.sh ================================================ #! bash oh-my-bash.module # Theme inspired on: # - Ronacher's dotfiles (mitsuhikos) - http://github.com/mitsuhiko/dotfiles/tree/master/bash/ # - Glenbot - http://theglenbot.com/custom-bash-shell-for-development/ # - My extravagant zsh - http://stevelosh.com/blog/2010/02/my-extravagant-zsh-prompt/ # - Monokai colors - http://monokai.nl/blog/2006/07/15/textmate-color-theme/ # - Bash_it modern theme # # by Rana Amrit Parth # For the real Monokai colors you should add these to your .XDefaults or # terminal configuration: #! ----------------------------------------------------------- TERMINAL COLORS #! monokai - http://www.monokai.nl/blog/2006/07/15/textmate-color-theme/ #*background: #272822 #*foreground: #E2DA6E #*color0: black #! mild red #*color1: #CD0000 #! light green #*color2: #A5E02D #! orange (yellow) #*color3: #FB951F #! "dark" blue #*color4: #076BCC #! hot pink #*color5: #F6266C #! cyan #*color6: #64D9ED #! gray #*color7: #E5E5E5 # ----------------------------------------------------------------- DEF COLOR _omb_deprecate_const 20000 RCol "$_omb_prompt_normal" "${_omb_deprecate_msg_please_use/'%s'/_omb_prompt_normal}" _omb_deprecate_const 20000 Bla "$_omb_prompt_black" "${_omb_deprecate_msg_please_use/'%s'/_omb_prompt_black}" _omb_deprecate_const 20000 Red "$_omb_prompt_brown" "${_omb_deprecate_msg_please_use/'%s'/_omb_prompt_brown}" _omb_deprecate_const 20000 Gre "$_omb_prompt_green" "${_omb_deprecate_msg_please_use/'%s'/_omb_prompt_green}" _omb_deprecate_const 20000 Yel "$_omb_prompt_olive" "${_omb_deprecate_msg_please_use/'%s'/_omb_prompt_olive}" _omb_deprecate_const 20000 Blu "$_omb_prompt_navy" "${_omb_deprecate_msg_please_use/'%s'/_omb_prompt_navy}" _omb_deprecate_const 20000 Pur "$_omb_prompt_purple" "${_omb_deprecate_msg_please_use/'%s'/_omb_prompt_purple}" _omb_deprecate_const 20000 Cya "$_omb_prompt_teal" "${_omb_deprecate_msg_please_use/'%s'/_omb_prompt_teal}" _omb_deprecate_const 20000 Whi "$_omb_prompt_silver" "${_omb_deprecate_msg_please_use/'%s'/_omb_prompt_silver}" _omb_deprecate_const 20000 BBla "$_omb_prompt_bold_black" "${_omb_deprecate_msg_please_use/'%s'/_omb_prompt_bold_black}" _omb_deprecate_const 20000 BRed "$_omb_prompt_bold_brown" "${_omb_deprecate_msg_please_use/'%s'/_omb_prompt_bold_brown}" _omb_deprecate_const 20000 BGre "$_omb_prompt_bold_green" "${_omb_deprecate_msg_please_use/'%s'/_omb_prompt_bold_green}" _omb_deprecate_const 20000 BYel "$_omb_prompt_bold_olive" "${_omb_deprecate_msg_please_use/'%s'/_omb_prompt_bold_olive}" _omb_deprecate_const 20000 BBlu "$_omb_prompt_bold_navy" "${_omb_deprecate_msg_please_use/'%s'/_omb_prompt_bold_navy}" _omb_deprecate_const 20000 BPur "$_omb_prompt_bold_purple" "${_omb_deprecate_msg_please_use/'%s'/_omb_prompt_bold_purple}" _omb_deprecate_const 20000 BCya "$_omb_prompt_bold_teal" "${_omb_deprecate_msg_please_use/'%s'/_omb_prompt_bold_teal}" _omb_deprecate_const 20000 BWhi "$_omb_prompt_bold_silver" "${_omb_deprecate_msg_please_use/'%s'/_omb_prompt_bold_silver}" _omb_deprecate_const 20000 IBla "$_omb_prompt_gray" "${_omb_deprecate_msg_please_use/'%s'/_omb_prompt_gray}" _omb_deprecate_const 20000 IRed "$_omb_prompt_red" "${_omb_deprecate_msg_please_use/'%s'/_omb_prompt_red}" _omb_deprecate_const 20000 IGre "$_omb_prompt_lime" "${_omb_deprecate_msg_please_use/'%s'/_omb_prompt_lime}" _omb_deprecate_const 20000 IYel "$_omb_prompt_yellow" "${_omb_deprecate_msg_please_use/'%s'/_omb_prompt_yellow}" _omb_deprecate_const 20000 IBlu "$_omb_prompt_blue" "${_omb_deprecate_msg_please_use/'%s'/_omb_prompt_blue}" _omb_deprecate_const 20000 IPur "$_omb_prompt_magenta" "${_omb_deprecate_msg_please_use/'%s'/_omb_prompt_magenta}" _omb_deprecate_const 20000 ICya "$_omb_prompt_cyan" "${_omb_deprecate_msg_please_use/'%s'/_omb_prompt_cyan}" _omb_deprecate_const 20000 IWhi "$_omb_prompt_white" "${_omb_deprecate_msg_please_use/'%s'/_omb_prompt_white}" # ----------------------------------------------------------------- COLOR CONF D_DEFAULT_COLOR="$_omb_prompt_silver" D_INTERMEDIATE_COLOR="$_omb_prompt_bold_silver" D_USER_COLOR="$_omb_prompt_olive" D_SUPERUSER_COLOR="$_omb_prompt_brown" D_MACHINE_COLOR="$_omb_prompt_yellow" D_DIR_COLOR="$_omb_prompt_green" D_GIT_COLOR="$_omb_prompt_bold_navy" D_SCM_COLOR="$_omb_prompt_bold_olive" D_BRANCH_COLOR="$_omb_prompt_bold_olive" D_CHANGES_COLOR="$_omb_prompt_silver" D_CMDFAIL_COLOR="$_omb_prompt_brown" D_VIMSHELL_COLOR="$_omb_prompt_teal" # ------------------------------------------------------------------ FUNCTIONS case $TERM in xterm*) TITLEBAR='\[\e]0;\w\e\\\]' ;; *) TITLEBAR="" ;; esac function is_vim_shell { if [[ ${VIMRUNTIME-} ]]; then _omb_util_print "${D_INTERMEDIATE_COLOR}on ${D_VIMSHELL_COLOR}vim shell${D_DEFAULT_COLOR} " fi } function mitsuhikos_lastcommandfailed { local status=$? if ((status != 0)); then _omb_util_print "${D_INTERMEDIATE_COLOR}exited ${D_CMDFAIL_COLOR}$status ${D_DEFAULT_COLOR}" fi } # vcprompt for scm instead of oh-my-bash default function demula_vcprompt { if [[ ${VCPROMPT_EXECUTABLE-} ]]; then local D_VCPROMPT_FORMAT="on ${D_SCM_COLOR}%s${D_INTERMEDIATE_COLOR}:${D_BRANCH_COLOR}%b %r ${D_CHANGES_COLOR}%m%u ${D_DEFAULT_COLOR}" $VCPROMPT_EXECUTABLE -f "$D_VCPROMPT_FORMAT" fi } # checks if the plugin is installed before calling battery_charge function safe_battery_charge { if _omb_util_function_exists battery_charge; then battery_charge fi } function prompt_git { local s='' local branchName='' # Check if the current directory is in a Git repository. if _omb_prompt_git rev-parse --is-inside-work-tree &>/dev/null; then # check if the current directory is in .git before running git checks if [[ $(_omb_prompt_git rev-parse --is-inside-git-dir 2> /dev/null) == false ]]; then # Ensure the index is up to date. _omb_prompt_git update-index --really-refresh -q &>/dev/null # Check for uncommitted changes in the index. if ! _omb_prompt_git diff --quiet --ignore-submodules --cached; then s+='+' fi # Check for unstaged changes. if ! _omb_prompt_git diff-files --quiet --ignore-submodules --; then s+='!' fi # Check for untracked files. if [[ $(_omb_prompt_git ls-files --others --exclude-standard) ]]; then s+='?' fi # Check for stashed files. if _omb_prompt_git rev-parse --verify refs/stash &>/dev/null; then s+='$' fi fi # Get the short symbolic ref. # If HEAD isn’t a symbolic ref, get the short SHA for the latest commit # Otherwise, just give up. branchName=$( _omb_prompt_git symbolic-ref --quiet --short HEAD 2> /dev/null || _omb_prompt_git rev-parse --short HEAD 2> /dev/null || _omb_util_print '(unknown)') [[ $s ]] && s=" [$s]" echo -e "${1}${branchName}${_omb_prompt_teal}$s" else return fi } # -------------------------------------------------------------- PROMPT OUTPUT function _omb_theme_PROMPT_COMMAND { local LAST_COMMAND_FAILED=$(mitsuhikos_lastcommandfailed) local SAVE_CURSOR='\[\e7' local RESTORE_CURSOR='\e8\]' local MOVE_CURSOR_RIGHTMOST='\e['${COLUMNS:-9999}'C' local MOVE_CURSOR_5_LEFT='\e[5D' PS1=${TITLEBAR}$'\n' if [[ $OSTYPE == linux* ]]; then PS1+=${SAVE_CURSOR}${MOVE_CURSOR_RIGHTMOST}${MOVE_CURSOR_5_LEFT} PS1+=$(safe_battery_charge)${RESTORE_CURSOR} fi PS1+="${D_USER_COLOR}\u ${D_INTERMEDIATE_COLOR}" PS1+="at ${D_MACHINE_COLOR}\h ${D_INTERMEDIATE_COLOR}" PS1+="in ${D_DIR_COLOR}\w ${D_INTERMEDIATE_COLOR}" PS1+=$(prompt_git "$D_INTERMEDIATE_COLOR on $D_GIT_COLOR") PS1+=${LAST_COMMAND_FAILED} PS1+=$(demula_vcprompt) PS1+=$(is_vim_shell) if [[ $OSTYPE != linux* ]]; then PS1+=$(safe_battery_charge) fi PS1+=$'\n'"${D_INTERMEDIATE_COLOR}$ ${D_DEFAULT_COLOR}" PS2="${D_INTERMEDIATE_COLOR}$ ${D_DEFAULT_COLOR}" } # Runs prompt (this bypasses oh-my-bash $PROMPT setting) _omb_util_add_prompt_command _omb_theme_PROMPT_COMMAND ================================================ FILE: themes/random/README.md ================================================ # Random This is a special Oh-My-Bash theme value. When `random` is specified to `OSH_THEME`, Oh My Bash randomly selects and loads an existing theme. ## Variables The list of theme names from which the theme is selected can be specified to the array `OMB_THEME_RANDOM_CANDIDATES` in `~/.bashrc`. When the candidate list is not supplied, a theme is selected from all available themes in `$OSH_CUSTOM` and `$OSH`. The theme names that the `random` theme should not select can be sorted in the array `OMB_THEME_RANDOM_IGNORED` in `~/.bashrc`. After initialization, the currently selected theme name is stored in the variable `OMB_THEME_RANDOM_SELECTED`: ```console [oh-my-bash] Random theme 'font' loaded... $ echo "$OMB_THEME_RANDOM_SELECTED" font ``` ================================================ FILE: themes/random/random.theme.bash ================================================ #! bash oh-my-bash.module # This theme loads another randomly-chosen theme. ## @var[out] _omb_init_themes function _omb_theme_random__list_available_themes { # When OMB_THEME_RANDOM_CANDIDATES is set, we use it as the theme list # available for the random theme. if [[ ${OMB_THEME_RANDOM_CANDIDATES[@]+set} ]]; then _omb_init_themes=("${OMB_THEME_RANDOM_CANDIDATES[@]}") return 0 fi _omb_init_themes=() local theme_files _omb_util_glob_expand theme_files '{"$OSH_CUSTOM"{,/themes},"$OSH"/themes}/*/*.theme.{bash,sh}' ((${#theme_files[@]})) || return 1 local -a exclude_themes=(random) if ((${#OMB_THEME_RANDOM_IGNORED[@]})); then exclude_themes+=("${OMB_THEME_RANDOM_IGNORED[@]}") fi local -a themes=() index theme for index in "${!theme_files[@]}"; do theme=${theme_files[index]##*/} theme=${theme%.theme.sh} # Check the filename format [[ ${theme_files[index]} == */"$theme"/"$theme".theme.sh ]] || [[ ${theme_files[index]} == */"$theme"/"$theme".theme.bash ]] || continue # Exclude ignored themes from the list _omb_util_array_contains exclude_themes "$theme" && continue # Remove duplicates _omb_util_array_contains themes "$theme" && continue themes+=("$theme") done ((${#themes[@]})) || return 1 _omb_init_themes=("${themes[@]}") } _omb_theme_random__list_available_themes if ((${#_omb_init_themes[@]})); then OMB_THEME_RANDOM_SELECTED=${_omb_init_themes[RANDOM%${#_omb_init_themes[@]}]} _omb_module_require_theme "$OMB_THEME_RANDOM_SELECTED" && printf '%s\n' "[oh-my-bash] Random theme '$OMB_THEME_RANDOM_SELECTED' loaded..." fi unset -v _omb_init_themes ================================================ FILE: themes/rjorgenson/rjorgenson.theme.sh ================================================ #! bash oh-my-bash.module # port of zork theme # set colors for use throughout the prompt # i like things consistent OMB_THEME_BRACKET_COLOR="${OMB_THEME_BRACKET_COLOR-${_omb_prompt_navy}}" OMB_THEME_STRING_COLOR="${OMB_THEME_STRING_COLOR-${_omb_prompt_green}}" SCM_THEME_PROMPT_PREFIX="" SCM_THEME_PROMPT_SUFFIX="" SCM_THEME_PROMPT_DIRTY=" ${_omb_prompt_bold_brown}✗${_omb_prompt_normal}" SCM_THEME_PROMPT_CLEAN=" ${_omb_prompt_bold_green}✓${_omb_prompt_normal}" SCM_GIT_CHAR="${OMB_THEME_STRING_COLOR}±${_omb_prompt_normal}" SCM_SVN_CHAR="${_omb_prompt_bold_teal}⑆${_omb_prompt_normal}" SCM_HG_CHAR="${_omb_prompt_bold_brown}☿${_omb_prompt_normal}" PROMPT_CHAR="${OMB_THEME_BRACKET_COLOR}➞ ${_omb_prompt_normal}" if [[ $OSTYPE == *darwin* ]]; then PROMPT_CHAR="${OMB_THEME_BRACKET_COLOR}➞ ${_omb_prompt_normal}" fi #Mysql Prompt export MYSQL_PS1="(\u@\h) [\d]> " TITLEBAR="" case $TERM in xterm*) TITLEBAR="\[\033]0;\w\007\]" ;; esac function __my_rvm_ruby_version { local gemset=$(awk -F'@' '{print $2}' <<< "${GEM_HOME}") local version=$(awk -F'-' '{print $2}' <<< "${MY_RUBY_HOME}") [[ $gemset ]] && gemset=@$gemset local full=$version$gemset [[ $full ]] && _omb_util_print "${OMB_THEME_BRACKET_COLOR}[${OMB_THEME_STRING_COLOR}${full}${OMB_THEME_BRACKET_COLOR}]${_omb_prompt_normal}" } function is_vim_shell { if [[ $VIMRUNTIME ]]; then _omb_util_print "${OMB_THEME_BRACKET_COLOR}[${OMB_THEME_STRING_COLOR}vim shell${OMB_THEME_BRACKET_COLOR}]${_omb_prompt_normal}" fi } function is_integer { # helper function to make sure input is an integer [ "$1" -eq "$1" ] &> /dev/null return "$?" } # XXX do we need/want to integrate with todo.sh? We don't provide it and I # can't find a version online that accepts ls as an input function todo_txt_count { if _omb_util_command_exists todo.sh; then # is todo.sh installed local count=$(todo.sh ls \ | awk '/TODO: [0-9]+ of ([0-9]+) tasks shown/ { print $4 }') if is_integer "${count}"; then # did we get a sane answer back _omb_util_print "${OMB_THEME_BRACKET_COLOR}[${OMB_THEME_STRING_COLOR}T:$count${OMB_THEME_BRACKET_COLOR}]$_omb_prompt_normal" fi fi } function modern_scm_prompt { local CHAR=$(scm_char) if [[ $CHAR != "$SCM_NONE_CHAR" ]]; then local char=$OMB_THEME_BRACKET_COLOR[$CHAR$OMB_THEME_BRACKET_COLOR] local info=[$OMB_THEME_STRING_COLOR$(scm_prompt_info)$OMB_THEME_BRACKET_COLOR] _omb_util_print "$char$info$_omb_prompt_normal" fi } function _omb_theme_PROMPT_COMMAND { local my_host=$OMB_THEME_STRING_COLOR'\h'$_omb_prompt_normal local my_user=$OMB_THEME_STRING_COLOR'\u'$_omb_prompt_normal local my_path=$OMB_THEME_STRING_COLOR'\w'$_omb_prompt_normal local bracket_c=$OMB_THEME_BRACKET_COLOR local line2=$bracket_c'└─'$(todo_txt_count)$PROMPT_CHAR # nice prompt case $(id -u) in (0) my_user=$_omb_prompt_bold_brown'\u'$_omb_prompt_normal line2=$bracket_c'└─'$PROMPT_CHAR ;; esac PS1=$TITLEBAR PS1=$PS1$bracket_c'┌─'[$my_user$bracket_c][$my_host$bracket_c] PS1=$PS1$(modern_scm_prompt) PS1=$PS1$(__my_rvm_ruby_version) PS1=$PS1$bracket_c[$my_path$bracket_c]$(is_vim_shell) PS1=$PS1'\n'$line2 } PS2='└─'$PROMPT_CHAR PS3='>> ' _omb_util_add_prompt_command _omb_theme_PROMPT_COMMAND ================================================ FILE: themes/robbyrussell/robbyrussell.theme.sh ================================================ #! bash oh-my-bash.module # This theme attempts to replicate the default "robbyrussell" theme from ohmyzsh: # https://github.com/ohmyzsh/ohmyzsh/blob/master/themes/robbyrussell.zsh-theme # Example outside git repo: # ➜ ~ # Example inside clean git repo: # ➜ config-files git:(main) # Example inside dirty git repo: # ➜ config-files git:(main ?:1) ✗ # Example with virtual environment: # ➜ (env1) ~ # Example with virtual environment and inside git repo: # ➜ (env1) config-files git:(main) # python_venv setup OMB_PROMPT_VIRTUALENV_FORMAT='(%s) ' OMB_PROMPT_SHOW_PYTHON_VENV=${OMB_PROMPT_SHOW_PYTHON_VENV:=true} function _omb_theme_PROMPT_COMMAND() { if [[ "$?" == 0 ]]; then local arrow_color="${_omb_prompt_bold_green}" else local arrow_color="${_omb_prompt_bold_brown}" fi # set the python_venv format local python_venv; _omb_prompt_get_python_venv python_venv="$_omb_prompt_olive$python_venv" local base_directory="${_omb_prompt_bold_teal}\W${_omb_prompt_reset_color}" local GIT_THEME_PROMPT_PREFIX="${_omb_prompt_bold_navy}git:(${_omb_prompt_bold_brown}" local SVN_THEME_PROMPT_PREFIX="${_omb_prompt_bold_navy}svn:(${_omb_prompt_bold_brown}" local HG_THEME_PROMPT_PREFIX="${_omb_prompt_bold_navy}hg:(${_omb_prompt_bold_brown}" local SCM_THEME_PROMPT_SUFFIX="${_omb_prompt_reset_color}" local SCM_THEME_PROMPT_CLEAN="${_omb_prompt_bold_navy})${_omb_prompt_reset_color}" local SCM_THEME_PROMPT_DIRTY="${_omb_prompt_bold_navy}) ${_omb_prompt_olive}✗${_omb_prompt_reset_color}" local arrow="${arrow_color}➜${_omb_prompt_reset_color}" PS1="${arrow} ${python_venv}${base_directory} " local scm_info=$(scm_prompt_info) PS1+=${scm_info:+$scm_info } PS1+=${_omb_prompt_normal} } _omb_util_add_prompt_command _omb_theme_PROMPT_COMMAND ================================================ FILE: themes/roderik/roderik.theme.sh ================================================ #! bash oh-my-bash.module GIT_PS1_SHOWDIRTYSTATE=true GIT_PS1_SHOWUNTRACKEDFILES=true GIT_PS1_SHOWSTASHSTATE=true export PROMPT_DIRTRIM=${PROMPT_DIRTRIM:-3} function _omb_theme_PROMPT_COMMAND { local color=$_omb_prompt_teal if ((EUID == 0)); then color=$_omb_prompt_brown fi PS1="[$(clock_prompt)]" PS1+="${_omb_prompt_olive}[${color}\u@\h ${_omb_prompt_green}\w${_omb_prompt_olive}]" PS1+="${_omb_prompt_brown}$(__git_ps1 "(%s)")${_omb_prompt_normal}\\$ " } _omb_util_add_prompt_command _omb_theme_PROMPT_COMMAND ================================================ FILE: themes/rr/rr.theme.sh ================================================ #! bash oh-my-bash.module # rr is a simple one-liner prompt inspired by robbyrussell from ohmyzsh themes. # # Looks: # # ➜ anish ~ cd .bash-it/themes/dulcie # ➜ anish custom-dulcie git:(master ✓) # with git # # Configuration. Change these by adding them in your .bash_profile OMB_PROMPT_SHOW_PYTHON_VENV=${OMB_PROMPT_SHOW_PYTHON_VENV:=false} OMB_PROMPT_VIRTUALENV_FORMAT="${_omb_prompt_bold_purple}vitualenv:(${_omb_prompt_reset_color}%s${_omb_prompt_bold_purple}) ${_omb_prompt_reset_color}" OMB_PROMPT_CONDAENV_FORMAT="${_omb_prompt_bold_purple}condaenv:(${_omb_prompt_reset_color}%s${_omb_prompt_bold_purple}) ${_omb_prompt_reset_color}" function _omb_theme_PROMPT_COMMAND() { local arrow="${_omb_prompt_bold_purple}➜${_omb_prompt_reset_color}" local user_name="${_omb_prompt_white}\u${_omb_prompt_reset_color}" local base_directory="${_omb_prompt_bold_blue}\W${_omb_prompt_reset_color}" local GIT_THEME_PROMPT_PREFIX="${_omb_prompt_bold_purple}git:(${_omb_prompt_reset_color}" local SVN_THEME_PROMPT_PREFIX="${_omb_prompt_bold_purple}svn:(${_omb_prompt_reset_color}" local HG_THEME_PROMPT_PREFIX="${_omb_prompt_bold_purple}hg:(${_omb_prompt_reset_color}" local SCM_THEME_PROMPT_SUFFIX="${_omb_prompt_bold_purple})${_omb_prompt_reset_color}" local SCM_THEME_PROMPT_CLEAN="${_omb_prompt_bold_green} ✓${_omb_prompt_reset_color}" local SCM_THEME_PROMPT_DIRTY="${_omb_prompt_bold_red} ✗${_omb_prompt_reset_color}" PS1="${arrow} ${user_name} ${base_directory} " local python_venv _omb_prompt_get_python_venv PS1+=$python_venv local scm_info=$(scm_prompt_info) PS1+=${scm_info:+$scm_info } PS1+=$_omb_prompt_normal } _omb_util_add_prompt_command _omb_theme_PROMPT_COMMAND ================================================ FILE: themes/sexy/sexy.theme.sh ================================================ #! bash oh-my-bash.module # Sexy Bash Prompt, inspired by "Extravagant Zsh Prompt" # Screenshot: http://cloud.gf3.ca/M5rG # A big thanks to \amethyst on Freenode if [[ $COLORTERM == gnome-* && $TERM == xterm ]] && infocmp gnome-256color &>/dev/null; then export TERM=gnome-256color elif [[ $TERM != dumb ]] && infocmp xterm-256color &>/dev/null; then export TERM=xterm-256color fi MAGENTA=$_omb_prompt_bold_red WHITE=$_omb_prompt_bold_silver ORANGE=$_omb_prompt_bold_olive GREEN=$_omb_prompt_bold_green PURPLE=$_omb_prompt_bold_purple RESET=$_omb_prompt_normal if ((_omb_term_colors >= 256)); then ORANGE=$_omb_prompt_bold'\['$(tput setaf 172)'\]' GREEN=$_omb_prompt_bold'\['$(tput setaf 190)'\]' PURPLE=$_omb_prompt_bold'\['$(tput setaf 141)'\]' fi OMB_PROMPT_VIRTUALENV_FORMAT=$WHITE'<%s> ' OMB_PROMPT_CONDAENV_FORMAT=$WHITE'<%s> ' OMB_PROMPT_CONDAENV_USE_BASENAME=true OMB_PROMPT_SHOW_PYTHON_VENV=${OMB_PROMPT_SHOW_PYTHON_VENV:=false} function parse_git_dirty { [[ $(_omb_prompt_git status 2> /dev/null | tail -n1 | cut -c 1-17) != "nothing to commit" ]] && _omb_util_print "*" } function parse_git_branch { _omb_prompt_git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/\1$(parse_git_dirty)/" } function _omb_theme_PROMPT_COMMAND() { local python_venv _omb_prompt_get_python_venv local git_prefix= [[ $(_omb_prompt_git branch 2> /dev/null) ]] && git_prefix=' on ' PS1=$python_venv$MAGENTA'\u '$WHITE'at '$ORANGE'\h' PS1+=' '$WHITE'in '$GREEN'\w'$WHITE PS1+=$git_prefix$PURPLE'$(parse_git_branch)'$WHITE'\n\$ '$RESET } _omb_util_add_prompt_command _omb_theme_PROMPT_COMMAND ================================================ FILE: themes/simple/simple.theme.sh ================================================ #! bash oh-my-bash.module # prompt themeing #added TITLEBAR for updating the tab and window titles with the pwd case $TERM in xterm*) TITLEBAR="\[\033]0;\w\007\]" ;; *) TITLEBAR="" ;; esac function _omb_theme_PROMPT_COMMAND() { PS1="${TITLEBAR}${_omb_prompt_red}${_omb_prompt_reset_color}${_omb_prompt_green}\w${_omb_prompt_bold_navy}\[\$(scm_prompt_info)\]${_omb_prompt_normal} " } # scm themeing SCM_THEME_PROMPT_DIRTY=" ✗" SCM_THEME_PROMPT_CLEAN=" ✓" SCM_THEME_PROMPT_PREFIX="(" SCM_THEME_PROMPT_SUFFIX=")" _omb_util_add_prompt_command _omb_theme_PROMPT_COMMAND ================================================ FILE: themes/sirup/sirup.theme.sh ================================================ #! bash oh-my-bash.module # For unstaged(*) and staged(+) values next to branch name in __git_ps1 GIT_PS1_SHOWDIRTYSTATE="enabled" OMB_PROMPT_VIRTUALENV_FORMAT=' [%s]' OMB_PROMPT_CONDAENV_FORMAT=' [%s]' OMB_PROMPT_SHOW_PYTHON_VENV=${OMB_PROMPT_SHOW_PYTHON_VENV:=false} function _omb_theme_sirup_rubygem { local gemset=$(command awk -F'@' '{print $2}' <<< "$GEM_HOME") [[ $gemset ]] && gemset="@$gemset" local version=$(command awk -F'-' '{print $2}' <<< "$MY_RUBY_HOME") [[ $version == 1.9.2 ]] && version= local full=$version$gemset [[ $full ]] && _omb_util_print "$full" } function _omb_theme_PROMPT_COMMAND { # Check http://github.com/Sirupsen/dotfiles for screenshot local python_venv _omb_prompt_get_python_venv PS1="$_omb_prompt_navy\W/$_omb_prompt_bold_navy$(_omb_theme_sirup_rubygem)$_omb_prompt_bold_purple$python_venv$_omb_prompt_bold_green$(__git_ps1 " (%s)") ${_omb_prompt_normal}$ " } _omb_util_add_prompt_command _omb_theme_PROMPT_COMMAND ================================================ FILE: themes/slick/slick.theme.sh ================================================ #! bash oh-my-bash.module SCM_THEME_PROMPT_PREFIX="" SCM_THEME_PROMPT_SUFFIX="" SCM_THEME_PROMPT_DIRTY=" ${_omb_prompt_bold_brown}✗${_omb_prompt_normal}" SCM_THEME_PROMPT_CLEAN=" ${_omb_prompt_bold_green}✓${_omb_prompt_normal}" SCM_GIT_CHAR="${_omb_prompt_bold_teal}±${_omb_prompt_normal}" SCM_SVN_CHAR="${_omb_prompt_bold_green}⑆${_omb_prompt_normal}" SCM_HG_CHAR="${_omb_prompt_bold_brown}☿${_omb_prompt_normal}" #Mysql Prompt export MYSQL_PS1="(\u@\h) [\d]> " case $TERM in xterm*) TITLEBAR="\[\033]0;\w\007\]" ;; *) TITLEBAR="" ;; esac PS3=">> " function __my_rvm_ruby_version { local gemset=$(awk -F'@' '{print $2}' <<< "$GEM_HOME") [[ $gemset ]] && gemset=@$gemset local version=$(awk -F'-' '{print $2}' <<< "$MY_RUBY_HOME") local full=$version$gemset [[ $full ]] && _omb_util_print "[$full]" } function __my_venv_prompt { if [[ $VIRTUAL_ENV ]]; then _omb_util_print "[${_omb_prompt_navy}@${_omb_prompt_normal}${VIRTUAL_ENV##*/}]" fi } function is_vim_shell { if [[ $VIMRUNTIME ]]; then _omb_util_print "[${_omb_prompt_teal}vim shell${_omb_prompt_normal}]" fi } function modern_scm_prompt { local CHAR=$(scm_char) if [[ $CHAR == "$SCM_NONE_CHAR" ]]; then return else _omb_util_print "[$(scm_char)][$(scm_prompt_info)]" fi } function _omb_theme_PROMPT_COMMAND { local my_ps_host case $HOSTNAME in "clappy"* ) my_ps_host="${_omb_prompt_green}\h${_omb_prompt_normal}"; ;; "icekernel") my_ps_host="${_omb_prompt_brown}\h${_omb_prompt_normal}"; ;; * ) my_ps_host="${_omb_prompt_green}\h${_omb_prompt_normal}"; ;; esac local my_ps_user="\[\033[01;32m\]\u\[\033[00m\]"; local my_ps_root="\[\033[01;31m\]\u\[\033[00m\]"; local my_ps_path="\[\033[01;36m\]\w\[\033[00m\]"; # nice prompt case $(id -u) in 0) PS1="${TITLEBAR}[$my_ps_root][$my_ps_host]$(modern_scm_prompt)$(__my_rvm_ruby_version)[${_omb_prompt_teal}\w${_omb_prompt_normal}]$(is_vim_shell) $ " ;; *) PS1="${TITLEBAR}[$my_ps_user][$my_ps_host]$(modern_scm_prompt)$(__my_rvm_ruby_version)$(__my_venv_prompt)[${_omb_prompt_teal}\w${_omb_prompt_normal}]$(is_vim_shell) $ " ;; esac } PS2="> " _omb_util_add_prompt_command _omb_theme_PROMPT_COMMAND ================================================ FILE: themes/standard/standard.theme.sh ================================================ #! bash oh-my-bash.module # scm themeing SCM_THEME_PROMPT_DIRTY="×" SCM_THEME_PROMPT_CLEAN="✓" SCM_THEME_PROMPT_PREFIX="" SCM_THEME_PROMPT_SUFFIX="" # TODO: need a check for OS before adding this to the prompt # ${debian_chroot:+($debian_chroot)} #added TITLEBAR for updating the tab and window titles with the pwd case $TERM in xterm*) TITLEBAR='\[\033]0;\w\007\]' ;; *) TITLEBAR="" ;; esac function _omb_theme_PROMPT_COMMAND() { PROMPT='${_omb_prompt_green}\u${_omb_prompt_normal}@${_omb_prompt_green}\h${_omb_prompt_normal}:${_omb_prompt_navy}\w${_omb_prompt_normal}${_omb_prompt_brown}$(prompt_char)$(git_prompt_info)${_omb_prompt_normal}\$ ' } _omb_util_add_prompt_command _omb_theme_PROMPT_COMMAND ================================================ FILE: themes/tonka/tonka.theme.sh ================================================ #! bash oh-my-bash.module function __tonka_time { THEME_CLOCK_FORMAT="%H%M" clock_prompt } function __tonka_date { THEME_CLOCK_FORMAT="%a,%d %b %y" clock_prompt } function __tonka_clock { local LIGHT_BLUE="\[\033[1;34m\]" if [[ "${THEME_SHOW_CLOCK}" = "true" ]]; then _omb_util_print "$(__tonka_time)${LIGHT_BLUE}:$(__tonka_date)${LIGHT_BLUE}:" fi } function _omb_theme_PROMPT_COMMAND { # Named "Tonka" because of the colour scheme local WHITE="\[\033[1;37m\]" local LIGHT_BLUE="\[\033[1;34m\]" local YELLOW="\[\033[1;33m\]" local NO_COLOUR="\[\033[0m\]" case $TERM in xterm*|rxvt*) TITLEBAR='\[\033]0;\u@\h:\w\007\]' ;; *) TITLEBAR="" ;; esac PS1="$TITLEBAR\ $YELLOW-$LIGHT_BLUE-(\ $YELLOW\u$LIGHT_BLUE@$YELLOW\h\ $LIGHT_BLUE)-(\ $YELLOW\$PWD\ $LIGHT_BLUE)-$YELLOW-\ \n\ $YELLOW-$LIGHT_BLUE-(\ $(__tonka_clock)\ $WHITE\$ $LIGHT_BLUE)-$YELLOW-$NO_COLOUR " PS2="$LIGHT_BLUE-$YELLOW-$YELLOW-$NO_COLOUR " } _omb_util_add_prompt_command _omb_theme_PROMPT_COMMAND THEME_SHOW_CLOCK=${THEME_SHOW_CLOCK:-"true"} THEME_CLOCK_COLOR=${THEME_CLOCK_COLOR:-"\[\033[1;33m\]"} export PS3=">> " LS_COLORS='no=00:fi=00:di=00;33:ln=01;36:pi=40;34:so=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.gz=01;31:*.deb=01;31:*.jpg=01;35:*.gif=01;35:*.bmp=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.mpg=01;37:*.avi=01;37:*.gl=01;37:*.dl=01;37:'; export LS_COLORS ================================================ FILE: themes/tonotdo/tonotdo.theme.sh ================================================ #! bash oh-my-bash.module SCM_THEME_PROMPT_PREFIX=" ${_omb_prompt_purple}" SCM_THEME_PROMPT_SUFFIX=" ${_omb_prompt_normal}" SCM_THEME_PROMPT_DIRTY=" ${_omb_prompt_brown}✗" SCM_THEME_PROMPT_CLEAN=" ${_omb_prompt_green}✓" SCM_GIT_SHOW_DETAILS="false" function _omb_theme_PROMPT_COMMAND() { PS1="${_omb_prompt_olive}\u${_omb_prompt_normal}${_omb_prompt_teal}@\h${_omb_prompt_normal}${_omb_prompt_purple} ${_omb_prompt_normal}${_omb_prompt_green}\w${_omb_prompt_normal}$(scm_prompt_info)> " } _omb_util_add_prompt_command _omb_theme_PROMPT_COMMAND ================================================ FILE: themes/tylenol/tylenol.theme.sh ================================================ #! bash oh-my-bash.module # # Based on 'bobby' theme with the addition of python_venv # SCM_THEME_PROMPT_DIRTY=" ${_omb_prompt_brown}✗" SCM_THEME_PROMPT_CLEAN=" ${_omb_prompt_green}✓" SCM_THEME_PROMPT_PREFIX=" ${_omb_prompt_olive}|${_omb_prompt_reset_color}" SCM_THEME_PROMPT_SUFFIX="${_omb_prompt_olive}|" RVM_THEME_PROMPT_PREFIX="|" RVM_THEME_PROMPT_SUFFIX="|" OMB_PROMPT_VIRTUALENV_FORMAT='|%s|' OMB_PROMPT_SHOW_PYTHON_VENV=${OMB_PROMPT_SHOW_PYTHON_VENV:=true} function _omb_theme_PROMPT_COMMAND() { PS1="\n${_omb_prompt_green}$(_omb_prompt_print_python_venv)${_omb_prompt_brown}$(_omb_prompt_print_ruby_env) ${_omb_prompt_reset_color}\h ${_omb_prompt_red}in ${_omb_prompt_reset_color}\w\n${_omb_prompt_olive}$(scm_char)$(scm_prompt_info) ${_omb_prompt_olive}→${_omb_prompt_white} " } _omb_util_add_prompt_command _omb_theme_PROMPT_COMMAND ================================================ FILE: themes/vscode/vscode.theme.sh ================================================ #! bash oh-my-bash.module #------------------------------------------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See https://go.microsoft.com/fwlink/?linkid=2090316 for license information. #------------------------------------------------------------------------------------------------------------- # # This theme [1] is based on the code generated by vscode-dev-container [2]. # Specifically, the code is based on the template found in Ref. [3]. The # original code of [2] is licensed by Microsoft Corporation under the MIT # license. # # [1] https://github.com/ohmybash/oh-my-bash/pull/331 # [2] https://github.com/microsoft/vscode-dev-containers # [3] https://github.com/microsoft/vscode-dev-containers/blob/172a918f40e31bd24da8e64135026ec9f26c91b0/containers/javascript-node/.devcontainer/library-scripts/common-debian.sh#L303-L320 # function _omb_theme_vscode_initialize { local userpart='`export XIT=$? \ && [ ! -z "${GITHUB_USER}" ] && echo -n "\[\033[0;32m\]@${GITHUB_USER} " || echo -n "\[\033[0;32m\]\u " \ && [ "$XIT" -ne "0" ] && echo -n "\[\033[1;31m\]➜" || echo -n "\[\033[0m\]➜"`' local gitbranch='`\ if [ "$(_omb_prompt_git config --get codespaces-theme.hide-status 2>/dev/null)" != 1 ]; then \ export BRANCH=$(_omb_prompt_git symbolic-ref --short HEAD 2>/dev/null || _omb_prompt_git rev-parse --short HEAD 2>/dev/null); \ if [ "${BRANCH}" != "" ]; then \ echo -n "\[\033[0;36m\](\[\033[1;31m\]${BRANCH}" \ && if _omb_prompt_git ls-files --error-unmatch -m --directory --no-empty-directory -o --exclude-standard ":/*" > /dev/null 2>&1; then \ echo -n " \[\033[1;33m\]✗"; \ fi \ && echo -n "\[\033[0;36m\]) "; \ fi; \ fi`' local lightblue='\[\033[1;34m\]' local removecolor='\[\033[0m\]' PS1="${userpart} ${lightblue}\w ${gitbranch}${removecolor}\$ " unset -f _omb_theme_vscode_initialize } _omb_theme_vscode_initialize function _omb_theme_PROMPT_COMMAND { true; } PROMPT_DIRTRIM=${PROMPT_DIRTRIM:-4} ================================================ FILE: themes/wanelo/wanelo.theme.sh ================================================ #! bash oh-my-bash.module SCM_THEME_PROMPT_DIRTY=" ${_omb_prompt_brown}✗" SCM_THEME_PROMPT_CLEAN=" ${_omb_prompt_bold_green}✓" SCM_THEME_PROMPT_PREFIX=" |" SCM_THEME_PROMPT_SUFFIX="${_omb_prompt_green}|" GIT_THEME_PROMPT_DIRTY=" ${_omb_prompt_brown}✗" GIT_THEME_PROMPT_CLEAN=" ${_omb_prompt_bold_green}✓" GIT_THEME_PROMPT_PREFIX=" ${_omb_prompt_green}|" GIT_THEME_PROMPT_SUFFIX="${_omb_prompt_green}|" RVM_THEME_PROMPT_PREFIX="|" RVM_THEME_PROMPT_SUFFIX="|" function _omb_theme_PROMPT_COMMAND { if (($? == 0)); then local status=❤️ else local status=💔 fi PS1="\n${_omb_prompt_olive}$(_omb_prompt_print_ruby_env) " PS1+="${_omb_prompt_purple}\h ${_omb_prompt_reset_color}in ${_omb_prompt_green}\w $status \n" PS1+="${_omb_prompt_bold_teal} ${_omb_prompt_navy}|$(clock_prompt)|" PS1+="${_omb_prompt_green}$(scm_prompt_info) " PS1+="${_omb_prompt_green}→${_omb_prompt_reset_color} " } THEME_CLOCK_COLOR=${THEME_CLOCK_COLOR:-"$_omb_prompt_navy"} _omb_util_add_prompt_command _omb_theme_PROMPT_COMMAND ================================================ FILE: themes/zitron/zitron.theme.sh ================================================ #! bash oh-my-bash.module # zitron theme by Florian Baumann ## git-theme # feel free to change git chars. GIT_THEME_PROMPT_DIRTY="${_omb_prompt_bold_olive}*${_omb_prompt_normal}" GIT_THEME_PROMPT_CLEAN="" GIT_THEME_PROMPT_PREFIX="" GIT_THEME_PROMPT_SUFFIX="" ## ls colors # thanks a lot to http://geoff.greer.fm/lscolors/ export LSCOLORS="Gxfxcxdxbxegedabagacad" export LS_COLORS="no=00:fi=00:di=01;33:ln=01;36:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:ex=01;32:*.tar=01;31:*.tgz=01;31:*.svgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.lzma=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.dz=01;31:*.gz=01;31:*.bz2=01;31:*.bz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.rar=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.jpg=01;35:*.jpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;34:*.svg=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:" function _omb_theme_PROMPT_COMMAND() { ## look-a-like # user:host:pwd git-branch(*)$ # for example: # noqqe:deathstar:themes master*$ PS1="${no_color}\u:$(hostname)${_omb_prompt_normal}:${_omb_prompt_bold_olive}\W/${_omb_prompt_normal} $(git_prompt_info)${_omb_prompt_reset_color}$ " } _omb_util_add_prompt_command _omb_theme_PROMPT_COMMAND ================================================ FILE: themes/zork/zork.theme.sh ================================================ #! bash oh-my-bash.module SCM_THEME_PROMPT_PREFIX="" SCM_THEME_PROMPT_SUFFIX="" SCM_THEME_PROMPT_DIRTY=" ${_omb_prompt_bold_brown}✗${_omb_prompt_normal}" SCM_THEME_PROMPT_CLEAN=" ${_omb_prompt_bold_green}✓${_omb_prompt_normal}" SCM_GIT_CHAR="${_omb_prompt_bold_green}±${_omb_prompt_normal}" SCM_SVN_CHAR="${_omb_prompt_bold_teal}⑆${_omb_prompt_normal}" SCM_HG_CHAR="${_omb_prompt_bold_brown}☿${_omb_prompt_normal}" #Mysql Prompt export MYSQL_PS1="(\u@\h) [\d]> " case $TERM in xterm*) TITLEBAR="\[\033]0;\w\007\]" ;; *) TITLEBAR="" ;; esac PS3=">> " function __my_rvm_ruby_version { local gemset=$(awk -F'@' '{print $2}' <<< "$GEM_HOME") [[ $gemset ]] && gemset=@$gemset local version=$(awk -F'-' '{print $2}' <<< "$MY_RUBY_HOME") local full=$version$gemset [[ $full ]] && _omb_util_print "[$full]" } function is_vim_shell { if [[ $VIMRUNTIME ]]; then _omb_util_print "[${_omb_prompt_teal}vim shell${_omb_prompt_normal}]" fi } function modern_scm_prompt { local CHAR=$(scm_char) if [[ $CHAR == "$SCM_NONE_CHAR" ]]; then return else _omb_util_print "[$(scm_char)][$(scm_prompt_info)]" fi } # show chroot if exist function chroot { if [[ $debian_chroot ]]; then local my_ps_chroot=$_omb_prompt_bold_teal$debian_chroot$_omb_prompt_normal _omb_util_print "($my_ps_chroot)" fi } # show virtualenvwrapper function my_ve { if [[ $VIRTUAL_ENV ]]; then local ve=$(basename "$VIRTUAL_ENV") local my_ps_ve=$_omb_prompt_bold_purple$ve$_omb_prompt_normal _omb_util_print "($my_ps_ve)" fi _omb_util_print "" } function _omb_theme_PROMPT_COMMAND { local my_ps_host="${_omb_prompt_green}\h${_omb_prompt_normal}" # yes, these are the the same for now ... local my_ps_host_root="${_omb_prompt_green}\h${_omb_prompt_normal}" local my_ps_user="${_omb_prompt_bold_green}\u${_omb_prompt_normal}" local my_ps_root="${_omb_prompt_bold_brown}\u${_omb_prompt_normal}" # nice prompt case $(id -u) in 0) PS1="${TITLEBAR}┌─$(my_ve)$(chroot)[$my_ps_root][$my_ps_host_root]$(modern_scm_prompt)$(__my_rvm_ruby_version)[${_omb_prompt_teal}\w${_omb_prompt_normal}]$(is_vim_shell) └─▪ " ;; *) PS1="${TITLEBAR}┌─$(my_ve)$(chroot)[$my_ps_user][$my_ps_host]$(modern_scm_prompt)$(__my_rvm_ruby_version)[${_omb_prompt_teal}\w${_omb_prompt_normal}]$(is_vim_shell) └─▪ " ;; esac } PS2="└─▪ " _omb_util_add_prompt_command _omb_theme_PROMPT_COMMAND ================================================ FILE: tools/autossh.sh ================================================ #!/usr/bin/env bash # ------------------------------------------------------------------------------ # FILE: autossh # DESCRIPTION: This is an SSH-D proxy with auto-reconnect on disconnect # AUTHOR: Toan Nguyen (nntoan at protonmail dot com) # VERSION: 1.0.0 # USAGE: autossh your_user@your_server_ip # shellcheck disable=SC2034,SC2182,SC2162,SC2236,SC2120,SC2009,SC2119,SC2086,SC2059,SC2006 # ------------------------------------------------------------------------------ VERSION="1.0.0" GITHUB="https://github.com/nntoan/autossh" AUTHOR="Toan Nguyen" SCRIPT=${0##*/} IFS=$'\n' ALIVE=0 HISTFILE="$HOME/.autossh.history" # Use colors, but only if connected to a terminal, and that terminal supports them. if type -P tput >/dev/null 2>&1; then ncolors=$(tput colors) fi if [ -t 1 ] && [ -n "$ncolors" ] && [ "$ncolors" -ge 8 ]; then RED="$(tput setaf 1)" GREEN="$(tput setaf 2)" YELLOW="$(tput setaf 3)" BLUE="$(tput setaf 4)" BOLD="$(tput bold)" NORMAL="$(tput sgr0)" else RED="" GREEN="" YELLOW="" BLUE="" BOLD="" NORMAL="" fi # Progress or something start_progress() { while true do echo -ne "#" sleep 1 done } quick_progress() { while true do echo -ne "#" sleep .033 done } long_progress() { while true do echo -ne "#" sleep 3 done } dot_progress() { for i in {1..100}; do printf "." $i -1 $i sleep .033 done echo_c green " 100%{$NORMAL}" sleep 1 } stop_progress() { kill $1 wait $1 2>/dev/null echo -en "\n" } # Case-insensitive for regex matching shopt -s nocasematch # Prepare history mode set -i history -c history -r # Input method get_input() { read -e -p "${BLUE}$1${NORMAL}" "$2" history -s "${!2}" } # Echo in bold echo_b() { if [ "$1" = "-e" ]; then echo -e "${BOLD}$2${NORMAL}" else echo "${BOLD}$1${NORMAL}" fi } # Echo in colour echo_c() { case "$1" in red | r | -red | -r | --red | --r ) echo "${RED}$2${NORMAL}" ;; green | g | -green | -g | --green | --g ) echo "${GREEN}$2${NORMAL}" ;; blue | b | -blue | -b | --blue | --b ) echo "${BLUE}$2${NORMAL}" ;; yellow | y | -yellow | -y | --yellow | --y ) echo "${YELLOW}$2${NORMAL}" ;; * ) echo "$(BOLD)$2$(RESET)" ;; esac } # Get data from parameters if [[ ! -n "$remote_param" && -n "$1" ]]; then remote_param="$1" remote_user="${remote_param%%@*}" remote_ip="${remote_param##*@}" fi # Get input data and save to history save_input() { if [[ ! -n "$remote_user" && ! -n "$1" ]]; then while get_input "SSH Username > " remote_user; do case ${remote_user%% *} in * ) if [ -n "$remote_user" ]; then break else continue fi ;; esac done fi if [[ ! -n "$remote_ip" && ! -n "$1" ]]; then while get_input "SSH Alias/IP-address > " remote_ip; do case ${remote_ip%% *} in * ) if [ -n "$remote_ip" ]; then break else continue fi ;; esac done fi } # Infinitie loop to keep connecting auto_connect() { while true; do exist=`ps aux | grep $remote_user@$remote_ip | grep 22` if test -n "$exist" then if test $ALIVE -eq 0 then echo_c yellow "I'm alive since $(date)" fi ALIVE=1 else ALIVE=0 echo_c red "I'm dead... God is bringing me back..." clear printf "${GREEN}Connecting: " for i in {1..100}; do printf "." "$i" -1 "$i" sleep .033 done echo_c green " 100%${NORMAL}" sleep 1 clear ssh $remote_user@$remote_ip fi sleep 1 done } main() { save_input auto_connect } main ================================================ FILE: tools/bash-preexec.sh ================================================ # bash-preexec.sh -- Bash support for ZSH-like 'preexec' and 'precmd' functions. # https://github.com/rcaloras/bash-preexec # # # 'preexec' functions are executed before each interactive command is # executed, with the interactive command as its argument. The 'precmd' # function is executed before each prompt is displayed. # # Author: Ryan Caloras (ryan@bashhub.com) # Forked from Original Author: Glyph Lefkowitz # # V0.5.0 # # General Usage: # # 1. Source this file at the end of your bash profile so as not to interfere # with anything else that's using PROMPT_COMMAND. # # 2. Add any precmd or preexec functions by appending them to their arrays: # e.g. # precmd_functions+=(my_precmd_function) # precmd_functions+=(some_other_precmd_function) # # preexec_functions+=(my_preexec_function) # # 3. Consider changing anything using the DEBUG trap or PROMPT_COMMAND # to use preexec and precmd instead. Preexisting usages will be # preserved, but doing so manually may be less surprising. # # Note: This module requires two Bash features which you must not otherwise be # using: the "DEBUG" trap, and the "PROMPT_COMMAND" variable. If you override # either of these after bash-preexec has been installed it will most likely break. # Tell shellcheck what kind of file this is. # shellcheck shell=bash # Make sure this is bash that's running and return otherwise. # Use POSIX syntax for this line: if [ -z "${BASH_VERSION-}" ]; then return 1; fi # We only support Bash 3.1+. # Note: BASH_VERSINFO is first available in Bash-2.0. if [[ -z "${BASH_VERSINFO-}" || BASH_VERSINFO[0] -lt 3 || BASH_VERSINFO[0] -eq 3 && BASH_VERSINFO[1] -lt 1 ]]; then return 1 fi # Avoid duplicate inclusion if [[ -n "${bash_preexec_imported:-}" ]]; then return 0 fi bash_preexec_imported="defined" # WARNING: This variable is no longer used and should not be relied upon. # Use ${bash_preexec_imported} instead. # shellcheck disable=SC2034 __bp_imported="${bash_preexec_imported}" # Should be available to each precmd and preexec # functions, should they want it. $? and $_ are available as $? and $_, but # $PIPESTATUS is available only in a copy, $BP_PIPESTATUS. # TODO: Figure out how to restore PIPESTATUS before each precmd or preexec # function. __bp_last_ret_value="$?" BP_PIPESTATUS=("${PIPESTATUS[@]}") __bp_last_argument_prev_command="$_" __bp_inside_precmd=0 __bp_inside_preexec=0 # Initial PROMPT_COMMAND string that is removed from PROMPT_COMMAND post __bp_install __bp_install_string=$'__bp_trap_string="$(trap -p DEBUG)"\ntrap - DEBUG\n__bp_install' # Fails if any of the given variables are readonly # Reference https://stackoverflow.com/a/4441178 function __bp_require_not_readonly { local var for var; do if ! ( unset "$var" 2> /dev/null ); then echo "bash-preexec requires write access to ${var}" >&2 return 1 fi done } # Remove ignorespace and or replace ignoreboth from HISTCONTROL # so we can accurately invoke preexec with a command from our # history even if it starts with a space. function __bp_adjust_histcontrol { local histcontrol histcontrol="${HISTCONTROL:-}" histcontrol="${histcontrol//ignorespace}" # Replace ignoreboth with ignoredups if [[ "$histcontrol" == *"ignoreboth"* ]]; then histcontrol="ignoredups:${histcontrol//ignoreboth}" fi; export HISTCONTROL="$histcontrol" } # This variable describes whether we are currently in "interactive mode"; # i.e. whether this shell has just executed a prompt and is waiting for user # input. It documents whether the current command invoked by the trace hook is # run interactively by the user; it's set immediately after the prompt hook, # and unset as soon as the trace hook is run. __bp_preexec_interactive_mode="" # These arrays are used to add functions to be run before, or after, prompts. declare -a precmd_functions declare -a preexec_functions # Trims leading and trailing whitespace from $2 and writes it to the variable # name passed as $1 function __bp_trim_whitespace { local var=${1:?} text=${2:-} text="${text#"${text%%[![:space:]]*}"}" # remove leading whitespace characters text="${text%"${text##*[![:space:]]}"}" # remove trailing whitespace characters printf -v "$var" '%s' "$text" } # Trims whitespace and removes any leading or trailing semicolons from $2 and # writes the resulting string to the variable name passed as $1. Used for # manipulating substrings in PROMPT_COMMAND function __bp_sanitize_string { local var=${1:?} text=${2:-} sanitized __bp_trim_whitespace sanitized "$text" sanitized=${sanitized%;} sanitized=${sanitized#;} __bp_trim_whitespace sanitized "$sanitized" printf -v "$var" '%s' "$sanitized" } # This function is installed as part of the PROMPT_COMMAND; # It sets a variable to indicate that the prompt was just displayed, # to allow the DEBUG trap to know that the next command is likely interactive. function __bp_interactive_mode { __bp_preexec_interactive_mode="on"; } # This function is installed as part of the PROMPT_COMMAND. # It will invoke any functions defined in the precmd_functions array. function __bp_precmd_invoke_cmd { # Save the returned value from our last command, and from each process in # its pipeline. Note: this MUST be the first thing done in this function. # BP_PIPESTATUS may be unused, ignore # shellcheck disable=SC2034 __bp_last_ret_value="$?" BP_PIPESTATUS=("${PIPESTATUS[@]}") # Don't invoke precmds if we are inside an execution of an "original # prompt command" by another precmd execution loop. This avoids infinite # recursion. if (( __bp_inside_precmd > 0 )); then return fi local __bp_inside_precmd=1 # Invoke every function defined in our function array. local precmd_function for precmd_function in "${precmd_functions[@]}"; do # Only execute this function if it actually exists. # Test existence of functions with: declare -[Ff] if type -t "$precmd_function" 1>/dev/null; then __bp_set_ret_value "$__bp_last_ret_value" "$__bp_last_argument_prev_command" # Quote our function invocation to prevent issues with IFS "$precmd_function" fi done __bp_set_ret_value "$__bp_last_ret_value" } # Sets a return value in $?. We may want to get access to the $? variable in our # precmd functions. This is available for instance in zsh. We can simulate it in bash # by setting the value here. function __bp_set_ret_value { return ${1:+"$1"} } function __bp_in_prompt_command { local prompt_command_array IFS=$'\n;' read -rd '' -a prompt_command_array <<< "${PROMPT_COMMAND:-}" local trimmed_arg __bp_trim_whitespace trimmed_arg "${1:-}" local command trimmed_command for command in "${prompt_command_array[@]:-}"; do __bp_trim_whitespace trimmed_command "$command" if [[ "$trimmed_command" == "$trimmed_arg" ]]; then return 0 fi done return 1 } # This function is installed as the DEBUG trap. It is invoked before each # interactive prompt display. Its purpose is to inspect the current # environment to attempt to detect if the current command is being invoked # interactively, and invoke 'preexec' if so. function __bp_preexec_invoke_exec { # Save the contents of $_ so that it can be restored later on. # https://stackoverflow.com/questions/40944532/bash-preserve-in-a-debug-trap#40944702 __bp_last_argument_prev_command="${1:-}" # Don't invoke preexecs if we are inside of another preexec. if (( __bp_inside_preexec > 0 )); then return fi local __bp_inside_preexec=1 # Checks if the file descriptor is not standard out (i.e. '1') # __bp_delay_install checks if we're in test. Needed for bats to run. # Prevents preexec from being invoked for functions in PS1 if [[ ! -t 1 && -z "${__bp_delay_install:-}" ]]; then return fi if [[ -n "${COMP_LINE:-}" ]]; then # We're in the middle of a completer. This obviously can't be # an interactively issued command. return fi if [[ -z "${__bp_preexec_interactive_mode:-}" ]]; then # We're doing something related to displaying the prompt. Let the # prompt set the title instead of me. return else # If we're in a subshell, then the prompt won't be re-displayed to put # us back into interactive mode, so let's not set the variable back. # In other words, if you have a subshell like # (sleep 1; sleep 2) # You want to see the 'sleep 2' as a set_command_title as well. if [[ 0 -eq "${BASH_SUBSHELL:-}" ]]; then __bp_preexec_interactive_mode="" fi fi if __bp_in_prompt_command "${BASH_COMMAND:-}"; then # If we're executing something inside our prompt_command then we don't # want to call preexec. Bash prior to 3.1 can't detect this at all :/ __bp_preexec_interactive_mode="" return fi local this_command this_command=$( export LC_ALL=C HISTTIMEFORMAT='' builtin history 1 | sed '1 s/^ *[0-9][0-9]*[* ] //' ) # Sanity check to make sure we have something to invoke our function with. if [[ -z "$this_command" ]]; then return fi # Invoke every function defined in our function array. local preexec_function local preexec_function_ret_value local preexec_ret_value=0 for preexec_function in "${preexec_functions[@]:-}"; do # Only execute each function if it actually exists. # Test existence of function with: declare -[fF] if type -t "$preexec_function" 1>/dev/null; then __bp_set_ret_value "${__bp_last_ret_value:-}" # Quote our function invocation to prevent issues with IFS "$preexec_function" "$this_command" preexec_function_ret_value="$?" if [[ "$preexec_function_ret_value" != 0 ]]; then preexec_ret_value="$preexec_function_ret_value" fi fi done # Restore the last argument of the last executed command, and set the return # value of the DEBUG trap to be the return code of the last preexec function # to return an error. # If `extdebug` is enabled a non-zero return value from any preexec function # will cause the user's command not to execute. # Run `shopt -s extdebug` to enable __bp_set_ret_value "$preexec_ret_value" "$__bp_last_argument_prev_command" } function __bp_install { # Exit if we already have this installed. if [[ "${PROMPT_COMMAND:-}" == *"__bp_precmd_invoke_cmd"* ]]; then return 1; fi trap '__bp_preexec_invoke_exec "$_"' DEBUG # Preserve any prior DEBUG trap as a preexec function local prior_trap # we can't easily do this with variable expansion. Leaving as sed command. # shellcheck disable=SC2001 prior_trap=$(sed "s/[^']*'\(.*\)'[^']*/\1/" <<<"${__bp_trap_string:-}") unset __bp_trap_string if [[ -n "$prior_trap" ]]; then eval '__bp_original_debug_trap() { '"$prior_trap"' }' preexec_functions+=(__bp_original_debug_trap) fi # Adjust our HISTCONTROL Variable if needed. __bp_adjust_histcontrol # Issue #25. Setting debug trap for subshells causes sessions to exit for # backgrounded subshell commands (e.g. (pwd)& ). Believe this is a bug in Bash. # # Disabling this by default. It can be enabled by setting this variable. if [[ -n "${__bp_enable_subshells:-}" ]]; then # Set so debug trap will work be invoked in subshells. set -o functrace > /dev/null 2>&1 shopt -s extdebug > /dev/null 2>&1 fi; local existing_prompt_command # Remove setting our trap install string and sanitize the existing prompt command string existing_prompt_command="${PROMPT_COMMAND:-}" existing_prompt_command="${existing_prompt_command//${__bp_install_string}[;$'\n']}" # Edge case of appending to PROMPT_COMMAND existing_prompt_command="${existing_prompt_command//$__bp_install_string}" __bp_sanitize_string existing_prompt_command "$existing_prompt_command" # Install our hooks in PROMPT_COMMAND to allow our trap to know when we've # actually entered something. PROMPT_COMMAND=$'__bp_precmd_invoke_cmd\n' if [[ -n "$existing_prompt_command" ]]; then PROMPT_COMMAND+=${existing_prompt_command}$'\n' fi; PROMPT_COMMAND+='__bp_interactive_mode' # Add two functions to our arrays for convenience # of definition. precmd_functions+=(precmd) preexec_functions+=(preexec) # Invoke our two functions manually that were added to $PROMPT_COMMAND __bp_precmd_invoke_cmd __bp_interactive_mode } # Sets an installation string as part of our PROMPT_COMMAND to install # after our session has started. This allows bash-preexec to be included # at any point in our bash profile. function __bp_install_after_session_init { # bash-preexec needs to modify these variables in order to work correctly # if it can't, just stop the installation __bp_require_not_readonly PROMPT_COMMAND HISTCONTROL HISTTIMEFORMAT || return local sanitized_prompt_command __bp_sanitize_string sanitized_prompt_command "${PROMPT_COMMAND:-}" if [[ -n "$sanitized_prompt_command" ]]; then PROMPT_COMMAND=${sanitized_prompt_command}$'\n' fi; PROMPT_COMMAND+=${__bp_install_string} } # Run our install so long as we're not delaying it. if [[ -z "${__bp_delay_install:-}" ]]; then __bp_install_after_session_init fi; ================================================ FILE: tools/check_for_upgrade.sh ================================================ #!/usr/bin/env bash if [[ $_omb_upgrade_reload_bashrc ]]; then # We skip the upgrade check if it is attempted while reloading .bashrc after # upgrading OMB. return 0 fi function _omb_upgrade_current_epoch { local sec=${EPOCHSECONDS-} [[ $sec ]] || printf -v sec '%(%s)T' -1 2>/dev/null || sec=$(command date +%s) echo $((sec / 60 / 60 / 24)) } function _omb_upgrade_update_timestamp { echo "LAST_EPOCH=$(_omb_upgrade_current_epoch)" >| ~/.osh-update } function _omb_upgrade_check { if [[ ! -f ~/.osh-update ]]; then # create ~/.osh-update _omb_upgrade_update_timestamp return 0 fi local LAST_EPOCH # shellcheck disable=SC1090 . ~/.osh-update if [[ ! $LAST_EPOCH ]]; then _omb_upgrade_update_timestamp return 0 fi # Default to the old behavior local epoch_expires=${UPDATE_OSH_DAYS:-13} local epoch_elapsed=$(($(_omb_upgrade_current_epoch) - LAST_EPOCH)) if ((epoch_elapsed <= epoch_expires)); then return 0 fi # update ~/.osh-update _omb_upgrade_update_timestamp if [[ $DISABLE_UPDATE_PROMPT == true ]] || { read -rp '[Oh My Bash] Would you like to check for updates? [Y/n]: ' line && [[ $line == Y* || $line == y* || ! $line ]]; } then source "$OSH"/tools/upgrade.sh fi } # Cancel upgrade if the current user doesn't have write permissions for the # oh-my-bash directory. [[ -w $OSH ]] || return 0 # Cancel upgrade if git is unavailable on the system type -P git &>/dev/null || return 0 if command mkdir "$OSH/log/update.lock" 2>/dev/null; then _omb_upgrade_check command rmdir "$OSH"/log/update.lock else printf '%s\n' \ 'oh-my-bash/check_for_upgrade: Failed to get a lock. Please make sure that no' \ 'other process is trying to update Oh My Bash and remove' \ '"'"$OSH"'/log/update.lock"' >&2 fi ================================================ FILE: tools/git-completion.bash ================================================ # bash/zsh completion support for core Git. # # Copyright (C) 2006,2007 Shawn O. Pearce # Conceptually based on gitcompletion (http://gitweb.hawaga.org.uk/). # Distributed under the GNU General Public License, version 2.0. # # The contained completion routines provide support for completing: # # *) local and remote branch names # *) local and remote tag names # *) .git/remotes file names # *) git 'subcommands' # *) git email aliases for git-send-email # *) tree paths within 'ref:path/to/file' expressions # *) file paths within current working directory and index # *) common --long-options # # To use these routines: # # 1) Copy this file to somewhere (e.g. ~/.git-completion.bash). # 2) Add the following line to your .bashrc/.zshrc: # source ~/.git-completion.bash # 3) Consider changing your PS1 to also show the current branch, # see git-prompt.sh for details. # # If you use complex aliases of form '!f() { ... }; f', you can use the null # command ':' as the first command in the function body to declare the desired # completion style. For example '!f() { : git commit ; ... }; f' will # tell the completion to use commit completion. This also works with aliases # of form "!sh -c '...'". For example, "!sh -c ': git commit ; ... '". # # If you have a command that is not part of git, but you would still # like completion, you can use __git_complete: # # __git_complete gl git_log # # Or if it's a main command (i.e. git or gitk): # # __git_complete gk gitk # # Compatible with bash 3.2.57. # # You can set the following environment variables to influence the behavior of # the completion routines: # # GIT_COMPLETION_CHECKOUT_NO_GUESS # # When set to "1", do not include "DWIM" suggestions in git-checkout # and git-switch completion (e.g., completing "foo" when "origin/foo" # exists). # # GIT_COMPLETION_SHOW_ALL # # When set to "1" suggest all options, including options which are # typically hidden (e.g. '--allow-empty' for 'git commit'). case "$COMP_WORDBREAKS" in *:*) : great ;; *) COMP_WORDBREAKS="$COMP_WORDBREAKS:" esac # Discovers the path to the git repository taking any '--git-dir=' and # '-C ' options into account and stores it in the $__git_repo_path # variable. __git_find_repo_path () { if [ -n "${__git_repo_path-}" ]; then # we already know where it is return fi if [ -n "${__git_C_args-}" ]; then __git_repo_path="$(git "${__git_C_args[@]}" \ ${__git_dir:+--git-dir="$__git_dir"} \ rev-parse --absolute-git-dir 2>/dev/null)" elif [ -n "${__git_dir-}" ]; then test -d "$__git_dir" && __git_repo_path="$__git_dir" elif [ -n "${GIT_DIR-}" ]; then test -d "$GIT_DIR" && __git_repo_path="$GIT_DIR" elif [ -d .git ]; then __git_repo_path=.git else __git_repo_path="$(git rev-parse --git-dir 2>/dev/null)" fi } # Deprecated: use __git_find_repo_path() and $__git_repo_path instead # __gitdir accepts 0 or 1 arguments (i.e., location) # returns location of .git repo __gitdir () { if [ -z "${1-}" ]; then __git_find_repo_path || return 1 echo "$__git_repo_path" elif [ -d "$1/.git" ]; then echo "$1/.git" else echo "$1" fi } # Runs git with all the options given as argument, respecting any # '--git-dir=' and '-C ' options present on the command line __git () { git ${__git_C_args:+"${__git_C_args[@]}"} \ ${__git_dir:+--git-dir="$__git_dir"} "$@" 2>/dev/null } # Removes backslash escaping, single quotes and double quotes from a word, # stores the result in the variable $dequoted_word. # 1: The word to dequote. __git_dequote () { local rest="$1" len ch dequoted_word="" while test -n "$rest"; do len=${#dequoted_word} dequoted_word="$dequoted_word${rest%%[\\\'\"]*}" rest="${rest:$((${#dequoted_word}-$len))}" case "${rest:0:1}" in \\) ch="${rest:1:1}" case "$ch" in $'\n') ;; *) dequoted_word="$dequoted_word$ch" ;; esac rest="${rest:2}" ;; \') rest="${rest:1}" len=${#dequoted_word} dequoted_word="$dequoted_word${rest%%\'*}" rest="${rest:$((${#dequoted_word}-$len+1))}" ;; \") rest="${rest:1}" while test -n "$rest" ; do len=${#dequoted_word} dequoted_word="$dequoted_word${rest%%[\\\"]*}" rest="${rest:$((${#dequoted_word}-$len))}" case "${rest:0:1}" in \\) ch="${rest:1:1}" case "$ch" in \"|\\|\$|\`) dequoted_word="$dequoted_word$ch" ;; $'\n') ;; *) dequoted_word="$dequoted_word\\$ch" ;; esac rest="${rest:2}" ;; \") rest="${rest:1}" break ;; esac done ;; esac done } # The following function is based on code from: # # bash_completion - programmable completion functions for bash 3.2+ # # Copyright © 2006-2008, Ian Macdonald # © 2009-2010, Bash Completion Maintainers # # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2, or (at your option) # any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, see . # # The latest version of this software can be obtained here: # # http://bash-completion.alioth.debian.org/ # # RELEASE: 2.x # This function can be used to access a tokenized list of words # on the command line: # # __git_reassemble_comp_words_by_ref '=:' # if test "${words_[cword_-1]}" = -w # then # ... # fi # # The argument should be a collection of characters from the list of # word completion separators (COMP_WORDBREAKS) to treat as ordinary # characters. # # This is roughly equivalent to going back in time and setting # COMP_WORDBREAKS to exclude those characters. The intent is to # make option types like --date= and : easy to # recognize by treating each shell word as a single token. # # It is best not to set COMP_WORDBREAKS directly because the value is # shared with other completion scripts. By the time the completion # function gets called, COMP_WORDS has already been populated so local # changes to COMP_WORDBREAKS have no effect. # # Output: words_, cword_, cur_. __git_reassemble_comp_words_by_ref() { local exclude i j first # Which word separators to exclude? exclude="${1//[^$COMP_WORDBREAKS]}" cword_=$COMP_CWORD if [ -z "$exclude" ]; then words_=("${COMP_WORDS[@]}") return fi # List of word completion separators has shrunk; # re-assemble words to complete. for ((i=0, j=0; i < ${#COMP_WORDS[@]}; i++, j++)); do # Append each nonempty word consisting of just # word separator characters to the current word. first=t while [ $i -gt 0 ] && [ -n "${COMP_WORDS[$i]}" ] && # word consists of excluded word separators [ "${COMP_WORDS[$i]//[^$exclude]}" = "${COMP_WORDS[$i]}" ] do # Attach to the previous token, # unless the previous token is the command name. if [ $j -ge 2 ] && [ -n "$first" ]; then ((j--)) fi first= words_[$j]=${words_[j]}${COMP_WORDS[i]} if [ $i = $COMP_CWORD ]; then cword_=$j fi if (($i < ${#COMP_WORDS[@]} - 1)); then ((i++)) else # Done. return fi done words_[$j]=${words_[j]}${COMP_WORDS[i]} if [ $i = $COMP_CWORD ]; then cword_=$j fi done } if ! type _get_comp_words_by_ref >/dev/null 2>&1; then _get_comp_words_by_ref () { local exclude cur_ words_ cword_ if [ "$1" = "-n" ]; then exclude=$2 shift 2 fi __git_reassemble_comp_words_by_ref "$exclude" cur_=${words_[cword_]} while [ $# -gt 0 ]; do case "$1" in cur) cur=$cur_ ;; prev) prev=${words_[$cword_-1]} ;; words) words=("${words_[@]}") ;; cword) cword=$cword_ ;; esac shift done } fi # Fills the COMPREPLY array with prefiltered words without any additional # processing. # Callers must take care of providing only words that match the current word # to be completed and adding any prefix and/or suffix (trailing space!), if # necessary. # 1: List of newline-separated matching completion words, complete with # prefix and suffix. __gitcomp_direct () { local IFS=$'\n' COMPREPLY=($1) } # Similar to __gitcomp_direct, but appends to COMPREPLY instead. # Callers must take care of providing only words that match the current word # to be completed and adding any prefix and/or suffix (trailing space!), if # necessary. # 1: List of newline-separated matching completion words, complete with # prefix and suffix. __gitcomp_direct_append () { local IFS=$'\n' COMPREPLY+=($1) } __gitcompappend () { local x i=${#COMPREPLY[@]} for x in $1; do if [[ "$x" == "$3"* ]]; then COMPREPLY[i++]="$2$x$4" fi done } __gitcompadd () { COMPREPLY=() __gitcompappend "$@" } # Generates completion reply, appending a space to possible completion words, # if necessary. # It accepts 1 to 4 arguments: # 1: List of possible completion words. # 2: A prefix to be added to each possible completion word (optional). # 3: Generate possible completion matches for this word (optional). # 4: A suffix to be appended to each possible completion word (optional). __gitcomp () { local cur_="${3-$cur}" case "$cur_" in *=) ;; --no-*) local c i=0 IFS=$' \t\n' for c in $1; do if [[ $c == "--" ]]; then continue fi c="$c${4-}" if [[ $c == "$cur_"* ]]; then case $c in --*=|*.) ;; *) c="$c " ;; esac COMPREPLY[i++]="${2-}$c" fi done ;; *) local c i=0 IFS=$' \t\n' for c in $1; do if [[ $c == "--" ]]; then c="--no-...${4-}" if [[ $c == "$cur_"* ]]; then COMPREPLY[i++]="${2-}$c " fi break fi c="$c${4-}" if [[ $c == "$cur_"* ]]; then case $c in *=|*.) ;; *) c="$c " ;; esac COMPREPLY[i++]="${2-}$c" fi done ;; esac } # Clear the variables caching builtins' options when (re-)sourcing # the completion script. if [[ -n ${ZSH_VERSION-} ]]; then unset ${(M)${(k)parameters[@]}:#__gitcomp_builtin_*} 2>/dev/null else unset $(compgen -v __gitcomp_builtin_) fi # This function is equivalent to # # __gitcomp "$(git xxx --git-completion-helper) ..." # # except that the output is cached. Accept 1-3 arguments: # 1: the git command to execute, this is also the cache key # 2: extra options to be added on top (e.g. negative forms) # 3: options to be excluded __gitcomp_builtin () { # spaces must be replaced with underscore for multi-word # commands, e.g. "git remote add" becomes remote_add. local cmd="$1" local incl="${2-}" local excl="${3-}" local var=__gitcomp_builtin_"${cmd//-/_}" local options eval "options=\${$var-}" if [ -z "$options" ]; then local completion_helper if [ "${GIT_COMPLETION_SHOW_ALL-}" = "1" ]; then completion_helper="--git-completion-helper-all" else completion_helper="--git-completion-helper" fi # leading and trailing spaces are significant to make # option removal work correctly. options=" $incl $(__git ${cmd/_/ } $completion_helper) " || return for i in $excl; do options="${options/ $i / }" done eval "$var=\"$options\"" fi __gitcomp "$options" } # Variation of __gitcomp_nl () that appends to the existing list of # completion candidates, COMPREPLY. __gitcomp_nl_append () { local IFS=$'\n' __gitcompappend "$1" "${2-}" "${3-$cur}" "${4- }" } # Generates completion reply from newline-separated possible completion words # by appending a space to all of them. # It accepts 1 to 4 arguments: # 1: List of possible completion words, separated by a single newline. # 2: A prefix to be added to each possible completion word (optional). # 3: Generate possible completion matches for this word (optional). # 4: A suffix to be appended to each possible completion word instead of # the default space (optional). If specified but empty, nothing is # appended. __gitcomp_nl () { COMPREPLY=() __gitcomp_nl_append "$@" } # Fills the COMPREPLY array with prefiltered paths without any additional # processing. # Callers must take care of providing only paths that match the current path # to be completed and adding any prefix path components, if necessary. # 1: List of newline-separated matching paths, complete with all prefix # path components. __gitcomp_file_direct () { local IFS=$'\n' COMPREPLY=($1) # use a hack to enable file mode in bash < 4 compopt -o filenames +o nospace 2>/dev/null || compgen -f /non-existing-dir/ >/dev/null || true } # Generates completion reply with compgen from newline-separated possible # completion filenames. # It accepts 1 to 3 arguments: # 1: List of possible completion filenames, separated by a single newline. # 2: A directory prefix to be added to each possible completion filename # (optional). # 3: Generate possible completion matches for this word (optional). __gitcomp_file () { local IFS=$'\n' # XXX does not work when the directory prefix contains a tilde, # since tilde expansion is not applied. # This means that COMPREPLY will be empty and Bash default # completion will be used. __gitcompadd "$1" "${2-}" "${3-$cur}" "" # use a hack to enable file mode in bash < 4 compopt -o filenames +o nospace 2>/dev/null || compgen -f /non-existing-dir/ >/dev/null || true } # Execute 'git ls-files', unless the --committable option is specified, in # which case it runs 'git diff-index' to find out the files that can be # committed. It return paths relative to the directory specified in the first # argument, and using the options specified in the second argument. __git_ls_files_helper () { if [ "$2" = "--committable" ]; then __git -C "$1" -c core.quotePath=false diff-index \ --name-only --relative HEAD -- "${3//\\/\\\\}*" else # NOTE: $2 is not quoted in order to support multiple options __git -C "$1" -c core.quotePath=false ls-files \ --exclude-standard $2 -- "${3//\\/\\\\}*" fi } # __git_index_files accepts 1 or 2 arguments: # 1: Options to pass to ls-files (required). # 2: A directory path (optional). # If provided, only files within the specified directory are listed. # Sub directories are never recursed. Path must have a trailing # slash. # 3: List only paths matching this path component (optional). __git_index_files () { local root="$2" match="$3" __git_ls_files_helper "$root" "$1" "${match:-?}" | awk -F / -v pfx="${2//\\/\\\\}" '{ paths[$1] = 1 } END { for (p in paths) { if (substr(p, 1, 1) != "\"") { # No special characters, easy! print pfx p continue } # The path is quoted. p = dequote(p) if (p == "") continue # Even when a directory name itself does not contain # any special characters, it will still be quoted if # any of its (stripped) trailing path components do. # Because of this we may have seen the same directory # both quoted and unquoted. if (p in paths) # We have seen the same directory unquoted, # skip it. continue else print pfx p } } function dequote(p, bs_idx, out, esc, esc_idx, dec) { # Skip opening double quote. p = substr(p, 2) # Interpret backslash escape sequences. while ((bs_idx = index(p, "\\")) != 0) { out = out substr(p, 1, bs_idx - 1) esc = substr(p, bs_idx + 1, 1) p = substr(p, bs_idx + 2) if ((esc_idx = index("abtvfr\"\\", esc)) != 0) { # C-style one-character escape sequence. out = out substr("\a\b\t\v\f\r\"\\", esc_idx, 1) } else if (esc == "n") { # Uh-oh, a newline character. # We cannot reliably put a pathname # containing a newline into COMPREPLY, # and the newline would create a mess. # Skip this path. return "" } else { # Must be a \nnn octal value, then. dec = esc * 64 + \ substr(p, 1, 1) * 8 + \ substr(p, 2, 1) out = out sprintf("%c", dec) p = substr(p, 3) } } # Drop closing double quote, if there is one. # (There is not any if this is a directory, as it was # already stripped with the trailing path components.) if (substr(p, length(p), 1) == "\"") out = out substr(p, 1, length(p) - 1) else out = out p return out }' } # __git_complete_index_file requires 1 argument: # 1: the options to pass to ls-file # # The exception is --committable, which finds the files appropriate commit. __git_complete_index_file () { local dequoted_word pfx="" cur_ __git_dequote "$cur" case "$dequoted_word" in ?*/*) pfx="${dequoted_word%/*}/" cur_="${dequoted_word##*/}" ;; *) cur_="$dequoted_word" esac __gitcomp_file_direct "$(__git_index_files "$1" "$pfx" "$cur_")" } # Lists branches from the local repository. # 1: A prefix to be added to each listed branch (optional). # 2: List only branches matching this word (optional; list all branches if # unset or empty). # 3: A suffix to be appended to each listed branch (optional). __git_heads () { local pfx="${1-}" cur_="${2-}" sfx="${3-}" __git for-each-ref --format="${pfx//\%/%%}%(refname:strip=2)$sfx" \ "refs/heads/$cur_*" "refs/heads/$cur_*/**" } # Lists branches from remote repositories. # 1: A prefix to be added to each listed branch (optional). # 2: List only branches matching this word (optional; list all branches if # unset or empty). # 3: A suffix to be appended to each listed branch (optional). __git_remote_heads () { local pfx="${1-}" cur_="${2-}" sfx="${3-}" __git for-each-ref --format="${pfx//\%/%%}%(refname:strip=2)$sfx" \ "refs/remotes/$cur_*" "refs/remotes/$cur_*/**" } # Lists tags from the local repository. # Accepts the same positional parameters as __git_heads() above. __git_tags () { local pfx="${1-}" cur_="${2-}" sfx="${3-}" __git for-each-ref --format="${pfx//\%/%%}%(refname:strip=2)$sfx" \ "refs/tags/$cur_*" "refs/tags/$cur_*/**" } # List unique branches from refs/remotes used for 'git checkout' and 'git # switch' tracking DWIMery. # 1: A prefix to be added to each listed branch (optional) # 2: List only branches matching this word (optional; list all branches if # unset or empty). # 3: A suffix to be appended to each listed branch (optional). __git_dwim_remote_heads () { local pfx="${1-}" cur_="${2-}" sfx="${3-}" local fer_pfx="${pfx//\%/%%}" # "escape" for-each-ref format specifiers # employ the heuristic used by git checkout and git switch # Try to find a remote branch that cur_es the completion word # but only output if the branch name is unique __git for-each-ref --format="$fer_pfx%(refname:strip=3)$sfx" \ --sort="refname:strip=3" \ "refs/remotes/*/$cur_*" "refs/remotes/*/$cur_*/**" | \ uniq -u } # Lists refs from the local (by default) or from a remote repository. # It accepts 0, 1 or 2 arguments: # 1: The remote to list refs from (optional; ignored, if set but empty). # Can be the name of a configured remote, a path, or a URL. # 2: In addition to local refs, list unique branches from refs/remotes/ for # 'git checkout's tracking DWIMery (optional; ignored, if set but empty). # 3: A prefix to be added to each listed ref (optional). # 4: List only refs matching this word (optional; list all refs if unset or # empty). # 5: A suffix to be appended to each listed ref (optional; ignored, if set # but empty). # # Use __git_complete_refs() instead. __git_refs () { local i hash dir track="${2-}" local list_refs_from=path remote="${1-}" local format refs local pfx="${3-}" cur_="${4-$cur}" sfx="${5-}" local match="${4-}" local fer_pfx="${pfx//\%/%%}" # "escape" for-each-ref format specifiers __git_find_repo_path dir="$__git_repo_path" if [ -z "$remote" ]; then if [ -z "$dir" ]; then return fi else if __git_is_configured_remote "$remote"; then # configured remote takes precedence over a # local directory with the same name list_refs_from=remote elif [ -d "$remote/.git" ]; then dir="$remote/.git" elif [ -d "$remote" ]; then dir="$remote" else list_refs_from=url fi fi if [ "$list_refs_from" = path ]; then if [[ "$cur_" == ^* ]]; then pfx="$pfx^" fer_pfx="$fer_pfx^" cur_=${cur_#^} match=${match#^} fi case "$cur_" in refs|refs/*) format="refname" refs=("$match*" "$match*/**") track="" ;; *) for i in HEAD FETCH_HEAD ORIG_HEAD MERGE_HEAD REBASE_HEAD CHERRY_PICK_HEAD; do case "$i" in $match*) if [ -e "$dir/$i" ]; then echo "$pfx$i$sfx" fi ;; esac done format="refname:strip=2" refs=("refs/tags/$match*" "refs/tags/$match*/**" "refs/heads/$match*" "refs/heads/$match*/**" "refs/remotes/$match*" "refs/remotes/$match*/**") ;; esac __git_dir="$dir" __git for-each-ref --format="$fer_pfx%($format)$sfx" \ "${refs[@]}" if [ -n "$track" ]; then __git_dwim_remote_heads "$pfx" "$match" "$sfx" fi return fi case "$cur_" in refs|refs/*) __git ls-remote "$remote" "$match*" | \ while read -r hash i; do case "$i" in *^{}) ;; *) echo "$pfx$i$sfx" ;; esac done ;; *) if [ "$list_refs_from" = remote ]; then case "HEAD" in $match*) echo "${pfx}HEAD$sfx" ;; esac __git for-each-ref --format="$fer_pfx%(refname:strip=3)$sfx" \ "refs/remotes/$remote/$match*" \ "refs/remotes/$remote/$match*/**" else local query_symref case "HEAD" in $match*) query_symref="HEAD" ;; esac __git ls-remote "$remote" $query_symref \ "refs/tags/$match*" "refs/heads/$match*" \ "refs/remotes/$match*" | while read -r hash i; do case "$i" in *^{}) ;; refs/*) echo "$pfx${i#refs/*/}$sfx" ;; *) echo "$pfx$i$sfx" ;; # symbolic refs esac done fi ;; esac } # Completes refs, short and long, local and remote, symbolic and pseudo. # # Usage: __git_complete_refs [