Обновление ohmyzsh

This commit is contained in:
Дмитрий Рамазанов 2021-06-10 11:49:35 +05:00
parent 9fcc978a55
commit e7247fa93a
501 changed files with 18233 additions and 8842 deletions

8
zsh/.editorconfig Normal file
View File

@ -0,0 +1,8 @@
root = true
[*]
end_of_line = lf
insert_final_newline = true
charset = utf-8
indent_size = 2
indent_style = space

9
zsh/.github/CODEOWNERS vendored Normal file
View File

@ -0,0 +1,9 @@
# Plugin owners
plugins/archlinux/ @ratijas
plugins/aws/ @maksyms
plugins/genpass/ @atoponce
plugins/git-lfs/ @hellovietduc
plugins/gitfast/ @felipec
plugins/sdk/ @rgoldberg
plugins/universalarchive/ @Konfekt
plugins/wp-cli/ @joshmedeski

2
zsh/.github/FUNDING.yml vendored Normal file
View File

@ -0,0 +1,2 @@
github: [robbyrussell, mcornella, larson-carter]
open_collective: ohmyzsh

View File

@ -0,0 +1,46 @@
---
name: Bug report
about: Create a report to help us improve Oh My Zsh
labels: 'Bug'
---
<!--
Fill this out before posting. You can delete irrelevant sections, but
an issue where no sections have been filled will be deleted without comment.
-->
**Describe the bug**
A clear description of what the bug is.
**To Reproduce**
Steps to reproduce the behavior, for example:
1. Enable this plugin '...'
2. Run command '...' or try the autocomplete command '...'
3. See error
**Expected behavior**
A brief description of what should happen.
**Screenshots and/or Recordings**
If applicable, add screenshots to help explain your problem.
You can also record an asciinema session: https://asciinema.org/
**Self Check**
- Have you tried reaching out on the [Discord server](https://discord.gg/ohmyzsh)?
This can help cut down on filling up issues. We always have a few people
online that are in a variety of timezones that are willing to help you!
- Also searching existing [GitHub Issues](https://github.com/ohmyzsh/ohmyzsh/issues?q=) might help you get quicker support
**Desktop (please complete the following information):**
- OS / Distro: [e.g. Arch Linux, macOS]
- If on Windows what version of WSL: [e.g. WSL1, WSL2]
- Latest ohmyzsh update?: [e.g. Yes/No]
- ZSH Version: [e.g. 5.6]
- Terminal emulator: [e.g. iTerm2]
**Additional context**
Add any other context about the problem here. This can be themes, plugins, custom configs.

8
zsh/.github/ISSUE_TEMPLATE/config.yml vendored Normal file
View File

@ -0,0 +1,8 @@
blank_issues_enabled: true
contact_links:
- name: Support
url: https://github.com/ohmyzsh/ohmyzsh/discussions
about: Ask the community for support
- name: Get help on Discord
url: https://discord.gg/ohmyzsh
about: Have a quick question? Join the Discord server and ask on the appropriate channel.

View File

@ -0,0 +1,29 @@
---
name: Feature request
about: Suggest a feature for Oh My Zsh
labels: 'Feature'
---
<!--
Fill this out before posting. You can delete irrelevant sections, but
an issue where no sections have been filled will be deleted without comment.
-->
**Is your feature request related to a particular plugin or theme? If so, specify it.**
The name of the plugin, theme or alias that you would like us to improve. [...]
**Is your feature request related to a problem? Please describe.**
A description of what the problem is. Ex. I'm always frustrated when [...]
**Describe the solution you'd like**
A description of what you want to happen. [...]
**Describe alternatives you've considered**
A description of any alternative solutions or features you've considered. This can also include other plugins or themes.
**Additional context**
Add any other context, screenshots or discord conversations about the feature request here. Also if you have any PRs related to this issue that are already open that you would like us to look at.
**Related Issues**
Is there any open or closed issues that is related to this feature request? If so please link them below! [...]

19
zsh/.github/PULL_REQUEST_TEMPLATE.md vendored Normal file
View File

@ -0,0 +1,19 @@
## Standards checklist:
<!-- Fill with an x the ones that apply. Example: [x] -->
- [ ] The PR title is descriptive.
- [ ] The PR doesn't replicate another PR which is already open.
- [ ] I have read the contribution guide and followed all the instructions.
- [ ] The code follows the code style guide detailed in the wiki.
- [ ] The code is mine or it's from somewhere with an MIT-compatible license.
- [ ] The code is efficient, to the best of my ability, and does not waste computer resources.
- [ ] The code is stable and I have tested it myself, to the best of my abilities.
## Changes:
- [...]
## Other comments:
...

36
zsh/.github/workflows/main.yml vendored Normal file
View File

@ -0,0 +1,36 @@
name: CI
on:
pull_request:
types:
- opened
- synchronize
branches:
- master
push:
branches:
- master
jobs:
tests:
name: Run tests
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
steps:
- name: Set up git repository
uses: actions/checkout@v2
- name: Install zsh
if: runner.os == 'Linux'
run: sudo apt-get update; sudo apt-get install zsh
- name: Test installer
run: sh ./tools/install.sh
- name: Check syntax
run: |
for file in ./oh-my-zsh.sh \
./lib/*.zsh \
./plugins/*/*.plugin.zsh \
./plugins/*/_* \
./themes/*.zsh-theme; do
zsh -n "$file" || return 1
done

8
zsh/.gitignore vendored Normal file
View File

@ -0,0 +1,8 @@
# custom files
custom/
# temp files directories
cache/
log/
*.swp
.DS_Store

5
zsh/.gitpod.Dockerfile vendored Normal file
View File

@ -0,0 +1,5 @@
FROM gitpod/workspace-full
RUN sudo apt-get update && \
sudo apt-get install -y zsh && \
sudo rm -rf /var/lib/apt/lists/*

9
zsh/.gitpod.yml Normal file
View File

@ -0,0 +1,9 @@
image:
file: .gitpod.Dockerfile
tasks:
- init: |
export EDITOR="command gp open -w" VISUAL="command gp open -w"
cp -f /workspace/ohmyzsh/templates/zshrc.zsh-template ~/.zshrc
ln -sf /workspace/ohmyzsh ~/.oh-my-zsh
command: exec zsh

76
zsh/CODE_OF_CONDUCT.md Normal file
View File

@ -0,0 +1,76 @@
# Contributor Covenant Code of Conduct
## Our Pledge
In the interest of fostering an open and welcoming environment, we as
contributors and maintainers pledge to making participation in our project and
our community a harassment-free experience for everyone, regardless of age, body
size, disability, ethnicity, sex characteristics, gender identity and expression,
level of experience, education, socio-economic status, nationality, personal
appearance, race, religion, or sexual identity and orientation.
## Our Standards
Examples of behavior that contributes to creating a positive environment
include:
* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy towards other community members
Examples of unacceptable behavior by participants include:
* The use of sexualized language or imagery and unwelcome sexual attention or
advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic
address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a
professional setting
## Our Responsibilities
Project maintainers are responsible for clarifying the standards of acceptable
behavior and are expected to take appropriate and fair corrective action in
response to any instances of unacceptable behavior.
Project maintainers have the right and responsibility to remove, edit, or
reject comments, commits, code, wiki edits, issues, and other contributions
that are not aligned to this Code of Conduct, or to ban temporarily or
permanently any contributor for other behaviors that they deem inappropriate,
threatening, offensive, or harmful.
## Scope
This Code of Conduct applies within all project spaces, and it also applies when
an individual is representing the project or its community in public spaces.
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 ohmyzsh@planetargon.com. All
complaints will be reviewed and investigated and will result in a response that
is deemed necessary and appropriate to the circumstances. The project team is
obligated to maintain confidentiality with regard to the reporter of an incident.
Further details of specific enforcement policies may be posted separately.
Project maintainers who do not follow or enforce the Code of Conduct in good
faith may face temporary or permanent repercussions as determined by other
members of the project's leadership.
## Attribution
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
[homepage]: https://www.contributor-covenant.org
For answers to common questions about this code of conduct, see
https://www.contributor-covenant.org/faq

224
zsh/CONTRIBUTING.md Normal file
View File

@ -0,0 +1,224 @@
# CONTRIBUTING GUIDELINES
Oh-My-Zsh is a community-driven project. Contribution is welcome, encouraged, and appreciated.
It is also essential for the development of the project.
First, please take a moment to review our [code of conduct](CODE_OF_CONDUCT.md).
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.
<!-- TOC updateonsave:true depthfrom:2 -->
- [Reporting Issues](#reporting-issues)
- [You have a problem](#you-have-a-problem)
- [You have a suggestion](#you-have-a-suggestion)
- [Submitting Pull Requests](#submitting-pull-requests)
- [Getting started](#getting-started)
- [You have a solution](#you-have-a-solution)
- [You have an addition](#you-have-an-addition)
- [Use the Search, Luke](#use-the-search-luke)
- [Commit Guidelines](#commit-guidelines)
- [Format](#format)
- [Style](#style)
- [Volunteer](#volunteer)
<!-- /TOC -->
## 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/ohmyzsh/ohmyzsh/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 (_eg_ 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.
## Submitting Pull Requests
### Getting started
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/ohmyzsh/ohmyzsh/wiki/Contribution-Technical-Practices).
You MUST always create PRs with _a dedicated branch_ based on the latest upstream tree.
If you create your own PR, please make sure you do it right. Also be so kind as to reference
any issue that would be solved in the PR description body,
[for instance](https://help.github.com/articles/closing-issues-via-commit-messages/)
_"Fixes #XXXX"_ for issue number XXXX.
### You have a solution
Please be so kind as to [search](#use-the-search-luke) for any open issue already covering
your [problem](#you-have-a-problem), and any pending/merged/rejected PR covering your solution.
If the solution 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 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 have an addition
Please [do not](https://github.com/ohmyzsh/ohmyzsh/wiki/Themes#dont-send-us-your-theme-for-now)
send themes for now.
Please be so kind as to [search](#use-the-search-luke) for any pending, merged or rejected Pull Requests
covering or related to what you want to add.
If you find one, 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 (_eg_ plugin
maintainers) by mentioning their GitHub handle (starting with `@`) in your message.
For any extensive change, _eg_ a new plugin, you will have to find testers to +1 your PR.
----
## 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/ohmyzsh/ohmyzsh/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).
----
## Commit Guidelines
Oh My Zsh uses the [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/)
specification. The automatic changelog tool uses these to automatically generate
a changelog based on the commit messages. Here's a guide to writing a commit message
to allow this:
### Format
```
type(scope)!: subject
```
- `type`: the type of the commit is one of the following:
- `feat`: new features.
- `fix`: bug fixes.
- `docs`: documentation changes.
- `refactor`: refactor of a particular code section without introducing
new features or bug fixes.
- `style`: code style improvements.
- `perf`: performance improvements.
- `test`: changes to the test suite.
- `ci`: changes to the CI system.
- `build`: changes to the build system (we don't yet have one so this shouldn't apply).
- `chore`: for other changes that don't match previous types. This doesn't appear
in the changelog.
- `scope`: section of the codebase that the commit makes changes to. If it makes changes to
many sections, or if no section in particular is modified, leave blank without the parentheses.
Examples:
- Commit that changes the `git` plugin:
```
feat(git): add alias for `git commit`
```
- Commit that changes many plugins:
```
style: fix inline declaration of arrays
```
For changes to plugins or themes, the scope should be the plugin or theme name:
- ✅ `fix(agnoster): commit subject`
- ❌ `fix(theme/agnoster): commit subject`
- `!`: this goes after the `scope` (or the `type` if scope is empty), to indicate that the commit
introduces breaking changes.
Optionally, you can specify a message that the changelog tool will display to the user to indicate
what's changed and what they can do to deal with it. You can use multiple lines to type this message;
the changelog parser will keep reading until the end of the commit message or until it finds an empty
line.
Example (made up):
```
style(agnoster)!: change dirty git repo glyph
BREAKING CHANGE: the glyph to indicate when a git repository is dirty has
changed from a Powerline character to a standard UTF-8 emoji. You can
change it back by setting `ZSH_THEME_DIRTY_GLYPH`.
Fixes #420
Co-authored-by: Username <email>
```
- `subject`: a brief description of the changes. This will be displayed in the changelog. If you need
to specify other details you can use the commit body but it won't be visible.
Formatting tricks: the commit subject may contain:
- Links to related issues or PRs by writing `#issue`. This will be highlighted by the changelog tool:
```
feat(archlinux): add support for aura AUR helper (#9467)
```
- Formatted inline code by using backticks: the text inbetween backticks will also be highlighted by
the changelog tool:
```
feat(shell-proxy): enable unexported `DEFAULT_PROXY` setting (#9774)
```
### Style
Try to keep the first commit line short. This is harder to do using this commit style but try to be
concise and if you need more space, you can use the commit body. Try to make sure that the commit
subject is clear and precise enough that users will know what change by just looking at the changelog.
----
## Volunteer
Very nice!! :)
Please have a look at the [Volunteer](https://github.com/ohmyzsh/ohmyzsh/wiki/Volunteers)
page for instructions on where to start and more.

View File

@ -1,7 +1,6 @@
The MIT License (MIT) MIT License
Copyright (c) 2009-2019 Robby Russell and contributors Copyright (c) 2009-2021 Robby Russell and contributors (https://github.com/ohmyzsh/ohmyzsh/contributors)
See the full list at https://github.com/robbyrussell/oh-my-zsh/contributors
Permission is hereby granted, free of charge, to any person obtaining a copy Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal of this software and associated documentation files (the "Software"), to deal

View File

@ -1,45 +1,40 @@
<p align="center"> <p align="center"><img src="https://s3.amazonaws.com/ohmyzsh/oh-my-zsh-logo.png" alt="Oh My Zsh"></p>
<img src="https://s3.amazonaws.com/ohmyzsh/oh-my-zsh-logo.png" alt="Oh My Zsh">
</p>
Oh My Zsh is an open source, community-driven framework for managing your [zsh](https://www.zsh.org/) configuration. Oh My Zsh is an open source, community-driven framework for managing your [zsh](https://www.zsh.org/) configuration.
Sounds boring. Let's try again. Sounds boring. Let's try again.
__Oh My Zsh will not make you a 10x developer...but you may feel like one.__ **Oh My Zsh will not make you a 10x developer...but you may 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?"_ 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. 😬 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. 😬
To learn more, visit [ohmyz.sh](https://ohmyz.sh) and follow [@ohmyzsh](https://twitter.com/ohmyzsh) on Twitter. To learn more, visit [ohmyz.sh](https://ohmyz.sh), follow [@ohmyzsh](https://twitter.com/ohmyzsh) on Twitter, and join us on [Discord](https://discord.gg/ohmyzsh).
[![CI](https://github.com/ohmyzsh/ohmyzsh/workflows/CI/badge.svg)](https://github.com/ohmyzsh/ohmyzsh/actions?query=workflow%3ACI)
[![Follow @ohmyzsh](https://img.shields.io/twitter/follow/ohmyzsh?label=Follow+@ohmyzsh&style=flat)](https://twitter.com/intent/follow?screen_name=ohmyzsh)
[![Discord server](https://img.shields.io/discord/642496866407284746)](https://discord.gg/ohmyzsh)
[![Gitpod ready](https://img.shields.io/badge/Gitpod-ready-blue?logo=gitpod)](https://gitpod.io/#https://github.com/ohmyzsh/ohmyzsh)
## Getting Started ## Getting Started
### Prerequisites ### Prerequisites
__Disclaimer:__ _Oh My Zsh works best on macOS and Linux._ - A Unix-like operating system: macOS, Linux, BSD. On Windows: WSL2 is preferred, but cygwin or msys also mostly work.
- [Zsh](https://www.zsh.org) should be installed (v4.3.9 or more recent is fine but we prefer 5.0.8 and newer). If not pre-installed (run `zsh --version` to confirm), check the following wiki instructions here: [Installing ZSH](https://github.com/ohmyzsh/ohmyzsh/wiki/Installing-ZSH)
* Unix-like operating system (macOS or Linux) - `curl` or `wget` should be installed
* [Zsh](https://www.zsh.org) should be installed (v4.3.9 or more recent). If not pre-installed (`zsh --version` to confirm), check the following instruction here: [Installing ZSH](https://github.com/robbyrussell/oh-my-zsh/wiki/Installing-ZSH) - `git` should be installed (recommended v2.4.11 or higher)
* `curl` or `wget` should be installed
* `git` should be installed
### Basic Installation ### Basic Installation
Oh My Zsh 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`. Oh My Zsh is installed by running one of the following commands in your terminal. You can install this via the command-line with either `curl`, `wget` or another similar tool.
#### via curl | Method | Command |
|:----------|:--------------------------------------------------------------------------------------------------|
```shell | **curl** | `sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"` |
sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)" | **wget** | `sh -c "$(wget -O- https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"` |
``` | **fetch** | `sh -c "$(fetch -o - https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"` |
#### via wget
```shell
sh -c "$(wget -O- https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
```
#### Manual inspection #### Manual inspection
@ -48,7 +43,7 @@ that by downloading the install script first, looking through it so everything l
then running it: then running it:
```shell ```shell
curl -Lo install.sh https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh wget https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh
sh install.sh sh install.sh
``` ```
@ -56,7 +51,7 @@ sh install.sh
### Plugins ### Plugins
Oh My Zsh comes with a shitload of plugins to take advantage of. You can take a look in the [plugins](https://github.com/robbyrussell/oh-my-zsh/tree/master/plugins) directory and/or the [wiki](https://github.com/robbyrussell/oh-my-zsh/wiki/Plugins) to see what's currently available. Oh My Zsh comes with a shitload of plugins for you to take advantage of. You can take a look in the [plugins](https://github.com/ohmyzsh/ohmyzsh/tree/master/plugins) directory and/or the [wiki](https://github.com/ohmyzsh/ohmyzsh/wiki/Plugins) to see what's currently available.
#### Enabling Plugins #### Enabling Plugins
@ -80,15 +75,15 @@ plugins=(
) )
``` ```
_Note that the plugins are separated by whitespace. **Do not** use commas between them._ _Note that the plugins are separated by whitespace (spaces, tabs, new lines...). **Do not** use commas between them or it will break._
#### Using Plugins #### Using Plugins
Most plugins (should! we're working on this) include a __README__, which documents how to use them. Each plugin includes a __README__, documenting it. This README should show the aliases (if the plugin adds any) and extra goodies that are included in that particular plugin.
### Themes ### Themes
We'll admit it. Early in the Oh My Zsh 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/robbyrussell/oh-my-zsh/wiki/Themes) on the wiki. Check them out! We'll admit it. Early in the Oh My Zsh world, we may have gotten a bit too theme happy. We have over one hundred and fifty themes now bundled. Most of them have [screenshots](https://github.com/ohmyzsh/ohmyzsh/wiki/Themes) on the wiki (We are working on updating this!). Check them out!
#### Selecting a Theme #### Selecting a Theme
@ -104,7 +99,7 @@ To use a different theme, simply change the value to match the name of your desi
```shell ```shell
ZSH_THEME="agnoster" # (this is one of the fancy ones) ZSH_THEME="agnoster" # (this is one of the fancy ones)
# see https://github.com/robbyrussell/oh-my-zsh/wiki/Themes#agnoster # see https://github.com/ohmyzsh/ohmyzsh/wiki/Themes#agnoster
``` ```
_Note: many themes require installing the [Powerline Fonts](https://github.com/powerline/fonts) in order to render properly._ _Note: many themes require installing the [Powerline Fonts](https://github.com/powerline/fonts) in order to render properly._
@ -113,11 +108,10 @@ Open up a new terminal window and your prompt should look something like this:
![Agnoster theme](https://cloud.githubusercontent.com/assets/2618447/6316862/70f58fb6-ba03-11e4-82c9-c083bf9a6574.png) ![Agnoster theme](https://cloud.githubusercontent.com/assets/2618447/6316862/70f58fb6-ba03-11e4-82c9-c083bf9a6574.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/robbyrussell/oh-my-zsh/wiki/External-themes). 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/ohmyzsh/ohmyzsh/wiki/External-themes).
If you're feeling feisty, you can let the computer select one randomly for you each time you open a new terminal window. If you're feeling feisty, you can let the computer select one randomly for you each time you open a new terminal window.
```shell ```shell
ZSH_THEME="random" # (...please let it be pie... please be some pie..) ZSH_THEME="random" # (...please let it be pie... please be some pie..)
``` ```
@ -131,6 +125,16 @@ ZSH_THEME_RANDOM_CANDIDATES=(
) )
``` ```
If you only know which themes you don't like, you can add them similarly to an ignored list:
```shell
ZSH_THEME_RANDOM_IGNORED=(pygmalion tjkirch_mod)
```
### FAQ
If you have some more questions or issues, you might find a solution in our [FAQ](https://github.com/ohmyzsh/ohmyzsh/wiki/FAQ).
## Advanced Topics ## Advanced Topics
If you're the type that likes to get their hands dirty, these sections might resonate. If you're the type that likes to get their hands dirty, these sections might resonate.
@ -142,7 +146,7 @@ the installer accepts (these settings are also documented at the top of the inst
#### Custom Directory #### Custom Directory
The default location is `~/.oh-my-zsh` (hidden in your home directory) The default location is `~/.oh-my-zsh` (hidden in your home directory, you can access it with `cd ~/.oh-my-zsh`)
If you'd like to change the install directory with the `ZSH` environment variable, either by running If you'd like to change the install directory with the `ZSH` environment variable, either by running
`export ZSH=/your/path` before installing, or by setting it before the end of the install pipeline `export ZSH=/your/path` before installing, or by setting it before the end of the install pipeline
@ -159,14 +163,14 @@ flag `--unattended` to the `install.sh` script. This will have the effect of not
the default shell, and also won't run `zsh` when the installation has finished. the default shell, and also won't run `zsh` when the installation has finished.
```shell ```shell
sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)" "" --unattended sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" "" --unattended
``` ```
#### Installing from a forked repository #### Installing from a forked repository
The install script also accepts these variables to allow installation of a different repository: The install script also accepts these variables to allow installation of a different repository:
- `REPO` (default: `robbyrussell/oh-my-zsh`): this takes the form of `owner/repository`. If you set - `REPO` (default: `ohmyzsh/ohmyzsh`): this takes the form of `owner/repository`. If you set
this variable, the installer will look for a repository at `https://github.com/{owner}/{repository}`. this variable, the installer will look for a repository at `https://github.com/{owner}/{repository}`.
- `REMOTE` (default: `https://github.com/${REPO}.git`): this is the full URL of the git repository - `REMOTE` (default: `https://github.com/${REPO}.git`): this is the full URL of the git repository
@ -187,13 +191,13 @@ REPO=apjanke/oh-my-zsh BRANCH=edge sh install.sh
#### Manual Installation #### Manual Installation
##### 1. Clone the repository: ##### 1. Clone the repository
```shell ```shell
git clone https://github.com/robbyrussell/oh-my-zsh.git ~/.oh-my-zsh git clone https://github.com/ohmyzsh/ohmyzsh.git ~/.oh-my-zsh
``` ```
##### 2. *Optionally*, backup your existing `~/.zshrc` file: ##### 2. *Optionally*, backup your existing `~/.zshrc` file
```shell ```shell
cp ~/.zshrc ~/.zshrc.orig cp ~/.zshrc ~/.zshrc.orig
@ -223,9 +227,9 @@ Once you open up a new terminal window, it should load zsh with Oh My Zsh's conf
If you have any hiccups installing, here are a few common fixes. If you have any hiccups installing, here are a few common fixes.
* You _might_ need to modify your `PATH` in `~/.zshrc` if you're not able to find some commands after - You _might_ need to modify your `PATH` in `~/.zshrc` if you're not able to find some commands after
switching to `oh-my-zsh`. switching to `oh-my-zsh`.
* If you installed manually or changed the install location, check the `ZSH` environment variable in - If you installed manually or changed the install location, check the `ZSH` environment variable in
`~/.zshrc`. `~/.zshrc`.
### Custom Plugins and Themes ### Custom Plugins and Themes
@ -255,7 +259,7 @@ DISABLE_AUTO_UPDATE=true
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: 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 ```shell
upgrade_oh_my_zsh omz update
``` ```
Magic! 🎉 Magic! 🎉
@ -272,13 +276,13 @@ Before you participate in our delightful community, please read the [code of con
I'm far from being a [Zsh](https://www.zsh.org/) expert and suspect there are many ways to improve if you have ideas on how to make the configuration easier to maintain (and faster), don't hesitate to fork and send pull requests! I'm far from being a [Zsh](https://www.zsh.org/) expert and suspect there are many ways to improve 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. So take a look through [the open issues](https://github.com/robbyrussell/oh-my-zsh/issues) and help where you can. We also need people to test out pull-requests. So take a look through [the open issues](https://github.com/ohmyzsh/ohmyzsh/issues) and help where you can.
See [Contributing](CONTRIBUTING.md) for more details. See [Contributing](CONTRIBUTING.md) for more details.
### Do NOT send us themes ### Do NOT send us themes
We have (more than) enough themes for the time being. Please add your theme to the [external themes](https://github.com/robbyrussell/oh-my-zsh/wiki/External-themes) wiki page. We have (more than) enough themes for the time being. Please add your theme to the [external themes](https://github.com/ohmyzsh/ohmyzsh/wiki/External-themes) wiki page.
## Contributors ## Contributors
@ -288,10 +292,12 @@ Thank you so much!
## Follow Us ## Follow Us
We're on the social media. We're on social media:
* [@ohmyzsh](https://twitter.com/ohmyzsh) on Twitter. You should follow it. - [@ohmyzsh](https://twitter.com/ohmyzsh) on Twitter. You should follow it.
* [Oh My Zsh](https://www.facebook.com/Oh-My-Zsh-296616263819290/) on Facebook. - [Facebook](https://www.facebook.com/Oh-My-Zsh-296616263819290/) poke us.
- [Instagram](https://www.instagram.com/_ohmyzsh/) tag us in your post showing Oh My Zsh!
- [Discord](https://discord.gg/ohmyzsh) to chat with us!
## Merchandise ## Merchandise

View File

@ -0,0 +1,5 @@
# The next line updates PATH for Yandex Cloud CLI.
if [ -f '$HOME/yandex-cloud/path.bash.inc' ]; then source '$HOME/yandex-cloud/path.bash.inc'; fi
# The next line enables shell command completion for yc.
if [ -f '$HOME/yandex-cloud/completion.zsh.inc' ]; then source '$HOME/yandex-cloud/completion.zsh.inc'; fi

426
zsh/lib/cli.zsh Normal file
View File

@ -0,0 +1,426 @@
#!/usr/bin/env zsh
function omz {
[[ $# -gt 0 ]] || {
_omz::help
return 1
}
local command="$1"
shift
# Subcommand functions start with _ so that they don't
# appear as completion entries when looking for `omz`
(( $+functions[_omz::$command] )) || {
_omz::help
return 1
}
_omz::$command "$@"
}
function _omz {
local -a cmds subcmds
cmds=(
'changelog:Print the changelog'
'help:Usage information'
'plugin:Manage plugins'
'pr:Manage Oh My Zsh Pull Requests'
'theme:Manage themes'
'update:Update Oh My Zsh'
)
if (( CURRENT == 2 )); then
_describe 'command' cmds
elif (( CURRENT == 3 )); then
case "$words[2]" in
changelog) local -a refs
refs=("${(@f)$(command git for-each-ref --format="%(refname:short):%(subject)" refs/heads refs/tags)}")
_describe 'command' refs ;;
plugin) subcmds=('info:Get plugin information' 'list:List plugins')
_describe 'command' subcmds ;;
pr) subcmds=('test:Test a Pull Request' 'clean:Delete all Pull Request branches')
_describe 'command' subcmds ;;
theme) subcmds=('use:Load a theme' 'list:List themes')
_describe 'command' subcmds ;;
esac
elif (( CURRENT == 4 )); then
case "$words[2]::$words[3]" in
plugin::info) compadd "$ZSH"/plugins/*/README.md(.N:h:t) \
"$ZSH_CUSTOM"/plugins/*/README.md(.N:h:t) ;;
theme::use) compadd "$ZSH"/themes/*.zsh-theme(.N:t:r) \
"$ZSH_CUSTOM"/**/*.zsh-theme(.N:r:gs:"$ZSH_CUSTOM"/themes/:::gs:"$ZSH_CUSTOM"/:::) ;;
esac
fi
return 0
}
compdef _omz omz
## Utility functions
function _omz::confirm {
# If question supplied, ask it before reading the answer
# NOTE: uses the logname of the caller function
if [[ -n "$1" ]]; then
_omz::log prompt "$1" "${${functrace[1]#_}%:*}"
fi
# Read one character
read -r -k 1
# If no newline entered, add a newline
if [[ "$REPLY" != $'\n' ]]; then
echo
fi
}
function _omz::log {
# if promptsubst is set, a message with `` or $()
# will be run even if quoted due to `print -P`
setopt localoptions nopromptsubst
# $1 = info|warn|error|debug
# $2 = text
# $3 = (optional) name of the logger
local logtype=$1
local logname=${3:-${${functrace[1]#_}%:*}}
# Don't print anything if debug is not active
if [[ $logtype = debug && -z $_OMZ_DEBUG ]]; then
return
fi
# Choose coloring based on log type
case "$logtype" in
prompt) print -Pn "%S%F{blue}$logname%f%s: $2" ;;
debug) print -P "%F{white}$logname%f: $2" ;;
info) print -P "%F{green}$logname%f: $2" ;;
warn) print -P "%S%F{yellow}$logname%f%s: $2" ;;
error) print -P "%S%F{red}$logname%f%s: $2" ;;
esac >&2
}
## User-facing commands
function _omz::help {
cat <<EOF
Usage: omz <command> [options]
Available commands:
help Print this help message
changelog Print the changelog
plugin <command> Manage plugins
pr <command> Manage Oh My Zsh Pull Requests
theme <command> Manage themes
update Update Oh My Zsh
EOF
}
function _omz::changelog {
local version=${1:-HEAD} format=${3:-"--text"}
if ! command git -C "$ZSH" show-ref --verify refs/heads/$version &>/dev/null && \
! command git -C "$ZSH" show-ref --verify refs/tags/$version &>/dev/null && \
! command git -C "$ZSH" rev-parse --verify "${version}^{commit}" &>/dev/null; then
cat <<EOF
Usage: omz changelog [version]
NOTE: <version> must be a valid branch, tag or commit.
EOF
return 1
fi
"$ZSH/tools/changelog.sh" "$version" "${2:-}" "$format"
}
function _omz::plugin {
(( $# > 0 && $+functions[_omz::plugin::$1] )) || {
cat <<EOF
Usage: omz plugin <command> [options]
Available commands:
info <plugin> Get information of a plugin
list List all available Oh My Zsh plugins
EOF
return 1
}
local command="$1"
shift
_omz::plugin::$command "$@"
}
function _omz::plugin::info {
if [[ -z "$1" ]]; then
echo >&2 "Usage: omz plugin info <plugin>"
return 1
fi
local readme
for readme in "$ZSH_CUSTOM/plugins/$1/README.md" "$ZSH/plugins/$1/README.md"; do
if [[ -f "$readme" ]]; then
(( ${+commands[less]} )) && less "$readme" || cat "$readme"
return 0
fi
done
if [[ -d "$ZSH_CUSTOM/plugins/$1" || -d "$ZSH/plugins/$1" ]]; then
_omz::log error "the '$1' plugin doesn't have a README file"
else
_omz::log error "'$1' plugin not found"
fi
return 1
}
function _omz::plugin::list {
local -a custom_plugins builtin_plugins
custom_plugins=("$ZSH_CUSTOM"/plugins/*(-/N:t))
builtin_plugins=("$ZSH"/plugins/*(-/N:t))
# If the command is being piped, print all found line by line
if [[ ! -t 1 ]]; then
print -l ${(q-)custom_plugins} ${(q-)builtin_plugins}
return
fi
if (( ${#custom_plugins} )); then
print -P "%U%BCustom plugins%b%u:"
print -l ${(q-)custom_plugins} | column
fi
if (( ${#builtin_plugins} )); then
(( ${#custom_plugins} )) && echo # add a line of separation
print -P "%U%BBuilt-in plugins%b%u:"
print -l ${(q-)builtin_plugins} | column
fi
}
function _omz::pr {
(( $# > 0 && $+functions[_omz::pr::$1] )) || {
cat <<EOF
Usage: omz pr <command> [options]
Available commands:
clean Delete all PR branches (ohmyzsh/pull-*)
test <PR_number_or_URL> Fetch PR #NUMBER and rebase against master
EOF
return 1
}
local command="$1"
shift
_omz::pr::$command "$@"
}
function _omz::pr::clean {
(
set -e
builtin cd -q "$ZSH"
# Check if there are PR branches
local fmt branches
fmt="%(color:bold blue)%(align:18,right)%(refname:short)%(end)%(color:reset) %(color:dim bold red)%(objectname:short)%(color:reset) %(color:yellow)%(contents:subject)"
branches="$(command git for-each-ref --sort=-committerdate --color --format="$fmt" "refs/heads/ohmyzsh/pull-*")"
# Exit if there are no PR branches
if [[ -z "$branches" ]]; then
_omz::log info "there are no Pull Request branches to remove."
return
fi
# Print found PR branches
echo "$branches\n"
# Confirm before removing the branches
_omz::confirm "do you want remove these Pull Request branches? [Y/n] "
# Only proceed if the answer is a valid yes option
[[ "$REPLY" != [yY$'\n'] ]] && return
_omz::log info "removing all Oh My Zsh Pull Request branches..."
command git branch --list 'ohmyzsh/pull-*' | while read branch; do
command git branch -D "$branch"
done
)
}
function _omz::pr::test {
# Allow $1 to be a URL to the pull request
if [[ "$1" = https://* ]]; then
1="${1:t}"
fi
# Check the input
if ! [[ -n "$1" && "$1" =~ ^[[:digit:]]+$ ]]; then
echo >&2 "Usage: omz pr test <PR_NUMBER_or_URL>"
return 1
fi
# Save current git HEAD
local branch
branch=$(builtin cd -q "$ZSH"; git symbolic-ref --short HEAD) || {
_omz::log error "error when getting the current git branch. Aborting..."
return 1
}
# Fetch PR onto ohmyzsh/pull-<PR_NUMBER> branch and rebase against master
# If any of these operations fail, undo the changes made
(
set -e
builtin cd -q "$ZSH"
# Get the ohmyzsh git remote
command git remote -v | while read remote url _; do
case "$url" in
https://github.com/ohmyzsh/ohmyzsh(|.git)) found=1; break ;;
git@github.com:ohmyzsh/ohmyzsh(|.git)) found=1; break ;;
esac
done
(( $found )) || {
_omz::log error "could not found the ohmyzsh git remote. Aborting..."
return 1
}
# Fetch pull request head
_omz::log info "fetching PR #$1 to ohmyzsh/pull-$1..."
command git fetch -f "$remote" refs/pull/$1/head:ohmyzsh/pull-$1 || {
_omz::log error "error when trying to fetch PR #$1."
return 1
}
# Rebase pull request branch against the current master
_omz::log info "rebasing PR #$1..."
command git rebase master ohmyzsh/pull-$1 || {
command git rebase --abort &>/dev/null
_omz::log warn "could not rebase PR #$1 on top of master."
_omz::log warn "you might not see the latest stable changes."
_omz::log info "run \`zsh\` to test the changes."
return 1
}
_omz::log info "fetch of PR #${1} successful."
)
# If there was an error, abort running zsh to test the PR
[[ $? -eq 0 ]] || return 1
# Run zsh to test the changes
_omz::log info "running \`zsh\` to test the changes. Run \`exit\` to go back."
command zsh -l
# After testing, go back to the previous HEAD if the user wants
_omz::confirm "do you want to go back to the previous branch? [Y/n] "
# Only proceed if the answer is a valid yes option
[[ "$REPLY" != [yY$'\n'] ]] && return
(
set -e
builtin cd -q "$ZSH"
command git checkout "$branch" -- || {
_omz::log error "could not go back to the previous branch ('$branch')."
return 1
}
)
}
function _omz::theme {
(( $# > 0 && $+functions[_omz::theme::$1] )) || {
cat <<EOF
Usage: omz theme <command> [options]
Available commands:
list List all available Oh My Zsh themes
use <theme> Load an Oh My Zsh theme
EOF
return 1
}
local command="$1"
shift
_omz::theme::$command "$@"
}
function _omz::theme::list {
local -a custom_themes builtin_themes
custom_themes=("$ZSH_CUSTOM"/**/*.zsh-theme(-.N:r:gs:"$ZSH_CUSTOM"/themes/:::gs:"$ZSH_CUSTOM"/:::))
builtin_themes=("$ZSH"/themes/*.zsh-theme(-.N:t:r))
# If the command is being piped, print all found line by line
if [[ ! -t 1 ]]; then
print -l ${(q-)custom_themes} ${(q-)builtin_themes}
return
fi
if (( ${#custom_themes} )); then
print -P "%U%BCustom themes%b%u:"
print -l ${(q-)custom_themes} | column
fi
if (( ${#builtin_themes} )); then
(( ${#custom_themes} )) && echo # add a line of separation
print -P "%U%BBuilt-in themes%b%u:"
print -l ${(q-)builtin_themes} | column
fi
}
function _omz::theme::use {
if [[ -z "$1" ]]; then
echo >&2 "Usage: omz theme use <theme>"
return 1
fi
# Respect compatibility with old lookup order
if [[ -f "$ZSH_CUSTOM/$1.zsh-theme" ]]; then
source "$ZSH_CUSTOM/$1.zsh-theme"
elif [[ -f "$ZSH_CUSTOM/themes/$1.zsh-theme" ]]; then
source "$ZSH_CUSTOM/themes/$1.zsh-theme"
elif [[ -f "$ZSH/themes/$1.zsh-theme" ]]; then
source "$ZSH/themes/$1.zsh-theme"
else
_omz::log error "theme '$1' not found"
return 1
fi
}
function _omz::update {
local last_commit=$(cd "$ZSH"; git rev-parse HEAD)
# Run update script
if [[ "$1" != --unattended ]]; then
ZSH="$ZSH" zsh -f "$ZSH/tools/upgrade.sh" --interactive
else
ZSH="$ZSH" zsh -f "$ZSH/tools/upgrade.sh"
fi
# Update last updated file
zmodload zsh/datetime
echo "LAST_EPOCH=$(( EPOCHSECONDS / 60 / 60 / 24 ))" >! "${ZSH_CACHE_DIR}/.zsh-update"
# Remove update lock if it exists
command rm -rf "$ZSH/log/update.lock"
# Restart the zsh session if there were changes
if [[ "$1" != --unattended && "$(cd "$ZSH"; git rev-parse HEAD)" != "$last_commit" ]]; then
# Old zsh versions don't have ZSH_ARGZERO
local zsh="${ZSH_ARGZERO:-${functrace[-1]%:*}}"
# Check whether to run a login shell
[[ "$zsh" = -* || -o login ]] && exec -l "${zsh#-}" || exec "$zsh"
fi
}

View File

@ -3,10 +3,23 @@
# This file has support for doing system clipboard copy and paste operations # This file has support for doing system clipboard copy and paste operations
# from the command line in a generic cross-platform fashion. # from the command line in a generic cross-platform fashion.
# #
# On OS X and Windows, the main system clipboard or "pasteboard" is used. On other # This is uses essentially the same heuristic as neovim, with the additional
# Unix-like OSes, this considers the X Windows CLIPBOARD selection to be the # special support for Cygwin.
# "system clipboard", and the X Windows `xclip` command must be installed. # See: https://github.com/neovim/neovim/blob/e682d799fa3cf2e80a02d00c6ea874599d58f0e7/runtime/autoload/provider/clipboard.vim#L55-L121
#
# - pbcopy, pbpaste (macOS)
# - cygwin (Windows running Cygwin)
# - wl-copy, wl-paste (if $WAYLAND_DISPLAY is set)
# - xclip (if $DISPLAY is set)
# - xsel (if $DISPLAY is set)
# - lemonade (for SSH) https://github.com/pocke/lemonade
# - doitclient (for SSH) http://www.chiark.greenend.org.uk/~sgtatham/doit/
# - win32yank (Windows)
# - tmux (if $TMUX is set)
#
# Defines two functions, clipcopy and clippaste, based on the detected platform.
##
#
# clipcopy - Copy data to clipboard # clipcopy - Copy data to clipboard
# #
# Usage: # Usage:
@ -15,41 +28,8 @@
# #
# clipcopy <file> - copies a file's contents to clipboard # clipcopy <file> - copies a file's contents to clipboard
# #
function clipcopy() { ##
emulate -L zsh #
local file=$1
if [[ $OSTYPE == darwin* ]]; then
if [[ -z $file ]]; then
pbcopy
else
cat $file | pbcopy
fi
elif [[ $OSTYPE == cygwin* ]]; then
if [[ -z $file ]]; then
cat > /dev/clipboard
else
cat $file > /dev/clipboard
fi
else
if (( $+commands[xclip] )); then
if [[ -z $file ]]; then
xclip -in -selection clipboard
else
xclip -in -selection clipboard $file
fi
elif (( $+commands[xsel] )); then
if [[ -z $file ]]; then
xsel --clipboard --input
else
cat "$file" | xsel --clipboard --input
fi
else
print "clipcopy: Platform $OSTYPE not supported or xclip/xsel not installed" >&2
return 1
fi
fi
}
# clippaste - "Paste" data from clipboard to stdout # clippaste - "Paste" data from clipboard to stdout
# #
# Usage: # Usage:
@ -67,20 +47,61 @@ function clipcopy() {
# #
# # Paste to a file # # Paste to a file
# clippaste > file.txt # clippaste > file.txt
function clippaste() { #
function detect-clipboard() {
emulate -L zsh emulate -L zsh
if [[ $OSTYPE == darwin* ]]; then
pbpaste if [[ "${OSTYPE}" == darwin* ]] && (( ${+commands[pbcopy]} )) && (( ${+commands[pbpaste]} )); then
elif [[ $OSTYPE == cygwin* ]]; then function clipcopy() { pbcopy < "${1:-/dev/stdin}"; }
cat /dev/clipboard function clippaste() { pbpaste; }
elif [[ "${OSTYPE}" == (cygwin|msys)* ]]; then
function clipcopy() { cat "${1:-/dev/stdin}" > /dev/clipboard; }
function clippaste() { cat /dev/clipboard; }
elif [ -n "${WAYLAND_DISPLAY:-}" ] && (( ${+commands[wl-copy]} )) && (( ${+commands[wl-paste]} )); then
function clipcopy() { wl-copy < "${1:-/dev/stdin}"; }
function clippaste() { wl-paste; }
elif [ -n "${DISPLAY:-}" ] && (( ${+commands[xclip]} )); then
function clipcopy() { xclip -in -selection clipboard < "${1:-/dev/stdin}"; }
function clippaste() { xclip -out -selection clipboard; }
elif [ -n "${DISPLAY:-}" ] && (( ${+commands[xsel]} )); then
function clipcopy() { xsel --clipboard --input < "${1:-/dev/stdin}"; }
function clippaste() { xsel --clipboard --output; }
elif (( ${+commands[lemonade]} )); then
function clipcopy() { lemonade copy < "${1:-/dev/stdin}"; }
function clippaste() { lemonade paste; }
elif (( ${+commands[doitclient]} )); then
function clipcopy() { doitclient wclip < "${1:-/dev/stdin}"; }
function clippaste() { doitclient wclip -r; }
elif (( ${+commands[win32yank]} )); then
function clipcopy() { win32yank -i < "${1:-/dev/stdin}"; }
function clippaste() { win32yank -o; }
elif [[ $OSTYPE == linux-android* ]] && (( $+commands[termux-clipboard-set] )); then
function clipcopy() { termux-clipboard-set "${1:-/dev/stdin}"; }
function clippaste() { termux-clipboard-get; }
elif [ -n "${TMUX:-}" ] && (( ${+commands[tmux]} )); then
function clipcopy() { tmux load-buffer "${1:--}"; }
function clippaste() { tmux save-buffer -; }
elif [[ $(uname -r) = *icrosoft* ]]; then
function clipcopy() { clip.exe < "${1:-/dev/stdin}"; }
function clippaste() { powershell.exe -noprofile -command Get-Clipboard; }
else else
if (( $+commands[xclip] )); then function _retry_clipboard_detection_or_fail() {
xclip -out -selection clipboard local clipcmd="${1}"; shift
elif (( $+commands[xsel] )); then if detect-clipboard; then
xsel --clipboard --output "${clipcmd}" "$@"
else else
print "clipcopy: Platform $OSTYPE not supported or xclip/xsel not installed" >&2 print "${clipcmd}: Platform $OSTYPE not supported or xclip/xsel not installed" >&2
return 1 return 1
fi fi
}
function clipcopy() { _retry_clipboard_detection_or_fail clipcopy "$@"; }
function clippaste() { _retry_clipboard_detection_or_fail clippaste "$@"; }
return 1
fi fi
} }
# Detect at startup. A non-zero exit here indicates that the dummy clipboards were set,
# which is not really an error. If the user calls them, they will attempt to redetect
# (for example, perhaps the user has now installed xclip) and then either print an error
# or proceed successfully.
detect-clipboard || true

View File

@ -32,17 +32,17 @@ zstyle ':completion:*' list-colors ''
zstyle ':completion:*:*:kill:*:processes' list-colors '=(#b) #([0-9]#) ([0-9a-z-]#)*=01;34=0=01' zstyle ':completion:*:*:kill:*:processes' list-colors '=(#b) #([0-9]#) ([0-9a-z-]#)*=01;34=0=01'
if [[ "$OSTYPE" = solaris* ]]; then if [[ "$OSTYPE" = solaris* ]]; then
zstyle ':completion:*:*:*:*:processes' command "ps -u $USER -o pid,user,comm" zstyle ':completion:*:*:*:*:processes' command "ps -u $USERNAME -o pid,user,comm"
else else
zstyle ':completion:*:*:*:*:processes' command "ps -u $USER -o pid,user,comm -w -w" zstyle ':completion:*:*:*:*:processes' command "ps -u $USERNAME -o pid,user,comm -w -w"
fi fi
# disable named-directories autocompletion # disable named-directories autocompletion
zstyle ':completion:*:cd:*' tag-order local-directories directory-stack path-directories zstyle ':completion:*:cd:*' tag-order local-directories directory-stack path-directories
# Use caching so that commands like apt and dpkg complete are useable # Use caching so that commands like apt and dpkg complete are useable
zstyle ':completion::complete:*' use-cache 1 zstyle ':completion:*' use-cache yes
zstyle ':completion::complete:*' cache-path $ZSH_CACHE_DIR zstyle ':completion:*' cache-path $ZSH_CACHE_DIR
# Don't complete uninteresting users # Don't complete uninteresting users
zstyle ':completion:*:*:*:users' ignored-patterns \ zstyle ':completion:*:*:*:users' ignored-patterns \
@ -60,14 +60,16 @@ zstyle '*' single-ignored show
if [[ $COMPLETION_WAITING_DOTS = true ]]; then if [[ $COMPLETION_WAITING_DOTS = true ]]; then
expand-or-complete-with-dots() { expand-or-complete-with-dots() {
# toggle line-wrapping off and back on again print -Pn "%F{red}…%f"
[[ -n "$terminfo[rmam]" && -n "$terminfo[smam]" ]] && echoti rmam
print -Pn "%{%F{red}......%f%}"
[[ -n "$terminfo[rmam]" && -n "$terminfo[smam]" ]] && echoti smam
zle expand-or-complete zle expand-or-complete
zle redisplay zle redisplay
} }
zle -N expand-or-complete-with-dots zle -N expand-or-complete-with-dots
bindkey "^I" expand-or-complete-with-dots # Set the function as the default tab completion widget
bindkey -M emacs "^I" expand-or-complete-with-dots
bindkey -M viins "^I" expand-or-complete-with-dots
bindkey -M vicmd "^I" expand-or-complete-with-dots
fi fi
# automatically load bash completion functions
autoload -U +X bashcompinit && bashcompinit

View File

@ -112,7 +112,7 @@ function _omz_diag_dump_one_big_text() {
command uname -a command uname -a
builtin echo OSTYPE=$OSTYPE builtin echo OSTYPE=$OSTYPE
builtin echo ZSH_VERSION=$ZSH_VERSION builtin echo ZSH_VERSION=$ZSH_VERSION
builtin echo User: $USER builtin echo User: $USERNAME
builtin echo umask: $(umask) builtin echo umask: $(umask)
builtin echo builtin echo
_omz_diag_dump_os_specific_version _omz_diag_dump_os_specific_version
@ -192,19 +192,19 @@ function _omz_diag_dump_one_big_text() {
command ls -ld ~/.oh* command ls -ld ~/.oh*
builtin echo builtin echo
builtin echo oh-my-zsh git state: builtin echo oh-my-zsh git state:
(cd $ZSH && builtin echo "HEAD: $(git rev-parse HEAD)" && git remote -v && git status | command grep "[^[:space:]]") (builtin cd $ZSH && builtin echo "HEAD: $(git rev-parse HEAD)" && git remote -v && git status | command grep "[^[:space:]]")
if [[ $verbose -ge 1 ]]; then if [[ $verbose -ge 1 ]]; then
(cd $ZSH && git reflog --date=default | command grep pull) (builtin cd $ZSH && git reflog --date=default | command grep pull)
fi fi
builtin echo builtin echo
if [[ -e $ZSH_CUSTOM ]]; then if [[ -e $ZSH_CUSTOM ]]; then
local custom_dir=$ZSH_CUSTOM local custom_dir=$ZSH_CUSTOM
if [[ -h $custom_dir ]]; then if [[ -h $custom_dir ]]; then
custom_dir=$(cd $custom_dir && pwd -P) custom_dir=$(builtin cd $custom_dir && pwd -P)
fi fi
builtin echo "oh-my-zsh custom dir:" builtin echo "oh-my-zsh custom dir:"
builtin echo " $ZSH_CUSTOM ($custom_dir)" builtin echo " $ZSH_CUSTOM ($custom_dir)"
(cd ${custom_dir:h} && command find ${custom_dir:t} -name .git -prune -o -print) (builtin cd ${custom_dir:h} && command find ${custom_dir:t} -name .git -prune -o -print)
builtin echo builtin echo
fi fi

View File

@ -1,13 +1,16 @@
function zsh_stats() { function zsh_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 fc -l 1 \
| awk '{ CMD[$2]++; count++; } END { for (a in CMD) print CMD[a] " " CMD[a]*100/count "% " a }' \
| grep -v "./" | sort -nr | head -20 | column -c3 -s " " -t | nl
} }
function uninstall_oh_my_zsh() { function uninstall_oh_my_zsh() {
env ZSH=$ZSH sh $ZSH/tools/uninstall.sh env ZSH="$ZSH" sh "$ZSH/tools/uninstall.sh"
} }
function upgrade_oh_my_zsh() { function upgrade_oh_my_zsh() {
env ZSH=$ZSH sh $ZSH/tools/upgrade.sh echo >&2 "${fg[yellow]}Note: \`$0\` is deprecated. Use \`omz update\` instead.$reset_color"
omz update
} }
function take() { function take() {
@ -21,7 +24,7 @@ function open_command() {
case "$OSTYPE" in case "$OSTYPE" in
darwin*) open_cmd='open' ;; darwin*) open_cmd='open' ;;
cygwin*) open_cmd='cygstart' ;; cygwin*) open_cmd='cygstart' ;;
linux*) ! [[ $(uname -a) =~ "Microsoft" ]] && open_cmd='xdg-open' || { linux*) [[ "$(uname -r)" != *icrosoft* ]] && open_cmd='nohup xdg-open' || {
open_cmd='cmd.exe /c start ""' open_cmd='cmd.exe /c start ""'
[[ -e "$1" ]] && { 1="$(wslpath -w "${1:a}")" || return 1 } [[ -e "$1" ]] && { 1="$(wslpath -w "${1:a}")" || return 1 }
} ;; } ;;
@ -31,12 +34,7 @@ function open_command() {
;; ;;
esac esac
# don't use nohup on OSX ${=open_cmd} "$@" &>/dev/null
if [[ "$OSTYPE" == darwin* ]]; then
${=open_cmd} "$@" &>/dev/null
else
nohup ${=open_cmd} "$@" &>/dev/null
fi
} }
# #
@ -93,7 +91,7 @@ function default() {
# 0 if the env variable exists, 3 if it was set # 0 if the env variable exists, 3 if it was set
# #
function env_default() { function env_default() {
(( ${${(@f):-$(typeset +xg)}[(I)$1]} )) && return 0 [[ ${parameters[$1]} = *-export* ]] && return 0
export "$1=$2" && return 3 export "$1=$2" && return 3
} }
@ -127,6 +125,7 @@ zmodload zsh/langinfo
# -P causes spaces to be encoded as '%20' instead of '+' # -P causes spaces to be encoded as '%20' instead of '+'
function omz_urlencode() { function omz_urlencode() {
emulate -L zsh emulate -L zsh
local -a opts
zparseopts -D -E -a opts r m P zparseopts -D -E -a opts r m P
local in_str=$1 local in_str=$1

View File

@ -1,23 +1,57 @@
# Outputs current branch info in prompt format # The git prompt's git commands are read-only and should not interfere with
# other processes. This environment variable is equivalent to running with `git
# --no-optional-locks`, but falls back gracefully for older versions of git.
# See git(1) for and git-status(1) for a description of that flag.
#
# We wrap in a local function instead of exporting the variable directly in
# order to avoid interfering with manually-run git commands by the user.
function __git_prompt_git() {
GIT_OPTIONAL_LOCKS=0 command git "$@"
}
function git_prompt_info() { function git_prompt_info() {
local ref # If we are on a folder not tracked by git, get out.
if [[ "$(command git config --get oh-my-zsh.hide-status 2>/dev/null)" != "1" ]]; then # Otherwise, check for hide-info at global and local repository level
ref=$(command git symbolic-ref HEAD 2> /dev/null) || \ if ! __git_prompt_git rev-parse --git-dir &> /dev/null \
ref=$(command git rev-parse --short HEAD 2> /dev/null) || return 0 || [[ "$(__git_prompt_git config --get oh-my-zsh.hide-info 2>/dev/null)" == 1 ]]; then
echo "$ZSH_THEME_GIT_PROMPT_PREFIX${ref#refs/heads/}$(parse_git_dirty)$ZSH_THEME_GIT_PROMPT_SUFFIX" return 0
fi fi
local ref
ref=$(__git_prompt_git symbolic-ref --short HEAD 2> /dev/null) \
|| ref=$(__git_prompt_git rev-parse --short HEAD 2> /dev/null) \
|| return 0
# Use global ZSH_THEME_GIT_SHOW_UPSTREAM=1 for including upstream remote info
local upstream
if (( ${+ZSH_THEME_GIT_SHOW_UPSTREAM} )); then
upstream=$(__git_prompt_git rev-parse --abbrev-ref --symbolic-full-name "@{upstream}" 2>/dev/null) \
&& upstream=" -> ${upstream}"
fi
echo "${ZSH_THEME_GIT_PROMPT_PREFIX}${ref}${upstream}$(parse_git_dirty)${ZSH_THEME_GIT_PROMPT_SUFFIX}"
} }
# Checks if working tree is dirty # Checks if working tree is dirty
function parse_git_dirty() { function parse_git_dirty() {
local STATUS local STATUS
local -a FLAGS local -a FLAGS
FLAGS=('--porcelain' '--ignore-submodules=dirty') FLAGS=('--porcelain')
if [[ "$(command git config --get oh-my-zsh.hide-dirty)" != "1" ]]; then if [[ "$(__git_prompt_git config --get oh-my-zsh.hide-dirty)" != "1" ]]; then
if [[ "$DISABLE_UNTRACKED_FILES_DIRTY" == "true" ]]; then if [[ "${DISABLE_UNTRACKED_FILES_DIRTY:-}" == "true" ]]; then
FLAGS+='--untracked-files=no' FLAGS+='--untracked-files=no'
fi fi
STATUS=$(command git status ${FLAGS} 2> /dev/null | tail -n1) case "${GIT_STATUS_IGNORE_SUBMODULES:-}" in
git)
# let git decide (this respects per-repo config in .gitmodules)
;;
*)
# if unset: ignore dirty submodules
# other values are passed to --ignore-submodules
FLAGS+="--ignore-submodules=${GIT_STATUS_IGNORE_SUBMODULES:-dirty}"
;;
esac
STATUS=$(__git_prompt_git status ${FLAGS} 2> /dev/null | tail -1)
fi fi
if [[ -n $STATUS ]]; then if [[ -n $STATUS ]]; then
echo "$ZSH_THEME_GIT_PROMPT_DIRTY" echo "$ZSH_THEME_GIT_PROMPT_DIRTY"
@ -29,10 +63,10 @@ function parse_git_dirty() {
# Gets the difference between the local and remote branches # Gets the difference between the local and remote branches
function git_remote_status() { function git_remote_status() {
local remote ahead behind git_remote_status git_remote_status_detailed local remote ahead behind git_remote_status git_remote_status_detailed
remote=${$(command git rev-parse --verify ${hook_com[branch]}@{upstream} --symbolic-full-name 2>/dev/null)/refs\/remotes\/} remote=${$(__git_prompt_git rev-parse --verify ${hook_com[branch]}@{upstream} --symbolic-full-name 2>/dev/null)/refs\/remotes\/}
if [[ -n ${remote} ]]; then if [[ -n ${remote} ]]; then
ahead=$(command git rev-list ${hook_com[branch]}@{upstream}..HEAD 2>/dev/null | wc -l) ahead=$(__git_prompt_git rev-list ${hook_com[branch]}@{upstream}..HEAD 2>/dev/null | wc -l)
behind=$(command git rev-list HEAD..${hook_com[branch]}@{upstream} 2>/dev/null | wc -l) behind=$(__git_prompt_git rev-list HEAD..${hook_com[branch]}@{upstream} 2>/dev/null | wc -l)
if [[ $ahead -eq 0 ]] && [[ $behind -eq 0 ]]; then if [[ $ahead -eq 0 ]] && [[ $behind -eq 0 ]]; then
git_remote_status="$ZSH_THEME_GIT_PROMPT_EQUAL_REMOTE" git_remote_status="$ZSH_THEME_GIT_PROMPT_EQUAL_REMOTE"
@ -61,11 +95,11 @@ function git_remote_status() {
# it's not a symbolic ref, but in a Git repo. # it's not a symbolic ref, but in a Git repo.
function git_current_branch() { function git_current_branch() {
local ref local ref
ref=$(command git symbolic-ref --quiet HEAD 2> /dev/null) ref=$(__git_prompt_git symbolic-ref --quiet HEAD 2> /dev/null)
local ret=$? local ret=$?
if [[ $ret != 0 ]]; then if [[ $ret != 0 ]]; then
[[ $ret == 128 ]] && return # no git repo. [[ $ret == 128 ]] && return # no git repo.
ref=$(command git rev-parse --short HEAD 2> /dev/null) || return ref=$(__git_prompt_git rev-parse --short HEAD 2> /dev/null) || return
fi fi
echo ${ref#refs/heads/} echo ${ref#refs/heads/}
} }
@ -73,8 +107,8 @@ function git_current_branch() {
# Gets the number of commits ahead from remote # Gets the number of commits ahead from remote
function git_commits_ahead() { function git_commits_ahead() {
if command git rev-parse --git-dir &>/dev/null; then if __git_prompt_git rev-parse --git-dir &>/dev/null; then
local commits="$(git rev-list --count @{upstream}..HEAD 2>/dev/null)" local commits="$(__git_prompt_git rev-list --count @{upstream}..HEAD 2>/dev/null)"
if [[ -n "$commits" && "$commits" != 0 ]]; then if [[ -n "$commits" && "$commits" != 0 ]]; then
echo "$ZSH_THEME_GIT_COMMITS_AHEAD_PREFIX$commits$ZSH_THEME_GIT_COMMITS_AHEAD_SUFFIX" echo "$ZSH_THEME_GIT_COMMITS_AHEAD_PREFIX$commits$ZSH_THEME_GIT_COMMITS_AHEAD_SUFFIX"
fi fi
@ -83,8 +117,8 @@ function git_commits_ahead() {
# Gets the number of commits behind remote # Gets the number of commits behind remote
function git_commits_behind() { function git_commits_behind() {
if command git rev-parse --git-dir &>/dev/null; then if __git_prompt_git rev-parse --git-dir &>/dev/null; then
local commits="$(git rev-list --count HEAD..@{upstream} 2>/dev/null)" local commits="$(__git_prompt_git rev-list --count HEAD..@{upstream} 2>/dev/null)"
if [[ -n "$commits" && "$commits" != 0 ]]; then if [[ -n "$commits" && "$commits" != 0 ]]; then
echo "$ZSH_THEME_GIT_COMMITS_BEHIND_PREFIX$commits$ZSH_THEME_GIT_COMMITS_BEHIND_SUFFIX" echo "$ZSH_THEME_GIT_COMMITS_BEHIND_PREFIX$commits$ZSH_THEME_GIT_COMMITS_BEHIND_SUFFIX"
fi fi
@ -93,21 +127,21 @@ function git_commits_behind() {
# Outputs if current branch is ahead of remote # Outputs if current branch is ahead of remote
function git_prompt_ahead() { function git_prompt_ahead() {
if [[ -n "$(command git rev-list origin/$(git_current_branch)..HEAD 2> /dev/null)" ]]; then if [[ -n "$(__git_prompt_git rev-list origin/$(git_current_branch)..HEAD 2> /dev/null)" ]]; then
echo "$ZSH_THEME_GIT_PROMPT_AHEAD" echo "$ZSH_THEME_GIT_PROMPT_AHEAD"
fi fi
} }
# Outputs if current branch is behind remote # Outputs if current branch is behind remote
function git_prompt_behind() { function git_prompt_behind() {
if [[ -n "$(command git rev-list HEAD..origin/$(git_current_branch) 2> /dev/null)" ]]; then if [[ -n "$(__git_prompt_git rev-list HEAD..origin/$(git_current_branch) 2> /dev/null)" ]]; then
echo "$ZSH_THEME_GIT_PROMPT_BEHIND" echo "$ZSH_THEME_GIT_PROMPT_BEHIND"
fi fi
} }
# Outputs if current branch exists on remote or not # Outputs if current branch exists on remote or not
function git_prompt_remote() { function git_prompt_remote() {
if [[ -n "$(command git show-ref origin/$(git_current_branch) 2> /dev/null)" ]]; then if [[ -n "$(__git_prompt_git show-ref origin/$(git_current_branch) 2> /dev/null)" ]]; then
echo "$ZSH_THEME_GIT_PROMPT_REMOTE_EXISTS" echo "$ZSH_THEME_GIT_PROMPT_REMOTE_EXISTS"
else else
echo "$ZSH_THEME_GIT_PROMPT_REMOTE_MISSING" echo "$ZSH_THEME_GIT_PROMPT_REMOTE_MISSING"
@ -117,75 +151,130 @@ function git_prompt_remote() {
# Formats prompt string for current git commit short SHA # Formats prompt string for current git commit short SHA
function git_prompt_short_sha() { function git_prompt_short_sha() {
local SHA local SHA
SHA=$(command git rev-parse --short HEAD 2> /dev/null) && echo "$ZSH_THEME_GIT_PROMPT_SHA_BEFORE$SHA$ZSH_THEME_GIT_PROMPT_SHA_AFTER" SHA=$(__git_prompt_git rev-parse --short HEAD 2> /dev/null) && echo "$ZSH_THEME_GIT_PROMPT_SHA_BEFORE$SHA$ZSH_THEME_GIT_PROMPT_SHA_AFTER"
} }
# Formats prompt string for current git commit long SHA # Formats prompt string for current git commit long SHA
function git_prompt_long_sha() { function git_prompt_long_sha() {
local SHA local SHA
SHA=$(command git rev-parse HEAD 2> /dev/null) && echo "$ZSH_THEME_GIT_PROMPT_SHA_BEFORE$SHA$ZSH_THEME_GIT_PROMPT_SHA_AFTER" SHA=$(__git_prompt_git rev-parse HEAD 2> /dev/null) && echo "$ZSH_THEME_GIT_PROMPT_SHA_BEFORE$SHA$ZSH_THEME_GIT_PROMPT_SHA_AFTER"
} }
# Get the status of the working tree
function git_prompt_status() { function git_prompt_status() {
local INDEX STATUS [[ "$(__git_prompt_git config --get oh-my-zsh.hide-status 2>/dev/null)" = 1 ]] && return
INDEX=$(command git status --porcelain -b 2> /dev/null)
STATUS="" # Maps a git status prefix to an internal constant
if $(echo "$INDEX" | command grep -E '^\?\? ' &> /dev/null); then # This cannot use the prompt constants, as they may be empty
STATUS="$ZSH_THEME_GIT_PROMPT_UNTRACKED$STATUS" local -A prefix_constant_map
prefix_constant_map=(
'\?\? ' 'UNTRACKED'
'A ' 'ADDED'
'M ' 'ADDED'
'MM ' 'MODIFIED'
' M ' 'MODIFIED'
'AM ' 'MODIFIED'
' T ' 'MODIFIED'
'R ' 'RENAMED'
' D ' 'DELETED'
'D ' 'DELETED'
'UU ' 'UNMERGED'
'ahead' 'AHEAD'
'behind' 'BEHIND'
'diverged' 'DIVERGED'
'stashed' 'STASHED'
)
# Maps the internal constant to the prompt theme
local -A constant_prompt_map
constant_prompt_map=(
'UNTRACKED' "$ZSH_THEME_GIT_PROMPT_UNTRACKED"
'ADDED' "$ZSH_THEME_GIT_PROMPT_ADDED"
'MODIFIED' "$ZSH_THEME_GIT_PROMPT_MODIFIED"
'RENAMED' "$ZSH_THEME_GIT_PROMPT_RENAMED"
'DELETED' "$ZSH_THEME_GIT_PROMPT_DELETED"
'UNMERGED' "$ZSH_THEME_GIT_PROMPT_UNMERGED"
'AHEAD' "$ZSH_THEME_GIT_PROMPT_AHEAD"
'BEHIND' "$ZSH_THEME_GIT_PROMPT_BEHIND"
'DIVERGED' "$ZSH_THEME_GIT_PROMPT_DIVERGED"
'STASHED' "$ZSH_THEME_GIT_PROMPT_STASHED"
)
# The order that the prompt displays should be added to the prompt
local status_constants
status_constants=(
UNTRACKED ADDED MODIFIED RENAMED DELETED
STASHED UNMERGED AHEAD BEHIND DIVERGED
)
local status_text="$(__git_prompt_git status --porcelain -b 2> /dev/null)"
# Don't continue on a catastrophic failure
if [[ $? -eq 128 ]]; then
return 1
fi fi
if $(echo "$INDEX" | grep '^A ' &> /dev/null); then
STATUS="$ZSH_THEME_GIT_PROMPT_ADDED$STATUS" # A lookup table of each git status encountered
elif $(echo "$INDEX" | grep '^M ' &> /dev/null); then local -A statuses_seen
STATUS="$ZSH_THEME_GIT_PROMPT_ADDED$STATUS"
elif $(echo "$INDEX" | grep '^MM ' &> /dev/null); then if __git_prompt_git rev-parse --verify refs/stash &>/dev/null; then
STATUS="$ZSH_THEME_GIT_PROMPT_ADDED$STATUS" statuses_seen[STASHED]=1
fi fi
if $(echo "$INDEX" | grep '^ M ' &> /dev/null); then
STATUS="$ZSH_THEME_GIT_PROMPT_MODIFIED$STATUS" local status_lines
elif $(echo "$INDEX" | grep '^AM ' &> /dev/null); then status_lines=("${(@f)${status_text}}")
STATUS="$ZSH_THEME_GIT_PROMPT_MODIFIED$STATUS"
elif $(echo "$INDEX" | grep '^MM ' &> /dev/null); then # If the tracking line exists, get and parse it
STATUS="$ZSH_THEME_GIT_PROMPT_MODIFIED$STATUS" if [[ "$status_lines[1]" =~ "^## [^ ]+ \[(.*)\]" ]]; then
elif $(echo "$INDEX" | grep '^ T ' &> /dev/null); then local branch_statuses
STATUS="$ZSH_THEME_GIT_PROMPT_MODIFIED$STATUS" branch_statuses=("${(@s/,/)match}")
for branch_status in $branch_statuses; do
if [[ ! $branch_status =~ "(behind|diverged|ahead) ([0-9]+)?" ]]; then
continue
fi
local last_parsed_status=$prefix_constant_map[$match[1]]
statuses_seen[$last_parsed_status]=$match[2]
done
fi fi
if $(echo "$INDEX" | grep '^R ' &> /dev/null); then
STATUS="$ZSH_THEME_GIT_PROMPT_RENAMED$STATUS" # For each status prefix, do a regex comparison
fi for status_prefix in ${(k)prefix_constant_map}; do
if $(echo "$INDEX" | grep '^ D ' &> /dev/null); then local status_constant="${prefix_constant_map[$status_prefix]}"
STATUS="$ZSH_THEME_GIT_PROMPT_DELETED$STATUS" local status_regex=$'(^|\n)'"$status_prefix"
elif $(echo "$INDEX" | grep '^D ' &> /dev/null); then
STATUS="$ZSH_THEME_GIT_PROMPT_DELETED$STATUS" if [[ "$status_text" =~ $status_regex ]]; then
elif $(echo "$INDEX" | grep '^AD ' &> /dev/null); then statuses_seen[$status_constant]=1
STATUS="$ZSH_THEME_GIT_PROMPT_DELETED$STATUS" fi
fi done
if $(command git rev-parse --verify refs/stash >/dev/null 2>&1); then
STATUS="$ZSH_THEME_GIT_PROMPT_STASHED$STATUS" # Display the seen statuses in the order specified
fi local status_prompt
if $(echo "$INDEX" | grep '^UU ' &> /dev/null); then for status_constant in $status_constants; do
STATUS="$ZSH_THEME_GIT_PROMPT_UNMERGED$STATUS" if (( ${+statuses_seen[$status_constant]} )); then
fi local next_display=$constant_prompt_map[$status_constant]
if $(echo "$INDEX" | grep '^## [^ ]\+ .*ahead' &> /dev/null); then status_prompt="$next_display$status_prompt"
STATUS="$ZSH_THEME_GIT_PROMPT_AHEAD$STATUS" fi
fi done
if $(echo "$INDEX" | grep '^## [^ ]\+ .*behind' &> /dev/null); then
STATUS="$ZSH_THEME_GIT_PROMPT_BEHIND$STATUS" echo $status_prompt
fi
if $(echo "$INDEX" | grep '^## [^ ]\+ .*diverged' &> /dev/null); then
STATUS="$ZSH_THEME_GIT_PROMPT_DIVERGED$STATUS"
fi
echo $STATUS
} }
# Outputs the name of the current user # Outputs the name of the current user
# Usage example: $(git_current_user_name) # Usage example: $(git_current_user_name)
function git_current_user_name() { function git_current_user_name() {
command git config user.name 2>/dev/null __git_prompt_git config user.name 2>/dev/null
} }
# Outputs the email of the current user # Outputs the email of the current user
# Usage example: $(git_current_user_email) # Usage example: $(git_current_user_email)
function git_current_user_email() { function git_current_user_email() {
command git config user.email 2>/dev/null __git_prompt_git config user.email 2>/dev/null
}
# Output the name of the root directory of the git repository
# Usage example: $(git_repo_name)
function git_repo_name() {
local repo_path
if repo_path="$(__git_prompt_git rev-parse --show-toplevel 2>/dev/null)" && [[ -n "$repo_path" ]]; then
echo ${repo_path:t}
fi
} }

View File

@ -1,28 +1,41 @@
# is x grep argument available? __GREP_CACHE_FILE="$ZSH_CACHE_DIR"/grep-alias
grep-flag-available() {
echo | grep $1 "" >/dev/null 2>&1
}
GREP_OPTIONS="" # See if there's a cache file modified in the last day
__GREP_ALIAS_CACHES=("$__GREP_CACHE_FILE"(Nm-1))
if [[ -n "$__GREP_ALIAS_CACHES" ]]; then
source "$__GREP_CACHE_FILE"
else
grep-flags-available() {
command grep "$@" "" &>/dev/null <<< ""
}
# color grep results # Ignore these folders (if the necessary grep flags are available)
if grep-flag-available --color=auto; then EXC_FOLDERS="{.bzr,CVS,.git,.hg,.svn,.idea,.tox}"
GREP_OPTIONS+=" --color=auto"
# Check for --exclude-dir, otherwise check for --exclude. If --exclude
# isn't available, --color won't be either (they were released at the same
# time (v2.5): https://git.savannah.gnu.org/cgit/grep.git/tree/NEWS?id=1236f007
if grep-flags-available --color=auto --exclude-dir=.cvs; then
GREP_OPTIONS="--color=auto --exclude-dir=$EXC_FOLDERS"
elif grep-flags-available --color=auto --exclude=.cvs; then
GREP_OPTIONS="--color=auto --exclude=$EXC_FOLDERS"
fi
if [[ -n "$GREP_OPTIONS" ]]; then
# export grep, egrep and fgrep settings
alias grep="grep $GREP_OPTIONS"
alias egrep="egrep $GREP_OPTIONS"
alias fgrep="fgrep $GREP_OPTIONS"
# write to cache file if cache directory is writable
if [[ -w "$ZSH_CACHE_DIR" ]]; then
alias -L grep egrep fgrep >| "$__GREP_CACHE_FILE"
fi
fi
# Clean up
unset GREP_OPTIONS EXC_FOLDERS
unfunction grep-flags-available
fi fi
# ignore VCS folders (if the necessary grep flags are available) unset __GREP_CACHE_FILE __GREP_ALIAS_CACHES
VCS_FOLDERS="{.bzr,CVS,.git,.hg,.svn}"
if grep-flag-available --exclude-dir=.cvs; then
GREP_OPTIONS+=" --exclude-dir=$VCS_FOLDERS"
elif grep-flag-available --exclude=.cvs; then
GREP_OPTIONS+=" --exclude=$VCS_FOLDERS"
fi
# export grep settings
alias grep="grep $GREP_OPTIONS"
# clean up
unset GREP_OPTIONS
unset VCS_FOLDERS
unfunction grep-flag-available

View File

@ -6,7 +6,8 @@ function omz_history {
if [[ -n "$clear" ]]; then if [[ -n "$clear" ]]; then
# if -c provided, clobber the history file # if -c provided, clobber the history file
echo -n >| "$HISTFILE" echo -n >| "$HISTFILE"
echo >&2 History file deleted. Reload the session to see its effects. fc -p "$HISTFILE"
echo >&2 History file deleted.
elif [[ -n "$list" ]]; then elif [[ -n "$list" ]]; then
# if -l provided, run as if calling `fc' directly # if -l provided, run as if calling `fc' directly
builtin fc "$@" builtin fc "$@"
@ -27,8 +28,8 @@ esac
## History file configuration ## History file configuration
[ -z "$HISTFILE" ] && HISTFILE="$HOME/.zsh_history" [ -z "$HISTFILE" ] && HISTFILE="$HOME/.zsh_history"
HISTSIZE=50000 [ "$HISTSIZE" -lt 50000 ] && HISTSIZE=50000
SAVEHIST=10000 [ "$SAVEHIST" -lt 10000 ] && SAVEHIST=10000
## History command configuration ## History command configuration
setopt extended_history # record timestamp of command in HISTFILE setopt extended_history # record timestamp of command in HISTFILE
@ -36,5 +37,4 @@ setopt hist_expire_dups_first # delete duplicates first when HISTFILE size excee
setopt hist_ignore_dups # ignore duplicated commands history list setopt hist_ignore_dups # ignore duplicated commands history list
setopt hist_ignore_space # ignore commands that start with space setopt hist_ignore_space # ignore commands that start with space
setopt hist_verify # show command with history expansion to user before running it setopt hist_verify # show command with history expansion to user before running it
setopt inc_append_history # add commands to HISTFILE in order of execution
setopt share_history # share command history data setopt share_history # share command history data

View File

@ -15,55 +15,100 @@ if (( ${+terminfo[smkx]} )) && (( ${+terminfo[rmkx]} )); then
zle -N zle-line-finish zle -N zle-line-finish
fi fi
bindkey -e # Use emacs key bindings # Use emacs key bindings
bindkey -e
# [PageUp] - Up a line of history
if [[ -n "${terminfo[kpp]}" ]]; then
bindkey -M emacs "${terminfo[kpp]}" up-line-or-history
bindkey -M viins "${terminfo[kpp]}" up-line-or-history
bindkey -M vicmd "${terminfo[kpp]}" up-line-or-history
fi
# [PageDown] - Down a line of history
if [[ -n "${terminfo[knp]}" ]]; then
bindkey -M emacs "${terminfo[knp]}" down-line-or-history
bindkey -M viins "${terminfo[knp]}" down-line-or-history
bindkey -M vicmd "${terminfo[knp]}" down-line-or-history
fi
# Start typing + [Up-Arrow] - fuzzy find history forward
if [[ -n "${terminfo[kcuu1]}" ]]; then
autoload -U up-line-or-beginning-search
zle -N up-line-or-beginning-search
bindkey -M emacs "${terminfo[kcuu1]}" up-line-or-beginning-search
bindkey -M viins "${terminfo[kcuu1]}" up-line-or-beginning-search
bindkey -M vicmd "${terminfo[kcuu1]}" up-line-or-beginning-search
fi
# Start typing + [Down-Arrow] - fuzzy find history backward
if [[ -n "${terminfo[kcud1]}" ]]; then
autoload -U down-line-or-beginning-search
zle -N down-line-or-beginning-search
bindkey -M emacs "${terminfo[kcud1]}" down-line-or-beginning-search
bindkey -M viins "${terminfo[kcud1]}" down-line-or-beginning-search
bindkey -M vicmd "${terminfo[kcud1]}" down-line-or-beginning-search
fi
# [Home] - Go to beginning of line
if [[ -n "${terminfo[khome]}" ]]; then
bindkey -M emacs "${terminfo[khome]}" beginning-of-line
bindkey -M viins "${terminfo[khome]}" beginning-of-line
bindkey -M vicmd "${terminfo[khome]}" beginning-of-line
fi
# [End] - Go to end of line
if [[ -n "${terminfo[kend]}" ]]; then
bindkey -M emacs "${terminfo[kend]}" end-of-line
bindkey -M viins "${terminfo[kend]}" end-of-line
bindkey -M vicmd "${terminfo[kend]}" end-of-line
fi
# [Shift-Tab] - move through the completion menu backwards
if [[ -n "${terminfo[kcbt]}" ]]; then
bindkey -M emacs "${terminfo[kcbt]}" reverse-menu-complete
bindkey -M viins "${terminfo[kcbt]}" reverse-menu-complete
bindkey -M vicmd "${terminfo[kcbt]}" reverse-menu-complete
fi
# [Backspace] - delete backward
bindkey -M emacs '^?' backward-delete-char
bindkey -M viins '^?' backward-delete-char
bindkey -M vicmd '^?' backward-delete-char
# [Delete] - delete forward
if [[ -n "${terminfo[kdch1]}" ]]; then
bindkey -M emacs "${terminfo[kdch1]}" delete-char
bindkey -M viins "${terminfo[kdch1]}" delete-char
bindkey -M vicmd "${terminfo[kdch1]}" delete-char
else
bindkey -M emacs "^[[3~" delete-char
bindkey -M viins "^[[3~" delete-char
bindkey -M vicmd "^[[3~" delete-char
bindkey -M emacs "^[3;5~" delete-char
bindkey -M viins "^[3;5~" delete-char
bindkey -M vicmd "^[3;5~" delete-char
fi
# [Ctrl-Delete] - delete whole forward-word
bindkey -M emacs '^[[3;5~' kill-word
bindkey -M viins '^[[3;5~' kill-word
bindkey -M vicmd '^[[3;5~' kill-word
# [Ctrl-RightArrow] - move forward one word
bindkey -M emacs '^[[1;5C' forward-word
bindkey -M viins '^[[1;5C' forward-word
bindkey -M vicmd '^[[1;5C' forward-word
# [Ctrl-LeftArrow] - move backward one word
bindkey -M emacs '^[[1;5D' backward-word
bindkey -M viins '^[[1;5D' backward-word
bindkey -M vicmd '^[[1;5D' backward-word
bindkey '\ew' kill-region # [Esc-w] - Kill from the cursor to the mark bindkey '\ew' kill-region # [Esc-w] - Kill from the cursor to the mark
bindkey -s '\el' 'ls\n' # [Esc-l] - run command: ls bindkey -s '\el' 'ls\n' # [Esc-l] - run command: ls
bindkey '^r' history-incremental-search-backward # [Ctrl-r] - Search backward incrementally for a specified string. The string may begin with ^ to anchor the search to the beginning of the line. bindkey '^r' history-incremental-search-backward # [Ctrl-r] - Search backward incrementally for a specified string. The string may begin with ^ to anchor the search to the beginning of the line.
if [[ "${terminfo[kpp]}" != "" ]]; then bindkey ' ' magic-space # [Space] - don't do history expansion
bindkey "${terminfo[kpp]}" up-line-or-history # [PageUp] - Up a line of history
fi
if [[ "${terminfo[knp]}" != "" ]]; then
bindkey "${terminfo[knp]}" down-line-or-history # [PageDown] - Down a line of history
fi
# start typing + [Up-Arrow] - fuzzy find history forward
if [[ "${terminfo[kcuu1]}" != "" ]]; then
autoload -U up-line-or-beginning-search
zle -N up-line-or-beginning-search
bindkey "${terminfo[kcuu1]}" up-line-or-beginning-search
fi
# start typing + [Down-Arrow] - fuzzy find history backward
if [[ "${terminfo[kcud1]}" != "" ]]; then
autoload -U down-line-or-beginning-search
zle -N down-line-or-beginning-search
bindkey "${terminfo[kcud1]}" down-line-or-beginning-search
fi
if [[ "${terminfo[khome]}" != "" ]]; then
bindkey "${terminfo[khome]}" beginning-of-line # [Home] - Go to beginning of line
fi
if [[ "${terminfo[kend]}" != "" ]]; then
bindkey "${terminfo[kend]}" end-of-line # [End] - Go to end of line
fi
bindkey ' ' magic-space # [Space] - do history expansion
bindkey '^[[1;5C' forward-word # [Ctrl-RightArrow] - move forward one word
bindkey '^[[1;5D' backward-word # [Ctrl-LeftArrow] - move backward one word
if [[ "${terminfo[kcbt]}" != "" ]]; then
bindkey "${terminfo[kcbt]}" reverse-menu-complete # [Shift-Tab] - move through the completion menu backwards
fi
bindkey '^?' backward-delete-char # [Backspace] - delete backward
if [[ "${terminfo[kdch1]}" != "" ]]; then
bindkey "${terminfo[kdch1]}" delete-char # [Delete] - delete forward
else
bindkey "^[[3~" delete-char
bindkey "^[3;5~" delete-char
bindkey "\e[3~" delete-char
fi
# Edit the current command line in $EDITOR # Edit the current command line in $EDITOR
autoload -U edit-command-line autoload -U edit-command-line

View File

@ -3,15 +3,15 @@ autoload -Uz is-at-least
# *-magic is known buggy in some versions; disable if so # *-magic is known buggy in some versions; disable if so
if [[ $DISABLE_MAGIC_FUNCTIONS != true ]]; then if [[ $DISABLE_MAGIC_FUNCTIONS != true ]]; then
for d in $fpath; do for d in $fpath; do
if [[ -e "$d/url-quote-magic" ]]; then if [[ -e "$d/url-quote-magic" ]]; then
if is-at-least 5.1; then if is-at-least 5.1; then
autoload -Uz bracketed-paste-magic autoload -Uz bracketed-paste-magic
zle -N bracketed-paste bracketed-paste-magic zle -N bracketed-paste bracketed-paste-magic
fi fi
autoload -Uz url-quote-magic autoload -Uz url-quote-magic
zle -N self-insert url-quote-magic zle -N self-insert url-quote-magic
break break
fi fi
done done
fi fi
@ -22,10 +22,10 @@ env_default 'PAGER' 'less'
env_default 'LESS' '-R' env_default 'LESS' '-R'
## super user alias ## super user alias
alias _='sudo' alias _='sudo '
## more intelligent acking for ubuntu users ## more intelligent acking for ubuntu users
if which ack-grep &> /dev/null; then if (( $+commands[ack-grep] )); then
alias afind='ack-grep -il' alias afind='ack-grep -il'
else else
alias afind='ack -il' alias afind='ack -il'

View File

@ -1,9 +1,6 @@
# get the node.js version # get the nvm-controlled node.js version
function nvm_prompt_info() { function nvm_prompt_info() {
[[ -f "$NVM_DIR/nvm.sh" ]] || return which nvm &>/dev/null || return
local nvm_prompt local nvm_prompt=${$(nvm current)#v}
nvm_prompt=$(node -v 2>/dev/null)
[[ "${nvm_prompt}x" == "x" ]] && return
nvm_prompt=${nvm_prompt:1}
echo "${ZSH_THEME_NVM_PROMPT_PREFIX}${nvm_prompt}${ZSH_THEME_NVM_PROMPT_SUFFIX}" echo "${ZSH_THEME_NVM_PROMPT_PREFIX}${nvm_prompt}${ZSH_THEME_NVM_PROMPT_SUFFIX}"
} }

View File

@ -18,6 +18,7 @@ function chruby_prompt_info \
vi_mode_prompt_info \ vi_mode_prompt_info \
virtualenv_prompt_info \ virtualenv_prompt_info \
jenv_prompt_info \ jenv_prompt_info \
tf_prompt_info \
{ {
return 1 return 1
} }

View File

@ -1,4 +1,3 @@
#! /bin/zsh
# A script to make using 256 colors in zsh less painful. # A script to make using 256 colors in zsh less painful.
# P.C. Shyamshankar <sykora@lucentbeing.com> # P.C. Shyamshankar <sykora@lucentbeing.com>
# Copied from https://github.com/sykora/etc/blob/master/zsh/functions/spectrum/ # Copied from https://github.com/sykora/etc/blob/master/zsh/functions/spectrum/
@ -6,32 +5,31 @@
typeset -AHg FX FG BG typeset -AHg FX FG BG
FX=( FX=(
reset "%{%}" reset "%{%}"
bold "%{%}" no-bold "%{%}" bold "%{%}" no-bold "%{%}"
italic "%{%}" no-italic "%{%}" italic "%{%}" no-italic "%{%}"
underline "%{%}" no-underline "%{%}" underline "%{%}" no-underline "%{%}"
blink "%{%}" no-blink "%{%}" blink "%{%}" no-blink "%{%}"
reverse "%{%}" no-reverse "%{%}" reverse "%{%}" no-reverse "%{%}"
) )
for color in {000..255}; do for color in {000..255}; do
FG[$color]="%{[38;5;${color}m%}" FG[$color]="%{[38;5;${color}m%}"
BG[$color]="%{[48;5;${color}m%}" BG[$color]="%{[48;5;${color}m%}"
done done
ZSH_SPECTRUM_TEXT=${ZSH_SPECTRUM_TEXT:-Arma virumque cano Troiae qui primus ab oris}
# Show all 256 colors with color number # Show all 256 colors with color number
function spectrum_ls() { function spectrum_ls() {
local ZSH_SPECTRUM_TEXT=${ZSH_SPECTRUM_TEXT:-Arma virumque cano Troiae qui primus ab oris}
for code in {000..255}; do for code in {000..255}; do
print -P -- "$code: %{$FG[$code]%}$ZSH_SPECTRUM_TEXT%{$reset_color%}" print -P -- "$code: $FG[$code]$ZSH_SPECTRUM_TEXT%{$reset_color%}"
done done
} }
# Show all 256 colors where the background is set to specific color # Show all 256 colors where the background is set to specific color
function spectrum_bls() { function spectrum_bls() {
local ZSH_SPECTRUM_TEXT=${ZSH_SPECTRUM_TEXT:-Arma virumque cano Troiae qui primus ab oris}
for code in {000..255}; do for code in {000..255}; do
print -P -- "$code: %{$BG[$code]%}$ZSH_SPECTRUM_TEXT%{$reset_color%}" print -P -- "$code: $BG[$code]$ZSH_SPECTRUM_TEXT%{$reset_color%}"
done done
} }

View File

@ -10,39 +10,39 @@ function title {
emulate -L zsh emulate -L zsh
setopt prompt_subst setopt prompt_subst
[[ "$EMACS" == *term* ]] && return [[ "$INSIDE_EMACS" == *term* ]] && return
# if $2 is unset use $1 as default # if $2 is unset use $1 as default
# if it is set and empty, leave it as is # if it is set and empty, leave it as is
: ${2=$1} : ${2=$1}
case "$TERM" in case "$TERM" in
cygwin|xterm*|putty*|rxvt*|ansi) cygwin|xterm*|putty*|rxvt*|konsole*|ansi|mlterm*|alacritty|st*)
print -Pn "\e]2;$2:q\a" # set window name print -Pn "\e]2;${2:q}\a" # set window name
print -Pn "\e]1;$1:q\a" # set tab name print -Pn "\e]1;${1:q}\a" # set tab name
;; ;;
screen*|tmux*) screen*|tmux*)
print -Pn "\ek$1:q\e\\" # set screen hardstatus print -Pn "\ek${1:q}\e\\" # set screen hardstatus
;; ;;
*) *)
if [[ "$TERM_PROGRAM" == "iTerm.app" ]]; then if [[ "$TERM_PROGRAM" == "iTerm.app" ]]; then
print -Pn "\e]2;$2:q\a" # set window name print -Pn "\e]2;${2:q}\a" # set window name
print -Pn "\e]1;$1:q\a" # set tab name print -Pn "\e]1;${1:q}\a" # set tab name
else else
# Try to use terminfo to set the title # Try to use terminfo to set the title
# If the feature is available set title # If the feature is available set title
if [[ -n "$terminfo[fsl]" ]] && [[ -n "$terminfo[tsl]" ]]; then if [[ -n "$terminfo[fsl]" ]] && [[ -n "$terminfo[tsl]" ]]; then
echoti tsl echoti tsl
print -Pn "$1" print -Pn "$1"
echoti fsl echoti fsl
fi fi
fi fi
;; ;;
esac esac
} }
ZSH_THEME_TERM_TAB_TITLE_IDLE="%15<..<%~%<<" #15 char left truncated PWD ZSH_THEME_TERM_TAB_TITLE_IDLE="%15<..<%~%<<" #15 char left truncated PWD
ZSH_THEME_TERM_TITLE_IDLE="%n@%m: %~" ZSH_THEME_TERM_TITLE_IDLE="%n@%m:%~"
# Avoid duplication of directory in terminals with independent dir display # Avoid duplication of directory in terminals with independent dir display
if [[ "$TERM_PROGRAM" == Apple_Terminal ]]; then if [[ "$TERM_PROGRAM" == Apple_Terminal ]]; then
ZSH_THEME_TERM_TITLE_IDLE="%n@%m" ZSH_THEME_TERM_TITLE_IDLE="%n@%m"
@ -50,22 +50,52 @@ fi
# Runs before showing the prompt # Runs before showing the prompt
function omz_termsupport_precmd { function omz_termsupport_precmd {
emulate -L zsh [[ "${DISABLE_AUTO_TITLE:-}" == true ]] && return
if [[ "$DISABLE_AUTO_TITLE" == true ]]; then
return
fi
title $ZSH_THEME_TERM_TAB_TITLE_IDLE $ZSH_THEME_TERM_TITLE_IDLE title $ZSH_THEME_TERM_TAB_TITLE_IDLE $ZSH_THEME_TERM_TITLE_IDLE
} }
# Runs before executing the command # Runs before executing the command
function omz_termsupport_preexec { function omz_termsupport_preexec {
[[ "${DISABLE_AUTO_TITLE:-}" == true ]] && return
emulate -L zsh emulate -L zsh
setopt extended_glob setopt extended_glob
if [[ "$DISABLE_AUTO_TITLE" == true ]]; then # split command into array of arguments
return local -a cmdargs
cmdargs=("${(z)2}")
# if running fg, extract the command from the job description
if [[ "${cmdargs[1]}" = fg ]]; then
# get the job id from the first argument passed to the fg command
local job_id jobspec="${cmdargs[2]#%}"
# logic based on jobs arguments:
# http://zsh.sourceforge.net/Doc/Release/Jobs-_0026-Signals.html#Jobs
# https://www.zsh.org/mla/users/2007/msg00704.html
case "$jobspec" in
<->) # %number argument:
# use the same <number> passed as an argument
job_id=${jobspec} ;;
""|%|+) # empty, %% or %+ argument:
# use the current job, which appears with a + in $jobstates:
# suspended:+:5071=suspended (tty output)
job_id=${(k)jobstates[(r)*:+:*]} ;;
-) # %- argument:
# use the previous job, which appears with a - in $jobstates:
# suspended:-:6493=suspended (signal)
job_id=${(k)jobstates[(r)*:-:*]} ;;
[?]*) # %?string argument:
# use $jobtexts to match for a job whose command *contains* <string>
job_id=${(k)jobtexts[(r)*${(Q)jobspec}*]} ;;
*) # %string argument:
# use $jobtexts to match for a job whose command *starts with* <string>
job_id=${(k)jobtexts[(r)${(Q)jobspec}*]} ;;
esac
# override preexec function arguments with job command
if [[ -n "${jobtexts[$job_id]}" ]]; then
1="${jobtexts[$job_id]}"
2="${jobtexts[$job_id]}"
fi
fi fi
# cmd name only, or if this is sudo or ssh, the next cmd # cmd name only, or if this is sudo or ssh, the next cmd
@ -75,8 +105,9 @@ function omz_termsupport_preexec {
title '$CMD' '%100>...>$LINE%<<' title '$CMD' '%100>...>$LINE%<<'
} }
precmd_functions+=(omz_termsupport_precmd) autoload -U add-zsh-hook
preexec_functions+=(omz_termsupport_preexec) add-zsh-hook precmd omz_termsupport_precmd
add-zsh-hook preexec omz_termsupport_preexec
# Keep Apple Terminal.app's current working directory updated # Keep Apple Terminal.app's current working directory updated
@ -90,16 +121,17 @@ if [[ "$TERM_PROGRAM" == "Apple_Terminal" ]] && [[ -z "$INSIDE_EMACS" ]]; then
function update_terminalapp_cwd() { function update_terminalapp_cwd() {
emulate -L zsh emulate -L zsh
# Percent-encode the pathname. # Percent-encode the host and path names.
local URL_PATH="$(omz_urlencode -P $PWD)" local URL_HOST URL_PATH
[[ $? != 0 ]] && return 1 URL_HOST="$(omz_urlencode -P $HOST)" || return 1
URL_PATH="$(omz_urlencode -P $PWD)" || return 1
# Undocumented Terminal.app-specific control sequence # Undocumented Terminal.app-specific control sequence
printf '\e]7;%s\a' "file://$HOST$URL_PATH" printf '\e]7;%s\a' "file://$URL_HOST$URL_PATH"
} }
# Use a precmd hook instead of a chpwd hook to avoid contaminating output # Use a precmd hook instead of a chpwd hook to avoid contaminating output
precmd_functions+=(update_terminalapp_cwd) add-zsh-hook precmd update_terminalapp_cwd
# Run once to get initial cwd set # Run once to get initial cwd set
update_terminalapp_cwd update_terminalapp_cwd
fi fi

View File

@ -39,6 +39,11 @@ if [[ "$DISABLE_LS_COLORS" != "true" ]]; then
fi fi
fi fi
# enable diff color if possible.
if command diff --color . . &>/dev/null; then
alias diff='diff --color'
fi
setopt auto_cd setopt auto_cd
setopt multios setopt multios
setopt prompt_subst setopt prompt_subst

View File

@ -1,17 +1,15 @@
# If ZSH is not defined, use the current script's directory.
[[ -z "$ZSH" ]] && export ZSH="${${(%):-%x}:a:h}"
# Set ZSH_CACHE_DIR to the path where cache files should be created # Set ZSH_CACHE_DIR to the path where cache files should be created
# or else we will use the default cache/ # or else we will use the default cache/
if [[ -z "$ZSH_CACHE_DIR" ]]; then if [[ -z "$ZSH_CACHE_DIR" ]]; then
ZSH_CACHE_DIR="$ZSH/cache" ZSH_CACHE_DIR="$ZSH/cache"
fi fi
# Migrate .zsh-update file to $ZSH_CACHE_DIR
if [ -f ~/.zsh-update ] && [ ! -f ${ZSH_CACHE_DIR}/.zsh-update ]; then
mv ~/.zsh-update ${ZSH_CACHE_DIR}/.zsh-update
fi
# Check for updates on initial load... # Check for updates on initial load...
if [ "$DISABLE_AUTO_UPDATE" != "true" ]; then if [ "$DISABLE_AUTO_UPDATE" != "true" ]; then
env ZSH=$ZSH ZSH_CACHE_DIR=$ZSH_CACHE_DIR DISABLE_UPDATE_PROMPT=$DISABLE_UPDATE_PROMPT zsh -f $ZSH/tools/check_for_upgrade.sh source $ZSH/tools/check_for_upgrade.sh
fi fi
# Initializes Oh My Zsh # Initializes Oh My Zsh
@ -32,8 +30,8 @@ fi
is_plugin() { is_plugin() {
local base_dir=$1 local base_dir=$1
local name=$2 local name=$2
test -f $base_dir/plugins/$name/$name.plugin.zsh \ builtin test -f $base_dir/plugins/$name/$name.plugin.zsh \
|| test -f $base_dir/plugins/$name/_$name || builtin test -f $base_dir/plugins/$name/_$name
} }
# Add all defined plugins to fpath. This must be done # Add all defined plugins to fpath. This must be done
@ -61,6 +59,17 @@ if [ -z "$ZSH_COMPDUMP" ]; then
ZSH_COMPDUMP="${ZDOTDIR:-${HOME}}/.zcompdump-${SHORT_HOST}-${ZSH_VERSION}" ZSH_COMPDUMP="${ZDOTDIR:-${HOME}}/.zcompdump-${SHORT_HOST}-${ZSH_VERSION}"
fi fi
# Construct zcompdump OMZ metadata
zcompdump_revision="#omz revision: $(builtin cd -q "$ZSH"; git rev-parse HEAD 2>/dev/null)"
zcompdump_fpath="#omz fpath: $fpath"
# Delete the zcompdump file if OMZ zcompdump metadata changed
if ! command grep -q -Fx "$zcompdump_revision" "$ZSH_COMPDUMP" 2>/dev/null \
|| ! command grep -q -Fx "$zcompdump_fpath" "$ZSH_COMPDUMP" 2>/dev/null; then
command rm -f "$ZSH_COMPDUMP"
zcompdump_refresh=1
fi
if [[ $ZSH_DISABLE_COMPFIX != true ]]; then if [[ $ZSH_DISABLE_COMPFIX != true ]]; then
source $ZSH/lib/compfix.zsh source $ZSH/lib/compfix.zsh
# If completion insecurities exist, warn the user # If completion insecurities exist, warn the user
@ -72,6 +81,19 @@ else
compinit -u -C -d "${ZSH_COMPDUMP}" compinit -u -C -d "${ZSH_COMPDUMP}"
fi fi
# Append zcompdump metadata if missing
if (( $zcompdump_refresh )); then
# Use `tee` in case the $ZSH_COMPDUMP filename is invalid, to silence the error
# See https://github.com/ohmyzsh/ohmyzsh/commit/dd1a7269#commitcomment-39003489
tee -a "$ZSH_COMPDUMP" &>/dev/null <<EOF
$zcompdump_revision
$zcompdump_fpath
EOF
fi
unset zcompdump_revision zcompdump_fpath zcompdump_refresh
# Load all of the config files in ~/oh-my-zsh that end in .zsh # Load all of the config files in ~/oh-my-zsh that end in .zsh
# TIP: Add files you don't want in git to .gitignore # TIP: Add files you don't want in git to .gitignore
@ -97,25 +119,12 @@ done
unset config_file unset config_file
# Load the theme # Load the theme
if [[ "$ZSH_THEME" == "random" ]]; then if [ ! "$ZSH_THEME" = "" ]; then
if [[ "${(t)ZSH_THEME_RANDOM_CANDIDATES}" = "array" ]] && [[ "${#ZSH_THEME_RANDOM_CANDIDATES[@]}" -gt 0 ]]; then if [ -f "$ZSH_CUSTOM/$ZSH_THEME.zsh-theme" ]; then
themes=($ZSH/themes/${^ZSH_THEME_RANDOM_CANDIDATES}.zsh-theme) source "$ZSH_CUSTOM/$ZSH_THEME.zsh-theme"
elif [ -f "$ZSH_CUSTOM/themes/$ZSH_THEME.zsh-theme" ]; then
source "$ZSH_CUSTOM/themes/$ZSH_THEME.zsh-theme"
else else
themes=($ZSH/themes/*zsh-theme) source "$ZSH/themes/$ZSH_THEME.zsh-theme"
fi
N=${#themes[@]}
((N=(RANDOM%N)+1))
RANDOM_THEME=${themes[$N]}
source "$RANDOM_THEME"
echo "[oh-my-zsh] Random theme '$RANDOM_THEME' loaded..."
else
if [ ! "$ZSH_THEME" = "" ]; then
if [ -f "$ZSH_CUSTOM/$ZSH_THEME.zsh-theme" ]; then
source "$ZSH_CUSTOM/$ZSH_THEME.zsh-theme"
elif [ -f "$ZSH_CUSTOM/themes/$ZSH_THEME.zsh-theme" ]; then
source "$ZSH_CUSTOM/themes/$ZSH_THEME.zsh-theme"
else
source "$ZSH/themes/$ZSH_THEME.zsh-theme"
fi
fi fi
fi fi

View File

@ -14,7 +14,7 @@ alias-finder() {
esac esac
done done
cmd=$(sed 's/[].\|$(){}?+*^[]/\\&/g' <<< $cmd) # adds escaping for grep cmd=$(sed 's/[].\|$(){}?+*^[]/\\&/g' <<< $cmd) # adds escaping for grep
if [[ $(wc -l <<< $cmd) == 1 ]]; then if (( $(wc -l <<< $cmd) == 1 )); then
while [[ $cmd != "" ]]; do while [[ $cmd != "" ]]; do
if [[ $longer = true ]]; then if [[ $longer = true ]]; then
wordStart="'{0,1}" wordStart="'{0,1}"
@ -43,4 +43,5 @@ preexec_alias-finder() {
fi fi
} }
preexec_functions+=(preexec_alias-finder) autoload -U add-zsh-hook
add-zsh-hook preexec preexec_alias-finder

View File

@ -4,7 +4,7 @@ function ansible-version(){
} }
function ansible-role-init(){ function ansible-role-init(){
if ! [ -z $1] ; then if ! [ -z $1 ] ; then
echo "Ansible Role : $1 Creating...." echo "Ansible Role : $1 Creating...."
ansible-galaxy init $1 ansible-galaxy init $1
tree $1 tree $1

View File

@ -1,19 +1,21 @@
## APACHE2 MACPORTS PLUGIN # apache2-macports plugin
Enables aliases to control a local Apache2 installed via [MacPorts](https://www.macports.org/).
--- To use it, add `apache2-macports` to the plugins array in your zshrc file:
### FEATURES ```zsh
plugins=(... apache2-macports)
```
| Alias | Function | Description | ## Aliases
|:--------------:|:-------------------------------------------------------------------------------|----------------------:|
| apache2restart | sudo /opt/local/etc/LaunchDaemons/org.macports.apache2/apache2.wrapper restart | Restart apache daemon |
| apache2start | sudo /opt/local/etc/LaunchDaemons/org.macports.apache2/apache2.wrapper start | Start apache daemon |
| apache2stop | sudo /opt/local/etc/LaunchDaemons/org.macports.apache2/apache2.wrapper stop | Stop apache daemon |
--- | Alias | Function | Description |
|----------------|-----------------------------------------|-----------------------|
| apache2restart | `sudo /path/to/apache2.wrapper restart` | Restart apache daemon |
| apache2start | `sudo /path/to/apache2.wrapper start` | Start apache daemon |
| apache2stop | `sudo /path/to/apache2.wrapper stop` | Stop apache daemon |
### CONTRIBUTORS ## Contributors
- Alexander Rinass (alex@rinass.net)
--- - Alexander Rinass (alex@rinass.net)

View File

@ -1,5 +1,41 @@
## arcanist ## arcanist
**Maintainer:** [@emzar](https://github.com/emzar) This plugin adds many useful aliases for [arcanist](https://github.com/phacility/arcanist).
This plugin adds many useful aliases. To use it, add `arcanist` to the plugins array of your zshrc file:
```zsh
plugins=(... arcanist)
```
## Aliases
| Alias | Command |
| ------- | ---------------------------------- |
| ara | `arc amend` |
| arb | `arc branch` |
| arco | `arc cover` |
| arci | `arc commit` |
| ard | `arc diff` |
| ardc | `arc diff --create` |
| ardp | `arc diff --preview` |
| ardnu | `arc diff --nounit` |
| ardnupc | `arc diff --nounit --plan-changes` |
| ardpc | `arc diff --plan-changes` |
| are | `arc export` |
| arh | `arc help` |
| arl | `arc land` |
| arli | `arc lint` |
| arls | `arc list` |
| arpa | `arc patch` |
## Functions
The following functions make copy pasting revision ids from the URL bar of your browser
easier, as they allow for copy pasting the whole URL. For example: `ardu` accepts
both `https://arcanist-url.com/<REVISION>` as well as `<REVISION>`.
| Function | Command |
| ------------------------- | --------------------------------- |
| ardu [URL or revision_id] | `arc diff --update` [revision_id] |
| arpa [URL or revision_id] | `arc patch` [revision_id] |

View File

@ -9,13 +9,29 @@ alias arco='arc cover'
alias arci='arc commit' alias arci='arc commit'
alias ard='arc diff' alias ard='arc diff'
alias ardc='arc diff --create'
alias ardnu='arc diff --nounit' alias ardnu='arc diff --nounit'
alias ardnupc='arc diff --nounit --plan-changes' alias ardnupc='arc diff --nounit --plan-changes'
alias ardpc='arc diff --plan-changes' alias ardpc='arc diff --plan-changes'
alias ardp='arc diff --preview' # creates a new diff in the phab interface
alias are='arc export' alias are='arc export'
alias arh='arc help' alias arh='arc help'
alias arl='arc land' alias arl='arc land'
alias arli='arc lint' alias arli='arc lint'
alias arls='arc list' alias arls='arc list'
alias arpa='arc patch'
#
# Functions
# (sorted alphabetically)
#
ardu() {
# Both `ardu https://arcanist-url.com/<REVISION>`, and `ardu <REVISION>` work.
arc diff --update "${1:t}"
}
arpa() {
# Both `arpa https://arcanist-url.com/<REVISION>`, and `arpa <REVISION>` work.
arc patch "${1:t}"
}

View File

@ -1,146 +1,198 @@
# Archlinux plugin # Arch Linux plugin
This plugin adds some aliases and functions to work with Arch Linux.
To use it, add `archlinux` to the plugins array in your zshrc file:
```zsh
plugins=(... archlinux)
```
## Features ## Features
#### YAY ### Pacman
| Alias | Command | Description | | Alias | Command | Description |
|---------|------------------------------------|---------------------------------------------------------------------| |--------------|----------------------------------------|------------------------------------------------------------------|
| yaconf | yay -Pg | Print current configuration | | pacin | `sudo pacman -S` | Install packages from the repositories |
| yain | yay -S | Install packages from the repositories | | pacins | `sudo pacman -U` | Install a package from a local file |
| yains | yay -U | Install a package from a local file | | pacinsd | `sudo pacman -S --asdeps` | Install packages as dependencies of another package |
| yainsd | yay -S --asdeps | Install packages as dependencies of another package | | pacloc | `pacman -Qi` | Display information about a package in the local database |
| yaloc | yay -Qi | Display information about a package in the local database | | paclocs | `pacman -Qs` | Search for packages in the local database |
| yalocs | yay -Qs | Search for packages in the local database | | paclsorphans | `sudo pacman -Qdt` | List all orphaned packages |
| yalst | yay -Qe | List installed packages including from AUR (tagged as "local") | | pacmir | `sudo pacman -Syy` | Force refresh of all package lists after updating mirrorlist |
| yamir | yay -Syy | Force refresh of all package lists after updating mirrorlist | | pacre | `sudo pacman -R` | Remove packages, keeping its settings and dependencies |
| yaorph | yay -Qtd | Remove orphans using yay | | pacrem | `sudo pacman -Rns` | Remove packages, including its settings and dependencies |
| yare | yay -R | Remove packages, keeping its settings and dependencies | | pacrep | `pacman -Si` | Display information about a package in the repositories |
| yarem | yay -Rns | Remove packages, including its settings and unneeded dependencies | | pacreps | `pacman -Ss` | Search for packages in the repositories |
| yarep | yay -Si | Display information about a package in the repositories | | pacrmorphans | `sudo pacman -Rs $(pacman -Qtdq)` | Delete all orphaned packages |
| yareps | yay -Ss | Search for packages in the repositories | | pacupd | `sudo pacman -Sy` | Update and refresh local package, ABS and AUR databases |
| yaupg | yay -Syu | Sync with repositories before upgrading packages | | pacupg | `sudo pacman -Syu` | Sync with repositories before upgrading packages |
| yasu | yay -Syu --no-confirm | Same as `yaupg`, but without confirmation | | pacfileupg | `sudo pacman -Fy` | Download fresh package databases from the server |
| pacfiles | `pacman -F` | Search package file names for matching strings |
| pacls | `pacman -Ql` | List files in a package |
| pacown | `pacman -Qo` | Show which package owns a file |
| upgrade[²](#f2) | `sudo pacman -Syu` | Sync with repositories before upgrading packages |
#### TRIZEN | Function | Description |
|----------------|-----------------------------------------------------------|
| pacdisowned | List all disowned files in your system |
| paclist | List all explicitly installed packages with a description |
| pacmanallkeys | Get all keys for developers and trusted users |
| pacmansignkeys | Locally trust all keys passed as parameters |
| pacweb | Open the website of an ArchLinux package |
| Alias | Command | Description | Note: paclist used to print packages with a description which are (1) explicitly installed
|---------|------------------------------------|---------------------------------------------------------------------| and (2) available for upgrade. Due to flawed scripting, it also printed all packages if no
| trconf | trizen -C | Fix all configuration files with vimdiff | upgrades were available. Use `pacman -Que` instead.
| trin | trizen -S | Install packages from the repositories |
| trins | trizen -U | Install a package from a local file |
| trinsd | trizen -S --asdeps | Install packages as dependencies of another package |
| trloc | trizen -Qi | Display information about a package in the local database |
| trlocs | trizen -Qs | Search for packages in the local database |
| trlst | trizen -Qe | List installed packages including from AUR (tagged as "local") |
| trmir | trizen -Syy | Force refresh of all package lists after updating mirrorlist |
| trorph | trizen -Qtd | Remove orphans using yaourt |
| trre | trizen -R | Remove packages, keeping its settings and dependencies |
| trrem | trizen -Rns | Remove packages, including its settings and unneeded dependencies |
| trrep | trizen -Si | Display information about a package in the repositories |
| trreps | trizen -Ss | Search for packages in the repositories |
| trupd | trizen -Sy && sudo abs && sudo aur | Update and refresh local package, ABS and AUR databases |
| trupd | trizen -Sy && sudo abs | Update and refresh the local package and ABS databases |
| trupd | trizen -Sy && sudo aur | Update and refresh the local package and AUR databases |
| trupd | trizen -Sy | Update and refresh the local package database |
| trupg | trizen -Syua | Sync with repositories before upgrading all packages (from AUR too) |
| trsu | trizen -Syua --no-confirm | Same as `trupg`, but without confirmation |
| upgrade | trizen -Syu | Sync with repositories before upgrading packages |
#### YAOURT ### AUR helpers
| Alias | Command | Description | #### Aura
|---------|------------------------------------|---------------------------------------------------------------------|
| yaconf | yaourt -C | Fix all configuration files with vimdiff |
| yain | yaourt -S | Install packages from the repositories |
| yains | yaourt -U | Install a package from a local file |
| yainsd | yaourt -S --asdeps | Install packages as dependencies of another package |
| yaloc | yaourt -Qi | Display information about a package in the local database |
| yalocs | yaourt -Qs | Search for packages in the local database |
| yalst | yaourt -Qe | List installed packages including from AUR (tagged as "local") |
| yamir | yaourt -Syy | Force refresh of all package lists after updating mirrorlist |
| yaorph | yaourt -Qtd | Remove orphans using yaourt |
| yare | yaourt -R | Remove packages, keeping its settings and dependencies |
| yarem | yaourt -Rns | Remove packages, including its settings and unneeded dependencies |
| yarep | yaourt -Si | Display information about a package in the repositories |
| yareps | yaourt -Ss | Search for packages in the repositories |
| yaupd | yaourt -Sy && sudo abs && sudo aur | Update and refresh local package, ABS and AUR databases |
| yaupd | yaourt -Sy && sudo abs | Update and refresh the local package and ABS databases |
| yaupd | yaourt -Sy && sudo aur | Update and refresh the local package and AUR databases |
| yaupd | yaourt -Sy | Update and refresh the local package database |
| yaupg | yaourt -Syua | Sync with repositories before upgrading all packages (from AUR too) |
| yasu | yaourt -Syua --no-confirm | Same as `yaupg`, but without confirmation |
| upgrade | yaourt -Syu | Sync with repositories before upgrading packages |
#### PACAUR | Alias | Command | Description |
|---------|-------------------------------------------------|-------------------------------------------------------------------------|
| auin | `sudo aura -S` | Install packages from the repositories |
| aurin | `sudo aura -A` | Install packages from the repositories |
| auins | `sudo aura -U` | Install a package from a local file |
| auinsd | `sudo aura -S --asdeps` | Install packages as dependencies of another package (repositories only) |
| aurinsd | `sudo aura -A --asdeps` | Install packages as dependencies of another package (AUR only) |
| auloc | `aura -Qi` | Display information about a package in the local database |
| aulocs | `aura -Qs` | Search for packages in the local database |
| auls | `aura -Qql` | List all files owned by a given package |
| aulst | `aura -Qe` | List installed packages including from AUR (tagged as "local") |
| aumir | `sudo aura -Syy` | Force refresh of all package lists after updating mirrorlist |
| aurph | `sudo aura -Oj` | Remove orphans using aura |
| auown | `aura -Qqo` | Search for packages that own the specified file(s) |
| aure | `sudo aura -R` | Remove packages, keeping its settings and dependencies |
| aurem | `sudo aura -Rns` | Remove packages, including its settings and unneeded dependencies |
| aurep | `aura -Si` | Display information about a package in the repositories |
| aurrep | `aura -Ai` | Display information about a package from AUR |
| aureps | `aura -As --both` | Search for packages in the repositories and AUR |
| auras | `aura -As --both` | Same as above |
| auupd | `sudo aura -Sy` | Update and refresh local package, ABS and AUR databases |
| auupg | `sudo sh -c "aura -Syu && aura -Au"` | Sync with repositories before upgrading all packages (from AUR too) |
| ausu | `sudo sh -c "aura -Syu --no-confirm && aura -Au --no-confirm"` | Same as `auupg`, but without confirmation |
| upgrade[²](#f2) | `sudo aura -Syu` | Sync with repositories before upgrading packages |
| Alias | Command | Description | | Function | Description |
|---------|------------------------------------|---------------------------------------------------------------------| |-----------------|---------------------------------------------------------------------|
| pain | pacaur -S | Install packages from the repositories | | auownloc _file_ | Display information about a package that owns the specified file(s) |
| pains | pacaur -U | Install a package from a local file | | auownls _file_ | List all files owned by a package that owns the specified file(s) |
| painsd | pacaur -S --asdeps | Install packages as dependencies of another package |
| paloc | pacaur -Qi | Display information about a package in the local database |
| palocs | pacaur -Qs | Search for packages in the local database |
| palst | pacaur -Qe | List installed packages including from AUR (tagged as "local") |
| pamir | pacaur -Syy | Force refresh of all package lists after updating mirrorlist |
| paorph | pacaur -Qtd | Remove orphans using pacaur |
| pare | pacaur -R | Remove packages, keeping its settings and dependencies |
| parem | pacaur -Rns | Remove packages, including its settings and unneeded dependencies |
| parep | pacaur -Si | Display information about a package in the repositories |
| pareps | pacaur -Ss | Search for packages in the repositories |
| paupd | pacaur -Sy && sudo abs && sudo aur | Update and refresh local package, ABS and AUR databases |
| paupd | pacaur -Sy && sudo abs | Update and refresh the local package and ABS databases |
| paupd | pacaur -Sy && sudo aur | Update and refresh the local package and AUR databases |
| paupd | pacaur -Sy | Update and refresh the local package database |
| paupg | pacaur -Syua | Sync with repositories before upgrading all packages (from AUR too) |
| pasu | pacaur -Syua --no-confirm | Same as `paupg`, but without confirmation |
| upgrade | pacaur -Syu | Sync with repositories before upgrading packages |
#### PACMAN #### Pacaur
| Alias | Command | Description | | Alias | Command | Description |
|--------------|-----------------------------------------|--------------------------------------------------------------| |---------|-----------------------------------|---------------------------------------------------------------------|
| pacin | sudo pacman -S | Install packages from the repositories | | pain | `pacaur -S` | Install packages from the repositories |
| pacins | sudo pacman -U | Install a package from a local file | | pains | `pacaur -U` | Install a package from a local file |
| pacinsd | sudo pacman -S --asdeps | Install packages as dependencies of another package | | painsd | `pacaur -S --asdeps` | Install packages as dependencies of another package |
| pacloc | pacman -Qi | Display information about a package in the local database | | paloc | `pacaur -Qi` | Display information about a package in the local database |
| paclocs | pacman -Qs | Search for packages in the local database | | palocs | `pacaur -Qs` | Search for packages in the local database |
| paclsorphans | sudo pacman -Qdt | List all orphaned packages | | palst | `pacaur -Qe` | List installed packages including from AUR (tagged as "local") |
| pacmir | sudo pacman -Syy | Force refresh of all package lists after updating mirrorlist | | pamir | `pacaur -Syy` | Force refresh of all package lists after updating mirrorlist |
| pacre | sudo pacman -R | Remove packages, keeping its settings and dependencies | | paorph | `pacaur -Qtd` | Remove orphans using pacaur |
| pacrem | sudo pacman -Rns | Remove packages, including its settings and dependencies | | pare | `pacaur -R` | Remove packages, keeping its settings and dependencies |
| pacrep | pacman -Si | Display information about a package in the repositories | | parem | `pacaur -Rns` | Remove packages, including its settings and unneeded dependencies |
| pacreps | pacman -Ss | Search for packages in the repositories | | parep | `pacaur -Si` | Display information about a package in the repositories |
| pacrmorphans | sudo pacman -Rs $(pacman -Qtdq) | Delete all orphaned packages | | pareps | `pacaur -Ss` | Search for packages in the repositories |
| pacupd | sudo pacman -Sy && sudo abs && sudo aur | Update and refresh the local package, ABS and AUR databases | | paupd | `pacaur -Sy` | Update and refresh local package, ABS and AUR databases |
| pacupd | sudo pacman -Sy && sudo abs | Update and refresh the local package and ABS databases | | paupg | `pacaur -Syua` | Sync with repositories before upgrading all packages (from AUR too) |
| pacupd | sudo pacman -Sy && sudo aur | Update and refresh the local package and AUR databases | | pasu | `pacaur -Syua --no-confirm` | Same as `paupg`, but without confirmation |
| pacupd | sudo pacman -Sy | Update and refresh the local package database | | upgrade[²](#f2) | `pacaur -Syu` | Sync with repositories before upgrading packages |
| pacupg | sudo pacman -Syu | Sync with repositories before upgrading packages |
| upgrade | sudo pacman -Syu | Sync with repositories before upgrading packages |
| pacfileupg | sudo pacman -Fy | Download fresh package databases from the server |
| pacfiles | pacman -Fs | Search package file names for matching strings |
| pacls | pacman -Ql | List files in a package |
| pacown | pacman -Qo | Show which package owns a file |
| Function | Description | #### Trizen
|----------------|------------------------------------------------------|
| pacdisowned | List all disowned files in your system | | Alias | Command | Description |
| paclist | List all installed packages with a short description | |---------|-----------------------------------|---------------------------------------------------------------------|
| pacmanallkeys | Get all keys for developers and trusted users | | trconf | `trizen -C` | Fix all configuration files with vimdiff |
| pacmansignkeys | Locally trust all keys passed as parameters | | trin | `trizen -S` | Install packages from the repositories |
| pacweb | Open the website of an ArchLinux package | | trins | `trizen -U` | Install a package from a local file |
| trinsd | `trizen -S --asdeps` | Install packages as dependencies of another package |
| trloc | `trizen -Qi` | Display information about a package in the local database |
| trlocs | `trizen -Qs` | Search for packages in the local database |
| trlst | `trizen -Qe` | List installed packages including from AUR (tagged as "local") |
| trmir | `trizen -Syy` | Force refresh of all package lists after updating mirrorlist |
| trorph | `trizen -Qtd` | Remove orphans using yaourt |
| trre | `trizen -R` | Remove packages, keeping its settings and dependencies |
| trrem | `trizen -Rns` | Remove packages, including its settings and unneeded dependencies |
| trrep | `trizen -Si` | Display information about a package in the repositories |
| trreps | `trizen -Ss` | Search for packages in the repositories |
| trupd | `trizen -Sy` | Update and refresh local package, ABS and AUR databases |
| trupg | `trizen -Syua` | Sync with repositories before upgrading all packages (from AUR too) |
| trsu | `trizen -Syua --no-confirm` | Same as `trupg`, but without confirmation |
| upgrade[²](#f2) | `trizen -Syu` | Sync with repositories before upgrading packages |
#### Yaourt[¹](#f1)
| Alias | Command | Description |
|---------|-----------------------------------|---------------------------------------------------------------------|
| yaconf | `yaourt -C` | Fix all configuration files with vimdiff |
| yain | `yaourt -S` | Install packages from the repositories |
| yains | `yaourt -U` | Install a package from a local file |
| yainsd | `yaourt -S --asdeps` | Install packages as dependencies of another package |
| yaloc | `yaourt -Qi` | Display information about a package in the local database |
| yalocs | `yaourt -Qs` | Search for packages in the local database |
| yalst | `yaourt -Qe` | List installed packages including from AUR (tagged as "local") |
| yamir | `yaourt -Syy` | Force refresh of all package lists after updating mirrorlist |
| yaorph | `yaourt -Qtd` | Remove orphans using yaourt |
| yare | `yaourt -R` | Remove packages, keeping its settings and dependencies |
| yarem | `yaourt -Rns` | Remove packages, including its settings and unneeded dependencies |
| yarep | `yaourt -Si` | Display information about a package in the repositories |
| yareps | `yaourt -Ss` | Search for packages in the repositories |
| yaupd | `yaourt -Sy` | Update and refresh local package, ABS and AUR databases |
| yaupg | `yaourt -Syua` | Sync with repositories before upgrading all packages (from AUR too) |
| yasu | `yaourt -Syua --no-confirm` | Same as `yaupg`, but without confirmation |
| upgrade[²](#f2) | `yaourt -Syu` | Sync with repositories before upgrading packages |
#### Yay[¹](#f1)
| Alias | Command | Description |
|---------|--------------------------------|-------------------------------------------------------------------|
| yaconf | `yay -Pg` | Print current configuration |
| yain | `yay -S` | Install packages from the repositories |
| yains | `yay -U` | Install a package from a local file |
| yainsd | `yay -S --asdeps` | Install packages as dependencies of another package |
| yaloc | `yay -Qi` | Display information about a package in the local database |
| yalocs | `yay -Qs` | Search for packages in the local database |
| yalst | `yay -Qe` | List installed packages including from AUR (tagged as "local") |
| yamir | `yay -Syy` | Force refresh of all package lists after updating mirrorlist |
| yaorph | `yay -Qtd` | Remove orphans using yay |
| yare | `yay -R` | Remove packages, keeping its settings and dependencies |
| yarem | `yay -Rns` | Remove packages, including its settings and unneeded dependencies |
| yarep | `yay -Si` | Display information about a package in the repositories |
| yareps | `yay -Ss` | Search for packages in the repositories |
| yaupd | `yay -Sy` | Update and refresh local package, ABS and AUR databases |
| yaupg | `yay -Syu` | Sync with repositories before upgrading packages |
| yasu | `yay -Syu --no-confirm` | Same as `yaupg`, but without confirmation |
| upgrade[²](#f2) | `yay -Syu` | Sync with repositories before upgrading packages |
--- ---
<span id="f1">¹</span>
Yay and Yaourt aliases overlap. If both are installed, yay will take precedence.
<span id="f2">²</span>
The `upgrade` alias is set for all package managers. Its value will depend on
whether the package manager is installed, checked in the following order:
1. `yay`
2. `yaourt`
3. `trizen`
4. `pacaur`
5. `aura`
6. `pacman`
## Contributors ## Contributors
- Benjamin Boudreau - dreurmail@gmail.com - Benjamin Boudreau - dreurmail@gmail.com
- Celso Miranda - contacto@celsomiranda.net - Celso Miranda - contacto@celsomiranda.net
- ratijas (ivan tkachenko) - me@ratijas.tk
- Juraj Fiala - doctorjellyface@riseup.net
- KhasMek - Boushh@gmail.com - KhasMek - Boushh@gmail.com
- Majora320 (Moses Miller) - Majora320@gmail.com
- Martin Putniorz - mputniorz@gmail.com - Martin Putniorz - mputniorz@gmail.com
- MatthR3D - matthr3d@gmail.com - MatthR3D - matthr3d@gmail.com
- ornicar - thibault.duplessis@gmail.com - ornicar - thibault.duplessis@gmail.com
- Juraj Fiala - doctorjellyface@riseup.net
- Majora320 (Moses Miller) - Majora320@gmail.com
- Ybalrid (Arthur Brainville) - ybalrid@ybalrid.info - Ybalrid (Arthur Brainville) - ybalrid@ybalrid.info
- Jeff M. Hubbard - jeffmhubbard@gmail.com

View File

@ -1,3 +1,138 @@
#######################################
# Pacman #
#######################################
# Pacman - https://wiki.archlinux.org/index.php/Pacman_Tips
alias pacupg='sudo pacman -Syu'
alias pacin='sudo pacman -S'
alias pacins='sudo pacman -U'
alias pacre='sudo pacman -R'
alias pacrem='sudo pacman -Rns'
alias pacrep='pacman -Si'
alias pacreps='pacman -Ss'
alias pacloc='pacman -Qi'
alias paclocs='pacman -Qs'
alias pacinsd='sudo pacman -S --asdeps'
alias pacmir='sudo pacman -Syy'
alias paclsorphans='sudo pacman -Qdt'
alias pacrmorphans='sudo pacman -Rs $(pacman -Qtdq)'
alias pacfileupg='sudo pacman -Fy'
alias pacfiles='pacman -F'
alias pacls='pacman -Ql'
alias pacown='pacman -Qo'
alias pacupd="sudo pacman -Sy"
alias upgrade='sudo pacman -Syu'
function paclist() {
# Based on https://bbs.archlinux.org/viewtopic.php?id=93683
pacman -Qqe | \
xargs -I '{}' \
expac "${bold_color}% 20n ${fg_no_bold[white]}%d${reset_color}" '{}'
}
function pacdisowned() {
local tmp db fs
tmp=${TMPDIR-/tmp}/pacman-disowned-$UID-$$
db=$tmp/db
fs=$tmp/fs
mkdir "$tmp"
trap 'rm -rf "$tmp"' EXIT
pacman -Qlq | sort -u > "$db"
find /bin /etc /lib /sbin /usr ! -name lost+found \
\( -type d -printf '%p/\n' -o -print \) | sort > "$fs"
comm -23 "$fs" "$db"
}
alias pacmanallkeys='sudo pacman-key --refresh-keys'
function pacmansignkeys() {
local key
for key in $@; do
sudo pacman-key --recv-keys $key
sudo pacman-key --lsign-key $key
printf 'trust\n3\n' | sudo gpg --homedir /etc/pacman.d/gnupg \
--no-permission-warning --command-fd 0 --edit-key $key
done
}
if (( $+commands[xdg-open] )); then
function pacweb() {
if [[ $# = 0 || "$1" =~ '--help|-h' ]]; then
local underline_color="\e[${color[underline]}m"
echo "$0 - open the website of an ArchLinux package"
echo
echo "Usage:"
echo " $bold_color$0$reset_color ${underline_color}target${reset_color}"
return 1
fi
local pkg="$1"
local infos="$(LANG=C pacman -Si "$pkg")"
if [[ -z "$infos" ]]; then
return
fi
local repo="$(grep -m 1 '^Repo' <<< "$infos" | grep -oP '[^ ]+$')"
local arch="$(grep -m 1 '^Arch' <<< "$infos" | grep -oP '[^ ]+$')"
xdg-open "https://www.archlinux.org/packages/$repo/$arch/$pkg/" &>/dev/null
}
fi
#######################################
# AUR helpers #
#######################################
if (( $+commands[aura] )); then
alias auin='sudo aura -S'
alias aurin='sudo aura -A'
alias auins='sudo aura -U'
alias auinsd='sudo aura -S --asdeps'
alias aurinsd='sudo aura -A --asdeps'
alias auloc='aura -Qi'
alias aulocs='aura -Qs'
alias aulst='aura -Qe'
alias aumir='sudo aura -Syy'
alias aurph='sudo aura -Oj'
alias aure='sudo aura -R'
alias aurem='sudo aura -Rns'
alias aurep='aura -Si'
alias aurrep='aura -Ai'
alias aureps='aura -As --both'
alias auras='aura -As --both'
alias auupd="sudo aura -Sy"
alias auupg='sudo sh -c "aura -Syu && aura -Au"'
alias ausu='sudo sh -c "aura -Syu --no-confirm && aura -Au --no-confirm"'
alias upgrade='sudo aura -Syu'
# extra bonus specially for aura
alias auown="aura -Qqo"
alias auls="aura -Qql"
function auownloc() { aura -Qi $(aura -Qqo $@); }
function auownls () { aura -Qql $(aura -Qqo $@); }
fi
if (( $+commands[pacaur] )); then
alias paupg='pacaur -Syu'
alias pasu='pacaur -Syu --noconfirm'
alias pain='pacaur -S'
alias pains='pacaur -U'
alias pare='pacaur -R'
alias parem='pacaur -Rns'
alias parep='pacaur -Si'
alias pareps='pacaur -Ss'
alias paloc='pacaur -Qi'
alias palocs='pacaur -Qs'
alias palst='pacaur -Qe'
alias paorph='pacaur -Qtd'
alias painsd='pacaur -S --asdeps'
alias pamir='pacaur -Syy'
alias paupd="pacaur -Sy"
alias upgrade='pacaur -Syu'
fi
if (( $+commands[trizen] )); then if (( $+commands[trizen] )); then
alias trconf='trizen -C' alias trconf='trizen -C'
alias trupg='trizen -Syua' alias trupg='trizen -Syua'
@ -14,17 +149,8 @@ if (( $+commands[trizen] )); then
alias trorph='trizen -Qtd' alias trorph='trizen -Qtd'
alias trinsd='trizen -S --asdeps' alias trinsd='trizen -S --asdeps'
alias trmir='trizen -Syy' alias trmir='trizen -Syy'
alias trupd="trizen -Sy"
alias upgrade='trizen -Syu'
if (( $+commands[abs] && $+commands[aur] )); then
alias trupd='trizen -Sy && sudo abs && sudo aur'
elif (( $+commands[abs] )); then
alias trupd='trizen -Sy && sudo abs'
elif (( $+commands[aur] )); then
alias trupd='trizen -Sy && sudo aur'
else
alias trupd='trizen -Sy'
fi
fi fi
if (( $+commands[yaourt] )); then if (( $+commands[yaourt] )); then
@ -43,17 +169,8 @@ if (( $+commands[yaourt] )); then
alias yaorph='yaourt -Qtd' alias yaorph='yaourt -Qtd'
alias yainsd='yaourt -S --asdeps' alias yainsd='yaourt -S --asdeps'
alias yamir='yaourt -Syy' alias yamir='yaourt -Syy'
alias yaupd="yaourt -Sy"
alias upgrade='yaourt -Syu'
if (( $+commands[abs] && $+commands[aur] )); then
alias yaupd='yaourt -Sy && sudo abs && sudo aur'
elif (( $+commands[abs] )); then
alias yaupd='yaourt -Sy && sudo abs'
elif (( $+commands[aur] )); then
alias yaupd='yaourt -Sy && sudo aur'
else
alias yaupd='yaourt -Sy'
fi
fi fi
if (( $+commands[yay] )); then if (( $+commands[yay] )); then
@ -72,148 +189,7 @@ if (( $+commands[yay] )); then
alias yaorph='yay -Qtd' alias yaorph='yay -Qtd'
alias yainsd='yay -S --asdeps' alias yainsd='yay -S --asdeps'
alias yamir='yay -Syy' alias yamir='yay -Syy'
alias yaupd="yay -Sy"
alias upgrade='yay -Syu'
if (( $+commands[abs] && $+commands[aur] )); then
alias yaupd='yay -Sy && sudo abs && sudo aur'
elif (( $+commands[abs] )); then
alias yaupd='yay -Sy && sudo abs'
elif (( $+commands[aur] )); then
alias yaupd='yay -Sy && sudo aur'
else
alias yaupd='yay -Sy'
fi
fi fi
if (( $+commands[pacaur] )); then
alias paupg='pacaur -Syu'
alias pasu='pacaur -Syu --noconfirm'
alias pain='pacaur -S'
alias pains='pacaur -U'
alias pare='pacaur -R'
alias parem='pacaur -Rns'
alias parep='pacaur -Si'
alias pareps='pacaur -Ss'
alias paloc='pacaur -Qi'
alias palocs='pacaur -Qs'
alias palst='pacaur -Qe'
alias paorph='pacaur -Qtd'
alias painsd='pacaur -S --asdeps'
alias pamir='pacaur -Syy'
if (( $+commands[abs] && $+commands[aur] )); then
alias paupd='pacaur -Sy && sudo abs && sudo aur'
elif (( $+commands[abs] )); then
alias paupd='pacaur -Sy && sudo abs'
elif (( $+commands[aur] )); then
alias paupd='pacaur -Sy && sudo aur'
else
alias paupd='pacaur -Sy'
fi
fi
if (( $+commands[trizen] )); then
function upgrade() {
trizen -Syu
}
elif (( $+commands[pacaur] )); then
function upgrade() {
pacaur -Syu
}
elif (( $+commands[yaourt] )); then
function upgrade() {
yaourt -Syu
}
elif (( $+commands[yay] )); then
function upgrade() {
yay -Syu
}
else
function upgrade() {
sudo pacman -Syu
}
fi
# Pacman - https://wiki.archlinux.org/index.php/Pacman_Tips
alias pacupg='sudo pacman -Syu'
alias pacin='sudo pacman -S'
alias pacins='sudo pacman -U'
alias pacre='sudo pacman -R'
alias pacrem='sudo pacman -Rns'
alias pacrep='pacman -Si'
alias pacreps='pacman -Ss'
alias pacloc='pacman -Qi'
alias paclocs='pacman -Qs'
alias pacinsd='sudo pacman -S --asdeps'
alias pacmir='sudo pacman -Syy'
alias paclsorphans='sudo pacman -Qdt'
alias pacrmorphans='sudo pacman -Rs $(pacman -Qtdq)'
alias pacfileupg='sudo pacman -Fy'
alias pacfiles='pacman -Fs'
alias pacls='pacman -Ql'
alias pacown='pacman -Qo'
if (( $+commands[abs] && $+commands[aur] )); then
alias pacupd='sudo pacman -Sy && sudo abs && sudo aur'
elif (( $+commands[abs] )); then
alias pacupd='sudo pacman -Sy && sudo abs'
elif (( $+commands[aur] )); then
alias pacupd='sudo pacman -Sy && sudo aur'
else
alias pacupd='sudo pacman -Sy'
fi
function paclist() {
# Source: https://bbs.archlinux.org/viewtopic.php?id=93683
LC_ALL=C pacman -Qei $(pacman -Qu | cut -d " " -f 1) | \
awk 'BEGIN {FS=":"} /^Name/{printf("\033[1;36m%s\033[1;37m", $2)} /^Description/{print $2}'
}
function pacdisowned() {
emulate -L zsh
tmp=${TMPDIR-/tmp}/pacman-disowned-$UID-$$
db=$tmp/db
fs=$tmp/fs
mkdir "$tmp"
trap 'rm -rf "$tmp"' EXIT
pacman -Qlq | sort -u > "$db"
find /bin /etc /lib /sbin /usr ! -name lost+found \
\( -type d -printf '%p/\n' -o -print \) | sort > "$fs"
comm -23 "$fs" "$db"
}
function pacmanallkeys() {
emulate -L zsh
curl -s https://www.archlinux.org/people/{developers,trustedusers}/ | \
awk -F\" '(/pgp.mit.edu/) { sub(/.*search=0x/,""); print $1}' | \
xargs sudo pacman-key --recv-keys
}
function pacmansignkeys() {
emulate -L zsh
for key in $*; do
sudo pacman-key --recv-keys $key
sudo pacman-key --lsign-key $key
printf 'trust\n3\n' | sudo gpg --homedir /etc/pacman.d/gnupg \
--no-permission-warning --command-fd 0 --edit-key $key
done
}
if (( $+commands[xdg-open] )); then
function pacweb() {
pkg="$1"
infos="$(pacman -Si "$pkg")"
if [[ -z "$infos" ]]; then
return
fi
repo="$(grep '^Repo' <<< "$infos" | grep -oP '[^ ]+$')"
arch="$(grep '^Arch' <<< "$infos" | grep -oP '[^ ]+$')"
xdg-open "https://www.archlinux.org/packages/$repo/$arch/$pkg/" &>/dev/null
}
fi

View File

@ -3,7 +3,7 @@ ASDF_DIR="${ASDF_DIR:-$HOME/.asdf}"
ASDF_COMPLETIONS="$ASDF_DIR/completions" ASDF_COMPLETIONS="$ASDF_DIR/completions"
# If not found, check for Homebrew package # If not found, check for Homebrew package
if [[ ! -f "$ASDF_DIR/asdf.sh" ]] && (( $+commands[brew] )); then if [[ ! -f "$ASDF_DIR/asdf.sh" || ! -f "$ASDF_COMPLETIONS/asdf.bash" ]] && (( $+commands[brew] )); then
ASDF_DIR="$(brew --prefix asdf)" ASDF_DIR="$(brew --prefix asdf)"
ASDF_COMPLETIONS="$ASDF_DIR/etc/bash_completion.d" ASDF_COMPLETIONS="$ASDF_DIR/etc/bash_completion.d"
fi fi

View File

@ -0,0 +1,20 @@
# Autoenv plugin
This plugin loads the [Autoenv](https://github.com/inishchith/autoenv).
To use it, add `autoenv` to the plugins array in your zshrc file:
```zsh
plugins=(... autoenv)
```
## Functions
* `use_env()`: creates and/or activates a virtualenv. For use in `.env` files.
See the source code for details.
## Requirements
In order to make this work, you will need to have the autoenv installed.
More info on the usage and install at [the project's homepage](https://github.com/inishchith/autoenv).

View File

@ -1,12 +1,39 @@
# Activates autoenv or reports its failure # Initialization: activate autoenv or report its absence
() { () {
local d autoenv_dir install_locations
if ! type autoenv_init >/dev/null; then if ! type autoenv_init >/dev/null; then
for d (~/.autoenv ~/.local/bin /usr/local/opt/autoenv /usr/local/bin); do # Check if activate.sh is in $PATH
if (( $+commands[activate.sh] )); then
autoenv_dir="${commands[activate.sh]:h}"
fi
# Locate autoenv installation
if [[ -z $autoenv_dir ]]; then
install_locations=(
~/.autoenv
~/.local/bin
/usr/local/opt/autoenv
/usr/local/bin
/usr/share/autoenv-git
~/Library/Python/bin
)
for d ( $install_locations ); do
if [[ -e $d/activate.sh ]]; then
autoenv_dir=$d
break
fi
done
fi
# Look for Homebrew path as a last resort
if [[ -z "$autoenv_dir" ]] && (( $+commands[brew] )); then
d=$(brew --prefix)/opt/autoenv
if [[ -e $d/activate.sh ]]; then if [[ -e $d/activate.sh ]]; then
autoenv_dir=$d autoenv_dir=$d
break
fi fi
done fi
# Complain if autoenv is not installed
if [[ -z $autoenv_dir ]]; then if [[ -z $autoenv_dir ]]; then
cat <<END >&2 cat <<END >&2
-------- AUTOENV --------- -------- AUTOENV ---------
@ -17,6 +44,7 @@ In the meantime the autoenv plugin is DISABLED.
END END
return 1 return 1
fi fi
# Load autoenv
source $autoenv_dir/activate.sh source $autoenv_dir/activate.sh
fi fi
} }
@ -27,17 +55,17 @@ fi
# It only performs an action if the requested virtualenv is not the current one. # It only performs an action if the requested virtualenv is not the current one.
use_env() { use_env() {
typeset venv local venv
venv="$1" venv="$1"
if [[ "${VIRTUAL_ENV:t}" != "$venv" ]]; then if [[ "${VIRTUAL_ENV:t}" != "$venv" ]]; then
if workon | grep -q "$venv"; then if workon | grep -q "$venv"; then
workon "$venv" workon "$venv"
else else
echo -n "Create virtualenv $venv now? (Yn) " echo -n "Create virtualenv $venv now? (Yn) "
read answer read answer
if [[ "$answer" == "Y" ]]; then if [[ "$answer" == "Y" ]]; then
mkvirtualenv "$venv" mkvirtualenv "$venv"
fi fi
fi
fi fi
fi
} }

View File

@ -8,4 +8,4 @@ To use it, add `autojump` to the plugins array in your zshrc file:
plugins=(... autojump) plugins=(... autojump)
``` ```
More info on the usage: https://github.com/wting/autojump **Note:** you have to [install autojump](https://github.com/wting/autojump#installation) first.

View File

@ -29,6 +29,6 @@ if (( ! found && $+commands[brew] )); then
fi fi
fi fi
(( ! found )) && echo '[oh-my-zsh] autojump script not found' (( ! found )) && echo '[oh-my-zsh] autojump not found. Please install it first.'
unset autojump_paths file found unset autojump_paths file found

View File

@ -15,6 +15,13 @@ plugins=(... aws)
It also sets `$AWS_EB_PROFILE` to `<profile>` for the Elastic Beanstalk CLI. It also sets `$AWS_EB_PROFILE` to `<profile>` for the Elastic Beanstalk CLI.
Run `asp` without arguments to clear the profile. Run `asp` without arguments to clear the profile.
* `acp [<profile>]`: in addition to `asp` functionality, it actually changes the profile by
assuming the role specified in the `<profile>` configuration. It supports MFA and sets
`$AWS_ACCESS_KEY_ID`, `$AWS_SECRET_ACCESS_KEY` and `$AWS_SESSION_TOKEN`, if obtained. It
requires the roles to be configured as per the
[official guide](https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-role.html).
Run `acp` without arguments to clear the profile.
* `agp`: gets the current value of `$AWS_PROFILE`. * `agp`: gets the current value of `$AWS_PROFILE`.
* `aws_change_access_key`: changes the AWS access key of a profile. * `aws_change_access_key`: changes the AWS access key of a profile.
@ -33,6 +40,36 @@ plugins=(... aws)
The plugin creates an `aws_prompt_info` function that you can use in your theme, which displays The plugin creates an `aws_prompt_info` function that you can use in your theme, which displays
the current `$AWS_PROFILE`. It uses two variables to control how that is shown: the current `$AWS_PROFILE`. It uses two variables to control how that is shown:
- ZSH_THEME_AWS_PREFIX: sets the prefix of the AWS_PROFILE. Defaults to `<aws:`. * ZSH_THEME_AWS_PREFIX: sets the prefix of the AWS_PROFILE. Defaults to `<aws:`.
- ZSH_THEME_AWS_SUFFIX: sets the suffix of the AWS_PROFILE. Defaults to `>`. * ZSH_THEME_AWS_SUFFIX: sets the suffix of the AWS_PROFILE. Defaults to `>`.
## Configuration
[Configuration and credential file settings](https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-files.html) by AWS
### Scenario: IAM roles with a source profile and MFA authentication
Source profile credentials in `~/.aws/credentials`:
```
[source-profile-name]
aws_access_key_id = ...
aws_secret_access_key = ...
```
Role configuration in `~/.aws/config`:
```
[profile source-profile-name]
mfa_serial = arn:aws:iam::111111111111:mfa/myuser
region = us-east-1
output = json
[profile profile-with-role]
role_arn = arn:aws:iam::9999999999999:role/myrole
mfa_serial = arn:aws:iam::111111111111:mfa/myuser
source_profile = source-profile-name
region = us-east-1
output = json
```

View File

@ -10,7 +10,8 @@ function asp() {
return return
fi fi
local available_profiles=($(aws_profiles)) local -a available_profiles
available_profiles=($(aws_profiles))
if [[ -z "${available_profiles[(r)$1]}" ]]; then if [[ -z "${available_profiles[(r)$1]}" ]]; then
echo "${fg[red]}Profile '$1' not found in '${AWS_CONFIG_FILE:-$HOME/.aws/config}'" >&2 echo "${fg[red]}Profile '$1' not found in '${AWS_CONFIG_FILE:-$HOME/.aws/config}'" >&2
echo "Available profiles: ${(j:, :)available_profiles:-no profiles found}${reset_color}" >&2 echo "Available profiles: ${(j:, :)available_profiles:-no profiles found}${reset_color}" >&2
@ -22,31 +23,131 @@ function asp() {
export AWS_EB_PROFILE=$1 export AWS_EB_PROFILE=$1
} }
# AWS profile switch
function acp() {
if [[ -z "$1" ]]; then
unset AWS_DEFAULT_PROFILE AWS_PROFILE AWS_EB_PROFILE
unset AWS_ACCESS_KEY_ID AWS_SECRET_ACCESS_KEY AWS_SESSION_TOKEN
echo AWS profile cleared.
return
fi
local -a available_profiles
available_profiles=($(aws_profiles))
if [[ -z "${available_profiles[(r)$1]}" ]]; then
echo "${fg[red]}Profile '$1' not found in '${AWS_CONFIG_FILE:-$HOME/.aws/config}'" >&2
echo "Available profiles: ${(j:, :)available_profiles:-no profiles found}${reset_color}" >&2
return 1
fi
local profile="$1"
# Get fallback credentials for if the aws command fails or no command is run
local aws_access_key_id="$(aws configure get aws_access_key_id --profile $profile)"
local aws_secret_access_key="$(aws configure get aws_secret_access_key --profile $profile)"
local aws_session_token="$(aws configure get aws_session_token --profile $profile)"
# First, if the profile has MFA configured, lets get the token and session duration
local mfa_serial="$(aws configure get mfa_serial --profile $profile)"
local sess_duration="$(aws configure get duration_seconds --profile $profile)"
if [[ -n "$mfa_serial" ]]; then
local -a mfa_opt
local mfa_token
echo -n "Please enter your MFA token for $mfa_serial: "
read -r mfa_token
if [[ -z "$sess_duration" ]]; then
echo -n "Please enter the session duration in seconds (900-43200; default: 3600, which is the default maximum for a role): "
read -r sess_duration
fi
mfa_opt=(--serial-number "$mfa_serial" --token-code "$mfa_token" --duration-seconds "${sess_duration:-3600}")
# Now see whether we need to just MFA for the current role, or assume a different one
local role_arn="$(aws configure get role_arn --profile $profile)"
local sess_name="$(aws configure get role_session_name --profile $profile)"
if [[ -n "$role_arn" ]]; then
# Means we need to assume a specified role
aws_command=(aws sts assume-role --role-arn "$role_arn" "${mfa_opt[@]}")
# Check whether external_id is configured to use while assuming the role
local external_id="$(aws configure get external_id --profile $profile)"
if [[ -n "$external_id" ]]; then
aws_command+=(--external-id "$external_id")
fi
# Get source profile to use to assume role
local source_profile="$(aws configure get source_profile --profile $profile)"
if [[ -z "$sess_name" ]]; then
sess_name="${source_profile:-profile}"
fi
aws_command+=(--profile="${source_profile:-profile}" --role-session-name "${sess_name}")
echo "Assuming role $role_arn using profile ${source_profile:-profile}"
else
# Means we only need to do MFA
aws_command=(aws sts get-session-token --profile="$profile" "${mfa_opt[@]}")
echo "Obtaining session token for profile $profile"
fi
# Format output of aws command for easier processing
aws_command+=(--query '[Credentials.AccessKeyId,Credentials.SecretAccessKey,Credentials.SessionToken]' --output text)
# Run the aws command to obtain credentials
local -a credentials
credentials=(${(ps:\t:)"$(${aws_command[@]})"})
if [[ -n "$credentials" ]]; then
aws_access_key_id="${credentials[1]}"
aws_secret_access_key="${credentials[2]}"
aws_session_token="${credentials[3]}"
fi
fi
# Switch to AWS profile
if [[ -n "${aws_access_key_id}" && -n "$aws_secret_access_key" ]]; then
export AWS_DEFAULT_PROFILE="$profile"
export AWS_PROFILE="$profile"
export AWS_EB_PROFILE="$profile"
export AWS_ACCESS_KEY_ID="$aws_access_key_id"
export AWS_SECRET_ACCESS_KEY="$aws_secret_access_key"
if [[ -n "$aws_session_token" ]]; then
export AWS_SESSION_TOKEN="$aws_session_token"
else
unset AWS_SESSION_TOKEN
fi
echo "Switched to AWS Profile: $profile"
fi
}
function aws_change_access_key() { function aws_change_access_key() {
if [[ -z "$1" ]]; then if [[ -z "$1" ]]; then
echo "usage: $0 <profile>" echo "usage: $0 <profile>"
return 1 return 1
fi fi
echo Insert the credentials when asked. echo "Insert the credentials when asked."
asp "$1" || return 1 asp "$1" || return 1
aws iam create-access-key AWS_PAGER="" aws iam create-access-key
aws configure --profile "$1" AWS_PAGER="" aws configure --profile "$1"
echo You can now safely delete the old access key running \`aws iam delete-access-key --access-key-id ID\` echo "You can now safely delete the old access key running \`aws iam delete-access-key --access-key-id ID\`"
echo Your current keys are: echo "Your current keys are:"
aws iam list-access-keys AWS_PAGER="" aws iam list-access-keys
} }
function aws_profiles() { function aws_profiles() {
[[ -r "${AWS_CONFIG_FILE:-$HOME/.aws/config}" ]] || return 1 [[ -r "${AWS_CONFIG_FILE:-$HOME/.aws/config}" ]] || return 1
grep '\[profile' "${AWS_CONFIG_FILE:-$HOME/.aws/config}"|sed -e 's/.*profile \([a-zA-Z0-9_\.-]*\).*/\1/' grep --color=never -Eo '\[.*\]' "${AWS_CONFIG_FILE:-$HOME/.aws/config}" | sed -E 's/^[[:space:]]*\[(profile)?[[:space:]]*([-_[:alnum:]\.@]+)\][[:space:]]*$/\2/g'
} }
function _aws_profiles() { function _aws_profiles() {
reply=($(aws_profiles)) reply=($(aws_profiles))
} }
compctl -K _aws_profiles asp aws_change_access_key compctl -K _aws_profiles asp acp aws_change_access_key
# AWS prompt # AWS prompt
function aws_prompt_info() { function aws_prompt_info() {
@ -54,43 +155,52 @@ function aws_prompt_info() {
echo "${ZSH_THEME_AWS_PREFIX:=<aws:}${AWS_PROFILE}${ZSH_THEME_AWS_SUFFIX:=>}" echo "${ZSH_THEME_AWS_PREFIX:=<aws:}${AWS_PROFILE}${ZSH_THEME_AWS_SUFFIX:=>}"
} }
if [ "$SHOW_AWS_PROMPT" != false ]; then if [[ "$SHOW_AWS_PROMPT" != false && "$RPROMPT" != *'$(aws_prompt_info)'* ]]; then
RPROMPT='$(aws_prompt_info)'"$RPROMPT" RPROMPT='$(aws_prompt_info)'"$RPROMPT"
fi fi
# Load awscli completions # Load awscli completions
function _awscli-homebrew-installed() { # AWS CLI v2 comes with its own autocompletion. Check if that is there, otherwise fall back
# check if Homebrew is installed if command -v aws_completer &> /dev/null; then
(( $+commands[brew] )) || return 1 autoload -Uz bashcompinit && bashcompinit
complete -C aws_completer aws
else
function _awscli-homebrew-installed() {
# check if Homebrew is installed
(( $+commands[brew] )) || return 1
# speculatively check default brew prefix # speculatively check default brew prefix
if [ -h /usr/local/opt/awscli ]; then if [ -h /usr/local/opt/awscli ]; then
_brew_prefix=/usr/local/opt/awscli _brew_prefix=/usr/local/opt/awscli
else else
# ok, it is not in the default prefix # ok, it is not in the default prefix
# this call to brew is expensive (about 400 ms), so at least let's make it only once # this call to brew is expensive (about 400 ms), so at least let's make it only once
_brew_prefix=$(brew --prefix awscli) _brew_prefix=$(brew --prefix awscli)
fi
}
# get aws_zsh_completer.sh location from $PATH
_aws_zsh_completer_path="$commands[aws_zsh_completer.sh]"
# otherwise check common locations
if [[ -z $_aws_zsh_completer_path ]]; then
# Homebrew
if _awscli-homebrew-installed; then
_aws_zsh_completer_path=$_brew_prefix/libexec/bin/aws_zsh_completer.sh
# Ubuntu
elif [[ -e /usr/share/zsh/vendor-completions/_awscli ]]; then
_aws_zsh_completer_path=/usr/share/zsh/vendor-completions/_awscli
# NixOS
elif [[ -e "${commands[aws]:P:h:h}/share/zsh/site-functions/aws_zsh_completer.sh" ]]; then
_aws_zsh_completer_path="${commands[aws]:P:h:h}/share/zsh/site-functions/aws_zsh_completer.sh"
# RPM
else
_aws_zsh_completer_path=/usr/share/zsh/site-functions/aws_zsh_completer.sh
fi
fi fi
}
# get aws_zsh_completer.sh location from $PATH [[ -r $_aws_zsh_completer_path ]] && source $_aws_zsh_completer_path
_aws_zsh_completer_path="$commands[aws_zsh_completer.sh]" unset _aws_zsh_completer_path _brew_prefix
# otherwise check common locations
if [[ -z $_aws_zsh_completer_path ]]; then
# Homebrew
if _awscli-homebrew-installed; then
_aws_zsh_completer_path=$_brew_prefix/libexec/bin/aws_zsh_completer.sh
# Ubuntu
elif [[ -e /usr/share/zsh/vendor-completions/_awscli ]]; then
_aws_zsh_completer_path=/usr/share/zsh/vendor-completions/_awscli
# RPM
else
_aws_zsh_completer_path=/usr/share/zsh/site-functions/aws_zsh_completer.sh
fi
fi fi
[[ -r $_aws_zsh_completer_path ]] && source $_aws_zsh_completer_path
unset _aws_zsh_completer_path _brew_prefix

View File

@ -9,5 +9,14 @@ To use, add `battery` to the list of plugins in your `.zshrc` file:
Then, add the `battery_pct_prompt` function to your custom theme. For example: Then, add the `battery_pct_prompt` function to your custom theme. For example:
``` ```
RPROMPT='$(battery_pct_prompt)' RPROMPT='$(battery_pct_prompt) ...'
```
## Requirements
On Linux, you must have the `acpi` tool installed on your operating system.
Here's an example of how to install with apt:
```
sudo apt-get install acpi
``` ```

View File

@ -7,23 +7,22 @@
# Email: neuralsandwich@gmail.com # # Email: neuralsandwich@gmail.com #
# Modified to add support for Apple Mac # # Modified to add support for Apple Mac #
########################################### ###########################################
# Author: J (927589452) #
# Modified to add support for FreeBSD #
###########################################
if [[ "$OSTYPE" = darwin* ]] ; then if [[ "$OSTYPE" = darwin* ]]; then
function battery_pct() { function battery_is_charging() {
local smart_battery_status="$(ioreg -rc "AppleSmartBattery")" ioreg -rc AppleSmartBattery | command grep -q '^.*"ExternalConnected"\ =\ Yes'
typeset -F maxcapacity=$(echo $smart_battery_status | grep '^.*"MaxCapacity"\ =\ ' | sed -e 's/^.*"MaxCapacity"\ =\ //')
typeset -F currentcapacity=$(echo $smart_battery_status | grep '^.*"CurrentCapacity"\ =\ ' | sed -e 's/^.*CurrentCapacity"\ =\ //')
integer i=$(((currentcapacity/maxcapacity) * 100))
echo $i
} }
function plugged_in() { function battery_pct() {
[ $(ioreg -rc AppleSmartBattery | grep -c '^.*"ExternalConnected"\ =\ Yes') -eq 1 ] pmset -g batt | grep -Eo "\d+%" | cut -d% -f1
} }
function battery_pct_remaining() { function battery_pct_remaining() {
if plugged_in ; then if battery_is_charging; then
echo "External Power" echo "External Power"
else else
battery_pct battery_pct
@ -32,9 +31,9 @@ if [[ "$OSTYPE" = darwin* ]] ; then
function battery_time_remaining() { function battery_time_remaining() {
local smart_battery_status="$(ioreg -rc "AppleSmartBattery")" local smart_battery_status="$(ioreg -rc "AppleSmartBattery")"
if [[ $(echo $smart_battery_status | grep -c '^.*"ExternalConnected"\ =\ No') -eq 1 ]] ; then if [[ $(echo $smart_battery_status | command grep -c '^.*"ExternalConnected"\ =\ No') -eq 1 ]]; then
timeremaining=$(echo $smart_battery_status | grep '^.*"AvgTimeToEmpty"\ =\ ' | sed -e 's/^.*"AvgTimeToEmpty"\ =\ //') timeremaining=$(echo $smart_battery_status | command grep '^.*"AvgTimeToEmpty"\ =\ ' | sed -e 's/^.*"AvgTimeToEmpty"\ =\ //')
if [ $timeremaining -gt 720 ] ; then if [ $timeremaining -gt 720 ]; then
echo "::" echo "::"
else else
echo "~$((timeremaining / 60)):$((timeremaining % 60))" echo "~$((timeremaining / 60)):$((timeremaining % 60))"
@ -45,39 +44,36 @@ if [[ "$OSTYPE" = darwin* ]] ; then
} }
function battery_pct_prompt () { function battery_pct_prompt () {
if [[ $(ioreg -rc AppleSmartBattery | grep -c '^.*"ExternalConnected"\ =\ No') -eq 1 ]] ; then local battery_pct color
b=$(battery_pct_remaining) if ioreg -rc AppleSmartBattery | command grep -q '^.*"ExternalConnected"\ =\ No'; then
if [ $b -gt 50 ] ; then battery_pct=$(battery_pct_remaining)
if [[ $battery_pct -gt 50 ]]; then
color='green' color='green'
elif [ $b -gt 20 ] ; then elif [[ $battery_pct -gt 20 ]]; then
color='yellow' color='yellow'
else else
color='red' color='red'
fi fi
echo "%{$fg[$color]%}[$(battery_pct_remaining)%%]%{$reset_color%}" echo "%{$fg[$color]%}[${battery_pct}%%]%{$reset_color%}"
else else
echo "∞" echo "∞"
fi fi
} }
function battery_is_charging() { elif [[ "$OSTYPE" = freebsd* ]]; then
[[ $(ioreg -rc "AppleSmartBattery"| grep '^.*"IsCharging"\ =\ ' | sed -e 's/^.*"IsCharging"\ =\ //') == "Yes" ]]
}
elif [[ "$OSTYPE" = linux* ]] ; then
function battery_is_charging() { function battery_is_charging() {
! [[ $(acpi 2>/dev/null | grep -c '^Battery.*Discharging') -gt 0 ]] [[ $(sysctl -n hw.acpi.battery.state) -eq 2 ]]
} }
function battery_pct() { function battery_pct() {
if (( $+commands[acpi] )) ; then if (( $+commands[sysctl] )); then
echo "$(acpi 2>/dev/null | cut -f2 -d ',' | tr -cd '[:digit:]')" sysctl -n hw.acpi.battery.life
fi fi
} }
function battery_pct_remaining() { function battery_pct_remaining() {
if [ ! $(battery_is_charging) ] ; then if ! battery_is_charging; then
battery_pct battery_pct
else else
echo "External Power" echo "External Power"
@ -85,76 +81,128 @@ elif [[ "$OSTYPE" = linux* ]] ; then
} }
function battery_time_remaining() { function battery_time_remaining() {
if [[ $(acpi 2>/dev/null | grep -c '^Battery.*Discharging') -gt 0 ]] ; then local remaining_time
echo $(acpi 2>/dev/null | cut -f3 -d ',') remaining_time=$(sysctl -n hw.acpi.battery.time)
if [[ $remaining_time -ge 0 ]]; then
((hour = $remaining_time / 60 ))
((minute = $remaining_time % 60 ))
printf %02d:%02d $hour $minute
fi fi
} }
function battery_pct_prompt() { function battery_pct_prompt() {
b=$(battery_pct_remaining) local battery_pct color
if [[ $(acpi 2>/dev/null | grep -c '^Battery.*Discharging') -gt 0 ]] ; then battery_pct=$(battery_pct_remaining)
if [ $b -gt 50 ] ; then if battery_is_charging; then
echo "∞"
else
if [[ $battery_pct -gt 50 ]]; then
color='green' color='green'
elif [ $b -gt 20 ] ; then elif [[ $battery_pct -gt 20 ]]; then
color='yellow' color='yellow'
else else
color='red' color='red'
fi fi
echo "%{$fg[$color]%}$(battery_pct_remaining)%%%{$reset_color%}" echo "%{$fg[$color]%}${battery_pct}%%%{$reset_color%}"
fi
}
elif [[ "$OSTYPE" = linux* ]]; then
function battery_is_charging() {
! acpi 2>/dev/null | command grep -v "rate information unavailable" | command grep -q '^Battery.*Discharging'
}
function battery_pct() {
if (( $+commands[acpi] )); then
acpi 2>/dev/null | command grep -v "rate information unavailable" | command grep -E '^Battery.*(Full|(Disc|C)harging)' | cut -f2 -d ',' | tr -cd '[:digit:]'
fi
}
function battery_pct_remaining() {
if ! battery_is_charging; then
battery_pct
else else
echo "External Power"
fi
}
function battery_time_remaining() {
if ! battery_is_charging; then
acpi 2>/dev/null | command grep -v "rate information unavailable" | cut -f3 -d ','
fi
}
function battery_pct_prompt() {
local battery_pct color
battery_pct=$(battery_pct_remaining)
if battery_is_charging; then
echo "∞" echo "∞"
else
if [[ $battery_pct -gt 50 ]]; then
color='green'
elif [[ $battery_pct -gt 20 ]]; then
color='yellow'
else
color='red'
fi
echo "%{$fg[$color]%}${battery_pct}%%%{$reset_color%}"
fi fi
} }
else else
# Empty functions so we don't cause errors in prompts # Empty functions so we don't cause errors in prompts
function battery_pct_remaining() { function battery_is_charging { false }
} function battery_pct \
battery_pct_remaining \
function battery_time_remaining() { battery_time_remaining \
} battery_pct_prompt { }
function battery_pct_prompt() {
}
fi fi
function battery_level_gauge() { function battery_level_gauge() {
local gauge_slots=${BATTERY_GAUGE_SLOTS:-10}; local gauge_slots=${BATTERY_GAUGE_SLOTS:-10}
local green_threshold=${BATTERY_GREEN_THRESHOLD:-6}; local green_threshold=${BATTERY_GREEN_THRESHOLD:-$(( gauge_slots * 0.6 ))}
local yellow_threshold=${BATTERY_YELLOW_THRESHOLD:-4}; local yellow_threshold=${BATTERY_YELLOW_THRESHOLD:-$(( gauge_slots * 0.4 ))}
local color_green=${BATTERY_COLOR_GREEN:-%F{green}}; local color_green=${BATTERY_COLOR_GREEN:-%F{green}}
local color_yellow=${BATTERY_COLOR_YELLOW:-%F{yellow}}; local color_yellow=${BATTERY_COLOR_YELLOW:-%F{yellow}}
local color_red=${BATTERY_COLOR_RED:-%F{red}}; local color_red=${BATTERY_COLOR_RED:-%F{red}}
local color_reset=${BATTERY_COLOR_RESET:-%{%f%k%b%}}; local color_reset=${BATTERY_COLOR_RESET:-%{%f%k%b%}}
local battery_prefix=${BATTERY_GAUGE_PREFIX:-'['}; local battery_prefix=${BATTERY_GAUGE_PREFIX:-'['}
local battery_suffix=${BATTERY_GAUGE_SUFFIX:-']'}; local battery_suffix=${BATTERY_GAUGE_SUFFIX:-']'}
local filled_symbol=${BATTERY_GAUGE_FILLED_SYMBOL:-'▶'}; local filled_symbol=${BATTERY_GAUGE_FILLED_SYMBOL:-'▶'}
local empty_symbol=${BATTERY_GAUGE_EMPTY_SYMBOL:-'▷'}; local empty_symbol=${BATTERY_GAUGE_EMPTY_SYMBOL:-'▷'}
local charging_color=${BATTERY_CHARGING_COLOR:-$color_yellow}; local charging_color=${BATTERY_CHARGING_COLOR:-$color_yellow}
local charging_symbol=${BATTERY_CHARGING_SYMBOL:-'⚡'}; local charging_symbol=${BATTERY_CHARGING_SYMBOL:-'⚡'}
local battery_remaining_percentage=$(battery_pct); local battery_remaining_percentage=$(battery_pct)
local filled empty gauge_color
if [[ $battery_remaining_percentage =~ [0-9]+ ]]; then if [[ $battery_remaining_percentage =~ [0-9]+ ]]; then
local filled=$(((( $battery_remaining_percentage + $gauge_slots - 1) / $gauge_slots))); filled=$(( ($battery_remaining_percentage * $gauge_slots) / 100 ))
local empty=$(($gauge_slots - $filled)); empty=$(( $gauge_slots - $filled ))
if [[ $filled -gt $green_threshold ]]; then local gauge_color=$color_green; if [[ $filled -gt $green_threshold ]]; then
elif [[ $filled -gt $yellow_threshold ]]; then local gauge_color=$color_yellow; gauge_color=$color_green
else local gauge_color=$color_red; elif [[ $filled -gt $yellow_threshold ]]; then
gauge_color=$color_yellow
else
gauge_color=$color_red
fi fi
else else
local filled=$gauge_slots; filled=$gauge_slots
local empty=0; empty=0
filled_symbol=${BATTERY_UNKNOWN_SYMBOL:-'.'}; filled_symbol=${BATTERY_UNKNOWN_SYMBOL:-'.'}
fi fi
local charging=' ' && battery_is_charging && charging=$charging_symbol; local charging=' '
battery_is_charging && charging=$charging_symbol
printf ${charging_color//\%/\%\%}$charging${color_reset//\%/\%\%}${battery_prefix//\%/\%\%}${gauge_color//\%/\%\%} # Charging status and prefix
printf ${filled_symbol//\%/\%\%}'%.0s' {1..$filled} print -n ${charging_color}${charging}${color_reset}${battery_prefix}${gauge_color}
# Filled slots
[[ $filled -gt 0 ]] && printf ${filled_symbol//\%/\%\%}'%.0s' {1..$filled}
# Empty slots
[[ $filled -lt $gauge_slots ]] && printf ${empty_symbol//\%/\%\%}'%.0s' {1..$empty} [[ $filled -lt $gauge_slots ]] && printf ${empty_symbol//\%/\%\%}'%.0s' {1..$empty}
printf ${color_reset//\%/\%\%}${battery_suffix//\%/\%\%}${color_reset//\%/\%\%} # Suffix
print -n ${color_reset}${battery_suffix}${color_reset}
} }

View File

@ -0,0 +1,5 @@
## Bazel autocomplete plugin
A copy of the completion script from the
[bazelbuild/bazel](https://github.com/bazelbuild/bazel/master/scripts/zsh_completion/_bazel)
git repo.

341
zsh/plugins/bazel/_bazel Normal file
View File

@ -0,0 +1,341 @@
#compdef bazel
# Copyright 2015 The Bazel Authors. All rights reserved.
#
# Licensed 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.
# Installation
# ------------
#
# 1. Add this script to a directory on your $fpath:
# fpath[1,0]=~/.zsh/completion/
# mkdir -p ~/.zsh/completion/
# cp scripts/zsh_completion/_bazel ~/.zsh/completion
#
# 2. Optionally, add the following to your .zshrc.
# zstyle ':completion:*' use-cache on
# zstyle ':completion:*' cache-path ~/.zsh/cache
#
# This way, the completion script does not have to parse Bazel's options
# repeatedly. The directory in cache-path must be created manually.
#
# 3. Restart the shell
#
# Options
# -------
# completion:init:bazel:* cache-lifetime
# Lifetime for the completion cache (if turned on, default: 1 week)
local curcontext="$curcontext" state line
: ${BAZEL_COMPLETION_PACKAGE_PATH:=%workspace%}
: ${BAZEL:=bazel}
_bazel_b() { ${BAZEL} --noblock_for_lock "$@" 2>/dev/null; }
# Default cache lifetime is 1 week
zstyle -s ":completion:${curcontext}:" cache-lifetime lifetime
if [[ -z "${lifetime}" ]]; then
lifetime=$((60*60*24*7))
fi
_bazel_cache_policy() {
local -a oldp
oldp=( "$1"(Nms+${lifetime}) )
(( $#oldp ))
}
_set_cache_policy() {
zstyle -s ":completion:*:$curcontext*" cache-policy update_policy
if [[ -z "$update_policy" ]]; then
zstyle ":completion:$curcontext*" cache-policy _bazel_cache_policy
fi
}
# Skips over all global arguments. After invocation, OFFSET contains the
# position of the bazel command in $words.
_adapt_subcommand_offset() {
OFFSET=2
for w in ${words[2,-1]}; do
if [[ $w == (#b)-* ]]; then
(( OFFSET++ ))
else
return
fi
done
}
# Retrieve the cache but also check that the value is not empty.
_bazel_safe_retrieve_cache() {
_retrieve_cache $1 && [[ ${(P)#2} -gt 0 ]]
}
# Puts the name of the variable that contains the options for the bazel
# subcommand handed in as the first argument into the global variable
# _bazel_cmd_options.
_bazel_get_options() {
local lcmd=$1
_bazel_cmd_options=_bazel_${lcmd}_options
_bazel_cmd_args=_bazel_${lcmd}_args
if [[ ${(P)#_bazel_cmd_options} != 0 ]]; then
return
fi
if _cache_invalid BAZEL_${lcmd}_options || _cache_invalid BAZEL_${lcmd}_args \
|| ! _bazel_safe_retrieve_cache BAZEL_${lcmd}_options ${_bazel_cmd_options} \
|| ! _retrieve_cache BAZEL_${lcmd}_args ${_bazel_cmd_args}; then
if ! eval "$(_bazel_b help completion)"; then
return
fi
local opts_var
if [[ $lcmd == "startup_options" ]]; then
opts_var="BAZEL_STARTUP_OPTIONS"
else
opts_var="BAZEL_COMMAND_${lcmd:u}_FLAGS"
fi
local -a raw_options
if ! eval "raw_options=(\${(@f)$opts_var})"; then
return
fi
local -a option_list
for opt in $raw_options; do
case $opt in
--*"={"*)
local lst="${${opt##*"={"}%"}"}"
local opt="${opt%%=*}="
option_list+=("${opt}:string:_values '' ${lst//,/ }") ;;
--*=path)
option_list+=("${opt%path}:path:_files") ;;
--*=label)
option_list+=("${opt%label}:target:_bazel_complete_target") ;;
--*=*)
option_list+=("${opt}:string:") ;;
*)
option_list+=("$opt") ;;
esac
done
local -a cmd_args
local cmd_type
if eval "cmd_type=\${BAZEL_COMMAND_${lcmd:u}_ARGUMENT}" && [[ -n $cmd_type ]]; then
case $cmd_type in
label|label-*)
cmd_args+=("*::${cmd_type}:_bazel_complete_target_${cmd_type//-/_}") ;;
info-key)
cmd_args+=('1::key:_bazel_info_key') ;;
path)
cmd_args+=('1::profile:_path_files') ;;
"command|{"*"}")
local lst=${${cmd_type#"command|{"}%"}"}
cmd_args+=("1::topic:_bazel_help_topic -- ${lst//,/ }") ;;
esac
fi
typeset -g "${_bazel_cmd_options}"="${(pj:|:)option_list[*]}"
_store_cache BAZEL_${lcmd}_options ${_bazel_cmd_options}
typeset -g "${_bazel_cmd_args}"="${(pj:|:)cmd_args[*]}"
_store_cache BAZEL_${lcmd}_args ${_bazel_cmd_args}
fi
}
_get_build_targets() {
local pkg=$1
local rule_re
typeset -a completions
case $target_type in
test)
rule_re=".*_test"
;;
build)
rule_re=".*"
;;
bin)
rule_re=".*_test|.*_binary"
;;
esac
completions=(${$(_bazel_b query "kind(\"${rule_re}\", ${pkg}:all)" 2>/dev/null)##*:})
if ( (( ${#completions} > 0 )) && [[ $target_type != run ]] ); then
completions+=(all)
fi
echo ${completions[*]}
}
# Returns all packages that match $PREFIX. PREFIX may start with //, in which
# case the workspace roots are searched. Otherwise, they are completed based on
# PWD.
_get_build_packages() {
local workspace pfx
typeset -a package_roots paths final_paths
workspace=$PWD
package_roots=(${(ps.:.)BAZEL_COMPLETION_PACKAGE_PATH})
package_roots=(${^package_roots//\%workspace\%/$workspace})
if [[ "${(e)PREFIX}" == //* ]]; then
pfx=${(e)PREFIX[2,-1]}
else
pfx=${(e)PREFIX}
fi
paths=(${^package_roots}/${pfx}*(/))
for p in ${paths[*]}; do
if [[ -f ${p}/BUILD || -f ${p}/BUILD.bazel ]]; then
final_paths+=(${p##*/}:)
fi
final_paths+=(${p##*/}/)
done
echo ${final_paths[*]}
}
_package_remove_slash() {
if [[ $KEYS == ':' && $LBUFFER == */ ]]; then
LBUFFER=${LBUFFER[1,-2]}
fi
}
# Completion function for BUILD targets, called by the completion system.
_bazel_complete_target() {
local expl
typeset -a packages targets
if [[ "${(e)PREFIX}" != *:* ]]; then
# There is no : in the prefix, completion can be either
# a package or a target, if the cwd is a package itself.
if [[ -f $PWD/BUILD || -f $PWD/BUILD.bazel ]]; then
targets=($(_get_build_targets ""))
_description build_target expl "BUILD target"
compadd "${expl[@]}" -a targets
fi
packages=($(_get_build_packages))
_description build_package expl "BUILD package"
# Chop of the leading path segments from the prefix for display.
compset -P '*/'
compadd -R _package_remove_slash -S '' "${expl[@]}" -a packages
else
targets=($(_get_build_targets "${${(e)PREFIX}%:*}"))
_description build_target expl "BUILD target"
# Ignore the current prefix for the upcoming completion, since we only list
# the names of the targets, not the full path.
compset -P '*:'
compadd "${expl[@]}" -a targets
fi
}
_bazel_complete_target_label() {
typeset -g target_type=build
_bazel_complete_target
}
_bazel_complete_target_label_test() {
typeset -g target_type=test
_bazel_complete_target
}
_bazel_complete_target_label_bin() {
typeset -g target_type=bin
_bazel_complete_target
}
### Actual completion commands
_bazel() {
_adapt_subcommand_offset
if (( CURRENT - OFFSET > 0 )); then
# Remember the subcommand name, stored globally so we can access it
# from any subsequent function
cmd=${words[OFFSET]//-/_}
# Set the context for the subcommand.
curcontext="${curcontext%:*:*}:bazel-$cmd:"
_set_cache_policy
# Narrow the range of words we are looking at to exclude cmd
# name and any leading options
(( CURRENT = CURRENT - OFFSET + 1 ))
shift $((OFFSET - 1)) words
# Run the completion for the subcommand
_bazel_get_options $cmd
_arguments : \
${(Pps:|:)_bazel_cmd_options} \
${(Pps:|:)_bazel_cmd_args}
else
_set_cache_policy
# Start special handling for global options,
# which can be retrieved by calling
# $ bazel help startup_options
_bazel_get_options startup_options
_arguments : \
${(Pps:|:)_bazel_cmd_options} \
"*:commands:_bazel_commands"
fi
return
}
_get_commands() {
# bazel_cmd_list is a global (g) array (a)
typeset -ga _bazel_cmd_list
# Use `bazel help` instead of `bazel help completion` to get command
# descriptions.
if _bazel_cmd_list=("${(@f)$(_bazel_b help | awk '
/Available commands/ { command=1; }
/ [-a-z]+[ \t]+.+/ { if (command) { printf "%s:", $1; for (i=2; i<=NF; i++) printf "%s ", $i; print "" } }
/^$/ { command=0; }')}"); then
_store_cache BAZEL_commands _bazel_cmd_list
fi
}
# Completion function for bazel subcommands, called by the completion system.
_bazel_commands() {
if [[ ${#_bazel_cmd_list} == 0 ]]; then
if _cache_invalid BAZEL_commands \
|| ! _bazel_safe_retrieve_cache BAZEL_commands _bazel_cmd_list; then
_get_commands
fi
fi
_describe -t bazel-commands 'Bazel command' _bazel_cmd_list
}
# Completion function for bazel help options, called by the completion system.
_bazel_help_topic() {
if [[ ${#_bazel_cmd_list} == 0 ]]; then
if _cache_invalid BAZEL_commands \
|| ! _bazel_safe_retrieve_cache BAZEL_commands _bazel_cmd_list; then
_get_commands
fi
fi
while [[ $# -gt 0 ]]; do
if [[ $1 == -- ]]; then
shift
break
fi
shift
done
_bazel_help_list=($@)
_bazel_help_list+=($_bazel_cmd_list)
_describe -t bazel-help 'Help topic' _bazel_help_list
}
# Completion function for bazel info keys, called by the completion system.
_bazel_info_key() {
if [[ ${#_bazel_info_keys_list} == 0 ]]; then
if _cache_invalid BAZEL_info_keys \
|| ! _bazel_safe_retrieve_cache BAZEL_info_keys _bazel_info_keys_list; then
typeset -ga _bazel_info_keys_list
# Use `bazel help` instead of `bazel help completion` to get info-key
# descriptions.
if _bazel_info_keys_list=("${(@f)$(_bazel_b help info-keys | awk '
{ printf "%s:", $1; for (i=2; i<=NF; i++) printf "%s ", $i; print "" }')}"); then
_store_cache BAZEL_info_keys _bazel_info_keys_list
fi
fi
fi
_describe -t bazel-info 'Key' _bazel_info_keys_list
}

View File

@ -53,7 +53,7 @@ bgnotify () { ## args: (title, subtitle)
bgnotify_begin() { bgnotify_begin() {
bgnotify_timestamp=$EPOCHSECONDS bgnotify_timestamp=$EPOCHSECONDS
bgnotify_lastcmd="$1" bgnotify_lastcmd="${1:-$2}"
bgnotify_windowid=$(currentWindowId) bgnotify_windowid=$(currentWindowId)
} }

View File

@ -4,7 +4,7 @@ This plugin adds completion for [Bower](https://bower.io/) and a few useful alia
To use it, add `bower` to the plugins array in your zshrc file: To use it, add `bower` to the plugins array in your zshrc file:
``` ```zsh
plugins=(... bower) plugins=(... bower)
``` ```
@ -15,4 +15,3 @@ plugins=(... bower)
| bi | `bower install` | Installs the project dependencies listed in bower.json | | bi | `bower install` | Installs the project dependencies listed in bower.json |
| bl | `bower list` | List local packages and possible updates | | bl | `bower list` | List local packages and possible updates |
| bs | `bower search` | Finds all packages or a specific package. | | bs | `bower search` | Finds all packages or a specific package. |

View File

@ -3,19 +3,28 @@
The plugin adds several aliases for common [brew](https://brew.sh) commands. The plugin adds several aliases for common [brew](https://brew.sh) commands.
To use it, add `brew` to the plugins array of your zshrc file: To use it, add `brew` to the plugins array of your zshrc file:
```
```zsh
plugins=(... brew) plugins=(... brew)
``` ```
## Aliases ## Aliases
| Alias | Command | Description | | Alias | Command | Description |
|--------|----------------------|---------------| |----------|---------------------------------------|---------------------------------------------------------------------|
| brewp | `brew pin` | Pin a specified formulae, preventing them from being upgraded when issuing the brew upgrade <formulae> command. | | `brewp` | `brew pin` | Pin a specified formula so that it's not upgraded. |
| brews | `brew list -1` | List installed formulae, one entry per line, or the installed files for a given formulae. | | `brews` | `brew list -1` | List installed formulae or the installed files for a given formula. |
| brewsp | `brew list --pinned` | Show the versions of pinned formulae, or only the specified (pinned) formulae if formulae are given. | | `brewsp` | `brew list --pinned` | List pinned formulae, or show the version of a given formula. |
| bubo | `brew update && brew outdated` | Fetch the newest version of Homebrew and all formulae, then list outdated formulae. | | `bubo` | `brew update && brew outdated` | Update Homebrew data, then list outdated formulae and casks. |
| 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. | | `bubc` | `brew upgrade && brew cleanup` | Upgrade outdated formulae and casks, then run cleanup. |
| bubu | `bubo && bubc` | Updates Homebrew, lists outdated formulae, upgrades oudated and unpinned formulae, and removes stale and outdated downloads and versions. | | `bubu` | `bubo && bubc` | Do the last two operations above. |
| bcubo | `brew update && brew cask outdated` | Fetch the newest version of Homebrew and all formulae, then list outdated casks. | | `buf` | `brew upgrade --formula` | Upgrade only formulas (not casks). |
| bcubc | `brew cask reinstall $(brew cask outdated) && brew cleanup` | Updates outdated casks, then runs cleanup. | | `bcubo` | `brew update && brew outdated --cask` | Update Homebrew data, then list outdated casks. |
| `bcubc` | `brew upgrade --cask && brew cleanup` | Update outdated casks, then run cleanup. |
## Completion
With the release of Homebrew 1.0, they decided to bundle the zsh completion as part of the
brew installation, so we no longer ship it with the brew plugin; now it only has brew
aliases. If you find that brew completion no longer works, make sure you have your Homebrew
installation fully up to date.

View File

@ -4,21 +4,6 @@ alias brewsp='brew list --pinned'
alias bubo='brew update && brew outdated' alias bubo='brew update && brew outdated'
alias bubc='brew upgrade && brew cleanup' alias bubc='brew upgrade && brew cleanup'
alias bubu='bubo && bubc' alias bubu='bubo && bubc'
alias bcubo='brew update && brew cask outdated' alias buf='brew upgrade --formula'
alias bcubc='brew cask reinstall $(brew cask outdated) && brew cleanup' alias bcubo='brew update && brew outdated --cask'
alias bcubc='brew upgrade --cask && brew cleanup'
if command mkdir "$ZSH_CACHE_DIR/.brew-completion-message" 2>/dev/null; then
print -P '%F{yellow}'Oh My Zsh brew plugin:
cat <<-'EOF'
With the advent of their 1.0 release, Homebrew has decided to bundle
the zsh completion as part of the brew installation, so we no longer
ship it with the brew plugin; now it only has brew aliases.
If you find that brew completion no longer works, make sure you have
your Homebrew installation fully up to date.
You will only see this message once.
EOF
print -P '%f'
fi

View File

@ -1,52 +1,74 @@
# Bundler # Bundler
- adds completion for basic bundler commands This plugin adds completion for basic bundler commands, as well as aliases and helper functions for
- adds short aliases for common bundler commands an easier experience with bundler.
- `be` aliased to `bundle exec`.
It also supports aliases (if `rs` is `rails server`, `be rs` will bundle-exec `rails server`). To use it, add `bundler` to the plugins array in your zshrc file:
- `bl` aliased to `bundle list`
- `bp` aliased to `bundle package` ```zsh
- `bo` aliased to `bundle open` plugins=(... bundler)
- `bout` aliased to `bundle outdated` ```
- `bu` aliased to `bundle update`
- `bi` aliased to `bundle install --jobs=<cpu core count>` (only for bundler `>= 1.4.0`) ## Aliases
- adds a wrapper for common gems:
- looks for a binstub under `./bin/` and executes it (if present) | Alias | Command | Description |
- calls `bundle exec <gem executable>` otherwise |--------|--------------------------------------|------------------------------------------------------------------------------------------|
| `ba` | `bundle add` | Add gem to the Gemfile and run bundle install |
| `bck` | `bundle check` | Verifies if dependencies are satisfied by installed gems |
| `bcn` | `bundle clean` | Cleans up unused gems in your bundler directory |
| `be` | `bundle exec` | Execute a command in the context of the bundle |
| `bi` | `bundle install --jobs=<core_count>` | Install the dependencies specified in your Gemfile (using all cores in bundler >= 1.4.0) |
| `bl` | `bundle list` | List all the gems in the bundle |
| `bo` | `bundle open` | Opens the source directory for a gem in your bundle |
| `bout` | `bundle outdated` | List installed gems with newer versions available |
| `bp` | `bundle package` | Package your needed .gem files into your application |
| `bu` | `bundle update` | Update your gems to the latest available versions |
## Gem wrapper
The plugin adds a wrapper for common gems, which:
- Looks for a binstub under `./bin/` and executes it if present.
- Calls `bundle exec <gem>` otherwise.
Common gems wrapped by default (by name of the executable): Common gems wrapped by default (by name of the executable):
`annotate`, `cap`, `capify`, `cucumber`, `foodcritic`, `guard`, `hanami`, `irb`, `jekyll`, `kitchen`, `knife`, `middleman`, `nanoc`, `pry`, `puma`, `rackup`, `rainbows`, `rake`, `rspec`, `shotgun`, `sidekiq`, `spec`, `spork`, `spring`, `strainer`, `tailor`, `taps`, `thin`, `thor`, `unicorn` and `unicorn_rails`.
## Configuration `annotate`, `cap`, `capify`, `cucumber`, `foodcritic`, `guard`, `hanami`, `irb`, `jekyll`, `kitchen`, `knife`, `middleman`, `nanoc`, `pry`, `puma`, `rackup`, `rainbows`, `rake`, `rspec`, `rubocop`, `shotgun`, `sidekiq`, `spec`, `spork`, `spring`, `strainer`, `tailor`, `taps`, `thin`, `thor`, `unicorn` and `unicorn_rails`.
Please use the exact name of the executable and not the gem name. ### Settings
### Add additional gems to be wrapped You can add or remove gems from the list of wrapped commands.
Please **use the exact name of the executable** and not the gem name.
#### Include gems to be wrapped (`BUNDLED_COMMANDS`)
Add this before the plugin list in your `.zshrc`:
Add this before the plugin-list in your `.zshrc`:
```sh ```sh
BUNDLED_COMMANDS=(rubocop) BUNDLED_COMMANDS=(rubocop)
plugins=(... bundler ...) plugins=(... bundler ...)
``` ```
This will add the wrapper for the `rubocop` gem (i.e. the executable). This will add the wrapper for the `rubocop` gem (i.e. the executable).
#### Exclude gems from being wrapped (`UNBUNDLED_COMMANDS`)
### Exclude gems from being wrapped Add this before the plugin list in your `.zshrc`:
Add this before the plugin-list in your `.zshrc`:
```sh ```sh
UNBUNDLED_COMMANDS=(foreman spin) UNBUNDLED_COMMANDS=(foreman spin)
plugins=(... bundler ...) plugins=(... bundler ...)
``` ```
This will exclude the `foreman` and `spin` gems (i.e. their executable) from being wrapped. This will exclude the `foreman` and `spin` gems (i.e. their executable) from being wrapped.
## Excluded gems ### Excluded gems
These gems should not be called with `bundle exec`. Please see [issue #2923](https://github.com/robbyrussell/oh-my-zsh/pull/2923) on GitHub for clarification. These gems should not be called with `bundle exec`. Please see [issue #2923](https://github.com/ohmyzsh/ohmyzsh/pull/2923) on GitHub for clarification:
`berks` - `berks`
`foreman` - `foreman`
`mailcatcher` - `mailcatcher`
`rails` - `rails`
`ruby` - `ruby`
`spin` - `spin`

View File

@ -1,11 +1,49 @@
## Aliases
alias ba="bundle add"
alias bck="bundle check"
alias bcn="bundle clean"
alias be="bundle exec" alias be="bundle exec"
alias bi="bundle_install"
alias bl="bundle list" alias bl="bundle list"
alias bp="bundle package"
alias bo="bundle open" alias bo="bundle open"
alias bout="bundle outdated" alias bout="bundle outdated"
alias bp="bundle package"
alias bu="bundle update" alias bu="bundle update"
alias bi="bundle_install"
alias bcn="bundle clean" ## Functions
bundle_install() {
# Bail out if bundler is not installed
if (( ! $+commands[bundle] )); then
echo "Bundler is not installed"
return 1
fi
# Bail out if not in a bundled project
if ! _within-bundled-project; then
echo "Can't 'bundle install' outside a bundled project"
return 1
fi
# Check the bundler version is at least 1.4.0
autoload -Uz is-at-least
local bundler_version=$(bundle version | cut -d' ' -f3)
if ! is-at-least 1.4.0 "$bundler_version"; then
bundle install "$@"
return $?
fi
# If bundler is at least 1.4.0, use all the CPU cores to bundle install
if [[ "$OSTYPE" = (darwin|freebsd)* ]]; then
local cores_num="$(sysctl -n hw.ncpu)"
else
local cores_num="$(nproc)"
fi
bundle install --jobs="$cores_num" "$@"
}
## Gem wrapper
bundled_commands=( bundled_commands=(
annotate annotate
@ -27,6 +65,7 @@ bundled_commands=(
rainbows rainbows
rake rake
rspec rspec
rubocop
shotgun shotgun
sidekiq sidekiq
spec spec
@ -51,65 +90,41 @@ for cmd in $BUNDLED_COMMANDS; do
bundled_commands+=($cmd); bundled_commands+=($cmd);
done done
## Functions # Check if in the root or a subdirectory of a bundled project
bundle_install() {
if ! _bundler-installed; then
echo "Bundler is not installed"
elif ! _within-bundled-project; then
echo "Can't 'bundle install' outside a bundled project"
else
local bundler_version=`bundle version | cut -d' ' -f3`
if [[ $bundler_version > '1.4.0' || $bundler_version = '1.4.0' ]]; then
if [[ "$OSTYPE" = (darwin|freebsd)* ]]
then
local cores_num="$(sysctl -n hw.ncpu)"
else
local cores_num="$(nproc)"
fi
bundle install --jobs=$cores_num $@
else
bundle install $@
fi
fi
}
_bundler-installed() {
which bundle > /dev/null 2>&1
}
_within-bundled-project() { _within-bundled-project() {
local check_dir="$PWD" local check_dir="$PWD"
while [ "$check_dir" != "/" ]; do while [[ "$check_dir" != "/" ]]; do
[ -f "$check_dir/Gemfile" ] && return if [[ -f "$check_dir/Gemfile" || -f "$check_dir/gems.rb" ]]; then
check_dir="$(dirname $check_dir)" return 0
fi
check_dir="${check_dir:h}"
done done
false return 1
}
_binstubbed() {
[ -f "./bin/${1}" ]
} }
_run-with-bundler() { _run-with-bundler() {
if _bundler-installed && _within-bundled-project; then if (( ! $+commands[bundle] )) || ! _within-bundled-project; then
if _binstubbed $1; then "$@"
./bin/$@ return $?
else fi
bundle exec $@
fi if [[ -f "./bin/${1}" ]]; then
./bin/${^^@}
else else
$@ bundle exec "$@"
fi fi
} }
## Main program
for cmd in $bundled_commands; do for cmd in $bundled_commands; do
eval "function unbundled_$cmd () { $cmd \$@ }" # Create wrappers for bundled and unbundled execution
eval "function bundled_$cmd () { _run-with-bundler $cmd \$@}" eval "function unbundled_$cmd () { \"$cmd\" \"\$@\"; }"
alias $cmd=bundled_$cmd eval "function bundled_$cmd () { _run-with-bundler \"$cmd\" \"\$@\"; }"
alias "$cmd"="bundled_$cmd"
if which _$cmd > /dev/null 2>&1; then # Bind completion function to wrapped gem if available
compdef _$cmd bundled_$cmd=$cmd if (( $+functions[_$cmd] )); then
compdef "_$cmd" "bundled_$cmd"="$cmd"
fi fi
done done
unset cmd bundled_commands

View File

@ -0,0 +1,16 @@
# cakephp3 plugin
The plugin adds aliases and autocompletion for [cakephp3](https://book.cakephp.org/3.0/en/index.html).
To use it, add `cakephp3` to the plugins array of your zshrc file:
```
plugins=(... cakephp3)
```
## Aliases
| Alias | Command |
|-----------|-------------------------------|
| c3 | `bin/cake` |
| c3cache | `bin/cake orm_cache clear` |
| c3migrate | `bin/cake migrations migrate` |

View File

@ -2,489 +2,367 @@
autoload -U regexp-replace autoload -U regexp-replace
zstyle -T ':completion:*:*:cargo:*' tag-order && \
zstyle ':completion:*:*:cargo:*' tag-order 'common-commands'
_cargo() { _cargo() {
local context state state_descr line local curcontext="$curcontext" ret=1
typeset -A opt_args local -a command_scope_spec common parallel features msgfmt triple target registry
local -a state line state_descr # These are set by _arguments
typeset -A opt_args
# leading items in parentheses are an exclusion list for the arguments following that arg common=(
# See: http://zsh.sourceforge.net/Doc/Release/Completion-System.html#Completion-Functions '(-q --quiet)*'{-v,--verbose}'[use verbose output]'
# - => exclude all other options '(-q --quiet -v --verbose)'{-q,--quiet}'[no output printed to stdout]'
# 1 => exclude positional arg 1 '-Z+[pass unstable (nightly-only) flags to cargo]: :_cargo_unstable_flags'
# * => exclude all other args '--frozen[require that Cargo.lock and cache are up to date]'
# +blah => exclude +blah '--locked[require that Cargo.lock is up to date]'
_arguments \ '--color=[specify colorization option]:coloring:(auto always never)'
'(- 1 *)'{-h,--help}'[show help message]' \ '(- 1 *)'{-h,--help}'[show help message]'
'(- 1 *)--list[list installed commands]' \ )
'(- 1 *)'{-V,--version}'[show version information]' \
{-v,--verbose}'[use verbose output]' \
--color'[colorization option]' \
'(+beta +nightly)+stable[use the stable toolchain]' \
'(+stable +nightly)+beta[use the beta toolchain]' \
'(+stable +beta)+nightly[use the nightly toolchain]' \
'1: :->command' \
'*:: :->args'
case $state in # leading items in parentheses are an exclusion list for the arguments following that arg
command) # See: http://zsh.sourceforge.net/Doc/Release/Completion-System.html#Completion-Functions
_alternative 'common-commands:common:_cargo_cmds' 'all-commands:all:_cargo_all_cmds' # - => exclude all other options
;; # 1 => exclude positional arg 1
# * => exclude all other args
# +blah => exclude +blah
_arguments -s -S -C $common \
'(- 1 *)--list[list installed commands]' \
'(- 1 *)--explain=[provide a detailed explanation of an error message]:error code' \
'(- 1 *)'{-V,--version}'[show version information]' \
'(+beta +nightly)+stable[use the stable toolchain]' \
'(+stable +nightly)+beta[use the beta toolchain]' \
'(+stable +beta)+nightly[use the nightly toolchain]' \
'1: :_cargo_cmds' \
'*:: :->args'
args) # These flags are mutually exclusive specifiers for the scope of a command; as
case $words[1] in # they are used in multiple places without change, they are expanded into the
bench) # appropriate command's `_arguments` where appropriate.
_arguments \ command_scope_spec=(
'--features=[space separated feature list]' \ '(--bin --example --test --lib)--bench=[specify benchmark name]: :_cargo_benchmark_names'
'--all-features[enable all available features]' \ '(--bench --bin --test --lib)--example=[specify example name]:example name'
'(-h, --help)'{-h,--help}'[show help message]' \ '(--bench --example --test --lib)--bin=[specify binary name]:binary name'
'(-j, --jobs)'{-j,--jobs}'[number of parallel jobs, defaults to # of CPUs]' \ '(--bench --bin --example --test)--lib=[specify library name]:library name'
"${command_scope_spec[@]}" \ '(--bench --bin --example --lib)--test=[specify test name]:test name'
'--manifest-path=[path to manifest]: :_files -/' \ )
'--no-default-features[do not build the default features]' \
'--no-run[compile but do not run]' \
'(-p,--package)'{-p=,--package=}'[package to run benchmarks for]:packages:_get_package_names' \
'--target=[target triple]' \
'(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
'(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \
'--color=:colorization option:(auto always never)' \
;;
build) parallel=(
_arguments \ '(-j --jobs)'{-j+,--jobs=}'[specify number of parallel jobs]:jobs [# of CPUs]'
'--features=[space separated feature list]' \ )
'--all-features[enable all available features]' \
'(-h, --help)'{-h,--help}'[show help message]' \
'(-j, --jobs)'{-j,--jobs}'[number of parallel jobs, defaults to # of CPUs]' \
"${command_scope_spec[@]}" \
'--manifest-path=[path to manifest]: :_files -/' \
'--no-default-features[do not build the default features]' \
'(-p,--package)'{-p=,--package=}'[package to build]:packages:_get_package_names' \
'--release=[build in release mode]' \
'--target=[target triple]' \
'(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
'(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \
'--color=:colorization option:(auto always never)' \
;;
check) features=(
_arguments \ '(--all-features)--features=[specify features to activate]:feature'
'--features=[space separated feature list]' \ '(--features)--all-features[activate all available features]'
'--all-features[enable all available features]' \ "--no-default-features[don't build the default features]"
'(-h, --help)'{-h,--help}'[show help message]' \ )
'(-j, --jobs)'{-j,--jobs}'[number of parallel jobs, defaults to # of CPUs]' \
"${command_scope_spec[@]}" \
'--manifest-path=[path to manifest]: :_files -/' \
'--no-default-features[do not check the default features]' \
'(-p,--package)'{-p=,--package=}'[package to check]:packages:_get_package_names' \
'--release=[check in release mode]' \
'--target=[target triple]' \
'(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
'(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \
'--color=:colorization option:(auto always never)' \
;;
clean) msgfmt='--message-format=[specify error format]:error format [human]:(human json short)'
_arguments \ triple='--target=[specify target triple]:target triple'
'(-h, --help)'{-h,--help}'[show help message]' \ target='--target-dir=[specify directory for all generated artifacts]:directory:_directories'
'--manifest-path=[path to manifest]: :_files -/' \ manifest='--manifest-path=[specify path to manifest]:path:_directories'
'(-p,--package)'{-p=,--package=}'[package to clean]:packages:_get_package_names' \ registry='--registry=[specify registry to use]:registry'
'(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \
'--release[whether or not to clean release artifacts]' \
'--target=[target triple(default:all)]' \
'(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
'--color=:colorization option:(auto always never)' \
;;
doc) case $state in
_arguments \ args)
'--features=[space separated feature list]' \ curcontext="${curcontext%:*}-${words[1]}:"
'--all-features[enable all available features]' \ case ${words[1]} in
'(-h, --help)'{-h,--help}'[show help message]' \ bench)
'(-j, --jobs)'{-j,--jobs}'[number of parallel jobs, defaults to # of CPUs]' \ _arguments -s -A "^--" $common $parallel $features $msgfmt $triple $target $manifest \
'--manifest-path=[path to manifest]: :_files -/' \ "${command_scope_spec[@]}" \
'--no-deps[do not build docs for dependencies]' \ '--all-targets[benchmark all targets]' \
'--no-default-features[do not build the default features]' \ "--no-run[compile but don't run]" \
'--open[open docs in browser after the build]' \ '(-p --package)'{-p+,--package=}'[specify package to run benchmarks for]:package:_cargo_package_names' \
'(-p, --package)'{-p,--package}'=[package to document]' \ '--exclude=[exclude packages from the benchmark]:spec' \
'(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \ '--no-fail-fast[run all benchmarks regardless of failure]' \
'--release[build artifacts in release mode, with optimizations]' \ '1: :_guard "^-*" "bench name"' \
'--target=[build for the target triple]' \ '*:args:_default'
'(-v, --verbose)'{-v,--verbose}'[use verbose output]' \ ;;
'--color=:colorization option:(auto always never)' \
;;
fetch) build|b)
_arguments \ _arguments -s -S $common $parallel $features $msgfmt $triple $target $manifest \
'(-h, --help)'{-h,--help}'[show help message]' \ '--all-targets[equivalent to specifying --lib --bins --tests --benches --examples]' \
'--manifest-path=[path to manifest]: :_files -/' \ "${command_scope_spec[@]}" \
'(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \ '(-p --package)'{-p+,--package=}'[specify package to build]:package:_cargo_package_names' \
'(-v, --verbose)'{-v,--verbose}'[use verbose output]' \ '--release[build in release mode]' \
'--color=:colorization option:(auto always never)' \ '--build-plan[output the build plan in JSON]' \
;; ;;
generate-lockfile) check|c)
_arguments \ _arguments -s -S $common $parallel $features $msgfmt $triple $target $manifest \
'(-h, --help)'{-h,--help}'[show help message]' \ '--all-targets[equivalent to specifying --lib --bins --tests --benches --examples]' \
'--manifest-path=[path to manifest]: :_files -/' \ "${command_scope_spec[@]}" \
'(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \ '(-p --package)'{-p+,--package=}'[specify package to check]:package:_cargo_package_names' \
'(-v, --verbose)'{-v,--verbose}'[use verbose output]' \ '--release[check in release mode]' \
'--color=:colorization option:(auto always never)' \ ;;
;;
git-checkout) clean)
_arguments \ _arguments -s -S $common $triple $target $manifest \
'(-h, --help)'{-h,--help}'[show help message]' \ '(-p --package)'{-p+,--package=}'[specify package to clean]:package:_cargo_package_names' \
'(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \ '--release[clean release artifacts]' \
'--reference=[REF]' \ '--doc[clean just the documentation directory]'
'--url=[URL]' \ ;;
'(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
'--color=:colorization option:(auto always never)' \
;;
help) doc)
_arguments \ _arguments -s -S $common $parallel $features $msgfmt $triple $target $manifest \
'(-h, --help)'{-h,--help}'[show help message]' \ '--no-deps[do not build docs for dependencies]' \
'*: :_cargo_cmds' \ '--document-private-items[include non-public items in the documentation]' \
;; '--open[open docs in browser after the build]' \
'(-p --package)'{-p+,--package=}'[specify package to document]:package:_cargo_package_names' \
'--release[build artifacts in release mode, with optimizations]' \
;;
init) fetch)
_arguments \ _arguments -s -S $common $triple $manifest
'--bin[use binary template]' \ ;;
'--vcs:initialize a new repo with a given VCS:(git hg none)' \
'(-h, --help)'{-h,--help}'[show help message]' \
'--name=[set the resulting package name]' \
'(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \
'(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
'--color=:colorization option:(auto always never)' \
;;
install) fix)
_arguments \ _arguments -s -S $common $parallel $features $msgfmt $triple $target $manifest \
'--bin=[only install the specified binary]' \ "${command_scope_spec[@]}" \
'--branch=[branch to use when installing from git]' \ '--broken-code[fix code even if it already has compiler errors]' \
'--color=:colorization option:(auto always never)' \ '--edition[fix in preparation for the next edition]' \
'--debug[build in debug mode instead of release mode]' \ '--edition-idioms[fix warnings to migrate to the idioms of an edition]' \
'--example[install the specified example instead of binaries]' \ '--allow-no-vcs[fix code even if a VCS was not detected]' \
'--features=[space separated feature list]' \ '--allow-dirty[fix code even if the working directory is dirty]' \
'--all-features[enable all available features]' \ '--allow-staged[fix code even if the working directory has staged changes]'
'--git=[URL from which to install the crate]' \ ;;
'(-h, --help)'{-h,--help}'[show help message]' \
'(-j, --jobs)'{-j,--jobs}'[number of parallel jobs, defaults to # of CPUs]' \
'--no-default-features[do not build the default features]' \
'--path=[local filesystem path to crate to install]: :_files -/' \
'(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \
'--rev=[specific commit to use when installing from git]' \
'--root=[directory to install packages into]: :_files -/' \
'--tag=[tag to use when installing from git]' \
'(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
'--vers=[version to install from crates.io]' \
;;
locate-project) generate-lockfile)
_arguments \ _arguments -s -S $common $manifest
'(-h, --help)'{-h,--help}'[show help message]' \ ;;
'--manifest-path=[path to manifest]: :_files -/' \
;;
login) git-checkout)
_arguments \ _arguments -s -S $common \
'(-h, --help)'{-h,--help}'[show help message]' \ '--reference=:reference' \
'--host=[Host to set the token for]' \ '--url=:url:_urls'
'(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \ ;;
'(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
'--color=:colorization option:(auto always never)' \
;;
metadata) help)
_arguments \ _cargo_cmds
'(-h, --help)'{-h,--help}'[show help message]' \ ;;
'(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \
'(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
"--no-deps[output information only about the root package and don't fetch dependencies]" \
'--no-default-features[do not include the default feature]' \
'--manifest-path=[path to manifest]: :_files -/' \
'--features=[space separated feature list]' \
'--all-features[enable all available features]' \
'--format-version=[format version(default: 1)]' \
'--color=:colorization option:(auto always never)' \
;;
new) init)
_arguments \ _arguments -s -S $common $registry \
'--bin[use binary template]' \ '--lib[use library template]' \
'--vcs:initialize a new repo with a given VCS:(git hg none)' \ '--edition=[specify edition to set for the crate generated]:edition:(2015 2018)' \
'(-h, --help)'{-h,--help}'[show help message]' \ '--vcs=[initialize a new repo with a given VCS]:vcs:(git hg pijul fossil none)' \
'--name=[set the resulting package name]' \ '--name=[set the resulting package name]:name' \
'(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \ '1:path:_directories'
'(-v, --verbose)'{-v,--verbose}'[use verbose output]' \ ;;
'--color=:colorization option:(auto always never)' \
;;
owner) install)
_arguments \ _arguments -s -S $common $parallel $features $triple $registry \
'(-a, --add)'{-a,--add}'[add owner LOGIN]' \ '(-f --force)'{-f,--force}'[force overwriting of existing crates or binaries]' \
'(-h, --help)'{-h,--help}'[show help message]' \ '--bin=[only install the specified binary]:binary' \
'--index[registry index]' \ '--branch=[branch to use when installing from git]:branch' \
'(-l, --list)'{-l,--list}'[list owners of a crate]' \ '--debug[build in debug mode instead of release mode]' \
'(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \ '--example=[install the specified example instead of binaries]:example' \
'(-r, --remove)'{-r,--remove}'[remove owner LOGIN]' \ '--git=[specify URL from which to install the crate]:url:_urls' \
'--token[API token to use when authenticating]' \ '--path=[local filesystem path to crate to install]: :_directories' \
'(-v, --verbose)'{-v,--verbose}'[use verbose output]' \ '--rev=[specific commit to use when installing from git]:commit' \
'--color=:colorization option:(auto always never)' \ '--root=[directory to install packages into]: :_directories' \
;; '--tag=[tag to use when installing from git]:tag' \
'--vers=[version to install from crates.io]:version' \
'--list[list all installed packages and their versions]' \
'*: :_guard "^-*" "crate"'
;;
package) locate-project)
_arguments \ _arguments -s -S $common $manifest
'(-h, --help)'{-h,--help}'[show help message]' \ ;;
'(-l, --list)'{-l,--list}'[print files included in a package without making one]' \
'--manifest-path=[path to manifest]: :_files -/' \
'--no-metadata[ignore warnings about a lack of human-usable metadata]' \
'--no-verify[do not build to verify contents]' \
'(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \
'(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
'--color=:colorization option:(auto always never)' \
;;
pkgid) login)
_arguments \ _arguments -s -S $common $registry \
'(-h, --help)'{-h,--help}'[show help message]' \ '*: :_guard "^-*" "token"'
'--manifest-path=[path to manifest]: :_files -/' \ ;;
'(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \
'(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
'--color=:colorization option:(auto always never)' \
;;
publish) metadata)
_arguments \ _arguments -s -S $common $features $manifest \
'(-h, --help)'{-h,--help}'[show help message]' \ "--no-deps[output information only about the root package and don't fetch dependencies]" \
'--host=[Host to set the token for]' \ '--format-version=[specify format version]:version [1]:(1)'
'--manifest-path=[path to manifest]: :_files -/' \ ;;
'--no-verify[Do not verify tarball until before publish]' \
'(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \
'--token[token to use when uploading]' \
'(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
'--color=:colorization option:(auto always never)' \
;;
read-manifest) new)
_arguments \ _arguments -s -S $common $registry \
'(-h, --help)'{-h,--help}'[show help message]' \ '--lib[use library template]' \
'--manifest-path=[path to manifest]: :_files -/' \ '--vcs:initialize a new repo with a given VCS:(git hg none)' \
'(-v, --verbose)'{-v,--verbose}'[use verbose output]' \ '--name=[set the resulting package name]'
'--color=:colorization option:(auto always never)' \ ;;
;;
run) owner)
_arguments \ _arguments -s -S $common $registry \
'--example=[name of the bin target]' \ '(-a --add)'{-a,--add}'[specify name of a user or team to invite as an owner]:name' \
'--features=[space separated feature list]' \ '--index=[specify registry index]:index' \
'--all-features[enable all available features]' \ '(-l --list)'{-l,--list}'[list owners of a crate]' \
'(-h, --help)'{-h,--help}'[show help message]' \ '(-r --remove)'{-r,--remove}'[specify name of a user or team to remove as an owner]:name' \
'(-j, --jobs)'{-j,--jobs}'[number of parallel jobs, defaults to # of CPUs]' \ '--token=[specify API token to use when authenticating]:token' \
'--manifest-path=[path to manifest]: :_files -/' \ '*: :_guard "^-*" "crate"'
'--bin=[name of the bin target]' \ ;;
'--no-default-features[do not build the default features]' \
'(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \
'--release=[build in release mode]' \
'--target=[target triple]' \
'(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
'--color=:colorization option:(auto always never)' \
'*: :_normal' \
;;
rustc) package)
_arguments \ _arguments -s -S $common $parallel $features $triple $target $manifest \
'--color=:colorization option:(auto always never)' \ '(-l --list)'{-l,--list}'[print files included in a package without making one]' \
'--features=[features to compile for the package]' \ '--no-metadata[ignore warnings about a lack of human-usable metadata]' \
'--all-features[enable all available features]' \ '--allow-dirty[allow dirty working directories to be packaged]' \
'(-h, --help)'{-h,--help}'[show help message]' \ "--no-verify[don't build to verify contents]"
'(-j, --jobs)'{-j,--jobs}'=[number of parallel jobs, defaults to # of CPUs]' \ ;;
'--manifest-path=[path to the manifest to fetch dependencies for]: :_files -/' \
'--no-default-features[do not compile default features for the package]' \
'(-p, --package)'{-p,--package}'=[profile to compile for]' \
'--profile=[profile to build the selected target for]' \
'(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \
'--release[build artifacts in release mode, with optimizations]' \
'--target=[target triple which compiles will be for]' \
'(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
"${command_scope_spec[@]}" \
;;
rustdoc) pkgid)
_arguments \ _arguments -s -S $common $manifest \
'--color=:colorization option:(auto always never)' \ '(-p --package)'{-p+,--package=}'[specify package to get ID specifier for]:package:_cargo_package_names' \
'--features=[space-separated list of features to also build]' \ '*: :_guard "^-*" "spec"'
'--all-features[enable all available features]' \ ;;
'(-h, --help)'{-h,--help}'[show help message]' \
'(-j, --jobs)'{-j,--jobs}'=[number of parallel jobs, defaults to # of CPUs]' \
'--manifest-path=[path to the manifest to document]: :_files -/' \
'--no-default-features[do not build the `default` feature]' \
'--open[open the docs in a browser after the operation]' \
'(-p, --package)'{-p,--package}'=[package to document]' \
'(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \
'--release[build artifacts in release mode, with optimizations]' \
'--target=[build for the target triple]' \
'(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
"${command_scope_spec[@]}" \
;;
search) publish)
_arguments \ _arguments -s -S $common $parallel $features $triple $target $manifest $registry \
'--color=:colorization option:(auto always never)' \ '--index=[specify registry index]:index' \
'(-h, --help)'{-h,--help}'[show help message]' \ '--allow-dirty[allow dirty working directories to be packaged]' \
'--host=[host of a registry to search in]' \ "--no-verify[don't verify the contents by building them]" \
'--limit=[limit the number of results]' \ '--token=[specify token to use when uploading]:token' \
'(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \ '--dry-run[perform all checks without uploading]'
'(-v, --verbose)'{-v,--verbose}'[use verbose output]' \ ;;
;;
test) read-manifest)
_arguments \ _arguments -s -S $common $manifest
'--features=[space separated feature list]' \ ;;
'--all-features[enable all available features]' \
'(-h, --help)'{-h,--help}'[show help message]' \
'(-j, --jobs)'{-j,--jobs}'[number of parallel jobs, defaults to # of CPUs]' \
'--manifest-path=[path to manifest]: :_files -/' \
'--test=[test name]: :_test_names' \
'--no-default-features[do not build the default features]' \
'--no-fail-fast[run all tests regardless of failure]' \
'--no-run[compile but do not run]' \
'(-p,--package)'{-p=,--package=}'[package to run tests for]:packages:_get_package_names' \
'(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \
'--release[build artifacts in release mode, with optimizations]' \
'--target=[target triple]' \
'(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
'--color=:colorization option:(auto always never)' \
'1: :_test_names' \
'(--doc --bin --example --test --bench)--lib[only test library]' \
'(--lib --bin --example --test --bench)--doc[only test documentation]' \
'(--lib --doc --example --test --bench)--bin=[binary name]' \
'(--lib --doc --bin --test --bench)--example=[example name]' \
'(--lib --doc --bin --example --bench)--test=[test name]' \
'(--lib --doc --bin --example --test)--bench=[benchmark name]' \
'--message-format:error format:(human json short)' \
'--frozen[require lock and cache up to date]' \
'--locked[require lock up to date]'
;;
uninstall) run|r)
_arguments \ _arguments -s -S $common $parallel $features $msgfmt $triple $target $manifest \
'--bin=[only uninstall the binary NAME]' \ '--example=[name of the bin target]:name' \
'--color=:colorization option:(auto always never)' \ '--bin=[name of the bin target]:name' \
'(-h, --help)'{-h,--help}'[show help message]' \ '(-p --package)'{-p+,--package=}'[specify package with the target to run]:package:_cargo_package_names' \
'(-q, --quiet)'{-q,--quiet}'[less output printed to stdout]' \ '--release[build in release mode]' \
'--root=[directory to uninstall packages from]: :_files -/' \ '*: :_default'
'(-v, --verbose)'{-v,--verbose}'[use verbose output]' \ ;;
;;
update) rustc)
_arguments \ _arguments -s -S $common $parallel $features $msgfmt $triple $target $manifest \
'--aggressive=[force dependency update]' \ '(-p --package)'{-p+,--package=}'[specify package to build]:package:_cargo_package_names' \
'(-h, --help)'{-h,--help}'[show help message]' \ '--profile=[specify profile to build the selected target for]:profile' \
'--manifest-path=[path to manifest]: :_files -/' \ '--release[build artifacts in release mode, with optimizations]' \
'(-p,--package)'{-p=,--package=}'[package to update]:packages:__get_package_names' \ "${command_scope_spec[@]}" \
'--precise=[update single dependency to PRECISE]: :' \ '*: : _dispatch rustc rustc -default-'
'(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \ ;;
'(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
'--color=:colorization option:(auto always never)' \
;;
verify-project) rustdoc)
_arguments \ _arguments -s -S $common $parallel $features $msgfmt $triple $target $manifest \
'(-h, --help)'{-h,--help}'[show help message]' \ '--document-private-items[include non-public items in the documentation]' \
'--manifest-path=[path to manifest]: :_files -/' \ '--open[open the docs in a browser after the operation]' \
'(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \ '(-p --package)'{-p+,--package=}'[specify package to document]:package:_cargo_package_names' \
'(-v, --verbose)'{-v,--verbose}'[use verbose output]' \ '--release[build artifacts in release mode, with optimizations]' \
'--color=:colorization option:(auto always never)' \ "${command_scope_spec[@]}" \
;; '*: : _dispatch rustdoc rustdoc -default-'
;;
version) search)
_arguments \ _arguments -s -S $common $registry \
'(-h, --help)'{-h,--help}'[show help message]' \ '--index=[specify registry index]:index' \
'(-v, --verbose)'{-v,--verbose}'[use verbose output]' \ '--limit=[limit the number of results]:results [10]' \
'--color=:colorization option:(auto always never)' \ '*: :_guard "^-*" "query"'
;; ;;
yank) test|t)
_arguments \ _arguments -s -S $common $parallel $features $msgfmt $triple $target $manifest \
'(-h, --help)'{-h,--help}'[show help message]' \ '--test=[test name]: :_cargo_test_names' \
'--index[registry index]' \ '--no-fail-fast[run all tests regardless of failure]' \
'(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \ '--no-run[compile but do not run]' \
'--token[API token to use when authenticating]' \ '(-p --package)'{-p+,--package=}'[package to run tests for]:package:_cargo_package_names' \
'--undo[undo a yank, putting a version back into the index]' \ '--all[test all packages in the workspace]' \
'(-v, --verbose)'{-v,--verbose}'[use verbose output]' \ '--release[build artifacts in release mode, with optimizations]' \
'--color=:colorization option:(auto always never)' \ '1: :_cargo_test_names' \
'--vers[yank version]' \ '(--doc --bin --example --test --bench)--lib[only test library]' \
;; '(--lib --bin --example --test --bench)--doc[only test documentation]' \
esac '(--lib --doc --example --test --bench)--bin=[binary name]' \
;; '(--lib --doc --bin --test --bench)--example=[example name]' \
esac '(--lib --doc --bin --example --bench)--test=[test name]' \
'(--lib --doc --bin --example --test)--bench=[benchmark name]' \
'*: :_default'
;;
uninstall)
_arguments -s -S $common \
'(-p --package)'{-p+,--package=}'[specify package to uninstall]:package:_cargo_package_names' \
'--bin=[only uninstall the specified binary]:name' \
'--root=[directory to uninstall packages from]: :_files -/' \
'*:crate:_cargo_installed_crates -F line'
;;
update)
_arguments -s -S $common $manifest \
'--aggressive=[force dependency update]' \
"--dry-run[don't actually write the lockfile]" \
'(-p --package)'{-p+,--package=}'[specify package to update]:package:_cargo_package_names' \
'--precise=[update single dependency to precise release]:release'
;;
verify-project)
_arguments -s -S $common $manifest
;;
version)
_arguments -s -S $common
;;
yank)
_arguments -s -S $common $registry \
'--vers=[specify yank version]:version' \
'--undo[undo a yank, putting a version back into the index]' \
'--index=[specify registry index to yank from]:registry index' \
'--token=[specify API token to use when authenticating]:token' \
'*: :_guard "^-*" "crate"'
;;
*)
# allow plugins to define their own functions
if ! _call_function ret _cargo-${words[1]}; then
# fallback on default completion for unknown commands
_default && ret=0
fi
(( ! ret ))
;;
esac
;;
esac
} }
_cargo_cmds(){ _cargo_unstable_flags() {
local -a commands;commands=( local flags
'bench:execute all benchmarks of a local package' flags=( help ${${${(M)${(f)"$(_call_program flags cargo -Z help)"}:#*--*}/ #-- #/:}##*-Z } )
'build:compile the current package' _describe -t flags 'unstable flag' flags
'check:check the current package without compiling'
'clean:remove generated artifacts'
'doc:build package documentation'
'fetch:fetch package dependencies'
'generate-lockfile:create lockfile'
'git-checkout:git checkout'
'help:get help for commands'
'init:create new package in current directory'
'install:install a Rust binary'
'locate-project:print "Cargo.toml" location'
'login:login to remote server'
'metadata:the metadata for a package in json'
'new:create a new package'
'owner:manage the owners of a crate on the registry'
'package:assemble local package into a distributable tarball'
'pkgid:print a fully qualified package specification'
'publish:upload package to the registry'
'read-manifest:print manifest in JSON format'
'run:run the main binary of the local package'
'rustc:compile a package and all of its dependencies'
'rustdoc:build documentation for a package'
'search:search packages on crates.io'
'test:execute all unit and tests of a local package'
'uninstall:remove a Rust binary'
'update:update dependencies'
'verify-project:check Cargo.toml'
'version:show version information'
'yank:remove pushed file from index'
)
_describe -t common-commands 'common commands' commands
} }
_cargo_all_cmds(){ _cargo_installed_crates() {
local -a commands;commands=($(cargo --list)) local expl
_describe -t all-commands 'all commands' commands _description crates expl 'crate'
compadd "$@" "$expl[@]" - ${${${(f)"$(cargo install --list)"}:# *}%% *}
}
_cargo_cmds() {
local -a commands
# This uses Parameter Expansion Flags, which are a built-in Zsh feature.
# See more: http://zsh.sourceforge.net/Doc/Release/Expansion.html#Parameter-Expansion-Flags
# and http://zsh.sourceforge.net/Doc/Release/Expansion.html#Parameter-Expansion
#
# # How this work?
#
# First it splits the result of `cargo --list` at newline, then it removes the first line.
# Then it removes indentation (4 whitespaces) before each items. (Note the x## pattern [1]).
# Then it replaces those spaces between item and description with a `:`
#
# [1]: https://github.com/zsh-users/zsh-completions/blob/master/zsh-completions-howto.org#patterns
commands=( ${${${(M)"${(f)$(_call_program commands cargo --list)}":# *}/ ##/}/ ##/:} )
_describe -t commands 'command' commands
} }
#FIXME: Disabled until fixed #FIXME: Disabled until fixed
#gets package names from the manifest file #gets package names from the manifest file
_get_package_names() _cargo_package_names() {
{ _message -e packages package
}
#TODO:see if it makes sense to have 'locate-project' to have non-json output.
#strips package name from json stuff
_locate_manifest(){
local manifest=`cargo locate-project 2>/dev/null`
regexp-replace manifest '\{"root":"|"\}' ''
echo $manifest
} }
# Extracts the values of "name" from the array given in $1 and shows them as # Extracts the values of "name" from the array given in $1 and shows them as
# command line options for completion # command line options for completion
_get_names_from_array() _cargo_names_from_array() {
{ # strip json from the path
local -a filelist; local manifest=${${${"$(cargo locate-project)"}%\"\}}##*\"}
local manifest=$(_locate_manifest)
if [[ -z $manifest ]]; then if [[ -z $manifest ]]; then
return 0 return 0
fi fi
@ -494,51 +372,36 @@ _get_names_from_array()
local in_block=false local in_block=false
local block_name=$1 local block_name=$1
names=() names=()
while read line while read -r line; do
do
if [[ $last_line == "[[$block_name]]" ]]; then if [[ $last_line == "[[$block_name]]" ]]; then
in_block=true in_block=true
else else
if [[ $last_line =~ '.*\[\[.*' ]]; then if [[ $last_line =~ '\s*\[\[.*' ]]; then
in_block=false in_block=false
fi fi
fi fi
if [[ $in_block == true ]]; then if [[ $in_block == true ]]; then
if [[ $line =~ '.*name.*=' ]]; then if [[ $line =~ '\s*name\s*=' ]]; then
regexp-replace line '^.*name *= *|"' "" regexp-replace line '^\s*name\s*=\s*|"' ''
names+=$line names+=( "$line" )
fi fi
fi fi
last_line=$line last_line=$line
done < $manifest done < "$manifest"
_describe $block_name names _describe "$block_name" names
} }
#Gets the test names from the manifest file #Gets the test names from the manifest file
_test_names() _cargo_test_names() {
{ _cargo_names_from_array "test"
_get_names_from_array "test"
} }
#Gets the bench names from the manifest file #Gets the bench names from the manifest file
_benchmark_names() _cargo_benchmark_names() {
{ _cargo_names_from_array "bench"
_get_names_from_array "bench"
} }
# These flags are mutually exclusive specifiers for the scope of a command; as
# they are used in multiple places without change, they are expanded into the
# appropriate command's `_arguments` where appropriate.
set command_scope_spec
command_scope_spec=(
'(--bin --example --test --lib)--bench=[benchmark name]: :_benchmark_names'
'(--bench --bin --test --lib)--example=[example name]'
'(--bench --example --test --lib)--bin=[binary name]'
'(--bench --bin --example --test)--lib=[library name]'
'(--bench --bin --example --lib)--test=[test name]'
)
_cargo _cargo

View File

@ -2,28 +2,16 @@
Plugin for displaying images on the terminal using the the `catimg.sh` script provided by [posva](https://github.com/posva/catimg) Plugin for displaying images on the terminal using the the `catimg.sh` script provided by [posva](https://github.com/posva/catimg)
To use it, add `catimg` to the plugins array in your zshrc file:
```zsh
plugins=(... catimg)
```
## Requirements ## Requirements
- `convert` (ImageMagick) - `convert` (ImageMagick)
## Enabling the plugin
1. Open your `.zshrc` file and add `catimg` in the plugins section:
```zsh
plugins=(
# all your enabled plugins
catimg
)
```
2. Reload the source file or restart your Terminal session:
```console
$ source ~/.zshrc
$
```
## Functions ## Functions
| Function | Description | | Function | Description |

View File

@ -0,0 +1,20 @@
# chruby plugin
This plugin loads [chruby](https://github.com/postmodern/chruby), a tool that changes the
current Ruby version, and completion and a prompt function to display the Ruby version.
Supports brew and manual installation of chruby.
To use it, add `chruby` to the plugins array in your zshrc file:
```zsh
plugins=(... chruby)
```
## Usage
If you'd prefer to specify an explicit path to load chruby from
you can set variables like so:
```
zstyle :omz:plugins:chruby path /local/path/to/chruby.sh
zstyle :omz:plugins:chruby auto /local/path/to/auto.sh
```

View File

@ -1,6 +1,6 @@
# chucknorris # chucknorris
Chuck Norris fortunes plugin for oh-my-zsh Chuck Norris fortunes plugin for oh-my-zsh. Perfectly suitable as MOTD.
**Maintainers**: [apjanke](https://github.com/apjanke) [maff](https://github.com/maff) **Maintainers**: [apjanke](https://github.com/apjanke) [maff](https://github.com/maff)
@ -10,11 +10,31 @@ To use it add `chucknorris` to the plugins array in you zshrc file.
plugins=(... chucknorris) plugins=(... chucknorris)
``` ```
## Usage
Depends on fortune (and cowsay if using chuck_cow) being installed (available via homebrew, apt, ...). Perfectly suitable as MOTD.
| Command | Description | | Command | Description |
| ----------- | ------------------------------- | | ----------- | ------------------------------- |
| `chuck` | Print random Chuck Norris quote | | `chuck` | Print random Chuck Norris quote |
| `chuck_cow` | Print quote in cowthink | | `chuck_cow` | Print quote in cowthink |
Example: output of `chuck_cow`:
```
Last login: Fri Jan 30 23:12:26 on ttys001
______________________________________
( When Chuck Norris plays Monopoly, it )
( affects the actual world economy. )
--------------------------------------
o ^__^
o (oo)\_______
(__)\ )\/\
||----w |
|| ||
```
## Requirements
- `fortune`
- `cowsay` if using `chuck_cow`
Available via homebrew, apt, ...

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,26 @@
# CloudApp plugin
## The CloudApp API is deprecated, so the plugin will be removed shortly
[CloudApp](https://www.getcloudapp.com) brings screen recording, screenshots, and GIF creation to the cloud, in an easy-to-use enterprise-level app. The CloudApp plugin allows you to upload a file to your CloadApp account from the command line.
To use it, add `cloudapp` to the plugins array of your `~/.zshrc` file:
```zsh
plugins=(... cloudapp)
```
## Requirements
1. [Aaron Russell's `cloudapp_api` gem](https://github.com/aaronrussell/cloudapp_api#installation)
2. That you set your CloudApp credentials in `~/.cloudapp` as a simple text file like below:
```
email
password
```
## Usage
- `cloudapp <filename>`: uploads `<filename>` to your CloudApp account, and if you're using
macOS, copies the URL to your clipboard.

View File

@ -1,6 +1,4 @@
alias cloudapp="${0:a:h}/cloudapp.rb" print -Pn "%F{yellow}"
print "[oh-my-zsh] The CloudApp API no longer works, so the cloudapp plugin will"
# Ensure only the owner can access the credentials file print "[oh-my-zsh] be removed shortly. Please remove it from your plugins list."
if [[ -f ~/.cloudapp ]]; then print -Pn "%f"
chmod 600 ~/.cloudapp
fi

View File

@ -1,60 +0,0 @@
#!/usr/bin/env ruby
#
# cloudapp
# Zach Holman / @holman
#
# Uploads a file from the command line to CloudApp, drops it into your
# clipboard (on a Mac, at least).
#
# Example:
#
# cloudapp drunk-blake.png
#
# This requires Aaron Russell's cloudapp_api gem:
#
# gem install cloudapp_api
#
# Requires you set your CloudApp credentials in ~/.cloudapp as a simple file of:
#
# email
# password
require 'rubygems'
begin
require 'cloudapp_api'
rescue LoadError
puts "You need to install cloudapp_api: gem install cloudapp_api"
exit!(1)
end
config_file = "#{ENV['HOME']}/.cloudapp"
unless File.exist?(config_file)
puts "You need to type your email and password (one per line) into "+
"`~/.cloudapp`"
exit!(1)
end
email,password = File.read(config_file).split("\n")
class HTTParty::Response
# Apparently HTTPOK.ok? IS NOT OKAY WTFFFFFFFFFFUUUUUUUUUUUUUU
# LETS MONKEY PATCH IT I FEEL OKAY ABOUT IT
def ok? ; true end
end
if ARGV[0].nil?
puts "You need to specify a file to upload."
exit!(1)
end
CloudApp.authenticate(email,password)
url = CloudApp::Item.create(:upload, {:file => ARGV[0]}).url
# Say it for good measure.
puts "Uploaded to #{url}."
# Get the embed link.
url = "#{url}/#{ARGV[0].split('/').last}"
# Copy it to your (Mac's) clipboard.
`echo '#{url}' | tr -d "\n" | pbcopy`

View File

@ -0,0 +1,8 @@
# codeclimate plugin
This plugin adds autocompletion for the [`codeclimate` CLI](https://github.com/codeclimate/codeclimate).
To use it, add `codeclimate` to the plugins array in your zshrc file:
```zsh
plugins=(... codeclimate)
```

View File

@ -1,4 +1,4 @@
## Coffeescript Plugin # Coffeescript Plugin
This plugin provides aliases for quickly compiling and previewing your This plugin provides aliases for quickly compiling and previewing your
coffeescript code. coffeescript code.

View File

@ -0,0 +1,48 @@
# Colemak plugin
This plugin remaps keys in `zsh`'s [`vi`-style navigation mode](http://zsh.sourceforge.net/Doc/Release/Zsh-Line-Editor.html#Keymaps)
for a [Colemak](https://colemak.com/) keyboard layout, to match the QWERTY position:
![Colemak layout on a US keyboard](https://colemak.com/wiki/images/6/6c/Colemak2.png)
To use it, add it to the plugins array in your `~/.zshrc` file:
```
plugins=(... colemak)
```
You will also need to enable `vi` mode, so add another line to `~/.zshrc`:
```
bindkey -v
```
Restart your shell and hit the `<ESC>` key to activate `vicmd` (navigation) mode,
and start navigating `zsh` with your new keybindings!
## Key bindings for vicmd
| Old | New | Binding | Description |
|------------|------------|---------------------------|----------------------------------------------------|
| `CTRL`+`j` | `CTRL`+`n` | accept-line | Insert new line |
| `j` | `n` | down-line-or-history | Move one line down or command history forwards |
| `k` | `e` | up-line-or-history | Move one line up or command history backwards |
| `l` | `i` | vi-forward-char | Move one character to the right |
| `n` | `k` | vi-repeat-search | Repeat command search forwards |
| `N` | `K` | vi-rev-repeat-search | Repeat command search backwards |
| `i` | `u` | vi-insert | Enter insert mode |
| `I` | `U` | vi-insert-bol | Move to first non-blank char and enter insert mode |
| `<none>` | `l` | vi-undo-change | Undo change |
| `J` | `N` | vi-join | Join the current line with the next one |
| `e` | `j` | vi-forward-word-end | Move to the end of the next word |
| `E` | `J` | vi-forward-blank-word-end | Move to end of the current or next word |
## Key bindings for less
| Keyboard shortcut | `less` key binding |
|-------------------|--------------------|
| `n` | forw-line |
| `e` | back-line |
| `k` | repeat-search |
| `ESC`+`k` | repeat-search-all |
| `K` | reverse-search |
| `ESC`+`K` | reverse-search-all |

View File

@ -8,8 +8,25 @@ To use it, add `colored-man-pages` to the plugins array in your zshrc file:
plugins=(... colored-man-pages) plugins=(... colored-man-pages)
``` ```
It will also automatically colorize man pages displayed by `dman` or `debman`,
from [`debian-goodies`](https://packages.debian.org/stable/debian-goodies).
You can also try to color other pages by prefixing the respective command with `colored`: You can also try to color other pages by prefixing the respective command with `colored`:
```zsh ```zsh
colored git help clone colored git help clone
``` ```
## Customization
The plugin declares global associative array `less_termcap`, which maps termcap capabilities to escape
sequences for the `less` pager. This mapping can be further customized by the user after the plugin is
loaded. Check out sources for more.
For example: `less_termcap[md]` maps to `LESS_TERMCAP_md` which is the escape sequence that tells `less`
how to print something in bold. It's currently shown in bold red, but if you want to change it, you
can redefine `less_termcap[md]` in your zshrc file, after OMZ is sourced:
```zsh
less_termcap[md]="${fg_bold[blue]}" # this tells less to print bold text in bold blue
```

View File

@ -1,36 +1,48 @@
if [[ "$OSTYPE" = solaris* ]] # Requires colors autoload.
then # See termcap(5).
if [[ ! -x "$HOME/bin/nroff" ]]
then # Set up once, and then reuse. This way it supports user overrides after the
mkdir -p "$HOME/bin" # plugin is loaded.
cat > "$HOME/bin/nroff" <<EOF typeset -AHg less_termcap
#!/bin/sh
if [ -n "\$_NROFF_U" -a "\$1,\$2,\$3" = "-u0,-Tlp,-man" ]; then # bold & blinking mode
shift less_termcap[mb]="${fg_bold[red]}"
exec /usr/bin/nroff -u\$_NROFF_U "\$@" less_termcap[md]="${fg_bold[red]}"
fi less_termcap[me]="${reset_color}"
#-- Some other invocation of nroff # standout mode
exec /usr/bin/nroff "\$@" less_termcap[so]="${fg_bold[yellow]}${bg[blue]}"
EOF less_termcap[se]="${reset_color}"
chmod +x "$HOME/bin/nroff" # underlining
fi less_termcap[us]="${fg_bold[green]}"
fi less_termcap[ue]="${reset_color}"
# Absolute path to this file's directory.
typeset __colored_man_pages_dir="${0:A:h}"
function colored() { function colored() {
env \ local -a environment
LESS_TERMCAP_mb=$(printf "\e[1;31m") \
LESS_TERMCAP_md=$(printf "\e[1;31m") \ # Convert associative array to plain array of NAME=VALUE items.
LESS_TERMCAP_me=$(printf "\e[0m") \ local k v
LESS_TERMCAP_se=$(printf "\e[0m") \ for k v in "${(@kv)less_termcap}"; do
LESS_TERMCAP_so=$(printf "\e[1;44;33m") \ environment+=( "LESS_TERMCAP_${k}=${v}" )
LESS_TERMCAP_ue=$(printf "\e[0m") \ done
LESS_TERMCAP_us=$(printf "\e[1;32m") \
PAGER="${commands[less]:-$PAGER}" \ # Prefer `less` whenever available, since we specifically configured
_NROFF_U=1 \ # environment for it.
PATH="$HOME/bin:$PATH" \ environment+=( PAGER="${commands[less]:-$PAGER}" )
"$@"
# See ./nroff script.
if [[ "$OSTYPE" = solaris* ]]; then
environment+=( PATH="${__colored_man_pages_dir}:$PATH" )
fi
command env $environment "$@"
} }
function man() { # Colorize man and dman/debman (from debian-goodies)
colored man "$@" function man \
dman \
debman {
colored $0 "$@"
} }

View File

@ -0,0 +1,12 @@
#!/bin/sh
# The whole point of this wrapper is to replace emboldening factor -u0 with
# -u1 under certain circumstances on Solaris.
if [ "$1,$2,$3" = "-u0,-Tlp,-man" ]; then
shift
exec /usr/bin/nroff -u1 "$@"
else
# Some other invocation of nroff
exec /usr/bin/nroff "$@"
fi

View File

@ -6,30 +6,51 @@ Colorize will highlight the content based on the filename extension. If it can't
method for a given extension, it will try to find one by looking at the file contents. If no highlight method method for a given extension, it will try to find one by looking at the file contents. If no highlight method
is found it will just cat the file normally, without syntax highlighting. is found it will just cat the file normally, without syntax highlighting.
To use it, add colorize to the plugins array of your zshrc file: ## Setup
To use it, add colorize to the plugins array of your `~/.zshrc` file:
``` ```
plugins=(... colorize) plugins=(... colorize)
``` ```
## Styles ## Configuration
### Requirements
This plugin requires that at least one of the following tools is installed:
* [Chroma](https://github.com/alecthomas/chroma)
* [Pygments](https://pygments.org/download/)
### Colorize tool
Colorize supports `pygmentize` and `chroma` as syntax highlighter. By default colorize uses `pygmentize` unless it's not installed and `chroma` is. This can be overridden by the `ZSH_COLORIZE_TOOL` environment variable:
```
ZSH_COLORIZE_TOOL=chroma
```
### Styles
Pygments offers multiple styles. By default, the `default` style is used, but you can choose another theme by setting the `ZSH_COLORIZE_STYLE` environment variable: Pygments offers multiple styles. By default, the `default` style is used, but you can choose another theme by setting the `ZSH_COLORIZE_STYLE` environment variable:
`ZSH_COLORIZE_STYLE="colorful"` ```
ZSH_COLORIZE_STYLE="colorful"
```
### Chroma Formatter Settings
Chroma supports terminal output in 8 color, 256 color, and true-color. If you need to change the default terminal output style from the standard 8 color output, set the `ZSH_COLORIZE_CHROMA_FORMATTER` environment variable:
```
ZSH_COLORIZE_CHROMA_FORMATTER=terminal256
```
## Usage ## Usage
* `ccat <file> [files]`: colorize the contents of the file (or files, if more than one are provided). * `ccat <file> [files]`: colorize the contents of the file (or files, if more than one are provided).
If no arguments are passed it will colorize the standard input or stdin. If no files are passed it will colorize the standard input.
* `cless <file> [files]`: colorize the contents of the file (or files, if more than one are provided) and * `cless [less-options] <file> [files]`: colorize the contents of the file (or files, if more than one are provided) and open less.
open less. If no arguments are passed it will colorize the standard input or stdin. If no files are passed it will colorize the standard input.
The LESSOPEN and LESSCLOSE will be overwritten for this to work, but only in a local scope.
Note that `cless` will behave as less when provided more than one file: you have to navigate files with
the commands `:n` for next and `:p` for previous. The downside is that less options are not supported.
But you can circumvent this by either using the LESS environment variable, or by running `ccat file1 file2|less --opts`.
In the latter form, the file contents will be concatenated and presented by less as a single file.
## Requirements
You have to install Pygments first: [pygments.org](http://pygments.org/download/)

View File

@ -1,57 +1,114 @@
# easier alias to use the plugin # Easier alias to use the plugin
alias ccat='colorize_via_pygmentize' alias ccat="colorize_cat"
alias cless='colorize_via_pygmentize_less' alias cless="colorize_less"
colorize_via_pygmentize() { # '$0:A' gets the absolute path of this file
if ! (( $+commands[pygmentize] )); then ZSH_COLORIZE_PLUGIN_PATH=$0:A
echo "package 'Pygments' is not installed!"
colorize_check_requirements() {
local -a available_tools
available_tools=("chroma" "pygmentize")
if [ -z "$ZSH_COLORIZE_TOOL" ]; then
if (( $+commands[pygmentize] )); then
ZSH_COLORIZE_TOOL="pygmentize"
elif (( $+commands[chroma] )); then
ZSH_COLORIZE_TOOL="chroma"
else
echo "Neither 'pygments' nor 'chroma' is installed!" >&2
return 1
fi
fi
if [[ ${available_tools[(Ie)$ZSH_COLORIZE_TOOL]} -eq 0 ]]; then
echo "ZSH_COLORIZE_TOOL '$ZSH_COLORIZE_TOOL' not recognized. Available options are 'pygmentize' and 'chroma'." >&2
return 1
elif (( $+commands["$ZSH_COLORIZE_TOOL"] )); then
echo "Package '$ZSH_COLORIZE_TOOL' is not installed!" >&2
return 1
fi
}
colorize_cat() {
if ! colorize_check_requirements; then
return 1 return 1
fi fi
# If the environment varianle ZSH_COLORIZE_STYLE # If the environment variable ZSH_COLORIZE_STYLE
# is set, use that theme instead. Otherwise, # is set, use that theme instead. Otherwise,
# use the default. # use the default.
if [ -z $ZSH_COLORIZE_STYLE ]; then if [ -z "$ZSH_COLORIZE_STYLE" ]; then
ZSH_COLORIZE_STYLE="default" # Both pygmentize & chroma support 'emacs'
ZSH_COLORIZE_STYLE="emacs"
fi fi
# pygmentize stdin if no arguments passed # Use stdin if no arguments have been passed.
if [ $# -eq 0 ]; then if [ $# -eq 0 ]; then
pygmentize -O style="$ZSH_COLORIZE_STYLE" -g if [[ "$ZSH_COLORIZE_TOOL" == "pygmentize" ]]; then
pygmentize -O style="$ZSH_COLORIZE_STYLE" -g
else
chroma --style="$ZSH_COLORIZE_STYLE" --formatter="${ZSH_COLORIZE_CHROMA_FORMATTER:-terminal}"
fi
return $? return $?
fi fi
# guess lexer from file extension, or # Guess lexer from file extension, or guess it from file contents if unsuccessful.
# guess it from file contents if unsuccessful
local FNAME lexer local FNAME lexer
for FNAME in "$@" for FNAME in "$@"; do
do if [[ "$ZSH_COLORIZE_TOOL" == "pygmentize" ]]; then
lexer=$(pygmentize -N "$FNAME") lexer=$(pygmentize -N "$FNAME")
if [[ $lexer != text ]]; then if [[ $lexer != text ]]; then
pygmentize -O style="$ZSH_COLORIZE_STYLE" -l "$lexer" "$FNAME" pygmentize -O style="$ZSH_COLORIZE_STYLE" -l "$lexer" "$FNAME"
else
pygmentize -O style="$ZSH_COLORIZE_STYLE" -g "$FNAME"
fi
else else
pygmentize -O style="$ZSH_COLORIZE_STYLE" -g "$FNAME" chroma --style="$ZSH_COLORIZE_STYLE" --formatter="${ZSH_COLORIZE_CHROMA_FORMATTER:-terminal}" "$FNAME"
fi fi
done done
} }
colorize_via_pygmentize_less() ( # The less option 'F - Forward forever; like "tail -f".' will not work in this implementation
# this function is a subshell so tmp_files can be shared to cleanup function # caused by the lack of the ability to follow the file within pygmentize.
declare -a tmp_files colorize_less() {
if ! colorize_check_requirements; then
return 1
fi
cleanup () { _cless() {
[[ ${#tmp_files} -gt 0 ]] && rm -f "${tmp_files[@]}" # LESS="-R $LESS" enables raw ANSI colors, while maintain already set options.
exit local LESS="-R $LESS"
# This variable tells less to pipe every file through the specified command
# (see the man page of less INPUT PREPROCESSOR).
# 'zsh -ic "colorize_cat %s 2> /dev/null"' would not work for huge files like
# the ~/.zsh_history. For such files the tty of the preprocessor will be supended.
# Therefore we must source this file to make colorize_cat available in the
# preprocessor without the interactive mode.
# `2>/dev/null` will suppress the error for large files 'broken pipe' of the python
# script pygmentize, which will show up if less has not fully "loaded the file"
# (e.g. when not scrolled to the bottom) while already the next file will be displayed.
local LESSOPEN="| zsh -c 'source \"$ZSH_COLORIZE_PLUGIN_PATH\"; \
ZSH_COLORIZE_TOOL=$ZSH_COLORIZE_TOOL ZSH_COLORIZE_STYLE=$ZSH_COLORIZE_STYLE \
colorize_cat %s 2> /dev/null'"
# LESSCLOSE will be set to prevent any errors by executing a user script
# which assumes that his LESSOPEN has been executed.
local LESSCLOSE=""
LESS="$LESS" LESSOPEN="$LESSOPEN" LESSCLOSE="$LESSCLOSE" command less "$@"
} }
trap 'cleanup' EXIT HUP TERM INT
while (( $# != 0 )); do #TODO: filter out less opts if [ -t 0 ]; then
tmp_file="$(mktemp -t "tmp.colorize.XXXX.$(sed 's/\//./g' <<< "$1")")" _cless "$@"
tmp_files+=("$tmp_file") else
colorize_via_pygmentize "$1" > "$tmp_file" # The input is not associated with a terminal, therefore colorize_cat will
shift 1 # colorize this input and pass it to less.
done # Less has now to decide what to use. If any files have been provided, less
# will ignore the input by default, otherwise the colorized input will be used.
less -f "${tmp_files[@]}" # If files have been supplied and the input has been redirected, this will
) # lead to unnecessary overhead, but retains the ability to use the less options
# without checking for them inside this script.
colorize_cat | _cless "$@"
fi
}

View File

@ -28,5 +28,6 @@ It works out of the box with the command-not-found packages for:
- [macOS (Homebrew)](https://github.com/Homebrew/homebrew-command-not-found) - [macOS (Homebrew)](https://github.com/Homebrew/homebrew-command-not-found)
- [Fedora](https://fedoraproject.org/wiki/Features/PackageKitCommandNotFound) - [Fedora](https://fedoraproject.org/wiki/Features/PackageKitCommandNotFound)
- [NixOS](https://github.com/NixOS/nixpkgs/tree/master/nixos/modules/programs/command-not-found) - [NixOS](https://github.com/NixOS/nixpkgs/tree/master/nixos/modules/programs/command-not-found)
- [Termux](https://github.com/termux/command-not-found)
You can add support for other platforms by submitting a Pull Request. You can add support for other platforms by submitting a Pull Request.

View File

@ -1,40 +1,62 @@
# Uses the command-not-found package zsh support ## Platforms with a built-in command-not-found handler init file
# as seen in https://www.porcheron.info/command-not-found-for-zsh/
# this is installed in Ubuntu
[[ -e /etc/zsh_command_not_found ]] && source /etc/zsh_command_not_found for file (
# Arch Linux. Must have pkgfile installed: https://wiki.archlinux.org/index.php/Pkgfile#Command_not_found
# Arch Linux command-not-found support, you must have package pkgfile installed /usr/share/doc/pkgfile/command-not-found.zsh
# https://wiki.archlinux.org/index.php/Pkgfile#.22Command_not_found.22_hook # macOS (M1 and classic Homebrew): https://github.com/Homebrew/homebrew-command-not-found
[[ -e /usr/share/doc/pkgfile/command-not-found.zsh ]] && source /usr/share/doc/pkgfile/command-not-found.zsh /opt/homebrew/Library/Taps/homebrew/homebrew-command-not-found/handler.sh
/usr/local/Homebrew/Library/Taps/homebrew/homebrew-command-not-found/handler.sh
# Fedora command-not-found support ); do
if [ -f /usr/libexec/pk-command-not-found ]; then if [[ -r "$file" ]]; then
command_not_found_handler () { source "$file"
runcnf=1 unset file
retval=127 return 0
[ ! -S /var/run/dbus/system_bus_socket ] && runcnf=0
[ ! -x /usr/libexec/packagekitd ] && runcnf=0
if [ $runcnf -eq 1 ]
then
/usr/libexec/pk-command-not-found $@
retval=$?
fi
return $retval
}
fi
# OSX command-not-found support
# https://github.com/Homebrew/homebrew-command-not-found
if type brew &> /dev/null; then
if brew command command-not-found-init > /dev/null 2>&1; then
eval "$(brew command-not-found-init)";
fi fi
done
unset file
## Platforms with manual command_not_found_handler() setup
# Debian and derivatives: https://launchpad.net/ubuntu/+source/command-not-found
if [[ -x /usr/lib/command-not-found || -x /usr/share/command-not-found/command-not-found ]]; then
command_not_found_handler() {
if [[ -x /usr/lib/command-not-found ]]; then
/usr/lib/command-not-found -- "$1"
return $?
elif [[ -x /usr/share/command-not-found/command-not-found ]]; then
/usr/share/command-not-found/command-not-found -- "$1"
return $?
else
printf "zsh: command not found: %s\n" "$1" >&2
return 127
fi
}
fi fi
# NixOS command-not-found support # Fedora: https://fedoraproject.org/wiki/Features/PackageKitCommandNotFound
if [ -x /run/current-system/sw/bin/command-not-found ]; then if [[ -x /usr/libexec/pk-command-not-found ]]; then
command_not_found_handler () { command_not_found_handler() {
/run/current-system/sw/bin/command-not-found $@ if [[ -S /var/run/dbus/system_bus_socket && -x /usr/libexec/packagekitd ]]; then
} /usr/libexec/pk-command-not-found "$@"
return $?
fi
printf "zsh: command not found: %s\n" "$1" >&2
return 127
}
fi
# NixOS: https://github.com/NixOS/nixpkgs/tree/master/nixos/modules/programs/command-not-found
if [[ -x /run/current-system/sw/bin/command-not-found ]]; then
command_not_found_handler() {
/run/current-system/sw/bin/command-not-found -- "$@"
}
fi
# Termux: https://github.com/termux/command-not-found
if [[ -x /data/data/com.termux/files/usr/libexec/termux/command-not-found ]]; then
command_not_found_handler() {
/data/data/com.termux/files/usr/libexec/termux/command-not-found -- "$1"
}
fi fi

View File

@ -40,11 +40,13 @@ plugins=(... common-aliases)
| Alias | Command | Description | | Alias | Command | Description |
|-------|-----------------------------------------------------|-----------------------------------------| |-------|-----------------------------------------------------|-----------------------------------------|
| fd | `find . -type d -name` | Find a directory with the given name | | fd\* | `find . -type d -name` | Find a directory with the given name |
| ff | `find . -type f -name` | Find a file with the given name | | ff | `find . -type f -name` | Find a file with the given name |
| grep | `grep --color` | Searches for a query string | | grep | `grep --color` | Searches for a query string |
| sgrep | `grep -R -n -H -C 5 --exclude-dir={.git,.svn,CVS}` | Useful for searching within files | | sgrep | `grep -R -n -H -C 5 --exclude-dir={.git,.svn,CVS}` | Useful for searching within files |
\* Only if the [`fd`](https://github.com/sharkdp/fd) command isn't installed.
### Other Aliases ### Other Aliases
| Alias | Command | Description | | Alias | Command | Description |

View File

@ -13,7 +13,7 @@ alias lS='ls -1FSsh'
alias lart='ls -1Fcart' alias lart='ls -1Fcart'
alias lrt='ls -1Fcrt' alias lrt='ls -1Fcrt'
alias zshrc='${=EDITOR} ~/.zshrc' # Quick access to the ~/.zshrc file alias zshrc='${=EDITOR} ${ZDOTDIR:-$HOME}/.zshrc' # Quick access to the .zshrc file
alias grep='grep --color' alias grep='grep --color'
alias sgrep='grep -R -n -H -C 5 --exclude-dir={.git,.svn,CVS} ' alias sgrep='grep -R -n -H -C 5 --exclude-dir={.git,.svn,CVS} '
@ -34,7 +34,7 @@ alias -g P="2>&1| pygmentize -l pytb"
alias dud='du -d 1 -h' alias dud='du -d 1 -h'
alias duf='du -sh *' alias duf='du -sh *'
alias fd='find . -type d -name' (( $+commands[fd] )) || alias fd='find . -type d -name'
alias ff='find . -type f -name' alias ff='find . -type f -name'
alias h='history' alias h='history'
@ -50,19 +50,20 @@ alias mv='mv -i'
# zsh is able to auto-do some kungfoo # zsh is able to auto-do some kungfoo
# depends on the SUFFIX :) # depends on the SUFFIX :)
autoload -Uz is-at-least
if is-at-least 4.2.0; then if is-at-least 4.2.0; then
# open browser on urls # open browser on urls
if [[ -n "$BROWSER" ]]; then if [[ -n "$BROWSER" ]]; then
_browser_fts=(htm html de org net com at cx nl se dk) _browser_fts=(htm html de org net com at cx nl se dk)
for ft in $_browser_fts; do alias -s $ft=$BROWSER; done for ft in $_browser_fts; do alias -s $ft='$BROWSER'; done
fi fi
_editor_fts=(cpp cxx cc c hh h inl asc txt TXT tex) _editor_fts=(cpp cxx cc c hh h inl asc txt TXT tex)
for ft in $_editor_fts; do alias -s $ft=$EDITOR; done for ft in $_editor_fts; do alias -s $ft='$EDITOR'; done
if [[ -n "$XIVIEWER" ]]; then if [[ -n "$XIVIEWER" ]]; then
_image_fts=(jpg jpeg png gif mng tiff tif xpm) _image_fts=(jpg jpeg png gif mng tiff tif xpm)
for ft in $_image_fts; do alias -s $ft=$XIVIEWER; done for ft in $_image_fts; do alias -s $ft='$XIVIEWER'; done
fi fi
_media_fts=(ape avi flv m4a mkv mov mp3 mpeg mpg ogg ogm rm wav webm) _media_fts=(ape avi flv m4a mkv mov mp3 mpeg mpg ogg ogm rm wav webm)

View File

@ -0,0 +1,9 @@
# compleat plugin
This plugin looks for [compleat](https://github.com/mbrubeck/compleat) and loads its completion.
To use it, add compleat to the plugins array in your zshrc file:
```zsh
plugins=(... compleat)
```

View File

@ -12,18 +12,20 @@ plugins=(... composer)
## Aliases ## Aliases
| Alias | Command | Description | | Alias | Command | Description |
| ------ | -------------------------------------------- | -------------------------------------------------------------------------------------- | | ------ | ------------------------------------------- | --------------------------------------------------------------------------------------- |
| `c` | composer | Starts composer | | `c` | `composer` | Starts composer |
| `csu` | composer self-update | Updates composer to the latest version | | `csu` | `composer self-update` | Updates composer to the latest version |
| `cu` | composer update | Updates composer dependencies and `composer.lock` file | | `cu` | `composer update` | Updates composer dependencies and `composer.lock` file |
| `cr` | composer require | Adds new packages to `composer.json` | | `cr` | `composer require` | Adds new packages to `composer.json` |
| `crm` | composer remove | Removes packages from `composer.json` | | `crm` | `composer remove` | Removes packages from `composer.json` |
| `ci` | composer install | Resolves and installs dependencies from `composer.json` | | `ci` | `composer install` | Resolves and installs dependencies from `composer.json` |
| `ccp` | composer create-project | Create new project from an existing package | | `ccp` | `composer create-project` | Create new project from an existing package |
| `cdu` | composer dump-autoload | Updates the autoloader | | `cdu` | `composer dump-autoload` | Updates the autoloader |
| `cdo` | composer dump-autoload --optimize-autoloader | Converts PSR-0/4 autoloading to classmap for a faster autoloader (good for production) | | `cdo` | `composer dump-autoload -o` | Converts PSR-0/4 autoloading to classmap for a faster autoloader (good for production) |
| `cgu` | composer global update | Allows update command to run on COMPOSER_HOME directory | | `cgu` | `composer global update` | Allows update command to run on COMPOSER_HOME directory |
| `cgr` | composer global require | Allows require command to run on COMPOSER_HOME directory | | `cgr` | `composer global require` | Allows require command to run on COMPOSER_HOME directory |
| `cgrm` | composer global remove | Allows remove command to run on COMPOSER_HOME directory | | `cgrm` | `composer global remove` | Allows remove command to run on COMPOSER_HOME directory |
| `cget` | `curl -s https://getcomposer.org/installer` | Installs composer in the current directory | | `cget` | `curl -s https://getcomposer.org/installer` | Installs composer in the current directory |
| `co` | `composer outdated` | Shows a list of installed packages with available updates |
| `cod` | `composer outdated --direct` | Shows a list of installed packages with available updates which are direct dependencies |

View File

@ -15,20 +15,16 @@ _composer_get_required_list () {
} }
_composer () { _composer () {
local curcontext="$curcontext" state line local curcontext="$curcontext" state line
typeset -A opt_args typeset -A opt_args
_arguments \ _arguments \
'1: :->command'\ '*:: :->subcmds'
'*: :->args'
case $state in if (( CURRENT == 1 )) || ( ((CURRENT == 2)) && [ "$words[1]" = "global" ] ) ; then
command) compadd $(_composer_get_command_list)
compadd $(_composer_get_command_list) else
;; compadd $(_composer_get_required_list)
*) fi
compadd $(_composer_get_required_list)
;;
esac
} }
compdef _composer composer compdef _composer composer
@ -43,17 +39,31 @@ alias crm='composer remove'
alias ci='composer install' alias ci='composer install'
alias ccp='composer create-project' alias ccp='composer create-project'
alias cdu='composer dump-autoload' alias cdu='composer dump-autoload'
alias cdo='composer dump-autoload --optimize-autoloader' alias cdo='composer dump-autoload -o'
alias cgu='composer global update' alias cgu='composer global update'
alias cgr='composer global require' alias cgr='composer global require'
alias cgrm='composer global remove' alias cgrm='composer global remove'
alias co='composer outdated'
alias cod='composer outdated --direct'
# install composer in the current directory # install composer in the current directory
alias cget='curl -s https://getcomposer.org/installer | php' alias cget='curl -s https://getcomposer.org/installer | php'
# Add Composer's global binaries to PATH, using Composer if available. # Add Composer's global binaries to PATH, using Composer if available.
if (( $+commands[composer] )); then if (( $+commands[composer] )); then
export PATH=$PATH:$(composer global config bin-dir --absolute 2>/dev/null) autoload -Uz _store_cache _retrieve_cache _cache_invalid
_retrieve_cache composer
if [[ -z $__composer_bin_dir ]]; then
__composer_bin_dir=$(composer global config bin-dir --absolute 2>/dev/null)
_store_cache composer __composer_bin_dir
fi
# Add Composer's global binaries to PATH
export PATH="$PATH:$__composer_bin_dir"
unset __composer_bin_dir
else else
[ -d $HOME/.composer/vendor/bin ] && export PATH=$PATH:$HOME/.composer/vendor/bin [ -d $HOME/.composer/vendor/bin ] && export PATH=$PATH:$HOME/.composer/vendor/bin
[ -d $HOME/.config/composer/vendor/bin ] && export PATH=$PATH:$HOME/.config/composer/vendor/bin [ -d $HOME/.config/composer/vendor/bin ] && export PATH=$PATH:$HOME/.config/composer/vendor/bin

View File

@ -1,9 +1,9 @@
# copy the active line from the command line buffer # copy the active line from the command line buffer
# onto the system clipboard (requires clipcopy plugin) # onto the system clipboard
copybuffer () { copybuffer () {
if which clipcopy &>/dev/null; then if which clipcopy &>/dev/null; then
echo $BUFFER | clipcopy printf "%s" "$BUFFER" | clipcopy
else else
echo "clipcopy function not found. Please make sure you have Oh My Zsh installed correctly." echo "clipcopy function not found. Please make sure you have Oh My Zsh installed correctly."
fi fi

View File

@ -3,7 +3,8 @@
Puts the contents of a file in your system clipboard so you can paste it anywhere. Puts the contents of a file in your system clipboard so you can paste it anywhere.
To use, add `copyfile` to your plugins array: To use, add `copyfile` to your plugins array:
```
```zsh
plugins=(... copyfile) plugins=(... copyfile)
``` ```

View File

@ -4,6 +4,6 @@ This plugin provides completion for [Cpanm](https://github.com/miyagawa/cpanminu
To use it add cpanm to the plugins array in your zshrc file. To use it add cpanm to the plugins array in your zshrc file.
```bash ```zsh
plugins=(... cpanm) plugins=(... cpanm)
``` ```

View File

@ -0,0 +1,28 @@
# Dash plugin
This plugin adds command line functionality for [Dash](https://kapeli.com/dash),
an API Documentation Browser for macOS. This plugin requires Dash to be installed
to work.
To use it, add `dash` to the plugins array in your zshrc file:
```zsh
plugins=(... dash)
```
## Usage
- Open and switch to the dash application.
```
dash
```
- Query for something in dash app: `dash query`
```
dash golang
```
- You can optionally provide a keyword: `dash [keyword:]query`
```
dash python:tuple
```

View File

@ -35,36 +35,30 @@ _dash() {
if [[ "$locator" == "platform" ]]; then if [[ "$locator" == "platform" ]]; then
# Since these are the only special cases right now, let's not do the # Since these are the only special cases right now, let's not do the
# expensive processing unless we have to # expensive processing unless we have to
if [[ "$keyword" == "python" || "$keyword" == "java" || \ if [[ "$keyword" = (python|java|qt|cocos2d) ]]; then
"$keyword" == "qt" || "$keyword" == "cocs2d" ]]; then
docsetName=`echo $doc | grep -Eo "docsetName = .*?;" | sed -e "s/docsetName = \(.*\);/\1/" -e "s/[\":]//g"` docsetName=`echo $doc | grep -Eo "docsetName = .*?;" | sed -e "s/docsetName = \(.*\);/\1/" -e "s/[\":]//g"`
if [[ "$keyword" == "python" ]]; then case "$keyword" in
if [[ "$docsetName" == "Python 2" ]]; then python)
keyword="python2" case "$docsetName" in
elif [[ "$docsetName" == "Python 3" ]]; then "Python 2") keyword="python2" ;;
keyword="python3" "Python 3") keyword="python3" ;;
fi esac ;;
elif [[ "$keyword" == "java" ]]; then java)
if [[ "$docsetName" == "Java SE7" ]]; then case "$docsetName" in
keyword="java7" "Java SE7") keyword="java7" ;;
elif [[ "$docsetName" == "Java SE6" ]]; then "Java SE6") keyword="java6" ;;
keyword="java6" "Java SE8") keyword="java8" ;;
elif [[ "$docsetName" == "Java SE8" ]]; then esac ;;
keyword="java8" qt)
fi case "$docsetName" in
elif [[ "$keyword" == "qt" ]]; then "Qt 5") keyword="qt5" ;;
if [[ "$docsetName" == "Qt 5" ]]; then "Qt 4"|Qt) keyword="qt4" ;;
keyword="qt5" esac ;;
elif [[ "$docsetName" == "Qt 4" ]]; then cocos2d)
keyword="qt4" case "$docsetName" in
elif [[ "$docsetName" == "Qt" ]]; then Cocos3D) keyword="cocos3d" ;;
keyword="qt4" esac ;;
fi esac
elif [[ "$keyword" == "cocos2d" ]]; then
if [[ "$docsetName" == "Cocos3D" ]]; then
keyword="cocos3d"
fi
fi
fi fi
fi fi

View File

@ -66,7 +66,7 @@ if [[ $use_sudo -eq 1 ]]; then
alias di="sudo dpkg -i" alias di="sudo dpkg -i"
# Remove ALL kernel images and headers EXCEPT the one in use # Remove ALL kernel images and headers EXCEPT the one in use
alias kclean='sudo aptitude remove -P ?and(~i~nlinux-(ima|hea) ?not(~n$(uname -r)))' alias kclean='sudo aptitude remove -P "?and(~i~nlinux-(ima|hea) ?not(~n$(uname -r)))"'
# commands using su ######### # commands using su #########
@ -105,7 +105,7 @@ else
alias di='su -lc "dpkg -i" root' alias di='su -lc "dpkg -i" root'
# Remove ALL kernel images and headers EXCEPT the one in use # Remove ALL kernel images and headers EXCEPT the one in use
alias kclean='su -lc "aptitude remove -P ?and(~i~nlinux-(ima|hea) ?not(~n$(uname -r)))" root' alias kclean='su -lc "aptitude remove -P \"?and(~i~nlinux-(ima|hea) ?not(~n$(uname -r)))\"" root'
fi fi
# Completion ################################################################ # Completion ################################################################

1
zsh/plugins/deno/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
_deno

View File

@ -0,0 +1,18 @@
# Deno Plugin
This plugin sets up completion and aliases for [Deno](https://deno.land).
## Aliases
| Alias | Full command |
| ----- | ---------------- |
| db | deno bundle |
| dc | deno compile |
| dca | deno cache |
| dfmt | deno fmt |
| dh | deno help |
| dli | deno lint |
| drn | deno run |
| drw | deno run --watch |
| dts | deno test |
| dup | deno upgrade |

View File

@ -0,0 +1,23 @@
# ALIASES
alias db='deno bundle'
alias dc='deno compile'
alias dca='deno cache'
alias dfmt='deno fmt'
alias dh='deno help'
alias dli='deno lint'
alias drn='deno run'
alias drw='deno run --watch'
alias dts='deno test'
alias dup='deno upgrade'
# COMPLETION FUNCTION
if (( $+commands[deno] )); then
if [[ ! -f $ZSH_CACHE_DIR/deno_version ]] \
|| [[ "$(deno --version)" != "$(< "$ZSH_CACHE_DIR/deno_version")" ]] \
|| [[ ! -f $ZSH/plugins/deno/_deno ]]; then
deno completions zsh > $ZSH/plugins/deno/_deno
deno --version > $ZSH_CACHE_DIR/deno_version
fi
autoload -Uz _deno
_comps[deno]=_deno
fi

View File

@ -15,10 +15,10 @@ This plugin enables directory navigation similar to using back and forward on br
) )
``` ```
2. Reload the source file or restart your Terminal session: 2. Restart the shell or restart your Terminal session:
```console ```console
$ source ~/.zshrc $ exec zsh
$ $
``` ```

View File

@ -0,0 +1,15 @@
# direnv plugin
This plugin creates the [Direnv](https://direnv.net/) hook.
To use it, add `direnv` to the plugins array in your zshrc file:
```zsh
plugins=(... direnv)
```
## Requirements
In order to make this work, you will need to have the direnv installed.
More info on the usage and install: https://github.com/direnv/direnv

View File

@ -0,0 +1,16 @@
# Don't continue if direnv is not found
command -v direnv &>/dev/null || return
_direnv_hook() {
trap -- '' SIGINT;
eval "$(direnv export zsh)";
trap - SIGINT;
}
typeset -ag precmd_functions;
if [[ -z ${precmd_functions[(r)_direnv_hook]} ]]; then
precmd_functions=( _direnv_hook ${precmd_functions[@]} )
fi
typeset -ag chpwd_functions;
if [[ -z ${chpwd_functions[(r)_direnv_hook]} ]]; then
chpwd_functions=( _direnv_hook ${chpwd_functions[@]} )
fi

View File

@ -7,6 +7,7 @@ To use it, add `dirhistory` to the plugins array in your zshrc file:
```zsh ```zsh
plugins=(... dirhistory) plugins=(... dirhistory)
``` ```
## Keyboard Shortcuts ## Keyboard Shortcuts
| Shortcut | Description | | Shortcut | Description |
@ -15,3 +16,24 @@ plugins=(... dirhistory)
| <kbd>alt</kbd> + <kbd>right</kbd> | Undo <kbd>alt</kbd> + <kbd>left</kbd> | | <kbd>alt</kbd> + <kbd>right</kbd> | Undo <kbd>alt</kbd> + <kbd>left</kbd> |
| <kbd>alt</kbd> + <kbd>up</kbd> | Move into the parent directory | | <kbd>alt</kbd> + <kbd>up</kbd> | Move into the parent directory |
| <kbd>alt</kbd> + <kbd>down</kbd> | Move into the first child directory by alphabetical order | | <kbd>alt</kbd> + <kbd>down</kbd> | Move into the first child directory by alphabetical order |
## Usage
This plugin allows you to navigate the history of previous current-working-directories using ALT-LEFT and ALT-RIGHT. ALT-LEFT moves back to directories that the user has changed to in the past, and ALT-RIGHT undoes ALT-LEFT. MAC users may alternately use OPT-LEFT and OPT-RIGHT.
Also, navigate directory **hierarchy** using ALT-UP and ALT-DOWN. (mac keybindings not yet implemented). ALT-UP moves to higher hierarchy (shortcut for 'cd ..'). ALT-DOWN moves into the first directory found in alphabetical order (useful to navigate long empty directories e.g. java packages)
For example, if the shell was started, and the following commands were entered:
```shell
cd ~
cd /usr
cd share
cd doc
```
Then entering ALT-LEFT at the prompt would change directory from /usr/share/doc to /usr/share, then if pressed again to /usr/, then ~. If ALT-RIGHT were pressed the directory would be changed to /usr/ again.
After that, ALT-DOWN will probably go to /usr/bin (depends on your /usr structure), ALT-UP will return to /usr, then ALT-UP will get you to /
**Currently the max history size is 30**. The navigation should work for xterm, PuTTY xterm mode, GNU screen, and on MAC with alternate keys as mentioned above.

View File

@ -2,7 +2,7 @@
# Navigate directory history using ALT-LEFT and ALT-RIGHT. ALT-LEFT moves back to directories # Navigate directory history using ALT-LEFT and ALT-RIGHT. ALT-LEFT moves back to directories
# that the user has changed to in the past, and ALT-RIGHT undoes ALT-LEFT. # that the user has changed to in the past, and ALT-RIGHT undoes ALT-LEFT.
# #
# Navigate directory hierarchy using ALT-UP and ALT-DOWN. (mac keybindings not yet implemented) # Navigate directory hierarchy using ALT-UP and ALT-DOWN.
# ALT-UP moves to higher hierarchy (cd ..) # ALT-UP moves to higher hierarchy (cd ..)
# ALT-DOWN moves into the first directory found in alphabetical order # ALT-DOWN moves into the first directory found in alphabetical order
# #
@ -53,7 +53,8 @@ function push_future() {
} }
# Called by zsh when directory changes # Called by zsh when directory changes
chpwd_functions+=(chpwd_dirhistory) autoload -U add-zsh-hook
add-zsh-hook chpwd chpwd_dirhistory
function chpwd_dirhistory() { function chpwd_dirhistory() {
push_past $PWD push_past $PWD
# If DIRHISTORY_CD is not set... # If DIRHISTORY_CD is not set...
@ -107,26 +108,30 @@ function dirhistory_forward() {
# Bind keys to history navigation # Bind keys to history navigation
function dirhistory_zle_dirhistory_back() { function dirhistory_zle_dirhistory_back() {
# Erase current line in buffer # Erase current line in buffer
zle kill-buffer zle .kill-buffer
dirhistory_back dirhistory_back
zle accept-line zle .accept-line
} }
function dirhistory_zle_dirhistory_future() { function dirhistory_zle_dirhistory_future() {
# Erase current line in buffer # Erase current line in buffer
zle kill-buffer zle .kill-buffer
dirhistory_forward dirhistory_forward
zle accept-line zle .accept-line
} }
zle -N dirhistory_zle_dirhistory_back zle -N dirhistory_zle_dirhistory_back
# xterm in normal mode # xterm in normal mode
bindkey "\e[3D" dirhistory_zle_dirhistory_back bindkey "\e[3D" dirhistory_zle_dirhistory_back
bindkey "\e[1;3D" dirhistory_zle_dirhistory_back bindkey "\e[1;3D" dirhistory_zle_dirhistory_back
# Mac teminal (alt+left/right) # Terminal.app
if [[ "$TERM_PROGRAM" == "Apple_Terminal" ]]; then if [[ "$TERM_PROGRAM" == "Apple_Terminal" ]]; then
bindkey "^[b" dirhistory_zle_dirhistory_back bindkey "^[b" dirhistory_zle_dirhistory_back
fi fi
# iTerm2
if [[ "$TERM_PROGRAM" == "iTerm.app" ]]; then
bindkey "^[^[[D" dirhistory_zle_dirhistory_back
fi
# Putty: # Putty:
bindkey "\e\e[D" dirhistory_zle_dirhistory_back bindkey "\e\e[D" dirhistory_zle_dirhistory_back
# GNU screen: # GNU screen:
@ -135,9 +140,14 @@ bindkey "\eO3D" dirhistory_zle_dirhistory_back
zle -N dirhistory_zle_dirhistory_future zle -N dirhistory_zle_dirhistory_future
bindkey "\e[3C" dirhistory_zle_dirhistory_future bindkey "\e[3C" dirhistory_zle_dirhistory_future
bindkey "\e[1;3C" dirhistory_zle_dirhistory_future bindkey "\e[1;3C" dirhistory_zle_dirhistory_future
# Terminal.app
if [[ "$TERM_PROGRAM" == "Apple_Terminal" ]]; then if [[ "$TERM_PROGRAM" == "Apple_Terminal" ]]; then
bindkey "^[f" dirhistory_zle_dirhistory_future bindkey "^[f" dirhistory_zle_dirhistory_future
fi fi
# iTerm2
if [[ "$TERM_PROGRAM" == "iTerm.app" ]]; then
bindkey "^[^[[C" dirhistory_zle_dirhistory_future
fi
bindkey "\e\e[C" dirhistory_zle_dirhistory_future bindkey "\e\e[C" dirhistory_zle_dirhistory_future
bindkey "\eO3C" dirhistory_zle_dirhistory_future bindkey "\eO3C" dirhistory_zle_dirhistory_future
@ -159,23 +169,24 @@ function dirhistory_down() {
# Bind keys to hierarchy navigation # Bind keys to hierarchy navigation
function dirhistory_zle_dirhistory_up() { function dirhistory_zle_dirhistory_up() {
zle kill-buffer # Erase current line in buffer zle .kill-buffer # Erase current line in buffer
dirhistory_up dirhistory_up
zle accept-line zle .accept-line
} }
function dirhistory_zle_dirhistory_down() { function dirhistory_zle_dirhistory_down() {
zle kill-buffer # Erase current line in buffer zle .kill-buffer # Erase current line in buffer
dirhistory_down dirhistory_down
zle accept-line zle .accept-line
} }
zle -N dirhistory_zle_dirhistory_up zle -N dirhistory_zle_dirhistory_up
# xterm in normal mode # xterm in normal mode
bindkey "\e[3A" dirhistory_zle_dirhistory_up bindkey "\e[3A" dirhistory_zle_dirhistory_up
bindkey "\e[1;3A" dirhistory_zle_dirhistory_up bindkey "\e[1;3A" dirhistory_zle_dirhistory_up
# Mac teminal (alt+up) if [[ "$TERM_PROGRAM" == "Apple_Terminal" || "$TERM_PROGRAM" == "iTerm.app" ]]; then
#bindkey "^[?" dirhistory_zle_dirhistory_up #dont know it bindkey "^[[A" dirhistory_zle_dirhistory_up
fi
# Putty: # Putty:
bindkey "\e\e[A" dirhistory_zle_dirhistory_up bindkey "\e\e[A" dirhistory_zle_dirhistory_up
# GNU screen: # GNU screen:
@ -184,7 +195,8 @@ bindkey "\eO3A" dirhistory_zle_dirhistory_up
zle -N dirhistory_zle_dirhistory_down zle -N dirhistory_zle_dirhistory_down
bindkey "\e[3B" dirhistory_zle_dirhistory_down bindkey "\e[3B" dirhistory_zle_dirhistory_down
bindkey "\e[1;3B" dirhistory_zle_dirhistory_down bindkey "\e[1;3B" dirhistory_zle_dirhistory_down
# Mac teminal (alt+down) if [[ "$TERM_PROGRAM" == "Apple_Terminal" || "$TERM_PROGRAM" == "iTerm.app" ]]; then
#bindkey "^[?" dirhistory_zle_dirhistory_down #dont know it bindkey "^[[B" dirhistory_zle_dirhistory_down
fi
bindkey "\e\e[B" dirhistory_zle_dirhistory_down bindkey "\e\e[B" dirhistory_zle_dirhistory_down
bindkey "\eO3B" dirhistory_zle_dirhistory_down bindkey "\eO3B" dirhistory_zle_dirhistory_down

View File

@ -1,6 +1,7 @@
# Dirpersist plugin # Dirpersist plugin
This plugin keeps a running tally of the previous 20 unique directories in the $HOME/.zdirs file. When you cd to a new directory, it is prepended to the beginning of the file. This plugin keeps a running tally of the previous 20 unique directories in the `$HOME/.zdirs` file.
When you cd to a new directory, it is prepended to the beginning of the file.
To use it, add `dirpersist` to the plugins array in your zshrc file: To use it, add `dirpersist` to the plugins array in your zshrc file:

View File

@ -11,7 +11,8 @@ if [[ -f ${dirstack_file} ]] && [[ ${#dirstack[*]} -eq 0 ]] ; then
[[ -d $dirstack[1] ]] && cd $dirstack[1] && cd $OLDPWD [[ -d $dirstack[1] ]] && cd $dirstack[1] && cd $OLDPWD
fi fi
chpwd_functions+=(chpwd_dirpersist) autoload -U add-zsh-hook
add-zsh-hook chpwd chpwd_dirpersist
chpwd_dirpersist() { chpwd_dirpersist() {
if (( $DIRSTACKSIZE <= 0 )) || [[ -z $dirstack_file ]]; then return; fi if (( $DIRSTACKSIZE <= 0 )) || [[ -z $dirstack_file ]]; then return; fi
local -ax my_stack local -ax my_stack

View File

@ -34,23 +34,3 @@ runfcgi -- run this project as a fastcgi
runserver -- start a lightweight web server for development runserver -- start a lightweight web server for development
... ...
``` ```
If you want to see the options available for a specific command, try:
```zsh
$> python manage.py makemessages (press <TAB> here)
```
And that would result in:
```zsh
--all -a -- re-examine all code and templates
--domain -d -- domain of the message files (default: "django")
--extensions -e -- file extension(s) to examine (default: ".html")
--help -- display help information
--locale -l -- locale to process (default: all)
--pythonpath -- directory to add to the Python path
--settings -- python path to settings module
...
```

View File

@ -374,7 +374,8 @@ _managepy-commands() {
_applist() { _applist() {
local line local line
local -a apps local -a apps
_call_program help-command "python -c \"import os.path as op, re, django.conf, sys;\\ _call_program help-command "python -c \"import sys; del sys.path[0];\\
import os.path as op, re, django.conf;\\
bn=op.basename(op.abspath(op.curdir));[sys\\ bn=op.basename(op.abspath(op.curdir));[sys\\
.stdout.write(str(re.sub(r'^%s\.(.*?)$' % .stdout.write(str(re.sub(r'^%s\.(.*?)$' %
bn, r'\1', i)) + '\n') for i in django.conf.settings.\\ bn, r'\1', i)) + '\n') for i in django.conf.settings.\\

View File

@ -1,10 +1,14 @@
## Description # dnf plugin
This plugin makes `dnf` usage easier by adding aliases for the most This plugin makes `dnf` usage easier by adding aliases for the most common commands.
common commands.
`dnf` is the new package manager for RPM-based distributions, which `dnf` is the new package manager for RPM-based distributions, which replaces `yum`.
replaces `yum`.
To use it, add `dnf` to the plugins array in your zshrc file:
```zsh
plugins=(... dnf)
```
## Aliases ## Aliases

Some files were not shown because too many files have changed in this diff Show More