Compare commits
16 Commits
f8eb9f2139
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f1a014a38a | ||
|
|
8b360c8f7b | ||
|
|
9de9b5d1e7 | ||
|
|
8401568a50 | ||
|
|
993113e9ec | ||
|
|
53aa52f5d8 | ||
|
|
909e11855b | ||
|
|
f114789dd7 | ||
|
|
977ca94059 | ||
|
|
d401395dc4 | ||
|
|
356be1c98e | ||
|
|
0da5797115 | ||
|
|
994ecd7eb3 | ||
|
|
f7e479f8a5 | ||
|
|
f71bb8d6b7 | ||
|
|
e48db8b42a |
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
.zcompdump
|
||||||
1923
.zcompdump
Normal file
1923
.zcompdump
Normal file
File diff suppressed because it is too large
Load Diff
3
.zprofile
Normal file
3
.zprofile
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
|
||||||
|
# Created by `pipx` on 2026-03-26 01:09:22
|
||||||
|
export PATH="$PATH:/home/venus/.local/bin"
|
||||||
84
.zshrc
Normal file
84
.zshrc
Normal file
@@ -0,0 +1,84 @@
|
|||||||
|
#!/bin/sh env vars to set on login, zsh settings in ~/config/zsh/.zshrc
|
||||||
|
# added `export ZDOTDIR="$HOME/.config/zsh"` to /etc/zsh/zshenv in order to place this file at .config/zsh/.zprofile
|
||||||
|
# read first
|
||||||
|
|
||||||
|
debug=0
|
||||||
|
|
||||||
|
if [ $debug = 1 ]; then echo reading zshrc config from $0
|
||||||
|
fi
|
||||||
|
|
||||||
|
# default programs
|
||||||
|
export EDITOR="nvim"
|
||||||
|
# export MUSPLAYER="termusic"
|
||||||
|
export BROWSER="firefox"
|
||||||
|
# export BROWSER2="librewolf"
|
||||||
|
# export DISPLAY=:0 # useful for some scripts
|
||||||
|
|
||||||
|
# follow XDG base dir specification
|
||||||
|
export XDG_CONFIG_HOME="$HOME/.config"
|
||||||
|
export XDG_DATA_HOME="$HOME/.local/share"
|
||||||
|
export XDG_CACHE_HOME="$HOME/.cache"
|
||||||
|
|
||||||
|
# bootstrap .zshrc to ~/.config/zsh/.zshrc, any other zsh config files can also reside here
|
||||||
|
export ZDOTDIR="$XDG_CONFIG_HOME/zsh"
|
||||||
|
|
||||||
|
# history files
|
||||||
|
export LESSHISTFILE="$XDG_CACHE_HOME/less_history"
|
||||||
|
export PYTHON_HISTORY="$XDG_DATA_HOME/python/history"
|
||||||
|
|
||||||
|
|
||||||
|
# moving other files and some other vars
|
||||||
|
export XINITRC="$XDG_CONFIG_HOME/x11/xinitrc"
|
||||||
|
export XPROFILE="$XDG_CONFIG_HOME/x11/xprofile"
|
||||||
|
export XREkOURCES="$XDG_CONFIG_HOME/x11/xresources"
|
||||||
|
export GTK2_RC_FILES="$XDG_CONFIG_HOME/gtk-2.0/gtkrc-2.0" # gtk 3 & 4 are XDG compliant
|
||||||
|
export WGETRC="$XDG_CONFIG_HOME/wget/wgetrc"
|
||||||
|
export PYTHONSTARTUP="$XDG_CONFIG_HOME/python/pythonrc.py"
|
||||||
|
export GNUPGHOME="$XDG_DATA_HOME/gnupg"
|
||||||
|
export CARGO_HOME="$XDG_DATA_HOME/cargo"
|
||||||
|
export GOPATH="$XDG_DATA_HOME/go"
|
||||||
|
export GOBIN="$GOPATH/bin"
|
||||||
|
export GOMODCACHE="$XDG_CACHE_HOME/go/mod"
|
||||||
|
export NPM_CONFIG_USERCONFIG="$XDG_CONFIG_HOME/npm/npmrc"
|
||||||
|
export GRADLE_USER_HOME="$XDG_DATA_HOME/gradle"
|
||||||
|
export NUGET_PACKAGES="$XDG_CACHE_HOME/NuGetPackages"
|
||||||
|
export _JAVA_OPTIONS=-Djava.util.prefs.userRoot="$XDG_CONFIG_HOME/java"
|
||||||
|
export _JAVA_AWT_WM_NONREPARENTING=1
|
||||||
|
export PARALLEL_HOME="$XDG_CONFIG_HOME/parallel"
|
||||||
|
export FFMPEG_DATADIR="$XDG_CONFIG_HOME/ffmpeg"
|
||||||
|
export WINEPREFIX="$XDG_DATA_HOME/wineprefixes/default"
|
||||||
|
export DATE=$(date "+%A, %B %e %_I:%M%P")
|
||||||
|
|
||||||
|
export FZF_DEFAULT_OPTS="--style minimal --color 16 --layout=reverse --height 30% --preview='bat -p --color=always {}'"
|
||||||
|
export FZF_CTRL_R_OPTS="--style minimal --color 16 --info inline --no-sort --no-preview" # separate opts for history widget
|
||||||
|
export MANPAGER="nvim '+Man!' -"
|
||||||
|
|
||||||
|
# colored less + termcap vars
|
||||||
|
export LESS="R --use-color -Dd+r -Du+b"
|
||||||
|
export LESS_TERMCAP_mb="$(printf '%b' '[1;31m')"
|
||||||
|
export LESS_TERMCAP_md="$(printf '%b' '[1;36m')"
|
||||||
|
export LESS_TERMCAP_me="$(printf '%b' '[0m')"
|
||||||
|
export LESS_TERMCAP_so="$(printf '%b' '[01;44;33m')"
|
||||||
|
export LESS_TERMCAP_se="$(printf '%b' '[0m')"
|
||||||
|
export LESS_TERMCAP_us="$(printf '%b' '[1;32m')"
|
||||||
|
export LESS_TERMCAP_ue="$(printf '%b' '[0m')"
|
||||||
|
|
||||||
|
|
||||||
|
# Created by `pipx` on 2026-03-26 01:09:22
|
||||||
|
# add custom elements to path
|
||||||
|
export PATH="$PATH:/home/venus/.local/bin"
|
||||||
|
export PATH="$PATH:$XDG_CONFIG_HOME/scripts"
|
||||||
|
export PATH="$PATH:$HOME/.local/share/cargo/bin/"
|
||||||
|
export PATH="$PATH:$HOME/.local/share/cargo/bin/"
|
||||||
|
export PATH="$PATH:$HOME/.luarocks/bin/"
|
||||||
|
export PATH="$PATH:$HOME/$GOBIN"
|
||||||
|
|
||||||
|
# Remove the default of run-help being aliased to man
|
||||||
|
unalias run-help 2>/dev/null
|
||||||
|
# Use zsh's run-help, which will display information for zsh builtins.
|
||||||
|
autoload run-help
|
||||||
|
alias help="run-help"
|
||||||
|
|
||||||
|
#source primary config script
|
||||||
|
source $XDG_CONFIG_HOME/zsh/zsh.config
|
||||||
|
|
||||||
@@ -1,76 +0,0 @@
|
|||||||
# 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
|
|
||||||
270
CONTRIBUTING.md
270
CONTRIBUTING.md
@@ -1,270 +0,0 @@
|
|||||||
# 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)
|
|
||||||
- [A note on AI-assisted contributions](#a-note-on-ai-assisted-contributions)
|
|
||||||
- [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 know more people are 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 the following:
|
|
||||||
|
|
||||||
1. How to reproduce the problem
|
|
||||||
2. What the correct behavior should be
|
|
||||||
3. What the actual behavior is
|
|
||||||
|
|
||||||
Please copy to anyone relevant (e.g. plugin maintainers) by mentioning their GitHub handle
|
|
||||||
(starting with `@`) in your message.
|
|
||||||
|
|
||||||
We will do our very best to help you.
|
|
||||||
|
|
||||||
### You have a suggestion
|
|
||||||
|
|
||||||
Please be so kind as to [search](#use-the-search-luke) for any open issue already covering
|
|
||||||
your suggestion.
|
|
||||||
|
|
||||||
If you find one, comment on it, so we know more people are supporting it.
|
|
||||||
|
|
||||||
If not, you can go ahead and create an issue. Please copy to anyone relevant (e.g. 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 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 (e.g. plugin
|
|
||||||
maintainers) by mentioning their GitHub handle (starting with `@`) in your message.
|
|
||||||
|
|
||||||
For any extensive change, such as a new plugin, you will have to find testers to +1 your PR.
|
|
||||||
|
|
||||||
### New plugin aliases
|
|
||||||
|
|
||||||
We acknowledge that aliases are a core part of Oh My Zsh. There are plugins that have +100 aliases!
|
|
||||||
|
|
||||||
This has become an issue for two opposing reasons:
|
|
||||||
|
|
||||||
- Some users want to have their personal aliases in Oh My Zsh.
|
|
||||||
- Some users don't want any aliases at all and feel that there are too many.
|
|
||||||
|
|
||||||
Because of this, from now on, we require that new aliases follow these conditions:
|
|
||||||
|
|
||||||
1. They will be used by many people, not just a few.
|
|
||||||
2. The aliases will be used many times and for common tasks.
|
|
||||||
3. Prefer one generic alias over many specific ones.
|
|
||||||
4. When justifying the need for an alias, talk about workflows where you'll use it,
|
|
||||||
preferably in combination with other aliases.
|
|
||||||
5. If a command with the same name exists, look for a different alias name.
|
|
||||||
|
|
||||||
This list is not exhaustive! Please remember that your alias will be in the machines of many people,
|
|
||||||
so it should be justified why they should have it.
|
|
||||||
|
|
||||||
## A note on AI-assisted contributions
|
|
||||||
|
|
||||||
We'll admit it: AI tools can be pretty helpful for coding tasks, and we're not here to gatekeep how you get your work done. We use these tools ourselves! 🤖
|
|
||||||
|
|
||||||
But here's the thing—Oh My Zsh is maintained by a small team of volunteers who do this in their spare time. We already have hundreds of pending PRs, and we want to make sure we're spending our limited time effectively.
|
|
||||||
|
|
||||||
If you used AI tools meaningfully in your contribution (code generation, agentic coding assistants, etc.), please mention it in your PR description. Basic autocomplete doesn't count, but if an AI wrote substantial parts of your code, just let us know.
|
|
||||||
|
|
||||||
**Examples of good disclosure:**
|
|
||||||
- "Used ChatGPT to help generate the initial regex pattern for parsing git status output"
|
|
||||||
- "Claude assisted with writing the unit tests for this feature"
|
|
||||||
- "Generated with Gemini and then reviewed/tested manually"
|
|
||||||
- Or simply: "AI-assisted" in your PR description
|
|
||||||
|
|
||||||
Here's what we're looking for:
|
|
||||||
|
|
||||||
- **You understand your code**: You should be able to explain what your contribution does and how it works. We want to collaborate with humans who are invested in the project.
|
|
||||||
- **Context matters**: Tell us what problem you're solving, how you tested it, and link to relevant docs. Small, incremental changes work better than massive generated overhauls.
|
|
||||||
- **Quality over quantity**: We'd rather have one thoughtful, well-tested contribution than ten AI-generated PRs that need extensive review.
|
|
||||||
|
|
||||||
The disclosure helps us know how much guidance to offer. If we're just reviewing AI output that you can't explain or improve, that changes the dynamic—and frankly, it's not a great use of anyone's time.
|
|
||||||
|
|
||||||
As always, we reserve the right to decline any contribution. PRs that appear to be unreviewed AI output, or code the contributor can't explain, may be closed without extensive feedback.
|
|
||||||
|
|
||||||
----
|
|
||||||
|
|
||||||
## 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 between 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. It's 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 changed 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.
|
|
||||||
21
LICENSE.txt
21
LICENSE.txt
@@ -1,21 +0,0 @@
|
|||||||
MIT License
|
|
||||||
|
|
||||||
Copyright (c) 2009-2026 Robby Russell and contributors (https://github.com/ohmyzsh/ohmyzsh/contributors)
|
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
|
||||||
in the Software without restriction, including without limitation the rights
|
|
||||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
copies of the Software, and to permit persons to whom the Software is
|
|
||||||
furnished to do so, subject to the following conditions:
|
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be included in all
|
|
||||||
copies or substantial portions of the Software.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
SOFTWARE.
|
|
||||||
564
README.md
564
README.md
@@ -1,564 +0,0 @@
|
|||||||
<p align="center"><img src="https://ohmyzsh.s3.amazonaws.com/omz-ansi-github.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.
|
|
||||||
|
|
||||||
Sounds boring. Let's try again.
|
|
||||||
|
|
||||||
**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?"_
|
|
||||||
|
|
||||||
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), follow [@ohmyzsh](https://x.com/ohmyzsh) on X (formerly
|
|
||||||
Twitter), and join us on [Discord](https://discord.gg/ohmyzsh).
|
|
||||||
|
|
||||||
[](https://github.com/ohmyzsh/ohmyzsh/actions?query=workflow%3ACI)
|
|
||||||
[](https://www.bestpractices.dev/projects/10713)
|
|
||||||
[](https://twitter.com/intent/follow?screen_name=ohmyzsh)
|
|
||||||
[](https://mstdn.social/@ohmyzsh)
|
|
||||||
[](https://discord.gg/ohmyzsh)
|
|
||||||
|
|
||||||
<details>
|
|
||||||
<summary>Table of Contents</summary>
|
|
||||||
|
|
||||||
- [Getting Started](#getting-started)
|
|
||||||
- [Operating System Compatibility](#operating-system-compatibility)
|
|
||||||
- [Prerequisites](#prerequisites)
|
|
||||||
- [Basic Installation](#basic-installation)
|
|
||||||
- [Manual Inspection](#manual-inspection)
|
|
||||||
- [Using Oh My Zsh](#using-oh-my-zsh)
|
|
||||||
- [Plugins](#plugins)
|
|
||||||
- [Enabling Plugins](#enabling-plugins)
|
|
||||||
- [Using Plugins](#using-plugins)
|
|
||||||
- [Themes](#themes)
|
|
||||||
- [Selecting A Theme](#selecting-a-theme)
|
|
||||||
- [FAQ](#faq)
|
|
||||||
- [Advanced Topics](#advanced-topics)
|
|
||||||
- [Advanced Installation](#advanced-installation)
|
|
||||||
- [Custom Directory](#custom-directory)
|
|
||||||
- [Unattended Install](#unattended-install)
|
|
||||||
- [Installing From A Forked Repository](#installing-from-a-forked-repository)
|
|
||||||
- [Manual Installation](#manual-installation)
|
|
||||||
- [Installation Problems](#installation-problems)
|
|
||||||
- [Custom Plugins And Themes](#custom-plugins-and-themes)
|
|
||||||
- [Enable GNU ls In macOS And freeBSD Systems](#enable-gnu-ls-in-macos-and-freebsd-systems)
|
|
||||||
- [Skip Aliases](#skip-aliases)
|
|
||||||
- [Async git prompt](#async-git-prompt)
|
|
||||||
- [Getting Updates](#getting-updates)
|
|
||||||
- [Updates Verbosity](#updates-verbosity)
|
|
||||||
- [Manual Updates](#manual-updates)
|
|
||||||
- [Uninstalling Oh My Zsh](#uninstalling-oh-my-zsh)
|
|
||||||
- [How Do I Contribute To Oh My Zsh?](#how-do-i-contribute-to-oh-my-zsh)
|
|
||||||
- [Do Not Send Us Themes](#do-not-send-us-themes)
|
|
||||||
- [Contributors](#contributors)
|
|
||||||
- [Follow Us](#follow-us)
|
|
||||||
- [Merchandise](#merchandise)
|
|
||||||
- [License](#license)
|
|
||||||
- [About Planet Argon](#about-planet-argon)
|
|
||||||
|
|
||||||
</details>
|
|
||||||
|
|
||||||
## Getting Started
|
|
||||||
|
|
||||||
### Operating System Compatibility
|
|
||||||
|
|
||||||
| O/S | Status |
|
|
||||||
| :------------- | :----: |
|
|
||||||
| Android | ✅ |
|
|
||||||
| freeBSD | ✅ |
|
|
||||||
| LCARS | 🛸 |
|
|
||||||
| Linux | ✅ |
|
|
||||||
| macOS | ✅ |
|
|
||||||
| OS/2 Warp | ❌ |
|
|
||||||
| Windows (WSL2) | ✅ |
|
|
||||||
|
|
||||||
### Prerequisites
|
|
||||||
|
|
||||||
- [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)
|
|
||||||
- `curl` or `wget` should be installed
|
|
||||||
- `git` should be installed (recommended v2.4.11 or higher)
|
|
||||||
|
|
||||||
### 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`, `wget` or another similar tool.
|
|
||||||
|
|
||||||
| Method | Command |
|
|
||||||
| :-------- | :------------------------------------------------------------------------------------------------ |
|
|
||||||
| **curl** | `sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/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)"` |
|
|
||||||
|
|
||||||
Alternatively, the installer is also mirrored outside GitHub. Using this URL instead may be required if you're
|
|
||||||
in a country like China or India (for certain ISPs), that blocks `raw.githubusercontent.com`:
|
|
||||||
|
|
||||||
| Method | Command |
|
|
||||||
| :-------- | :------------------------------------------------ |
|
|
||||||
| **curl** | `sh -c "$(curl -fsSL https://install.ohmyz.sh/)"` |
|
|
||||||
| **wget** | `sh -c "$(wget -O- https://install.ohmyz.sh/)"` |
|
|
||||||
| **fetch** | `sh -c "$(fetch -o - https://install.ohmyz.sh/)"` |
|
|
||||||
|
|
||||||
_Note that any previous `.zshrc` will be renamed to `.zshrc.pre-oh-my-zsh`. After installation, you can move
|
|
||||||
the configuration you want to preserve into the new `.zshrc`._
|
|
||||||
|
|
||||||
#### Manual Inspection
|
|
||||||
|
|
||||||
It's a good idea to inspect the install script from projects you don't yet know. You can do that by
|
|
||||||
downloading the install script first, looking through it so everything looks normal, then running it:
|
|
||||||
|
|
||||||
```sh
|
|
||||||
wget https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh
|
|
||||||
sh install.sh
|
|
||||||
```
|
|
||||||
|
|
||||||
If the above URL times out or otherwise fails, you may have to substitute the URL for
|
|
||||||
`https://install.ohmyz.sh` to be able to get the script.
|
|
||||||
|
|
||||||
## Using Oh My Zsh
|
|
||||||
|
|
||||||
### Plugins
|
|
||||||
|
|
||||||
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
|
|
||||||
|
|
||||||
Once you spot a plugin (or several) that you'd like to use with Oh My Zsh, you'll need to enable them in the
|
|
||||||
`.zshrc` file. You'll find the zshrc file in your `$HOME` directory. Open it with your favorite text editor
|
|
||||||
and you'll see a spot to list all the plugins you want to load.
|
|
||||||
|
|
||||||
```sh
|
|
||||||
vi ~/.zshrc
|
|
||||||
```
|
|
||||||
|
|
||||||
For example, this might begin to look like this:
|
|
||||||
|
|
||||||
```sh
|
|
||||||
plugins=(
|
|
||||||
git
|
|
||||||
bundler
|
|
||||||
dotenv
|
|
||||||
macos
|
|
||||||
rake
|
|
||||||
rbenv
|
|
||||||
ruby
|
|
||||||
)
|
|
||||||
```
|
|
||||||
|
|
||||||
_Note that the plugins are separated by whitespace (spaces, tabs, new lines...). **Do not** use commas between
|
|
||||||
them or it will break._
|
|
||||||
|
|
||||||
#### Using Plugins
|
|
||||||
|
|
||||||
Each built-in 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
|
|
||||||
|
|
||||||
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
|
|
||||||
|
|
||||||
_Robby's theme is the default one. It's not the fanciest one. It's not the simplest one. It's just the right
|
|
||||||
one (for him)._
|
|
||||||
|
|
||||||
Once you find a theme that you'd like to use, you will need to edit the `~/.zshrc` file. You'll see an
|
|
||||||
environment variable (all caps) in there that looks like:
|
|
||||||
|
|
||||||
```sh
|
|
||||||
ZSH_THEME="robbyrussell"
|
|
||||||
```
|
|
||||||
|
|
||||||
To use a different theme, simply change the value to match the name of your desired theme. For example:
|
|
||||||
|
|
||||||
```sh
|
|
||||||
ZSH_THEME="agnoster" # (this is one of the fancy ones)
|
|
||||||
# see https://github.com/ohmyzsh/ohmyzsh/wiki/Themes#agnoster
|
|
||||||
```
|
|
||||||
|
|
||||||
<!-- prettier-ignore-start -->
|
|
||||||
> [!NOTE]
|
|
||||||
> You will many times see screenshots for a zsh theme, and try it out, and find that it doesn't look the same for you.
|
|
||||||
>
|
|
||||||
> This is because many themes require installing a [Powerline Font](https://github.com/powerline/fonts) or a
|
|
||||||
> [Nerd Font](https://github.com/ryanoasis/nerd-fonts) in order to render properly. Without them, these themes
|
|
||||||
> will render weird prompt symbols. Check out
|
|
||||||
> [the FAQ](https://github.com/ohmyzsh/ohmyzsh/wiki/FAQ#i-have-a-weird-character-in-my-prompt) for more
|
|
||||||
> information.
|
|
||||||
>
|
|
||||||
> Also, beware that themes only control what your prompt looks like. This is, the text you see before or after
|
|
||||||
> your cursor, where you'll type your commands. Themes don't control things such as the colors of your
|
|
||||||
> terminal window (known as _color scheme_) or the font of your terminal. These are settings that you can
|
|
||||||
> change in your terminal emulator. For more information, see
|
|
||||||
> [what is a zsh theme](https://github.com/ohmyzsh/ohmyzsh/wiki/FAQ#what-is-a-zsh-theme).
|
|
||||||
<!-- prettier-ignore-end -->
|
|
||||||
|
|
||||||
Open up a new terminal window and your prompt should look something like this:
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
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.
|
|
||||||
|
|
||||||
```sh
|
|
||||||
ZSH_THEME="random" # (...please let it be pie... please be some pie..)
|
|
||||||
```
|
|
||||||
|
|
||||||
And if you want to pick a random theme from a list of your favorite themes:
|
|
||||||
|
|
||||||
```sh
|
|
||||||
ZSH_THEME_RANDOM_CANDIDATES=(
|
|
||||||
"robbyrussell"
|
|
||||||
"agnoster"
|
|
||||||
)
|
|
||||||
```
|
|
||||||
|
|
||||||
If you only know which themes you don't like, you can add them similarly to an ignored list:
|
|
||||||
|
|
||||||
```sh
|
|
||||||
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
|
|
||||||
|
|
||||||
If you're the type that likes to get their hands dirty, these sections might resonate.
|
|
||||||
|
|
||||||
### Advanced Installation
|
|
||||||
|
|
||||||
Some users may want to manually install Oh My Zsh, or change the default path or other settings that the
|
|
||||||
installer accepts (these settings are also documented at the top of the install script).
|
|
||||||
|
|
||||||
#### Custom 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
|
|
||||||
`export ZSH=/your/path` before installing, or by setting it before the end of the install pipeline like this:
|
|
||||||
|
|
||||||
```sh
|
|
||||||
ZSH="$HOME/.dotfiles/oh-my-zsh" sh install.sh
|
|
||||||
```
|
|
||||||
|
|
||||||
#### Unattended Install
|
|
||||||
|
|
||||||
If you're running the Oh My Zsh install script as part of an automated install, you can pass the
|
|
||||||
`--unattended` flag to the `install.sh` script. This will have the effect of not trying to change the default
|
|
||||||
shell, and it also won't run `zsh` when the installation has finished.
|
|
||||||
|
|
||||||
```sh
|
|
||||||
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" "" --unattended
|
|
||||||
```
|
|
||||||
|
|
||||||
If you're in China, India, or another country that blocks `raw.githubusercontent.com`, you may have to
|
|
||||||
substitute the URL for `https://install.ohmyz.sh` for it to install.
|
|
||||||
|
|
||||||
#### Installing From A Forked Repository
|
|
||||||
|
|
||||||
The install script also accepts these variables to allow the installation of a different repository:
|
|
||||||
|
|
||||||
- `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}`.
|
|
||||||
|
|
||||||
- `REMOTE` (default: `https://github.com/${REPO}.git`): this is the full URL of the git repository clone. You
|
|
||||||
can use this setting if you want to install from a fork that is not on GitHub (GitLab, Bitbucket...) or if
|
|
||||||
you want to clone with SSH instead of HTTPS (`git@github.com:user/project.git`).
|
|
||||||
|
|
||||||
_NOTE: it's incompatible with setting the `REPO` variable. This setting will take precedence._
|
|
||||||
|
|
||||||
- `BRANCH` (default: `master`): you can use this setting if you want to change the default branch to be
|
|
||||||
checked out when cloning the repository. This might be useful for testing a Pull Request, or if you want to
|
|
||||||
use a branch other than `master`.
|
|
||||||
|
|
||||||
For example:
|
|
||||||
|
|
||||||
```sh
|
|
||||||
REPO=apjanke/oh-my-zsh BRANCH=edge sh install.sh
|
|
||||||
```
|
|
||||||
|
|
||||||
#### Manual Installation
|
|
||||||
|
|
||||||
##### 1. Clone The Repository <!-- omit in toc -->
|
|
||||||
|
|
||||||
```sh
|
|
||||||
git clone https://github.com/ohmyzsh/ohmyzsh.git ~/.oh-my-zsh
|
|
||||||
```
|
|
||||||
|
|
||||||
##### 2. _Optionally_, Backup Your Existing `~/.zshrc` File <!-- omit in toc -->
|
|
||||||
|
|
||||||
```sh
|
|
||||||
cp ~/.zshrc ~/.zshrc.orig
|
|
||||||
```
|
|
||||||
|
|
||||||
##### 3. Create A New Zsh Configuration File <!-- omit in toc -->
|
|
||||||
|
|
||||||
You can create a new zsh config file by copying the template that we have included for you.
|
|
||||||
|
|
||||||
```sh
|
|
||||||
cp ~/.oh-my-zsh/templates/zshrc.zsh-template ~/.zshrc
|
|
||||||
```
|
|
||||||
|
|
||||||
##### 4. Change Your Default Shell <!-- omit in toc -->
|
|
||||||
|
|
||||||
```sh
|
|
||||||
chsh -s $(which zsh)
|
|
||||||
```
|
|
||||||
|
|
||||||
You must log out from your user session and log back in to see this change.
|
|
||||||
|
|
||||||
##### 5. Initialize Your New Zsh Configuration <!-- omit in toc -->
|
|
||||||
|
|
||||||
Once you open up a new terminal window, it should load zsh with Oh My Zsh's configuration.
|
|
||||||
|
|
||||||
### Installation Problems
|
|
||||||
|
|
||||||
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
|
|
||||||
switching to `oh-my-zsh`.
|
|
||||||
- If you installed manually or changed the install location, check the `ZSH` environment variable in
|
|
||||||
`~/.zshrc`.
|
|
||||||
|
|
||||||
### Custom Plugins And Themes
|
|
||||||
|
|
||||||
If you want to override any of the default behaviors, just add a new file (ending in `.zsh`) in the `custom/`
|
|
||||||
directory.
|
|
||||||
|
|
||||||
If you have many functions that go well together, you can put them as a `XYZ.plugin.zsh` file in the
|
|
||||||
`custom/plugins/` directory and then enable this plugin.
|
|
||||||
|
|
||||||
If you would like to override the functionality of a plugin distributed with Oh My Zsh, create a plugin of the
|
|
||||||
same name in the `custom/plugins/` directory and it will be loaded instead of the one in `plugins/`.
|
|
||||||
|
|
||||||
### Enable GNU ls In macOS And freeBSD Systems
|
|
||||||
|
|
||||||
<a name="enable-gnu-ls"></a>
|
|
||||||
|
|
||||||
The default behaviour in Oh My Zsh is to use BSD `ls` in macOS and FreeBSD systems. If GNU `ls` is installed
|
|
||||||
(as `gls` command), you can choose to use it instead. To do it, you can use zstyle-based config before
|
|
||||||
sourcing `oh-my-zsh.sh`:
|
|
||||||
|
|
||||||
```zsh
|
|
||||||
zstyle ':omz:lib:theme-and-appearance' gnu-ls yes
|
|
||||||
```
|
|
||||||
|
|
||||||
_Note: this is not compatible with `DISABLE_LS_COLORS=true`_
|
|
||||||
|
|
||||||
### Skip Aliases
|
|
||||||
|
|
||||||
<a name="remove-directories-aliases"></a>
|
|
||||||
|
|
||||||
If you want to skip default Oh My Zsh aliases (those defined in `lib/*` files) or plugin aliases, you can use
|
|
||||||
the settings below in your `~/.zshrc` file, **before Oh My Zsh is loaded**. Note that there are many different
|
|
||||||
ways to skip aliases, depending on your needs.
|
|
||||||
|
|
||||||
```sh
|
|
||||||
# Skip all aliases, in lib files and enabled plugins
|
|
||||||
zstyle ':omz:*' aliases no
|
|
||||||
|
|
||||||
# Skip all aliases in lib files
|
|
||||||
zstyle ':omz:lib:*' aliases no
|
|
||||||
# Skip only aliases defined in the directories.zsh lib file
|
|
||||||
zstyle ':omz:lib:directories' aliases no
|
|
||||||
|
|
||||||
# Skip all plugin aliases
|
|
||||||
zstyle ':omz:plugins:*' aliases no
|
|
||||||
# Skip only the aliases from the git plugin
|
|
||||||
zstyle ':omz:plugins:git' aliases no
|
|
||||||
```
|
|
||||||
|
|
||||||
You can combine these in other ways taking into account that more specific scopes take precedence:
|
|
||||||
|
|
||||||
```sh
|
|
||||||
# Skip all plugin aliases, except for the git plugin
|
|
||||||
zstyle ':omz:plugins:*' aliases no
|
|
||||||
zstyle ':omz:plugins:git' aliases yes
|
|
||||||
```
|
|
||||||
|
|
||||||
A previous version of this feature was using the setting below, which has been removed:
|
|
||||||
|
|
||||||
```sh
|
|
||||||
zstyle ':omz:directories' aliases no
|
|
||||||
```
|
|
||||||
|
|
||||||
Instead, you can now use the following:
|
|
||||||
|
|
||||||
```sh
|
|
||||||
zstyle ':omz:lib:directories' aliases no
|
|
||||||
```
|
|
||||||
|
|
||||||
#### Notice <!-- omit in toc -->
|
|
||||||
|
|
||||||
> This feature is currently in a testing phase and it may be subject to change in the future. It is also not
|
|
||||||
> currently compatible with plugin managers such as zpm or zinit, which don't source the init script
|
|
||||||
> (`oh-my-zsh.sh`) where this feature is implemented in.
|
|
||||||
|
|
||||||
> It is also not currently aware of "aliases" that are defined as functions. Example of such are `gccd`,
|
|
||||||
> `ggf`, or `ggl` functions from the git plugin.
|
|
||||||
|
|
||||||
### Async git prompt
|
|
||||||
|
|
||||||
Async prompt functions are an experimental feature (included on April 3, 2024) that allows Oh My Zsh to render
|
|
||||||
prompt information asynchronously. This can improve prompt rendering performance, but it might not work well
|
|
||||||
with some setups. We hope that's not an issue, but if you're seeing problems with this new feature, you can
|
|
||||||
turn it off by setting the following in your .zshrc file, before Oh My Zsh is sourced:
|
|
||||||
|
|
||||||
```sh
|
|
||||||
zstyle ':omz:alpha:lib:git' async-prompt no
|
|
||||||
```
|
|
||||||
|
|
||||||
If your problem is that the git prompt just stopped appearing, you can try to force it by setting the following
|
|
||||||
configuration before `oh-my-zsh.sh` is sourced. If it still does not work, please open an issue with your
|
|
||||||
case.
|
|
||||||
|
|
||||||
```sh
|
|
||||||
zstyle ':omz:alpha:lib:git' async-prompt force
|
|
||||||
```
|
|
||||||
|
|
||||||
## Getting Updates
|
|
||||||
|
|
||||||
By default, you will be prompted to check for updates every 2 weeks. You can choose other update modes by
|
|
||||||
adding a line to your `~/.zshrc` file, **before Oh My Zsh is loaded**:
|
|
||||||
|
|
||||||
1. Automatic update without confirmation prompt:
|
|
||||||
|
|
||||||
```sh
|
|
||||||
zstyle ':omz:update' mode auto
|
|
||||||
```
|
|
||||||
|
|
||||||
2. Just offer a reminder every few days, if there are updates available:
|
|
||||||
|
|
||||||
```sh
|
|
||||||
zstyle ':omz:update' mode reminder
|
|
||||||
```
|
|
||||||
|
|
||||||
3. To disable automatic updates entirely:
|
|
||||||
|
|
||||||
```sh
|
|
||||||
zstyle ':omz:update' mode disabled
|
|
||||||
```
|
|
||||||
|
|
||||||
NOTE: you can control how often Oh My Zsh checks for updates with the following setting:
|
|
||||||
|
|
||||||
```sh
|
|
||||||
# This will check for updates every 7 days
|
|
||||||
zstyle ':omz:update' frequency 7
|
|
||||||
# This will check for updates every time you open the terminal (not recommended)
|
|
||||||
zstyle ':omz:update' frequency 0
|
|
||||||
```
|
|
||||||
|
|
||||||
### Updates Verbosity
|
|
||||||
|
|
||||||
You can also limit the update verbosity with the following settings:
|
|
||||||
|
|
||||||
```sh
|
|
||||||
zstyle ':omz:update' verbose default # default update prompt
|
|
||||||
|
|
||||||
zstyle ':omz:update' verbose minimal # only few lines
|
|
||||||
|
|
||||||
zstyle ':omz:update' verbose silent # only errors
|
|
||||||
```
|
|
||||||
|
|
||||||
### Manual Updates
|
|
||||||
|
|
||||||
If you'd like to update 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:
|
|
||||||
|
|
||||||
```sh
|
|
||||||
omz update
|
|
||||||
```
|
|
||||||
|
|
||||||
> [!NOTE]
|
|
||||||
> If you want to automate this process in a script, you should call directly the `upgrade` script, like this:
|
|
||||||
>
|
|
||||||
> ```sh
|
|
||||||
> $ZSH/tools/upgrade.sh
|
|
||||||
> ```
|
|
||||||
>
|
|
||||||
> See more options in the [FAQ: How do I update Oh My Zsh?](https://github.com/ohmyzsh/ohmyzsh/wiki/FAQ#how-do-i-update-oh-my-zsh).
|
|
||||||
>
|
|
||||||
> **USE OF `omz update --unattended` HAS BEEN REMOVED, AS IT HAS SIDE EFFECTS**.
|
|
||||||
|
|
||||||
Magic! 🎉
|
|
||||||
|
|
||||||
## Uninstalling Oh My Zsh
|
|
||||||
|
|
||||||
Oh My Zsh isn't for everyone. We'll miss you, but we want to make this an easy breakup.
|
|
||||||
|
|
||||||
If you want to uninstall `oh-my-zsh`, just run `uninstall_oh_my_zsh` from the command-line. It will remove
|
|
||||||
itself and revert your previous `bash` or `zsh` configuration.
|
|
||||||
|
|
||||||
## How Do I Contribute To Oh My Zsh?
|
|
||||||
|
|
||||||
Before you participate in our delightful community, please read the [code of conduct](CODE_OF_CONDUCT.md).
|
|
||||||
|
|
||||||
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/ohmyzsh/ohmyzsh/issues) and help where you can.
|
|
||||||
|
|
||||||
See [Contributing](CONTRIBUTING.md) for more details.
|
|
||||||
|
|
||||||
### 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/ohmyzsh/ohmyzsh/wiki/External-themes) wiki page.
|
|
||||||
|
|
||||||
## Contributors
|
|
||||||
|
|
||||||
Oh My Zsh has a vibrant community of happy users and delightful contributors. Without all the time and help
|
|
||||||
from our contributors, it wouldn't be so awesome.
|
|
||||||
|
|
||||||
Thank you so much!
|
|
||||||
|
|
||||||
<a href="https://github.com/ohmyzsh/ohmyzsh/graphs/contributors">
|
|
||||||
<img src="https://contrib.rocks/image?repo=ohmyzsh/ohmyzsh" width="100%"/>
|
|
||||||
</a>
|
|
||||||
|
|
||||||
## Follow Us
|
|
||||||
|
|
||||||
We're on social media:
|
|
||||||
|
|
||||||
- [@ohmyzsh](https://x.com/ohmyzsh) on X (formerly Twitter). You should follow it.
|
|
||||||
- [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
|
|
||||||
|
|
||||||
We have
|
|
||||||
[stickers, shirts, and coffee mugs available](https://commitgoods.com/collections/oh-my-zsh?utm_source=github)
|
|
||||||
for you to show off your love of Oh My Zsh. Again, you will become the talk of the town!
|
|
||||||
|
|
||||||
## License
|
|
||||||
|
|
||||||
Oh My Zsh is released under the [MIT license](LICENSE.txt).
|
|
||||||
|
|
||||||
## About Planet Argon
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
Oh My Zsh was started by the team at [Planet Argon](https://www.planetargon.com/?utm_source=github), a
|
|
||||||
[Ruby on Rails development agency](https://www.planetargon.com/services/ruby-on-rails-development?utm_source=github).
|
|
||||||
Check out our [other open source projects](https://www.planetargon.com/open-source?utm_source=github).
|
|
||||||
23
SECURITY.md
23
SECURITY.md
@@ -1,23 +0,0 @@
|
|||||||
# Security Policy
|
|
||||||
|
|
||||||
## Supported Versions
|
|
||||||
|
|
||||||
At the moment Oh My Zsh only considers the very latest commit to be supported.
|
|
||||||
We combine that with our fast response to incidents and the automated updates
|
|
||||||
to minimize the time between vulnerability publication and patch release.
|
|
||||||
|
|
||||||
| Version | Supported |
|
|
||||||
|:-------------- |:------------------ |
|
|
||||||
| master | :white_check_mark: |
|
|
||||||
| other commits | :x: |
|
|
||||||
|
|
||||||
In the near future we will introduce versioning, so expect this section to change.
|
|
||||||
|
|
||||||
## Reporting a Vulnerability
|
|
||||||
|
|
||||||
**Do not submit an issue or pull request**: this might reveal the vulnerability.
|
|
||||||
|
|
||||||
Instead, you should use the form to [privately report a vulnerability to us via GitHub](https://github.com/ohmyzsh/ohmyzsh/security/advisories/new)
|
|
||||||
or email the maintainers directly at: [**security@ohmyz.sh**](mailto:security@ohmyz.sh).
|
|
||||||
|
|
||||||
We will deal with the vulnerability privately and submit a patch as soon as possible.
|
|
||||||
50
alias
Normal file
50
alias
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
alias pacman="sudo pacman"
|
||||||
|
alias ssh="kitten ssh"
|
||||||
|
alias show="kitty +kitten icat"
|
||||||
|
alias ips="ip a show wlan0"
|
||||||
|
alias mip='/home/venus/tools/getIp.sh'
|
||||||
|
alias omp="oh-my-posh"
|
||||||
|
alias rz="rizin"
|
||||||
|
alias ls="eza"
|
||||||
|
alias gz="gzip"
|
||||||
|
alias ri="sudo systemctl restart iwd && sleep 3 && ipcheck"
|
||||||
|
alias la="eza --all"
|
||||||
|
alias ll="eza --long --icons"
|
||||||
|
alias lr="eza --recurse"
|
||||||
|
alias lt="eza --tree --level 3"
|
||||||
|
alias li="eza --icons"
|
||||||
|
alias lg="eza --git-ignore"
|
||||||
|
alias e='v .'
|
||||||
|
alias air='sudo wg-quick up air-america'
|
||||||
|
alias aird='sudo wg-quick down air-america'
|
||||||
|
alias gc='git add . && git commit'
|
||||||
|
alias cat='bat'
|
||||||
|
alias eh="nvim ~/.config/hypr/"
|
||||||
|
alias ev="nvim ~/.config/nvim/"
|
||||||
|
alias v='nvim'
|
||||||
|
alias kb="nvim $XDG_CONFIG_HOME/hypr/basic/keybinds.conf"
|
||||||
|
alias vh="nvim $XDG_CONFIG_HOME/hypr/"
|
||||||
|
alias vk="nvim $XDG_CONFIG_HOME/hypr/basic/keybinds.conf"
|
||||||
|
alias vv="nvim $XDG_CONFIG_HOME/nvim/"
|
||||||
|
alias va="nvim $XDG_CONFIG_HOME/alias && source ~/.config/alias"
|
||||||
|
alias vz="nvim $XDG_CONFIG_HOME/zsh"
|
||||||
|
alias v!="nvim <(!!)"
|
||||||
|
alias cd="z"
|
||||||
|
alias pms="sudo pacman -S"
|
||||||
|
alias ipc="ipcheck"
|
||||||
|
alias pr="ping riverrooks.dev"
|
||||||
|
alias pg="ping gmail.com"
|
||||||
|
alias snake="python3"
|
||||||
|
alias path="echo $PATH"
|
||||||
|
alias -g @d="~/Downloads/Browser/$(eza -s new ~/Downloads/Browser | tail -n 1)"
|
||||||
|
alias -g L="| less"
|
||||||
|
alias -g T="| tail"
|
||||||
|
alias -g HH="| head"
|
||||||
|
alias -g H="| head -n "
|
||||||
|
alias -g S="| sort"
|
||||||
|
alias -g SC="| sort | uniq -c"
|
||||||
|
alias -g R="| rg "
|
||||||
|
alias -g W="| awk "
|
||||||
|
alias -g C="| wl-copy"
|
||||||
|
checkhash(){du $1 | sha256sum}
|
||||||
|
|
||||||
4
alias.sh
4
alias.sh
@@ -1,4 +0,0 @@
|
|||||||
alias show="kitty +kitten icat"
|
|
||||||
alias ssh="kitten ssh"
|
|
||||||
alias ip-check="~/home/venus/tools/cli-ipleak/cli-ipleak.sh"
|
|
||||||
alias mip="ip a show wlan0"
|
|
||||||
0
cache/.gitkeep
vendored
0
cache/.gitkeep
vendored
1
cache/.zsh-update
vendored
1
cache/.zsh-update
vendored
@@ -1 +0,0 @@
|
|||||||
LAST_EPOCH=20496
|
|
||||||
3
cache/grep-alias
vendored
3
cache/grep-alias
vendored
@@ -1,3 +0,0 @@
|
|||||||
alias grep='grep --color=auto --exclude-dir={.bzr,CVS,.git,.hg,.svn,.idea,.tox,.venv,venv}'
|
|
||||||
alias egrep='grep -E'
|
|
||||||
alias fgrep='grep -F'
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
alias pacman="sudo pacman"
|
|
||||||
alias foo="echo foo"
|
|
||||||
alias add-alias="~/.config/zsh/tools/add-alias.sh"
|
|
||||||
alias show="kitty +kitten icat"
|
|
||||||
alias ip-check="/home/venus/tools/cli-ipleak/cli-ipleak.sh"
|
|
||||||
|
|
||||||
Submodule custom/custom/plugins/zsh-autosuggestions deleted from 85919cd1ff
Submodule custom/custom/plugins/zsh-syntax-highlighting deleted from 1d85c69261
@@ -1,12 +0,0 @@
|
|||||||
# Put files in this folder to add your own custom functionality.
|
|
||||||
# See: https://github.com/ohmyzsh/ohmyzsh/wiki/Customization
|
|
||||||
#
|
|
||||||
# Files in the custom/ directory will be:
|
|
||||||
# - loaded automatically by the init script, in alphabetical order
|
|
||||||
# - loaded last, after all built-ins in the lib/ directory, to override them
|
|
||||||
# - ignored by git by default
|
|
||||||
#
|
|
||||||
# Example: add custom/shortcuts.zsh for shortcuts to your local projects
|
|
||||||
#
|
|
||||||
# brainstormr=~/Projects/development/planetargon/brainstormr
|
|
||||||
# cd $brainstormr
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
# Add your own custom plugins in the custom/plugins directory. Plugins placed
|
|
||||||
# here will override ones with the same name in the main plugins directory.
|
|
||||||
# See: https://github.com/ohmyzsh/ohmyzsh/wiki/Customization#overriding-and-adding-plugins
|
|
||||||
Submodule custom/plugins/zsh-autosuggestions deleted from 85919cd1ff
Submodule custom/plugins/zsh-syntax-highlighting deleted from 1d85c69261
@@ -1,6 +0,0 @@
|
|||||||
# Put your custom themes in this folder.
|
|
||||||
# See: https://github.com/ohmyzsh/ohmyzsh/wiki/Customization#overriding-and-adding-themes
|
|
||||||
#
|
|
||||||
# Example:
|
|
||||||
|
|
||||||
PROMPT="%{$fg[red]%}%n%{$reset_color%}@%{$fg[blue]%}%m %{$fg[yellow]%}%~ %{$reset_color%}%% "
|
|
||||||
59
lab04.sh
Normal file
59
lab04.sh
Normal file
@@ -0,0 +1,59 @@
|
|||||||
|
# Create the directory structure [cite: 28]
|
||||||
|
mkdir -p ~/password-cracking-lab04
|
||||||
|
|
||||||
|
# Verify the structure exists [cite: 30]
|
||||||
|
ls -R ~/password-cracking-lab04
|
||||||
|
|
||||||
|
n=1
|
||||||
|
import part0.png
|
||||||
|
# Move into the new directory [cite: 31]
|
||||||
|
cd ~/password-cracking-lab04
|
||||||
|
|
||||||
|
# Hash a password using MD5 [cite: 38]
|
||||||
|
echo -n "CyberStudent123!" | md5sum
|
||||||
|
|
||||||
|
# Hash a password using SHA-1 [cite: 39]
|
||||||
|
echo -n "CyberStudent123!" | sha1sum
|
||||||
|
|
||||||
|
# Hash a password using SHA-256 [cite: 39]
|
||||||
|
echo -n "CyberStudent123!" | sha256sum
|
||||||
|
|
||||||
|
import "1.1hashes.png"
|
||||||
|
|
||||||
|
# Set your salt and password variables [cite: 51, 52]
|
||||||
|
SALT="X9112"
|
||||||
|
PASSWORD="CyberStudent123!"
|
||||||
|
|
||||||
|
# Create a salted SHA-256 hash [cite: 53]
|
||||||
|
echo -n "${SALT}${PASSWORD}" | sha256sum
|
||||||
|
import "2.1salt.png"
|
||||||
|
|
||||||
|
# Create an unsalted SHA-256 hash for comparison [cite: 57]
|
||||||
|
echo -n "${PASSWORD}" | sha256sum
|
||||||
|
import "2.2unsalt.png"
|
||||||
|
|
||||||
|
## Part 3
|
||||||
|
|
||||||
|
# Create and edit the hashes file [cite: 69]
|
||||||
|
echo "5f4dcc3b5aa765d61d8327deb882cf99
|
||||||
|
e10adc3949ba59abbe56e057f20f883e
|
||||||
|
25d55ad283aa400af464c76d713c07ad" > hashes.txt
|
||||||
|
|
||||||
|
# Decompress the rockyou wordlist [cite: 76]
|
||||||
|
sudo gzip -dk /usr/share/wordlists/rockyou.txt.gz 2>/dev/null
|
||||||
|
|
||||||
|
# Run John the Ripper using the wordlist [cite: 76]
|
||||||
|
john --format=raw-md5 --wordlist=/usr/share/wordlists/rockyou.txt hashes.txt
|
||||||
|
import "3.3crackedHashes.png"
|
||||||
|
|
||||||
|
# Display the cracked results [cite: 79]
|
||||||
|
john --show --format=raw-md5 hashes.txt
|
||||||
|
|
||||||
|
|
||||||
|
### PART 4
|
||||||
|
# Run a Hashcat dictionary attack (Mode 0 is MD5) [cite: 89]
|
||||||
|
hashcat -m 0 hashes.txt /usr/share/wordlists/rockyou.txt --force
|
||||||
|
|
||||||
|
# Show Hashcat results [cite: 91]
|
||||||
|
hashcat -m 0 --show hashes.txt
|
||||||
|
import "4.1hashCatCracket.png"
|
||||||
@@ -1,145 +0,0 @@
|
|||||||
# The async code is taken from
|
|
||||||
# https://github.com/zsh-users/zsh-autosuggestions/blob/master/src/async.zsh
|
|
||||||
# https://github.com/woefe/git-prompt.zsh/blob/master/git-prompt.zsh
|
|
||||||
|
|
||||||
zmodload zsh/system
|
|
||||||
autoload -Uz is-at-least
|
|
||||||
|
|
||||||
# For now, async prompt function handlers are set up like so:
|
|
||||||
# First, define the async function handler and register the handler
|
|
||||||
# with _omz_register_handler:
|
|
||||||
#
|
|
||||||
# function _git_prompt_status_async {
|
|
||||||
# # Do some expensive operation that outputs to stdout
|
|
||||||
# }
|
|
||||||
# _omz_register_handler _git_prompt_status_async
|
|
||||||
#
|
|
||||||
# Then add a stub prompt function in `$PROMPT` or similar prompt variables,
|
|
||||||
# which will show the output of "$_OMZ_ASYNC_OUTPUT[handler_name]":
|
|
||||||
#
|
|
||||||
# function git_prompt_status {
|
|
||||||
# echo -n $_OMZ_ASYNC_OUTPUT[_git_prompt_status_async]
|
|
||||||
# }
|
|
||||||
#
|
|
||||||
# RPROMPT='$(git_prompt_status)'
|
|
||||||
#
|
|
||||||
# This API is subject to change and optimization. Rely on it at your own risk.
|
|
||||||
|
|
||||||
function _omz_register_handler {
|
|
||||||
setopt localoptions noksharrays unset
|
|
||||||
typeset -ga _omz_async_functions
|
|
||||||
# we want to do nothing if there's no $1 function or we already set it up
|
|
||||||
if [[ -z "$1" ]] || (( ! ${+functions[$1]} )) \
|
|
||||||
|| (( ${_omz_async_functions[(Ie)$1]} )); then
|
|
||||||
return
|
|
||||||
fi
|
|
||||||
_omz_async_functions+=("$1")
|
|
||||||
# let's add the hook to async_request if it's not there yet
|
|
||||||
if (( ! ${precmd_functions[(Ie)_omz_async_request]} )) \
|
|
||||||
&& (( ${+functions[_omz_async_request]})); then
|
|
||||||
autoload -Uz add-zsh-hook
|
|
||||||
add-zsh-hook precmd _omz_async_request
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
# Set up async handlers and callbacks
|
|
||||||
function _omz_async_request {
|
|
||||||
setopt localoptions noksharrays unset
|
|
||||||
local -i ret=$?
|
|
||||||
typeset -gA _OMZ_ASYNC_FDS _OMZ_ASYNC_PIDS _OMZ_ASYNC_OUTPUT
|
|
||||||
|
|
||||||
# executor runs a subshell for all async requests based on key
|
|
||||||
local handler
|
|
||||||
for handler in ${_omz_async_functions}; do
|
|
||||||
(( ${+functions[$handler]} )) || continue
|
|
||||||
|
|
||||||
local fd=${_OMZ_ASYNC_FDS[$handler]:--1}
|
|
||||||
local pid=${_OMZ_ASYNC_PIDS[$handler]:--1}
|
|
||||||
|
|
||||||
# If we've got a pending request, cancel it
|
|
||||||
if (( fd != -1 && pid != -1 )) && { true <&$fd } 2>/dev/null; then
|
|
||||||
# Close the file descriptor and remove the handler
|
|
||||||
exec {fd}<&-
|
|
||||||
zle -F $fd
|
|
||||||
|
|
||||||
# Zsh will make a new process group for the child process only if job
|
|
||||||
# control is enabled (MONITOR option)
|
|
||||||
if [[ -o MONITOR ]]; then
|
|
||||||
# Send the signal to the process group to kill any processes that may
|
|
||||||
# have been forked by the async function handler
|
|
||||||
kill -TERM -$pid 2>/dev/null
|
|
||||||
else
|
|
||||||
# Kill just the child process since it wasn't placed in a new process
|
|
||||||
# group. If the async function handler forked any child processes they may
|
|
||||||
# be orphaned and left behind.
|
|
||||||
kill -TERM $pid 2>/dev/null
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Define global variables to store the file descriptor, PID and output
|
|
||||||
_OMZ_ASYNC_FDS[$handler]=-1
|
|
||||||
_OMZ_ASYNC_PIDS[$handler]=-1
|
|
||||||
|
|
||||||
# Fork a process to fetch the git status and open a pipe to read from it
|
|
||||||
exec {fd}< <(
|
|
||||||
# Tell parent process our PID
|
|
||||||
builtin echo ${sysparams[pid]}
|
|
||||||
# Set exit code for the handler if used
|
|
||||||
() { return $ret }
|
|
||||||
# Run the async function handler
|
|
||||||
$handler
|
|
||||||
)
|
|
||||||
|
|
||||||
# Save FD for handler
|
|
||||||
_OMZ_ASYNC_FDS[$handler]=$fd
|
|
||||||
|
|
||||||
# There's a weird bug here where ^C stops working unless we force a fork
|
|
||||||
# See https://github.com/zsh-users/zsh-autosuggestions/issues/364
|
|
||||||
# and https://github.com/zsh-users/zsh-autosuggestions/pull/612
|
|
||||||
is-at-least 5.8 || command true
|
|
||||||
|
|
||||||
# Save the PID from the handler child process
|
|
||||||
read -u $fd "_OMZ_ASYNC_PIDS[$handler]"
|
|
||||||
|
|
||||||
# When the fd is readable, call the response handler
|
|
||||||
zle -F "$fd" _omz_async_callback
|
|
||||||
done
|
|
||||||
}
|
|
||||||
|
|
||||||
# Called when new data is ready to be read from the pipe
|
|
||||||
function _omz_async_callback() {
|
|
||||||
emulate -L zsh
|
|
||||||
|
|
||||||
local fd=$1 # First arg will be fd ready for reading
|
|
||||||
local err=$2 # Second arg will be passed in case of error
|
|
||||||
|
|
||||||
if [[ -z "$err" || "$err" == "hup" ]]; then
|
|
||||||
# Get handler name from fd
|
|
||||||
local handler="${(k)_OMZ_ASYNC_FDS[(r)$fd]}"
|
|
||||||
|
|
||||||
# Store old output which is supposed to be already printed
|
|
||||||
local old_output="${_OMZ_ASYNC_OUTPUT[$handler]}"
|
|
||||||
|
|
||||||
# Read output from fd
|
|
||||||
IFS= read -r -u $fd -d '' "_OMZ_ASYNC_OUTPUT[$handler]"
|
|
||||||
|
|
||||||
# Repaint prompt if output has changed
|
|
||||||
if [[ "$old_output" != "${_OMZ_ASYNC_OUTPUT[$handler]}" ]]; then
|
|
||||||
zle .reset-prompt
|
|
||||||
zle -R
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Close the fd
|
|
||||||
exec {fd}<&-
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Always remove the handler
|
|
||||||
zle -F "$fd"
|
|
||||||
|
|
||||||
# Unset global FD variable to prevent closing user created FDs in the precmd hook
|
|
||||||
_OMZ_ASYNC_FDS[$handler]=-1
|
|
||||||
_OMZ_ASYNC_PIDS[$handler]=-1
|
|
||||||
}
|
|
||||||
|
|
||||||
autoload -Uz add-zsh-hook
|
|
||||||
add-zsh-hook precmd _omz_async_request
|
|
||||||
14
lib/bzr.zsh
14
lib/bzr.zsh
@@ -1,14 +0,0 @@
|
|||||||
## Bazaar integration
|
|
||||||
## Just works with the GIT integration. Add $(bzr_prompt_info) to the PROMPT
|
|
||||||
function bzr_prompt_info() {
|
|
||||||
local bzr_branch
|
|
||||||
bzr_branch=$(bzr nick 2>/dev/null) || return
|
|
||||||
|
|
||||||
if [[ -n "$bzr_branch" ]]; then
|
|
||||||
local bzr_dirty=""
|
|
||||||
if [[ -n $(bzr status 2>/dev/null) ]]; then
|
|
||||||
bzr_dirty=" %{$fg[red]%}*%{$reset_color%}"
|
|
||||||
fi
|
|
||||||
printf "%s%s%s%s" "$ZSH_THEME_SCM_PROMPT_PREFIX" "bzr::${bzr_branch##*:}" "$bzr_dirty" "$ZSH_THEME_GIT_PROMPT_SUFFIX"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
944
lib/cli.zsh
944
lib/cli.zsh
@@ -1,944 +0,0 @@
|
|||||||
#!/usr/bin/env zsh
|
|
||||||
|
|
||||||
function omz {
|
|
||||||
setopt localoptions noksharrays
|
|
||||||
[[ $# -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'
|
|
||||||
'reload:Reload the current zsh session'
|
|
||||||
'shop:Open the Oh My Zsh shop'
|
|
||||||
'theme:Manage themes'
|
|
||||||
'update:Update Oh My Zsh'
|
|
||||||
'version:Show the version'
|
|
||||||
)
|
|
||||||
|
|
||||||
if (( CURRENT == 2 )); then
|
|
||||||
_describe 'command' cmds
|
|
||||||
elif (( CURRENT == 3 )); then
|
|
||||||
case "$words[2]" in
|
|
||||||
changelog) local -a refs
|
|
||||||
refs=("${(@f)$(builtin cd -q "$ZSH"; command git for-each-ref --format="%(refname:short):%(subject)" refs/heads refs/tags)}")
|
|
||||||
_describe 'command' refs ;;
|
|
||||||
plugin) subcmds=(
|
|
||||||
'disable:Disable plugin(s)'
|
|
||||||
'enable:Enable plugin(s)'
|
|
||||||
'info:Get plugin information'
|
|
||||||
'list:List plugins'
|
|
||||||
'load:Load plugin(s)'
|
|
||||||
)
|
|
||||||
_describe 'command' subcmds ;;
|
|
||||||
pr) subcmds=('clean:Delete all Pull Request branches' 'test:Test a Pull Request')
|
|
||||||
_describe 'command' subcmds ;;
|
|
||||||
theme) subcmds=('list:List themes' 'set:Set a theme in your .zshrc file' 'use:Load a theme')
|
|
||||||
_describe 'command' subcmds ;;
|
|
||||||
esac
|
|
||||||
elif (( CURRENT == 4 )); then
|
|
||||||
case "${words[2]}::${words[3]}" in
|
|
||||||
plugin::(disable|enable|load))
|
|
||||||
local -aU valid_plugins
|
|
||||||
|
|
||||||
if [[ "${words[3]}" = disable ]]; then
|
|
||||||
# if command is "disable", only offer already enabled plugins
|
|
||||||
valid_plugins=($plugins)
|
|
||||||
else
|
|
||||||
valid_plugins=("$ZSH"/plugins/*/{_*,*.plugin.zsh}(-.N:h:t) "$ZSH_CUSTOM"/plugins/*/{_*,*.plugin.zsh}(-.N:h:t))
|
|
||||||
# if command is "enable", remove already enabled plugins
|
|
||||||
[[ "${words[3]}" = enable ]] && valid_plugins=(${valid_plugins:|plugins})
|
|
||||||
fi
|
|
||||||
|
|
||||||
_describe 'plugin' valid_plugins ;;
|
|
||||||
plugin::info)
|
|
||||||
local -aU plugins
|
|
||||||
plugins=("$ZSH"/plugins/*/{_*,*.plugin.zsh}(-.N:h:t) "$ZSH_CUSTOM"/plugins/*/{_*,*.plugin.zsh}(-.N:h:t))
|
|
||||||
_describe 'plugin' plugins ;;
|
|
||||||
plugin::list)
|
|
||||||
local -a opts
|
|
||||||
opts=('--enabled:List enabled plugins only')
|
|
||||||
_describe -o 'options' opts ;;
|
|
||||||
theme::(set|use))
|
|
||||||
local -aU themes
|
|
||||||
themes=("$ZSH"/themes/*.zsh-theme(-.N:t:r) "$ZSH_CUSTOM"/**/*.zsh-theme(-.N:r:gs:"$ZSH_CUSTOM"/themes/:::gs:"$ZSH_CUSTOM"/:::))
|
|
||||||
_describe 'theme' themes ;;
|
|
||||||
esac
|
|
||||||
elif (( CURRENT > 4 )); then
|
|
||||||
case "${words[2]}::${words[3]}" in
|
|
||||||
plugin::(enable|disable|load))
|
|
||||||
local -aU valid_plugins
|
|
||||||
|
|
||||||
if [[ "${words[3]}" = disable ]]; then
|
|
||||||
# if command is "disable", only offer already enabled plugins
|
|
||||||
valid_plugins=($plugins)
|
|
||||||
else
|
|
||||||
valid_plugins=("$ZSH"/plugins/*/{_*,*.plugin.zsh}(-.N:h:t) "$ZSH_CUSTOM"/plugins/*/{_*,*.plugin.zsh}(-.N:h:t))
|
|
||||||
# if command is "enable", remove already enabled plugins
|
|
||||||
[[ "${words[3]}" = enable ]] && valid_plugins=(${valid_plugins:|plugins})
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Remove plugins already passed as arguments
|
|
||||||
# NOTE: $(( CURRENT - 1 )) is the last plugin argument completely passed, i.e. that which
|
|
||||||
# has a space after them. This is to avoid removing plugins partially passed, which makes
|
|
||||||
# the completion not add a space after the completed plugin.
|
|
||||||
local -a args
|
|
||||||
args=(${words[4,$(( CURRENT - 1))]})
|
|
||||||
valid_plugins=(${valid_plugins:|args})
|
|
||||||
|
|
||||||
_describe 'plugin' valid_plugins ;;
|
|
||||||
esac
|
|
||||||
fi
|
|
||||||
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
|
|
||||||
# If run from a script, do not set the completion function
|
|
||||||
if (( ${+functions[compdef]} )); then
|
|
||||||
compdef _omz omz
|
|
||||||
fi
|
|
||||||
|
|
||||||
## 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 >&2 <<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
|
|
||||||
reload Reload the current zsh session
|
|
||||||
shop Open the Oh My Zsh shop
|
|
||||||
theme <command> Manage themes
|
|
||||||
update Update Oh My Zsh
|
|
||||||
version Show the version
|
|
||||||
|
|
||||||
EOF
|
|
||||||
}
|
|
||||||
|
|
||||||
function _omz::changelog {
|
|
||||||
local version=${1:-HEAD} format=${3:-"--text"}
|
|
||||||
|
|
||||||
if (
|
|
||||||
builtin cd -q "$ZSH"
|
|
||||||
! command git show-ref --verify refs/heads/$version && \
|
|
||||||
! command git show-ref --verify refs/tags/$version && \
|
|
||||||
! command git rev-parse --verify "${version}^{commit}"
|
|
||||||
) &>/dev/null; then
|
|
||||||
cat >&2 <<EOF
|
|
||||||
Usage: ${(j: :)${(s.::.)0#_}} [version]
|
|
||||||
|
|
||||||
NOTE: <version> must be a valid branch, tag or commit.
|
|
||||||
EOF
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
ZSH="$ZSH" command zsh -f "$ZSH/tools/changelog.sh" "$version" "${2:-}" "$format"
|
|
||||||
}
|
|
||||||
|
|
||||||
function _omz::plugin {
|
|
||||||
(( $# > 0 && $+functions[$0::$1] )) || {
|
|
||||||
cat >&2 <<EOF
|
|
||||||
Usage: ${(j: :)${(s.::.)0#_}} <command> [options]
|
|
||||||
|
|
||||||
Available commands:
|
|
||||||
|
|
||||||
disable <plugin> Disable plugin(s)
|
|
||||||
enable <plugin> Enable plugin(s)
|
|
||||||
info <plugin> Get information of a plugin
|
|
||||||
list [--enabled] List Oh My Zsh plugins
|
|
||||||
load <plugin> Load plugin(s)
|
|
||||||
|
|
||||||
EOF
|
|
||||||
return 1
|
|
||||||
}
|
|
||||||
|
|
||||||
local command="$1"
|
|
||||||
shift
|
|
||||||
|
|
||||||
$0::$command "$@"
|
|
||||||
}
|
|
||||||
|
|
||||||
function _omz::plugin::disable {
|
|
||||||
if [[ -z "$1" ]]; then
|
|
||||||
echo >&2 "Usage: ${(j: :)${(s.::.)0#_}} <plugin> [...]"
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Check that plugin is in $plugins
|
|
||||||
local -a dis_plugins
|
|
||||||
for plugin in "$@"; do
|
|
||||||
if [[ ${plugins[(Ie)$plugin]} -eq 0 ]]; then
|
|
||||||
_omz::log warn "plugin '$plugin' is not enabled."
|
|
||||||
continue
|
|
||||||
fi
|
|
||||||
dis_plugins+=("$plugin")
|
|
||||||
done
|
|
||||||
|
|
||||||
# Exit if there are no enabled plugins to disable
|
|
||||||
if [[ ${#dis_plugins} -eq 0 ]]; then
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Remove plugins substitution awk script
|
|
||||||
local awk_subst_plugins="\
|
|
||||||
gsub(/[ \t]+(${(j:|:)dis_plugins})[ \t]+/, \" \") # with spaces before or after
|
|
||||||
gsub(/[ \t]+(${(j:|:)dis_plugins})$/, \"\") # with spaces before and EOL
|
|
||||||
gsub(/^(${(j:|:)dis_plugins})[ \t]+/, \"\") # with BOL and spaces after
|
|
||||||
|
|
||||||
gsub(/\((${(j:|:)dis_plugins})[ \t]+/, \"(\") # with parenthesis before and spaces after
|
|
||||||
gsub(/[ \t]+(${(j:|:)dis_plugins})\)/, \")\") # with spaces before or parenthesis after
|
|
||||||
gsub(/\((${(j:|:)dis_plugins})\)/, \"()\") # with only parentheses
|
|
||||||
|
|
||||||
gsub(/^(${(j:|:)dis_plugins})\)/, \")\") # with BOL and closing parenthesis
|
|
||||||
gsub(/\((${(j:|:)dis_plugins})$/, \"(\") # with opening parenthesis and EOL
|
|
||||||
"
|
|
||||||
|
|
||||||
# Disable plugins awk script
|
|
||||||
local awk_script="
|
|
||||||
# if plugins=() is in oneline form, substitute disabled plugins and go to next line
|
|
||||||
/^[ \t]*plugins=\([^#]+\).*\$/ {
|
|
||||||
$awk_subst_plugins
|
|
||||||
print \$0
|
|
||||||
next
|
|
||||||
}
|
|
||||||
|
|
||||||
# if plugins=() is in multiline form, enable multi flag and disable plugins if they're there
|
|
||||||
/^[ \t]*plugins=\(/ {
|
|
||||||
multi=1
|
|
||||||
$awk_subst_plugins
|
|
||||||
print \$0
|
|
||||||
next
|
|
||||||
}
|
|
||||||
|
|
||||||
# if multi flag is enabled and we find a valid closing parenthesis, remove plugins and disable multi flag
|
|
||||||
multi == 1 && /^[^#]*\)/ {
|
|
||||||
multi=0
|
|
||||||
$awk_subst_plugins
|
|
||||||
print \$0
|
|
||||||
next
|
|
||||||
}
|
|
||||||
|
|
||||||
multi == 1 && length(\$0) > 0 {
|
|
||||||
$awk_subst_plugins
|
|
||||||
if (length(\$0) > 0) print \$0
|
|
||||||
next
|
|
||||||
}
|
|
||||||
|
|
||||||
{ print \$0 }
|
|
||||||
"
|
|
||||||
|
|
||||||
local zdot="${ZDOTDIR:-$HOME}"
|
|
||||||
local zshrc="${${:-"${zdot}/.zshrc"}:A}"
|
|
||||||
awk "$awk_script" "$zshrc" > "$zdot/.zshrc.new" \
|
|
||||||
&& command cp -f "$zshrc" "$zdot/.zshrc.bck" \
|
|
||||||
&& command mv -f "$zdot/.zshrc.new" "$zshrc"
|
|
||||||
|
|
||||||
# Exit if the new .zshrc file wasn't created correctly
|
|
||||||
[[ $? -eq 0 ]] || {
|
|
||||||
local ret=$?
|
|
||||||
_omz::log error "error disabling plugins."
|
|
||||||
return $ret
|
|
||||||
}
|
|
||||||
|
|
||||||
# Exit if the new .zshrc file has syntax errors
|
|
||||||
if ! command zsh -n "$zdot/.zshrc"; then
|
|
||||||
_omz::log error "broken syntax in '"${zdot/#$HOME/\~}/.zshrc"'. Rolling back changes..."
|
|
||||||
command mv -f "$zdot/.zshrc.bck" "$zshrc"
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Restart the zsh session if there were no errors
|
|
||||||
_omz::log info "plugins disabled: ${(j:, :)dis_plugins}."
|
|
||||||
|
|
||||||
# Only reload zsh if run in an interactive session
|
|
||||||
[[ ! -o interactive ]] || _omz::reload
|
|
||||||
}
|
|
||||||
|
|
||||||
function _omz::plugin::enable {
|
|
||||||
if [[ -z "$1" ]]; then
|
|
||||||
echo >&2 "Usage: ${(j: :)${(s.::.)0#_}} <plugin> [...]"
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Check that plugin is not in $plugins
|
|
||||||
local -a add_plugins
|
|
||||||
for plugin in "$@"; do
|
|
||||||
if [[ ${plugins[(Ie)$plugin]} -ne 0 ]]; then
|
|
||||||
_omz::log warn "plugin '$plugin' is already enabled."
|
|
||||||
continue
|
|
||||||
fi
|
|
||||||
add_plugins+=("$plugin")
|
|
||||||
done
|
|
||||||
|
|
||||||
# Exit if there are no plugins to enable
|
|
||||||
if [[ ${#add_plugins} -eq 0 ]]; then
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Enable plugins awk script
|
|
||||||
local awk_script="
|
|
||||||
# if plugins=() is in oneline form, substitute ) with new plugins and go to the next line
|
|
||||||
/^[ \t]*plugins=\([^#]+\).*\$/ {
|
|
||||||
sub(/\)/, \" $add_plugins&\")
|
|
||||||
print \$0
|
|
||||||
next
|
|
||||||
}
|
|
||||||
|
|
||||||
# if plugins=() is in multiline form, enable multi flag and indent by default with 2 spaces
|
|
||||||
/^[ \t]*plugins=\(/ {
|
|
||||||
multi=1
|
|
||||||
indent=\" \"
|
|
||||||
print \$0
|
|
||||||
next
|
|
||||||
}
|
|
||||||
|
|
||||||
# if multi flag is enabled and we find a valid closing parenthesis,
|
|
||||||
# add new plugins with proper indent and disable multi flag
|
|
||||||
multi == 1 && /^[^#]*\)/ {
|
|
||||||
multi=0
|
|
||||||
split(\"$add_plugins\",p,\" \")
|
|
||||||
for (i in p) {
|
|
||||||
print indent p[i]
|
|
||||||
}
|
|
||||||
print \$0
|
|
||||||
next
|
|
||||||
}
|
|
||||||
|
|
||||||
# if multi flag is enabled and we didnt find a closing parenthesis,
|
|
||||||
# get the indentation level to match when adding plugins
|
|
||||||
multi == 1 && /^[^#]*/ {
|
|
||||||
indent=\"\"
|
|
||||||
for (i = 1; i <= length(\$0); i++) {
|
|
||||||
char=substr(\$0, i, 1)
|
|
||||||
if (char == \" \" || char == \"\t\") {
|
|
||||||
indent = indent char
|
|
||||||
} else {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
{ print \$0 }
|
|
||||||
"
|
|
||||||
|
|
||||||
local zdot="${ZDOTDIR:-$HOME}"
|
|
||||||
local zshrc="${${:-"${zdot}/.zshrc"}:A}"
|
|
||||||
awk "$awk_script" "$zshrc" > "$zdot/.zshrc.new" \
|
|
||||||
&& command cp -f "$zshrc" "$zdot/.zshrc.bck" \
|
|
||||||
&& command mv -f "$zdot/.zshrc.new" "$zshrc"
|
|
||||||
|
|
||||||
# Exit if the new .zshrc file wasn't created correctly
|
|
||||||
[[ $? -eq 0 ]] || {
|
|
||||||
local ret=$?
|
|
||||||
_omz::log error "error enabling plugins."
|
|
||||||
return $ret
|
|
||||||
}
|
|
||||||
|
|
||||||
# Exit if the new .zshrc file has syntax errors
|
|
||||||
if ! command zsh -n "$zdot/.zshrc"; then
|
|
||||||
_omz::log error "broken syntax in '"${zdot/#$HOME/\~}/.zshrc"'. Rolling back changes..."
|
|
||||||
command mv -f "$zdot/.zshrc.bck" "$zshrc"
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Restart the zsh session if there were no errors
|
|
||||||
_omz::log info "plugins enabled: ${(j:, :)add_plugins}."
|
|
||||||
|
|
||||||
# Only reload zsh if run in an interactive session
|
|
||||||
[[ ! -o interactive ]] || _omz::reload
|
|
||||||
}
|
|
||||||
|
|
||||||
function _omz::plugin::info {
|
|
||||||
if [[ -z "$1" ]]; then
|
|
||||||
echo >&2 "Usage: ${(j: :)${(s.::.)0#_}} <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
|
|
||||||
# If being piped, just cat the README
|
|
||||||
if [[ ! -t 1 ]]; then
|
|
||||||
cat "$readme"
|
|
||||||
return $?
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Enrich the README display depending on the tools we have
|
|
||||||
# - glow: https://github.com/charmbracelet/glow
|
|
||||||
# - bat: https://github.com/sharkdp/bat
|
|
||||||
# - less: typical pager command
|
|
||||||
case 1 in
|
|
||||||
${+commands[glow]}) glow -p "$readme" ;;
|
|
||||||
${+commands[bat]}) bat -l md --style plain "$readme" ;;
|
|
||||||
${+commands[less]}) less "$readme" ;;
|
|
||||||
*) cat "$readme" ;;
|
|
||||||
esac
|
|
||||||
return $?
|
|
||||||
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
|
|
||||||
|
|
||||||
# If --enabled is provided, only list what's enabled
|
|
||||||
if [[ "$1" == "--enabled" ]]; then
|
|
||||||
local plugin
|
|
||||||
for plugin in "${plugins[@]}"; do
|
|
||||||
if [[ -d "${ZSH_CUSTOM}/plugins/${plugin}" ]]; then
|
|
||||||
custom_plugins+=("${plugin}")
|
|
||||||
elif [[ -d "${ZSH}/plugins/${plugin}" ]]; then
|
|
||||||
builtin_plugins+=("${plugin}")
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
else
|
|
||||||
custom_plugins=("$ZSH_CUSTOM"/plugins/*(-/N:t))
|
|
||||||
builtin_plugins=("$ZSH"/plugins/*(-/N:t))
|
|
||||||
fi
|
|
||||||
|
|
||||||
# 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 -lac ${(q-)custom_plugins}
|
|
||||||
fi
|
|
||||||
|
|
||||||
if (( ${#builtin_plugins} )); then
|
|
||||||
(( ${#custom_plugins} )) && echo # add a line of separation
|
|
||||||
|
|
||||||
print -P "%U%BBuilt-in plugins%b%u:"
|
|
||||||
print -lac ${(q-)builtin_plugins}
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
function _omz::plugin::load {
|
|
||||||
if [[ -z "$1" ]]; then
|
|
||||||
echo >&2 "Usage: ${(j: :)${(s.::.)0#_}} <plugin> [...]"
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
local plugin base has_completion=0
|
|
||||||
for plugin in "$@"; do
|
|
||||||
if [[ -d "$ZSH_CUSTOM/plugins/$plugin" ]]; then
|
|
||||||
base="$ZSH_CUSTOM/plugins/$plugin"
|
|
||||||
elif [[ -d "$ZSH/plugins/$plugin" ]]; then
|
|
||||||
base="$ZSH/plugins/$plugin"
|
|
||||||
else
|
|
||||||
_omz::log warn "plugin '$plugin' not found"
|
|
||||||
continue
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Check if its a valid plugin
|
|
||||||
if [[ ! -f "$base/_$plugin" && ! -f "$base/$plugin.plugin.zsh" ]]; then
|
|
||||||
_omz::log warn "'$plugin' is not a valid plugin"
|
|
||||||
continue
|
|
||||||
# It is a valid plugin, add its directory to $fpath unless it is already there
|
|
||||||
elif (( ! ${fpath[(Ie)$base]} )); then
|
|
||||||
fpath=("$base" $fpath)
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Check if it has completion to reload compinit
|
|
||||||
local -a comp_files
|
|
||||||
comp_files=($base/_*(N))
|
|
||||||
has_completion=$(( $#comp_files > 0 ))
|
|
||||||
|
|
||||||
# Load the plugin
|
|
||||||
if [[ -f "$base/$plugin.plugin.zsh" ]]; then
|
|
||||||
source "$base/$plugin.plugin.zsh"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
# If we have completion, we need to reload the completion
|
|
||||||
# We pass -D to avoid generating a new dump file, which would overwrite our
|
|
||||||
# current one for the next session (and we don't want that because we're not
|
|
||||||
# actually enabling the plugins for the next session).
|
|
||||||
# Note that we still have to pass -d "$_comp_dumpfile", so that compinit
|
|
||||||
# doesn't use the default zcompdump location (${ZDOTDIR:-$HOME}/.zcompdump).
|
|
||||||
if (( has_completion )); then
|
|
||||||
compinit -D -d "$_comp_dumpfile"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
function _omz::pr {
|
|
||||||
(( $# > 0 && $+functions[$0::$1] )) || {
|
|
||||||
cat >&2 <<EOF
|
|
||||||
Usage: ${(j: :)${(s.::.)0#_}} <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
|
|
||||||
|
|
||||||
$0::$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: ${(j: :)${(s.::.)0#_}} <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 find the ohmyzsh git remote. Aborting..."
|
|
||||||
return 1
|
|
||||||
}
|
|
||||||
|
|
||||||
# Check if Pull Request has the "testers needed" label
|
|
||||||
_omz::log info "checking if PR #$1 has the 'testers needed' label..."
|
|
||||||
local pr_json label label_id="MDU6TGFiZWw4NzY1NTkwNA=="
|
|
||||||
pr_json=$(
|
|
||||||
curl -fsSL \
|
|
||||||
-H "Accept: application/vnd.github+json" \
|
|
||||||
-H "X-GitHub-Api-Version: 2022-11-28" \
|
|
||||||
"https://api.github.com/repos/ohmyzsh/ohmyzsh/pulls/$1"
|
|
||||||
)
|
|
||||||
|
|
||||||
if [[ $? -gt 0 || -z "$pr_json" ]]; then
|
|
||||||
_omz::log error "error when trying to fetch PR #$1 from GitHub."
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Check if the label is present with jq or grep
|
|
||||||
if (( $+commands[jq] )); then
|
|
||||||
label="$(command jq ".labels.[] | select(.node_id == \"$label_id\")" <<< "$pr_json")"
|
|
||||||
else
|
|
||||||
label="$(command grep "\"$label_id\"" <<< "$pr_json" 2>/dev/null)"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# If a maintainer hasn't labeled the PR to test, explain the security risk
|
|
||||||
if [[ -z "$label" ]]; then
|
|
||||||
_omz::log warn "PR #$1 does not have the 'testers needed' label. This means that the PR"
|
|
||||||
_omz::log warn "has not been reviewed by a maintainer and may contain malicious code."
|
|
||||||
|
|
||||||
# Ask for explicit confirmation: user needs to type "yes" to continue
|
|
||||||
_omz::log prompt "Do you want to continue testing it? [yes/N] "
|
|
||||||
builtin read -r
|
|
||||||
if [[ "${REPLY:l}" != yes ]]; then
|
|
||||||
_omz::log error "PR test canceled. Please ask a maintainer to review and label the PR."
|
|
||||||
return 1
|
|
||||||
else
|
|
||||||
_omz::log warn "Continuing to check out and test PR #$1. Be careful!"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
# 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..."
|
|
||||||
local ret gpgsign
|
|
||||||
{
|
|
||||||
# Back up commit.gpgsign setting: use --local to get the current repository
|
|
||||||
# setting, not the global one. If --local is not a known option, it will
|
|
||||||
# exit with a 129 status code.
|
|
||||||
gpgsign=$(command git config --local commit.gpgsign 2>/dev/null) || ret=$?
|
|
||||||
[[ $ret -ne 129 ]] || gpgsign=$(command git config commit.gpgsign 2>/dev/null)
|
|
||||||
command git config commit.gpgsign false
|
|
||||||
|
|
||||||
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
|
|
||||||
}
|
|
||||||
} always {
|
|
||||||
case "$gpgsign" in
|
|
||||||
"") command git config --unset commit.gpgsign ;;
|
|
||||||
*) command git config commit.gpgsign "$gpgsign" ;;
|
|
||||||
esac
|
|
||||||
}
|
|
||||||
|
|
||||||
_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::shop {
|
|
||||||
local shop_url="https://commitgoods.com/collections/oh-my-zsh"
|
|
||||||
|
|
||||||
_omz::log info "Opening Oh My Zsh shop in your browser..."
|
|
||||||
_omz::log info "$shop_url"
|
|
||||||
|
|
||||||
open_command "$shop_url"
|
|
||||||
}
|
|
||||||
|
|
||||||
function _omz::reload {
|
|
||||||
# Delete current completion cache
|
|
||||||
command rm -f $_comp_dumpfile $ZSH_COMPDUMP
|
|
||||||
|
|
||||||
# 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"
|
|
||||||
}
|
|
||||||
|
|
||||||
function _omz::theme {
|
|
||||||
(( $# > 0 && $+functions[$0::$1] )) || {
|
|
||||||
cat >&2 <<EOF
|
|
||||||
Usage: ${(j: :)${(s.::.)0#_}} <command> [options]
|
|
||||||
|
|
||||||
Available commands:
|
|
||||||
|
|
||||||
list List all available Oh My Zsh themes
|
|
||||||
set <theme> Set a theme in your .zshrc file
|
|
||||||
use <theme> Load a theme
|
|
||||||
|
|
||||||
EOF
|
|
||||||
return 1
|
|
||||||
}
|
|
||||||
|
|
||||||
local command="$1"
|
|
||||||
shift
|
|
||||||
|
|
||||||
$0::$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
|
|
||||||
|
|
||||||
# Print theme in use
|
|
||||||
if [[ -n "$ZSH_THEME" ]]; then
|
|
||||||
print -Pn "%U%BCurrent theme%b%u: "
|
|
||||||
[[ $ZSH_THEME = random ]] && echo "$RANDOM_THEME (via random)" || echo "$ZSH_THEME"
|
|
||||||
echo
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Print custom themes if there are any
|
|
||||||
if (( ${#custom_themes} )); then
|
|
||||||
print -P "%U%BCustom themes%b%u:"
|
|
||||||
print -lac ${(q-)custom_themes}
|
|
||||||
echo
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Print built-in themes
|
|
||||||
print -P "%U%BBuilt-in themes%b%u:"
|
|
||||||
print -lac ${(q-)builtin_themes}
|
|
||||||
}
|
|
||||||
|
|
||||||
function _omz::theme::set {
|
|
||||||
if [[ -z "$1" ]]; then
|
|
||||||
echo >&2 "Usage: ${(j: :)${(s.::.)0#_}} <theme>"
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Check that theme exists
|
|
||||||
if [[ ! -f "$ZSH_CUSTOM/$1.zsh-theme" ]] \
|
|
||||||
&& [[ ! -f "$ZSH_CUSTOM/themes/$1.zsh-theme" ]] \
|
|
||||||
&& [[ ! -f "$ZSH/themes/$1.zsh-theme" ]]; then
|
|
||||||
_omz::log error "%B$1%b theme not found"
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Enable theme in .zshrc
|
|
||||||
local awk_script='
|
|
||||||
!set && /^[ \t]*ZSH_THEME=[^#]+.*$/ {
|
|
||||||
set=1
|
|
||||||
sub(/^[ \t]*ZSH_THEME=[^#]+.*$/, "ZSH_THEME=\"'$1'\" # set by `omz`")
|
|
||||||
print $0
|
|
||||||
next
|
|
||||||
}
|
|
||||||
|
|
||||||
{ print $0 }
|
|
||||||
|
|
||||||
END {
|
|
||||||
# If no ZSH_THEME= line was found, return an error
|
|
||||||
if (!set) exit 1
|
|
||||||
}
|
|
||||||
'
|
|
||||||
|
|
||||||
local zdot="${ZDOTDIR:-$HOME}"
|
|
||||||
local zshrc="${${:-"${zdot}/.zshrc"}:A}"
|
|
||||||
awk "$awk_script" "$zshrc" > "$zdot/.zshrc.new" \
|
|
||||||
|| {
|
|
||||||
# Prepend ZSH_THEME= line to .zshrc if it doesn't exist
|
|
||||||
cat <<EOF
|
|
||||||
ZSH_THEME="$1" # set by \`omz\`
|
|
||||||
|
|
||||||
EOF
|
|
||||||
cat "$zdot/.zshrc"
|
|
||||||
} > "$zdot/.zshrc.new" \
|
|
||||||
&& command cp -f "$zshrc" "$zdot/.zshrc.bck" \
|
|
||||||
&& command mv -f "$zdot/.zshrc.new" "$zshrc"
|
|
||||||
|
|
||||||
# Exit if the new .zshrc file wasn't created correctly
|
|
||||||
[[ $? -eq 0 ]] || {
|
|
||||||
local ret=$?
|
|
||||||
_omz::log error "error setting theme."
|
|
||||||
return $ret
|
|
||||||
}
|
|
||||||
|
|
||||||
# Exit if the new .zshrc file has syntax errors
|
|
||||||
if ! command zsh -n "$zdot/.zshrc"; then
|
|
||||||
_omz::log error "broken syntax in '"${zdot/#$HOME/\~}/.zshrc"'. Rolling back changes..."
|
|
||||||
command mv -f "$zdot/.zshrc.bck" "$zshrc"
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Restart the zsh session if there were no errors
|
|
||||||
_omz::log info "'$1' theme set correctly."
|
|
||||||
|
|
||||||
# Only reload zsh if run in an interactive session
|
|
||||||
[[ ! -o interactive ]] || _omz::reload
|
|
||||||
}
|
|
||||||
|
|
||||||
function _omz::theme::use {
|
|
||||||
if [[ -z "$1" ]]; then
|
|
||||||
echo >&2 "Usage: ${(j: :)${(s.::.)0#_}} <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 "%B$1%b theme not found"
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Update theme settings
|
|
||||||
ZSH_THEME="$1"
|
|
||||||
[[ $1 = random ]] || unset RANDOM_THEME
|
|
||||||
}
|
|
||||||
|
|
||||||
function _omz::update {
|
|
||||||
# Check if git command is available
|
|
||||||
(( $+commands[git] )) || {
|
|
||||||
_omz::log error "git is not installed. Aborting..."
|
|
||||||
return 1
|
|
||||||
}
|
|
||||||
|
|
||||||
# Check if --unattended was passed
|
|
||||||
[[ "$1" != --unattended ]] || {
|
|
||||||
_omz::log error "the \`\e[2m--unattended\e[0m\` flag is no longer supported, use the \`\e[2mupgrade.sh\e[0m\` script instead."
|
|
||||||
_omz::log error "for more information see https://github.com/ohmyzsh/ohmyzsh/wiki/FAQ#how-do-i-update-oh-my-zsh"
|
|
||||||
return 1
|
|
||||||
}
|
|
||||||
|
|
||||||
local last_commit=$(builtin cd -q "$ZSH"; git rev-parse HEAD 2>/dev/null)
|
|
||||||
[[ $? -eq 0 ]] || {
|
|
||||||
_omz::log error "\`$ZSH\` is not a git directory. Aborting..."
|
|
||||||
return 1
|
|
||||||
}
|
|
||||||
|
|
||||||
# Run update script
|
|
||||||
zstyle -s ':omz:update' verbose verbose_mode || verbose_mode=default
|
|
||||||
ZSH="$ZSH" command zsh -f "$ZSH/tools/upgrade.sh" -i -v $verbose_mode || return $?
|
|
||||||
|
|
||||||
# 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 [[ "$(builtin cd -q "$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
|
|
||||||
}
|
|
||||||
|
|
||||||
function _omz::version {
|
|
||||||
(
|
|
||||||
builtin cd -q "$ZSH"
|
|
||||||
|
|
||||||
# Get the version name:
|
|
||||||
# 1) try tag-like version
|
|
||||||
# 2) try branch name
|
|
||||||
# 3) try name-rev (tag~<rev> or branch~<rev>)
|
|
||||||
local version
|
|
||||||
version=$(command git describe --tags HEAD 2>/dev/null) \
|
|
||||||
|| version=$(command git symbolic-ref --quiet --short HEAD 2>/dev/null) \
|
|
||||||
|| version=$(command git name-rev --no-undefined --name-only --exclude="remotes/*" HEAD 2>/dev/null) \
|
|
||||||
|| version="<detached>"
|
|
||||||
|
|
||||||
# Get short hash for the current HEAD
|
|
||||||
local commit=$(command git rev-parse --short HEAD 2>/dev/null)
|
|
||||||
|
|
||||||
# Show version and commit hash
|
|
||||||
printf "%s (%s)\n" "$version" "$commit"
|
|
||||||
)
|
|
||||||
}
|
|
||||||
@@ -1,107 +0,0 @@
|
|||||||
# System clipboard integration
|
|
||||||
#
|
|
||||||
# This file has support for doing system clipboard copy and paste operations
|
|
||||||
# from the command line in a generic cross-platform fashion.
|
|
||||||
#
|
|
||||||
# This is uses essentially the same heuristic as neovim, with the additional
|
|
||||||
# special support for Cygwin.
|
|
||||||
# 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)
|
|
||||||
# - xsel (if $DISPLAY is set)
|
|
||||||
# - xclip (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
|
|
||||||
#
|
|
||||||
# Usage:
|
|
||||||
#
|
|
||||||
# <command> | clipcopy - copies stdin to clipboard
|
|
||||||
#
|
|
||||||
# clipcopy <file> - copies a file's contents to clipboard
|
|
||||||
#
|
|
||||||
##
|
|
||||||
#
|
|
||||||
# clippaste - "Paste" data from clipboard to stdout
|
|
||||||
#
|
|
||||||
# Usage:
|
|
||||||
#
|
|
||||||
# clippaste - writes clipboard's contents to stdout
|
|
||||||
#
|
|
||||||
# clippaste | <command> - pastes contents and pipes it to another process
|
|
||||||
#
|
|
||||||
# clippaste > <file> - paste contents to a file
|
|
||||||
#
|
|
||||||
# Examples:
|
|
||||||
#
|
|
||||||
# # Pipe to another process
|
|
||||||
# clippaste | grep foo
|
|
||||||
#
|
|
||||||
# # Paste to a file
|
|
||||||
# clippaste > file.txt
|
|
||||||
#
|
|
||||||
function detect-clipboard() {
|
|
||||||
emulate -L zsh
|
|
||||||
|
|
||||||
if [[ "${OSTYPE}" == darwin* ]] && (( ${+commands[pbcopy]} )) && (( ${+commands[pbpaste]} )); then
|
|
||||||
function clipcopy() { cat "${1:-/dev/stdin}" | pbcopy; }
|
|
||||||
function clippaste() { pbpaste; }
|
|
||||||
elif [[ "${OSTYPE}" == (cygwin|msys)* ]]; then
|
|
||||||
function clipcopy() { cat "${1:-/dev/stdin}" > /dev/clipboard; }
|
|
||||||
function clippaste() { cat /dev/clipboard; }
|
|
||||||
elif (( $+commands[clip.exe] )) && (( $+commands[powershell.exe] )); then
|
|
||||||
function clipcopy() { cat "${1:-/dev/stdin}" | clip.exe; }
|
|
||||||
function clippaste() { powershell.exe -noprofile -command Get-Clipboard; }
|
|
||||||
elif [ -n "${WAYLAND_DISPLAY:-}" ] && (( ${+commands[wl-copy]} )) && (( ${+commands[wl-paste]} )); then
|
|
||||||
function clipcopy() { cat "${1:-/dev/stdin}" | wl-copy &>/dev/null &|; }
|
|
||||||
function clippaste() { wl-paste --no-newline; }
|
|
||||||
elif [ -n "${DISPLAY:-}" ] && (( ${+commands[xsel]} )); then
|
|
||||||
function clipcopy() { cat "${1:-/dev/stdin}" | xsel --clipboard --input; }
|
|
||||||
function clippaste() { xsel --clipboard --output; }
|
|
||||||
elif [ -n "${DISPLAY:-}" ] && (( ${+commands[xclip]} )); then
|
|
||||||
function clipcopy() { cat "${1:-/dev/stdin}" | xclip -selection clipboard -in &>/dev/null &|; }
|
|
||||||
function clippaste() { xclip -out -selection clipboard; }
|
|
||||||
elif (( ${+commands[lemonade]} )); then
|
|
||||||
function clipcopy() { cat "${1:-/dev/stdin}" | lemonade copy; }
|
|
||||||
function clippaste() { lemonade paste; }
|
|
||||||
elif (( ${+commands[doitclient]} )); then
|
|
||||||
function clipcopy() { cat "${1:-/dev/stdin}" | doitclient wclip; }
|
|
||||||
function clippaste() { doitclient wclip -r; }
|
|
||||||
elif (( ${+commands[win32yank]} )); then
|
|
||||||
function clipcopy() { cat "${1:-/dev/stdin}" | win32yank -i; }
|
|
||||||
function clippaste() { win32yank -o; }
|
|
||||||
elif [[ $OSTYPE == linux-android* ]] && (( $+commands[termux-clipboard-set] )); then
|
|
||||||
function clipcopy() { cat "${1:-/dev/stdin}" | termux-clipboard-set; }
|
|
||||||
function clippaste() { termux-clipboard-get; }
|
|
||||||
elif [ -n "${TMUX:-}" ] && (( ${+commands[tmux]} )); then
|
|
||||||
function clipcopy() { tmux load-buffer -w "${1:--}"; }
|
|
||||||
function clippaste() { tmux save-buffer -; }
|
|
||||||
else
|
|
||||||
function _retry_clipboard_detection_or_fail() {
|
|
||||||
local clipcmd="${1}"; shift
|
|
||||||
if detect-clipboard; then
|
|
||||||
"${clipcmd}" "$@"
|
|
||||||
else
|
|
||||||
print "${clipcmd}: Platform $OSTYPE not supported or xclip/xsel not installed" >&2
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
function clipcopy() { _retry_clipboard_detection_or_fail clipcopy "$@"; }
|
|
||||||
function clippaste() { _retry_clipboard_detection_or_fail clippaste "$@"; }
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
function clipcopy clippaste {
|
|
||||||
unfunction clipcopy clippaste
|
|
||||||
detect-clipboard || true # let one retry
|
|
||||||
"$0" "$@"
|
|
||||||
}
|
|
||||||
@@ -1,44 +0,0 @@
|
|||||||
# Handle completions insecurities (i.e., completion-dependent directories with
|
|
||||||
# insecure ownership or permissions) by:
|
|
||||||
#
|
|
||||||
# * Human-readably notifying the user of these insecurities.
|
|
||||||
function handle_completion_insecurities() {
|
|
||||||
# List of the absolute paths of all unique insecure directories, split on
|
|
||||||
# newline from compaudit()'s output resembling:
|
|
||||||
#
|
|
||||||
# There are insecure directories:
|
|
||||||
# /usr/share/zsh/site-functions
|
|
||||||
# /usr/share/zsh/5.0.6/functions
|
|
||||||
# /usr/share/zsh
|
|
||||||
# /usr/share/zsh/5.0.6
|
|
||||||
#
|
|
||||||
# Since the ignorable first line is printed to stderr and thus not captured,
|
|
||||||
# stderr is squelched to prevent this output from leaking to the user.
|
|
||||||
local -aU insecure_dirs
|
|
||||||
insecure_dirs=( ${(f@):-"$(compaudit 2>/dev/null)"} )
|
|
||||||
|
|
||||||
# If no such directories exist, get us out of here.
|
|
||||||
[[ -z "${insecure_dirs}" ]] && return
|
|
||||||
|
|
||||||
# List ownership and permissions of all insecure directories.
|
|
||||||
print "[oh-my-zsh] Insecure completion-dependent directories detected:"
|
|
||||||
ls -ld "${(@)insecure_dirs}"
|
|
||||||
|
|
||||||
cat <<EOD
|
|
||||||
|
|
||||||
[oh-my-zsh] For safety, we will not load completions from these directories until
|
|
||||||
[oh-my-zsh] you fix their permissions and ownership and restart zsh.
|
|
||||||
[oh-my-zsh] See the above list for directories with group or other writability.
|
|
||||||
|
|
||||||
[oh-my-zsh] To fix your permissions you can do so by disabling
|
|
||||||
[oh-my-zsh] the write permission of "group" and "others" and making sure that the
|
|
||||||
[oh-my-zsh] owner of these directories is either root or your current user.
|
|
||||||
[oh-my-zsh] The following command may help:
|
|
||||||
[oh-my-zsh] compaudit | xargs chmod g-w,o-w
|
|
||||||
|
|
||||||
[oh-my-zsh] If the above didn't help or you want to skip the verification of
|
|
||||||
[oh-my-zsh] insecure directories you can set the variable ZSH_DISABLE_COMPFIX to
|
|
||||||
[oh-my-zsh] "true" before oh-my-zsh is sourced in your zshrc file.
|
|
||||||
|
|
||||||
EOD
|
|
||||||
}
|
|
||||||
@@ -1,78 +0,0 @@
|
|||||||
# fixme - the load process here seems a bit bizarre
|
|
||||||
zmodload -i zsh/complist
|
|
||||||
|
|
||||||
WORDCHARS=''
|
|
||||||
|
|
||||||
unsetopt menu_complete # do not autoselect the first completion entry
|
|
||||||
unsetopt flowcontrol
|
|
||||||
setopt auto_menu # show completion menu on successive tab press
|
|
||||||
setopt complete_in_word
|
|
||||||
setopt always_to_end
|
|
||||||
|
|
||||||
# should this be in keybindings?
|
|
||||||
bindkey -M menuselect '^o' accept-and-infer-next-history
|
|
||||||
zstyle ':completion:*:*:*:*:*' menu select
|
|
||||||
|
|
||||||
# case insensitive (all), partial-word and substring completion
|
|
||||||
if [[ "$CASE_SENSITIVE" = true ]]; then
|
|
||||||
zstyle ':completion:*' matcher-list 'r:|=*' 'l:|=* r:|=*'
|
|
||||||
else
|
|
||||||
if [[ "$HYPHEN_INSENSITIVE" = true ]]; then
|
|
||||||
zstyle ':completion:*' matcher-list 'm:{[:lower:][:upper:]-_}={[:upper:][:lower:]_-}' 'r:|=*' 'l:|=* r:|=*'
|
|
||||||
else
|
|
||||||
zstyle ':completion:*' matcher-list 'm:{[:lower:][:upper:]}={[:upper:][:lower:]}' 'r:|=*' 'l:|=* r:|=*'
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
unset CASE_SENSITIVE HYPHEN_INSENSITIVE
|
|
||||||
|
|
||||||
# Complete . and .. special directories
|
|
||||||
zstyle ':completion:*' special-dirs true
|
|
||||||
|
|
||||||
zstyle ':completion:*' list-colors ''
|
|
||||||
zstyle ':completion:*:*:kill:*:processes' list-colors '=(#b) #([0-9]#) ([0-9a-z-]#)*=01;34=0=01'
|
|
||||||
|
|
||||||
if [[ "$OSTYPE" = solaris* ]]; then
|
|
||||||
zstyle ':completion:*:*:*:*:processes' command "ps -u $USERNAME -o pid,user,comm"
|
|
||||||
else
|
|
||||||
zstyle ':completion:*:*:*:*:processes' command "ps -u $USERNAME -o pid,user,comm -w -w"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# disable named-directories autocompletion
|
|
||||||
zstyle ':completion:*:cd:*' tag-order local-directories directory-stack path-directories
|
|
||||||
|
|
||||||
# Use caching so that commands like apt and dpkg complete are usable
|
|
||||||
zstyle ':completion:*' use-cache yes
|
|
||||||
zstyle ':completion:*' cache-path $ZSH_CACHE_DIR
|
|
||||||
|
|
||||||
# Don't complete uninteresting users
|
|
||||||
zstyle ':completion:*:*:*:users' ignored-patterns \
|
|
||||||
adm amanda apache at avahi avahi-autoipd beaglidx bin cacti canna \
|
|
||||||
clamav daemon dbus distcache dnsmasq dovecot fax ftp games gdm \
|
|
||||||
gkrellmd gopher hacluster haldaemon halt hsqldb ident junkbust kdm \
|
|
||||||
ldap lp mail mailman mailnull man messagebus mldonkey mysql nagios \
|
|
||||||
named netdump news nfsnobody nobody nscd ntp nut nx obsrun openvpn \
|
|
||||||
operator pcap polkitd postfix postgres privoxy pulse pvm quagga radvd \
|
|
||||||
rpc rpcuser rpm rtkit scard shutdown squid sshd statd svn sync tftp \
|
|
||||||
usbmux uucp vcsa wwwrun xfs '_*'
|
|
||||||
|
|
||||||
# ... unless we really want to.
|
|
||||||
zstyle '*' single-ignored show
|
|
||||||
|
|
||||||
if [[ ${COMPLETION_WAITING_DOTS:-false} != false ]]; then
|
|
||||||
expand-or-complete-with-dots() {
|
|
||||||
# use $COMPLETION_WAITING_DOTS either as toggle or as the sequence to show
|
|
||||||
[[ $COMPLETION_WAITING_DOTS = true ]] && COMPLETION_WAITING_DOTS="%F{red}…%f"
|
|
||||||
# turn off line wrapping and print prompt-expanded "dot" sequence
|
|
||||||
printf '\e[?7l%s\e[?7h' "${(%)COMPLETION_WAITING_DOTS}"
|
|
||||||
zle expand-or-complete
|
|
||||||
zle redisplay
|
|
||||||
}
|
|
||||||
zle -N 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
|
|
||||||
|
|
||||||
# automatically load bash completion functions
|
|
||||||
autoload -U +X bashcompinit && bashcompinit
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
if [[ "$ENABLE_CORRECTION" == "true" ]]; then
|
|
||||||
alias cp='nocorrect cp'
|
|
||||||
alias man='nocorrect man'
|
|
||||||
alias mkdir='nocorrect mkdir'
|
|
||||||
alias mv='nocorrect mv'
|
|
||||||
alias sudo='nocorrect sudo'
|
|
||||||
alias su='nocorrect su'
|
|
||||||
|
|
||||||
setopt correct_all
|
|
||||||
fi
|
|
||||||
@@ -1,353 +0,0 @@
|
|||||||
# diagnostics.zsh
|
|
||||||
#
|
|
||||||
# Diagnostic and debugging support for oh-my-zsh
|
|
||||||
|
|
||||||
# omz_diagnostic_dump()
|
|
||||||
#
|
|
||||||
# Author: Andrew Janke <andrew@apjanke.net>
|
|
||||||
#
|
|
||||||
# Usage:
|
|
||||||
#
|
|
||||||
# omz_diagnostic_dump [-v] [-V] [file]
|
|
||||||
#
|
|
||||||
# NOTE: This is a work in progress. Its interface and behavior are going to change,
|
|
||||||
# and probably in non-back-compatible ways.
|
|
||||||
#
|
|
||||||
# Outputs a bunch of information about the state and configuration of
|
|
||||||
# oh-my-zsh, zsh, and the user's system. This is intended to provide a
|
|
||||||
# bunch of context for diagnosing your own or a third party's problems, and to
|
|
||||||
# be suitable for posting to public bug reports.
|
|
||||||
#
|
|
||||||
# The output is human-readable and its format may change over time. It is not
|
|
||||||
# suitable for parsing. All the output is in one single file so it can be posted
|
|
||||||
# as a gist or bug comment on GitHub. GitHub doesn't support attaching tarballs
|
|
||||||
# or other files to bugs; otherwise, this would probably have an option to produce
|
|
||||||
# tarballs that contain copies of the config and customization files instead of
|
|
||||||
# catting them all in to one file.
|
|
||||||
#
|
|
||||||
# This is intended to be widely portable, and run anywhere that oh-my-zsh does.
|
|
||||||
# Feel free to report any portability issues as bugs.
|
|
||||||
#
|
|
||||||
# This is written in a defensive style so it still works (and can detect) cases when
|
|
||||||
# basic functionality like echo and which have been redefined. In particular, almost
|
|
||||||
# everything is invoked with "builtin" or "command", to work in the face of user
|
|
||||||
# redefinitions.
|
|
||||||
#
|
|
||||||
# OPTIONS
|
|
||||||
#
|
|
||||||
# [file] Specifies the output file. If not given, a file in the current directory
|
|
||||||
# is selected automatically.
|
|
||||||
#
|
|
||||||
# -v Increase the verbosity of the dump output. May be specified multiple times.
|
|
||||||
# Verbosity levels:
|
|
||||||
# 0 - Basic info, shell state, omz configuration, git state
|
|
||||||
# 1 - (default) Adds key binding info and configuration file contents
|
|
||||||
# 2 - Adds zcompdump file contents
|
|
||||||
#
|
|
||||||
# -V Reduce the verbosity of the dump output. May be specified multiple times.
|
|
||||||
#
|
|
||||||
# TODO:
|
|
||||||
# * Multi-file capture
|
|
||||||
# * Add automatic gist uploading
|
|
||||||
# * Consider whether to move default output file location to TMPDIR. More robust
|
|
||||||
# but less user friendly.
|
|
||||||
#
|
|
||||||
|
|
||||||
autoload -Uz is-at-least
|
|
||||||
|
|
||||||
function omz_diagnostic_dump() {
|
|
||||||
emulate -L zsh
|
|
||||||
|
|
||||||
builtin echo "Generating diagnostic dump; please be patient..."
|
|
||||||
|
|
||||||
local thisfcn=omz_diagnostic_dump
|
|
||||||
local -A opts
|
|
||||||
local opt_verbose opt_noverbose opt_outfile
|
|
||||||
local timestamp=$(date +%Y%m%d-%H%M%S)
|
|
||||||
local outfile=omz_diagdump_$timestamp.txt
|
|
||||||
builtin zparseopts -A opts -D -- "v+=opt_verbose" "V+=opt_noverbose"
|
|
||||||
local verbose n_verbose=${#opt_verbose} n_noverbose=${#opt_noverbose}
|
|
||||||
(( verbose = 1 + n_verbose - n_noverbose ))
|
|
||||||
|
|
||||||
if [[ ${#*} > 0 ]]; then
|
|
||||||
opt_outfile=$1
|
|
||||||
fi
|
|
||||||
if [[ ${#*} > 1 ]]; then
|
|
||||||
builtin echo "$thisfcn: error: too many arguments" >&2
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
if [[ -n "$opt_outfile" ]]; then
|
|
||||||
outfile="$opt_outfile"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Always write directly to a file so terminal escape sequences are
|
|
||||||
# captured cleanly
|
|
||||||
_omz_diag_dump_one_big_text &> "$outfile"
|
|
||||||
if [[ $? != 0 ]]; then
|
|
||||||
builtin echo "$thisfcn: error while creating diagnostic dump; see $outfile for details"
|
|
||||||
fi
|
|
||||||
|
|
||||||
builtin echo
|
|
||||||
builtin echo Diagnostic dump file created at: "$outfile"
|
|
||||||
builtin echo
|
|
||||||
builtin echo To share this with OMZ developers, post it as a gist on GitHub
|
|
||||||
builtin echo at "https://gist.github.com" and share the link to the gist.
|
|
||||||
builtin echo
|
|
||||||
builtin echo "WARNING: This dump file contains all your zsh and omz configuration files,"
|
|
||||||
builtin echo "so don't share it publicly if there's sensitive information in them."
|
|
||||||
builtin echo
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
function _omz_diag_dump_one_big_text() {
|
|
||||||
local program programs progfile md5
|
|
||||||
|
|
||||||
builtin echo oh-my-zsh diagnostic dump
|
|
||||||
builtin echo
|
|
||||||
builtin echo $outfile
|
|
||||||
builtin echo
|
|
||||||
|
|
||||||
# Basic system and zsh information
|
|
||||||
command date
|
|
||||||
command uname -a
|
|
||||||
builtin echo OSTYPE=$OSTYPE
|
|
||||||
builtin echo ZSH_VERSION=$ZSH_VERSION
|
|
||||||
builtin echo User: $USERNAME
|
|
||||||
builtin echo umask: $(umask)
|
|
||||||
builtin echo
|
|
||||||
_omz_diag_dump_os_specific_version
|
|
||||||
builtin echo
|
|
||||||
|
|
||||||
# Installed programs
|
|
||||||
programs=(sh zsh ksh bash sed cat grep ls find git posh)
|
|
||||||
local progfile="" extra_str="" sha_str=""
|
|
||||||
for program in $programs; do
|
|
||||||
extra_str="" sha_str=""
|
|
||||||
progfile=$(builtin which $program)
|
|
||||||
if [[ $? == 0 ]]; then
|
|
||||||
if [[ -e $progfile ]]; then
|
|
||||||
if builtin whence shasum &>/dev/null; then
|
|
||||||
sha_str=($(command shasum $progfile))
|
|
||||||
sha_str=$sha_str[1]
|
|
||||||
extra_str+=" SHA $sha_str"
|
|
||||||
fi
|
|
||||||
if [[ -h "$progfile" ]]; then
|
|
||||||
extra_str+=" ( -> ${progfile:A} )"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
builtin printf '%-9s %-20s %s\n' "$program is" "$progfile" "$extra_str"
|
|
||||||
else
|
|
||||||
builtin echo "$program: not found"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
builtin echo
|
|
||||||
builtin echo Command Versions:
|
|
||||||
builtin echo "zsh: $(zsh --version)"
|
|
||||||
builtin echo "this zsh session: $ZSH_VERSION"
|
|
||||||
builtin echo "bash: $(bash --version | command grep bash)"
|
|
||||||
builtin echo "git: $(git --version)"
|
|
||||||
builtin echo "grep: $(grep --version)"
|
|
||||||
builtin echo
|
|
||||||
|
|
||||||
# Core command definitions
|
|
||||||
_omz_diag_dump_check_core_commands || return 1
|
|
||||||
builtin echo
|
|
||||||
|
|
||||||
# ZSH Process state
|
|
||||||
builtin echo Process state:
|
|
||||||
builtin echo pwd: $PWD
|
|
||||||
if builtin whence pstree &>/dev/null; then
|
|
||||||
builtin echo Process tree for this shell:
|
|
||||||
pstree -p $$
|
|
||||||
else
|
|
||||||
ps -fT
|
|
||||||
fi
|
|
||||||
builtin set | command grep -a '^\(ZSH\|plugins\|TERM\|LC_\|LANG\|precmd\|chpwd\|preexec\|FPATH\|TTY\|DISPLAY\|PATH\)\|OMZ'
|
|
||||||
builtin echo
|
|
||||||
#TODO: Should this include `env` instead of or in addition to `export`?
|
|
||||||
builtin echo Exported:
|
|
||||||
builtin echo $(builtin export | command sed 's/=.*//')
|
|
||||||
builtin echo
|
|
||||||
builtin echo Locale:
|
|
||||||
command locale
|
|
||||||
builtin echo
|
|
||||||
|
|
||||||
# Zsh installation and configuration
|
|
||||||
builtin echo Zsh configuration:
|
|
||||||
builtin echo setopt: $(builtin setopt)
|
|
||||||
builtin echo
|
|
||||||
builtin echo zstyle:
|
|
||||||
builtin zstyle
|
|
||||||
builtin echo
|
|
||||||
builtin echo 'compaudit output:'
|
|
||||||
compaudit
|
|
||||||
builtin echo
|
|
||||||
builtin echo '$fpath directories:'
|
|
||||||
command ls -lad $fpath
|
|
||||||
builtin echo
|
|
||||||
|
|
||||||
# Oh-my-zsh installation
|
|
||||||
builtin echo oh-my-zsh installation:
|
|
||||||
command ls -ld ~/.z*
|
|
||||||
command ls -ld ~/.oh*
|
|
||||||
builtin echo
|
|
||||||
builtin echo oh-my-zsh git state:
|
|
||||||
(builtin cd $ZSH && builtin echo "HEAD: $(git rev-parse HEAD)" && git remote -v && git status | command grep "[^[:space:]]")
|
|
||||||
if [[ $verbose -ge 1 ]]; then
|
|
||||||
(builtin cd $ZSH && git reflog --date=default | command grep pull)
|
|
||||||
fi
|
|
||||||
builtin echo
|
|
||||||
if [[ -e $ZSH_CUSTOM ]]; then
|
|
||||||
local custom_dir=$ZSH_CUSTOM
|
|
||||||
if [[ -h $custom_dir ]]; then
|
|
||||||
custom_dir=$(builtin cd $custom_dir && pwd -P)
|
|
||||||
fi
|
|
||||||
builtin echo "oh-my-zsh custom dir:"
|
|
||||||
builtin echo " $ZSH_CUSTOM ($custom_dir)"
|
|
||||||
(builtin cd ${custom_dir:h} && command find ${custom_dir:t} -name .git -prune -o -print)
|
|
||||||
builtin echo
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Key binding and terminal info
|
|
||||||
if [[ $verbose -ge 1 ]]; then
|
|
||||||
builtin echo "bindkey:"
|
|
||||||
builtin bindkey
|
|
||||||
builtin echo
|
|
||||||
builtin echo "infocmp:"
|
|
||||||
command infocmp -L
|
|
||||||
builtin echo
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Configuration file info
|
|
||||||
local zdotdir=${ZDOTDIR:-$HOME}
|
|
||||||
builtin echo "Zsh configuration files:"
|
|
||||||
local cfgfile cfgfiles
|
|
||||||
# Some files for bash that zsh does not use are intentionally included
|
|
||||||
# to help with diagnosing behavior differences between bash and zsh
|
|
||||||
cfgfiles=( /etc/zshenv /etc/zprofile /etc/zshrc /etc/zlogin /etc/zlogout
|
|
||||||
$zdotdir/.zshenv $zdotdir/.zprofile $zdotdir/.zshrc $zdotdir/.zlogin $zdotdir/.zlogout
|
|
||||||
~/.zsh.pre-oh-my-zsh
|
|
||||||
/etc/bashrc /etc/profile ~/.bashrc ~/.profile ~/.bash_profile ~/.bash_logout )
|
|
||||||
command ls -lad $cfgfiles 2>&1
|
|
||||||
builtin echo
|
|
||||||
if [[ $verbose -ge 1 ]]; then
|
|
||||||
for cfgfile in $cfgfiles; do
|
|
||||||
_omz_diag_dump_echo_file_w_header $cfgfile
|
|
||||||
done
|
|
||||||
fi
|
|
||||||
builtin echo
|
|
||||||
builtin echo "Zsh compdump files:"
|
|
||||||
local dumpfile dumpfiles
|
|
||||||
command ls -lad $zdotdir/.zcompdump*
|
|
||||||
dumpfiles=( $zdotdir/.zcompdump*(N) )
|
|
||||||
if [[ $verbose -ge 2 ]]; then
|
|
||||||
for dumpfile in $dumpfiles; do
|
|
||||||
_omz_diag_dump_echo_file_w_header $dumpfile
|
|
||||||
done
|
|
||||||
fi
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
function _omz_diag_dump_check_core_commands() {
|
|
||||||
builtin echo "Core command check:"
|
|
||||||
local redefined name builtins externals reserved_words
|
|
||||||
redefined=()
|
|
||||||
# All the zsh non-module builtin commands
|
|
||||||
# These are taken from the zsh reference manual for 5.0.2
|
|
||||||
# Commands from modules should not be included.
|
|
||||||
# (For back-compatibility, if any of these are newish, they should be removed,
|
|
||||||
# or at least made conditional on the version of the current running zsh.)
|
|
||||||
# "history" is also excluded because OMZ is known to redefine that
|
|
||||||
reserved_words=( do done esac then elif else fi for case if while function
|
|
||||||
repeat time until select coproc nocorrect foreach end '!' '[[' '{' '}'
|
|
||||||
)
|
|
||||||
builtins=( alias autoload bg bindkey break builtin bye cd chdir command
|
|
||||||
comparguments compcall compctl compdescribe compfiles compgroups compquote comptags
|
|
||||||
comptry compvalues continue dirs disable disown echo echotc echoti emulate
|
|
||||||
enable eval exec exit false fc fg functions getln getopts hash
|
|
||||||
jobs kill let limit log logout noglob popd print printf
|
|
||||||
pushd pushln pwd r read rehash return sched set setopt shift
|
|
||||||
source suspend test times trap true ttyctl type ulimit umask unalias
|
|
||||||
unfunction unhash unlimit unset unsetopt vared wait whence where which zcompile
|
|
||||||
zle zmodload zparseopts zregexparse zstyle )
|
|
||||||
if is-at-least 5.1; then
|
|
||||||
reserved_word+=( declare export integer float local readonly typeset )
|
|
||||||
else
|
|
||||||
builtins+=( declare export integer float local readonly typeset )
|
|
||||||
fi
|
|
||||||
builtins_fatal=( builtin command local )
|
|
||||||
externals=( zsh )
|
|
||||||
for name in $reserved_words; do
|
|
||||||
if [[ $(builtin whence -w $name) != "$name: reserved" ]]; then
|
|
||||||
builtin echo "reserved word '$name' has been redefined"
|
|
||||||
builtin which $name
|
|
||||||
redefined+=$name
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
for name in $builtins; do
|
|
||||||
if [[ $(builtin whence -w $name) != "$name: builtin" ]]; then
|
|
||||||
builtin echo "builtin '$name' has been redefined"
|
|
||||||
builtin which $name
|
|
||||||
redefined+=$name
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
for name in $externals; do
|
|
||||||
if [[ $(builtin whence -w $name) != "$name: command" ]]; then
|
|
||||||
builtin echo "command '$name' has been redefined"
|
|
||||||
builtin which $name
|
|
||||||
redefined+=$name
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
if [[ -n "$redefined" ]]; then
|
|
||||||
builtin echo "SOME CORE COMMANDS HAVE BEEN REDEFINED: $redefined"
|
|
||||||
else
|
|
||||||
builtin echo "All core commands are defined normally"
|
|
||||||
fi
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
function _omz_diag_dump_echo_file_w_header() {
|
|
||||||
local file=$1
|
|
||||||
if [[ ( -f $file || -h $file ) ]]; then
|
|
||||||
builtin echo "========== $file =========="
|
|
||||||
if [[ -h $file ]]; then
|
|
||||||
builtin echo "========== ( => ${file:A} ) =========="
|
|
||||||
fi
|
|
||||||
command cat $file
|
|
||||||
builtin echo "========== end $file =========="
|
|
||||||
builtin echo
|
|
||||||
elif [[ -d $file ]]; then
|
|
||||||
builtin echo "File '$file' is a directory"
|
|
||||||
elif [[ ! -e $file ]]; then
|
|
||||||
builtin echo "File '$file' does not exist"
|
|
||||||
else
|
|
||||||
command ls -lad "$file"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
function _omz_diag_dump_os_specific_version() {
|
|
||||||
local osname osver version_file version_files
|
|
||||||
case "$OSTYPE" in
|
|
||||||
darwin*)
|
|
||||||
osname=$(command sw_vers -productName)
|
|
||||||
osver=$(command sw_vers -productVersion)
|
|
||||||
builtin echo "OS Version: $osname $osver build $(sw_vers -buildVersion)"
|
|
||||||
;;
|
|
||||||
cygwin)
|
|
||||||
command systeminfo | command head -n 4 | command tail -n 2
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
if builtin which lsb_release >/dev/null; then
|
|
||||||
builtin echo "OS Release: $(command lsb_release -s -d)"
|
|
||||||
fi
|
|
||||||
|
|
||||||
version_files=( /etc/*-release(N) /etc/*-version(N) /etc/*_version(N) )
|
|
||||||
for version_file in $version_files; do
|
|
||||||
builtin echo "$version_file:"
|
|
||||||
command cat "$version_file"
|
|
||||||
builtin echo
|
|
||||||
done
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -1,40 +0,0 @@
|
|||||||
# Changing/making/removing directory
|
|
||||||
setopt auto_cd
|
|
||||||
setopt auto_pushd
|
|
||||||
setopt pushd_ignore_dups
|
|
||||||
setopt pushdminus
|
|
||||||
|
|
||||||
|
|
||||||
alias -g ...='../..'
|
|
||||||
alias -g ....='../../..'
|
|
||||||
alias -g .....='../../../..'
|
|
||||||
alias -g ......='../../../../..'
|
|
||||||
|
|
||||||
alias -- -='cd -'
|
|
||||||
alias 1='cd -1'
|
|
||||||
alias 2='cd -2'
|
|
||||||
alias 3='cd -3'
|
|
||||||
alias 4='cd -4'
|
|
||||||
alias 5='cd -5'
|
|
||||||
alias 6='cd -6'
|
|
||||||
alias 7='cd -7'
|
|
||||||
alias 8='cd -8'
|
|
||||||
alias 9='cd -9'
|
|
||||||
|
|
||||||
alias md='mkdir -p'
|
|
||||||
alias rd=rmdir
|
|
||||||
|
|
||||||
function d () {
|
|
||||||
if [[ -n $1 ]]; then
|
|
||||||
dirs "$@"
|
|
||||||
else
|
|
||||||
dirs -v | head -n 10
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
compdef _dirs d
|
|
||||||
|
|
||||||
# List directory contents
|
|
||||||
alias lsa='ls -lah'
|
|
||||||
alias l='ls -lah'
|
|
||||||
alias ll='ls -lh'
|
|
||||||
alias la='ls -lAh'
|
|
||||||
@@ -1,284 +0,0 @@
|
|||||||
function zsh_stats() {
|
|
||||||
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 -n 20 | column -c3 -s " " -t | nl
|
|
||||||
}
|
|
||||||
|
|
||||||
function uninstall_oh_my_zsh() {
|
|
||||||
command env ZSH="$ZSH" sh "$ZSH/tools/uninstall.sh"
|
|
||||||
}
|
|
||||||
|
|
||||||
function upgrade_oh_my_zsh() {
|
|
||||||
echo >&2 "${fg[yellow]}Note: \`$0\` is deprecated. Use \`omz update\` instead.$reset_color"
|
|
||||||
omz update
|
|
||||||
}
|
|
||||||
|
|
||||||
function open_command() {
|
|
||||||
local open_cmd
|
|
||||||
|
|
||||||
# define the open command
|
|
||||||
case "$OSTYPE" in
|
|
||||||
darwin*) open_cmd='open' ;;
|
|
||||||
cygwin*) open_cmd='cygstart' ;;
|
|
||||||
linux*) [[ "$(uname -r)" != *icrosoft* ]] && open_cmd='nohup xdg-open' || {
|
|
||||||
open_cmd='cmd.exe /c start ""'
|
|
||||||
[[ -e "$1" ]] && { 1="$(wslpath -w "${1:a}")" || return 1 }
|
|
||||||
[[ "$1" = (http|https)://* ]] && {
|
|
||||||
1="$(echo "$1" | sed -E 's/([&|()<>^])/^\1/g')" || return 1
|
|
||||||
}
|
|
||||||
} ;;
|
|
||||||
msys*) open_cmd='start ""' ;;
|
|
||||||
*) echo "Platform $OSTYPE not supported"
|
|
||||||
return 1
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
# If a URL is passed, $BROWSER might be set to a local browser within SSH.
|
|
||||||
# See https://github.com/ohmyzsh/ohmyzsh/issues/11098
|
|
||||||
if [[ -n "$BROWSER" && "$1" = (http|https)://* ]]; then
|
|
||||||
"$BROWSER" "$@"
|
|
||||||
return
|
|
||||||
fi
|
|
||||||
|
|
||||||
${=open_cmd} "$@" &>/dev/null
|
|
||||||
}
|
|
||||||
|
|
||||||
# take functions
|
|
||||||
|
|
||||||
# mkcd is equivalent to takedir
|
|
||||||
function mkcd takedir() {
|
|
||||||
mkdir -p $@ && cd ${@:$#}
|
|
||||||
}
|
|
||||||
|
|
||||||
function takeurl() {
|
|
||||||
local data thedir
|
|
||||||
data="$(mktemp)"
|
|
||||||
curl -L "$1" > "$data"
|
|
||||||
tar xf "$data"
|
|
||||||
thedir="$(tar tf "$data" | head -n 1)"
|
|
||||||
rm "$data"
|
|
||||||
cd "$thedir"
|
|
||||||
}
|
|
||||||
|
|
||||||
function takezip() {
|
|
||||||
local data thedir
|
|
||||||
data="$(mktemp)"
|
|
||||||
curl -L "$1" > "$data"
|
|
||||||
unzip "$data" -d "./"
|
|
||||||
thedir="$(unzip -l "$data" | awk 'NR==4 {print $4}' | sed 's/\/.*//')"
|
|
||||||
rm "$data"
|
|
||||||
cd "$thedir"
|
|
||||||
}
|
|
||||||
|
|
||||||
function takegit() {
|
|
||||||
git clone "$1"
|
|
||||||
cd "$(basename ${1%%.git})"
|
|
||||||
}
|
|
||||||
|
|
||||||
function take() {
|
|
||||||
if [[ $1 =~ ^(https?|ftp).*\.(tar\.(gz|bz2|xz)|tgz)$ ]]; then
|
|
||||||
takeurl "$1"
|
|
||||||
elif [[ $1 =~ ^(https?|ftp).*\.(zip)$ ]]; then
|
|
||||||
takezip "$1"
|
|
||||||
elif [[ $1 =~ ^([A-Za-z0-9]\+@|https?|git|ssh|ftps?|rsync).*\.git/?$ ]]; then
|
|
||||||
takegit "$1"
|
|
||||||
else
|
|
||||||
takedir "$@"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
#
|
|
||||||
# Get the value of an alias.
|
|
||||||
#
|
|
||||||
# Arguments:
|
|
||||||
# 1. alias - The alias to get its value from
|
|
||||||
# STDOUT:
|
|
||||||
# The value of alias $1 (if it has one).
|
|
||||||
# Return value:
|
|
||||||
# 0 if the alias was found,
|
|
||||||
# 1 if it does not exist
|
|
||||||
#
|
|
||||||
function alias_value() {
|
|
||||||
(( $+aliases[$1] )) && echo $aliases[$1]
|
|
||||||
}
|
|
||||||
|
|
||||||
#
|
|
||||||
# Try to get the value of an alias,
|
|
||||||
# otherwise return the input.
|
|
||||||
#
|
|
||||||
# Arguments:
|
|
||||||
# 1. alias - The alias to get its value from
|
|
||||||
# STDOUT:
|
|
||||||
# The value of alias $1, or $1 if there is no alias $1.
|
|
||||||
# Return value:
|
|
||||||
# Always 0
|
|
||||||
#
|
|
||||||
function try_alias_value() {
|
|
||||||
alias_value "$1" || echo "$1"
|
|
||||||
}
|
|
||||||
|
|
||||||
#
|
|
||||||
# Set variable "$1" to default value "$2" if "$1" is not yet defined.
|
|
||||||
#
|
|
||||||
# Arguments:
|
|
||||||
# 1. name - The variable to set
|
|
||||||
# 2. val - The default value
|
|
||||||
# Return value:
|
|
||||||
# 0 if the variable exists, 3 if it was set
|
|
||||||
#
|
|
||||||
function default() {
|
|
||||||
(( $+parameters[$1] )) && return 0
|
|
||||||
typeset -g "$1"="$2" && return 3
|
|
||||||
}
|
|
||||||
|
|
||||||
#
|
|
||||||
# Set environment variable "$1" to default value "$2" if "$1" is not yet defined.
|
|
||||||
#
|
|
||||||
# Arguments:
|
|
||||||
# 1. name - The env variable to set
|
|
||||||
# 2. val - The default value
|
|
||||||
# Return value:
|
|
||||||
# 0 if the env variable exists, 3 if it was set
|
|
||||||
#
|
|
||||||
function env_default() {
|
|
||||||
[[ ${parameters[$1]} = *-export* ]] && return 0
|
|
||||||
export "$1=$2" && return 3
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
# Required for $langinfo
|
|
||||||
zmodload zsh/langinfo
|
|
||||||
|
|
||||||
# URL-encode a string
|
|
||||||
#
|
|
||||||
# Encodes a string using RFC 2396 URL-encoding (%-escaped).
|
|
||||||
# See: https://www.ietf.org/rfc/rfc2396.txt
|
|
||||||
#
|
|
||||||
# By default, reserved characters and unreserved "mark" characters are
|
|
||||||
# not escaped by this function. This allows the common usage of passing
|
|
||||||
# an entire URL in, and encoding just special characters in it, with
|
|
||||||
# the expectation that reserved and mark characters are used appropriately.
|
|
||||||
# The -r and -m options turn on escaping of the reserved and mark characters,
|
|
||||||
# respectively, which allows arbitrary strings to be fully escaped for
|
|
||||||
# embedding inside URLs, where reserved characters might be misinterpreted.
|
|
||||||
#
|
|
||||||
# Prints the encoded string on stdout.
|
|
||||||
# Returns nonzero if encoding failed.
|
|
||||||
#
|
|
||||||
# Usage:
|
|
||||||
# omz_urlencode [-r] [-m] [-P] <string> [<string> ...]
|
|
||||||
#
|
|
||||||
# -r causes reserved characters (;/?:@&=+$,) to be escaped
|
|
||||||
#
|
|
||||||
# -m causes "mark" characters (_.!~*''()-) to be escaped
|
|
||||||
#
|
|
||||||
# -P causes spaces to be encoded as '%20' instead of '+'
|
|
||||||
function omz_urlencode() {
|
|
||||||
emulate -L zsh
|
|
||||||
setopt norematchpcre
|
|
||||||
|
|
||||||
local -a opts
|
|
||||||
zparseopts -D -E -a opts r m P
|
|
||||||
|
|
||||||
local in_str="$@"
|
|
||||||
local url_str=""
|
|
||||||
local spaces_as_plus
|
|
||||||
if [[ -z $opts[(r)-P] ]]; then spaces_as_plus=1; fi
|
|
||||||
local str="$in_str"
|
|
||||||
|
|
||||||
# URLs must use UTF-8 encoding; convert str to UTF-8 if required
|
|
||||||
local encoding=$langinfo[CODESET]
|
|
||||||
local safe_encodings
|
|
||||||
safe_encodings=(UTF-8 utf8 US-ASCII)
|
|
||||||
if [[ -z ${safe_encodings[(r)$encoding]} ]]; then
|
|
||||||
str=$(echo -E "$str" | iconv -f $encoding -t UTF-8)
|
|
||||||
if [[ $? != 0 ]]; then
|
|
||||||
echo "Error converting string from $encoding to UTF-8" >&2
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Use LC_CTYPE=C to process text byte-by-byte
|
|
||||||
# Note that this doesn't work in Termux, as it only has UTF-8 locale.
|
|
||||||
# Characters will be processed as UTF-8, which is fine for URLs.
|
|
||||||
local i byte ord LC_ALL=C
|
|
||||||
export LC_ALL
|
|
||||||
local reserved=';/?:@&=+$,'
|
|
||||||
local mark='_.!~*''()-'
|
|
||||||
local dont_escape="[A-Za-z0-9"
|
|
||||||
if [[ -z $opts[(r)-r] ]]; then
|
|
||||||
dont_escape+=$reserved
|
|
||||||
fi
|
|
||||||
# $mark must be last because of the "-"
|
|
||||||
if [[ -z $opts[(r)-m] ]]; then
|
|
||||||
dont_escape+=$mark
|
|
||||||
fi
|
|
||||||
dont_escape+="]"
|
|
||||||
|
|
||||||
# Implemented to use a single printf call and avoid subshells in the loop,
|
|
||||||
# for performance (primarily on Windows).
|
|
||||||
local url_str=""
|
|
||||||
for (( i = 1; i <= ${#str}; ++i )); do
|
|
||||||
byte="$str[i]"
|
|
||||||
if [[ "$byte" =~ "$dont_escape" ]]; then
|
|
||||||
url_str+="$byte"
|
|
||||||
else
|
|
||||||
if [[ "$byte" == " " && -n $spaces_as_plus ]]; then
|
|
||||||
url_str+="+"
|
|
||||||
elif [[ "$PREFIX" = *com.termux* ]]; then
|
|
||||||
# Termux does not have non-UTF8 locales, so just send the UTF-8 character directly
|
|
||||||
url_str+="$byte"
|
|
||||||
else
|
|
||||||
ord=$(( [##16] #byte ))
|
|
||||||
url_str+="%$ord"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
echo -E "$url_str"
|
|
||||||
}
|
|
||||||
|
|
||||||
# URL-decode a string
|
|
||||||
#
|
|
||||||
# Decodes a RFC 2396 URL-encoded (%-escaped) string.
|
|
||||||
# This decodes the '+' and '%' escapes in the input string, and leaves
|
|
||||||
# other characters unchanged. Does not enforce that the input is a
|
|
||||||
# valid URL-encoded string. This is a convenience to allow callers to
|
|
||||||
# pass in a full URL or similar strings and decode them for human
|
|
||||||
# presentation.
|
|
||||||
#
|
|
||||||
# Outputs the encoded string on stdout.
|
|
||||||
# Returns nonzero if encoding failed.
|
|
||||||
#
|
|
||||||
# Usage:
|
|
||||||
# omz_urldecode <urlstring> - prints decoded string followed by a newline
|
|
||||||
function omz_urldecode {
|
|
||||||
emulate -L zsh
|
|
||||||
local encoded_url=$1
|
|
||||||
|
|
||||||
# Work bytewise, since URLs escape UTF-8 octets
|
|
||||||
local caller_encoding=$langinfo[CODESET]
|
|
||||||
local LC_ALL=C
|
|
||||||
export LC_ALL
|
|
||||||
|
|
||||||
# Change + back to ' '
|
|
||||||
local tmp=${encoded_url:gs/+/ /}
|
|
||||||
# Protect other escapes to pass through the printf unchanged
|
|
||||||
tmp=${tmp:gs/\\/\\\\/}
|
|
||||||
# Handle %-escapes by turning them into `\xXX` printf escapes
|
|
||||||
tmp=${tmp:gs/%/\\x/}
|
|
||||||
local decoded="$(printf -- "$tmp")"
|
|
||||||
|
|
||||||
# Now we have a UTF-8 encoded string in the variable. We need to re-encode
|
|
||||||
# it if caller is in a non-UTF-8 locale.
|
|
||||||
local -a safe_encodings
|
|
||||||
safe_encodings=(UTF-8 utf8 US-ASCII)
|
|
||||||
if [[ -z ${safe_encodings[(r)$caller_encoding]} ]]; then
|
|
||||||
decoded=$(echo -E "$decoded" | iconv -f UTF-8 -t $caller_encoding)
|
|
||||||
if [[ $? != 0 ]]; then
|
|
||||||
echo "Error converting string from UTF-8 to $caller_encoding" >&2
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo -E "$decoded"
|
|
||||||
}
|
|
||||||
367
lib/git.zsh
367
lib/git.zsh
@@ -1,367 +0,0 @@
|
|||||||
autoload -Uz is-at-least
|
|
||||||
|
|
||||||
# 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 _omz_git_prompt_info() {
|
|
||||||
# If we are on a folder not tracked by git, get out.
|
|
||||||
# Otherwise, check for hide-info at global and local repository level
|
|
||||||
if ! __git_prompt_git rev-parse --git-dir &> /dev/null \
|
|
||||||
|| [[ "$(__git_prompt_git config --get oh-my-zsh.hide-info 2>/dev/null)" == 1 ]]; then
|
|
||||||
return 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Get either:
|
|
||||||
# - the current branch name
|
|
||||||
# - the tag name if we are on a tag
|
|
||||||
# - the short SHA of the current commit
|
|
||||||
local ref
|
|
||||||
ref=$(__git_prompt_git symbolic-ref --short HEAD 2> /dev/null) \
|
|
||||||
|| ref=$(__git_prompt_git describe --tags --exact-match 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:gs/%/%%}${upstream:gs/%/%%}$(parse_git_dirty)${ZSH_THEME_GIT_PROMPT_SUFFIX}"
|
|
||||||
}
|
|
||||||
|
|
||||||
function _omz_git_prompt_status() {
|
|
||||||
[[ "$(__git_prompt_git config --get oh-my-zsh.hide-status 2>/dev/null)" = 1 ]] && return
|
|
||||||
|
|
||||||
# Maps a git status prefix to an internal constant
|
|
||||||
# This cannot use the prompt constants, as they may be empty
|
|
||||||
local -A prefix_constant_map
|
|
||||||
prefix_constant_map=(
|
|
||||||
'\?\? ' 'UNTRACKED'
|
|
||||||
'A ' 'ADDED'
|
|
||||||
'M ' 'MODIFIED'
|
|
||||||
'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
|
|
||||||
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
|
|
||||||
|
|
||||||
# A lookup table of each git status encountered
|
|
||||||
local -A statuses_seen
|
|
||||||
|
|
||||||
if __git_prompt_git rev-parse --verify refs/stash &>/dev/null; then
|
|
||||||
statuses_seen[STASHED]=1
|
|
||||||
fi
|
|
||||||
|
|
||||||
local status_lines
|
|
||||||
status_lines=("${(@f)${status_text}}")
|
|
||||||
|
|
||||||
# If the tracking line exists, get and parse it
|
|
||||||
if [[ "$status_lines[1]" =~ "^## [^ ]+ \[(.*)\]" ]]; then
|
|
||||||
local branch_statuses
|
|
||||||
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
|
|
||||||
|
|
||||||
# For each status prefix, do a regex comparison
|
|
||||||
for status_prefix in "${(@k)prefix_constant_map}"; do
|
|
||||||
local status_constant="${prefix_constant_map[$status_prefix]}"
|
|
||||||
local status_regex=$'(^|\n)'"$status_prefix"
|
|
||||||
|
|
||||||
if [[ "$status_text" =~ $status_regex ]]; then
|
|
||||||
statuses_seen[$status_constant]=1
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
# Display the seen statuses in the order specified
|
|
||||||
local status_prompt
|
|
||||||
for status_constant in $status_constants; do
|
|
||||||
if (( ${+statuses_seen[$status_constant]} )); then
|
|
||||||
local next_display=$constant_prompt_map[$status_constant]
|
|
||||||
status_prompt="$next_display$status_prompt"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
echo $status_prompt
|
|
||||||
}
|
|
||||||
|
|
||||||
# Use async version if setting is enabled, or unset but zsh version is at least 5.0.6.
|
|
||||||
# This avoids async prompt issues caused by previous zsh versions:
|
|
||||||
# - https://github.com/ohmyzsh/ohmyzsh/issues/12331
|
|
||||||
# - https://github.com/ohmyzsh/ohmyzsh/issues/12360
|
|
||||||
# TODO(2024-06-12): @mcornella remove workaround when CentOS 7 reaches EOL
|
|
||||||
local _style
|
|
||||||
if zstyle -t ':omz:alpha:lib:git' async-prompt \
|
|
||||||
|| { is-at-least 5.0.6 && zstyle -T ':omz:alpha:lib:git' async-prompt }; then
|
|
||||||
function git_prompt_info() {
|
|
||||||
if [[ -n "${_OMZ_ASYNC_OUTPUT[_omz_git_prompt_info]}" ]]; then
|
|
||||||
echo -n "${_OMZ_ASYNC_OUTPUT[_omz_git_prompt_info]}"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
function git_prompt_status() {
|
|
||||||
if [[ -n "${_OMZ_ASYNC_OUTPUT[_omz_git_prompt_status]}" ]]; then
|
|
||||||
echo -n "${_OMZ_ASYNC_OUTPUT[_omz_git_prompt_status]}"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
# Conditionally register the async handler, only if it's needed in $PROMPT
|
|
||||||
# or any of the other prompt variables
|
|
||||||
function _defer_async_git_register() {
|
|
||||||
# Check if git_prompt_info is used in a prompt variable
|
|
||||||
case "${PS1}:${PS2}:${PS3}:${PS4}:${RPROMPT}:${RPS1}:${RPS2}:${RPS3}:${RPS4}" in
|
|
||||||
*(\$\(git_prompt_info\)|\`git_prompt_info\`)*)
|
|
||||||
_omz_register_handler _omz_git_prompt_info
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
case "${PS1}:${PS2}:${PS3}:${PS4}:${RPROMPT}:${RPS1}:${RPS2}:${RPS3}:${RPS4}" in
|
|
||||||
*(\$\(git_prompt_status\)|\`git_prompt_status\`)*)
|
|
||||||
_omz_register_handler _omz_git_prompt_status
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
add-zsh-hook -d precmd _defer_async_git_register
|
|
||||||
unset -f _defer_async_git_register
|
|
||||||
}
|
|
||||||
|
|
||||||
# Register the async handler first. This needs to be done before
|
|
||||||
# the async request prompt is run
|
|
||||||
precmd_functions=(_defer_async_git_register $precmd_functions)
|
|
||||||
elif zstyle -s ':omz:alpha:lib:git' async-prompt _style && [[ $_style == "force" ]]; then
|
|
||||||
function git_prompt_info() {
|
|
||||||
if [[ -n "${_OMZ_ASYNC_OUTPUT[_omz_git_prompt_info]}" ]]; then
|
|
||||||
echo -n "${_OMZ_ASYNC_OUTPUT[_omz_git_prompt_info]}"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
function git_prompt_status() {
|
|
||||||
if [[ -n "${_OMZ_ASYNC_OUTPUT[_omz_git_prompt_status]}" ]]; then
|
|
||||||
echo -n "${_OMZ_ASYNC_OUTPUT[_omz_git_prompt_status]}"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
_omz_register_handler _omz_git_prompt_info
|
|
||||||
_omz_register_handler _omz_git_prompt_status
|
|
||||||
else
|
|
||||||
function git_prompt_info() {
|
|
||||||
_omz_git_prompt_info
|
|
||||||
}
|
|
||||||
function git_prompt_status() {
|
|
||||||
_omz_git_prompt_status
|
|
||||||
}
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Checks if working tree is dirty
|
|
||||||
function parse_git_dirty() {
|
|
||||||
local STATUS
|
|
||||||
local -a FLAGS
|
|
||||||
FLAGS=('--porcelain')
|
|
||||||
if [[ "$(__git_prompt_git config --get oh-my-zsh.hide-dirty)" != "1" ]]; then
|
|
||||||
if [[ "${DISABLE_UNTRACKED_FILES_DIRTY:-}" == "true" ]]; then
|
|
||||||
FLAGS+='--untracked-files=no'
|
|
||||||
fi
|
|
||||||
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 -n 1)
|
|
||||||
fi
|
|
||||||
if [[ -n $STATUS ]]; then
|
|
||||||
echo "$ZSH_THEME_GIT_PROMPT_DIRTY"
|
|
||||||
else
|
|
||||||
echo "$ZSH_THEME_GIT_PROMPT_CLEAN"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
# Gets the difference between the local and remote branches
|
|
||||||
function git_remote_status() {
|
|
||||||
local remote ahead behind git_remote_status git_remote_status_detailed
|
|
||||||
remote=${$(__git_prompt_git rev-parse --verify ${hook_com[branch]}@{upstream} --symbolic-full-name 2>/dev/null)/refs\/remotes\/}
|
|
||||||
if [[ -n ${remote} ]]; then
|
|
||||||
ahead=$(__git_prompt_git rev-list ${hook_com[branch]}@{upstream}..HEAD 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
|
|
||||||
git_remote_status="$ZSH_THEME_GIT_PROMPT_EQUAL_REMOTE"
|
|
||||||
elif [[ $ahead -gt 0 ]] && [[ $behind -eq 0 ]]; then
|
|
||||||
git_remote_status="$ZSH_THEME_GIT_PROMPT_AHEAD_REMOTE"
|
|
||||||
git_remote_status_detailed="$ZSH_THEME_GIT_PROMPT_AHEAD_REMOTE_COLOR$ZSH_THEME_GIT_PROMPT_AHEAD_REMOTE$((ahead))%{$reset_color%}"
|
|
||||||
elif [[ $behind -gt 0 ]] && [[ $ahead -eq 0 ]]; then
|
|
||||||
git_remote_status="$ZSH_THEME_GIT_PROMPT_BEHIND_REMOTE"
|
|
||||||
git_remote_status_detailed="$ZSH_THEME_GIT_PROMPT_BEHIND_REMOTE_COLOR$ZSH_THEME_GIT_PROMPT_BEHIND_REMOTE$((behind))%{$reset_color%}"
|
|
||||||
elif [[ $ahead -gt 0 ]] && [[ $behind -gt 0 ]]; then
|
|
||||||
git_remote_status="$ZSH_THEME_GIT_PROMPT_DIVERGED_REMOTE"
|
|
||||||
git_remote_status_detailed="$ZSH_THEME_GIT_PROMPT_AHEAD_REMOTE_COLOR$ZSH_THEME_GIT_PROMPT_AHEAD_REMOTE$((ahead))%{$reset_color%}$ZSH_THEME_GIT_PROMPT_BEHIND_REMOTE_COLOR$ZSH_THEME_GIT_PROMPT_BEHIND_REMOTE$((behind))%{$reset_color%}"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ -n $ZSH_THEME_GIT_PROMPT_REMOTE_STATUS_DETAILED ]]; then
|
|
||||||
git_remote_status="$ZSH_THEME_GIT_PROMPT_REMOTE_STATUS_PREFIX${remote:gs/%/%%}$git_remote_status_detailed$ZSH_THEME_GIT_PROMPT_REMOTE_STATUS_SUFFIX"
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo $git_remote_status
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
# Outputs the name of the current branch
|
|
||||||
# Usage example: git pull origin $(git_current_branch)
|
|
||||||
# Using '--quiet' with 'symbolic-ref' will not cause a fatal error (128) if
|
|
||||||
# it's not a symbolic ref, but in a Git repo.
|
|
||||||
function git_current_branch() {
|
|
||||||
local ref
|
|
||||||
ref=$(__git_prompt_git symbolic-ref --quiet HEAD 2> /dev/null)
|
|
||||||
local ret=$?
|
|
||||||
if [[ $ret != 0 ]]; then
|
|
||||||
[[ $ret == 128 ]] && return # no git repo.
|
|
||||||
ref=$(__git_prompt_git rev-parse --short HEAD 2> /dev/null) || return
|
|
||||||
fi
|
|
||||||
echo ${ref#refs/heads/}
|
|
||||||
}
|
|
||||||
|
|
||||||
# Outputs the name of the previously checked out branch
|
|
||||||
# Usage example: git pull origin $(git_previous_branch)
|
|
||||||
# rev-parse --symbolic-full-name @{-1} only prints if it is a branch
|
|
||||||
function git_previous_branch() {
|
|
||||||
local ref
|
|
||||||
ref=$(__git_prompt_git rev-parse --quiet --symbolic-full-name @{-1} 2> /dev/null)
|
|
||||||
local ret=$?
|
|
||||||
if [[ $ret != 0 ]] || [[ -z $ref ]]; then
|
|
||||||
return # no git repo or non-branch previous ref
|
|
||||||
fi
|
|
||||||
echo ${ref#refs/heads/}
|
|
||||||
}
|
|
||||||
|
|
||||||
# Gets the number of commits ahead from remote
|
|
||||||
function git_commits_ahead() {
|
|
||||||
if __git_prompt_git rev-parse --git-dir &>/dev/null; then
|
|
||||||
local commits="$(__git_prompt_git rev-list --count @{upstream}..HEAD 2>/dev/null)"
|
|
||||||
if [[ -n "$commits" && "$commits" != 0 ]]; then
|
|
||||||
echo "$ZSH_THEME_GIT_COMMITS_AHEAD_PREFIX$commits$ZSH_THEME_GIT_COMMITS_AHEAD_SUFFIX"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
# Gets the number of commits behind remote
|
|
||||||
function git_commits_behind() {
|
|
||||||
if __git_prompt_git rev-parse --git-dir &>/dev/null; then
|
|
||||||
local commits="$(__git_prompt_git rev-list --count HEAD..@{upstream} 2>/dev/null)"
|
|
||||||
if [[ -n "$commits" && "$commits" != 0 ]]; then
|
|
||||||
echo "$ZSH_THEME_GIT_COMMITS_BEHIND_PREFIX$commits$ZSH_THEME_GIT_COMMITS_BEHIND_SUFFIX"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
# Outputs if current branch is ahead of remote
|
|
||||||
function git_prompt_ahead() {
|
|
||||||
if [[ -n "$(__git_prompt_git rev-list origin/$(git_current_branch)..HEAD 2> /dev/null)" ]]; then
|
|
||||||
echo "$ZSH_THEME_GIT_PROMPT_AHEAD"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
# Outputs if current branch is behind remote
|
|
||||||
function git_prompt_behind() {
|
|
||||||
if [[ -n "$(__git_prompt_git rev-list HEAD..origin/$(git_current_branch) 2> /dev/null)" ]]; then
|
|
||||||
echo "$ZSH_THEME_GIT_PROMPT_BEHIND"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
# Outputs if current branch exists on remote or not
|
|
||||||
function git_prompt_remote() {
|
|
||||||
if [[ -n "$(__git_prompt_git show-ref origin/$(git_current_branch) 2> /dev/null)" ]]; then
|
|
||||||
echo "$ZSH_THEME_GIT_PROMPT_REMOTE_EXISTS"
|
|
||||||
else
|
|
||||||
echo "$ZSH_THEME_GIT_PROMPT_REMOTE_MISSING"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
# Formats prompt string for current git commit short SHA
|
|
||||||
function git_prompt_short_sha() {
|
|
||||||
local SHA
|
|
||||||
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
|
|
||||||
function git_prompt_long_sha() {
|
|
||||||
local SHA
|
|
||||||
SHA=$(__git_prompt_git rev-parse HEAD 2> /dev/null) && echo "$ZSH_THEME_GIT_PROMPT_SHA_BEFORE$SHA$ZSH_THEME_GIT_PROMPT_SHA_AFTER"
|
|
||||||
}
|
|
||||||
|
|
||||||
# Outputs the name of the current user
|
|
||||||
# Usage example: $(git_current_user_name)
|
|
||||||
function git_current_user_name() {
|
|
||||||
__git_prompt_git config user.name 2>/dev/null
|
|
||||||
}
|
|
||||||
|
|
||||||
# Outputs the email of the current user
|
|
||||||
# Usage example: $(git_current_user_email)
|
|
||||||
function git_current_user_email() {
|
|
||||||
__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
|
|
||||||
}
|
|
||||||
41
lib/grep.zsh
41
lib/grep.zsh
@@ -1,41 +0,0 @@
|
|||||||
__GREP_CACHE_FILE="$ZSH_CACHE_DIR"/grep-alias
|
|
||||||
|
|
||||||
# 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 <<< ""
|
|
||||||
}
|
|
||||||
|
|
||||||
# Ignore these folders (if the necessary grep flags are available)
|
|
||||||
EXC_FOLDERS="{.bzr,CVS,.git,.hg,.svn,.idea,.tox,.venv,venv}"
|
|
||||||
|
|
||||||
# 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="grep -E"
|
|
||||||
alias fgrep="grep -F"
|
|
||||||
|
|
||||||
# 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
|
|
||||||
|
|
||||||
unset __GREP_CACHE_FILE __GREP_ALIAS_CACHES
|
|
||||||
@@ -1,48 +0,0 @@
|
|||||||
## History wrapper
|
|
||||||
function omz_history {
|
|
||||||
# parse arguments and remove from $@
|
|
||||||
local clear list stamp REPLY
|
|
||||||
zparseopts -E -D c=clear l=list f=stamp E=stamp i=stamp t:=stamp
|
|
||||||
|
|
||||||
if [[ -n "$clear" ]]; then
|
|
||||||
# if -c provided, clobber the history file
|
|
||||||
|
|
||||||
# confirm action before deleting history
|
|
||||||
print -nu2 "This action will irreversibly delete your command history. Are you sure? [y/N] "
|
|
||||||
builtin read -E
|
|
||||||
[[ "$REPLY" = [yY] ]] || return 0
|
|
||||||
|
|
||||||
print -nu2 >| "$HISTFILE"
|
|
||||||
fc -p "$HISTFILE"
|
|
||||||
|
|
||||||
print -u2 History file deleted.
|
|
||||||
elif [[ $# -eq 0 ]]; then
|
|
||||||
# if no arguments provided, show full history starting from 1
|
|
||||||
builtin fc "${stamp[@]}" -l 1
|
|
||||||
else
|
|
||||||
# otherwise, run `fc -l` with a custom format
|
|
||||||
builtin fc "${stamp[@]}" -l "$@"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
# Timestamp format
|
|
||||||
case ${HIST_STAMPS-} in
|
|
||||||
"mm/dd/yyyy") alias history='omz_history -f' ;;
|
|
||||||
"dd.mm.yyyy") alias history='omz_history -E' ;;
|
|
||||||
"yyyy-mm-dd") alias history='omz_history -i' ;;
|
|
||||||
"") alias history='omz_history' ;;
|
|
||||||
*) alias history="omz_history -t '$HIST_STAMPS'" ;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
## History file configuration
|
|
||||||
[ -z "$HISTFILE" ] && HISTFILE="$HOME/.zsh_history"
|
|
||||||
[ "$HISTSIZE" -lt 50000 ] && HISTSIZE=50000
|
|
||||||
[ "$SAVEHIST" -lt 10000 ] && SAVEHIST=10000
|
|
||||||
|
|
||||||
## History command configuration
|
|
||||||
setopt extended_history # record timestamp of command in HISTFILE
|
|
||||||
setopt hist_expire_dups_first # delete duplicates first when HISTFILE size exceeds HISTSIZE
|
|
||||||
setopt hist_ignore_dups # ignore duplicated commands history list
|
|
||||||
setopt hist_ignore_space # ignore commands that start with space
|
|
||||||
setopt hist_verify # show command with history expansion to user before running it
|
|
||||||
setopt share_history # share command history data
|
|
||||||
@@ -1,145 +0,0 @@
|
|||||||
# http://zsh.sourceforge.net/Doc/Release/Zsh-Line-Editor.html
|
|
||||||
# http://zsh.sourceforge.net/Doc/Release/Zsh-Line-Editor.html#Zle-Builtins
|
|
||||||
# http://zsh.sourceforge.net/Doc/Release/Zsh-Line-Editor.html#Standard-Widgets
|
|
||||||
|
|
||||||
# Make sure that the terminal is in application mode when zle is active, since
|
|
||||||
# only then values from $terminfo are valid
|
|
||||||
if (( ${+terminfo[smkx]} )) && (( ${+terminfo[rmkx]} )); then
|
|
||||||
function zle-line-init() {
|
|
||||||
echoti smkx
|
|
||||||
}
|
|
||||||
function zle-line-finish() {
|
|
||||||
echoti rmkx
|
|
||||||
}
|
|
||||||
zle -N zle-line-init
|
|
||||||
zle -N zle-line-finish
|
|
||||||
fi
|
|
||||||
|
|
||||||
# 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
|
|
||||||
autoload -U up-line-or-beginning-search
|
|
||||||
zle -N up-line-or-beginning-search
|
|
||||||
|
|
||||||
bindkey -M emacs "^[[A" up-line-or-beginning-search
|
|
||||||
bindkey -M viins "^[[A" up-line-or-beginning-search
|
|
||||||
bindkey -M vicmd "^[[A" up-line-or-beginning-search
|
|
||||||
if [[ -n "${terminfo[kcuu1]}" ]]; then
|
|
||||||
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
|
|
||||||
autoload -U down-line-or-beginning-search
|
|
||||||
zle -N down-line-or-beginning-search
|
|
||||||
|
|
||||||
bindkey -M emacs "^[[B" down-line-or-beginning-search
|
|
||||||
bindkey -M viins "^[[B" down-line-or-beginning-search
|
|
||||||
bindkey -M vicmd "^[[B" down-line-or-beginning-search
|
|
||||||
if [[ -n "${terminfo[kcud1]}" ]]; then
|
|
||||||
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 -s '\el' '^q 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 ' ' magic-space # [Space] - don't do history expansion
|
|
||||||
|
|
||||||
|
|
||||||
# Edit the current command line in $VISUAL (or $EDITOR / `vi` if not set)
|
|
||||||
autoload -U edit-command-line
|
|
||||||
zle -N edit-command-line
|
|
||||||
bindkey '\C-x\C-e' edit-command-line
|
|
||||||
|
|
||||||
# file rename magick
|
|
||||||
bindkey "^[m" copy-prev-shell-word
|
|
||||||
|
|
||||||
# consider emacs keybindings:
|
|
||||||
|
|
||||||
#bindkey -e ## emacs key bindings
|
|
||||||
#
|
|
||||||
#bindkey '^[[A' up-line-or-search
|
|
||||||
#bindkey '^[[B' down-line-or-search
|
|
||||||
#bindkey '^[^[[C' emacs-forward-word
|
|
||||||
#bindkey '^[^[[D' emacs-backward-word
|
|
||||||
#
|
|
||||||
#bindkey -s '^X^Z' '%-^M'
|
|
||||||
#bindkey '^[e' expand-cmd-path
|
|
||||||
#bindkey '^[^I' reverse-menu-complete
|
|
||||||
#bindkey '^X^N' accept-and-infer-next-history
|
|
||||||
#bindkey '^W' kill-region
|
|
||||||
#bindkey '^I' complete-word
|
|
||||||
## Fix weird sequence that rxvt produces
|
|
||||||
#bindkey -s '^[[Z' '\t'
|
|
||||||
#
|
|
||||||
38
lib/misc.zsh
38
lib/misc.zsh
@@ -1,38 +0,0 @@
|
|||||||
autoload -Uz is-at-least
|
|
||||||
|
|
||||||
# *-magic is known buggy in some versions; disable if so
|
|
||||||
if [[ $DISABLE_MAGIC_FUNCTIONS != true ]]; then
|
|
||||||
for d in $fpath; do
|
|
||||||
if [[ -e "$d/url-quote-magic" ]]; then
|
|
||||||
if is-at-least 5.1; then
|
|
||||||
autoload -Uz bracketed-paste-magic
|
|
||||||
zle -N bracketed-paste bracketed-paste-magic
|
|
||||||
fi
|
|
||||||
autoload -Uz url-quote-magic
|
|
||||||
zle -N self-insert url-quote-magic
|
|
||||||
break
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
fi
|
|
||||||
|
|
||||||
setopt multios # enable redirect to multiple streams: echo >file1 >file2
|
|
||||||
setopt long_list_jobs # show long list format job notifications
|
|
||||||
setopt interactivecomments # recognize comments
|
|
||||||
|
|
||||||
# define pager depending on what is available (less or more)
|
|
||||||
if (( ${+commands[less]} )); then
|
|
||||||
env_default 'PAGER' 'less'
|
|
||||||
env_default 'LESS' '-R'
|
|
||||||
elif (( ${+commands[more]} )); then
|
|
||||||
env_default 'PAGER' 'more'
|
|
||||||
fi
|
|
||||||
|
|
||||||
## super user alias
|
|
||||||
alias _='sudo '
|
|
||||||
|
|
||||||
## more intelligent acking for ubuntu users and no alias for users without ack
|
|
||||||
if (( $+commands[ack-grep] )); then
|
|
||||||
alias afind='ack-grep -il'
|
|
||||||
elif (( $+commands[ack] )); then
|
|
||||||
alias afind='ack -il'
|
|
||||||
fi
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
# get the nvm-controlled node.js version
|
|
||||||
function nvm_prompt_info() {
|
|
||||||
which nvm &>/dev/null || return
|
|
||||||
local nvm_prompt=${$(nvm current)#v}
|
|
||||||
echo "${ZSH_THEME_NVM_PROMPT_PREFIX}${nvm_prompt:gs/%/%%}${ZSH_THEME_NVM_PROMPT_SUFFIX}"
|
|
||||||
}
|
|
||||||
@@ -1,45 +0,0 @@
|
|||||||
# *_prompt_info functions for usage in your prompt
|
|
||||||
#
|
|
||||||
# Plugin creators, please add your *_prompt_info function to the list
|
|
||||||
# of dummy implementations to help theme creators not receiving errors
|
|
||||||
# without the need of implementing conditional clauses.
|
|
||||||
#
|
|
||||||
# See also lib/bzr.zsh, lib/git.zsh and lib/nvm.zsh for
|
|
||||||
# git_prompt_info, bzr_prompt_info and nvm_prompt_info
|
|
||||||
|
|
||||||
# Dummy implementations that return false to prevent command_not_found
|
|
||||||
# errors with themes, that implement these functions
|
|
||||||
# Real implementations will be used when the respective plugins are loaded
|
|
||||||
function chruby_prompt_info \
|
|
||||||
rbenv_prompt_info \
|
|
||||||
hg_prompt_info \
|
|
||||||
pyenv_prompt_info \
|
|
||||||
svn_prompt_info \
|
|
||||||
vi_mode_prompt_info \
|
|
||||||
virtualenv_prompt_info \
|
|
||||||
jenv_prompt_info \
|
|
||||||
azure_prompt_info \
|
|
||||||
tf_prompt_info \
|
|
||||||
conda_prompt_info \
|
|
||||||
{
|
|
||||||
return 1
|
|
||||||
}
|
|
||||||
|
|
||||||
# oh-my-zsh supports an rvm prompt by default
|
|
||||||
# get the name of the rvm ruby version
|
|
||||||
function rvm_prompt_info() {
|
|
||||||
[ -f $HOME/.rvm/bin/rvm-prompt ] || return 1
|
|
||||||
local rvm_prompt
|
|
||||||
rvm_prompt=$($HOME/.rvm/bin/rvm-prompt ${=ZSH_THEME_RVM_PROMPT_OPTIONS} 2>/dev/null)
|
|
||||||
[[ -z "${rvm_prompt}" ]] && return 1
|
|
||||||
echo "${ZSH_THEME_RUBY_PROMPT_PREFIX}${rvm_prompt:gs/%/%%}${ZSH_THEME_RUBY_PROMPT_SUFFIX}"
|
|
||||||
}
|
|
||||||
|
|
||||||
ZSH_THEME_RVM_PROMPT_OPTIONS="i v g"
|
|
||||||
|
|
||||||
|
|
||||||
# use this to enable users to see their ruby version, no matter which
|
|
||||||
# version management system they use
|
|
||||||
function ruby_prompt_info() {
|
|
||||||
echo "$(rvm_prompt_info || rbenv_prompt_info || chruby_prompt_info)"
|
|
||||||
}
|
|
||||||
@@ -1,38 +0,0 @@
|
|||||||
# A script to make using 256 colors in zsh less painful.
|
|
||||||
# P.C. Shyamshankar <sykora@lucentbeing.com>
|
|
||||||
# Copied from https://github.com/sykora/etc/blob/master/zsh/functions/spectrum/
|
|
||||||
|
|
||||||
typeset -AHg FX FG BG
|
|
||||||
|
|
||||||
FX=(
|
|
||||||
reset "%{[00m%}"
|
|
||||||
bold "%{[01m%}" no-bold "%{[22m%}"
|
|
||||||
dim "%{[02m%}" no-dim "%{[22m%}"
|
|
||||||
italic "%{[03m%}" no-italic "%{[23m%}"
|
|
||||||
underline "%{[04m%}" no-underline "%{[24m%}"
|
|
||||||
blink "%{[05m%}" no-blink "%{[25m%}"
|
|
||||||
reverse "%{[07m%}" no-reverse "%{[27m%}"
|
|
||||||
)
|
|
||||||
|
|
||||||
for color in {000..255}; do
|
|
||||||
FG[$color]="%{[38;5;${color}m%}"
|
|
||||||
BG[$color]="%{[48;5;${color}m%}"
|
|
||||||
done
|
|
||||||
|
|
||||||
# Show all 256 colors with color number
|
|
||||||
function spectrum_ls() {
|
|
||||||
setopt localoptions nopromptsubst
|
|
||||||
local ZSH_SPECTRUM_TEXT=${ZSH_SPECTRUM_TEXT:-Arma virumque cano Troiae qui primus ab oris}
|
|
||||||
for code in {000..255}; do
|
|
||||||
print -P -- "$code: ${FG[$code]}${ZSH_SPECTRUM_TEXT}%{$reset_color%}"
|
|
||||||
done
|
|
||||||
}
|
|
||||||
|
|
||||||
# Show all 256 colors where the background is set to specific color
|
|
||||||
function spectrum_bls() {
|
|
||||||
setopt localoptions nopromptsubst
|
|
||||||
local ZSH_SPECTRUM_TEXT=${ZSH_SPECTRUM_TEXT:-Arma virumque cano Troiae qui primus ab oris}
|
|
||||||
for code in {000..255}; do
|
|
||||||
print -P -- "$code: ${BG[$code]}${ZSH_SPECTRUM_TEXT}%{$reset_color%}"
|
|
||||||
done
|
|
||||||
}
|
|
||||||
@@ -1,164 +0,0 @@
|
|||||||
# Set terminal window and tab/icon title
|
|
||||||
#
|
|
||||||
# usage: title short_tab_title [long_window_title]
|
|
||||||
#
|
|
||||||
# See: http://www.faqs.org/docs/Linux-mini/Xterm-Title.html#ss3.1
|
|
||||||
# Fully supports screen, iterm, and probably most modern xterm and rxvt
|
|
||||||
# (In screen, only short_tab_title is used)
|
|
||||||
# Limited support for Apple Terminal (Terminal can't set window and tab separately)
|
|
||||||
function title {
|
|
||||||
setopt localoptions nopromptsubst
|
|
||||||
|
|
||||||
# Don't set the title if inside emacs, unless using vterm
|
|
||||||
[[ -n "${INSIDE_EMACS:-}" && "$INSIDE_EMACS" != vterm ]] && return
|
|
||||||
|
|
||||||
# if $2 is unset use $1 as default
|
|
||||||
# if it is set and empty, leave it as is
|
|
||||||
: ${2=$1}
|
|
||||||
|
|
||||||
case "$TERM" in
|
|
||||||
cygwin|xterm*|putty*|rxvt*|konsole*|ansi|mlterm*|alacritty*|st*|foot*|contour*|wezterm*)
|
|
||||||
print -Pn "\e]2;${2:q}\a" # set window name
|
|
||||||
print -Pn "\e]1;${1:q}\a" # set tab name
|
|
||||||
;;
|
|
||||||
screen*|tmux*)
|
|
||||||
print -Pn "\ek${1:q}\e\\" # set screen hardstatus
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
if [[ "$TERM_PROGRAM" == "iTerm.app" ]]; then
|
|
||||||
print -Pn "\e]2;${2:q}\a" # set window name
|
|
||||||
print -Pn "\e]1;${1:q}\a" # set tab name
|
|
||||||
else
|
|
||||||
# Try to use terminfo to set the title if the feature is available
|
|
||||||
if (( ${+terminfo[fsl]} && ${+terminfo[tsl]} )); then
|
|
||||||
print -Pn "${terminfo[tsl]}$1${terminfo[fsl]}"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
}
|
|
||||||
|
|
||||||
ZSH_THEME_TERM_TAB_TITLE_IDLE="%15<..<%~%<<" #15 char left truncated PWD
|
|
||||||
ZSH_THEME_TERM_TITLE_IDLE="%n@%m:%~"
|
|
||||||
# Avoid duplication of directory in terminals with independent dir display
|
|
||||||
if [[ "$TERM_PROGRAM" == Apple_Terminal ]]; then
|
|
||||||
ZSH_THEME_TERM_TITLE_IDLE="%n@%m"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Runs before showing the prompt
|
|
||||||
function omz_termsupport_precmd {
|
|
||||||
[[ "${DISABLE_AUTO_TITLE:-}" != true ]] || return 0
|
|
||||||
title "$ZSH_THEME_TERM_TAB_TITLE_IDLE" "$ZSH_THEME_TERM_TITLE_IDLE"
|
|
||||||
}
|
|
||||||
|
|
||||||
# Runs before executing the command
|
|
||||||
function omz_termsupport_preexec {
|
|
||||||
[[ "${DISABLE_AUTO_TITLE:-}" != true ]] || return 0
|
|
||||||
|
|
||||||
emulate -L zsh
|
|
||||||
setopt extended_glob
|
|
||||||
|
|
||||||
# split command into array of arguments
|
|
||||||
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
|
|
||||||
|
|
||||||
# cmd name only, or if this is sudo or ssh, the next cmd
|
|
||||||
local CMD="${1[(wr)^(*=*|sudo|ssh|mosh|rake|-*)]:gs/%/%%}"
|
|
||||||
local LINE="${2:gs/%/%%}"
|
|
||||||
|
|
||||||
title "$CMD" "%100>...>${LINE}%<<"
|
|
||||||
}
|
|
||||||
|
|
||||||
autoload -Uz add-zsh-hook
|
|
||||||
|
|
||||||
if [[ -z "$INSIDE_EMACS" || "$INSIDE_EMACS" = vterm ]]; then
|
|
||||||
add-zsh-hook precmd omz_termsupport_precmd
|
|
||||||
add-zsh-hook preexec omz_termsupport_preexec
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Keep terminal emulator's current working directory correct,
|
|
||||||
# even if the current working directory path contains symbolic links
|
|
||||||
#
|
|
||||||
# References:
|
|
||||||
# - Apple's Terminal.app: https://superuser.com/a/315029
|
|
||||||
# - iTerm2: https://iterm2.com/documentation-escape-codes.html (iTerm2 Extension / CurrentDir+RemoteHost)
|
|
||||||
# - Konsole: https://bugs.kde.org/show_bug.cgi?id=327720#c1
|
|
||||||
# - libvte (gnome-terminal, mate-terminal, …): https://bugzilla.gnome.org/show_bug.cgi?id=675987#c14
|
|
||||||
# Apparently it had a bug before ~2012 were it would display the unknown OSC 7 code
|
|
||||||
#
|
|
||||||
# As of May 2021 mlterm, PuTTY, rxvt, screen, termux & xterm simply ignore the unknown OSC.
|
|
||||||
|
|
||||||
# Don't define the function if we're inside Emacs or in an SSH session (#11696)
|
|
||||||
if [[ -n "$INSIDE_EMACS" || -n "$SSH_CLIENT" || -n "$SSH_TTY" ]]; then
|
|
||||||
return
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Don't define the function if we're in an unsupported terminal
|
|
||||||
case "$TERM" in
|
|
||||||
# all of these either process OSC 7 correctly or ignore entirely
|
|
||||||
xterm*|putty*|rxvt*|konsole*|mlterm*|alacritty*|screen*|tmux*) ;;
|
|
||||||
contour*|foot*) ;;
|
|
||||||
*)
|
|
||||||
# Terminal.app and iTerm2 process OSC 7 correctly
|
|
||||||
case "$TERM_PROGRAM" in
|
|
||||||
Apple_Terminal|iTerm.app) ;;
|
|
||||||
*) return ;;
|
|
||||||
esac ;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
# Emits the control sequence to notify many terminal emulators
|
|
||||||
# of the cwd
|
|
||||||
#
|
|
||||||
# Identifies the directory using a file: URI scheme, including
|
|
||||||
# the host name to disambiguate local vs. remote paths.
|
|
||||||
function omz_termsupport_cwd {
|
|
||||||
setopt localoptions unset
|
|
||||||
# Percent-encode the host and path names.
|
|
||||||
local URL_HOST URL_PATH
|
|
||||||
URL_HOST="$(omz_urlencode -P $HOST)" || return 1
|
|
||||||
URL_PATH="$(omz_urlencode -P $PWD)" || return 1
|
|
||||||
|
|
||||||
# Konsole errors if the HOST is provided
|
|
||||||
[[ -z "$KONSOLE_PROFILE_NAME" && -z "$KONSOLE_DBUS_SESSION" ]] || URL_HOST=""
|
|
||||||
|
|
||||||
# common control sequence (OSC 7) to set current host and path
|
|
||||||
printf "\e]7;file://%s%s\e\\" "${URL_HOST}" "${URL_PATH}"
|
|
||||||
}
|
|
||||||
|
|
||||||
# Use a precmd hook instead of a chpwd hook to avoid contaminating output
|
|
||||||
# i.e. when a script or function changes directory without `cd -q`, chpwd
|
|
||||||
# will be called the output may be swallowed by the script or function.
|
|
||||||
add-zsh-hook precmd omz_termsupport_cwd
|
|
||||||
@@ -1,169 +0,0 @@
|
|||||||
#!/usr/bin/zsh -df
|
|
||||||
|
|
||||||
run_awk() {
|
|
||||||
local -a dis_plugins=(${=1})
|
|
||||||
local input_text="$2"
|
|
||||||
|
|
||||||
(( ! DEBUG )) || set -xv
|
|
||||||
|
|
||||||
local awk_subst_plugins="\
|
|
||||||
gsub(/[ \t]+(${(j:|:)dis_plugins})[ \t]+/, \" \") # with spaces before or after
|
|
||||||
gsub(/[ \t]+(${(j:|:)dis_plugins})$/, \"\") # with spaces before and EOL
|
|
||||||
gsub(/^(${(j:|:)dis_plugins})[ \t]+/, \"\") # with BOL and spaces after
|
|
||||||
|
|
||||||
gsub(/\((${(j:|:)dis_plugins})[ \t]+/, \"(\") # with parenthesis before and spaces after
|
|
||||||
gsub(/[ \t]+(${(j:|:)dis_plugins})\)/, \")\") # with spaces before or parenthesis after
|
|
||||||
gsub(/\((${(j:|:)dis_plugins})\)/, \"()\") # with only parentheses
|
|
||||||
|
|
||||||
gsub(/^(${(j:|:)dis_plugins})\)/, \")\") # with BOL and closing parenthesis
|
|
||||||
gsub(/\((${(j:|:)dis_plugins})$/, \"(\") # with opening parenthesis and EOL
|
|
||||||
"
|
|
||||||
# Disable plugins awk script
|
|
||||||
local awk_script="
|
|
||||||
# if plugins=() is in oneline form, substitute disabled plugins and go to next line
|
|
||||||
/^[ \t]*plugins=\([^#]+\).*\$/ {
|
|
||||||
$awk_subst_plugins
|
|
||||||
print \$0
|
|
||||||
next
|
|
||||||
}
|
|
||||||
|
|
||||||
# if plugins=() is in multiline form, enable multi flag and disable plugins if they're there
|
|
||||||
/^[ \t]*plugins=\(/ {
|
|
||||||
multi=1
|
|
||||||
$awk_subst_plugins
|
|
||||||
print \$0
|
|
||||||
next
|
|
||||||
}
|
|
||||||
|
|
||||||
# if multi flag is enabled and we find a valid closing parenthesis, remove plugins and disable multi flag
|
|
||||||
multi == 1 && /^[^#]*\)/ {
|
|
||||||
multi=0
|
|
||||||
$awk_subst_plugins
|
|
||||||
print \$0
|
|
||||||
next
|
|
||||||
}
|
|
||||||
|
|
||||||
multi == 1 && length(\$0) > 0 {
|
|
||||||
$awk_subst_plugins
|
|
||||||
if (length(\$0) > 0) print \$0
|
|
||||||
next
|
|
||||||
}
|
|
||||||
|
|
||||||
{ print \$0 }
|
|
||||||
"
|
|
||||||
|
|
||||||
command awk "$awk_script" <<< "$input_text"
|
|
||||||
|
|
||||||
(( ! DEBUG )) || set +xv
|
|
||||||
}
|
|
||||||
|
|
||||||
# runs awk against stdin, checks if the resulting file is not empty and then checks if the file has valid zsh syntax
|
|
||||||
run_awk_and_test() {
|
|
||||||
local description="$1"
|
|
||||||
local plugins_to_disable="$2"
|
|
||||||
local input_text="$3"
|
|
||||||
local expected_output="$4"
|
|
||||||
|
|
||||||
local tmpfile==(:)
|
|
||||||
|
|
||||||
{
|
|
||||||
print -u2 "Test: $description"
|
|
||||||
DEBUG=0 run_awk "$plugins_to_disable" "$input_text" >| $tmpfile
|
|
||||||
|
|
||||||
if [[ ! -s "$tmpfile" ]]; then
|
|
||||||
print -u2 "\e[31mError\e[0m: output file empty"
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
if ! zsh -n $tmpfile; then
|
|
||||||
print -u2 "\e[31mError\e[0m: zsh syntax error"
|
|
||||||
diff -u $tmpfile <(echo "$expected_output")
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
if ! diff -u --color=always $tmpfile <(echo "$expected_output"); then
|
|
||||||
if (( DEBUG )); then
|
|
||||||
print -u2 ""
|
|
||||||
DEBUG=1 run_awk "$plugins_to_disable" "$input_text"
|
|
||||||
print -u2 ""
|
|
||||||
fi
|
|
||||||
print -u2 "\e[31mError\e[0m: output file does not match expected output"
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
print -u2 "\e[32mSuccess\e[0m"
|
|
||||||
} always {
|
|
||||||
print -u2 ""
|
|
||||||
command rm -f "$tmpfile"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
# These tests are for the `omz plugin disable` command
|
|
||||||
run_awk_and_test \
|
|
||||||
"it should delete a single plugin in oneline format" \
|
|
||||||
"git" \
|
|
||||||
"plugins=(git)" \
|
|
||||||
"plugins=()"
|
|
||||||
|
|
||||||
run_awk_and_test \
|
|
||||||
"it should delete a single plugin in multiline format" \
|
|
||||||
"github" \
|
|
||||||
"plugins=(
|
|
||||||
github
|
|
||||||
)" \
|
|
||||||
"plugins=(
|
|
||||||
)"
|
|
||||||
|
|
||||||
run_awk_and_test \
|
|
||||||
"it should delete multiple plugins in oneline format" \
|
|
||||||
"github git z" \
|
|
||||||
"plugins=(github git z)" \
|
|
||||||
"plugins=()"
|
|
||||||
|
|
||||||
run_awk_and_test \
|
|
||||||
"it should delete multiple plugins in multiline format" \
|
|
||||||
"github git z" \
|
|
||||||
"plugins=(
|
|
||||||
github
|
|
||||||
git
|
|
||||||
z
|
|
||||||
)" \
|
|
||||||
"plugins=(
|
|
||||||
)"
|
|
||||||
|
|
||||||
run_awk_and_test \
|
|
||||||
"it should delete a single plugin among multiple in oneline format" \
|
|
||||||
"git" \
|
|
||||||
"plugins=(github git z)" \
|
|
||||||
"plugins=(github z)"
|
|
||||||
|
|
||||||
run_awk_and_test \
|
|
||||||
"it should delete a single plugin among multiple in multiline format" \
|
|
||||||
"git" \
|
|
||||||
"plugins=(
|
|
||||||
github
|
|
||||||
git
|
|
||||||
z
|
|
||||||
)" \
|
|
||||||
"plugins=(
|
|
||||||
github
|
|
||||||
z
|
|
||||||
)"
|
|
||||||
|
|
||||||
run_awk_and_test \
|
|
||||||
"it should delete multiple plugins in mixed format" \
|
|
||||||
"git z" \
|
|
||||||
"plugins=(github
|
|
||||||
git z)" \
|
|
||||||
"plugins=(github
|
|
||||||
)"
|
|
||||||
|
|
||||||
run_awk_and_test \
|
|
||||||
"it should delete multiple plugins in mixed format 2" \
|
|
||||||
"github z" \
|
|
||||||
"plugins=(github
|
|
||||||
git
|
|
||||||
z)" \
|
|
||||||
"plugins=(
|
|
||||||
git
|
|
||||||
)"
|
|
||||||
@@ -1,81 +0,0 @@
|
|||||||
# Sets color variable such as $fg, $bg, $color and $reset_color
|
|
||||||
autoload -U colors && colors
|
|
||||||
|
|
||||||
# Expand variables and commands in PROMPT variables
|
|
||||||
setopt prompt_subst
|
|
||||||
|
|
||||||
# Prompt function theming defaults
|
|
||||||
ZSH_THEME_GIT_PROMPT_PREFIX="git:(" # Beginning of the git prompt, before the branch name
|
|
||||||
ZSH_THEME_GIT_PROMPT_SUFFIX=")" # End of the git prompt
|
|
||||||
ZSH_THEME_GIT_PROMPT_DIRTY="*" # Text to display if the branch is dirty
|
|
||||||
ZSH_THEME_GIT_PROMPT_CLEAN="" # Text to display if the branch is clean
|
|
||||||
ZSH_THEME_RUBY_PROMPT_PREFIX="("
|
|
||||||
ZSH_THEME_RUBY_PROMPT_SUFFIX=")"
|
|
||||||
|
|
||||||
|
|
||||||
# Use diff --color if available
|
|
||||||
if command diff --color /dev/null{,} &>/dev/null; then
|
|
||||||
function diff {
|
|
||||||
command diff --color "$@"
|
|
||||||
}
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Don't set ls coloring if disabled
|
|
||||||
[[ "$DISABLE_LS_COLORS" != true ]] || return 0
|
|
||||||
|
|
||||||
# Default coloring for BSD-based ls
|
|
||||||
export LSCOLORS="Gxfxcxdxbxegedabagacad"
|
|
||||||
|
|
||||||
# Default coloring for GNU-based ls
|
|
||||||
if [[ -z "$LS_COLORS" ]]; then
|
|
||||||
# Define LS_COLORS via dircolors if available. Otherwise, set a default
|
|
||||||
# equivalent to LSCOLORS (generated via https://geoff.greer.fm/lscolors)
|
|
||||||
if (( $+commands[dircolors] )); then
|
|
||||||
[[ -f "$HOME/.dircolors" ]] \
|
|
||||||
&& source <(dircolors -b "$HOME/.dircolors") \
|
|
||||||
|| source <(dircolors -b)
|
|
||||||
else
|
|
||||||
export LS_COLORS="di=1;36:ln=35:so=32:pi=33:ex=31:bd=34;46:cd=34;43:su=30;41:sg=30;46:tw=30;42:ow=30;43"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
function test-ls-args {
|
|
||||||
# Usage: test-ls-args cmd args...
|
|
||||||
# e.g. test-ls-args gls --color
|
|
||||||
command "$@" /dev/null &>/dev/null
|
|
||||||
}
|
|
||||||
|
|
||||||
# Find the option for using colors in ls, depending on the version
|
|
||||||
case "$OSTYPE" in
|
|
||||||
netbsd*)
|
|
||||||
# On NetBSD, test if `gls` (GNU ls) is installed (this one supports colors);
|
|
||||||
# otherwise, leave ls as is, because NetBSD's ls doesn't support -G
|
|
||||||
test-ls-args gls --color && alias ls='gls --color=tty'
|
|
||||||
;;
|
|
||||||
openbsd*)
|
|
||||||
# On OpenBSD, `gls` (ls from GNU coreutils) and `colorls` (ls from base,
|
|
||||||
# with color and multibyte support) are available from ports.
|
|
||||||
# `colorls` will be installed on purpose and can't be pulled in by installing
|
|
||||||
# coreutils (which might be installed for ), so prefer it to `gls`.
|
|
||||||
test-ls-args gls --color && alias ls='gls --color=tty'
|
|
||||||
test-ls-args colorls -G && alias ls='colorls -G'
|
|
||||||
;;
|
|
||||||
(darwin|freebsd)*)
|
|
||||||
# This alias works by default just using $LSCOLORS
|
|
||||||
test-ls-args ls -G && alias ls='ls -G'
|
|
||||||
# Only use GNU ls if installed and there are user defaults for $LS_COLORS,
|
|
||||||
# as the default coloring scheme is not very pretty
|
|
||||||
zstyle -t ':omz:lib:theme-and-appearance' gnu-ls \
|
|
||||||
&& test-ls-args gls --color \
|
|
||||||
&& alias ls='gls --color=tty'
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
if test-ls-args ls --color; then
|
|
||||||
alias ls='ls --color=tty'
|
|
||||||
elif test-ls-args ls -G; then
|
|
||||||
alias ls='ls -G'
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
unfunction test-ls-args
|
|
||||||
@@ -1,53 +0,0 @@
|
|||||||
# Don't skip this file until a Zsh release does the necessary quoting.
|
|
||||||
# This is because even though 5.8.1 undid recursive prompt_subst inside
|
|
||||||
# prompt sequences, % characters in relevant fields will still be rendered
|
|
||||||
# incorrectly in vcs_info, on all Zsh releases up to writing this.
|
|
||||||
#
|
|
||||||
# There is no release yet that does this right, since it requires changing
|
|
||||||
# how what vcs_info hooks expect to receive. Even so, I'd rather be correct
|
|
||||||
# and break custom vcs_info hooks than have a broken prompt.
|
|
||||||
|
|
||||||
# Quote necessary $hook_com[<field>] items just before they are used
|
|
||||||
# in the line "VCS_INFO_hook 'post-backend'" of the VCS_INFO_formats
|
|
||||||
# function, where <field> is:
|
|
||||||
#
|
|
||||||
# base: the full path of the repository's root directory.
|
|
||||||
# base-name: the name of the repository's root directory.
|
|
||||||
# branch: the name of the currently checked out branch.
|
|
||||||
# misc: a string that may contain anything the vcs_info backend wants.
|
|
||||||
# revision: an identifier of the currently checked out revision.
|
|
||||||
# subdir: the path of the current directory relative to the
|
|
||||||
# repository's root directory.
|
|
||||||
#
|
|
||||||
# This patch %-quotes these fields previous to their use in vcs_info hooks and
|
|
||||||
# the zformat call and, eventually, when they get expanded in the prompt.
|
|
||||||
# It's important to quote these here, and not later after hooks have modified the
|
|
||||||
# fields, because then we could be quoting % characters from valid prompt sequences,
|
|
||||||
# like %F{color}, %B, etc.
|
|
||||||
#
|
|
||||||
# 32 │ hook_com[subdir]="$(VCS_INFO_reposub ${hook_com[base]})"
|
|
||||||
# 33 │ hook_com[subdir_orig]="${hook_com[subdir]}"
|
|
||||||
# 34 │
|
|
||||||
# 35 + │ for tmp in base base-name branch misc revision subdir; do
|
|
||||||
# 36 + │ hook_com[$tmp]="${hook_com[$tmp]//\%/%%}"
|
|
||||||
# 37 + │ done
|
|
||||||
# 38 + │
|
|
||||||
# 39 │ VCS_INFO_hook 'post-backend'
|
|
||||||
#
|
|
||||||
# This is especially important so that no command substitution is performed
|
|
||||||
# due to malicious input as a consequence of CVE-2021-45444, which affects
|
|
||||||
# zsh versions from 5.0.3 to 5.8.
|
|
||||||
#
|
|
||||||
autoload -Uz +X regexp-replace VCS_INFO_formats 2>/dev/null || return 0
|
|
||||||
|
|
||||||
# We use $tmp here because it's already a local variable in VCS_INFO_formats
|
|
||||||
typeset PATCH='for tmp (base base-name branch misc revision subdir) hook_com[$tmp]="${hook_com[$tmp]//\%/%%}"'
|
|
||||||
# Unique string to avoid reapplying the patch if this code gets called twice
|
|
||||||
typeset PATCH_ID=vcs_info-patch-9b9840f2-91e5-4471-af84-9e9a0dc68c1b
|
|
||||||
# Only patch the VCS_INFO_formats function if not already patched
|
|
||||||
if [[ "$functions[VCS_INFO_formats]" != *$PATCH_ID* ]]; then
|
|
||||||
regexp-replace 'functions[VCS_INFO_formats]' \
|
|
||||||
"VCS_INFO_hook 'post-backend'" \
|
|
||||||
': ${PATCH_ID}; ${PATCH}; ${MATCH}'
|
|
||||||
fi
|
|
||||||
unset PATCH PATCH_ID
|
|
||||||
240
oh-my-zsh.sh
240
oh-my-zsh.sh
@@ -1,240 +0,0 @@
|
|||||||
# ANSI formatting function (\033[<code>m)
|
|
||||||
# 0: reset, 1: bold, 4: underline, 22: no bold, 24: no underline, 31: red, 33: yellow
|
|
||||||
omz_f() {
|
|
||||||
[ $# -gt 0 ] || return
|
|
||||||
IFS=";" printf "\033[%sm" $*
|
|
||||||
}
|
|
||||||
# If stdout is not a terminal ignore all formatting
|
|
||||||
[ -t 1 ] || omz_f() { :; }
|
|
||||||
|
|
||||||
# Protect against non-zsh execution of Oh My Zsh (use POSIX syntax here)
|
|
||||||
[ -n "$ZSH_VERSION" ] || {
|
|
||||||
omz_ptree() {
|
|
||||||
# Get process tree of the current process
|
|
||||||
pid=$$; pids="$pid"
|
|
||||||
while [ ${pid-0} -ne 1 ] && ppid=$(ps -e -o pid,ppid | awk "\$1 == $pid { print \$2 }"); do
|
|
||||||
pids="$pids $pid"; pid=$ppid
|
|
||||||
done
|
|
||||||
|
|
||||||
# Show process tree
|
|
||||||
case "$(uname)" in
|
|
||||||
Linux) ps -o ppid,pid,command -f -p $pids 2>/dev/null ;;
|
|
||||||
Darwin|*) ps -o ppid,pid,command -p $pids 2>/dev/null ;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
# If ps command failed, try Busybox ps
|
|
||||||
[ $? -eq 0 ] || ps -o ppid,pid,comm | awk "NR == 1 || index(\"$pids\", \$2) != 0"
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
shell=$(ps -o pid,comm | awk "\$1 == $$ { print \$2 }")
|
|
||||||
printf "$(omz_f 1 31)Error:$(omz_f 22) Oh My Zsh can't be loaded from: $(omz_f 1)${shell}$(omz_f 22). "
|
|
||||||
printf "You need to run $(omz_f 1)zsh$(omz_f 22) instead.$(omz_f 0)\n"
|
|
||||||
printf "$(omz_f 33)Here's the process tree:$(omz_f 22)\n\n"
|
|
||||||
omz_ptree
|
|
||||||
printf "$(omz_f 0)\n"
|
|
||||||
} >&2
|
|
||||||
|
|
||||||
return 1
|
|
||||||
}
|
|
||||||
|
|
||||||
# Check if in emulation mode, if so early return
|
|
||||||
# https://github.com/ohmyzsh/ohmyzsh/issues/11686
|
|
||||||
[[ "$(emulate)" = zsh ]] || {
|
|
||||||
printf "$(omz_f 1 31)Error:$(omz_f 22) Oh My Zsh can't be loaded in \`$(emulate)\` emulation mode.$(omz_f 0)\n" >&2
|
|
||||||
return 1
|
|
||||||
}
|
|
||||||
|
|
||||||
unset -f omz_f
|
|
||||||
|
|
||||||
# If ZSH is not defined, use the current script's directory.
|
|
||||||
[[ -n "$ZSH" ]] || export ZSH="${${(%):-%x}:a:h}"
|
|
||||||
|
|
||||||
# Set ZSH_CUSTOM to the path where your custom config files
|
|
||||||
# and plugins exists, or else we will use the default custom/
|
|
||||||
[[ -n "$ZSH_CUSTOM" ]] || ZSH_CUSTOM="$ZSH/custom"
|
|
||||||
|
|
||||||
# Set ZSH_CACHE_DIR to the path where cache files should be created
|
|
||||||
# or else we will use the default cache/
|
|
||||||
[[ -n "$ZSH_CACHE_DIR" ]] || ZSH_CACHE_DIR="$ZSH/cache"
|
|
||||||
|
|
||||||
# Make sure $ZSH_CACHE_DIR is writable, otherwise use a directory in $HOME
|
|
||||||
if [[ ! -w "$ZSH_CACHE_DIR" ]]; then
|
|
||||||
ZSH_CACHE_DIR="${XDG_CACHE_HOME:-$HOME/.cache}/oh-my-zsh"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Create cache and completions dir and add to $fpath
|
|
||||||
mkdir -p "$ZSH_CACHE_DIR/completions"
|
|
||||||
(( ${fpath[(Ie)$ZSH_CACHE_DIR/completions]} )) || fpath=("$ZSH_CACHE_DIR/completions" $fpath)
|
|
||||||
|
|
||||||
# Check for updates on initial load...
|
|
||||||
source "$ZSH/tools/check_for_upgrade.sh"
|
|
||||||
|
|
||||||
# Initializes Oh My Zsh
|
|
||||||
|
|
||||||
# add a function path
|
|
||||||
fpath=($ZSH/{functions,completions} $ZSH_CUSTOM/{functions,completions} $fpath)
|
|
||||||
|
|
||||||
# Load all stock functions (from $fpath files) called below.
|
|
||||||
autoload -U compaudit compinit zrecompile
|
|
||||||
|
|
||||||
is_plugin() {
|
|
||||||
local base_dir=$1
|
|
||||||
local name=$2
|
|
||||||
builtin test -f $base_dir/plugins/$name/$name.plugin.zsh \
|
|
||||||
|| builtin test -f $base_dir/plugins/$name/_$name
|
|
||||||
}
|
|
||||||
|
|
||||||
# Add all defined plugins to fpath. This must be done
|
|
||||||
# before running compinit.
|
|
||||||
for plugin ($plugins); do
|
|
||||||
if is_plugin "$ZSH_CUSTOM" "$plugin"; then
|
|
||||||
fpath=("$ZSH_CUSTOM/plugins/$plugin" $fpath)
|
|
||||||
elif is_plugin "$ZSH" "$plugin"; then
|
|
||||||
fpath=("$ZSH/plugins/$plugin" $fpath)
|
|
||||||
else
|
|
||||||
echo "[oh-my-zsh] plugin '$plugin' not found"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
# Figure out the SHORT hostname
|
|
||||||
if [[ "$OSTYPE" = darwin* ]]; then
|
|
||||||
# macOS's $HOST changes with dhcp, etc. Use LocalHostName if possible.
|
|
||||||
SHORT_HOST=$(scutil --get LocalHostName 2>/dev/null) || SHORT_HOST="${HOST/.*/}"
|
|
||||||
else
|
|
||||||
SHORT_HOST="${HOST/.*/}"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Save the location of the current completion dump file.
|
|
||||||
if [[ -z "$ZSH_COMPDUMP" ]]; then
|
|
||||||
ZSH_COMPDUMP="${ZDOTDIR:-$HOME}/.zcompdump-${SHORT_HOST}-${ZSH_VERSION}"
|
|
||||||
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
|
|
||||||
source "$ZSH/lib/compfix.zsh"
|
|
||||||
# Load only from secure directories
|
|
||||||
compinit -i -d "$ZSH_COMPDUMP"
|
|
||||||
# If completion insecurities exist, warn the user
|
|
||||||
handle_completion_insecurities &|
|
|
||||||
else
|
|
||||||
# If the user wants it, load from all found directories
|
|
||||||
compinit -u -d "$ZSH_COMPDUMP"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Append zcompdump metadata if missing
|
|
||||||
if (( $zcompdump_refresh )) \
|
|
||||||
|| ! command grep -q -Fx "$zcompdump_revision" "$ZSH_COMPDUMP" 2>/dev/null; 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
|
|
||||||
|
|
||||||
# zcompile the completion dump file if the .zwc is older or missing.
|
|
||||||
if command mkdir "${ZSH_COMPDUMP}.lock" 2>/dev/null; then
|
|
||||||
zrecompile -q -p "$ZSH_COMPDUMP"
|
|
||||||
command rm -rf "$ZSH_COMPDUMP.zwc.old" "${ZSH_COMPDUMP}.lock"
|
|
||||||
fi
|
|
||||||
|
|
||||||
_omz_source() {
|
|
||||||
local context filepath="$1"
|
|
||||||
|
|
||||||
# Construct zstyle context based on path
|
|
||||||
case "$filepath" in
|
|
||||||
lib/*) context="lib:${filepath:t:r}" ;; # :t = lib_name.zsh, :r = lib_name
|
|
||||||
plugins/*) context="plugins:${filepath:h:t}" ;; # :h = plugins/plugin_name, :t = plugin_name
|
|
||||||
esac
|
|
||||||
|
|
||||||
local disable_aliases=0
|
|
||||||
zstyle -T ":omz:${context}" aliases || disable_aliases=1
|
|
||||||
|
|
||||||
# Back up alias names prior to sourcing
|
|
||||||
local -A aliases_pre galiases_pre
|
|
||||||
if (( disable_aliases )); then
|
|
||||||
aliases_pre=("${(@kv)aliases}")
|
|
||||||
galiases_pre=("${(@kv)galiases}")
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Source file from $ZSH_CUSTOM if it exists, otherwise from $ZSH
|
|
||||||
if [[ -f "$ZSH_CUSTOM/$filepath" ]]; then
|
|
||||||
source "$ZSH_CUSTOM/$filepath"
|
|
||||||
elif [[ -f "$ZSH/$filepath" ]]; then
|
|
||||||
source "$ZSH/$filepath"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Unset all aliases that don't appear in the backed up list of aliases
|
|
||||||
if (( disable_aliases )); then
|
|
||||||
if (( #aliases_pre )); then
|
|
||||||
aliases=("${(@kv)aliases_pre}")
|
|
||||||
else
|
|
||||||
(( #aliases )) && unalias "${(@k)aliases}"
|
|
||||||
fi
|
|
||||||
if (( #galiases_pre )); then
|
|
||||||
galiases=("${(@kv)galiases_pre}")
|
|
||||||
else
|
|
||||||
(( #galiases )) && unalias "${(@k)galiases}"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
# Load all of the lib files in ~/.oh-my-zsh/lib that end in .zsh
|
|
||||||
# TIP: Add files you don't want in git to .gitignore
|
|
||||||
for lib_file ("$ZSH"/lib/*.zsh); do
|
|
||||||
_omz_source "lib/${lib_file:t}"
|
|
||||||
done
|
|
||||||
unset lib_file
|
|
||||||
|
|
||||||
# Load all of the plugins that were defined in ~/.zshrc
|
|
||||||
for plugin ($plugins); do
|
|
||||||
_omz_source "plugins/$plugin/$plugin.plugin.zsh"
|
|
||||||
done
|
|
||||||
unset plugin
|
|
||||||
|
|
||||||
# Load all of your custom configurations from custom/
|
|
||||||
for config_file ("$ZSH_CUSTOM"/*.zsh(N)); do
|
|
||||||
source "$config_file"
|
|
||||||
done
|
|
||||||
unset config_file
|
|
||||||
|
|
||||||
# Load the theme
|
|
||||||
is_theme() {
|
|
||||||
local base_dir=$1
|
|
||||||
local name=$2
|
|
||||||
builtin test -f $base_dir/$name.zsh-theme
|
|
||||||
}
|
|
||||||
|
|
||||||
if [[ -n "$ZSH_THEME" ]]; then
|
|
||||||
if is_theme "$ZSH_CUSTOM" "$ZSH_THEME"; then
|
|
||||||
source "$ZSH_CUSTOM/$ZSH_THEME.zsh-theme"
|
|
||||||
elif is_theme "$ZSH_CUSTOM/themes" "$ZSH_THEME"; then
|
|
||||||
source "$ZSH_CUSTOM/themes/$ZSH_THEME.zsh-theme"
|
|
||||||
elif is_theme "$ZSH/themes" "$ZSH_THEME"; then
|
|
||||||
source "$ZSH/themes/$ZSH_THEME.zsh-theme"
|
|
||||||
else
|
|
||||||
echo "[oh-my-zsh] theme '$ZSH_THEME' not found"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
# set completion colors to be the same as `ls`, after theme has been loaded
|
|
||||||
[[ -z "$LS_COLORS" ]] || zstyle ':completion:*' list-colors "${(s.:.)LS_COLORS}"
|
|
||||||
|
|
||||||
## set command line based on terminal
|
|
||||||
if [ $TERM = "xterm-kitty" ] || [ $NVIM ]; then
|
|
||||||
export POSH_SESSION_ID="ee986c09-431b-4113-8916-f671eb8198af";source $'/home/venus/.cache/oh-my-posh/init.15655862796020231344.zsh'
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
# Do nothing if op is not installed
|
|
||||||
(( ${+commands[op]} )) || return
|
|
||||||
|
|
||||||
# If the completion file doesn't exist yet, we need to autoload it and
|
|
||||||
# bind it to `op`. Otherwise, compinit will have already done that.
|
|
||||||
if [[ ! -f "$ZSH_CACHE_DIR/completions/_op" ]]; then
|
|
||||||
typeset -g -A _comps
|
|
||||||
autoload -Uz _op
|
|
||||||
_comps[op]=_op
|
|
||||||
fi
|
|
||||||
|
|
||||||
op completion zsh >| "$ZSH_CACHE_DIR/completions/_op" &|
|
|
||||||
|
|
||||||
# Load opswd function
|
|
||||||
autoload -Uz opswd
|
|
||||||
@@ -1,40 +0,0 @@
|
|||||||
# 1Password
|
|
||||||
|
|
||||||
This plugin adds 1Password functionality to oh-my-zsh.
|
|
||||||
|
|
||||||
To use, add `1password` to the list of plugins in your `.zshrc` file:
|
|
||||||
|
|
||||||
```zsh
|
|
||||||
plugins=(... 1password)
|
|
||||||
```
|
|
||||||
|
|
||||||
Then, you can use the command `opswd` to copy passwords for services into your
|
|
||||||
clipboard.
|
|
||||||
|
|
||||||
## `opswd`
|
|
||||||
|
|
||||||
The `opswd` command is a wrapper around the `op` command. It takes a service
|
|
||||||
name as an argument and copies the username, then the password for that service
|
|
||||||
to the clipboard, after confirmation on the user part.
|
|
||||||
|
|
||||||
If the service also contains a TOTP, it is copied to the clipboard after confirmation
|
|
||||||
on the user part. Finally, after 20 seconds, the clipboard is cleared.
|
|
||||||
|
|
||||||
For example, `opswd github.com` will put your GitHub username into your clipboard. Then,
|
|
||||||
it will ask for confirmation to continue, and copy the password to your clipboard. Finally,
|
|
||||||
if a TOTP is available, it will be copied to the clipboard after your confirmation.
|
|
||||||
|
|
||||||
This function has completion support, so you can use tab completion to select which
|
|
||||||
service you want to get.
|
|
||||||
|
|
||||||
> NOTE: you need to be signed in for `opswd` to work. If you are using biometric unlock,
|
|
||||||
> 1Password CLI will automatically prompt you to sign in. See:
|
|
||||||
>
|
|
||||||
> - [Get started with 1Password CLI 2: Sign in](https://developer.1password.com/docs/cli/get-started#sign-in)
|
|
||||||
> - [Sign in to your 1Password account manually](https://developer.1password.com/docs/cli/sign-in-manually)
|
|
||||||
|
|
||||||
## Requirements
|
|
||||||
|
|
||||||
- [1Password CLI 2](https://developer.1password.com/docs/cli/get-started#install)
|
|
||||||
|
|
||||||
> NOTE: if you're using 1Password CLI 1, [see how to upgrade to CLI 2](https://developer.1password.com/docs/cli/upgrade).
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
#compdef opswd
|
|
||||||
|
|
||||||
function _opswd() {
|
|
||||||
local -a services
|
|
||||||
services=("${(@f)$(op item list --categories Login --cache 2>/dev/null | awk 'NR != 1 { print $2 }')}")
|
|
||||||
[[ -z "$services" ]] || compadd -a -- services
|
|
||||||
}
|
|
||||||
|
|
||||||
_opswd "$@"
|
|
||||||
@@ -1,49 +0,0 @@
|
|||||||
#autoload
|
|
||||||
|
|
||||||
# opswd puts the password of the named service into the clipboard. If there's a
|
|
||||||
# one time password, it will be copied into the clipboard after 10 seconds. The
|
|
||||||
# clipboard is cleared after another 20 seconds.
|
|
||||||
function opswd() {
|
|
||||||
if [[ $# -lt 1 ]]; then
|
|
||||||
echo "Usage: opswd <service>"
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
local service=$1
|
|
||||||
|
|
||||||
# If not logged in, print error and return
|
|
||||||
op user list > /dev/null || return
|
|
||||||
|
|
||||||
local username
|
|
||||||
# Copy the username to the clipboard
|
|
||||||
if ! username=$(op item get "$service" --fields username 2>/dev/null); then
|
|
||||||
echo "error: could not obtain username for $service"
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo -n "$username" | clipcopy
|
|
||||||
echo "✔ username for service $service copied to the clipboard. Press Enter to continue"
|
|
||||||
read
|
|
||||||
|
|
||||||
local password
|
|
||||||
# Copy the password to the clipboard
|
|
||||||
if ! password=$(op item get "$service" --reveal --fields password 2>/dev/null); then
|
|
||||||
echo "error: could not obtain password for $service"
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo -n "$password" | clipcopy
|
|
||||||
echo "✔ password for $service copied to clipboard. Press Enter to continue"
|
|
||||||
read
|
|
||||||
|
|
||||||
# If there's a one time password, copy it to the clipboard
|
|
||||||
local totp
|
|
||||||
if totp=$(op item get --otp "$service" 2>/dev/null) && [[ -n "$totp" ]]; then
|
|
||||||
echo -n "$totp" | clipcopy
|
|
||||||
echo "✔ TOTP for $service copied to clipboard"
|
|
||||||
fi
|
|
||||||
|
|
||||||
(sleep 20 && clipcopy </dev/null 2>/dev/null) &!
|
|
||||||
}
|
|
||||||
|
|
||||||
opswd "$@"
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
tap: false
|
|
||||||
directories:
|
|
||||||
tests: tests
|
|
||||||
output: tests/_output
|
|
||||||
support: tests/_support
|
|
||||||
time_limit: 0
|
|
||||||
fail_fast: false
|
|
||||||
allow_risky: false
|
|
||||||
verbose: true
|
|
||||||
@@ -1,70 +0,0 @@
|
|||||||
# alias-finder plugin
|
|
||||||
|
|
||||||
This plugin searches the defined aliases and outputs any that match the command inputted. This makes learning new aliases easier.
|
|
||||||
|
|
||||||
## Setup
|
|
||||||
|
|
||||||
To use it, add `alias-finder` to the `plugins` array of your zshrc file:
|
|
||||||
```
|
|
||||||
plugins=(... alias-finder)
|
|
||||||
```
|
|
||||||
|
|
||||||
To enable it for every single command, set zstyle in your `~/.zshrc`.
|
|
||||||
|
|
||||||
If the user has installed `rg`([ripgrep](https://github.com/BurntSushi/ripgrep)), it will be used because it's faster. Otherwise, it will use the `grep` command.
|
|
||||||
|
|
||||||
```zsh
|
|
||||||
# ~/.zshrc
|
|
||||||
|
|
||||||
zstyle ':omz:plugins:alias-finder' autoload yes # disabled by default
|
|
||||||
zstyle ':omz:plugins:alias-finder' longer yes # disabled by default
|
|
||||||
zstyle ':omz:plugins:alias-finder' exact yes # disabled by default
|
|
||||||
zstyle ':omz:plugins:alias-finder' cheaper yes # disabled by default
|
|
||||||
```
|
|
||||||
|
|
||||||
As you can see, options are also available with zstyle.
|
|
||||||
|
|
||||||
## Usage
|
|
||||||
|
|
||||||
When you execute a command alias finder will look at your defined aliases and suggest shorter aliases you could have used, for example:
|
|
||||||
|
|
||||||
Running the un-aliased `git status` command:
|
|
||||||
```sh
|
|
||||||
╭─tim@fox ~/repo/gitopolis ‹main›
|
|
||||||
╰─$ git status
|
|
||||||
|
|
||||||
gst='git status' # <=== shorter suggestion from alias-finder
|
|
||||||
|
|
||||||
On branch main
|
|
||||||
Your branch is up-to-date with 'origin/main'.
|
|
||||||
nothing to commit, working tree clean
|
|
||||||
```
|
|
||||||
|
|
||||||
Running a shorter `git st` alias from `.gitconfig` that it suggested :
|
|
||||||
```sh
|
|
||||||
╭─tim@fox ~/repo/gitopolis ‹main›
|
|
||||||
╰─$ git st
|
|
||||||
gs='git st' # <=== shorter suggestion from alias-finder
|
|
||||||
## main...origin/main
|
|
||||||
```
|
|
||||||
|
|
||||||
Running the shortest `gs` shell alias that it found:
|
|
||||||
```sh
|
|
||||||
╭─tim@fox ~/repo/gitopolis ‹main›
|
|
||||||
╰─$ gs
|
|
||||||
# <=== no suggestions alias-finder because this is the shortest
|
|
||||||
## main...origin/main
|
|
||||||
```
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
|
|
||||||
### Options
|
|
||||||
|
|
||||||
> In order to clarify, let's say `alias a=abc` has source 'abc' and destination 'a'.
|
|
||||||
|
|
||||||
- Use `--longer` or `-l` to include aliases where the source is longer than the input (in other words, the source could contain the whole input).
|
|
||||||
- Use `--exact` or `-e` to avoid aliases where the source is shorter than the input (in other words, the source must be the same with the input).
|
|
||||||
- Use `--cheaper` or `-c` to avoid aliases where the destination is longer than the input (in other words, the destination must be the shorter than the input).
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,70 +0,0 @@
|
|||||||
alias-finder() {
|
|
||||||
local cmd=" " exact="" longer="" cheaper="" wordEnd="'{0,1}$" finder="" filter=""
|
|
||||||
|
|
||||||
# build command and options
|
|
||||||
for c in "$@"; do
|
|
||||||
case $c in
|
|
||||||
# TODO: Remove backward compatibility (other than zstyle form)
|
|
||||||
# set options if exist
|
|
||||||
-e|--exact) exact=true;;
|
|
||||||
-l|--longer) longer=true;;
|
|
||||||
-c|--cheaper) cheaper=true;;
|
|
||||||
# concatenate cmd
|
|
||||||
*) cmd="$cmd$c " ;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
|
|
||||||
zstyle -t ':omz:plugins:alias-finder' longer && longer=true
|
|
||||||
zstyle -t ':omz:plugins:alias-finder' exact && exact=true
|
|
||||||
zstyle -t ':omz:plugins:alias-finder' cheaper && cheaper=true
|
|
||||||
|
|
||||||
# format cmd for grep
|
|
||||||
## - replace newlines with spaces
|
|
||||||
## - trim both ends
|
|
||||||
## - replace multiple spaces with one space
|
|
||||||
## - add escaping character to special characters
|
|
||||||
cmd=$(echo -n "$cmd" | tr '\n' ' ' | xargs | tr -s '[:space:]' | sed 's/[].\|$(){}?+*^[]/\\&/g')
|
|
||||||
|
|
||||||
if [[ $longer == true ]]; then
|
|
||||||
wordEnd="" # remove wordEnd to find longer aliases
|
|
||||||
fi
|
|
||||||
|
|
||||||
# find with alias and grep, removing last word each time until no more words
|
|
||||||
while [[ $cmd != "" ]]; do
|
|
||||||
finder="'{0,1}$cmd$wordEnd"
|
|
||||||
|
|
||||||
# make filter to find only shorter results than current cmd
|
|
||||||
if [[ $cheaper == true ]]; then
|
|
||||||
cmdLen=$(echo -n "$cmd" | wc -c)
|
|
||||||
if [[ $cmdLen -le 1 ]]; then
|
|
||||||
return
|
|
||||||
fi
|
|
||||||
|
|
||||||
filter="^'?.{1,$((cmdLen - 1))}'?=" # some aliases is surrounded by single quotes
|
|
||||||
fi
|
|
||||||
|
|
||||||
if (( $+commands[rg] )); then
|
|
||||||
alias | rg "$filter" | rg "=$finder"
|
|
||||||
else
|
|
||||||
alias | grep -E "$filter" | grep -E "=$finder"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ $exact == true ]]; then
|
|
||||||
break # because exact case is only one
|
|
||||||
elif [[ $longer == true ]]; then
|
|
||||||
break # because above grep command already found every longer aliases during first cycle
|
|
||||||
fi
|
|
||||||
|
|
||||||
cmd=$(sed -E 's/ {0,}[^ ]*$//' <<< "$cmd") # remove last word
|
|
||||||
done
|
|
||||||
}
|
|
||||||
|
|
||||||
preexec_alias-finder() {
|
|
||||||
# TODO: Remove backward compatibility (other than zstyle form)
|
|
||||||
zstyle -t ':omz:plugins:alias-finder' autoload && alias-finder $1 || if [[ $ZSH_ALIAS_FINDER_AUTOMATIC = true ]]; then
|
|
||||||
alias-finder $1
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
autoload -U add-zsh-hook
|
|
||||||
add-zsh-hook preexec preexec_alias-finder
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
#!/usr/bin/env zsh
|
|
||||||
# Write your bootstrap code here
|
|
||||||
@@ -1,107 +0,0 @@
|
|||||||
#!/usr/bin/env zunit
|
|
||||||
|
|
||||||
@setup {
|
|
||||||
load ../alias-finder.plugin.zsh
|
|
||||||
|
|
||||||
set_git_aliases() {
|
|
||||||
unalias -a # all
|
|
||||||
alias g="git"
|
|
||||||
alias gc="git commit"
|
|
||||||
alias gcv="git commit -v"
|
|
||||||
alias gcvs="git commit -v -S"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@test 'find aliases that contain input' {
|
|
||||||
set_git_aliases
|
|
||||||
|
|
||||||
run alias-finder "git"
|
|
||||||
|
|
||||||
assert "${#lines[@]}" equals 1
|
|
||||||
assert "${lines[1]}" same_as "g=git"
|
|
||||||
}
|
|
||||||
|
|
||||||
@test 'find aliases that contain input with whitespaces at ends' {
|
|
||||||
set_git_aliases
|
|
||||||
|
|
||||||
run alias-finder " git "
|
|
||||||
|
|
||||||
assert "${#lines[@]}" equals 1
|
|
||||||
assert "${lines[1]}" same_as "g=git"
|
|
||||||
}
|
|
||||||
|
|
||||||
@test 'find aliases that contain multiple words' {
|
|
||||||
set_git_aliases
|
|
||||||
|
|
||||||
run alias-finder "git commit -v"
|
|
||||||
|
|
||||||
assert "${#lines[@]}" equals 3
|
|
||||||
assert "${lines[1]}" same_as "gcv='git commit -v'"
|
|
||||||
assert "${lines[2]}" same_as "gc='git commit'"
|
|
||||||
assert "${lines[3]}" same_as "g=git"
|
|
||||||
}
|
|
||||||
|
|
||||||
@test 'find alias that is the same with input when --exact option is set' {
|
|
||||||
set_git_aliases
|
|
||||||
|
|
||||||
run alias-finder -e "git"
|
|
||||||
|
|
||||||
assert "${#lines[@]}" equals 1
|
|
||||||
assert "${lines[1]}" same_as "g=git"
|
|
||||||
}
|
|
||||||
|
|
||||||
@test 'find alias that is the same with multiple words input when --exact option is set' {
|
|
||||||
set_git_aliases
|
|
||||||
|
|
||||||
run alias-finder -e "git commit -v"
|
|
||||||
|
|
||||||
assert "${#lines[@]}" equals 1
|
|
||||||
assert "${lines[1]}" same_as "gcv='git commit -v'"
|
|
||||||
}
|
|
||||||
|
|
||||||
@test 'find alias that is the same with or longer than input when --longer option is set' {
|
|
||||||
set_git_aliases
|
|
||||||
|
|
||||||
run alias-finder -l "git"
|
|
||||||
|
|
||||||
assert "${#lines[@]}" equals 4
|
|
||||||
assert "${lines[1]}" same_as "g=git"
|
|
||||||
assert "${lines[2]}" same_as "gc='git commit'"
|
|
||||||
assert "${lines[3]}" same_as "gcv='git commit -v'"
|
|
||||||
assert "${lines[4]}" same_as "gcvs='git commit -v -S'"
|
|
||||||
}
|
|
||||||
|
|
||||||
@test 'find alias that is the same with or longer than multiple words input when --longer option is set' {
|
|
||||||
set_git_aliases
|
|
||||||
|
|
||||||
run alias-finder -l "git commit -v"
|
|
||||||
|
|
||||||
assert "${#lines[@]}" equals 2
|
|
||||||
assert "${lines[1]}" same_as "gcv='git commit -v'"
|
|
||||||
assert "${lines[2]}" same_as "gcvs='git commit -v -S'"
|
|
||||||
}
|
|
||||||
|
|
||||||
@test 'find aliases including expensive (longer) than input' {
|
|
||||||
set_git_aliases
|
|
||||||
alias expensiveCommands="git commit"
|
|
||||||
|
|
||||||
run alias-finder "git commit -v"
|
|
||||||
|
|
||||||
assert "${#lines[@]}" equals 4
|
|
||||||
assert "${lines[1]}" same_as "gcv='git commit -v'"
|
|
||||||
assert "${lines[2]}" same_as "expensiveCommands='git commit'"
|
|
||||||
assert "${lines[3]}" same_as "gc='git commit'"
|
|
||||||
assert "${lines[4]}" same_as "g=git"
|
|
||||||
}
|
|
||||||
|
|
||||||
@test 'find aliases excluding expensive (longer) than input when --cheap option is set' {
|
|
||||||
set_git_aliases
|
|
||||||
alias expensiveCommands="git commit"
|
|
||||||
|
|
||||||
run alias-finder -c "git commit -v"
|
|
||||||
|
|
||||||
assert "${#lines[@]}" equals 3
|
|
||||||
assert "${lines[1]}" same_as "gcv='git commit -v'"
|
|
||||||
assert "${lines[2]}" same_as "gc='git commit'"
|
|
||||||
assert "${lines[3]}" same_as "g=git"
|
|
||||||
}
|
|
||||||
1
plugins/aliases/.gitignore
vendored
1
plugins/aliases/.gitignore
vendored
@@ -1 +0,0 @@
|
|||||||
__pycache__
|
|
||||||
@@ -1,28 +0,0 @@
|
|||||||
# Aliases cheatsheet
|
|
||||||
|
|
||||||
With lots of 3rd-party amazing aliases installed, this plugin helps list the shortcuts
|
|
||||||
that are currently available based on the plugins you have enabled.
|
|
||||||
|
|
||||||
To use it, add `aliases` to the plugins array in your zshrc file:
|
|
||||||
|
|
||||||
```zsh
|
|
||||||
plugins=(aliases)
|
|
||||||
```
|
|
||||||
|
|
||||||
Requirements: Python needs to be installed.
|
|
||||||
|
|
||||||
**Maintainer:** [@hqingyi](https://github.com/hqingyi)
|
|
||||||
|
|
||||||
## Usage
|
|
||||||
|
|
||||||
- `als`: show all aliases by group
|
|
||||||
|
|
||||||
- `als -h/--help`: print help message
|
|
||||||
|
|
||||||
- `als <keyword(s)>`: filter and highlight aliases by `<keyword>`
|
|
||||||
|
|
||||||
- `als -g <group>/--group <group>`: show only aliases for group `<group>`. Multiple uses of the flag show all groups
|
|
||||||
|
|
||||||
- `als --groups`: show only group names
|
|
||||||
|
|
||||||

|
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
# Handle $0 according to the standard:
|
|
||||||
# https://zdharma-continuum.github.io/Zsh-100-Commits-Club/Zsh-Plugin-Standard.html
|
|
||||||
0="${${ZERO:-${0:#$ZSH_ARGZERO}}:-${(%):-%N}}"
|
|
||||||
0="${${(M)0:#/*}:-$PWD/$0}"
|
|
||||||
|
|
||||||
eval '
|
|
||||||
function als(){
|
|
||||||
(( $+commands[python3] )) || {
|
|
||||||
echo "[error] No python executable detected"
|
|
||||||
return
|
|
||||||
}
|
|
||||||
alias | python3 "'"${0:h}"'/cheatsheet.py" "$@"
|
|
||||||
}
|
|
||||||
'
|
|
||||||
@@ -1,69 +0,0 @@
|
|||||||
#!/usr/bin/env python3
|
|
||||||
import sys
|
|
||||||
import itertools
|
|
||||||
import termcolor
|
|
||||||
import argparse
|
|
||||||
|
|
||||||
def parse(line):
|
|
||||||
left = line[0:line.find('=')].strip()
|
|
||||||
right = line[line.find('=')+1:].strip('\'"\n ')
|
|
||||||
try:
|
|
||||||
cmd = next(part for part in right.split() if len([char for char in '=<>' if char in part])==0)
|
|
||||||
except StopIteration:
|
|
||||||
cmd = right
|
|
||||||
return (left, right, cmd)
|
|
||||||
|
|
||||||
def cheatsheet(lines):
|
|
||||||
exps = [ parse(line) for line in lines ]
|
|
||||||
exps.sort(key=lambda exp:exp[2])
|
|
||||||
cheatsheet = {'_default': []}
|
|
||||||
for key, group in itertools.groupby(exps, lambda exp:exp[2]):
|
|
||||||
group_list = [ item for item in group ]
|
|
||||||
if len(group_list)==1:
|
|
||||||
target_aliases = cheatsheet['_default']
|
|
||||||
else:
|
|
||||||
if key not in cheatsheet:
|
|
||||||
cheatsheet[key] = []
|
|
||||||
target_aliases = cheatsheet[key]
|
|
||||||
target_aliases.extend(group_list)
|
|
||||||
return cheatsheet
|
|
||||||
|
|
||||||
def pretty_print_group(key, aliases, highlight=None, only_groupname=False):
|
|
||||||
if len(aliases) == 0:
|
|
||||||
return
|
|
||||||
group_hl_formatter = lambda g, hl: termcolor.colored(hl, 'yellow').join([termcolor.colored(part, 'red') for part in ('[%s]' % g).split(hl)])
|
|
||||||
alias_hl_formatter = lambda alias, hl: termcolor.colored(hl, 'yellow').join([termcolor.colored(part, 'green') for part in ('\t%s = %s' % alias[0:2]).split(hl)])
|
|
||||||
group_formatter = lambda g: termcolor.colored('[%s]' % g, 'red')
|
|
||||||
alias_formatter = lambda alias: termcolor.colored('\t%s = %s' % alias[0:2], 'green')
|
|
||||||
if highlight and len(highlight)>0:
|
|
||||||
print (group_hl_formatter(key, highlight))
|
|
||||||
if not only_groupname:
|
|
||||||
print ('\n'.join([alias_hl_formatter(alias, highlight) for alias in aliases]))
|
|
||||||
else:
|
|
||||||
print (group_formatter(key))
|
|
||||||
if not only_groupname:
|
|
||||||
print ('\n'.join([alias_formatter(alias) for alias in aliases]))
|
|
||||||
print ('')
|
|
||||||
|
|
||||||
def pretty_print(cheatsheet, wfilter, group_list=None, groups_only=False):
|
|
||||||
sorted_key = sorted(cheatsheet.keys())
|
|
||||||
for key in sorted_key:
|
|
||||||
if group_list and key not in group_list:
|
|
||||||
continue
|
|
||||||
aliases = cheatsheet.get(key)
|
|
||||||
if not wfilter:
|
|
||||||
pretty_print_group(key, aliases, wfilter, groups_only)
|
|
||||||
else:
|
|
||||||
pretty_print_group(key, [ alias for alias in aliases if alias[0].find(wfilter)>-1 or alias[1].find(wfilter)>-1], wfilter)
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
parser = argparse.ArgumentParser(description="Pretty print aliases.", prog="als")
|
|
||||||
parser.add_argument('filter', nargs="*", metavar="<keyword>", help="search aliases matching keywords")
|
|
||||||
parser.add_argument('-g', '--group', dest="group_list", action='append', help="only print aliases in given groups")
|
|
||||||
parser.add_argument('--groups', dest='groups_only', action='store_true', help="only print alias groups")
|
|
||||||
args = parser.parse_args()
|
|
||||||
|
|
||||||
lines = sys.stdin.readlines()
|
|
||||||
group_list = args.group_list or None
|
|
||||||
wfilter = " ".join(args.filter) or None
|
|
||||||
pretty_print(cheatsheet(lines), wfilter, group_list, args.groups_only)
|
|
||||||
@@ -1,168 +0,0 @@
|
|||||||
# coding: utf-8
|
|
||||||
# Copyright (c) 2008-2011 Volvox Development Team
|
|
||||||
#
|
|
||||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
# of this software and associated documentation files (the "Software"), to deal
|
|
||||||
# in the Software without restriction, including without limitation the rights
|
|
||||||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
# copies of the Software, and to permit persons to whom the Software is
|
|
||||||
# furnished to do so, subject to the following conditions:
|
|
||||||
#
|
|
||||||
# The above copyright notice and this permission notice shall be included in
|
|
||||||
# all copies or substantial portions of the Software.
|
|
||||||
#
|
|
||||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
||||||
# THE SOFTWARE.
|
|
||||||
#
|
|
||||||
# Author: Konstantin Lepa <konstantin.lepa@gmail.com>
|
|
||||||
|
|
||||||
"""ANSI Color formatting for output in terminal."""
|
|
||||||
|
|
||||||
from __future__ import print_function
|
|
||||||
import os
|
|
||||||
|
|
||||||
|
|
||||||
__ALL__ = [ 'colored', 'cprint' ]
|
|
||||||
|
|
||||||
VERSION = (1, 1, 0)
|
|
||||||
|
|
||||||
ATTRIBUTES = dict(
|
|
||||||
list(zip([
|
|
||||||
'bold',
|
|
||||||
'dark',
|
|
||||||
'',
|
|
||||||
'underline',
|
|
||||||
'blink',
|
|
||||||
'',
|
|
||||||
'reverse',
|
|
||||||
'concealed'
|
|
||||||
],
|
|
||||||
list(range(1, 9))
|
|
||||||
))
|
|
||||||
)
|
|
||||||
del ATTRIBUTES['']
|
|
||||||
|
|
||||||
|
|
||||||
HIGHLIGHTS = dict(
|
|
||||||
list(zip([
|
|
||||||
'on_grey',
|
|
||||||
'on_red',
|
|
||||||
'on_green',
|
|
||||||
'on_yellow',
|
|
||||||
'on_blue',
|
|
||||||
'on_magenta',
|
|
||||||
'on_cyan',
|
|
||||||
'on_white'
|
|
||||||
],
|
|
||||||
list(range(40, 48))
|
|
||||||
))
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
COLORS = dict(
|
|
||||||
list(zip([
|
|
||||||
'grey',
|
|
||||||
'red',
|
|
||||||
'green',
|
|
||||||
'yellow',
|
|
||||||
'blue',
|
|
||||||
'magenta',
|
|
||||||
'cyan',
|
|
||||||
'white',
|
|
||||||
],
|
|
||||||
list(range(30, 38))
|
|
||||||
))
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
RESET = '\033[0m'
|
|
||||||
|
|
||||||
|
|
||||||
def colored(text, color=None, on_color=None, attrs=None):
|
|
||||||
"""Colorize text.
|
|
||||||
|
|
||||||
Available text colors:
|
|
||||||
red, green, yellow, blue, magenta, cyan, white.
|
|
||||||
|
|
||||||
Available text highlights:
|
|
||||||
on_red, on_green, on_yellow, on_blue, on_magenta, on_cyan, on_white.
|
|
||||||
|
|
||||||
Available attributes:
|
|
||||||
bold, dark, underline, blink, reverse, concealed.
|
|
||||||
|
|
||||||
Example:
|
|
||||||
colored('Hello, World!', 'red', 'on_grey', ['blue', 'blink'])
|
|
||||||
colored('Hello, World!', 'green')
|
|
||||||
"""
|
|
||||||
if os.getenv('ANSI_COLORS_DISABLED') is None:
|
|
||||||
fmt_str = '\033[%dm%s'
|
|
||||||
if color is not None:
|
|
||||||
text = fmt_str % (COLORS[color], text)
|
|
||||||
|
|
||||||
if on_color is not None:
|
|
||||||
text = fmt_str % (HIGHLIGHTS[on_color], text)
|
|
||||||
|
|
||||||
if attrs is not None:
|
|
||||||
for attr in attrs:
|
|
||||||
text = fmt_str % (ATTRIBUTES[attr], text)
|
|
||||||
|
|
||||||
text += RESET
|
|
||||||
return text
|
|
||||||
|
|
||||||
|
|
||||||
def cprint(text, color=None, on_color=None, attrs=None, **kwargs):
|
|
||||||
"""Print colorize text.
|
|
||||||
|
|
||||||
It accepts arguments of print function.
|
|
||||||
"""
|
|
||||||
|
|
||||||
print((colored(text, color, on_color, attrs)), **kwargs)
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
print('Current terminal type: %s' % os.getenv('TERM'))
|
|
||||||
print('Test basic colors:')
|
|
||||||
cprint('Grey color', 'grey')
|
|
||||||
cprint('Red color', 'red')
|
|
||||||
cprint('Green color', 'green')
|
|
||||||
cprint('Yellow color', 'yellow')
|
|
||||||
cprint('Blue color', 'blue')
|
|
||||||
cprint('Magenta color', 'magenta')
|
|
||||||
cprint('Cyan color', 'cyan')
|
|
||||||
cprint('White color', 'white')
|
|
||||||
print(('-' * 78))
|
|
||||||
|
|
||||||
print('Test highlights:')
|
|
||||||
cprint('On grey color', on_color='on_grey')
|
|
||||||
cprint('On red color', on_color='on_red')
|
|
||||||
cprint('On green color', on_color='on_green')
|
|
||||||
cprint('On yellow color', on_color='on_yellow')
|
|
||||||
cprint('On blue color', on_color='on_blue')
|
|
||||||
cprint('On magenta color', on_color='on_magenta')
|
|
||||||
cprint('On cyan color', on_color='on_cyan')
|
|
||||||
cprint('On white color', color='grey', on_color='on_white')
|
|
||||||
print('-' * 78)
|
|
||||||
|
|
||||||
print('Test attributes:')
|
|
||||||
cprint('Bold grey color', 'grey', attrs=['bold'])
|
|
||||||
cprint('Dark red color', 'red', attrs=['dark'])
|
|
||||||
cprint('Underline green color', 'green', attrs=['underline'])
|
|
||||||
cprint('Blink yellow color', 'yellow', attrs=['blink'])
|
|
||||||
cprint('Reversed blue color', 'blue', attrs=['reverse'])
|
|
||||||
cprint('Concealed Magenta color', 'magenta', attrs=['concealed'])
|
|
||||||
cprint('Bold underline reverse cyan color', 'cyan',
|
|
||||||
attrs=['bold', 'underline', 'reverse'])
|
|
||||||
cprint('Dark blink concealed white color', 'white',
|
|
||||||
attrs=['dark', 'blink', 'concealed'])
|
|
||||||
print(('-' * 78))
|
|
||||||
|
|
||||||
print('Test mixing:')
|
|
||||||
cprint('Underline red on grey color', 'red', 'on_grey',
|
|
||||||
['underline'])
|
|
||||||
cprint('Reversed green on red color', 'green', 'on_red', ['reverse'])
|
|
||||||
|
|
||||||
@@ -1,31 +0,0 @@
|
|||||||
# ansible plugin
|
|
||||||
|
|
||||||
The `ansible plugin` adds several aliases for useful [ansible](https://docs.ansible.com/ansible/latest/index.html) commands and [aliases](#aliases).
|
|
||||||
|
|
||||||
To use it, add `ansible` to the plugins array of your zshrc file:
|
|
||||||
|
|
||||||
```
|
|
||||||
plugins=(... ansible)
|
|
||||||
```
|
|
||||||
|
|
||||||
## Aliases
|
|
||||||
|
|
||||||
| Command | Description |
|
|
||||||
|:-------------------------------------------|:--------------------------------------------------------------------|
|
|
||||||
| `ansible-version` / `aver` | Show the version on ansible installed in this host |
|
|
||||||
| `ansible-role-init <role name>` / `arinit` | Creates the Ansible Role as per Ansible Galaxy standard |
|
|
||||||
| `a` | command `ansible` |
|
|
||||||
| `aconf` | command `ansible-config` |
|
|
||||||
| `acon` | command `ansible-console` |
|
|
||||||
| `ainv` | command `ansible-inventory` |
|
|
||||||
| `aplaybook` | command `ansible-playbook` |
|
|
||||||
| `adoc` | command `ansible-doc` |
|
|
||||||
| `agal` | command `ansible-galaxy` |
|
|
||||||
| `apull` | command `ansible-pull` |
|
|
||||||
| `aval` | command `ansible-vault` |
|
|
||||||
|
|
||||||
## Maintainer
|
|
||||||
|
|
||||||
### [Deepankumar](https://github.com/deepan10)
|
|
||||||
|
|
||||||
[https://github.com/deepan10/oh-my-zsh/tree/features/ansible-plugin](https://github.com/deepan10/oh-my-zsh/tree/features/ansible-plugin)
|
|
||||||
@@ -1,28 +0,0 @@
|
|||||||
# Functions
|
|
||||||
function ansible-version(){
|
|
||||||
ansible --version
|
|
||||||
}
|
|
||||||
|
|
||||||
function ansible-role-init(){
|
|
||||||
if ! [ -z $1 ] ; then
|
|
||||||
echo "Ansible Role : $1 Creating...."
|
|
||||||
ansible-galaxy init $1
|
|
||||||
tree $1
|
|
||||||
else
|
|
||||||
echo "Usage : ansible-role-init <role name>"
|
|
||||||
echo "Example : ansible-role-init role1"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
# Alias
|
|
||||||
alias a='ansible '
|
|
||||||
alias aconf='ansible-config '
|
|
||||||
alias acon='ansible-console '
|
|
||||||
alias aver='ansible-version'
|
|
||||||
alias arinit='ansible-role-init'
|
|
||||||
alias aplaybook='ansible-playbook '
|
|
||||||
alias ainv='ansible-inventory '
|
|
||||||
alias adoc='ansible-doc '
|
|
||||||
alias agal='ansible-galaxy '
|
|
||||||
alias apull='ansible-pull '
|
|
||||||
alias aval='ansible-vault'
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
# Ant
|
|
||||||
|
|
||||||
This plugin provides completion for [Ant](https://ant.apache.org/).
|
|
||||||
|
|
||||||
To use it, add `ant` to the plugins array in your zshrc file:
|
|
||||||
|
|
||||||
```zsh
|
|
||||||
plugins=(... ant)
|
|
||||||
```
|
|
||||||
|
|
||||||
It caches ant targets in a file named `.ant_targets`, you might want to add that to
|
|
||||||
your `.gitignore` file.
|
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
#compdef ant
|
|
||||||
|
|
||||||
_ant_does_target_list_need_generating () {
|
|
||||||
[[ ! -f .ant_targets ]] && return 0
|
|
||||||
[[ build.xml -nt .ant_targets ]] && return 0
|
|
||||||
return 1
|
|
||||||
}
|
|
||||||
|
|
||||||
_ant () {
|
|
||||||
if [[ ! -f build.xml ]]; then
|
|
||||||
return
|
|
||||||
fi
|
|
||||||
|
|
||||||
if ! _ant_does_target_list_need_generating; then
|
|
||||||
return
|
|
||||||
fi
|
|
||||||
|
|
||||||
ant -p | awk -F " " 'NR > 5 { print lastTarget } { lastTarget = $1 }' >| .ant_targets
|
|
||||||
compadd -- "$(cat .ant_targets)"
|
|
||||||
}
|
|
||||||
|
|
||||||
_ant "$@"
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
# Default to colored output
|
|
||||||
export ANT_ARGS='-logger org.apache.tools.ant.listener.AnsiColorLogger'
|
|
||||||
@@ -1,21 +0,0 @@
|
|||||||
# 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:
|
|
||||||
|
|
||||||
```zsh
|
|
||||||
plugins=(... apache2-macports)
|
|
||||||
```
|
|
||||||
|
|
||||||
## Aliases
|
|
||||||
|
|
||||||
| 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
|
|
||||||
|
|
||||||
- Alexander Rinass (alex@rinass.net)
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
# commands to control local apache2 server installation
|
|
||||||
# paths are for osx installation via macports
|
|
||||||
|
|
||||||
alias apache2start='sudo /opt/local/etc/LaunchDaemons/org.macports.apache2/apache2.wrapper start'
|
|
||||||
alias apache2stop='sudo /opt/local/etc/LaunchDaemons/org.macports.apache2/apache2.wrapper stop'
|
|
||||||
alias apache2restart='sudo /opt/local/etc/LaunchDaemons/org.macports.apache2/apache2.wrapper restart'
|
|
||||||
@@ -1,43 +0,0 @@
|
|||||||
## arcanist
|
|
||||||
|
|
||||||
This plugin adds many useful aliases for [arcanist](https://github.com/phacility/arcanist).
|
|
||||||
|
|
||||||
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` |
|
|
||||||
| arbl | `arc bland` |
|
|
||||||
| 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` |
|
|
||||||
| arho | `arc hotfix` |
|
|
||||||
| 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] |
|
|
||||||
@@ -1,39 +0,0 @@
|
|||||||
#
|
|
||||||
# Aliases
|
|
||||||
# (sorted alphabetically)
|
|
||||||
#
|
|
||||||
|
|
||||||
alias ara='arc amend'
|
|
||||||
alias arb='arc branch'
|
|
||||||
alias arbl='arc bland'
|
|
||||||
alias arco='arc cover'
|
|
||||||
alias arci='arc commit'
|
|
||||||
|
|
||||||
alias ard='arc diff'
|
|
||||||
alias ardc='arc diff --create'
|
|
||||||
alias ardnu='arc diff --nounit'
|
|
||||||
alias ardnupc='arc diff --nounit --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 arh='arc help'
|
|
||||||
alias arho='arc hotfix'
|
|
||||||
alias arl='arc land'
|
|
||||||
alias arli='arc lint'
|
|
||||||
alias arls='arc list'
|
|
||||||
|
|
||||||
#
|
|
||||||
# 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}"
|
|
||||||
}
|
|
||||||
@@ -1,184 +0,0 @@
|
|||||||
# 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
|
|
||||||
|
|
||||||
### Pacman
|
|
||||||
|
|
||||||
| Alias | Command | Description |
|
|
||||||
|--------------|----------------------------------------|------------------------------------------------------------------|
|
|
||||||
| pacin | `sudo pacman -S` | Install packages from the repositories |
|
|
||||||
| pacins | `sudo pacman -U` | Install a package from a local file |
|
|
||||||
| pacinsd | `sudo pacman -S --asdeps` | Install packages as dependencies of another package |
|
|
||||||
| paclean | `sudo pacman -Sc` | Clean out old and unused caches and packages |
|
|
||||||
| pacloc | `pacman -Qi` | Display information about a package in the local database |
|
|
||||||
| paclocs | `pacman -Qs` | Search for packages in the local database |
|
|
||||||
| paclr | `sudo pacman -Scc` | Remove all files from the cache |
|
|
||||||
| paclsorphans | `sudo pacman -Qdt` | List all orphaned packages |
|
|
||||||
| pacmir | `sudo pacman -Syy` | Force refresh of all package lists after updating mirrorlist |
|
|
||||||
| pacre | `sudo pacman -R` | Remove packages, keeping its settings and dependencies |
|
|
||||||
| pacrem | `sudo pacman -Rns` | Remove packages, including its settings and dependencies |
|
|
||||||
| pacrep | `pacman -Si` | Display information about a package in the repositories |
|
|
||||||
| pacreps | `pacman -Ss` | Search for packages in the repositories |
|
|
||||||
| pacrmorphans | `sudo pacman -Rs $(pacman -Qtdq)` | Delete all orphaned packages |
|
|
||||||
| pacupd | `sudo pacman -Sy` | Update and refresh local package, ABS and AUR databases |
|
|
||||||
| pacupg | `sudo pacman -Syu` | Sync with repositories before upgrading packages |
|
|
||||||
| 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[¹](#f1) | `sudo pacman -Syu` | Sync with repositories before upgrading packages |
|
|
||||||
|
|
||||||
| 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 |
|
|
||||||
|
|
||||||
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
|
|
||||||
upgrades were available. Use `pacman -Que` instead.
|
|
||||||
|
|
||||||
### AUR helpers
|
|
||||||
|
|
||||||
#### Aura
|
|
||||||
|
|
||||||
| Alias | Command | Description |
|
|
||||||
|---------|-------------------------------------------------|-------------------------------------------------------------------------|
|
|
||||||
| auclean | `sudo aura -Sc` | Clean out old and unused caches and packages |
|
|
||||||
| auclr | `sudo aura -Scc` | Remove all files from the cache |
|
|
||||||
| 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[¹](#f1) | `sudo aura -Syu` | Sync with repositories before upgrading packages |
|
|
||||||
|
|
||||||
| Function | Description |
|
|
||||||
|-----------------|---------------------------------------------------------------------|
|
|
||||||
| auownloc _file_ | Display information about a package that owns the specified file(s) |
|
|
||||||
| auownls _file_ | List all files owned by a package that owns the specified file(s) |
|
|
||||||
|
|
||||||
#### Pacaur
|
|
||||||
|
|
||||||
| Alias | Command | Description |
|
|
||||||
|---------|-----------------------------------|---------------------------------------------------------------------|
|
|
||||||
| pacclean| `pacaur -Sc` | Clean out old and unused caches and packages |
|
|
||||||
| pacclr | `pacaur -Scc` | Remove all files from the cache |
|
|
||||||
| pain | `pacaur -S` | Install packages from the repositories |
|
|
||||||
| pains | `pacaur -U` | Install a package from a local file |
|
|
||||||
| 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` | Update and refresh local package, ABS and AUR databases |
|
|
||||||
| 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[¹](#f1) | `pacaur -Syu` | Sync with repositories before upgrading packages |
|
|
||||||
|
|
||||||
#### Trizen
|
|
||||||
|
|
||||||
| Alias | Command | Description |
|
|
||||||
|---------|-----------------------------------|---------------------------------------------------------------------|
|
|
||||||
| trconf | `trizen -C` | Fix all configuration files with vimdiff |
|
|
||||||
| trclean | `trizen -Sc` | Clean out old and unused caches and packages |
|
|
||||||
| trclr | `trizen -Scc` | Remove all files from the cache |
|
|
||||||
| 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` | 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[¹](#f1) | `trizen -Syu` | Sync with repositories before upgrading packages |
|
|
||||||
|
|
||||||
#### Yay
|
|
||||||
|
|
||||||
| Alias | Command | Description |
|
|
||||||
|---------|--------------------------------|-------------------------------------------------------------------|
|
|
||||||
| yaconf | `yay -Pg` | Print current configuration |
|
|
||||||
| yaclean | `yay -Sc` | Clean out old and unused caches and packages |
|
|
||||||
| yaclr | `yay -Scc` | Remove all files from the cache |
|
|
||||||
| 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[¹](#f1) | `yay -Syu` | Sync with repositories before upgrading packages |
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
<span id="f1">¹</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. `trizen`
|
|
||||||
3. `pacaur`
|
|
||||||
4. `aura`
|
|
||||||
5. `pacman`
|
|
||||||
|
|
||||||
## Contributors
|
|
||||||
|
|
||||||
- Benjamin Boudreau - dreurmail@gmail.com
|
|
||||||
- Celso Miranda - contacto@celsomiranda.net
|
|
||||||
- ratijas (ivan tkachenko) - me@ratijas.tk
|
|
||||||
- Juraj Fiala - doctorjellyface@riseup.net
|
|
||||||
- KhasMek - Boushh@gmail.com
|
|
||||||
- Majora320 (Moses Miller) - Majora320@gmail.com
|
|
||||||
- Martin Putniorz - mputniorz@gmail.com
|
|
||||||
- MatthR3D - matthr3d@gmail.com
|
|
||||||
- ornicar - thibault.duplessis@gmail.com
|
|
||||||
- Ybalrid (Arthur Brainville) - ybalrid@ybalrid.info
|
|
||||||
- Jeff M. Hubbard - jeffmhubbard@gmail.com
|
|
||||||
- K. Harishankar(harishnkr) - hari2menon1234@gmail.com
|
|
||||||
- WH-2099 - wh2099@outlook.com
|
|
||||||
@@ -1,204 +0,0 @@
|
|||||||
#######################################
|
|
||||||
# Pacman #
|
|
||||||
#######################################
|
|
||||||
|
|
||||||
# Pacman - https://wiki.archlinux.org/index.php/Pacman_Tips
|
|
||||||
alias pacupg='sudo pacman -Syu'
|
|
||||||
alias pacin='sudo pacman -S'
|
|
||||||
alias paclean='sudo pacman -Sc'
|
|
||||||
alias pacins='sudo pacman -U'
|
|
||||||
alias paclr='sudo pacman -Scc'
|
|
||||||
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"
|
|
||||||
|
|
||||||
function paclist() {
|
|
||||||
pacman -Qqe | xargs -I{} -P0 --no-run-if-empty pacman -Qs --color=auto "^{}\$"
|
|
||||||
}
|
|
||||||
|
|
||||||
function pacdisowned() {
|
|
||||||
local tmp_dir db fs
|
|
||||||
tmp_dir=$(mktemp --directory)
|
|
||||||
db=$tmp_dir/db
|
|
||||||
fs=$tmp_dir/fs
|
|
||||||
|
|
||||||
trap "rm -rf $tmp_dir" EXIT
|
|
||||||
|
|
||||||
pacman -Qlq | sort -u > "$db"
|
|
||||||
|
|
||||||
find /etc /usr ! -name lost+found \
|
|
||||||
\( -type d -printf '%p/\n' -o -print \) | sort > "$fs"
|
|
||||||
|
|
||||||
comm -23 "$fs" "$db"
|
|
||||||
|
|
||||||
rm -rf $tmp_dir
|
|
||||||
}
|
|
||||||
|
|
||||||
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 auclean='sudo aura -Sc'
|
|
||||||
alias auclr='sudo aura -Scc'
|
|
||||||
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"'
|
|
||||||
|
|
||||||
# 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 pacclean='pacaur -Sc'
|
|
||||||
alias pacclr='pacaur -Scc'
|
|
||||||
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"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if (( $+commands[trizen] )); then
|
|
||||||
alias trconf='trizen -C'
|
|
||||||
alias trupg='trizen -Syua'
|
|
||||||
alias trsu='trizen -Syua --noconfirm'
|
|
||||||
alias trin='trizen -S'
|
|
||||||
alias trclean='trizen -Sc'
|
|
||||||
alias trclr='trizen -Scc'
|
|
||||||
alias trins='trizen -U'
|
|
||||||
alias trre='trizen -R'
|
|
||||||
alias trrem='trizen -Rns'
|
|
||||||
alias trrep='trizen -Si'
|
|
||||||
alias trreps='trizen -Ss'
|
|
||||||
alias trloc='trizen -Qi'
|
|
||||||
alias trlocs='trizen -Qs'
|
|
||||||
alias trlst='trizen -Qe'
|
|
||||||
alias trorph='trizen -Qtd'
|
|
||||||
alias trinsd='trizen -S --asdeps'
|
|
||||||
alias trmir='trizen -Syy'
|
|
||||||
alias trupd="trizen -Sy"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if (( $+commands[yay] )); then
|
|
||||||
alias yaconf='yay -Pg'
|
|
||||||
alias yaclean='yay -Sc'
|
|
||||||
alias yaclr='yay -Scc'
|
|
||||||
alias yaupg='yay -Syu'
|
|
||||||
alias yasu='yay -Syu --noconfirm'
|
|
||||||
alias yain='yay -S'
|
|
||||||
alias yains='yay -U'
|
|
||||||
alias yare='yay -R'
|
|
||||||
alias yarem='yay -Rns'
|
|
||||||
alias yarep='yay -Si'
|
|
||||||
alias yareps='yay -Ss'
|
|
||||||
alias yaloc='yay -Qi'
|
|
||||||
alias yalocs='yay -Qs'
|
|
||||||
alias yalst='yay -Qe'
|
|
||||||
alias yaorph='yay -Qtd'
|
|
||||||
alias yainsd='yay -S --asdeps'
|
|
||||||
alias yamir='yay -Syy'
|
|
||||||
alias yaupd="yay -Sy"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Check Arch Linux PGP Keyring before System Upgrade to prevent failure.
|
|
||||||
function upgrade() {
|
|
||||||
sudo pacman -Sy
|
|
||||||
echo ":: Checking Arch Linux PGP Keyring..."
|
|
||||||
local installedver="$(LANG= sudo pacman -Qi archlinux-keyring | grep -Po '(?<=Version : ).*')"
|
|
||||||
local currentver="$(LANG= sudo pacman -Si archlinux-keyring | grep -Po '(?<=Version : ).*')"
|
|
||||||
if [ $installedver != $currentver ]; then
|
|
||||||
echo " Arch Linux PGP Keyring is out of date."
|
|
||||||
echo " Updating before full system upgrade."
|
|
||||||
sudo pacman -S --needed --noconfirm archlinux-keyring
|
|
||||||
else
|
|
||||||
echo " Arch Linux PGP Keyring is up to date."
|
|
||||||
echo " Proceeding with full system upgrade."
|
|
||||||
fi
|
|
||||||
if (( $+commands[yay] )); then
|
|
||||||
yay -Su
|
|
||||||
elif (( $+commands[trizen] )); then
|
|
||||||
trizen -Su
|
|
||||||
elif (( $+commands[pacaur] )); then
|
|
||||||
pacaur -Su
|
|
||||||
elif (( $+commands[aura] )); then
|
|
||||||
sudo aura -Su
|
|
||||||
else
|
|
||||||
sudo pacman -Su
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
# Arduino CLI plugin
|
|
||||||
|
|
||||||
This plugin adds completion for the [arduino-cli](https://github.com/arduino/arduino-cli) tool.
|
|
||||||
|
|
||||||
To use it, add `arduino-cli` to the plugins array in your zshrc file:
|
|
||||||
|
|
||||||
```zsh
|
|
||||||
plugins=(... arduino-cli)
|
|
||||||
```
|
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
if (( ! $+commands[arduino-cli] )); then
|
|
||||||
return
|
|
||||||
fi
|
|
||||||
|
|
||||||
# If the completion file doesn't exist yet, we need to autoload it and
|
|
||||||
# bind it to `arduino-cli`. Otherwise, compinit will have already done that.
|
|
||||||
if [[ ! -f "$ZSH_CACHE_DIR/completions/_arduino-cli" ]]; then
|
|
||||||
typeset -g -A _comps
|
|
||||||
autoload -Uz _arduino-cli
|
|
||||||
_comps[arduino-cli]=_arduino-cli
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Generate and load arduino-cli completion
|
|
||||||
arduino-cli completion zsh >! "$ZSH_CACHE_DIR/completions/_arduino-cli" &|
|
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
# Argo CD plugin
|
|
||||||
|
|
||||||
This plugin adds completion for the [Argo CD](https://argoproj.github.io/cd/) CLI.
|
|
||||||
|
|
||||||
To use it, add `argocd` to the plugins array in your zshrc file:
|
|
||||||
|
|
||||||
```zsh
|
|
||||||
plugins=(... argocd)
|
|
||||||
```
|
|
||||||
|
|
||||||
This plugin does not add any aliases.
|
|
||||||
|
|
||||||
## Cache
|
|
||||||
|
|
||||||
This plugin caches the completion script and is automatically updated asynchronously when the plugin is
|
|
||||||
loaded, which is usually when you start up a new terminal emulator.
|
|
||||||
|
|
||||||
The cache is stored at:
|
|
||||||
|
|
||||||
- `$ZSH_CACHE/completions/_argocd` completions script
|
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
# Autocompletion for argocd.
|
|
||||||
if (( ! $+commands[argocd] )); then
|
|
||||||
return
|
|
||||||
fi
|
|
||||||
|
|
||||||
# If the completion file doesn't exist yet, we need to autoload it and
|
|
||||||
# bind it to `argocd`. Otherwise, compinit will have already done that.
|
|
||||||
if [[ ! -f "$ZSH_CACHE_DIR/completions/_argocd" ]]; then
|
|
||||||
typeset -g -A _comps
|
|
||||||
autoload -Uz _argocd
|
|
||||||
_comps[argocd]=_argocd
|
|
||||||
fi
|
|
||||||
|
|
||||||
argocd completion zsh >| "$ZSH_CACHE_DIR/completions/_argocd" &|
|
|
||||||
@@ -1,48 +0,0 @@
|
|||||||
# asdf
|
|
||||||
|
|
||||||
Adds integration with [asdf](https://github.com/asdf-vm/asdf), the extendable version manager, with support for Ruby, Node.js, Elixir, Erlang and more.
|
|
||||||
|
|
||||||
## Installation
|
|
||||||
|
|
||||||
1. [Install](https://asdf-vm.com/guide/getting-started.html#_1-install-asdf) asdf and ensure that's it's discoverable on `$PATH`;
|
|
||||||
2. Enable it by adding it to your `plugins` definition in `~/.zshrc`:
|
|
||||||
|
|
||||||
```sh
|
|
||||||
plugins=(asdf)
|
|
||||||
```
|
|
||||||
|
|
||||||
## Usage
|
|
||||||
|
|
||||||
Refer to the [asdf plugin documentation](https://asdf-vm.com/guide/getting-started.html#_4-install-a-plugin) for information on how to add a plugin and install the many runtime versions for it.
|
|
||||||
|
|
||||||
Example for installing the nodejs plugin and the many runtimes for it:
|
|
||||||
|
|
||||||
```sh
|
|
||||||
# Add plugin to asdf
|
|
||||||
asdf plugin add nodejs
|
|
||||||
|
|
||||||
# Install the latest available version
|
|
||||||
asdf install nodejs latest
|
|
||||||
|
|
||||||
# Uninstall the latest version
|
|
||||||
asdf uninstall nodejs latest
|
|
||||||
|
|
||||||
# Install a specific version
|
|
||||||
asdf install nodejs 16.5.0
|
|
||||||
|
|
||||||
# Set the latest version in .tool-versions of the `current directory`
|
|
||||||
asdf set nodejs latest
|
|
||||||
|
|
||||||
# Set a specific version in the `parent directory`
|
|
||||||
asdf set -p nodejs 16.5.0 # -p is shorthand for --parent
|
|
||||||
|
|
||||||
# Set a global version under `$HOME`
|
|
||||||
asdf set -u nodejs 16.5.0 # -u is shorthand for --home
|
|
||||||
```
|
|
||||||
|
|
||||||
For more commands, run `asdf help` or refer to the
|
|
||||||
[asdf CLI documentation](https://asdf-vm.com/manage/commands.html#all-commands).
|
|
||||||
|
|
||||||
## Maintainer
|
|
||||||
|
|
||||||
- [@RobLoach](https://github.com/RobLoach)
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
(( ! $+commands[asdf] )) && return
|
|
||||||
|
|
||||||
export ASDF_DATA_DIR="${ASDF_DATA_DIR:-$HOME/.asdf}"
|
|
||||||
|
|
||||||
# Add shims to the front of the path, removing if already present.
|
|
||||||
path=("$ASDF_DATA_DIR/shims" ${path:#$ASDF_DATA_DIR/shims})
|
|
||||||
|
|
||||||
# If the completion file doesn't exist yet, we need to autoload it and
|
|
||||||
# bind it to `asdf`. Otherwise, compinit will have already done that.
|
|
||||||
if [[ ! -f "$ZSH_CACHE_DIR/completions/_asdf" ]]; then
|
|
||||||
typeset -g -A _comps
|
|
||||||
autoload -Uz _asdf
|
|
||||||
_comps[asdf]=_asdf
|
|
||||||
fi
|
|
||||||
asdf completion zsh >| "$ZSH_CACHE_DIR/completions/_asdf" &|
|
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
# 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).
|
|
||||||
@@ -1,80 +0,0 @@
|
|||||||
# Initialization: activate autoenv or report its absence
|
|
||||||
() {
|
|
||||||
local d autoenv_dir install_locations
|
|
||||||
if ! type autoenv_init >/dev/null; then
|
|
||||||
# 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
|
|
||||||
/opt/homebrew/opt/autoenv
|
|
||||||
/usr/local/bin
|
|
||||||
/usr/share/autoenv-git
|
|
||||||
~/Library/Python/bin
|
|
||||||
.venv/bin
|
|
||||||
venv/bin
|
|
||||||
env/bin
|
|
||||||
.env/bin
|
|
||||||
)
|
|
||||||
for d ( $install_locations ); do
|
|
||||||
if [[ -e $d/activate || -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 || -e $d/activate.sh ]]; then
|
|
||||||
autoenv_dir=$d
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Complain if autoenv is not installed
|
|
||||||
if [[ -z $autoenv_dir ]]; then
|
|
||||||
cat <<END >&2
|
|
||||||
-------- AUTOENV ---------
|
|
||||||
Could not locate autoenv installation.
|
|
||||||
Please check if autoenv is correctly installed.
|
|
||||||
In the meantime the autoenv plugin is DISABLED.
|
|
||||||
--------------------------
|
|
||||||
END
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
# Load autoenv
|
|
||||||
if [[ -e $autoenv_dir/activate ]]; then
|
|
||||||
source $autoenv_dir/activate
|
|
||||||
else
|
|
||||||
source $autoenv_dir/activate.sh
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
[[ $? != 0 ]] && return $?
|
|
||||||
|
|
||||||
# The use_env call below is a reusable command to activate/create a new Python
|
|
||||||
# virtualenv, requiring only a single declarative line of code in your .env files.
|
|
||||||
# It only performs an action if the requested virtualenv is not the current one.
|
|
||||||
|
|
||||||
use_env() {
|
|
||||||
local venv
|
|
||||||
venv="$1"
|
|
||||||
if [[ "${VIRTUAL_ENV:t}" != "$venv" ]]; then
|
|
||||||
if workon | grep -q "$venv"; then
|
|
||||||
workon "$venv"
|
|
||||||
else
|
|
||||||
echo -n "Create virtualenv $venv now? (Yn) "
|
|
||||||
read answer
|
|
||||||
if [[ "$answer" == "Y" ]]; then
|
|
||||||
mkvirtualenv "$venv"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
# Autojump plugin
|
|
||||||
|
|
||||||
This plugin loads the [autojump navigation tool](https://github.com/wting/autojump).
|
|
||||||
|
|
||||||
To use it, add `autojump` to the plugins array in your zshrc file:
|
|
||||||
|
|
||||||
```zsh
|
|
||||||
plugins=(... autojump)
|
|
||||||
```
|
|
||||||
|
|
||||||
**Note:** you have to [install autojump](https://github.com/wting/autojump#installation) first.
|
|
||||||
@@ -1,41 +0,0 @@
|
|||||||
declare -a autojump_paths
|
|
||||||
autojump_paths=(
|
|
||||||
$HOME/.autojump/etc/profile.d/autojump.zsh # manual installation
|
|
||||||
$HOME/.autojump/share/autojump/autojump.zsh # manual installation
|
|
||||||
$HOME/.nix-profile/etc/profile.d/autojump.sh # NixOS installation
|
|
||||||
/run/current-system/sw/share/autojump/autojump.zsh # NixOS installation
|
|
||||||
/etc/profiles/per-user/$USER/share/autojump/autojump.zsh # Home Manager, NixOS with user-scoped packages
|
|
||||||
/usr/share/autojump/autojump.zsh # Debian and Ubuntu package
|
|
||||||
$PREFIX/share/autojump/autojump.zsh # Termux package
|
|
||||||
/etc/profile.d/autojump.zsh # manual installation
|
|
||||||
/etc/profile.d/autojump.sh # Gentoo installation
|
|
||||||
/usr/local/share/autojump/autojump.zsh # FreeBSD installation
|
|
||||||
/usr/pkg/share/autojump/autojump.zsh # NetBSD installation
|
|
||||||
/opt/local/etc/profile.d/autojump.sh # macOS with MacPorts
|
|
||||||
/usr/local/etc/profile.d/autojump.sh # macOS with Homebrew (default)
|
|
||||||
/opt/homebrew/etc/profile.d/autojump.sh # macOS with Homebrew (default on M1 macs)
|
|
||||||
/opt/pkg/share/autojump/autojump.zsh # macOS with pkgsrc
|
|
||||||
/etc/profiles/per-user/$USER/etc/profile.d/autojump.sh # macOS Nix, Home Manager and flakes
|
|
||||||
/nix/var/nix/gcroots/current-system/sw/share/zsh/site-functions/autojump.zsh # macOS Nix, nix-darwin
|
|
||||||
)
|
|
||||||
|
|
||||||
for file in $autojump_paths; do
|
|
||||||
if [[ -f "$file" ]]; then
|
|
||||||
source "$file"
|
|
||||||
found=1
|
|
||||||
break
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
# if no path found, try Homebrew
|
|
||||||
if (( ! found && $+commands[brew] )); then
|
|
||||||
file=$(brew --prefix)/etc/profile.d/autojump.sh
|
|
||||||
if [[ -f "$file" ]]; then
|
|
||||||
source "$file"
|
|
||||||
found=1
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
(( ! found )) && echo '[oh-my-zsh] autojump not found. Please install it first.'
|
|
||||||
|
|
||||||
unset autojump_paths file found
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
# autopep8 plugin
|
|
||||||
|
|
||||||
This plugin adds completion for [autopep8](https://pypi.org/project/autopep8/), a tool that automatically formats Python code to conform to the [PEP 8](http://www.python.org/dev/peps/pep-0008/) style guide.
|
|
||||||
|
|
||||||
To use it, add autopep8 to the plugins array of your zshrc file:
|
|
||||||
```
|
|
||||||
plugins=(... autopep8)
|
|
||||||
```
|
|
||||||
@@ -1,32 +0,0 @@
|
|||||||
#compdef autopep8
|
|
||||||
#
|
|
||||||
# this is zsh completion function file.
|
|
||||||
# generated by genzshcomp(ver: 0.5.1)
|
|
||||||
#
|
|
||||||
|
|
||||||
typeset -A opt_args
|
|
||||||
local context state line
|
|
||||||
|
|
||||||
_arguments -s -S \
|
|
||||||
"--help[show this help message and exit]:" \
|
|
||||||
"-h[show this help message and exit]:" \
|
|
||||||
"--version[show program's version number and exit]:" \
|
|
||||||
"--verbose[print verbose messages; multiple -v result in more verbose messages]" \
|
|
||||||
"-v[print verbose messages; multiple -v result in more verbose messages]" \
|
|
||||||
"--diff[print the diff for the fixed source]" \
|
|
||||||
"-d[print the diff for the fixed source]" \
|
|
||||||
"--in-place[make changes to files in place]" \
|
|
||||||
"-i[make changes to files in place]" \
|
|
||||||
"--recursive[run recursively; must be used with --in-place or --diff]" \
|
|
||||||
"-r[run recursively; must be used with --in-place or --diff]" \
|
|
||||||
"--jobs[number of parallel jobs; match CPU count if value is less than 1]::n number of parallel jobs; match CPU count if value is:_files" \
|
|
||||||
"-j[number of parallel jobs; match CPU count if value is less than 1]::n number of parallel jobs; match CPU count if value is:_files" \
|
|
||||||
"--pep8-passes[maximum number of additional pep8 passes (default: 100)]::n:_files" \
|
|
||||||
"-p[maximum number of additional pep8 passes (default: 100)]::n:_files" \
|
|
||||||
"-a[-a result in more aggressive changes]::result:_files" \
|
|
||||||
"--exclude[exclude files/directories that match these comma- separated globs]::globs:_files" \
|
|
||||||
"--list-fixes[list codes for fixes; used by --ignore and --select]" \
|
|
||||||
"--ignore[do not fix these errors/warnings (default E226,E24)]::errors:_files" \
|
|
||||||
"--select[fix only these errors/warnings (e.g. E4,W)]::errors:_files" \
|
|
||||||
"--max-line-length[set maximum allowed line length (default: 79)]::n:_files" \
|
|
||||||
"*::args:_files"
|
|
||||||
@@ -1,98 +0,0 @@
|
|||||||
# aws
|
|
||||||
|
|
||||||
This plugin provides completion support for [awscli v2](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/index.html)
|
|
||||||
and a few utilities to manage AWS profiles/regions and display them in the prompt.
|
|
||||||
[awscli v1](https://docs.aws.amazon.com/cli/latest/userguide/cliv2-migration.html) is no longer supported.
|
|
||||||
|
|
||||||
To use it, add `aws` to the plugins array in your zshrc file.
|
|
||||||
|
|
||||||
```zsh
|
|
||||||
plugins=(... aws)
|
|
||||||
```
|
|
||||||
|
|
||||||
## Plugin commands
|
|
||||||
|
|
||||||
* `asp [<profile>]`: sets `$AWS_PROFILE` and `$AWS_DEFAULT_PROFILE` (legacy) to `<profile>`.
|
|
||||||
It also sets `$AWS_EB_PROFILE` to `<profile>` for the Elastic Beanstalk CLI. It sets `$AWS_PROFILE_REGION` for display in `aws_prompt_info`.
|
|
||||||
Run `asp` without arguments to clear the profile.
|
|
||||||
* `asp [<profile>] login`: If AWS SSO has been configured in your aws profile, it will run the `aws sso login` command following profile selection.
|
|
||||||
* `asp [<profile>] login [<sso_session>]`: In addition to `asp [<profile>] login`, if SSO session has been configured in your aws profile, it will run the `aws sso login --sso-session <sso_session>` command following profile selection.
|
|
||||||
* `asp [<profile>] logout`: If AWS SSO has been configured in your aws profile, it will run the `aws sso logout` command following profile selection.
|
|
||||||
|
|
||||||
* `asr [<region>]`: sets `$AWS_REGION` and `$AWS_DEFAULT_REGION` (legacy) to `<region>`.
|
|
||||||
Run `asr` without arguments to clear the profile.
|
|
||||||
|
|
||||||
* `acp [<profile>] [<mfa_token>]`: 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`.
|
|
||||||
|
|
||||||
* `agr`: gets the current value of `$AWS_REGION`.
|
|
||||||
|
|
||||||
* `aws_change_access_key`: changes the AWS access key of a profile.
|
|
||||||
|
|
||||||
* `aws_profiles`: lists the available profiles in the `$AWS_CONFIG_FILE` (default: `~/.aws/config`).
|
|
||||||
Used to provide completion for the `asp` function.
|
|
||||||
|
|
||||||
* `aws_regions`: lists the available regions.
|
|
||||||
Used to provide completion for the `asr` function.
|
|
||||||
|
|
||||||
## Plugin options
|
|
||||||
|
|
||||||
* Set `SHOW_AWS_PROMPT=false` in your zshrc file if you want to prevent the plugin from modifying your RPROMPT.
|
|
||||||
Some themes might overwrite the value of RPROMPT instead of appending to it, so they'll need to be fixed to
|
|
||||||
see the AWS profile/region prompt.
|
|
||||||
|
|
||||||
* Set `AWS_PROFILE_STATE_ENABLED=true` in your zshrc file if you want the aws profile to persist between shell sessions.
|
|
||||||
This option might slow down your shell startup time.
|
|
||||||
By default the state file path is `/tmp/.aws_current_profile`. This means that the state won't survive a reboot or otherwise GC.
|
|
||||||
You can control the state file path using the `AWS_STATE_FILE` environment variable.
|
|
||||||
|
|
||||||
## Theme
|
|
||||||
|
|
||||||
The plugin creates an `aws_prompt_info` function that you can use in your theme, which displays
|
|
||||||
the current `$AWS_PROFILE` and `$AWS_REGION`. It uses four variables to control how that is shown:
|
|
||||||
|
|
||||||
* ZSH_THEME_AWS_PROFILE_PREFIX: sets the prefix of the AWS_PROFILE. Defaults to `<aws:`.
|
|
||||||
|
|
||||||
* ZSH_THEME_AWS_PROFILE_SUFFIX: sets the suffix of the AWS_PROFILE. Defaults to `>`.
|
|
||||||
|
|
||||||
* ZSH_THEME_AWS_REGION_PREFIX: sets the prefix of the AWS_REGION. Defaults to `<region:`.
|
|
||||||
|
|
||||||
* ZSH_THEME_AWS_REGION_SUFFIX: sets the suffix of the AWS_REGION. Defaults to `>`.
|
|
||||||
|
|
||||||
* ZSH_THEME_AWS_DIVIDER: sets the divider between ZSH_THEME_AWS_PROFILE_SUFFIX and ZSH_THEME_AWS_REGION_PREFIX. Defaults to ` ` (single space).
|
|
||||||
|
|
||||||
## 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`:
|
|
||||||
|
|
||||||
```ini
|
|
||||||
[source-profile-name]
|
|
||||||
aws_access_key_id = ...
|
|
||||||
aws_secret_access_key = ...
|
|
||||||
```
|
|
||||||
|
|
||||||
Role configuration in `~/.aws/config`:
|
|
||||||
|
|
||||||
```ini
|
|
||||||
[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
|
|
||||||
```
|
|
||||||
@@ -1,338 +0,0 @@
|
|||||||
function agp() {
|
|
||||||
echo $AWS_PROFILE
|
|
||||||
}
|
|
||||||
|
|
||||||
function agr() {
|
|
||||||
echo $AWS_REGION
|
|
||||||
}
|
|
||||||
|
|
||||||
# Update state file if enabled
|
|
||||||
function _aws_update_state() {
|
|
||||||
if [[ "$AWS_PROFILE_STATE_ENABLED" == true ]]; then
|
|
||||||
test -d $(dirname ${AWS_STATE_FILE}) || exit 1
|
|
||||||
echo "${AWS_PROFILE} ${AWS_REGION}" > "${AWS_STATE_FILE}"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
function _aws_clear_state() {
|
|
||||||
if [[ "$AWS_PROFILE_STATE_ENABLED" == true ]]; then
|
|
||||||
test -d $(dirname ${AWS_STATE_FILE}) || exit 1
|
|
||||||
echo -n > "${AWS_STATE_FILE}"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
# AWS profile selection
|
|
||||||
function asp() {
|
|
||||||
if [[ -z "$1" ]]; then
|
|
||||||
unset AWS_DEFAULT_PROFILE AWS_PROFILE AWS_EB_PROFILE AWS_PROFILE_REGION
|
|
||||||
_aws_clear_state
|
|
||||||
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
|
|
||||||
|
|
||||||
export AWS_DEFAULT_PROFILE=$1
|
|
||||||
export AWS_PROFILE=$1
|
|
||||||
export AWS_EB_PROFILE=$1
|
|
||||||
|
|
||||||
export AWS_PROFILE_REGION=$(aws configure get region)
|
|
||||||
|
|
||||||
_aws_update_state
|
|
||||||
|
|
||||||
if [[ "$2" == "login" ]]; then
|
|
||||||
if [[ -n "$3" ]]; then
|
|
||||||
aws sso login --sso-session $3
|
|
||||||
else
|
|
||||||
aws sso login
|
|
||||||
fi
|
|
||||||
elif [[ "$2" == "logout" ]]; then
|
|
||||||
aws sso logout
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
# AWS region selection
|
|
||||||
function asr() {
|
|
||||||
if [[ -z "$1" ]]; then
|
|
||||||
unset AWS_DEFAULT_REGION AWS_REGION
|
|
||||||
_aws_update_state
|
|
||||||
echo AWS region cleared.
|
|
||||||
return
|
|
||||||
fi
|
|
||||||
|
|
||||||
local -a available_regions
|
|
||||||
available_regions=($(aws_regions))
|
|
||||||
if [[ -z "${available_regions[(r)$1]}" ]]; then
|
|
||||||
echo "${fg[red]}Available regions: \n$(aws_regions)"
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
export AWS_REGION=$1
|
|
||||||
export AWS_DEFAULT_REGION=$1
|
|
||||||
_aws_update_state
|
|
||||||
}
|
|
||||||
|
|
||||||
# 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"
|
|
||||||
local mfa_token="$2"
|
|
||||||
|
|
||||||
# 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
|
|
||||||
if [[ -z "$mfa_token" ]]; then
|
|
||||||
echo -n "Please enter your MFA token for $mfa_serial: "
|
|
||||||
read -r mfa_token
|
|
||||||
fi
|
|
||||||
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}")
|
|
||||||
fi
|
|
||||||
|
|
||||||
# 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
|
|
||||||
|
|
||||||
# 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() {
|
|
||||||
if [[ -z "$1" ]]; then
|
|
||||||
echo "usage: $0 <profile>"
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
local profile="$1"
|
|
||||||
# Get current access key
|
|
||||||
local original_aws_access_key_id="$(aws configure get aws_access_key_id --profile $profile)"
|
|
||||||
|
|
||||||
asp "$profile" || return 1
|
|
||||||
echo "Generating a new access key pair for you now."
|
|
||||||
if aws --no-cli-pager iam create-access-key; then
|
|
||||||
echo "Insert the newly generated credentials when asked."
|
|
||||||
aws --no-cli-pager configure --profile $profile
|
|
||||||
else
|
|
||||||
echo "Current access keys:"
|
|
||||||
aws --no-cli-pager iam list-access-keys
|
|
||||||
echo "Profile \"${profile}\" is currently using the $original_aws_access_key_id key. You can delete an old access key by running \`aws --profile $profile iam delete-access-key --access-key-id AccessKeyId\`"
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
read -q "yn?Would you like to disable your previous access key (${original_aws_access_key_id}) now? "
|
|
||||||
case $yn in
|
|
||||||
[Yy]*)
|
|
||||||
echo -n "\nDisabling access key ${original_aws_access_key_id}..."
|
|
||||||
if aws --no-cli-pager iam update-access-key --access-key-id ${original_aws_access_key_id} --status Inactive; then
|
|
||||||
echo "done."
|
|
||||||
else
|
|
||||||
echo "\nFailed to disable ${original_aws_access_key_id} key."
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
echo ""
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
echo "You can now safely delete the old access key by running \`aws --profile $profile iam delete-access-key --access-key-id ${original_aws_access_key_id}\`"
|
|
||||||
echo "Your current keys are:"
|
|
||||||
aws --no-cli-pager iam list-access-keys
|
|
||||||
}
|
|
||||||
|
|
||||||
function aws_regions() {
|
|
||||||
local region
|
|
||||||
if [[ $AWS_DEFAULT_REGION ]];then
|
|
||||||
region="$AWS_DEFAULT_REGION"
|
|
||||||
elif [[ $AWS_REGION ]];then
|
|
||||||
region="$AWS_REGION"
|
|
||||||
else
|
|
||||||
region="us-west-1"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ $AWS_DEFAULT_PROFILE || $AWS_PROFILE ]];then
|
|
||||||
aws ec2 describe-regions --region $region |grep RegionName | awk -F ':' '{gsub(/"/, "", $2);gsub(/,/, "", $2);gsub(/ /, "", $2); print $2}'
|
|
||||||
else
|
|
||||||
echo "You must specify a AWS profile."
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
function aws_profiles() {
|
|
||||||
aws --no-cli-pager configure list-profiles 2> /dev/null && return
|
|
||||||
[[ -r "${AWS_CONFIG_FILE:-$HOME/.aws/config}" ]] || return 1
|
|
||||||
grep --color=never -Eo '\[.*\]' "${AWS_CONFIG_FILE:-$HOME/.aws/config}" | sed -E 's/^[[:space:]]*\[(profile)?[[:space:]]*([^[:space:]]+)\][[:space:]]*$/\2/g'
|
|
||||||
}
|
|
||||||
|
|
||||||
function _aws_regions() {
|
|
||||||
reply=($(aws_regions))
|
|
||||||
}
|
|
||||||
compctl -K _aws_regions asr
|
|
||||||
|
|
||||||
function _aws_profiles() {
|
|
||||||
reply=($(aws_profiles))
|
|
||||||
}
|
|
||||||
compctl -K _aws_profiles asp acp aws_change_access_key
|
|
||||||
|
|
||||||
# AWS prompt
|
|
||||||
function aws_prompt_info() {
|
|
||||||
local _aws_to_show
|
|
||||||
local region="${AWS_REGION:-${AWS_DEFAULT_REGION:-$AWS_PROFILE_REGION}}"
|
|
||||||
|
|
||||||
if [[ -n "$AWS_PROFILE" ]];then
|
|
||||||
_aws_to_show+="${ZSH_THEME_AWS_PROFILE_PREFIX="<aws:"}${AWS_PROFILE}${ZSH_THEME_AWS_PROFILE_SUFFIX=">"}"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ -n "$region" ]]; then
|
|
||||||
[[ -n "$_aws_to_show" ]] && _aws_to_show+="${ZSH_THEME_AWS_DIVIDER=" "}"
|
|
||||||
_aws_to_show+="${ZSH_THEME_AWS_REGION_PREFIX="<region:"}${region}${ZSH_THEME_AWS_REGION_SUFFIX=">"}"
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "$_aws_to_show"
|
|
||||||
}
|
|
||||||
|
|
||||||
if [[ "$SHOW_AWS_PROMPT" != false && "$RPROMPT" != *'$(aws_prompt_info)'* ]]; then
|
|
||||||
RPROMPT='$(aws_prompt_info)'"$RPROMPT"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ "$AWS_PROFILE_STATE_ENABLED" == true ]]; then
|
|
||||||
AWS_STATE_FILE="${AWS_STATE_FILE:-/tmp/.aws_current_profile}"
|
|
||||||
test -s "${AWS_STATE_FILE}" || return
|
|
||||||
|
|
||||||
aws_state=($(cat $AWS_STATE_FILE))
|
|
||||||
|
|
||||||
export AWS_DEFAULT_PROFILE="${aws_state[1]}"
|
|
||||||
export AWS_PROFILE="$AWS_DEFAULT_PROFILE"
|
|
||||||
export AWS_EB_PROFILE="$AWS_DEFAULT_PROFILE"
|
|
||||||
|
|
||||||
test -z "${aws_state[2]}" && AWS_REGION=$(aws configure get region)
|
|
||||||
|
|
||||||
export AWS_REGION=${AWS_REGION:-$aws_state[2]}
|
|
||||||
export AWS_DEFAULT_REGION="$AWS_REGION"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Load awscli completions
|
|
||||||
|
|
||||||
# AWS CLI v2 comes with its own autocompletion. Check if that is there, otherwise fall back
|
|
||||||
if command -v aws_completer &> /dev/null; then
|
|
||||||
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
|
|
||||||
if [ -h /usr/local/opt/awscli ]; then
|
|
||||||
_brew_prefix=/usr/local/opt/awscli
|
|
||||||
else
|
|
||||||
# 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
|
|
||||||
_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
|
|
||||||
|
|
||||||
[[ -r $_aws_zsh_completer_path ]] && source $_aws_zsh_completer_path
|
|
||||||
unset _aws_zsh_completer_path _brew_prefix
|
|
||||||
fi
|
|
||||||
|
|
||||||
@@ -1,49 +0,0 @@
|
|||||||
# azure
|
|
||||||
|
|
||||||
This plugin provides completion support for [azure cli](https://docs.microsoft.com/en-us/cli/azure/)
|
|
||||||
and a few utilities to manage azure subscriptions and display them in the prompt.
|
|
||||||
|
|
||||||
To use it, add `azure` to the plugins array in your zshrc file.
|
|
||||||
|
|
||||||
```zsh
|
|
||||||
plugins=(... azure)
|
|
||||||
```
|
|
||||||
|
|
||||||
## Plugin commands
|
|
||||||
|
|
||||||
|
|
||||||
* `az_subscriptions`: lists the available subscriptions in the `AZURE_CONFIG_DIR` (default: `~/.azure/`).
|
|
||||||
Used to provide completion for the `azss` function.
|
|
||||||
|
|
||||||
* `azgs`: gets the current value of `$azure_subscription`.
|
|
||||||
|
|
||||||
* `azss [<subscription>]`: sets the `$azure_subscription`.
|
|
||||||
|
|
||||||
|
|
||||||
NOTE : because azure keeps the state of active subscription in ${AZURE_CONFIG_DIR:-$HOME/.azure/azureProfile.json}, the prompt command requires `jq` to be enabled to parse the file. If jq is not in the path the prompt will show nothing
|
|
||||||
|
|
||||||
## Theme
|
|
||||||
|
|
||||||
The plugin creates an `azure_prompt_info` function that you can use in your theme, which displays
|
|
||||||
the current `$azure_subscription`. It uses two variables to control how that is shown:
|
|
||||||
|
|
||||||
- ZSH_THEME_AZURE_PREFIX: sets the prefix of the azure_subscription. Defaults to `<az:`.
|
|
||||||
|
|
||||||
- ZSH_THEME_azure_SUFFIX: sets the suffix of the azure_subscription. Defaults to `>`.
|
|
||||||
|
|
||||||
|
|
||||||
```
|
|
||||||
RPROMPT='$(azure_prompt_info)'
|
|
||||||
```
|
|
||||||
|
|
||||||
## Develop
|
|
||||||
|
|
||||||
On ubuntu get a working environment with :
|
|
||||||
|
|
||||||
` docker run -it -v $(pwd):/mnt -w /mnt ubuntu bash`
|
|
||||||
|
|
||||||
```
|
|
||||||
apt install -y curl jq zsh git vim
|
|
||||||
sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
|
|
||||||
curl -sL https://aka.ms/InstallAzureCLIDeb | bash
|
|
||||||
```
|
|
||||||
@@ -1,60 +0,0 @@
|
|||||||
# AZ Get Subscriptions
|
|
||||||
function azgs() {
|
|
||||||
az account show --output tsv --query 'name' 2>/dev/null
|
|
||||||
}
|
|
||||||
|
|
||||||
# AZ Subscription Selection
|
|
||||||
alias azss="az account set --subscription"
|
|
||||||
|
|
||||||
|
|
||||||
function az_subscriptions() {
|
|
||||||
az account list --all --output tsv --query '[*].name' 2> /dev/null
|
|
||||||
}
|
|
||||||
|
|
||||||
function _az_subscriptions() {
|
|
||||||
reply=($(az_subscriptions))
|
|
||||||
}
|
|
||||||
compctl -K _az_subscriptions azss
|
|
||||||
|
|
||||||
# Azure prompt
|
|
||||||
function azure_prompt_info() {
|
|
||||||
[[ ! -f "${AZURE_CONFIG_DIR:-$HOME/.azure}/azureProfile.json" ]] && return
|
|
||||||
# azgs is too expensive, if we have jq, we enable the prompt
|
|
||||||
(( $+commands[jq] )) || return 1
|
|
||||||
azgs=$(jq -r '.subscriptions[] | select(.isDefault==true) .name' "${AZURE_CONFIG_DIR:-$HOME/.azure}/azureProfile.json")
|
|
||||||
echo "${ZSH_THEME_AZURE_PREFIX:=<az:}${azgs}${ZSH_THEME_AZURE_SUFFIX:=>}"
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
# Load az completions
|
|
||||||
function _az-homebrew-installed() {
|
|
||||||
# check if Homebrew is installed
|
|
||||||
(( $+commands[brew] )) || return 1
|
|
||||||
|
|
||||||
# if so, we assume it's default way to install brew
|
|
||||||
if [[ ${commands[brew]:t2} == bin/brew ]]; then
|
|
||||||
_brew_prefix="${commands[brew]:h:h}" # remove trailing /bin/brew
|
|
||||||
else
|
|
||||||
# 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
|
|
||||||
_brew_prefix=$(brew --prefix)
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
# get az.completion.sh location from $PATH
|
|
||||||
_az_zsh_completer_path="$commands[az_zsh_completer.sh]"
|
|
||||||
|
|
||||||
# otherwise check common locations
|
|
||||||
if [[ -z $_az_zsh_completer_path ]]; then
|
|
||||||
# Homebrew
|
|
||||||
if _az-homebrew-installed; then
|
|
||||||
_az_zsh_completer_path=$_brew_prefix/etc/bash_completion.d/az
|
|
||||||
# Linux
|
|
||||||
else
|
|
||||||
_az_zsh_completer_path=/etc/bash_completion.d/azure-cli
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
[[ -r $_az_zsh_completer_path ]] && autoload -U +X bashcompinit && bashcompinit && source $_az_zsh_completer_path
|
|
||||||
unset _az_zsh_completer_path _brew_prefix
|
|
||||||
@@ -1,42 +0,0 @@
|
|||||||
# Battery Plugin
|
|
||||||
|
|
||||||
This plugin adds some functions you can use to display battery information in your custom theme.
|
|
||||||
|
|
||||||
To use, add `battery` to the list of plugins in your `.zshrc` file:
|
|
||||||
|
|
||||||
`plugins=(... battery)`
|
|
||||||
|
|
||||||
Then, add the `battery_pct_prompt` function to your custom theme. For example:
|
|
||||||
|
|
||||||
```zsh
|
|
||||||
RPROMPT='$(battery_pct_prompt) ...'
|
|
||||||
```
|
|
||||||
|
|
||||||
Also, you set the `BATTERY_CHARGING` variable to your favor.
|
|
||||||
For example:
|
|
||||||
|
|
||||||
```zsh
|
|
||||||
BATTERY_CHARGING="⚡️"
|
|
||||||
```
|
|
||||||
|
|
||||||
You can see the power of your charger using the following setting (MacOS only)
|
|
||||||
|
|
||||||
```zsh
|
|
||||||
BATTERY_SHOW_WATTS=true
|
|
||||||
```
|
|
||||||
|
|
||||||
## Requirements
|
|
||||||
|
|
||||||
- On Linux, you must have the `acpi` or `acpitool` commands installed on your operating system.
|
|
||||||
On Debian/Ubuntu, you can do that with `sudo apt install acpi` or `sudo apt install acpitool`.
|
|
||||||
|
|
||||||
- On Android (via [Termux](https://play.google.com/store/apps/details?id=com.termux)), you must have:
|
|
||||||
|
|
||||||
1. The `Termux:API` addon app installed:
|
|
||||||
[Google Play](https://play.google.com/store/apps/details?id=com.termux.api) | [F-Droid](https://f-droid.org/packages/com.termux.api/)
|
|
||||||
|
|
||||||
2. The `termux-api` package installed within termux:
|
|
||||||
|
|
||||||
```sh
|
|
||||||
pkg install termux-api
|
|
||||||
```
|
|
||||||
@@ -1,314 +0,0 @@
|
|||||||
###########################################
|
|
||||||
# Battery plugin for oh-my-zsh #
|
|
||||||
# Original Author: Peter hoeg (peterhoeg) #
|
|
||||||
# Email: peter@speartail.com #
|
|
||||||
###########################################
|
|
||||||
# Author: Sean Jones (neuralsandwich) #
|
|
||||||
# Email: neuralsandwich@gmail.com #
|
|
||||||
# Modified to add support for Apple Mac #
|
|
||||||
###########################################
|
|
||||||
# Author: J (927589452) #
|
|
||||||
# Modified to add support for FreeBSD #
|
|
||||||
###########################################
|
|
||||||
# Author: Avneet Singh (kalsi-avneet) #
|
|
||||||
# Modified to add support for Android #
|
|
||||||
###########################################
|
|
||||||
# Author: Not Pua (im-notpua) #
|
|
||||||
# Modified to add support for OpenBSD #
|
|
||||||
###########################################
|
|
||||||
|
|
||||||
: ${BATTERY_SHOW_WATTS:=false}
|
|
||||||
|
|
||||||
|
|
||||||
if [[ "$OSTYPE" = darwin* ]]; then
|
|
||||||
function get_charger_power() {
|
|
||||||
echo "$(ioreg -rc AppleSmartBattery | grep -o '"Watts"=[0-9]\+' | head -1 | grep -o '[0-9]\+')W "
|
|
||||||
}
|
|
||||||
function battery_is_charging() {
|
|
||||||
ioreg -rc AppleSmartBattery | command grep -q '^.*"ExternalConnected"\ =\ Yes'
|
|
||||||
}
|
|
||||||
function battery_pct() {
|
|
||||||
pmset -g batt | grep -Eo "\d+%" | cut -d% -f1
|
|
||||||
}
|
|
||||||
function battery_pct_remaining() {
|
|
||||||
if battery_is_charging; then
|
|
||||||
echo "External Power"
|
|
||||||
else
|
|
||||||
battery_pct
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
function battery_time_remaining() {
|
|
||||||
local smart_battery_status="$(ioreg -rc "AppleSmartBattery")"
|
|
||||||
if [[ $(echo $smart_battery_status | command grep -c '^.*"ExternalConnected"\ =\ No') -eq 1 ]]; then
|
|
||||||
timeremaining=$(echo $smart_battery_status | command grep '^.*"AvgTimeToEmpty"\ =\ ' | sed -e 's/^.*"AvgTimeToEmpty"\ =\ //')
|
|
||||||
if [ $timeremaining -gt 720 ]; then
|
|
||||||
echo "::"
|
|
||||||
else
|
|
||||||
echo "~$((timeremaining / 60)):$((timeremaining % 60))"
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
echo "∞"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
function battery_pct_prompt () {
|
|
||||||
local battery_pct color
|
|
||||||
if ioreg -rc AppleSmartBattery | command grep -q '^.*"ExternalConnected"\ =\ No'; then
|
|
||||||
battery_pct=$(battery_pct_remaining)
|
|
||||||
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%}"
|
|
||||||
else
|
|
||||||
if [[ "${BATTERY_SHOW_WATTS}" = "true" ]] ; then
|
|
||||||
watts=$(get_charger_power)
|
|
||||||
fi
|
|
||||||
echo "${watts}${BATTERY_CHARGING-⚡️}"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
elif [[ "$OSTYPE" = freebsd* ]]; then
|
|
||||||
function battery_is_charging() {
|
|
||||||
[[ $(sysctl -n hw.acpi.battery.state) -eq 2 ]]
|
|
||||||
}
|
|
||||||
function battery_pct() {
|
|
||||||
if (( $+commands[sysctl] )); then
|
|
||||||
sysctl -n hw.acpi.battery.life
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
function battery_pct_remaining() {
|
|
||||||
if ! battery_is_charging; then
|
|
||||||
battery_pct
|
|
||||||
else
|
|
||||||
echo "External Power"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
function battery_time_remaining() {
|
|
||||||
local remaining_time
|
|
||||||
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
|
|
||||||
}
|
|
||||||
function battery_pct_prompt() {
|
|
||||||
local battery_pct color
|
|
||||||
battery_pct=$(battery_pct_remaining)
|
|
||||||
if battery_is_charging; then
|
|
||||||
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
|
|
||||||
}
|
|
||||||
elif [[ "$OSTYPE" = linux-android ]] && (( ${+commands[termux-battery-status]} )); then
|
|
||||||
function battery_is_charging() {
|
|
||||||
termux-battery-status 2>/dev/null | command awk '/status/ { exit ($0 ~ /DISCHARGING/) }'
|
|
||||||
}
|
|
||||||
function battery_pct() {
|
|
||||||
# Sample output:
|
|
||||||
# {
|
|
||||||
# "health": "GOOD",
|
|
||||||
# "percentage": 93,
|
|
||||||
# "plugged": "UNPLUGGED",
|
|
||||||
# "status": "DISCHARGING",
|
|
||||||
# "temperature": 29.0,
|
|
||||||
# "current": 361816
|
|
||||||
# }
|
|
||||||
termux-battery-status 2>/dev/null | command awk '/percentage/ { gsub(/[,]/,""); print $2}'
|
|
||||||
}
|
|
||||||
function battery_pct_remaining() {
|
|
||||||
if ! battery_is_charging; then
|
|
||||||
battery_pct
|
|
||||||
else
|
|
||||||
echo "External Power"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
function battery_time_remaining() { } # Not available on android
|
|
||||||
function battery_pct_prompt() {
|
|
||||||
local battery_pct color
|
|
||||||
battery_pct=$(battery_pct_remaining)
|
|
||||||
if battery_is_charging; then
|
|
||||||
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
|
|
||||||
}
|
|
||||||
elif [[ "$OSTYPE" = openbsd* ]]; then
|
|
||||||
function battery_is_charging() {
|
|
||||||
[[ $(apm -b) -eq 3 ]]
|
|
||||||
}
|
|
||||||
function battery_pct() {
|
|
||||||
apm -l
|
|
||||||
}
|
|
||||||
function battery_pct_remaining() {
|
|
||||||
if ! battery_is_charging; then
|
|
||||||
battery_pct
|
|
||||||
else
|
|
||||||
echo "External Power"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
function battery_time_remaining() {
|
|
||||||
local remaining_time
|
|
||||||
remaining_time=$(apm -m)
|
|
||||||
if [[ $remaining_time -ge 0 ]]; then
|
|
||||||
((hour = $remaining_time / 60 ))
|
|
||||||
((minute = $remaining_time % 60 ))
|
|
||||||
printf %02d:%02d $hour $minute
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
function battery_pct_prompt() {
|
|
||||||
local battery_pct color
|
|
||||||
battery_pct=$(battery_pct_remaining)
|
|
||||||
if battery_is_charging; then
|
|
||||||
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
|
|
||||||
}
|
|
||||||
|
|
||||||
elif [[ "$OSTYPE" = linux* ]]; then
|
|
||||||
function battery_is_charging() {
|
|
||||||
if (( $+commands[acpitool] )); then
|
|
||||||
! acpitool 2>/dev/null | command grep -qE '^\s+Battery.*Discharging'
|
|
||||||
elif (( $+commands[acpi] )); then
|
|
||||||
! acpi 2>/dev/null | command grep -v "rate information unavailable" | command grep -q '^Battery.*Discharging'
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
function battery_pct() {
|
|
||||||
if (( $+commands[acpitool] )); then
|
|
||||||
# Sample output:
|
|
||||||
# Battery #1 : Unknown, 99.55%
|
|
||||||
# Battery #2 : Discharging, 49.58%, 01:12:05
|
|
||||||
# All batteries : 62.60%, 02:03:03
|
|
||||||
local -i pct=$(acpitool 2>/dev/null | command awk -F, '
|
|
||||||
/^\s+All batteries/ {
|
|
||||||
gsub(/[^0-9.]/, "", $1)
|
|
||||||
pct=$1
|
|
||||||
exit
|
|
||||||
}
|
|
||||||
!pct && /^\s+Battery/ {
|
|
||||||
gsub(/[^0-9.]/, "", $2)
|
|
||||||
pct=$2
|
|
||||||
}
|
|
||||||
END { print pct }
|
|
||||||
')
|
|
||||||
echo $pct
|
|
||||||
elif (( $+commands[acpi] )); then
|
|
||||||
# Sample output:
|
|
||||||
# Battery 0: Discharging, 0%, rate information unavailable
|
|
||||||
# Battery 1: Full, 100%
|
|
||||||
acpi 2>/dev/null | command awk -F, '
|
|
||||||
/rate information unavailable/ { next }
|
|
||||||
/^Battery.*: /{ gsub(/[^0-9]/, "", $2); print $2; exit }
|
|
||||||
'
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
function battery_pct_remaining() {
|
|
||||||
if ! battery_is_charging; then
|
|
||||||
battery_pct
|
|
||||||
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 "∞"
|
|
||||||
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
|
|
||||||
}
|
|
||||||
else
|
|
||||||
# Empty functions so we don't cause errors in prompts
|
|
||||||
function battery_is_charging { false }
|
|
||||||
function battery_pct \
|
|
||||||
battery_pct_remaining \
|
|
||||||
battery_time_remaining \
|
|
||||||
battery_pct_prompt { }
|
|
||||||
fi
|
|
||||||
|
|
||||||
function battery_level_gauge() {
|
|
||||||
local gauge_slots=${BATTERY_GAUGE_SLOTS:-10}
|
|
||||||
local green_threshold=${BATTERY_GREEN_THRESHOLD:-$(( gauge_slots * 0.6 ))}
|
|
||||||
local yellow_threshold=${BATTERY_YELLOW_THRESHOLD:-$(( gauge_slots * 0.4 ))}
|
|
||||||
local color_green=${BATTERY_COLOR_GREEN:-%F{green}}
|
|
||||||
local color_yellow=${BATTERY_COLOR_YELLOW:-%F{yellow}}
|
|
||||||
local color_red=${BATTERY_COLOR_RED:-%F{red}}
|
|
||||||
local color_reset=${BATTERY_COLOR_RESET:-%{%f%k%b%}}
|
|
||||||
local battery_prefix=${BATTERY_GAUGE_PREFIX:-'['}
|
|
||||||
local battery_suffix=${BATTERY_GAUGE_SUFFIX:-']'}
|
|
||||||
local filled_symbol=${BATTERY_GAUGE_FILLED_SYMBOL:-'▶'}
|
|
||||||
local empty_symbol=${BATTERY_GAUGE_EMPTY_SYMBOL:-'▷'}
|
|
||||||
local charging_color=${BATTERY_CHARGING_COLOR:-$color_yellow}
|
|
||||||
local charging_symbol=${BATTERY_CHARGING_SYMBOL:-'⚡'}
|
|
||||||
|
|
||||||
local -i battery_remaining_percentage=$(battery_pct)
|
|
||||||
local filled empty gauge_color
|
|
||||||
|
|
||||||
if [[ $battery_remaining_percentage =~ [0-9]+ ]]; then
|
|
||||||
filled=$(( ($battery_remaining_percentage * $gauge_slots) / 100 ))
|
|
||||||
empty=$(( $gauge_slots - $filled ))
|
|
||||||
|
|
||||||
if [[ $filled -gt $green_threshold ]]; then
|
|
||||||
gauge_color=$color_green
|
|
||||||
elif [[ $filled -gt $yellow_threshold ]]; then
|
|
||||||
gauge_color=$color_yellow
|
|
||||||
else
|
|
||||||
gauge_color=$color_red
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
filled=$gauge_slots
|
|
||||||
empty=0
|
|
||||||
filled_symbol=${BATTERY_UNKNOWN_SYMBOL:-'.'}
|
|
||||||
fi
|
|
||||||
|
|
||||||
local charging=' '
|
|
||||||
battery_is_charging && charging=$charging_symbol
|
|
||||||
|
|
||||||
# Charging status and prefix
|
|
||||||
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}
|
|
||||||
# Suffix
|
|
||||||
print -n ${color_reset}${battery_suffix}${color_reset}
|
|
||||||
}
|
|
||||||
@@ -1,29 +0,0 @@
|
|||||||
# Bazel plugin
|
|
||||||
|
|
||||||
This plugin adds completion and aliases for [bazel](https://bazel.build), an open-source build and test tool
|
|
||||||
that scalably supports multi-language and multi-platform projects.
|
|
||||||
|
|
||||||
To use it, add `bazel` to the plugins array in your zshrc file:
|
|
||||||
|
|
||||||
```zsh
|
|
||||||
plugins=(... bazel)
|
|
||||||
```
|
|
||||||
|
|
||||||
The plugin has a copy of [the completion script from the git repository][1].
|
|
||||||
|
|
||||||
[1]: https://github.com/bazelbuild/bazel/blob/master/scripts/zsh_completion/_bazel
|
|
||||||
|
|
||||||
## Aliases
|
|
||||||
|
|
||||||
| Alias | Command | Description |
|
|
||||||
| ----- | ------------- | ------------------------- |
|
|
||||||
| bzb | `bazel build` | The `bazel build` command |
|
|
||||||
| bzt | `bazel test` | The `bazel test` command |
|
|
||||||
| bzr | `bazel run` | The `bazel run` command |
|
|
||||||
| bzq | `bazel query` | The `bazel query` command |
|
|
||||||
|
|
||||||
## Functions
|
|
||||||
|
|
||||||
| Function | Description |
|
|
||||||
| -------- | -------------------------------- |
|
|
||||||
| sri-hash | Generate SRI hash used by bzlmod |
|
|
||||||
@@ -1,341 +0,0 @@
|
|||||||
#compdef bazel bazelisk
|
|
||||||
|
|
||||||
# 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 != bin ]] ); 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
|
|
||||||
}
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
# Aliases for bazel
|
|
||||||
alias bzb='bazel build'
|
|
||||||
alias bzt='bazel test'
|
|
||||||
alias bzr='bazel run'
|
|
||||||
alias bzq='bazel query'
|
|
||||||
|
|
||||||
sri-hash() {
|
|
||||||
openssl dgst -sha256 -binary $1 | openssl base64 -A | sed 's/^/sha256-/'
|
|
||||||
}
|
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
## bbedit
|
|
||||||
|
|
||||||
Plugin for BBEdit, an HTML and text editor for Mac OS X
|
|
||||||
|
|
||||||
### Requirements
|
|
||||||
|
|
||||||
* [BBEdit](https://www.barebones.com/products/bbedit/)
|
|
||||||
* [BBEdit Command-Line Tools](https://www.barebones.com/support/bbedit/cmd-line-tools.html)
|
|
||||||
|
|
||||||
### Usage
|
|
||||||
|
|
||||||
* If the `bb` command is called without an argument, launch BBEdit
|
|
||||||
|
|
||||||
* If `bb` is passed a directory, cd to it and open it in BBEdit
|
|
||||||
|
|
||||||
* If `bb` is passed a file, open it in BBEdit
|
|
||||||
|
|
||||||
* If `bbpb` create a new BBEdit document with the contents of the clipboard
|
|
||||||
|
|
||||||
* If `bbd` alias for BBEdit diff tool
|
|
||||||
@@ -1,21 +0,0 @@
|
|||||||
alias bbpb='pbpaste | bbedit --clean --view-top'
|
|
||||||
|
|
||||||
alias bbd=bbdiff
|
|
||||||
|
|
||||||
#
|
|
||||||
# If the bb command is called without an argument, launch BBEdit
|
|
||||||
# If bb is passed a directory, cd to it and open it in BBEdit
|
|
||||||
# If bb is passed a file, open it in BBEdit
|
|
||||||
#
|
|
||||||
function bb() {
|
|
||||||
if [[ -z "$1" ]]
|
|
||||||
then
|
|
||||||
bbedit --launch
|
|
||||||
else
|
|
||||||
bbedit "$1"
|
|
||||||
if [[ -d "$1" ]]
|
|
||||||
then
|
|
||||||
cd "$1"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
# Bedtools plugin
|
|
||||||
|
|
||||||
This plugin adds support for the [bedtools suite](http://bedtools.readthedocs.org/en/latest/):
|
|
||||||
|
|
||||||
* Adds autocomplete options for all bedtools sub commands.
|
|
||||||
@@ -1,64 +0,0 @@
|
|||||||
#compdef bedtools
|
|
||||||
#autoload
|
|
||||||
|
|
||||||
local curcontext="$curcontext" state line ret=1
|
|
||||||
local -a _files
|
|
||||||
|
|
||||||
_arguments -C \
|
|
||||||
'1: :->cmds' \
|
|
||||||
'2:: :->args' && ret=0
|
|
||||||
|
|
||||||
case $state in
|
|
||||||
cmds)
|
|
||||||
_values "bedtools command" \
|
|
||||||
"--contact[Feature requests, bugs, mailing lists, etc.]" \
|
|
||||||
"--help[Print this help menu.]" \
|
|
||||||
"--version[What version of bedtools are you using?.]" \
|
|
||||||
"annotate[Annotate coverage of features from multiple files.]" \
|
|
||||||
"bamtobed[Convert BAM alignments to BED (& other) formats.]" \
|
|
||||||
"bamtofastq[Convert BAM records to FASTQ records.]" \
|
|
||||||
"bed12tobed6[Breaks BED12 intervals into discrete BED6 intervals.]" \
|
|
||||||
"bedpetobam[Convert BEDPE intervals to BAM records.]" \
|
|
||||||
"bedtobam[Convert intervals to BAM records.]" \
|
|
||||||
"closest[Find the closest, potentially non-overlapping interval.]" \
|
|
||||||
"cluster[Cluster (but don't merge) overlapping/nearby intervals.]" \
|
|
||||||
"complement[Extract intervals _not_ represented by an interval file.]" \
|
|
||||||
"coverage[Compute the coverage over defined intervals.]" \
|
|
||||||
"expand[Replicate lines based on lists of values in columns.]" \
|
|
||||||
"fisher[Calculate Fisher statistic b/w two feature files.]" \
|
|
||||||
"flank[Create new intervals from the flanks of existing intervals.]" \
|
|
||||||
"genomecov[Compute the coverage over an entire genome.]" \
|
|
||||||
"getfasta[Use intervals to extract sequences from a FASTA file.]" \
|
|
||||||
"groupby[Group by common cols. & summarize oth. cols. (~ SQL "groupBy")]" \
|
|
||||||
"igv[Create an IGV snapshot batch script.]" \
|
|
||||||
"intersect[Find overlapping intervals in various ways.]" \
|
|
||||||
"jaccard[Calculate the Jaccard statistic b/w two sets of intervals.]" \
|
|
||||||
"links[Create a HTML page of links to UCSC locations.]" \
|
|
||||||
"makewindows[Make interval "windows" across a genome.]" \
|
|
||||||
"map[Apply a function to a column for each overlapping interval.]" \
|
|
||||||
"maskfasta[Use intervals to mask sequences from a FASTA file.]" \
|
|
||||||
"merge[Combine overlapping/nearby intervals into a single interval.]" \
|
|
||||||
"multicov[Counts coverage from multiple BAMs at specific intervals.]" \
|
|
||||||
"multiinter[Identifies common intervals among multiple interval files.]" \
|
|
||||||
"nuc[Profile the nucleotide content of intervals in a FASTA file.]" \
|
|
||||||
"overlap[Computes the amount of overlap from two intervals.]" \
|
|
||||||
"pairtobed[Find pairs that overlap intervals in various ways.]" \
|
|
||||||
"pairtopair[Find pairs that overlap other pairs in various ways.]" \
|
|
||||||
"random[Generate random intervals in a genome.]" \
|
|
||||||
"reldist[Calculate the distribution of relative distances b/w two files.]" \
|
|
||||||
"sample[Sample random records from file using reservoir sampling.]" \
|
|
||||||
"shuffle[Randomly redistribute intervals in a genome.]" \
|
|
||||||
"slop[Adjust the size of intervals.]" \
|
|
||||||
"sort[Order the intervals in a file.]" \
|
|
||||||
"subtract[Remove intervals based on overlaps b/w two files.]" \
|
|
||||||
"tag[Tag BAM alignments based on overlaps with interval files.]" \
|
|
||||||
"unionbedg[Combines coverage intervals from multiple BEDGRAPH files.]" \
|
|
||||||
"window[Find overlapping intervals within a window around an interval.]" \
|
|
||||||
ret=0
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
_files
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
return ret
|
|
||||||
@@ -1,64 +0,0 @@
|
|||||||
# bgnotify zsh plugin
|
|
||||||
|
|
||||||
cross-platform background notifications for long running commands! Supports OSX and Linux.
|
|
||||||
|
|
||||||
Standalone homepage: [t413/zsh-background-notify](https://github.com/t413/zsh-background-notify)
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## How to use
|
|
||||||
|
|
||||||
Just add bgnotify to your plugins list in your `.zshrc`
|
|
||||||
|
|
||||||
- On OS X you'll need [terminal-notifier](https://github.com/alloy/terminal-notifier)
|
|
||||||
* `brew install terminal-notifier` (or `gem install terminal-notifier`)
|
|
||||||
- On Linux, make sure you have `notify-send` or `kdialog` installed. If you're using Ubuntu you should already be all set!
|
|
||||||
- On Windows you can use [notifu](https://www.paralint.com/projects/notifu/) or the Cygwin Ports libnotify package
|
|
||||||
|
|
||||||
|
|
||||||
## Screenshots
|
|
||||||
|
|
||||||
**Linux**
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
**OS X**
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
**Windows**
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
|
|
||||||
## Configuration
|
|
||||||
|
|
||||||
One can configure a few things:
|
|
||||||
|
|
||||||
- `bgnotify_bell` enabled or disables the terminal bell (default true)
|
|
||||||
- `bgnotify_threshold` sets the notification threshold time (default 6 seconds)
|
|
||||||
- `function bgnotify_formatted` lets you change the notification. You can for instance customize the message and pass in an icon.
|
|
||||||
- `bgnotify_extraargs` appends extra args to notifier (e.g. `-e` for notify-send to create a transient notification)
|
|
||||||
|
|
||||||
Use these by adding a function definition before the your call to source. Example:
|
|
||||||
|
|
||||||
```sh
|
|
||||||
bgnotify_bell=false ## disable terminal bell
|
|
||||||
bgnotify_threshold=4 ## set your own notification threshold
|
|
||||||
|
|
||||||
function bgnotify_formatted {
|
|
||||||
## $1=exit_status, $2=command, $3=elapsed_time
|
|
||||||
|
|
||||||
# Humanly readable elapsed time
|
|
||||||
local elapsed="$(( $3 % 60 ))s"
|
|
||||||
(( $3 < 60 )) || elapsed="$((( $3 % 3600) / 60 ))m $elapsed"
|
|
||||||
(( $3 < 3600 )) || elapsed="$(( $3 / 3600 ))h $elapsed"
|
|
||||||
|
|
||||||
[ $1 -eq 0 ] && title="Holy Smokes Batman" || title="Holy Graf Zeppelin"
|
|
||||||
[ $1 -eq 0 ] && icon="$HOME/icons/success.png" || icon="$HOME/icons/fail.png"
|
|
||||||
bgnotify "$title - took ${elapsed}" "$2" "$icon"
|
|
||||||
}
|
|
||||||
|
|
||||||
plugins=(git bgnotify) ## add to plugins list
|
|
||||||
source $ZSH/oh-my-zsh.sh ## existing source call
|
|
||||||
```
|
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user