mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2026-01-23 02:35:38 +01:00
Merge branch 'master' into feature/clear-evicted-pods
This commit is contained in:
commit
3d16546946
190 changed files with 4251 additions and 1369 deletions
20
.devcontainer/devcontainer.json
Normal file
20
.devcontainer/devcontainer.json
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
{
|
||||
"image": "mcr.microsoft.com/devcontainers/base:noble",
|
||||
"features": {
|
||||
"ghcr.io/devcontainers/features/common-utils": {
|
||||
"installZsh": true,
|
||||
"configureZshAsDefaultShell": true,
|
||||
"username": "vscode",
|
||||
"userUid": 1000,
|
||||
"userGid": 1000
|
||||
}
|
||||
},
|
||||
"postCreateCommand": "dir=/workspaces/ohmyzsh; rm -rf $HOME/.oh-my-zsh && ln -s $dir $HOME/.oh-my-zsh && cp $dir/templates/minimal.zshrc $HOME/.zshrc && chgrp -R 1000 $dir && chmod g-w,o-w $dir",
|
||||
"customizations": {
|
||||
"codespaces": {
|
||||
"openFiles": [
|
||||
"README.md"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -9,3 +9,7 @@ indent_style = space
|
|||
|
||||
[*.py]
|
||||
indent_size = 4
|
||||
|
||||
[devcontainer.json]
|
||||
indent_size = 4
|
||||
indent_style = tab
|
||||
|
|
|
|||
5
.github/CODEOWNERS
vendored
5
.github/CODEOWNERS
vendored
|
|
@ -5,10 +5,15 @@ plugins/eza/ @pepoluan
|
|||
plugins/genpass/ @atoponce
|
||||
plugins/git-lfs/ @hellovietduc
|
||||
plugins/gitfast/ @felipec
|
||||
plugins/kube-ps1/ @mcornella
|
||||
plugins/kubectl/ @mcornella
|
||||
plugins/kubectx/ @mcornella
|
||||
plugins/opentofu/ @mcornella
|
||||
plugins/react-native @esthor
|
||||
plugins/sdk/ @rgoldberg
|
||||
plugins/shell-proxy/ @septs
|
||||
plugins/starship/ @axieax
|
||||
plugins/terraform/ @mcornella
|
||||
plugins/universalarchive/ @Konfekt
|
||||
plugins/wp-cli/ @joshmedeski
|
||||
plugins/zoxide/ @ajeetdsouza
|
||||
|
|
|
|||
87
.github/INCIDENT_RESPONSE_PLAN.md
vendored
Normal file
87
.github/INCIDENT_RESPONSE_PLAN.md
vendored
Normal file
|
|
@ -0,0 +1,87 @@
|
|||
# Incident Response Plan
|
||||
|
||||
## Reporting a Vulnerability
|
||||
|
||||
Please see [the latest guidelines](https://github.com/ohmyzsh/ohmyzsh/blob/master/SECURITY.md) for instructions.
|
||||
|
||||
## Phases
|
||||
|
||||
### Triage
|
||||
|
||||
1. Is this a valid security vulnerability?
|
||||
|
||||
- [ ] It affects our CI/CD or any of our repositories.
|
||||
- [ ] For ohmyzsh/ohmyzsh, it affects the latest commit.
|
||||
- [ ] For others, it affects the latest commit on the default branch.
|
||||
- [ ] It affects a third-party dependency:
|
||||
- [ ] Zsh or git
|
||||
- [ ] For a plugin, the vulnerability is a result of our usage of the dependency.
|
||||
|
||||
2. What's the scope of the vulnerability?
|
||||
|
||||
- [ ] Our codebase.
|
||||
- [ ] A direct third-party dependency (Zsh, git, other plugins).
|
||||
- [ ] An indirect third-party dependency.
|
||||
- [ ] Out of scope, a third-party dependency that is the responsibility of the user.
|
||||
- [ ] Out of scope, any other case (edit this plan and add the details).
|
||||
|
||||
3. Is the vulnerability actionable?
|
||||
|
||||
- [ ] Yes, we can submit a fix.
|
||||
- [ ] Yes, we can disable a feature.
|
||||
- [ ] Yes, we can mitigate the risk.
|
||||
- [ ] Yes, we can remove a vulnerable dependency.
|
||||
- [ ] Yes, we can apply a workaround.
|
||||
- [ ] Yes, we can apply a patch to a vulnerable dependency ([example for CVE-2021-45444](https://github.com/ohmyzsh/ohmyzsh/blob/cb72d7dcbf08b435c7f8a6470802b207b2aa02c3/lib/vcs_info.zsh)).
|
||||
- [ ] No, the vulnerability is not actionable.
|
||||
|
||||
4. What's the impact of the vulnerability?
|
||||
|
||||
Assess using the *CIA* triad:
|
||||
|
||||
- **Confidentiality**: example: report or sharing of secrets.
|
||||
- **Integrity**: affects the integrity of the system (deletion, corruption or encryption of data, OS file corruption, etc.).
|
||||
- **Availability**: denial of login, deletion of required files to boot / login, etc.
|
||||
|
||||
5. What's the exploitability of the vulnerability?
|
||||
|
||||
Consider how easy it is to exploit, and if it affects all users or requires specific configurations.
|
||||
|
||||
6. What's the severity of the vulnerability?
|
||||
|
||||
You can use the [CVSS v3.1](https://www.first.org/cvss/specification-document) to assess the severity of the vulnerability.
|
||||
|
||||
7. When was the vulnerability introduced?
|
||||
|
||||
- Find the responsible code path.
|
||||
- Find the commit or Pull Request that introduced the vulnerability.
|
||||
|
||||
8. Who are our security contacts?
|
||||
|
||||
Assess upstream or downstream contacts, and their desired channels of security.
|
||||
|
||||
> TODO: add a list of contacts.
|
||||
|
||||
### Mitigation
|
||||
|
||||
- **Primary focus:** removing possibility of exploitation fast.
|
||||
- **Secondary focus:** addressing the root cause.
|
||||
|
||||
> [!IMPORTANT]
|
||||
> Make sure to test that the mitigation works as expected, and does not introduce new vulnerabilities.
|
||||
> When deploying a patch, make sure not to disclose the vulnerability in the commit message or PR description.
|
||||
|
||||
> TODO: introduce a fast-track update process for security patches.
|
||||
|
||||
### Disclosure
|
||||
|
||||
Primary goal: inform our users about the vulnerability, and whether they are affected or not affected based on information they should be able to check themselves in a straightforward way.
|
||||
|
||||
> TODO: add a vulnerability disclosure template.
|
||||
|
||||
### Learn
|
||||
|
||||
- Document the vulnerability, steps performed, and lessons learned.
|
||||
- Document the timeline of events.
|
||||
- Document and address improvements on the Security Incident Response Plan.
|
||||
- Depending on the severity of the vulnerability, consider disclosing the root cause or not based on likely impact on users and estimated potential victims still affected.
|
||||
12
.github/dependencies.yml
vendored
12
.github/dependencies.yml
vendored
|
|
@ -2,11 +2,13 @@ dependencies:
|
|||
plugins/gitfast:
|
||||
repo: felipec/git-completion
|
||||
branch: master
|
||||
version: tag:v2.1
|
||||
version: tag:v2.2
|
||||
postcopy: |
|
||||
set -e
|
||||
rm -rf git-completion.plugin.zsh Makefile README.adoc t tools
|
||||
test -e git-completion.zsh && mv -f git-completion.zsh _git
|
||||
rm -rf git-completion.plugin.zsh Makefile t tools
|
||||
mv README.adoc MANUAL.adoc
|
||||
mv -f src/* .
|
||||
rmdir src
|
||||
plugins/gradle:
|
||||
repo: gradle/gradle-completion
|
||||
branch: master
|
||||
|
|
@ -28,7 +30,7 @@ dependencies:
|
|||
plugins/wd:
|
||||
repo: mfaerevaag/wd
|
||||
branch: master
|
||||
version: tag:v0.7.1
|
||||
version: tag:v0.10.1
|
||||
precopy: |
|
||||
set -e
|
||||
rm -r test
|
||||
|
|
@ -36,7 +38,7 @@ dependencies:
|
|||
plugins/z:
|
||||
branch: master
|
||||
repo: agkozak/zsh-z
|
||||
version: afaf2965b41fdc6ca66066e09382726aa0b6aa04
|
||||
version: cf9225feebfae55e557e103e95ce20eca5eff270
|
||||
precopy: |
|
||||
set -e
|
||||
test -e README.md && mv -f README.md MANUAL.md
|
||||
|
|
|
|||
13
.github/workflows/dependencies.yml
vendored
13
.github/workflows/dependencies.yml
vendored
|
|
@ -4,6 +4,9 @@ on:
|
|||
schedule:
|
||||
- cron: "0 6 * * 0"
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
check:
|
||||
name: Check for updates
|
||||
|
|
@ -15,11 +18,11 @@ jobs:
|
|||
with:
|
||||
fetch-depth: 0
|
||||
- name: Authenticate as @ohmyzsh
|
||||
id: generate_token
|
||||
uses: ohmyzsh/github-app-token@v2
|
||||
id: generate-token
|
||||
uses: actions/create-github-app-token@v2
|
||||
with:
|
||||
app_id: ${{ secrets.OHMYZSH_APP_ID }}
|
||||
private_key: ${{ secrets.OHMYZSH_APP_PRIVATE_KEY }}
|
||||
app-id: ${{ secrets.OHMYZSH_APP_ID }}
|
||||
private-key: ${{ secrets.OHMYZSH_APP_PRIVATE_KEY }}
|
||||
- name: Setup Python
|
||||
uses: actions/setup-python@v5
|
||||
with:
|
||||
|
|
@ -27,7 +30,7 @@ jobs:
|
|||
cache: "pip"
|
||||
- name: Process dependencies
|
||||
env:
|
||||
GH_TOKEN: ${{ steps.generate_token.outputs.token }}
|
||||
GH_TOKEN: ${{ steps.generate-token.outputs.token }}
|
||||
GIT_APP_NAME: ohmyzsh[bot]
|
||||
GIT_APP_EMAIL: 54982679+ohmyzsh[bot]@users.noreply.github.com
|
||||
TMP_DIR: ${{ runner.temp }}
|
||||
|
|
|
|||
14
.github/workflows/dependencies/requirements.txt
vendored
14
.github/workflows/dependencies/requirements.txt
vendored
|
|
@ -1,7 +1,7 @@
|
|||
certifi==2024.7.4
|
||||
charset-normalizer==3.3.2
|
||||
idna==3.7
|
||||
PyYAML==6.0.1
|
||||
requests==2.32.3
|
||||
semver==3.0.2
|
||||
urllib3==2.2.2
|
||||
certifi==2025.7.14
|
||||
charset-normalizer==3.4.3
|
||||
idna==3.10
|
||||
PyYAML==6.0.2
|
||||
requests==2.32.4
|
||||
semver==3.0.4
|
||||
urllib3==2.5.0
|
||||
|
|
|
|||
2
.github/workflows/dependencies/updater.py
vendored
2
.github/workflows/dependencies/updater.py
vendored
|
|
@ -228,7 +228,7 @@ class Dependency:
|
|||
self.__apply_upstream_changes()
|
||||
|
||||
# Add all changes and commit
|
||||
has_new_commit = Git.add_and_commit(self.name, short_sha)
|
||||
has_new_commit = Git.add_and_commit(self.name, new_version)
|
||||
|
||||
if has_new_commit:
|
||||
# Push changes to remote
|
||||
|
|
|
|||
4
.github/workflows/installer/vercel.json
vendored
4
.github/workflows/installer/vercel.json
vendored
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"headers": [
|
||||
{
|
||||
"source": "/((?!favicon.ico).*)",
|
||||
"source": "/(|install.sh)",
|
||||
"headers": [
|
||||
{
|
||||
"key": "Content-Type",
|
||||
|
|
@ -16,7 +16,7 @@
|
|||
],
|
||||
"rewrites": [
|
||||
{
|
||||
"source": "/((?!favicon.ico|install.sh).*)",
|
||||
"source": "/",
|
||||
"destination": "/install.sh"
|
||||
}
|
||||
]
|
||||
|
|
|
|||
10
.github/workflows/project.yml
vendored
10
.github/workflows/project.yml
vendored
|
|
@ -17,13 +17,13 @@ jobs:
|
|||
if: github.repository == 'ohmyzsh/ohmyzsh'
|
||||
steps:
|
||||
- name: Authenticate as @ohmyzsh
|
||||
id: generate_token
|
||||
uses: ohmyzsh/github-app-token@v2
|
||||
id: generate-token
|
||||
uses: actions/create-github-app-token@v2
|
||||
with:
|
||||
app_id: ${{ secrets.OHMYZSH_APP_ID }}
|
||||
private_key: ${{ secrets.OHMYZSH_APP_PRIVATE_KEY }}
|
||||
app-id: ${{ secrets.OHMYZSH_APP_ID }}
|
||||
private-key: ${{ secrets.OHMYZSH_APP_PRIVATE_KEY }}
|
||||
- name: Store app token
|
||||
run: echo "GH_TOKEN=${{ steps.generate_token.outputs.token }}" >> "$GITHUB_ENV"
|
||||
run: echo "GH_TOKEN=${{ steps.generate-token.outputs.token }}" >> "$GITHUB_ENV"
|
||||
- name: Read project data
|
||||
env:
|
||||
ORGANIZATION: ohmyzsh
|
||||
|
|
|
|||
3
.gitignore
vendored
3
.gitignore
vendored
|
|
@ -10,3 +10,6 @@ log/
|
|||
# editor configs
|
||||
.vscode
|
||||
.idea
|
||||
|
||||
# zcompile cached files
|
||||
*.zwc
|
||||
|
|
|
|||
241
README.md
241
README.md
|
|
@ -1,16 +1,21 @@
|
|||
<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.
|
||||
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?"_
|
||||
Once installed, your terminal shell will become the talk of the town _or your money back!_ With each keystroke
|
||||
in your command prompt, you'll take advantage of the hundreds of powerful plugins and beautiful themes.
|
||||
Strangers will come up to you in cafés and ask you, _"that is amazing! are you some sort of genius?"_
|
||||
|
||||
Finally, you'll begin to get the sort of attention that you have always felt you deserved. ...or maybe you'll use the time that you're saving to start flossing more often. 😬
|
||||
Finally, you'll begin to get the sort of attention that you have always felt you deserved. ...or maybe you'll
|
||||
use the time that you're saving to start flossing more often. 😬
|
||||
|
||||
To learn more, visit [ohmyz.sh](https://ohmyz.sh), follow [@ohmyzsh](https://x.com/ohmyzsh) on X (formerly Twitter), and join us on [Discord](https://discord.gg/ohmyzsh).
|
||||
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://twitter.com/intent/follow?screen_name=ohmyzsh)
|
||||
|
|
@ -43,7 +48,7 @@ To learn more, visit [ohmyz.sh](https://ohmyz.sh), follow [@ohmyzsh](https://x.c
|
|||
- [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)
|
||||
- [Disable async git prompt](#disable-async-git-prompt)
|
||||
- [Async git prompt](#async-git-prompt)
|
||||
- [Getting Updates](#getting-updates)
|
||||
- [Updates Verbosity](#updates-verbosity)
|
||||
- [Manual Updates](#manual-updates)
|
||||
|
|
@ -62,26 +67,28 @@ To learn more, visit [ohmyz.sh](https://ohmyz.sh), follow [@ohmyzsh](https://x.c
|
|||
|
||||
### Operating System Compatibility
|
||||
|
||||
| O/S | Status |
|
||||
| :------------- | :-----: |
|
||||
| Android | ✅ |
|
||||
| freeBSD | ✅ |
|
||||
| LCARS | 🛸 |
|
||||
| Linux | ✅ |
|
||||
| macOS | ✅ |
|
||||
| OS/2 Warp | ❌ |
|
||||
| Windows (WSL2) | ✅ |
|
||||
|
||||
| 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)
|
||||
- [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.
|
||||
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 |
|
||||
| :-------- | :------------------------------------------------------------------------------------------------ |
|
||||
|
|
@ -89,38 +96,44 @@ Oh My Zsh is installed by running one of the following commands in your terminal
|
|||
| **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`:
|
||||
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/)"` |
|
||||
| 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`._
|
||||
_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:
|
||||
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.
|
||||
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.
|
||||
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.
|
||||
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
|
||||
|
|
@ -140,21 +153,28 @@ plugins=(
|
|||
)
|
||||
```
|
||||
|
||||
_Note that the plugins are separated by whitespace (spaces, tabs, new lines...). **Do not** use commas between them or it will break._
|
||||
_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.
|
||||
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!
|
||||
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)._
|
||||
_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:
|
||||
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"
|
||||
|
|
@ -167,21 +187,38 @@ ZSH_THEME="agnoster" # (this is one of the fancy ones)
|
|||
# see https://github.com/ohmyzsh/ohmyzsh/wiki/Themes#agnoster
|
||||
```
|
||||
|
||||
_Note: 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](https://github.com/ohmyzsh/ohmyzsh/wiki/FAQ#i-have-a-weird-character-in-my-prompt)_
|
||||
<!-- 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).
|
||||
In case you did not find a suitable theme for your needs, please have a look at the wiki for
|
||||
[more of them](https://github.com/ohmyzsh/ohmyzsh/wiki/External-themes).
|
||||
|
||||
If you're feeling feisty, you can let the computer select one randomly for you each time you open a new terminal window.
|
||||
If you're feeling feisty, you can let the computer select one randomly for you each time you open a new
|
||||
terminal window.
|
||||
|
||||
```sh
|
||||
ZSH_THEME="random" # (...please let it be pie... please be some pie..)
|
||||
```
|
||||
|
||||
And if you want to pick random theme from a list of your favorite themes:
|
||||
And if you want to pick a random theme from a list of your favorite themes:
|
||||
|
||||
```sh
|
||||
ZSH_THEME_RANDOM_CANDIDATES=(
|
||||
|
|
@ -198,7 +235,8 @@ 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).
|
||||
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
|
||||
|
||||
|
|
@ -206,16 +244,16 @@ If you're the type that likes to get their hands dirty, these sections might res
|
|||
|
||||
### 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).
|
||||
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`)
|
||||
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:
|
||||
`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
|
||||
|
|
@ -223,32 +261,33 @@ 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.
|
||||
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.
|
||||
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}`.
|
||||
- `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`).
|
||||
- `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`.
|
||||
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:
|
||||
|
||||
|
|
@ -294,16 +333,21 @@ Once you open up a new terminal window, it should load zsh with Oh My Zsh's conf
|
|||
|
||||
If you have any hiccups installing, here are a few common fixes.
|
||||
|
||||
- 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`.
|
||||
- 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 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 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/`.
|
||||
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
|
||||
|
||||
|
|
@ -323,9 +367,9 @@ _Note: this is not compatible with `DISABLE_LS_COLORS=true`_
|
|||
|
||||
<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.
|
||||
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
|
||||
|
|
@ -364,27 +408,36 @@ 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.
|
||||
> 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.
|
||||
> 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.
|
||||
|
||||
### Disable async git prompt
|
||||
### 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:
|
||||
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**:
|
||||
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:
|
||||
|
||||
|
|
@ -427,37 +480,55 @@ 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:
|
||||
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.
|
||||
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!
|
||||
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.
|
||||
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.
|
||||
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.
|
||||
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!
|
||||
|
||||
|
|
@ -476,7 +547,9 @@ We're on social media:
|
|||
|
||||
## Merchandise
|
||||
|
||||
We have [stickers, shirts, and coffee mugs available](https://shop.planetargon.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!
|
||||
We have
|
||||
[stickers, shirts, and coffee mugs available](https://shop.planetargon.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
|
||||
|
||||
|
|
@ -486,4 +559,6 @@ Oh My Zsh is released under the [MIT license](LICENSE.txt).
|
|||
|
||||

|
||||
|
||||
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).
|
||||
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).
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ autoload -Uz is-at-least
|
|||
# This API is subject to change and optimization. Rely on it at your own risk.
|
||||
|
||||
function _omz_register_handler {
|
||||
setopt localoptions noksharrays
|
||||
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]} )) \
|
||||
|
|
@ -44,6 +44,7 @@ function _omz_register_handler {
|
|||
|
||||
# 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
|
||||
|
||||
|
|
|
|||
20
lib/bzr.zsh
20
lib/bzr.zsh
|
|
@ -1,10 +1,14 @@
|
|||
## Bazaar integration
|
||||
## Just works with the GIT integration just add $(bzr_prompt_info) to the PROMPT
|
||||
## Just works with the GIT integration. Add $(bzr_prompt_info) to the PROMPT
|
||||
function bzr_prompt_info() {
|
||||
BZR_CB=`bzr nick 2> /dev/null | grep -v "ERROR" | cut -d ":" -f2 | awk -F / '{print "bzr::"$1}'`
|
||||
if [ -n "$BZR_CB" ]; then
|
||||
BZR_DIRTY=""
|
||||
[[ -n `bzr status` ]] && BZR_DIRTY=" %{$fg[red]%} * %{$fg[green]%}"
|
||||
echo "$ZSH_THEME_SCM_PROMPT_PREFIX$BZR_CB$BZR_DIRTY$ZSH_THEME_GIT_PROMPT_SUFFIX"
|
||||
fi
|
||||
}
|
||||
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
|
||||
}
|
||||
|
|
|
|||
86
lib/cli.zsh
86
lib/cli.zsh
|
|
@ -1,6 +1,7 @@
|
|||
#!/usr/bin/env zsh
|
||||
|
||||
function omz {
|
||||
setopt localoptions noksharrays
|
||||
[[ $# -gt 0 ]] || {
|
||||
_omz::help
|
||||
return 1
|
||||
|
|
@ -71,6 +72,10 @@ function _omz {
|
|||
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"/:::))
|
||||
|
|
@ -192,7 +197,7 @@ EOF
|
|||
return 1
|
||||
fi
|
||||
|
||||
"$ZSH/tools/changelog.sh" "$version" "${2:-}" "$format"
|
||||
ZSH="$ZSH" command zsh -f "$ZSH/tools/changelog.sh" "$version" "${2:-}" "$format"
|
||||
}
|
||||
|
||||
function _omz::plugin {
|
||||
|
|
@ -205,7 +210,7 @@ Available commands:
|
|||
disable <plugin> Disable plugin(s)
|
||||
enable <plugin> Enable plugin(s)
|
||||
info <plugin> Get information of a plugin
|
||||
list List all available Oh My Zsh plugins
|
||||
list [--enabled] List Oh My Zsh plugins
|
||||
load <plugin> Load plugin(s)
|
||||
|
||||
EOF
|
||||
|
|
@ -344,20 +349,40 @@ function _omz::plugin::enable {
|
|||
next
|
||||
}
|
||||
|
||||
# if plugins=() is in multiline form, enable multi flag
|
||||
# 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 and disable multi flag
|
||||
# add new plugins with proper indent and disable multi flag
|
||||
multi == 1 && /^[^#]*\)/ {
|
||||
multi=0
|
||||
sub(/\)/, \" $add_plugins&\")
|
||||
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 }
|
||||
"
|
||||
|
||||
|
|
@ -397,8 +422,23 @@ function _omz::plugin::info {
|
|||
local readme
|
||||
for readme in "$ZSH_CUSTOM/plugins/$1/README.md" "$ZSH/plugins/$1/README.md"; do
|
||||
if [[ -f "$readme" ]]; then
|
||||
(( ${+commands[less]} )) && less "$readme" || cat "$readme"
|
||||
return 0
|
||||
# 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
|
||||
|
||||
|
|
@ -413,8 +453,21 @@ function _omz::plugin::info {
|
|||
|
||||
function _omz::plugin::list {
|
||||
local -a custom_plugins builtin_plugins
|
||||
custom_plugins=("$ZSH_CUSTOM"/plugins/*(-/N:t))
|
||||
builtin_plugins=("$ZSH"/plugins/*(-/N:t))
|
||||
|
||||
# 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
|
||||
|
|
@ -787,6 +840,13 @@ function _omz::update {
|
|||
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..."
|
||||
|
|
@ -795,11 +855,7 @@ function _omz::update {
|
|||
|
||||
# Run update script
|
||||
zstyle -s ':omz:update' verbose verbose_mode || verbose_mode=default
|
||||
if [[ "$1" != --unattended ]]; then
|
||||
ZSH="$ZSH" command zsh -f "$ZSH/tools/upgrade.sh" -i -v $verbose_mode || return $?
|
||||
else
|
||||
ZSH="$ZSH" command zsh -f "$ZSH/tools/upgrade.sh" -v $verbose_mode || return $?
|
||||
fi
|
||||
ZSH="$ZSH" command zsh -f "$ZSH/tools/upgrade.sh" -i -v $verbose_mode || return $?
|
||||
|
||||
# Update last updated file
|
||||
zmodload zsh/datetime
|
||||
|
|
@ -808,7 +864,7 @@ function _omz::update {
|
|||
command rm -rf "$ZSH/log/update.lock"
|
||||
|
||||
# Restart the zsh session if there were changes
|
||||
if [[ "$1" != --unattended && "$(builtin cd -q "$ZSH"; git rev-parse HEAD)" != "$last_commit" ]]; then
|
||||
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
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ 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 useable
|
||||
# Use caching so that commands like apt and dpkg complete are usable
|
||||
zstyle ':completion:*' use-cache yes
|
||||
zstyle ':completion:*' cache-path $ZSH_CACHE_DIR
|
||||
|
||||
|
|
|
|||
|
|
@ -23,6 +23,9 @@ function open_command() {
|
|||
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"
|
||||
|
|
@ -57,6 +60,16 @@ function takeurl() {
|
|||
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})"
|
||||
|
|
@ -65,6 +78,8 @@ function takegit() {
|
|||
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
|
||||
|
|
|
|||
388
lib/git.zsh
388
lib/git.zsh
|
|
@ -39,185 +39,6 @@ function _omz_git_prompt_info() {
|
|||
echo "${ZSH_THEME_GIT_PROMPT_PREFIX}${ref:gs/%/%%}${upstream:gs/%/%%}$(parse_git_dirty)${ZSH_THEME_GIT_PROMPT_SUFFIX}"
|
||||
}
|
||||
|
||||
# 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
|
||||
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)
|
||||
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/}
|
||||
}
|
||||
|
||||
|
||||
# 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"
|
||||
}
|
||||
|
||||
function _omz_git_prompt_status() {
|
||||
[[ "$(__git_prompt_git config --get oh-my-zsh.hide-status 2>/dev/null)" = 1 ]] && return
|
||||
|
||||
|
|
@ -227,7 +48,7 @@ function _omz_git_prompt_status() {
|
|||
prefix_constant_map=(
|
||||
'\?\? ' 'UNTRACKED'
|
||||
'A ' 'ADDED'
|
||||
'M ' 'ADDED'
|
||||
'M ' 'MODIFIED'
|
||||
'MM ' 'MODIFIED'
|
||||
' M ' 'MODIFIED'
|
||||
'AM ' 'MODIFIED'
|
||||
|
|
@ -317,6 +138,213 @@ function _omz_git_prompt_status() {
|
|||
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() {
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ else
|
|||
}
|
||||
|
||||
# Ignore these folders (if the necessary grep flags are available)
|
||||
EXC_FOLDERS="{.bzr,CVS,.git,.hg,.svn,.idea,.tox}"
|
||||
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
|
||||
|
|
@ -24,8 +24,8 @@ else
|
|||
if [[ -n "$GREP_OPTIONS" ]]; then
|
||||
# export grep, egrep and fgrep settings
|
||||
alias grep="grep $GREP_OPTIONS"
|
||||
alias egrep="grep -E $GREP_OPTIONS"
|
||||
alias fgrep="grep -F $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
|
||||
|
|
|
|||
|
|
@ -18,10 +18,10 @@ function omz_history {
|
|||
print -u2 History file deleted.
|
||||
elif [[ $# -eq 0 ]]; then
|
||||
# if no arguments provided, show full history starting from 1
|
||||
builtin fc $stamp -l 1
|
||||
builtin fc "${stamp[@]}" -l 1
|
||||
else
|
||||
# otherwise, run `fc -l` with a custom format
|
||||
builtin fc $stamp -l "$@"
|
||||
builtin fc "${stamp[@]}" -l "$@"
|
||||
fi
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ setopt multios # enable redirect to multiple streams: echo >file1 >
|
|||
setopt long_list_jobs # show long list format job notifications
|
||||
setopt interactivecomments # recognize comments
|
||||
|
||||
# define pager dependant on what is available (less or more)
|
||||
# define pager depending on what is available (less or more)
|
||||
if (( ${+commands[less]} )); then
|
||||
env_default 'PAGER' 'less'
|
||||
env_default 'LESS' '-R'
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ function title {
|
|||
: ${2=$1}
|
||||
|
||||
case "$TERM" in
|
||||
cygwin|xterm*|putty*|rxvt*|konsole*|ansi|mlterm*|alacritty*|st*|foot*|contour*)
|
||||
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
|
||||
;;
|
||||
|
|
@ -47,13 +47,13 @@ fi
|
|||
|
||||
# Runs before showing the prompt
|
||||
function omz_termsupport_precmd {
|
||||
[[ "${DISABLE_AUTO_TITLE:-}" != true ]] || return
|
||||
[[ "${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
|
||||
[[ "${DISABLE_AUTO_TITLE:-}" != true ]] || return 0
|
||||
|
||||
emulate -L zsh
|
||||
setopt extended_glob
|
||||
|
|
@ -145,6 +145,7 @@ esac
|
|||
# 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
|
||||
|
|
|
|||
|
|
@ -99,8 +99,8 @@ done
|
|||
|
||||
# Figure out the SHORT hostname
|
||||
if [[ "$OSTYPE" = darwin* ]]; then
|
||||
# macOS's $HOST changes with dhcp, etc. Use ComputerName if possible.
|
||||
SHORT_HOST=$(scutil --get ComputerName 2>/dev/null) || SHORT_HOST="${HOST/.*/}"
|
||||
# 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
|
||||
|
|
@ -192,7 +192,7 @@ _omz_source() {
|
|||
fi
|
||||
}
|
||||
|
||||
# Load all of the lib files in ~/oh-my-zsh/lib that end in .zsh
|
||||
# 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}"
|
||||
|
|
|
|||
|
|
@ -1,9 +1,15 @@
|
|||
# Do nothing if op is not installed
|
||||
(( ${+commands[op]} )) || return
|
||||
|
||||
# Load op completion
|
||||
eval "$(op completion zsh)"
|
||||
compdef _op op
|
||||
# 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
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ function opswd() {
|
|||
|
||||
local password
|
||||
# Copy the password to the clipboard
|
||||
if ! password=$(op item get "$service" --fields password 2>/dev/null); then
|
||||
if ! password=$(op item get "$service" --reveal --fields password 2>/dev/null); then
|
||||
echo "error: could not obtain password for $service"
|
||||
return 1
|
||||
fi
|
||||
|
|
|
|||
|
|
@ -11,6 +11,8 @@ 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
|
||||
|
||||
|
|
@ -28,7 +30,7 @@ When you execute a command alias finder will look at your defined aliases and su
|
|||
|
||||
Running the un-aliased `git status` command:
|
||||
```sh
|
||||
╭─tim@fox ~/repo/gitopolis ‹main›
|
||||
╭─tim@fox ~/repo/gitopolis ‹main›
|
||||
╰─$ git status
|
||||
|
||||
gst='git status' # <=== shorter suggestion from alias-finder
|
||||
|
|
@ -40,7 +42,7 @@ nothing to commit, working tree clean
|
|||
|
||||
Running a shorter `git st` alias from `.gitconfig` that it suggested :
|
||||
```sh
|
||||
╭─tim@fox ~/repo/gitopolis ‹main›
|
||||
╭─tim@fox ~/repo/gitopolis ‹main›
|
||||
╰─$ git st
|
||||
gs='git st' # <=== shorter suggestion from alias-finder
|
||||
## main...origin/main
|
||||
|
|
@ -48,7 +50,7 @@ gs='git st' # <=== shorter suggestion from alias-finder
|
|||
|
||||
Running the shortest `gs` shell alias that it found:
|
||||
```sh
|
||||
╭─tim@fox ~/repo/gitopolis ‹main›
|
||||
╭─tim@fox ~/repo/gitopolis ‹main›
|
||||
╰─$ gs
|
||||
# <=== no suggestions alias-finder because this is the shortest
|
||||
## main...origin/main
|
||||
|
|
|
|||
|
|
@ -36,14 +36,22 @@ alias-finder() {
|
|||
# make filter to find only shorter results than current cmd
|
||||
if [[ $cheaper == true ]]; then
|
||||
cmdLen=$(echo -n "$cmd" | wc -c)
|
||||
filter="^'{0,1}.{0,$((cmdLen - 1))}="
|
||||
if [[ $cmdLen -le 1 ]]; then
|
||||
return
|
||||
fi
|
||||
|
||||
filter="^'?.{1,$((cmdLen - 1))}'?=" # some aliases is surrounded by single quotes
|
||||
fi
|
||||
|
||||
alias | grep -E "$filter" | grep -E "=$finder"
|
||||
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
|
||||
elif [[ $longer == true ]]; then
|
||||
break # because above grep command already found every longer aliases during first cycle
|
||||
fi
|
||||
|
||||
|
|
|
|||
|
|
@ -178,26 +178,27 @@ 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 -Sy --needed --noconfirm archlinux-keyring
|
||||
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 -Syu
|
||||
yay -Su
|
||||
elif (( $+commands[trizen] )); then
|
||||
trizen -Syu
|
||||
trizen -Su
|
||||
elif (( $+commands[pacaur] )); then
|
||||
pacaur -Syu
|
||||
pacaur -Su
|
||||
elif (( $+commands[aura] )); then
|
||||
sudo aura -Syu
|
||||
sudo aura -Su
|
||||
else
|
||||
sudo pacman -Syu
|
||||
sudo pacman -Su
|
||||
fi
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,32 +1,48 @@
|
|||
## asdf
|
||||
# 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
|
||||
## Installation
|
||||
|
||||
1. [Download asdf](https://asdf-vm.com/guide/getting-started.html#_2-download-asdf) by running the following:
|
||||
|
||||
```
|
||||
git clone https://github.com/asdf-vm/asdf.git ~/.asdf
|
||||
```
|
||||
|
||||
2. [Enable asdf](https://asdf-vm.com/guide/getting-started.html#_3-install-asdf) by adding it to your `plugins` definition in `~/.zshrc`.
|
||||
|
||||
```
|
||||
plugins=(asdf)
|
||||
```
|
||||
|
||||
### Usage
|
||||
|
||||
See the [asdf documentation](https://asdf-vm.com/guide/getting-started.html#_4-install-a-plugin) for information on how to use asdf:
|
||||
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)
|
||||
```
|
||||
asdf plugin add nodejs https://github.com/asdf-vm/asdf-nodejs.git
|
||||
|
||||
## 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
|
||||
asdf global nodejs latest
|
||||
asdf local 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
|
||||
```
|
||||
|
||||
### Maintainer
|
||||
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,30 +1,13 @@
|
|||
# Find where asdf should be installed
|
||||
ASDF_DIR="${ASDF_DIR:-$HOME/.asdf}"
|
||||
ASDF_COMPLETIONS="$ASDF_DIR/completions"
|
||||
(( ! $+commands[asdf] )) && return
|
||||
|
||||
if [[ ! -f "$ASDF_DIR/asdf.sh" || ! -f "$ASDF_COMPLETIONS/_asdf" ]]; then
|
||||
# If not found, check for archlinux/AUR package (/opt/asdf-vm/)
|
||||
if [[ -f "/opt/asdf-vm/asdf.sh" ]]; then
|
||||
ASDF_DIR="/opt/asdf-vm"
|
||||
ASDF_COMPLETIONS="$ASDF_DIR"
|
||||
# If not found, check for Homebrew package
|
||||
elif (( $+commands[brew] )); then
|
||||
_ASDF_PREFIX="$(brew --prefix asdf)"
|
||||
ASDF_DIR="${_ASDF_PREFIX}/libexec"
|
||||
ASDF_COMPLETIONS="${_ASDF_PREFIX}/share/zsh/site-functions"
|
||||
unset _ASDF_PREFIX
|
||||
else
|
||||
return
|
||||
fi
|
||||
fi
|
||||
export ASDF_DATA_DIR="${ASDF_DATA_DIR:-$HOME/.asdf}"
|
||||
path=("$ASDF_DATA_DIR/shims" $path)
|
||||
|
||||
# Load command
|
||||
if [[ -f "$ASDF_DIR/asdf.sh" ]]; then
|
||||
source "$ASDF_DIR/asdf.sh"
|
||||
# Load completions
|
||||
if [[ -f "$ASDF_COMPLETIONS/_asdf" ]]; then
|
||||
fpath+=("$ASDF_COMPLETIONS")
|
||||
autoload -Uz _asdf
|
||||
compdef _asdf asdf # compdef is already loaded before loading plugins
|
||||
fi
|
||||
# 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" &|
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ autojump_paths=(
|
|||
/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
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
# 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.
|
||||
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:
|
||||
|
||||
|
|
@ -14,9 +15,15 @@ The plugin has a copy of [the completion script from the git repository][1].
|
|||
|
||||
## 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 |
|
||||
| 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 |
|
||||
|
|
|
|||
|
|
@ -3,3 +3,7 @@ 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-/'
|
||||
}
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ case $state in
|
|||
"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 redistrubute intervals in a genome.]" \
|
||||
"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.]" \
|
||||
|
|
|
|||
|
|
@ -38,6 +38,7 @@ 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:
|
||||
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ function bgnotify_formatted {
|
|||
function bgnotify_appid {
|
||||
if (( ${+commands[osascript]} )); then
|
||||
osascript -e "tell application id \"$(bgnotify_programid)\" to get the {id, frontmost, id of front window, visible of front window}" 2>/dev/null
|
||||
elif [[ -n $WAYLAND_DISPLAY ]] && (( ${+commands[swaymsg]} )); then # wayland+sway
|
||||
elif [[ -n $WAYLAND_DISPLAY ]] && ([[ -n $SWAYSOCK ]] || [[ -n $I3SOCK ]]) && (( ${+commands[swaymsg]} )); then # wayland+sway
|
||||
local app_id=$(bgnotify_find_sway_appid)
|
||||
[[ -n "$app_id" ]] && echo "$app_id" || echo $EPOCHSECONDS
|
||||
elif [[ -z $WAYLAND_DISPLAY ]] && [[ -n $DISPLAY ]] && (( ${+commands[xprop]} )); then
|
||||
|
|
@ -117,15 +117,15 @@ function bgnotify {
|
|||
local icon="$3"
|
||||
if (( ${+commands[terminal-notifier]} )); then # macOS
|
||||
local term_id=$(bgnotify_programid)
|
||||
terminal-notifier -message "$message" -title "$title" ${=icon:+-appIcon "$icon"} ${=term_id:+-activate "$term_id"} &>/dev/null
|
||||
terminal-notifier -message "$message" -title "$title" ${=icon:+-appIcon "$icon"} ${=term_id:+-activate "$term_id"} ${=bgnotify_extraargs:-} &>/dev/null
|
||||
elif (( ${+commands[growlnotify]} )); then # macOS growl
|
||||
growlnotify -m "$title" "$message"
|
||||
growlnotify -m "$title" "$message" ${=bgnotify_extraargs:-}
|
||||
elif (( ${+commands[notify-send]} )); then
|
||||
notify-send "$title" "$message" ${=icon:+--icon "$icon"}
|
||||
notify-send "$title" "$message" ${=icon:+--icon "$icon"} ${=bgnotify_extraargs:-}
|
||||
elif (( ${+commands[kdialog]} )); then # KDE
|
||||
kdialog --title "$title" --passivepopup "$message" 5
|
||||
kdialog --title "$title" --passivepopup "$message" 5 ${=bgnotify_extraargs:-}
|
||||
elif (( ${+commands[notifu]} )); then # cygwin
|
||||
notifu /m "$message" /p "$title" ${=icon:+/i "$icon"}
|
||||
notifu /m "$message" /p "$title" ${=icon:+/i "$icon"} ${=bgnotify_extraargs:-}
|
||||
fi
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ function branch_prompt_info() {
|
|||
while [[ "$dir" != '/' ]]; do
|
||||
# Found .git directory
|
||||
if [[ -d "${dir}/.git" ]]; then
|
||||
branch="${"$(<"${dir}/.git/HEAD")"##*/}"
|
||||
branch="${"$(<"${dir}/.git/HEAD")"##ref: refs/heads/}"
|
||||
echo '±' "${branch:gs/%/%%}"
|
||||
return
|
||||
fi
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ if (( ! $+commands[brew] )); then
|
|||
fi
|
||||
|
||||
if [[ -z "$HOMEBREW_PREFIX" ]]; then
|
||||
# Maintain compatability with potential custom user profiles, where we had
|
||||
# Maintain compatibility with potential custom user profiles, where we had
|
||||
# previously relied on always sourcing shellenv. OMZ plugins should not rely
|
||||
# on this to be defined due to out of order processing.
|
||||
export HOMEBREW_PREFIX="$(brew --prefix)"
|
||||
|
|
|
|||
9
plugins/buf/README.md
Normal file
9
plugins/buf/README.md
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
# Buf plugin
|
||||
|
||||
This plugin adds completion for [Buf CLI](https://github.com/bufbuild/buf), a tool working with Protocol Buffers.
|
||||
|
||||
To use it, add `buf` to the plugins array in your zshrc file:
|
||||
|
||||
```zsh
|
||||
plugins=(... buf)
|
||||
```
|
||||
14
plugins/buf/buf.plugin.zsh
Normal file
14
plugins/buf/buf.plugin.zsh
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
# Autocompletion for the Buf CLI (buf).
|
||||
if (( !$+commands[buf] )); then
|
||||
return
|
||||
fi
|
||||
# If the completion file doesn't exist yet, we need to autoload it and
|
||||
# bind it to `buf`. Otherwise, compinit will have already done that.
|
||||
if [[ ! -f "$ZSH_CACHE_DIR/completions/_buf" ]]; then
|
||||
typeset -g -A _comps
|
||||
autoload -Uz _buf
|
||||
_comps[buf]=_buf
|
||||
fi
|
||||
|
||||
# Generate and load buf completion
|
||||
buf completion zsh >! "$ZSH_CACHE_DIR/completions/_buf" &|
|
||||
|
|
@ -1,6 +1,7 @@
|
|||
# catimg
|
||||
|
||||
Plugin for displaying images on the terminal using the `catimg.sh` script provided by [posva](https://github.com/posva/catimg)
|
||||
Plugin for displaying images on the terminal using the `catimg.sh` script provided by
|
||||
[posva](https://github.com/posva/catimg)
|
||||
|
||||
To use it, add `catimg` to the plugins array in your zshrc file:
|
||||
|
||||
|
|
@ -10,7 +11,7 @@ plugins=(... catimg)
|
|||
|
||||
## Requirements
|
||||
|
||||
- `convert` (ImageMagick)
|
||||
- `magick convert` (ImageMagick)
|
||||
|
||||
## Functions
|
||||
|
||||
|
|
|
|||
|
|
@ -9,9 +9,11 @@
|
|||
|
||||
|
||||
function catimg() {
|
||||
if [[ -x `which convert` ]]; then
|
||||
zsh $ZSH/plugins/catimg/catimg.sh $@
|
||||
if (( $+commands[magick] )); then
|
||||
CONVERT_CMD="magick" zsh $ZSH/plugins/catimg/catimg.sh $@
|
||||
elif (( $+commands[convert] )); then
|
||||
CONVERT_CMD="convert" zsh $ZSH/plugins/catimg/catimg.sh $@
|
||||
else
|
||||
echo "catimg need convert (ImageMagick) to work)"
|
||||
echo "catimg need magick/convert (ImageMagick) to work)"
|
||||
fi
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,6 +7,10 @@
|
|||
# GitHub: https://github.com/posva/catimg #
|
||||
################################################################################
|
||||
|
||||
# this should come from outside, either `magick` or `convert`
|
||||
# from imagemagick v7 and ahead `convert` is deprecated
|
||||
: ${CONVERT_CMD:=convert}
|
||||
|
||||
function help() {
|
||||
echo "Usage catimg [-h] [-w width] [-c char] img"
|
||||
echo "By default char is \" \" and w is the terminal width"
|
||||
|
|
@ -43,23 +47,23 @@ if [ ! "$WIDTH" ]; then
|
|||
else
|
||||
COLS=$(expr $WIDTH "/" $(echo -n "$CHAR" | wc -c))
|
||||
fi
|
||||
WIDTH=$(convert "$IMG" -print "%w\n" /dev/null)
|
||||
WIDTH=$($CONVERT_CMD "$IMG" -print "%w\n" /dev/null)
|
||||
if [ "$WIDTH" -gt "$COLS" ]; then
|
||||
WIDTH=$COLS
|
||||
fi
|
||||
|
||||
REMAP=""
|
||||
if convert "$IMG" -resize $COLS\> +dither -remap $COLOR_FILE /dev/null ; then
|
||||
if $CONVERT_CMD "$IMG" -resize $COLS\> +dither -remap $COLOR_FILE /dev/null ; then
|
||||
REMAP="-remap $COLOR_FILE"
|
||||
else
|
||||
echo "The version of convert is too old, don't expect good results :(" >&2
|
||||
#convert "$IMG" -colors 256 PNG8:tmp.png
|
||||
#IMG="tmp.png"
|
||||
# $CONVERT_CMD "$IMG" -colors 256 PNG8:tmp.png
|
||||
# IMG="tmp.png"
|
||||
fi
|
||||
|
||||
# Display the image
|
||||
I=0
|
||||
convert "$IMG" -resize $COLS\> +dither `echo $REMAP` txt:- 2>/dev/null |
|
||||
$CONVERT_CMD "$IMG" -resize $COLS\> +dither `echo $REMAP` txt:- 2>/dev/null |
|
||||
sed -e 's/.*none.*/NO NO NO/g' -e '1d;s/^.*(\(.*\)[,)].*$/\1/g;y/,/ /' |
|
||||
while read R G B f; do
|
||||
if [ ! "$R" = "NO" ]; then
|
||||
|
|
|
|||
11
plugins/chezmoi/README.md
Normal file
11
plugins/chezmoi/README.md
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
# chezmoi Plugin
|
||||
|
||||
## Introduction
|
||||
|
||||
This `chezmoi` plugin sets up completion for [chezmoi](https://chezmoi.io).
|
||||
|
||||
To use it, add `chezmoi` to the plugins array of your zshrc file:
|
||||
|
||||
```bash
|
||||
plugins=(... chezmoi)
|
||||
```
|
||||
14
plugins/chezmoi/chezmoi.plugin.zsh
Normal file
14
plugins/chezmoi/chezmoi.plugin.zsh
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
# COMPLETION FUNCTION
|
||||
if (( ! $+commands[chezmoi] )); then
|
||||
return
|
||||
fi
|
||||
|
||||
# If the completion file doesn't exist yet, we need to autoload it and
|
||||
# bind it to `chezmoi`. Otherwise, compinit will have already done that.
|
||||
if [[ ! -f "$ZSH_CACHE_DIR/completions/_chezmoi" ]]; then
|
||||
typeset -g -A _comps
|
||||
autoload -Uz _chezmoi
|
||||
_comps[chezmoi]=_chezmoi
|
||||
fi
|
||||
|
||||
chezmoi completion zsh >| "$ZSH_CACHE_DIR/completions/_chezmoi" &|
|
||||
|
|
@ -22,6 +22,8 @@ _source-from-homebrew() {
|
|||
# check default brew prefix
|
||||
if [[ -h /usr/local/opt/chruby ]];then
|
||||
_brew_prefix="/usr/local/opt/chruby"
|
||||
elif [[ -h /opt/homebrew/opt/chruby ]]; then
|
||||
_brew_prefix="/opt/homebrew/opt/chruby"
|
||||
else
|
||||
# ok , it is not default prefix
|
||||
# this call to brew is expensive ( about 400 ms ), so at least let's make it only once
|
||||
|
|
|
|||
|
|
@ -36,3 +36,10 @@ Last login: Fri Jan 30 23:12:26 on ttys001
|
|||
- `cowsay` if using `chuck_cow`
|
||||
|
||||
Available via homebrew, apt, ...
|
||||
|
||||
> [!NOTE]
|
||||
> In addition to installing `fortune`, it may be necessary to run:
|
||||
>
|
||||
> `strfile $ZSH/plugins/chucknorris/fortunes/chucknorris\n`
|
||||
>
|
||||
> (include the "\n" literally) to write the fortune data to the proper directory.
|
||||
|
|
|
|||
|
|
@ -42,12 +42,12 @@ colorize_cat() {
|
|||
ZSH_COLORIZE_STYLE="emacs"
|
||||
fi
|
||||
|
||||
# Use stdin if no arguments have been passed.
|
||||
if [ $# -eq 0 ]; then
|
||||
# Use stdin if stdin is not attached to a terminal.
|
||||
if [ ! -t 0 ]; then
|
||||
if [[ "$ZSH_COLORIZE_TOOL" == "pygmentize" ]]; then
|
||||
pygmentize -O style="$ZSH_COLORIZE_STYLE" -g
|
||||
else
|
||||
chroma --style="$ZSH_COLORIZE_STYLE" --formatter="${ZSH_COLORIZE_CHROMA_FORMATTER:-terminal}"
|
||||
chroma --style="$ZSH_COLORIZE_STYLE" --formatter="${ZSH_COLORIZE_CHROMA_FORMATTER:-terminal}" "$@"
|
||||
fi
|
||||
return $?
|
||||
fi
|
||||
|
|
|
|||
37
plugins/conda/README.md
Normal file
37
plugins/conda/README.md
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
# conda plugin
|
||||
|
||||
The conda plugin provides [aliases](#aliases) for `conda`, usually installed via [anaconda](https://www.anaconda.com/) or [miniconda](https://docs.conda.io/en/latest/miniconda.html).
|
||||
|
||||
To use it, add `conda` to the plugins array in your zshrc file:
|
||||
|
||||
```zsh
|
||||
plugins=(... conda)
|
||||
```
|
||||
|
||||
## Aliases
|
||||
|
||||
| Alias | Command | Description |
|
||||
| :------- | :-------------------------------------- | :------------------------------------------------------------------------------ |
|
||||
| `cna` | `conda activate` | Activate the specified conda environment |
|
||||
| `cnab` | `conda activate base` | Activate the base conda environment |
|
||||
| `cncf` | `conda env create -f` | Create a new conda environment from a YAML file |
|
||||
| `cncn` | `conda create -y -n` | Create a new conda environment with the given name |
|
||||
| `cnconf` | `conda config` | View or modify conda configuration |
|
||||
| `cncp` | `conda create -y -p` | Create a new conda environment with the given prefix |
|
||||
| `cncr` | `conda create -n` | Create new virtual environment with given name |
|
||||
| `cncss` | `conda config --show-source` | Show the locations of conda configuration sources |
|
||||
| `cnde` | `conda deactivate` | Deactivate the current conda environment |
|
||||
| `cnel` | `conda env list` | List all available conda environments |
|
||||
| `cni` | `conda install` | Install given package |
|
||||
| `cniy` | `conda install -y` | Install given package without confirmation |
|
||||
| `cnl` | `conda list` | List installed packages in the current environment |
|
||||
| `cnle` | `conda list --export` | Export the list of installed packages in the current environment |
|
||||
| `cnles` | `conda list --explicit > spec-file.txt` | Export the list of installed packages in the current environment to a spec file |
|
||||
| `cnr` | `conda remove` | Remove given package |
|
||||
| `cnrn` | `conda remove -y -all -n` | Remove all packages in the specified environment |
|
||||
| `cnrp` | `conda remove -y -all -p` | Remove all packages in the specified prefix |
|
||||
| `cnry` | `conda remove -y` | Remove given package without confirmation |
|
||||
| `cnsr` | `conda search` | Search conda repositories for package |
|
||||
| `cnu` | `conda update` | Update conda package manager |
|
||||
| `cnua` | `conda update --all` | Update all installed packages |
|
||||
| `cnuc` | `conda update conda` | Update conda package manager |
|
||||
23
plugins/conda/conda.plugin.zsh
Normal file
23
plugins/conda/conda.plugin.zsh
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
alias cna='conda activate'
|
||||
alias cnab='conda activate base'
|
||||
alias cncf='conda env create -f'
|
||||
alias cncn='conda create -y -n'
|
||||
alias cnconf='conda config'
|
||||
alias cncp='conda create -y -p'
|
||||
alias cncr='conda create -n'
|
||||
alias cncss='conda config --show-source'
|
||||
alias cnde='conda deactivate'
|
||||
alias cnel='conda env list'
|
||||
alias cni='conda install'
|
||||
alias cniy='conda install -y'
|
||||
alias cnl='conda list'
|
||||
alias cnle='conda list --export'
|
||||
alias cnles='conda list --explicit > spec-file.txt'
|
||||
alias cnr='conda remove'
|
||||
alias cnrn='conda remove -y --all -n'
|
||||
alias cnrp='conda remove -y --all -p'
|
||||
alias cnry='conda remove -y'
|
||||
alias cnsr='conda search'
|
||||
alias cnu='conda update'
|
||||
alias cnua='conda update --all'
|
||||
alias cnuc='conda update conda'
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
# Usage: dash [keyword:]query
|
||||
dash() { open -a Dash.app dash://"$*" }
|
||||
dash() { open -a Dash.app "dash://$(omz_urlencode -r $*)" }
|
||||
compdef _dash dash
|
||||
|
||||
_dash() {
|
||||
|
|
|
|||
|
|
@ -83,9 +83,9 @@ else
|
|||
}
|
||||
alias ac="su -ls '$apt_pref clean' root"
|
||||
alias ad="su -lc '$apt_pref update' root"
|
||||
alias adg="su -lc '$apt_pref update && aptitude $apt_upgr' root"
|
||||
alias adu="su -lc '$apt_pref update && aptitude dist-upgrade' root"
|
||||
alias afu="su -lc '$apt-file update'"
|
||||
alias adg="su -lc '$apt_pref update && $apt_pref $apt_upgr' root"
|
||||
alias adu="su -lc '$apt_pref update && $apt_pref dist-upgrade' root"
|
||||
alias afu="su -lc 'apt-file update'"
|
||||
alias au="su -lc '$apt_pref $apt_upgr' root"
|
||||
function ai() {
|
||||
cmd="su -lc '$apt_pref install $@' root"
|
||||
|
|
|
|||
|
|
@ -1,5 +1,8 @@
|
|||
# Don't continue if direnv is not found
|
||||
command -v direnv &>/dev/null || return
|
||||
# If direnv is not found, don't continue and print a warning
|
||||
if (( ! $+commands[direnv] )); then
|
||||
echo "Warning: direnv not found. Please install direnv and ensure it's in your PATH before using this plugin."
|
||||
return
|
||||
fi
|
||||
|
||||
_direnv_hook() {
|
||||
trap -- '' SIGINT;
|
||||
|
|
|
|||
|
|
@ -60,3 +60,46 @@ to `/usr` again.
|
|||
After that, <kbd>Alt</kbd> + <kbd>Down</kbd> will probably go to `/usr/bin` if `bin` is the first directory in alphabetical
|
||||
order (depends on your `/usr` folder structure). <kbd>Alt</kbd> + <kbd>Up</kbd> will return to `/usr`, and once more will get
|
||||
you to the root folder (`/`).
|
||||
|
||||
### cde
|
||||
|
||||
This plugin also provides a `cde` alias that allows you to change to a directory without clearing the next directory stack.
|
||||
This changes the default behavior of `dirhistory`, which is to clear the next directory stack when changing directories.
|
||||
|
||||
For example, if the shell was started, and the following commands were entered:
|
||||
|
||||
```shell
|
||||
cd ~
|
||||
cd /usr
|
||||
cd share
|
||||
cd doc
|
||||
|
||||
# <Alt + Left>
|
||||
# <Alt + Left>
|
||||
```
|
||||
|
||||
The directory stack would look like this:
|
||||
|
||||
```sh
|
||||
➜ /usr typeset -pm dirhistory_\*
|
||||
typeset -ax dirhistory_past=( /home/user /usr )
|
||||
typeset -ax dirhistory_future=( /usr/share/doc /usr/share )
|
||||
```
|
||||
|
||||
This means that pressing <kbd>Alt</kbd> + <kbd>Right</kbd>, you'd go to `/usr/share` and `/usr/share/doc` (the "future" directories).
|
||||
|
||||
If you run `cd /usr/bin`, the "future" directories will be removed, and you won't be able to access them with <kbd>Alt</kbd> + <kbd>Right</kbd>:
|
||||
|
||||
```sh
|
||||
➜ /u/bin typeset -pm dirhistory_\*
|
||||
typeset -ax dirhistory_past=( /home/user /usr )
|
||||
typeset -ax dirhistory_future=( /usr/bin )
|
||||
```
|
||||
|
||||
If you instead run `cde /usr/bin`, the "future" directories will be preserved:
|
||||
|
||||
```sh
|
||||
➜ /u/bin typeset -pm dirhistory_\*
|
||||
typeset -ax dirhistory_past=( /home/user /usr /usr/bin )
|
||||
typeset -ax dirhistory_future=( /usr/share/doc /usr/share )
|
||||
```
|
||||
|
|
|
|||
|
|
@ -11,9 +11,10 @@ dirhistory_past=($PWD)
|
|||
dirhistory_future=()
|
||||
export dirhistory_past
|
||||
export dirhistory_future
|
||||
|
||||
export DIRHISTORY_SIZE=30
|
||||
|
||||
alias cde='dirhistory_cd'
|
||||
|
||||
# Pop the last element of dirhistory_past.
|
||||
# Pass the name of the variable to return the result in.
|
||||
# Returns the element if the array was not empty,
|
||||
|
|
@ -136,7 +137,11 @@ for keymap in emacs vicmd viins; do
|
|||
|
||||
case "$TERM_PROGRAM" in
|
||||
Apple_Terminal) bindkey -M $keymap "^[b" dirhistory_zle_dirhistory_back ;; # Terminal.app
|
||||
iTerm.app) bindkey -M $keymap "^[^[[D" dirhistory_zle_dirhistory_back ;; # iTerm2
|
||||
ghostty) bindkey -M $keymap "^[b" dirhistory_zle_dirhistory_back ;; # ghostty
|
||||
iTerm.app)
|
||||
bindkey -M $keymap "^[^[[D" dirhistory_zle_dirhistory_back
|
||||
bindkey -M $keymap "^[b" dirhistory_zle_dirhistory_back
|
||||
;;
|
||||
esac
|
||||
|
||||
if (( ${+terminfo[kcub1]} )); then
|
||||
|
|
@ -151,7 +156,11 @@ for keymap in emacs vicmd viins; do
|
|||
|
||||
case "$TERM_PROGRAM" in
|
||||
Apple_Terminal) bindkey -M $keymap "^[f" dirhistory_zle_dirhistory_future ;; # Terminal.app
|
||||
iTerm.app) bindkey -M $keymap "^[^[[C" dirhistory_zle_dirhistory_future ;; # iTerm2
|
||||
ghostty) bindkey -M $keymap "^[f" dirhistory_zle_dirhistory_future ;; # ghostty
|
||||
iTerm.app)
|
||||
bindkey -M $keymap "^[^[[C" dirhistory_zle_dirhistory_future
|
||||
bindkey -M $keymap "^[f" dirhistory_zle_dirhistory_future
|
||||
;;
|
||||
esac
|
||||
|
||||
if (( ${+terminfo[kcuf1]} )); then
|
||||
|
|
@ -200,6 +209,7 @@ for keymap in emacs vicmd viins; do
|
|||
case "$TERM_PROGRAM" in
|
||||
Apple_Terminal) bindkey -M $keymap "^[[A" dirhistory_zle_dirhistory_up ;; # Terminal.app
|
||||
iTerm.app) bindkey -M $keymap "^[^[[A" dirhistory_zle_dirhistory_up ;; # iTerm2
|
||||
ghostty) bindkey -M $keymap "^[[1;3A" dirhistory_zle_dirhistory_up ;; # ghostty
|
||||
esac
|
||||
|
||||
if (( ${+terminfo[kcuu1]} )); then
|
||||
|
|
@ -215,6 +225,7 @@ for keymap in emacs vicmd viins; do
|
|||
case "$TERM_PROGRAM" in
|
||||
Apple_Terminal) bindkey -M $keymap "^[[B" dirhistory_zle_dirhistory_down ;; # Terminal.app
|
||||
iTerm.app) bindkey -M $keymap "^[^[[B" dirhistory_zle_dirhistory_down ;; # iTerm2
|
||||
ghostty) bindkey -M $keymap "^[[1;3B" dirhistory_zle_dirhistory_down ;; # ghostty
|
||||
esac
|
||||
|
||||
if (( ${+terminfo[kcud1]} )); then
|
||||
|
|
|
|||
570
plugins/dnf/_dnf5
Normal file
570
plugins/dnf/_dnf5
Normal file
|
|
@ -0,0 +1,570 @@
|
|||
#compdef dnf5
|
||||
# based on dnf-5.2.6.2
|
||||
|
||||
# utility functions
|
||||
|
||||
_dnf5_helper() {
|
||||
_call_program specs $service "${(q-)@}" "${(q-)PREFIX}\*" \
|
||||
-qC --assumeno --nogpgcheck 2>/dev/null </dev/null
|
||||
}
|
||||
|
||||
_dnf5_repositories() {
|
||||
# required option: -T (all|disabled|enabled)
|
||||
local selected expl
|
||||
zparseopts -D -E - T:=selected
|
||||
selected=$selected[2]
|
||||
_wanted $selected-repositories expl "$selected repository" \
|
||||
compadd "$@" - "${(@)${(f)$(_dnf5_helper repo list --$selected)}[2,-1]%% *}"
|
||||
}
|
||||
|
||||
_dnf5_packages() {
|
||||
# required option: -T (all|available|installed|upgradable)
|
||||
local selected opt expl
|
||||
zparseopts -D -E - T:=selected
|
||||
selected=$selected[2]
|
||||
case $selected in
|
||||
all) opt='' ;; # option --all does not exist
|
||||
upgradable) opt='--upgrades' ;;
|
||||
*) opt="--$selected" ;;
|
||||
esac
|
||||
_wanted $selected-packages expl "$selected package" \
|
||||
compadd "$@" - $(_dnf5_helper repoquery $opt --qf='%{name} ')
|
||||
}
|
||||
|
||||
_dnf5_rpm_files() {
|
||||
local expl
|
||||
_wanted rpm-files expl 'rpm file' _files -g '(#i)*.rpm(-.)'
|
||||
}
|
||||
|
||||
_dnf5_packages_or_rpms() {
|
||||
if [[ "$words[CURRENT]" = (*/*|\~*) ]]; then # if looks like a path name
|
||||
_dnf5_rpm_files
|
||||
else
|
||||
_dnf5_packages "$@"
|
||||
fi
|
||||
}
|
||||
|
||||
_dnf5_groups() {
|
||||
# optional option: -T (available|installed)
|
||||
local update_policy selected line pat groups
|
||||
zparseopts -D -E - T:=selected
|
||||
selected=$selected[2]
|
||||
if [[ -z $selected ]]; then
|
||||
selected=all
|
||||
opt= # option --all does not exist
|
||||
else
|
||||
opt=--$selected
|
||||
fi
|
||||
# XXX hidden groups are not included
|
||||
for line in ${${(f)"$(_dnf5_helper group list $opt)"}[2,-1]}; do
|
||||
line=( ${(z)line} )
|
||||
groups+=( "$line[1]:$line[2,-2]" )
|
||||
done
|
||||
_describe -t $selected-groups "$selected group" groups
|
||||
}
|
||||
|
||||
_dnf5_environments() {
|
||||
local line envs
|
||||
for line in ${${(f)"$(_dnf5_helper environment list)"}[2,-1]}; do
|
||||
line=( ${(z)line} )
|
||||
envs+=( "$line[1]:$line[2,-2]" )
|
||||
done
|
||||
_describe -t environments 'environment' envs
|
||||
}
|
||||
|
||||
# completers for (several) dnf commands
|
||||
|
||||
_dnf5-advisory () {
|
||||
_arguments : \
|
||||
$advisory_opts \
|
||||
'--contains-pkgs=[only show advisories containing specified packages]: : _sequence _dnf5_packages -T installed' \
|
||||
+ '(with)' \
|
||||
'--with-cve[show only advisories referencing CVE ticket]' \
|
||||
'--with-bz[show only advisories referencing Bugzilla ticket]' \
|
||||
+ '(type)' \
|
||||
'--all[show all advisories]' \
|
||||
'--available[show advisories containing newer versions of installed packages (default)]' \
|
||||
'--installed[show advisories containing equal and older version of installed packages]' \
|
||||
'--updates[show advisories containing upgradable packages]' \
|
||||
+ args \
|
||||
':subcommand:(list info summary)' '*:advisory spec:'
|
||||
}
|
||||
|
||||
_dnf5-group() {
|
||||
local -a tmp
|
||||
if (( CURRENT == 2 )); then
|
||||
tmp=(
|
||||
'list:list all matching groups'
|
||||
'info:print detailed information about groups'
|
||||
'install:install packages from specified groups'
|
||||
'remove:remove removable packages in specified groups'
|
||||
'upgrade:upgrade specified groups and packages in them'
|
||||
)
|
||||
_describe -t subcommands 'subcommand' tmp
|
||||
else
|
||||
case $words[2] in
|
||||
list|info)
|
||||
tmp=(
|
||||
'(--installed)--available[show only available groups]'
|
||||
'(--available)--installed[show only installed groups]'
|
||||
'--hidden[show also hidden groups]'
|
||||
'--contains-pkgs=[show only groups containing specified packages]: : _sequence _dnf5_packages -T all'
|
||||
'*: : _dnf5_groups'
|
||||
)
|
||||
;;
|
||||
install)
|
||||
tmp=( $common_opts
|
||||
'--with-optional[include optional packages from the groups]'
|
||||
'*: : _dnf5_groups -T available' )
|
||||
;|
|
||||
upgrade)
|
||||
tmp=( ${common_opts:#--skip-broken*}
|
||||
'*: : _dnf5_groups -T installed' )
|
||||
;|
|
||||
remove)
|
||||
tmp=( $offline_opts
|
||||
'*: : _dnf5_groups -T installed' )
|
||||
;|
|
||||
install|remove)
|
||||
tmp+=( '--no-packages[operate on groups only, not manipulate any packages]' )
|
||||
;|
|
||||
install|upgrade)
|
||||
tmp+=( $downgrade_opts )
|
||||
;;
|
||||
esac
|
||||
_arguments : $tmp
|
||||
fi
|
||||
}
|
||||
|
||||
_dnf5-history() {
|
||||
local -a tmp
|
||||
if (( CURRENT == 2 )); then
|
||||
tmp=(
|
||||
'list:list info about recorded transactions'
|
||||
'info:print detailed about specific transactions'
|
||||
'undo:revert all actions from the specified transaction'
|
||||
'redo:repeat the specified transaction'
|
||||
'rollback:undo all transactions performed after the specified transaction'
|
||||
'store:store the transaction into a directory'
|
||||
)
|
||||
_describe -t subcommands 'subcommand' tmp
|
||||
else
|
||||
case $words[2] in
|
||||
list|info)
|
||||
tmp=( '--reverse[reverse the order of transactions in output]' )
|
||||
;;
|
||||
undo|rollback|redo)
|
||||
tmp=( '--skip-unavailable[allow skipping impossible actions]' )
|
||||
;|
|
||||
undo|rollback)
|
||||
tmp+=( $replay_opts )
|
||||
;;
|
||||
store)
|
||||
tmp=( {-o,--output=}'[directory for storing the transaction (default ./transaction)]: : _directories')
|
||||
esac
|
||||
_arguments : $tmp '2:transaction:( )'
|
||||
fi
|
||||
}
|
||||
|
||||
_dnf5-mark() {
|
||||
local -a tmp
|
||||
if (( CURRENT == 2 )); then
|
||||
tmp=(
|
||||
'user:mark the package as user-installed'
|
||||
'dependency:mark the package as a dependency'
|
||||
'weak:mark the package as a weak dependency'
|
||||
'group:mark the package as installed by the specified group'
|
||||
)
|
||||
_describe -t subcommands 'subcommand' tmp
|
||||
else
|
||||
tmp=(
|
||||
'--skip-unavailable[skip packages not installed on the system]'
|
||||
'--store=[store the transaction in specified directory]: : _directories'
|
||||
)
|
||||
if [[ $words[2] = group ]]; then
|
||||
tmp+=( '2:group-id: _dnf5_groups -T installed' )
|
||||
fi
|
||||
_arguments : $tmp '*: : _dnf5_packages -T installed'
|
||||
fi
|
||||
}
|
||||
|
||||
_dnf5-module() {
|
||||
local -a tmp
|
||||
if (( CURRENT == 2 )); then
|
||||
tmp=(
|
||||
'list:list module streams'
|
||||
'info:print details about module streams'
|
||||
'enable:enable module streams'
|
||||
'disable:disable modules including all their streams'
|
||||
"reset:reset module state so it's no longer enabled or disabled"
|
||||
)
|
||||
_describe -t subcommands 'subcommand' tmp
|
||||
elif (( CURRENT == 3 )) && [[ $cur = -* ]]; then
|
||||
case $words[2] in
|
||||
list|info) tmp=( --enabled --disabled ) ;;
|
||||
enable) tmp=( --skip-broken --skip-unavailable ) ;;
|
||||
*) tmp=( --skip-unavailable ) ;;
|
||||
esac
|
||||
_wanted options expl 'option' compadd -a tmp
|
||||
else
|
||||
_message 'module spec'
|
||||
fi
|
||||
}
|
||||
|
||||
_dnf5-offline() { # also used by the 'system-upgrade' command
|
||||
local -a tmp
|
||||
if (( CURRENT == 2 )); then
|
||||
tmp=(
|
||||
'clean:remove any stored offline transactions and cached packages'
|
||||
'log:list boots during which offline transaction was attempted'
|
||||
'reboot:prepare the system for offline transaction and reboot'
|
||||
)
|
||||
if [[ $cmd = offline ]]; then
|
||||
tmp+=( 'status:show status of the current offline transaction' )
|
||||
else
|
||||
tmp+=( 'download:download all packages needed for upgrade' )
|
||||
fi
|
||||
_describe -t subcommands 'subcommand' tmp && ret=0
|
||||
else
|
||||
case $words[2] in
|
||||
download)
|
||||
_arguments : \
|
||||
'--releasever=[the version to upgrade to]:version number:' \
|
||||
'--no-downgrade:do not install packages older than currently installed' '*: :' && ret=0
|
||||
;;
|
||||
log)
|
||||
_arguments : \
|
||||
'--number=[show log of transaction specified by number]:transaction number:' '*: :' && ret=0
|
||||
;;
|
||||
reboot)
|
||||
_wanted options expl 'option' compadd -- --poweroff && ret=0
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
}
|
||||
|
||||
_dnf5-repoquery() {
|
||||
local v
|
||||
local -a opts=(
|
||||
$advisory_opts
|
||||
'--arch=[limit results to specified architectures]:list of archs: '
|
||||
'--available[limit results to available packages]'
|
||||
'--disable-modular-filtering[include packages of inactive module streams]'
|
||||
'--duplicates[limit to installed duplicate packages]'
|
||||
'--exactdeps[limit to packages that require capability specified by ==what{requires,depends}]'
|
||||
'--extras[limit to installed packages that are not present in any available repository]'
|
||||
'--file=[limit results to packages which own specified file]:list of files: _sequence _files'
|
||||
'--installed[query installed packages]'
|
||||
'--installonly[limit to installed installonly packages]'
|
||||
'--latest-limit=[limit to latest packages of specified number]:number:'
|
||||
'--leaves[limit to groups of installed packages not required by other installed packages]'
|
||||
'--providers-of=[select packages that provide specified attribute]:attribute:(conflicts depends enhances obsoletes provides recommends requires requires_pre suggests supplement)'
|
||||
'--recent[limit to only recently changed packages]'
|
||||
'--recursive[make --whatrequires/--providers-of work recursively]'
|
||||
'--security[limit to packages in security advisories]'
|
||||
'--srpm[use the corresponding source RPM]'
|
||||
'--unneeded[limit to unneeded installed packages]'
|
||||
'--upgrades[limit to available packages that provide upgrade for installed packages]'
|
||||
'--userinstalled[limit to packages that are not installed as dependencies]'
|
||||
'--whatdepends=[limit to packages that require, enhance, recommend, suggest of supplement specified capability]:list of capability:'
|
||||
'--whatconflicts=[limit to packages that conflicts with specified capabilities]:list of capability: '
|
||||
)
|
||||
for v in enhance obsolete provide recommend require suggest supplement; do
|
||||
opts+=( "--what${v}s=[limit to packages that $v specified capabilities]:list of capability: ")
|
||||
done
|
||||
# mutually exclusive formatting options
|
||||
opts+=(
|
||||
+ '(format)'
|
||||
'--conflicts[display capabilities that the package conflicts with]'
|
||||
'--depends[display capabilities that the package depends on, enables, recommends, suggests or supplements]'
|
||||
'--files[show files in the package]'
|
||||
'--requires-pre[display capabilities required to run pre/post scripts of the package]'
|
||||
'--sourcerpm[display source RPM of the package]'
|
||||
'--location[display location of the package]'
|
||||
'--info[show detailed information about the package]'
|
||||
'--changelogs[print the package changelogs]'
|
||||
'(- *)--querytags[list tags recognized by --queryformat]'
|
||||
'--queryformat=[specify output format]:format:'
|
||||
)
|
||||
for v in enhance obsolete provide recommend require suggest supplement; do
|
||||
opts+=( "--${v}s[display capabilities ${v}ed by the package]" )
|
||||
done
|
||||
|
||||
_arguments : '*: : _dnf5_packages -T all' $opts
|
||||
}
|
||||
|
||||
# dnf commands
|
||||
|
||||
_dnf5_commands() {
|
||||
local -a dnf_cmds=(
|
||||
'advisory:manage advisories'
|
||||
'autoremove:remove unneeded packages'
|
||||
'check:check for problems in package database'
|
||||
'check-upgrade:check for available package upgrades'
|
||||
'clean:remove or invalidate cached data'
|
||||
'distro-sync:up/downgrade installed packages to the latest available'
|
||||
'downgrade:downgrade packages'
|
||||
'download:download packages'
|
||||
'environment:manage comps environments'
|
||||
'group:manage comps groups'
|
||||
'history:manage transaction history'
|
||||
'info:provide detailed information about packages'
|
||||
'install:install packages'
|
||||
'leaves:list groups of leaf packages'
|
||||
'list:list installed or available packages'
|
||||
'makecache:generate the metadata cache'
|
||||
'mark:change the reason of an installed package'
|
||||
'module:manage modules'
|
||||
'offline:manage offline transactions'
|
||||
'provides:find what package provides the given value'
|
||||
'reinstall:reinstall packages'
|
||||
'remove:remove packages'
|
||||
'replay:replay stored transactions'
|
||||
'repo:manage repositories'
|
||||
'repoquery:search for packages in repositories'
|
||||
'search:search for packages using keywords'
|
||||
'swap:remove software and install another in the single transaction'
|
||||
'system-upgrade:upgrade the system to a new major release'
|
||||
'upgrade:upgrade packages'
|
||||
'versionlock:protect packages from updates to newer versions'
|
||||
)
|
||||
_describe -t dnf-commands 'dnf command' dnf_cmds
|
||||
}
|
||||
|
||||
# subcommands and options
|
||||
|
||||
_dnf5_subcmds_opts() {
|
||||
local cur=$words[CURRENT] cmd=$words[1] expl ret=1
|
||||
local -a tmp
|
||||
# common options
|
||||
local -a offline_opts=(
|
||||
'(--store)--offline[store the transaction to be performed offline]'
|
||||
'(--offline)--store=[store the transaction in specified directory]: : _directories'
|
||||
)
|
||||
local -a common_opts=(
|
||||
$offline_opts
|
||||
'--allowerasing[allow erasing of installed packages]'
|
||||
'--skip-broken[resolve dependency problems by skipping problematic packages]'
|
||||
"--skip-unavailable[skip packages that can't be synchronized]"
|
||||
'--downloadonly[download packages without executing transaction]'
|
||||
)
|
||||
local -a advisory_opts=(
|
||||
'--advisories=[consider only specified advisories]:list of advisories:'
|
||||
'--advisory-severities=[limit to advisories with specified severity]:severity:_sequence compadd - critical important moderate low none'
|
||||
'--bzs=[limit to advisories that fix specified Bugzilla ID]:list of Bugzilla ID:'
|
||||
'--cves=[limit to advisories that fix specified CVE ID]:list of CVD ID]:'
|
||||
'--security[limit to security advisories]'
|
||||
'--bugfix[limit to bugfix advisories]'
|
||||
'--enhancement[limit to enhancement advisories]'
|
||||
'--newpackage[limit to newpackage advisories]'
|
||||
)
|
||||
local -a downgrade_opts=(
|
||||
'(--no-allow-downgrade)--allow-downgrade[enable downgrade of dependencies]'
|
||||
'(--allow-downgrade)--no-allow-downgrade[disable downgrade of dependencies]'
|
||||
)
|
||||
local -a replay_opts=(
|
||||
'--ignore-extras[not consider extra packages]'
|
||||
'--ignore-installed[mismatches between installed and stored transaction are not errors]'
|
||||
)
|
||||
# Deal with some aliases (not comprehensive)
|
||||
case $cmd in
|
||||
check-updgrade) cmd=check-update;;
|
||||
dg) cmd=downgrade;;
|
||||
dsync) cmd=distro-sync;;
|
||||
grp) cmd=group;;
|
||||
if) cmd=info;;
|
||||
in) cmd=install;;
|
||||
ls) cmd=list;;
|
||||
mc) cmd=makecache;;
|
||||
rei) cmd=reinstall;;
|
||||
rm) cmd=remove ;;
|
||||
rq) cmd=repoquery;;
|
||||
se) cmd=search;;
|
||||
update|up) cmd=upgrade;;
|
||||
esac
|
||||
local curcontext="${curcontext%:*:*}:dnf-${cmd}:"
|
||||
|
||||
case $cmd in
|
||||
advisory|group|history|mark|module|offline|repoquery)
|
||||
_dnf5-$cmd && ret=0
|
||||
;;
|
||||
system-upgrade)
|
||||
_dnf5-offline && ret=0
|
||||
;;
|
||||
autoremove)
|
||||
_arguments : $offline_opts && ret=0
|
||||
;;
|
||||
check)
|
||||
_arguments : \
|
||||
'--dependencies[show missing dependencies and conflicts]' \
|
||||
'--duplicates[show duplicated packages]' \
|
||||
'--obsoleted[show obsoleted packages]' && ret=0
|
||||
;;
|
||||
check-upgrade)
|
||||
_arguments : \
|
||||
$advisory_opts \
|
||||
'--changelogs[print package changelogs]' \
|
||||
'--minimal[reports the lowest versions of packages that fix advisories]' \
|
||||
'*: : _dnf5_packages -T installed' && ret=0
|
||||
;;
|
||||
clean)
|
||||
tmp=(
|
||||
'dbcache:remove cache files generated from the repository metadata'
|
||||
'expire-cache:mark the repository metadata expired'
|
||||
'metadata:remove the repository metadata'
|
||||
'packages:remove any cached packages'
|
||||
'all:clean all'
|
||||
)
|
||||
_describe -t cache-types 'cache type' tmp && ret=0
|
||||
;;
|
||||
distro-sync)
|
||||
_arguments : $common_opts '*: : _dnf5_packages -T installed' && ret=0
|
||||
;;
|
||||
downgrade)
|
||||
_arguments : \
|
||||
$common_opts $downgrade_opts \
|
||||
'*: : _dnf5_packages -T installed' && ret=0
|
||||
;;
|
||||
download)
|
||||
_arguments : \
|
||||
'--arch=[limit to packages of specified architecture]:list of architectures:' \
|
||||
'--resolve[resolve and download needed dependencies]' \
|
||||
'--alldeps[with --resolve, also download already installed dependencies]' \
|
||||
'--destdir=[download to the specified directory]: : _directories' \
|
||||
'--srpm[download the source rpm]' \
|
||||
'--url[print the list of URLs where the rpms can be downloaded]' \
|
||||
'*--urlprotocol=[with --url, limit to specified protocols]:protocol:_sequence compadd - http https ftp file' \
|
||||
'*: : _dnf5_packages -T all' && ret=0
|
||||
;;
|
||||
environment)
|
||||
_arguments : \
|
||||
'--available[show only available environments]' \
|
||||
'--installed[show only installed environments]' \
|
||||
':subcommand:(list info)' \
|
||||
'*: : _dnf5_environments' && ret=0
|
||||
;;
|
||||
info|list)
|
||||
_arguments : \
|
||||
'--showduplicates[show all versions of the packages]' \
|
||||
'*: : _dnf5_packages -T all' \
|
||||
+ '(type)' \
|
||||
'--installed[list only installed packages]:*: : _dnf5_packages -T installed' \
|
||||
'--available[list only available packages]:*: : _dnf5_packages -T available' \
|
||||
'--extras[list only extras]' \
|
||||
'--obsoletes[list only installed but obsoleted packages]:*: : _dnf5_packages -T installed' \
|
||||
'--recent[list only recently added packages]' \
|
||||
'--upgrades[list only available upgrades of installed packages]:*: : _dnf5_packages -T upgradable' \
|
||||
'--autoremove[list only packages that will be autoremoved]:*: : _dnf5_packages -T installed' &&ret=0
|
||||
;;
|
||||
install)
|
||||
_arguments : \
|
||||
$common_opts $downgrade_opts $advisory_opts \
|
||||
'*: : _dnf5_packages_or_rpms -T available' && ret=0
|
||||
;;
|
||||
leaves|makecache)
|
||||
# nothing to complete
|
||||
;;
|
||||
provides)
|
||||
_files && ret=0
|
||||
;;
|
||||
reinstall)
|
||||
_arguments : \
|
||||
$common_opts $downgrade_opts \
|
||||
'*: : _dnf5_packages_or_rpms -T installed' && ret=0
|
||||
;;
|
||||
remove)
|
||||
_arguments : \
|
||||
$offline_opts \
|
||||
'--no-autoremove[not remove dependencies that are no longer used]' \
|
||||
'*: : _dnf5_packages -T installed' && ret=0
|
||||
;;
|
||||
replay)
|
||||
_arguments : \
|
||||
$replay_opts \
|
||||
':transaction path:_directories' && ret=0
|
||||
;;
|
||||
repo)
|
||||
_arguments : \
|
||||
'--all[show info about all repositories]' \
|
||||
'--enabled[show info only about enabled repositories]' \
|
||||
'--disabled[show info only about disabled repositories]' \
|
||||
':subcommand:(list info)' && ret=0
|
||||
;;
|
||||
search)
|
||||
_arguments : \
|
||||
'--all[search patterns also inside description and URL fields]' \
|
||||
'--showduplicates[show all versions of packages, not only the latest ones]' \
|
||||
'*:search pattern:' && ret=0
|
||||
;;
|
||||
swap)
|
||||
_arguments : \
|
||||
$offline_opts \
|
||||
'--allowerasing[allow erasing of installed packages]' \
|
||||
': : _dnf5_packages -T installed' \
|
||||
': : _dnf5_packages -T available' && ret=0
|
||||
;;
|
||||
upgrade)
|
||||
_arguments : \
|
||||
${common_opts:#--skip-broken*} $downgrade_opts $advisory_opts \
|
||||
'--minimal[upgrade only to the lowest available versions that fix advisories]' \
|
||||
'--destdir=[specify directory into which downloading packages]: : _directories' \
|
||||
'*: : _dnf5_packages_or_rpms -T upgradable' && ret=0
|
||||
;;
|
||||
versionlock)
|
||||
_arguments : \
|
||||
':subcommand:(add exclude clear delete list)' \
|
||||
'*: : _dnf5_packages -T all' && ret=0
|
||||
;;
|
||||
esac
|
||||
return ret
|
||||
}
|
||||
|
||||
# main completer
|
||||
|
||||
_dnf5() {
|
||||
local curcontext="$curcontext" state state_descr line ret=1
|
||||
typeset -A opt_args
|
||||
local -a opts=(
|
||||
'(-y --assumeyes)--assumeno[answer no for all questions]'
|
||||
'--best[try the best available package version]'
|
||||
'(-C --cacheonly)'{-C,--cacheonly}"[run entirely from system cache, don't update cache]"
|
||||
'--comment=[add comment to transaction history]:comment:'
|
||||
'(-c --config)'{-c+,--config=}'[specify configuration file]:config file:_files'
|
||||
'--debugsolver[dump detailed solving results in file ./debugdata]'
|
||||
'*--disable-plugin=[disable specified plugins]:list of plugin names:'
|
||||
'(--repo)*--disable-repo=[disable specified repos]: : _sequence _dnf5_repositories -T enabled'
|
||||
'--dump-main-config[print main configuration values to stdout]'
|
||||
'*--dump-repo-config=[print repository configuration values to stdout]:repi id'
|
||||
'--dump-variables[print variable values to stdout]'
|
||||
'*--enable-plugin=[enable specified plugins]:list of plugin names:'
|
||||
'*--enable-repo=[enable additional repos]: : _sequence _dnf5_repositories -T disabled'
|
||||
'--forcearch=[force the use of the specified arch]:arch:'
|
||||
'(-)'{-h,--help}'[show the help message]'
|
||||
'--installroot=[set install root]: : _directories'
|
||||
'--no-best[do not limit transactions to best candidates]'
|
||||
'--no-docs[do not install documentation]'
|
||||
'--no-gpgcheck[skip checking GPG signatures on packages]'
|
||||
'--no-plugins[disable all plugins]'
|
||||
'(-q --quiet)'{-q,--quiet}'[show just the relevant content]'
|
||||
'--refresh[force refreshing metadata before running the command]'
|
||||
'--releasever=[override distribution release in config files]:release ver:'
|
||||
'(--disablerepo)*--repo=[enable just the specified repo]: : _sequence _dnf5_repositories -T all'
|
||||
'*--repofrompath=[specify additional repos]:repository_label,path_or_url: '
|
||||
'*--setopt=[override option in config file]:repoid.option=value:'
|
||||
'*--setvar=[override DNF5 variable value]'
|
||||
'--show-new-leaves[show newly installed leaf packages]'
|
||||
'--use-host-config[use config files and variables from host system]'
|
||||
'(- *)--version[show dnf version]'
|
||||
'(-y --assumeyes --assumeno)'{-y,--assumeyes}'[answer yes for all questions]'
|
||||
'*'{-x+,--exclude=}'[exclude specified packages from transaction]: : _sequence _dnf5_packages -T all'
|
||||
)
|
||||
_arguments -C -s : $opts ': :->command' '*:: :->cmd_args' && ret=0
|
||||
|
||||
case $state in
|
||||
command) _dnf5_commands && ret=0 ;;
|
||||
cmd_args) _dnf5_subcmds_opts && ret=0 ;;
|
||||
esac
|
||||
return ret
|
||||
}
|
||||
|
||||
_dnf5 "$@"
|
||||
|
|
@ -39,6 +39,10 @@ following setting. See https://github.com/ohmyzsh/ohmyzsh/issues/11789 for more
|
|||
zstyle ':omz:plugins:docker' legacy-completion yes
|
||||
```
|
||||
|
||||
### For Podman's Docker wrapper users
|
||||
|
||||
If you use Podman's Docker wrapper, you need to enable legacy completion. See above section.
|
||||
|
||||
## Aliases
|
||||
|
||||
| Alias | Command | Description |
|
||||
|
|
@ -73,6 +77,7 @@ zstyle ':omz:plugins:docker' legacy-completion yes
|
|||
| drs | `docker container restart` | Restart one or more containers |
|
||||
| dsta | `docker stop $(docker ps -q)` | Stop all running containers |
|
||||
| dstp | `docker container stop` | Stop one or more running containers |
|
||||
| dsts | `docker stats` | Display real-time streaming statistics for containers |
|
||||
| dtop | `docker top` | Display the running processes of a container |
|
||||
| dvi | `docker volume inspect` | Display detailed information about one or more volumes |
|
||||
| dvls | `docker volume ls` | List all the volumes known to docker |
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ alias dst='docker container start'
|
|||
alias drs='docker container restart'
|
||||
alias dsta='docker stop $(docker ps -q)'
|
||||
alias dstp='docker container stop'
|
||||
alias dsts='docker stats'
|
||||
alias dtop='docker top'
|
||||
alias dvi='docker volume inspect'
|
||||
alias dvls='docker volume ls'
|
||||
|
|
@ -39,7 +40,7 @@ if (( ! $+commands[docker] )); then
|
|||
return
|
||||
fi
|
||||
|
||||
# Standarized $0 handling
|
||||
# Standardized $0 handling
|
||||
# https://zdharma-continuum.github.io/Zsh-100-Commits-Club/Zsh-Plugin-Standard.html
|
||||
0="${${ZERO:-${0:#$ZSH_ARGZERO}}:-${(%):-%N}}"
|
||||
0="${${(M)0:#/*}:-$PWD/$0}"
|
||||
|
|
|
|||
|
|
@ -23,3 +23,4 @@ plugins=(... dotnet)
|
|||
| dp | dotnet pack | Create a NuGet package. |
|
||||
| dng | dotnet nuget | Provides additional NuGet commands. |
|
||||
| db | dotnet build | Build a .NET project |
|
||||
| dres | dotnet restore | Restore dependencies and project-specific tools for a project. |
|
||||
|
|
@ -10,7 +10,7 @@ _dotnet_completion() {
|
|||
|
||||
compdef _dotnet_completion dotnet
|
||||
|
||||
# Aliases bellow are here for backwards compatibility
|
||||
# Aliases below are here for backwards compatibility
|
||||
# added by Shaun Tabone (https://github.com/xontab)
|
||||
|
||||
alias dn='dotnet new'
|
||||
|
|
@ -24,3 +24,4 @@ alias da='dotnet add'
|
|||
alias dp='dotnet pack'
|
||||
alias dng='dotnet nuget'
|
||||
alias db='dotnet build'
|
||||
alias dres='dotnet restore'
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ alias eeval="$EMACS_PLUGIN_LAUNCHER --eval"
|
|||
alias eframe='emacsclient --alternate-editor="" --create-frame'
|
||||
|
||||
# Emacs ANSI Term tracking
|
||||
if [[ -n "$INSIDE_EMACS" ]]; then
|
||||
if [[ -n "$INSIDE_EMACS" ]] && [[ "$INSIDE_EMACS" != "vterm" ]]; then
|
||||
chpwd_emacs() { print -P "\033AnSiTc %d"; }
|
||||
print -P "\033AnSiTc %d" # Track current working directory
|
||||
print -P "\033AnSiTu %n" # Track username
|
||||
|
|
|
|||
|
|
@ -29,5 +29,5 @@ plugins=(... ember-cli)
|
|||
|
||||
- [BilalBudhani](https://github.com/BilalBudhani)
|
||||
- [eubenesa](https://github.com/eubenesa)
|
||||
- [scottkidder](https://github.com/scottkidder]
|
||||
- [scottkidder](https://github.com/scottkidder)
|
||||
- [t-sauer](https://www.github.com/t-sauer)
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
"""
|
||||
Update Emoji.py
|
||||
Refeshes OMZ emoji database based on the latest Unicode spec
|
||||
Refreshes OMZ emoji database based on the latest Unicode spec
|
||||
"""
|
||||
import re
|
||||
import json
|
||||
|
|
@ -95,7 +95,7 @@ def name_to_omz(_name, _group, _subgroup, _status):
|
|||
shortname = snake_case(_name)
|
||||
# Special treatment by status
|
||||
# Enables us to have every emoji combination,
|
||||
# even the one that are not officially sanctionned
|
||||
# even the one that are not officially sanctioned
|
||||
# and are implemented by, say, only one vendor
|
||||
if _status == "unqualified":
|
||||
shortname += "_unqualified"
|
||||
|
|
|
|||
|
|
@ -14,52 +14,56 @@ plugins=(... extract)
|
|||
|
||||
## Supported file extensions
|
||||
|
||||
| Extension | Description |
|
||||
| :---------------- | :----------------------------------- |
|
||||
| `7z` | 7zip file |
|
||||
| `Z` | Z archive (LZW) |
|
||||
| `apk` | Android app file |
|
||||
| `aar` | Android library file |
|
||||
| `bz2` | Bzip2 file |
|
||||
| `cab` | Microsoft cabinet archive |
|
||||
| `cpio` | Cpio archive |
|
||||
| `deb` | Debian package |
|
||||
| `ear` | Enterprise Application aRchive |
|
||||
| `exe` | Windows executable file |
|
||||
| `gz` | Gzip file |
|
||||
| `ipa` | iOS app package |
|
||||
| `ipsw` | iOS firmware file |
|
||||
| `jar` | Java Archive |
|
||||
| `lrz` | LRZ archive |
|
||||
| `lz4` | LZ4 archive |
|
||||
| `lzma` | LZMA archive |
|
||||
| `obscpio` | cpio archive used on OBS |
|
||||
| `rar` | WinRAR archive |
|
||||
| `rpm` | RPM package |
|
||||
| `sublime-package` | Sublime Text package |
|
||||
| `tar` | Tarball |
|
||||
| `tar.bz2` | Tarball with bzip2 compression |
|
||||
| `tar.gz` | Tarball with gzip compression |
|
||||
| `tar.lrz` | Tarball with lrzip compression |
|
||||
| `tar.lz` | Tarball with lzip compression |
|
||||
| `tar.lz4` | Tarball with lz4 compression |
|
||||
| `tar.xz` | Tarball with lzma2 compression |
|
||||
| `tar.zma` | Tarball with lzma compression |
|
||||
| `tar.zst` | Tarball with zstd compression |
|
||||
| `tbz` | Tarball with bzip compression |
|
||||
| `tbz2` | Tarball with bzip2 compression |
|
||||
| `tgz` | Tarball with gzip compression |
|
||||
| `tlz` | Tarball with lzma compression |
|
||||
| `txz` | Tarball with lzma2 compression |
|
||||
| `tzst` | Tarball with zstd compression |
|
||||
| `war` | Web Application archive (Java-based) |
|
||||
| `whl` | Python wheel file |
|
||||
| `xpi` | Mozilla XPI module file |
|
||||
| `xz` | LZMA2 archive |
|
||||
| `zip` | Zip archive |
|
||||
| `zlib` | zlib archive |
|
||||
| `zst` | Zstandard file (zstd) |
|
||||
| `zpaq` | Zpaq file |
|
||||
| Extension | Description |
|
||||
| :---------------- | :-------------------------------------- |
|
||||
| `7z` | 7zip file |
|
||||
| `apk` | Android app file |
|
||||
| `aar` | Android library file |
|
||||
| `bz2` | Bzip2 file |
|
||||
| `cab` | Microsoft cabinet archive |
|
||||
| `cpio` | Cpio archive |
|
||||
| `deb` | Debian package |
|
||||
| `ear` | Enterprise Application aRchive |
|
||||
| `exe` | Windows executable file |
|
||||
| `gz` | Gzip file |
|
||||
| `ipa` | iOS app package |
|
||||
| `ipsw` | iOS firmware file |
|
||||
| `jar` | Java Archive |
|
||||
| `lrz` | LRZ archive |
|
||||
| `lz4` | LZ4 archive |
|
||||
| `lzma` | LZMA archive |
|
||||
| `obscpio` | cpio archive used on OBS |
|
||||
| `pk3` | Renamed Zip archive used by Quake games |
|
||||
| `pk4` | Renamed Zip archive used by Quake games |
|
||||
| `pk7` | Renamed 7zip file used by Quake games |
|
||||
| `rar` | WinRAR archive |
|
||||
| `rpm` | RPM package |
|
||||
| `sublime-package` | Sublime Text package |
|
||||
| `tar` | Tarball |
|
||||
| `tar.bz2` | Tarball with bzip2 compression |
|
||||
| `tar.gz` | Tarball with gzip compression |
|
||||
| `tar.lrz` | Tarball with lrzip compression |
|
||||
| `tar.lz` | Tarball with lzip compression |
|
||||
| `tar.lz4` | Tarball with lz4 compression |
|
||||
| `tar.xz` | Tarball with lzma2 compression |
|
||||
| `tar.zma` | Tarball with lzma compression |
|
||||
| `tar.zst` | Tarball with zstd compression |
|
||||
| `tbz` | Tarball with bzip compression |
|
||||
| `tbz2` | Tarball with bzip2 compression |
|
||||
| `tgz` | Tarball with gzip compression |
|
||||
| `tlz` | Tarball with lzma compression |
|
||||
| `txz` | Tarball with lzma2 compression |
|
||||
| `tzst` | Tarball with zstd compression |
|
||||
| `vsix` | VS Code extension zip file |
|
||||
| `war` | Web Application archive (Java-based) |
|
||||
| `whl` | Python wheel file |
|
||||
| `xpi` | Mozilla XPI module file |
|
||||
| `xz` | LZMA2 archive |
|
||||
| `Z` | Z archive (LZW) |
|
||||
| `zip` | Zip archive |
|
||||
| `zlib` | zlib archive |
|
||||
| `zst` | Zstandard file (zstd) |
|
||||
| `zpaq` | Zpaq file |
|
||||
|
||||
See [list of archive formats](https://en.wikipedia.org/wiki/List_of_archive_formats) for more information
|
||||
regarding archive formats.
|
||||
|
|
|
|||
|
|
@ -1,7 +1,57 @@
|
|||
#compdef extract
|
||||
#autoload
|
||||
|
||||
local -a exts=(
|
||||
7z
|
||||
aar
|
||||
apk
|
||||
bz2
|
||||
cab
|
||||
cpio
|
||||
crx
|
||||
deb
|
||||
ear
|
||||
gz
|
||||
ipa
|
||||
ipsw
|
||||
jar
|
||||
lrz
|
||||
lz4
|
||||
lzma
|
||||
obscpio
|
||||
pk3
|
||||
pk4
|
||||
pk7
|
||||
rar
|
||||
rpm
|
||||
sublime-package
|
||||
tar
|
||||
tar.bz2
|
||||
tar.gz
|
||||
tar.lrz
|
||||
tar.lz
|
||||
tar.lz4
|
||||
tar.xz
|
||||
tar.zma
|
||||
tar.zst
|
||||
tbz
|
||||
tbz2
|
||||
tgz
|
||||
tlz
|
||||
txz
|
||||
tzst
|
||||
vsix
|
||||
war
|
||||
whl
|
||||
xpi
|
||||
xz
|
||||
Z
|
||||
zip
|
||||
zpaq
|
||||
zst
|
||||
)
|
||||
|
||||
_arguments \
|
||||
'(-r --remove)'{-r,--remove}'[Remove archive.]' \
|
||||
"*::archive file:_files -g '(#i)*.(7z|Z|apk|aar|bz2|cab|cpio|deb|ear|gz|ipa|ipsw|jar|lrz|lz4|lzma|obscpio|rar|rpm|sublime-package|tar|tar.bz2|tar.gz|tar.lrz|tar.lz|tar.lz4|tar.xz|tar.zma|tar.zst|tbz|tbz2|tgz|tlz|txz|tzst|war|whl|xpi|xz|zip|zst|zpaq)(-.)'" \
|
||||
"*::archive file:_files -g '(#i)*.(${(j:|:)exts})(-.)'" \
|
||||
&& return 0
|
||||
|
|
|
|||
|
|
@ -76,11 +76,11 @@ EOF
|
|||
(*.lz4) lz4 -d "$full_path" ;;
|
||||
(*.lzma) unlzma "$full_path" ;;
|
||||
(*.z) uncompress "$full_path" ;;
|
||||
(*.zip|*.war|*.jar|*.ear|*.sublime-package|*.ipa|*.ipsw|*.xpi|*.apk|*.aar|*.whl) unzip "$full_path" ;;
|
||||
(*.zip|*.war|*.jar|*.ear|*.sublime-package|*.ipa|*.ipsw|*.xpi|*.apk|*.aar|*.whl|*.vsix|*.crx|*.pk3|*.pk4) unzip "$full_path" ;;
|
||||
(*.rar) unrar x -ad "$full_path" ;;
|
||||
(*.rpm)
|
||||
rpm2cpio "$full_path" | cpio --quiet -id ;;
|
||||
(*.7z | *.7z.[0-9]*) 7za x "$full_path" ;;
|
||||
(*.7z | *.7z.[0-9]* | *.pk7) 7za x "$full_path" ;;
|
||||
(*.deb)
|
||||
command mkdir -p "control" "data"
|
||||
ar vx "$full_path" > /dev/null
|
||||
|
|
|
|||
|
|
@ -65,6 +65,29 @@ If `yes`, sets the `--icons` option of `eza`, adding icons for files and folders
|
|||
|
||||
Default: `no`
|
||||
|
||||
### `color-scale`
|
||||
|
||||
```zsh
|
||||
zstyle ':omz:plugins:eza' 'color-scale' all|age|size
|
||||
```
|
||||
|
||||
Highlight levels of field(s) distinctly. Use comma(,) separated list of `all`, `age`, `size`
|
||||
|
||||
Default: `none`
|
||||
|
||||
### `color-scale-mode`
|
||||
|
||||
```zsh
|
||||
zstyle ':omz:plugins:eza' 'color-scale-mode' gradient|fixed
|
||||
```
|
||||
|
||||
Choose the mode for highlighting:
|
||||
|
||||
- `gradient` (default) -- gradient coloring
|
||||
- `fixed` -- fixed coloring
|
||||
|
||||
Default: `gradient`
|
||||
|
||||
### `size-prefix`
|
||||
|
||||
```zsh
|
||||
|
|
|
|||
|
|
@ -34,6 +34,14 @@ function _configure_eza() {
|
|||
if zstyle -t ':omz:plugins:eza' 'icons'; then
|
||||
_EZA_TAIL+=("--icons=auto")
|
||||
fi
|
||||
zstyle -s ':omz:plugins:eza' 'color-scale' _val
|
||||
if [[ $_val ]]; then
|
||||
_EZA_TAIL+=("--color-scale=$_val")
|
||||
fi
|
||||
zstyle -s ':omz:plugins:eza' 'color-scale-mode' _val
|
||||
if [[ $_val == (gradient|fixed) ]]; then
|
||||
_EZA_TAIL+=("--color-scale-mode=$_val")
|
||||
fi
|
||||
zstyle -s ':omz:plugins:eza' 'time-style' _val
|
||||
if [[ $_val ]]; then
|
||||
_EZA_TAIL+=("--time-style='$_val'")
|
||||
|
|
|
|||
|
|
@ -5,8 +5,8 @@
|
|||
# If they are not set yet, they will be
|
||||
# overwritten with their default values
|
||||
|
||||
default fastfile_dir "${HOME}/.fastfile"
|
||||
default fastfile_var_prefix "§"
|
||||
fastfile_dir="${fastfile_dir:-${HOME}/.fastfile}"
|
||||
fastfile_var_prefix="${fastfile_var_prefix:-§}"
|
||||
|
||||
###########################
|
||||
# Impl
|
||||
|
|
|
|||
35
plugins/foot/README.md
Normal file
35
plugins/foot/README.md
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
# foot
|
||||
|
||||
This plugin adds shell integration for [foot, a fast, lightweight and
|
||||
minimalistic Wayland terminal emulator](https://codeberg.org/dnkl/foot).
|
||||
|
||||
To use, add `foot` to the list of plugins in your `.zshrc` file:
|
||||
|
||||
```zsh
|
||||
plugins=(... foot)
|
||||
```
|
||||
|
||||
## Spawning new terminal instances in the current working directory
|
||||
|
||||
When spawning a new terminal instance (with `ctrl+shift+n` by default), the new
|
||||
instance will start in the current working directory.
|
||||
|
||||
## Jumping between prompts
|
||||
|
||||
Foot can move the current viewport to focus prompts of already executed
|
||||
commands (bound to ctrl+shift+z/x by default).
|
||||
|
||||
## Piping last command's output
|
||||
|
||||
The key binding `pipe-command-output` can pipe the last command's output to an
|
||||
application of your choice (similar to the other `pipe-*` key bindings):
|
||||
|
||||
```
|
||||
[key-bindings]
|
||||
pipe-command-output=[sh -c "f=$(mktemp); cat - > $f; footclient emacsclient -nw $f; rm $f"] Control+Shift+g
|
||||
```
|
||||
|
||||
When pressing ctrl+shift+g, the last command's output is written to a
|
||||
temporary file, then an emacsclient is started in a new footclient instance.
|
||||
The temporary file is removed after the footclient instance has closed.
|
||||
|
||||
10
plugins/foot/foot.plugin.zsh
Normal file
10
plugins/foot/foot.plugin.zsh
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
function precmd {
|
||||
print -Pn "\e]133;A\e\\"
|
||||
if ! builtin zle; then
|
||||
print -n "\e]133;D\e\\"
|
||||
fi
|
||||
}
|
||||
|
||||
function preexec {
|
||||
print -n "\e]133;C\e\\"
|
||||
}
|
||||
|
|
@ -11,7 +11,7 @@ function gemy {
|
|||
if [[ ! -f "$ZSH_CACHE_DIR/completions/_gem" ]]; then
|
||||
typeset -g -A _comps
|
||||
autoload -Uz _gem
|
||||
_comps[docker]=_gem
|
||||
_comps[gem]=_gem
|
||||
fi
|
||||
|
||||
# zsh 5.5 already provides completion for `_gem`. With this we ensure that
|
||||
|
|
@ -23,7 +23,7 @@ if is-at-least 5.5; then
|
|||
fi
|
||||
|
||||
{
|
||||
# Standarized $0 handling
|
||||
# Standardized $0 handling
|
||||
# https://zdharma-continuum.github.io/Zsh-100-Commits-Club/Zsh-Plugin-Standard.html
|
||||
0="${${ZERO:-${0:#$ZSH_ARGZERO}}:-${(%):-%N}}"
|
||||
0="${${(M)0:#/*}:-$PWD/$0}"
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ You can change the fetch interval in your .zshrc:
|
|||
GIT_AUTO_FETCH_INTERVAL=1200 # in seconds
|
||||
```
|
||||
|
||||
A log of `git fetch --all` will be saved in `.git/FETCH_LOG`.
|
||||
A log of `git-fetch-all` will be saved in `.git/FETCH_LOG`.
|
||||
|
||||
## Toggle auto-fetch per folder
|
||||
|
||||
|
|
|
|||
|
|
@ -23,9 +23,10 @@ def get_tagname_or_hash():
|
|||
return hash_
|
||||
return None
|
||||
|
||||
# Re-use method from https://github.com/magicmonty/bash-git-prompt to get stashs count
|
||||
# Re-use method from https://github.com/magicmonty/bash-git-prompt to get stash count
|
||||
# Use `--git-common-dir` to avoid problems with git worktrees, which don't have individual stashes
|
||||
def get_stash():
|
||||
cmd = Popen(['git', 'rev-parse', '--git-dir'], stdout=PIPE, stderr=PIPE)
|
||||
cmd = Popen(['git', 'rev-parse', '--git-common-dir'], stdout=PIPE, stderr=PIPE)
|
||||
so, se = cmd.communicate()
|
||||
stash_file = '%s%s' % (so.decode('utf-8').rstrip(), '/logs/refs/stash')
|
||||
|
||||
|
|
@ -35,7 +36,6 @@ def get_stash():
|
|||
except IOError:
|
||||
return 0
|
||||
|
||||
|
||||
# `git status --porcelain --branch` can collect all information
|
||||
# branch, remote_branch, untracked, staged, changed, conflicts, ahead, behind
|
||||
po = Popen(['git', 'status', '--porcelain', '--branch'], env=dict(os.environ, LANG="C"), stdout=PIPE, stderr=PIPE)
|
||||
|
|
|
|||
|
|
@ -73,11 +73,13 @@ plugins=(... git)
|
|||
| `gcans!` | `git commit --verbose --all --signoff --no-edit --amend` |
|
||||
| `gcann!` | `git commit --verbose --all --date=now --no-edit --amend` |
|
||||
| `gc!` | `git commit --verbose --amend` |
|
||||
| `gcn` | `git commit --verbose --no-edit` |
|
||||
| `gcn!` | `git commit --verbose --no-edit --amend` |
|
||||
| `gcs` | `git commit -S` |
|
||||
| `gcss` | `git commit -S -s` |
|
||||
| `gcssm` | `git commit -S -s -m` |
|
||||
| `gcf` | `git config --list` |
|
||||
| `gcfu` | `git commit --fixup` |
|
||||
| `gdct` | `git describe --tags $(git rev-list --tags --max-count=1)` |
|
||||
| `gd` | `git diff` |
|
||||
| `gdca` | `git diff --cached` |
|
||||
|
|
@ -114,6 +116,7 @@ plugins=(... git)
|
|||
| `gma` | `git merge --abort` |
|
||||
| `gmc` | `git merge --continue` |
|
||||
| `gms` | `git merge --squash` |
|
||||
| `gmff` | `git merge --ff-only` |
|
||||
| `gmom` | `git merge origin/$(git_main_branch)` |
|
||||
| `gmum` | `git merge upstream/$(git_main_branch)` |
|
||||
| `gmtl` | `git mergetool --no-prompt` |
|
||||
|
|
@ -125,6 +128,8 @@ plugins=(... git)
|
|||
| `gprav` | `git pull --rebase --autostash -v` |
|
||||
| `gprom` | `git pull --rebase origin $(git_main_branch)` |
|
||||
| `gpromi` | `git pull --rebase=interactive origin $(git_main_branch)` |
|
||||
| `gprum` | `git pull --rebase upstream $(git_main_branch)` |
|
||||
| `gprumi` | `git pull --rebase=interactive upstream $(git_main_branch)` |
|
||||
| `ggpull` | `git pull origin "$(git_current_branch)"` |
|
||||
| `ggl` | `git pull origin $(current_branch)` |
|
||||
| `gluc` | `git pull upstream $(git_current_branch)` |
|
||||
|
|
@ -154,6 +159,7 @@ plugins=(... git)
|
|||
| `grbd` | `git rebase $(git_develop_branch)` |
|
||||
| `grbm` | `git rebase $(git_main_branch)` |
|
||||
| `grbom` | `git rebase origin/$(git_main_branch)` |
|
||||
| `grbum` | `git rebase upstream/$(git_main_branch)` |
|
||||
| `grf` | `git reflog` |
|
||||
| `gr` | `git remote` |
|
||||
| `grv` | `git remote --verbose` |
|
||||
|
|
|
|||
|
|
@ -86,7 +86,7 @@ function work_in_progress() {
|
|||
# Aliases
|
||||
# (sorted alphabetically by command)
|
||||
# (order should follow README)
|
||||
# (in some cases force the alisas order to match README, like for example gke and gk)
|
||||
# (in some cases force the alias order to match README, like for example gke and gk)
|
||||
#
|
||||
|
||||
alias grt='cd "$(git rev-parse --show-toplevel || echo .)"'
|
||||
|
|
@ -197,8 +197,10 @@ alias gcan!='git commit --verbose --all --no-edit --amend'
|
|||
alias gcans!='git commit --verbose --all --signoff --no-edit --amend'
|
||||
alias gcann!='git commit --verbose --all --date=now --no-edit --amend'
|
||||
alias gc!='git commit --verbose --amend'
|
||||
alias gcn='git commit --verbose --no-edit'
|
||||
alias gcn!='git commit --verbose --no-edit --amend'
|
||||
alias gcf='git config --list'
|
||||
alias gcfu='git commit --fixup'
|
||||
alias gdct='git describe --tags $(git rev-list --tags --max-count=1)'
|
||||
alias gd='git diff'
|
||||
alias gdca='git diff --cached'
|
||||
|
|
@ -255,6 +257,7 @@ alias gm='git merge'
|
|||
alias gma='git merge --abort'
|
||||
alias gmc='git merge --continue'
|
||||
alias gms="git merge --squash"
|
||||
alias gmff="git merge --ff-only"
|
||||
alias gmom='git merge origin/$(git_main_branch)'
|
||||
alias gmum='git merge upstream/$(git_main_branch)'
|
||||
alias gmtl='git mergetool --no-prompt'
|
||||
|
|
@ -274,6 +277,8 @@ compdef _git ggu=git-checkout
|
|||
|
||||
alias gprom='git pull --rebase origin $(git_main_branch)'
|
||||
alias gpromi='git pull --rebase=interactive origin $(git_main_branch)'
|
||||
alias gprum='git pull --rebase upstream $(git_main_branch)'
|
||||
alias gprumi='git pull --rebase=interactive upstream $(git_main_branch)'
|
||||
alias ggpull='git pull origin "$(git_current_branch)"'
|
||||
|
||||
function ggl() {
|
||||
|
|
@ -337,6 +342,7 @@ alias grbs='git rebase --skip'
|
|||
alias grbd='git rebase $(git_develop_branch)'
|
||||
alias grbm='git rebase $(git_main_branch)'
|
||||
alias grbom='git rebase origin/$(git_main_branch)'
|
||||
alias grbum='git rebase upstream/$(git_main_branch)'
|
||||
alias grf='git reflog'
|
||||
alias gr='git remote'
|
||||
alias grv='git remote --verbose'
|
||||
|
|
|
|||
40
plugins/gitfast/MANUAL.adoc
Normal file
40
plugins/gitfast/MANUAL.adoc
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
This project is a friendly fork of the official Git completion
|
||||
(`contrib/completion`) and prompt scripts for Bash, Zsh, and possibly other
|
||||
shells.
|
||||
|
||||
Most Git developers use the Bash shell, for which the completion scripts work
|
||||
rather well, however, Zsh is typically neglected. I've sent many patches to fix
|
||||
the issues, many have been merged, but many have been ignored, thus the need for
|
||||
a canonical location of a good, working Zsh completion.
|
||||
|
||||
There are advantages for Bash users too. Currently the scripts under `contrib` are tied to the
|
||||
specific Git version, for example the completion scripts of version v2.40
|
||||
(https://git.kernel.org/pub/scm/git/git.git/plain/contrib/completion/git-completion.bash?h=v2.40.0[git-completion.bash])
|
||||
have issues with older versions of Git (e.g. v2.33); the ones in
|
||||
this project don't.
|
||||
|
||||
With `git-completion` you can be sure you are using the latest completion that
|
||||
works in both shells, and any Git version.
|
||||
|
||||
This is a sister project of the
|
||||
https://github.com/ohmyzsh/ohmyzsh/tree/master/plugins/gitfast[Oh My Zsh
|
||||
gitfast] plugin (that I also maintain), which has similar needs.
|
||||
|
||||
== Installation ==
|
||||
|
||||
* https://github.com/felipec/git-completion/wiki/Bash[Bash instructions]
|
||||
* https://github.com/felipec/git-completion/wiki/Zsh[Zsh instructions]
|
||||
|
||||
== Improvements from upstream ==
|
||||
|
||||
This is a short list of the benefits you get:
|
||||
|
||||
* Easier installation
|
||||
* Tons of bug fixes
|
||||
* Works with older versions of git
|
||||
* Zsh: much more options
|
||||
* Zsh: quoting works properly
|
||||
* Zsh: automatic suffix removal
|
||||
|
||||
For a full list of all the patches on top of upstream git check
|
||||
https://github.com/felipec/git-completion/wiki/Patches[Patches].
|
||||
|
|
@ -2,23 +2,11 @@
|
|||
|
||||
# zsh completion wrapper for git
|
||||
#
|
||||
# Copyright (c) 2012-2020 Felipe Contreras <felipe.contreras@gmail.com>
|
||||
# Copyright (c) 2012-2024 Felipe Contreras <felipe.contreras@gmail.com>
|
||||
#
|
||||
# The recommended way to install this script is to make a copy of it as a
|
||||
# file named '_git' inside any directory in your fpath.
|
||||
# The recommended way to use this script is to prepend its location to your $fpath:
|
||||
#
|
||||
# For example, create a directory '~/.zsh/', copy this file to '~/.zsh/_git',
|
||||
# and then add the following to your ~/.zshrc file:
|
||||
#
|
||||
# fpath=(~/.zsh $fpath)
|
||||
#
|
||||
# You need git's bash completion script installed. By default bash-completion's
|
||||
# location will be used (e.g. pkg-config --variable=completionsdir bash-completion).
|
||||
#
|
||||
# If your bash completion script is somewhere else, you can specify the
|
||||
# location in your ~/.zshrc:
|
||||
#
|
||||
# zstyle ':completion:*:*:git:*' script ~/.git-completion.bash
|
||||
# fpath=($git_completion_srcdir $fpath)
|
||||
#
|
||||
|
||||
zstyle -T ':completion:*:*:git:*' tag-order && \
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
# bash/zsh completion support for core Git.
|
||||
#
|
||||
# Copyright (C) 2006,2007 Shawn O. Pearce <spearce@spearce.org>
|
||||
# Copyright (c) 2012-2024 Felipe Contreras <felipe.contreras@gmail.com>
|
||||
#
|
||||
# Conceptually based on gitcompletion (http://gitweb.hawaga.org.uk/).
|
||||
# Distributed under the GNU General Public License, version 2.0.
|
||||
#
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ files=(
|
|||
/etc/grc.zsh # default
|
||||
/usr/local/etc/grc.zsh # homebrew darwin-x64
|
||||
/opt/homebrew/etc/grc.zsh # homebrew darwin-arm64
|
||||
/home/linuxbrew/.linuxbrew/etc/grc.zsh # linuxbrew
|
||||
/usr/share/grc/grc.zsh # Gentoo Linux (app-misc/grc)
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -295,8 +295,8 @@ _history-substring-search-begin() {
|
|||
fi
|
||||
|
||||
#
|
||||
# Escape and join query parts with wildcard character '*' as seperator
|
||||
# `(j:CHAR:)` join array to string with CHAR as seperator
|
||||
# Escape and join query parts with wildcard character '*' as separator
|
||||
# `(j:CHAR:)` join array to string with CHAR as separator
|
||||
#
|
||||
local search_pattern="${(j:*:)_history_substring_search_query_parts[@]//(#m)[\][()|\\*?#<>~^]/\\$MATCH}*"
|
||||
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@
|
|||
|
||||
- Zaphod.
|
||||
%
|
||||
"`In those days spirits were brave, the stakes were high, men were REAL men, women were REAL women, and small furry creatures from Alpha Centauri were REAL small furry creatures from Aplha Centauri.'"
|
||||
"`In those days spirits were brave, the stakes were high, men were REAL men, women were REAL women, and small furry creatures from Alpha Centauri were REAL small furry creatures from Alpha Centauri.'"
|
||||
|
||||
- The Book getting all nostalgic.
|
||||
%
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ This plugin supplies one command, `jira`, through which all its features are exp
|
|||
| `jira new` | Opens a new Jira issue dialogue |
|
||||
| `jira ABC-123` | Opens an existing issue |
|
||||
| `jira ABC-123 m` | Opens an existing issue for adding a comment |
|
||||
| `jira project ABC` | Opens JIRA project summary |
|
||||
| `jira dashboard [rapid_view]` | Opens your JIRA dashboard |
|
||||
| `jira mine` | Queries for your own issues |
|
||||
| `jira tempo` | Opens your JIRA Tempo |
|
||||
|
|
@ -43,6 +44,22 @@ starting with "_": "MP-1234_fix_dashboard". In both these cases, the issue opene
|
|||
This is also checks if the prefix is in the name, and adds it if not, so: "MP-1234" opens the issue "MP-1234",
|
||||
"mp-1234" opens the issue "mp-1234", and "1234" opens the issue "MP-1234".
|
||||
|
||||
If your branch naming convention deviates, you can overwrite the jira_branch function to determine and echo the Jira issue key yourself.
|
||||
Define a function `jira_branch` after sourcing `oh-my-zsh.sh` in your `.zshrc`.
|
||||
Example:
|
||||
```zsh
|
||||
# Determine branch name from naming convention 'type/KEY-123/description'.
|
||||
function jira_branch() {
|
||||
# Get name of the branch
|
||||
issue_arg=$(git rev-parse --abbrev-ref HEAD)
|
||||
# Strip prefixes like feature/ or bugfix/
|
||||
issue_arg=${issue_arg#*/}
|
||||
# Strip suffixes like /some-branch-description
|
||||
issue_arg=${issue_arg%%/*}
|
||||
# Return the value
|
||||
echo $issue_arg
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
#### Debugging usage
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ local -a _1st_arguments
|
|||
_1st_arguments=(
|
||||
'new:create a new issue'
|
||||
'mine:open my issues'
|
||||
'project:open the project'
|
||||
'dashboard:open the dashboard'
|
||||
'tempo:open the tempo'
|
||||
'reported:search for issues reported by a user'
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ jira Performs the default action
|
|||
jira new Opens a new Jira issue dialogue
|
||||
jira ABC-123 Opens an existing issue
|
||||
jira ABC-123 m Opens an existing issue for adding a comment
|
||||
jira project ABC Opens JIRA project summary
|
||||
jira dashboard [rapid_view] Opens your JIRA dashboard
|
||||
jira mine Queries for your own issues
|
||||
jira tempo Opens your JIRA Tempo
|
||||
|
|
@ -17,6 +18,30 @@ jira branch Opens an existing issue matching the current bra
|
|||
EOF
|
||||
}
|
||||
|
||||
# If your branch naming convention deviates, you can partially override this plugin function
|
||||
# to determine the jira issue key based on your formatting.
|
||||
# See https://github.com/ohmyzsh/ohmyzsh/wiki/Customization#partially-overriding-an-existing-plugin
|
||||
function jira_branch() {
|
||||
# Get name of the branch
|
||||
issue_arg=$(git rev-parse --abbrev-ref HEAD)
|
||||
# Strip prefixes like feature/ or bugfix/
|
||||
issue_arg=${issue_arg##*/}
|
||||
# Strip suffixes starting with _
|
||||
issue_arg=(${(s:_:)issue_arg})
|
||||
# If there is only one part, it means that there is a different delimiter. Try with -
|
||||
if [[ ${#issue_arg[@]} = 1 && ${issue_arg} == *-* ]]; then
|
||||
issue_arg=(${(s:-:)issue_arg})
|
||||
issue_arg="${issue_arg[1]}-${issue_arg[2]}"
|
||||
else
|
||||
issue_arg=${issue_arg[1]}
|
||||
fi
|
||||
if [[ "${issue_arg:l}" = ${jira_prefix:l}* ]]; then
|
||||
echo "${issue_arg}"
|
||||
else
|
||||
echo "${jira_prefix}${issue_arg}"
|
||||
fi
|
||||
}
|
||||
|
||||
function jira() {
|
||||
emulate -L zsh
|
||||
local action jira_url jira_prefix
|
||||
|
|
@ -64,6 +89,9 @@ function jira() {
|
|||
elif [[ "$action" == "mine" ]]; then
|
||||
echo "Opening my issues"
|
||||
open_command "${jira_url}/issues/?filter=-1"
|
||||
elif [[ "$action" == "project" ]]; then
|
||||
echo "Opening project"
|
||||
open_command "${jira_url}/jira/software/c/projects/${2}/summary"
|
||||
elif [[ "$action" == "dashboard" ]]; then
|
||||
echo "Opening dashboard"
|
||||
if [[ "$JIRA_RAPID_BOARD" == "true" ]]; then
|
||||
|
|
@ -91,24 +119,7 @@ function jira() {
|
|||
# but `branch` is a special case that will parse the current git branch
|
||||
local issue_arg issue
|
||||
if [[ "$action" == "branch" ]]; then
|
||||
# Get name of the branch
|
||||
issue_arg=$(git rev-parse --abbrev-ref HEAD)
|
||||
# Strip prefixes like feature/ or bugfix/
|
||||
issue_arg=${issue_arg##*/}
|
||||
# Strip suffixes starting with _
|
||||
issue_arg=(${(s:_:)issue_arg})
|
||||
# If there is only one part, it means that there is a different delimiter. Try with -
|
||||
if [[ ${#issue_arg[@]} = 1 && ${issue_arg} == *-* ]]; then
|
||||
issue_arg=(${(s:-:)issue_arg})
|
||||
issue_arg="${issue_arg[1]}-${issue_arg[2]}"
|
||||
else
|
||||
issue_arg=${issue_arg[1]}
|
||||
fi
|
||||
if [[ "${issue_arg:l}" = ${jira_prefix:l}* ]]; then
|
||||
issue="${issue_arg}"
|
||||
else
|
||||
issue="${jira_prefix}${issue_arg}"
|
||||
fi
|
||||
issue=$(jira_branch)
|
||||
else
|
||||
issue_arg=${(U)action}
|
||||
issue="${jira_prefix}${issue_arg}"
|
||||
|
|
|
|||
90
plugins/jj/README.md
Normal file
90
plugins/jj/README.md
Normal file
|
|
@ -0,0 +1,90 @@
|
|||
# jj - Jujutsu CLI
|
||||
|
||||
This plugin provides autocompletion for [jj](https://martinvonz.github.io/jj).
|
||||
|
||||
To use it, add `jj` to the plugins array of your zshrc file:
|
||||
|
||||
```zsh
|
||||
plugins=(... jj)
|
||||
```
|
||||
|
||||
## Aliases
|
||||
|
||||
| Alias | Command |
|
||||
| ------ | ----------------------------- |
|
||||
| jjc | `jj commit` |
|
||||
| jjcmsg | `jj commit --message` |
|
||||
| jjd | `jj diff` |
|
||||
| jjdmsg | `jj desc --message` |
|
||||
| jjds | `jj desc` |
|
||||
| jje | `jj edit` |
|
||||
| jjgcl | `jj git clone` |
|
||||
| jjgf | `jj git fetch` |
|
||||
| jjgfa | `jj git fetch --all-remotes` |
|
||||
| jjgp | `jj git push` |
|
||||
| jjl | `jj log` |
|
||||
| jjla | `jj log -r "all()"` |
|
||||
| jjn | `jj new` |
|
||||
| jjrb | `jj rebase` |
|
||||
| jjrs | `jj restore` |
|
||||
| jjrt | `cd "$(jj root \|\| echo .)"` |
|
||||
| jjsp | `jj split` |
|
||||
| jjsq | `jj squash` |
|
||||
|
||||
## Prompt usage
|
||||
|
||||
Because `jj` has a very powerful [template syntax](https://martinvonz.github.io/jj/latest/templates/), this
|
||||
plugin only exposes a convenience function `jj_prompt_template` to read information from the current change.
|
||||
It is basically the same as `jj log --no-graph -r @ -T $1`:
|
||||
|
||||
```sh
|
||||
_my_theme_jj_info() {
|
||||
jj_prompt_template 'self.change_id().shortest(3)'
|
||||
}
|
||||
|
||||
PROMPT='$(_my_theme_jj_info) $'
|
||||
```
|
||||
|
||||
`jj_prompt_template` escapes `%` signs in the output. Use `jj_prompt_template_raw` if you don't want that
|
||||
(e.g. to colorize the output).
|
||||
|
||||
However, because `jj` can be used inside a Git repository, some themes might clash with it. Generally, you can
|
||||
fix it with a wrapper function that tries `jj` first and then falls back to `git` if it didn't work:
|
||||
|
||||
```sh
|
||||
_my_theme_vcs_info() {
|
||||
jj_prompt_template 'self.change_id().shortest(3)' \
|
||||
|| git_prompt_info
|
||||
}
|
||||
|
||||
PROMPT='$(_my_theme_vcs_info) $'
|
||||
```
|
||||
|
||||
You can find an example
|
||||
[here](https://github.com/nasso/omzsh/blob/e439e494f22f4fd4ef1b6cb64626255f4b341c1b/themes/sunakayu.zsh-theme).
|
||||
|
||||
### Performance
|
||||
|
||||
Sometimes `jj` can be slower than `git`.
|
||||
|
||||
If you feel slowdowns, consider using the following:
|
||||
|
||||
```
|
||||
zstyle :omz:plugins:jj ignore-working-copy yes
|
||||
```
|
||||
|
||||
This will add `--ignore-working-copy` to all `jj` commands executed by your prompt. The downside here is that
|
||||
your prompt might be out-of-sync until the next time `jj` gets a chance to _not_ ignore the working copy (i.e.
|
||||
you manually run a `jj` command).
|
||||
|
||||
If you prefer to keep your prompt always up-to-date but still don't want to _feel_ the slowdown, you can make
|
||||
your prompt asynchronous. This plugin doesn't do this automatically so you'd have to hack your theme a bit for
|
||||
that.
|
||||
|
||||
## See Also
|
||||
|
||||
- [martinvonz/jj](https://github.com/martinvonz/jj)
|
||||
|
||||
## Contributors
|
||||
|
||||
- [nasso](https://github.com/nasso) - Plugin Author
|
||||
54
plugins/jj/jj.plugin.zsh
Normal file
54
plugins/jj/jj.plugin.zsh
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
# if jj is not found, don't do the rest of the script
|
||||
if (( ! $+commands[jj] )); then
|
||||
return
|
||||
fi
|
||||
|
||||
# If the completion file doesn't exist yet, we need to autoload it and
|
||||
# bind it to `jj`. Otherwise, compinit will have already done that.
|
||||
if [[ ! -f "$ZSH_CACHE_DIR/completions/_jj" ]]; then
|
||||
typeset -g -A _comps
|
||||
autoload -Uz _jj
|
||||
_comps[jj]=_jj
|
||||
fi
|
||||
|
||||
COMPLETE=zsh jj >| "$ZSH_CACHE_DIR/completions/_jj" &|
|
||||
|
||||
function __jj_prompt_jj() {
|
||||
local -a flags
|
||||
flags=("--no-pager")
|
||||
if zstyle -t ':omz:plugins:jj' ignore-working-copy; then
|
||||
flags+=("--ignore-working-copy")
|
||||
fi
|
||||
command jj $flags "$@"
|
||||
}
|
||||
|
||||
# convenience functions for themes
|
||||
function jj_prompt_template_raw() {
|
||||
__jj_prompt_jj log --no-graph -r @ -T "$@" 2> /dev/null
|
||||
}
|
||||
|
||||
function jj_prompt_template() {
|
||||
local out
|
||||
out=$(jj_prompt_template_raw "$@") || return 1
|
||||
echo "${out:gs/%/%%}"
|
||||
}
|
||||
|
||||
# Aliases (sorted alphabetically)
|
||||
alias jjc='jj commit'
|
||||
alias jjcmsg='jj commit --message'
|
||||
alias jjd='jj diff'
|
||||
alias jjdmsg='jj desc --message'
|
||||
alias jjds='jj desc'
|
||||
alias jje='jj edit'
|
||||
alias jjgcl='jj git clone'
|
||||
alias jjgf='jj git fetch'
|
||||
alias jjgfa='jj git fetch --all-remotes'
|
||||
alias jjgp='jj git push'
|
||||
alias jjl='jj log'
|
||||
alias jjla='jj log -r "all()"'
|
||||
alias jjn='jj new'
|
||||
alias jjrb='jj rebase'
|
||||
alias jjrs='jj restore'
|
||||
alias jjrt='cd "$(jj root || echo .)"'
|
||||
alias jjsp='jj split'
|
||||
alias jjsq='jj squash'
|
||||
|
|
@ -8,6 +8,17 @@ To use it, add `jsontools` to the plugins array in your zshrc file:
|
|||
plugins=(... jsontools)
|
||||
```
|
||||
|
||||
## Requirements
|
||||
|
||||
The plugin uses one of these tools to process JSON data, in the following order:
|
||||
|
||||
- `node`
|
||||
- `python3`
|
||||
- `ruby`
|
||||
|
||||
Any of these must be in `$PATH` before the plugin is loaded, otherwise the plugin exits
|
||||
prematurely and the functions will not be available.
|
||||
|
||||
## Usage
|
||||
|
||||
Usage is simple... just take your json data and pipe it into the appropriate jsontool:
|
||||
|
|
@ -19,7 +30,7 @@ Usage is simple... just take your json data and pipe it into the appropriate jso
|
|||
|
||||
### Supports NDJSON (Newline Delimited JSON)
|
||||
|
||||
The plugin also supports [NDJSON](http://ndjson.org/) input, which means all functions
|
||||
The plugin also supports [NDJSON](https://github.com/ndjson/ndjson-spec) input, which means all functions
|
||||
have an alternative function that reads and processes the input line by line. These
|
||||
functions have the same name except using `ndjson` instead of `json`:
|
||||
|
||||
|
|
|
|||
9
plugins/k9s/README.md
Normal file
9
plugins/k9s/README.md
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
# k9s plugin
|
||||
|
||||
This plugin adds completion support for the [k9s](https://k9scli.io).
|
||||
|
||||
To use it, add `k9s` to the plugins array in your zshrc file:
|
||||
|
||||
```zsh
|
||||
plugins=(... k9s)
|
||||
```
|
||||
14
plugins/k9s/k9s.plugin.zsh
Normal file
14
plugins/k9s/k9s.plugin.zsh
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
if (( ! $+commands[k9s] )); then
|
||||
return
|
||||
fi
|
||||
|
||||
# If the completion file does not exist, fake it and load it
|
||||
if [[ ! -f "$ZSH_CACHE_DIR/completions/_k9s" ]]; then
|
||||
typeset -g -A _comps
|
||||
autoload -Uz _k9s
|
||||
_comps[k9s]=_k9s
|
||||
fi
|
||||
|
||||
# and then generate it in the background. On first completion,
|
||||
# the actual completion file will be loaded.
|
||||
k9s completion zsh >| "$ZSH_CACHE_DIR/completions/_k9s" &|
|
||||
16
plugins/kamal/README.md
Normal file
16
plugins/kamal/README.md
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
# Kamal
|
||||
|
||||
This plugin provides completion for [Kamal](https://kamal-deploy.org/) as well as some
|
||||
aliases for frequent Kamal commands.
|
||||
|
||||
To use it, add kamal to the plugins array of your zshrc file:
|
||||
|
||||
```zsh
|
||||
plugins=(... kamal)
|
||||
```
|
||||
|
||||
## Aliase
|
||||
|
||||
| Alias | Command | Description |
|
||||
|-----------|----------------------------------|----------------------------------------------------------------------------------|
|
||||
| kad | `kamal deploy` | Deploy app to servers |
|
||||
691
plugins/kamal/_kamal
Normal file
691
plugins/kamal/_kamal
Normal file
|
|
@ -0,0 +1,691 @@
|
|||
#compdef kamal
|
||||
|
||||
# Description
|
||||
# -----------
|
||||
# zsh completion for Kamal (https://kamal-deploy.org/)
|
||||
# -------------------------------------------------------------------------
|
||||
# Authors
|
||||
# -------
|
||||
# * Igor Aleksandrov <igor.alexandrov@gmail.com>
|
||||
# -------------------------------------------------------------------------
|
||||
# Inspiration
|
||||
# -----------
|
||||
# * docker-compose ohmyzsh completion script by @sdurrheimer Steve Durrheimer
|
||||
# -------------------------------------------------------------------------
|
||||
|
||||
# _kamal_commands() {
|
||||
# # Only initialize if empty
|
||||
# if (( ${#kamal_commands} == 0 )); then
|
||||
# kamal_commands=(
|
||||
# accessory
|
||||
# app
|
||||
# audit
|
||||
# build
|
||||
# config
|
||||
# deploy
|
||||
# details
|
||||
# docs
|
||||
# help
|
||||
# init
|
||||
# lock
|
||||
# proxy
|
||||
# prune
|
||||
# redeploy
|
||||
# registry
|
||||
# remove
|
||||
# rollback
|
||||
# secrets
|
||||
# server
|
||||
# setup
|
||||
# upgrade
|
||||
# version
|
||||
# )
|
||||
# fi
|
||||
|
||||
# _values 'Kamal commands' $kamal_commands
|
||||
# }
|
||||
|
||||
typeset -gr _kamal_commands=(
|
||||
'accessory:Control accessory services'
|
||||
'app:Control application deployment'
|
||||
'audit:Audit security of deployment'
|
||||
'build:Build and manage app images'
|
||||
'config:Show effective configuration'
|
||||
'deploy:Deploy app to servers'
|
||||
'details:Show details about deployment'
|
||||
'docs:Open documentation in browser'
|
||||
'help:Show command help'
|
||||
'init:Initialize new Kamal project'
|
||||
'lock:Manage deployment locks'
|
||||
'proxy:Control reverse proxy'
|
||||
'prune:Clean up containers and images'
|
||||
'redeploy:Redeploy current version'
|
||||
'registry:Manage Docker registry access'
|
||||
'remove:Remove app from servers'
|
||||
'rollback:Rollback to a previous version'
|
||||
'secrets:Manage deployment secrets'
|
||||
'server:Control server configuration'
|
||||
'setup:Setup initial deployment'
|
||||
'upgrade:Upgrade deployment'
|
||||
'version:Show Kamal version'
|
||||
)
|
||||
|
||||
# Helper function to display messages
|
||||
_kamal_message() {
|
||||
local msg="$1"
|
||||
_kamal_message "==> $msg"
|
||||
}
|
||||
|
||||
# Helper function to extract destination names from ./config/deploy.*.yml
|
||||
_kamal_destinations() {
|
||||
local -a dests
|
||||
local file
|
||||
|
||||
# Check if config directory exists
|
||||
if [[ ! -d "config" ]]; then
|
||||
_kamal_message "Cannot find Kamal configuration directory at ./config" && return 1
|
||||
fi
|
||||
|
||||
for file in config/deploy.*.yml(N); do
|
||||
[[ $file =~ config/deploy\.(.+)\.yml ]] && dests+=("${match[1]}")
|
||||
done
|
||||
|
||||
_values 'Destination' $dests
|
||||
}
|
||||
|
||||
# Define global _kamal_flags array
|
||||
typeset -ga _kamal_flags
|
||||
_kamal_flags=(
|
||||
'(-v --verbose )'{-v,--verbose}'[Detailed logging]'
|
||||
'(--no-verbose --skip-verbose)'{--no-verbose,--skip-verbose}'[No detailed logging]'
|
||||
'(-q --quiet --no-quiet --skip-quiet)'{-q,--quiet}'[Minimal logging]'
|
||||
'(-q --quiet --no-quiet --skip-quiet)'{--no-quiet,--skip-quiet}'[No minimal logging]'
|
||||
'--version=[Run commands against a specific app version]:version'
|
||||
'(-p --primary --no-primary --skip-primary)'{-p,--primary}'[Run commands only on primary host instead of all]'
|
||||
'(-p --primary --no-primary --skip-primary)'{--no-primary,--skip-primary}'[Do not run commands only on primary host]'
|
||||
'(-h --hosts)'{-h,--hosts=}'[Run commands on these hosts instead of all]:hosts'
|
||||
'(-r --roles)'{-r,--roles=}'[Run commands on these roles instead of all]:roles'
|
||||
'(-c --config-file)'{-c,--config-file=}'[Path to config file]:config file:_files'
|
||||
'(-d --destination)'{-d,--destination=}'[Specify destination to be used for config file]:destination:_kamal_destinations'
|
||||
'(-H --skip-hooks)'{-H,--skip-hooks}'[Do not run hooks]'
|
||||
)
|
||||
|
||||
_kamal() {
|
||||
local context state state_descr line curcontext="$curcontext"
|
||||
typeset -A opt_args
|
||||
|
||||
local ret=1
|
||||
|
||||
_arguments -C \
|
||||
$_kamal_flags \
|
||||
'1: :->command' \
|
||||
'*:: :->args' && ret=0
|
||||
|
||||
case $state in
|
||||
(command)
|
||||
# First argument - show available commands
|
||||
_describe -t kamal-commands "Kamal commands" _kamal_commands && ret=0
|
||||
;;
|
||||
(args)
|
||||
# Subsequent arguments - handle based on the command
|
||||
case $words[1] in
|
||||
(accessory)
|
||||
_kamal_accessory && ret=0
|
||||
;;
|
||||
(app)
|
||||
_kamal_app && ret=0
|
||||
;;
|
||||
(audit)
|
||||
_arguments $_kamal_flags && ret=0
|
||||
;;
|
||||
(build)
|
||||
_kamal_build && ret=0
|
||||
;;
|
||||
(config)
|
||||
_arguments $_kamal_flags && ret=0
|
||||
;;
|
||||
(deploy)
|
||||
_arguments $_kamal_flags && ret=0
|
||||
;;
|
||||
(details)
|
||||
_arguments $_kamal_flags && ret=0
|
||||
;;
|
||||
(docs)
|
||||
_arguments $_kamal_flags && ret=0
|
||||
;;
|
||||
(help)
|
||||
_kamal_help && ret=0
|
||||
;;
|
||||
(init)
|
||||
local -a init_flags
|
||||
init_flags=(
|
||||
$_kamal_flags
|
||||
'(--bundle --no-bundle --skip-bundle)--bundle[Add Kamal to the Gemfile and create a bin/kamal binstub]'
|
||||
'(--bundle --no-bundle --skip-bundle)--no-bundle[Do not add Kamal to the Gemfile and create a bin/kamal binstub]'
|
||||
'(--bundle --no-bundle --skip-bundle)--skip-bundle[Skip add Kamal to the Gemfile and create a bin/kamal binstub]'
|
||||
)
|
||||
_arguments $init_flags && ret=0
|
||||
;;
|
||||
(lock)
|
||||
_kamal_lock && ret=0
|
||||
;;
|
||||
(proxy)
|
||||
_kamal_proxy && ret=0
|
||||
;;
|
||||
(prune)
|
||||
_kamal_prune && ret=0
|
||||
;;
|
||||
(redeploy)
|
||||
_arguments $_kamal_flags && ret=0
|
||||
;;
|
||||
(registry)
|
||||
_kamal_registry && ret=0
|
||||
;;
|
||||
(remove)
|
||||
local -a remove_flags
|
||||
remove_flags=(
|
||||
$_kamal_flags
|
||||
'(-y --confirmed --no-confirmed --skip-confirmed)'{-y,--confirmed}'[Proceed without confirmation question]'
|
||||
'(-y --confirmed --no-confirmed --skip-confirmed)--no-confirmed[Proceed without confirmation question]'
|
||||
'(-y --confirmed --no-confirmed --skip-confirmed)--skip-confirmed[Proceed without confirmation question]'
|
||||
)
|
||||
_arguments $remove_flags && ret=0
|
||||
;;
|
||||
(rollback)
|
||||
if (( CURRENT == 2 )); then
|
||||
_kamal_message "Enter the version to rollback to" && ret=0
|
||||
else
|
||||
_values $_kamal_flags && ret=0
|
||||
fi
|
||||
;;
|
||||
(secrets)
|
||||
_kamal_secrets && ret=0
|
||||
;;
|
||||
(server)
|
||||
_kamal_server && ret=0
|
||||
;;
|
||||
(setup)
|
||||
local -a setup_flags
|
||||
setup_flags=(
|
||||
$_kamal_flags
|
||||
'(-P --skip-push)'{-P,--skip-push}'[Skip image build and push]'
|
||||
)
|
||||
_arguments $setup_flags && ret=0
|
||||
;;
|
||||
(upgrade)
|
||||
local -a upgrade_flags
|
||||
upgrade_flags=(
|
||||
$_kamal_flags
|
||||
'(-y --confirmed --no-confirmed --skip-confirmed)'{-y,--confirmed}'[Proceed without confirmation question]'
|
||||
'(-y --confirmed --no-confirmed --skip-confirmed)--no-confirmed[Do not proceed without confirmation question]'
|
||||
'(-y --confirmed --no-confirmed --skip-confirmed)--skip-confirmed[Skip confirmation question]'
|
||||
'(--rolling --no-rolling --skip-rolling)--rolling[Upgrade one host at a time]'
|
||||
'(--rolling --no-rolling --skip-rolling)--no-rolling[Do not upgrade one host at a time]'
|
||||
'(--rolling --no-rolling --skip-rolling)--skip-rolling[Skip rolling upgrade]'
|
||||
)
|
||||
_arguments $upgrade_flags && ret=0
|
||||
;;
|
||||
(version)
|
||||
_arguments $_kamal_flags && ret=0
|
||||
esac
|
||||
;;
|
||||
esac
|
||||
|
||||
return ret
|
||||
}
|
||||
|
||||
_kamal_accessory() {
|
||||
local context state line
|
||||
typeset -A opt_args
|
||||
local ret=1
|
||||
|
||||
# Define accessory subcommands
|
||||
local -a accessory_subcommands
|
||||
accessory_subcommands=(
|
||||
"boot:Boot new accessory service on host (use NAME=all to boot all accessories)"
|
||||
"details:Show details about accessory on host (use NAME=all to show all accessories)"
|
||||
"exec:Execute a custom command on servers within the accessory container (use --help to show options)"
|
||||
"help:Describe subcommands or one specific subcommand"
|
||||
"logs:Show log lines from accessory on host (use --help to show options)"
|
||||
"reboot:Reboot existing accessory on host (stop container, remove container, start new container; use NAME=all to boot all accessories)"
|
||||
"remove:Remove accessory container, image and data directory from host (use NAME=all to remove all accessories)"
|
||||
"restart:Restart existing accessory container on host"
|
||||
"start:Start existing accessory container on host"
|
||||
"stop:Stop existing accessory container on host"
|
||||
"upgrade:Upgrade accessories from Kamal 1.x to 2.0 (restart them in 'kamal' network)"
|
||||
)
|
||||
|
||||
_arguments -C \
|
||||
'1: :->subcmd' \
|
||||
'*:: :->args' && ret=0
|
||||
|
||||
case $state in
|
||||
(subcmd)
|
||||
_describe -t accessory-commands "Kamal accessory commands" accessory_subcommands && ret=0
|
||||
;;
|
||||
(args)
|
||||
case $words[1] in
|
||||
(boot|details|exec|logs|reboot|remove|restart|start|stop)
|
||||
# These commands require a NAME parameter
|
||||
if (( CURRENT == 2 )); then
|
||||
# At the NAME position - we could add accessory name completion here
|
||||
# if we had a way to list available accessories
|
||||
_kamal_message "Specify an accessory name (or 'all' for all accessories)" && ret=0
|
||||
elif [[ "$words[1]" == "exec" && CURRENT == 3 ]]; then
|
||||
# For exec, the 3rd argument is a command
|
||||
_kamal_message "Enter a command to execute" && ret=0
|
||||
elif (( CURRENT > 2 )) && [[ "$words[1]" != "exec" || CURRENT > 3 ]]; then
|
||||
_values $_kamal_flags && ret=0
|
||||
fi
|
||||
;;
|
||||
(help)
|
||||
# Remove help itself from the list of commands
|
||||
accessory_subcommands=("${(@)accessory_subcommands:#help*}")
|
||||
_describe -t accessory-help-commands "Kamal accessory help commands" accessory_subcommands
|
||||
;;
|
||||
(upgrade)
|
||||
# For upgrade, show flags immediately
|
||||
_arguments $_kamal_flags && ret=0
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
esac
|
||||
|
||||
return ret
|
||||
}
|
||||
|
||||
_kamal_app() {
|
||||
local context state line
|
||||
typeset -A opt_args
|
||||
local ret=1
|
||||
|
||||
local -a app_subcommands
|
||||
app_subcommands=(
|
||||
"boot:Boot app on servers (or reboot app if already running)"
|
||||
"containers:Show app containers on servers"
|
||||
"details:Show details about app containers"
|
||||
"exec:Execute a custom command on servers within the app container (use --help to show options)"
|
||||
"help:Describe subcommands or one specific subcommand"
|
||||
"images:Show app images on servers"
|
||||
"logs:Show log lines from app on servers (use --help to show options)"
|
||||
"remove:Remove app containers and images from servers"
|
||||
"stale_containers:Detect app stale containers"
|
||||
"start:Start existing app container on servers"
|
||||
"stop:Stop app container on servers"
|
||||
"version:Show app version currently running on servers"
|
||||
)
|
||||
|
||||
_arguments -C \
|
||||
'1: :->subcmd' \
|
||||
'*:: :->args' && ret=0
|
||||
|
||||
case $state in
|
||||
(subcmd)
|
||||
_describe -t app-commands "Kamal app commands" app_subcommands && ret=0
|
||||
;;
|
||||
(args)
|
||||
case $words[1] in
|
||||
(boot|containers|details|images|logs|remove|stale_containers|start|stop)
|
||||
_arguments $_kamal_flags && ret=0
|
||||
;;
|
||||
(exec)
|
||||
# For exec, the next argument is a command
|
||||
if (( CURRENT == 2 )); then
|
||||
_kamal_message "Enter a command to execute" && ret=0
|
||||
else
|
||||
_values $_kamal_flags && ret=0
|
||||
fi
|
||||
;;
|
||||
(help)
|
||||
# Remove help itself from the list of commands
|
||||
app_subcommands=("${(@)app_subcommands:#help*}")
|
||||
_describe -t app-help-commands "Kamal app help commands" app_subcommands
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
esac
|
||||
|
||||
return ret
|
||||
}
|
||||
|
||||
_kamal_build() {
|
||||
local context state line
|
||||
typeset -A opt_args
|
||||
local ret=1
|
||||
|
||||
local -a build_subcommands
|
||||
build_subcommands=(
|
||||
"create:Create a build setup"
|
||||
"deliver:Build app and push app image to registry then pull image on servers"
|
||||
"details:Show build setup"
|
||||
"dev:Build using the working directory, tag it as dirty, and push to local image store."
|
||||
"help:Describe subcommands or one specific subcommand"
|
||||
"pull:Pull app image from registry onto servers"
|
||||
"push:Build and push app image to registry"
|
||||
"remove:Remove build setup"
|
||||
)
|
||||
|
||||
_arguments -C \
|
||||
'1: :->subcmd' \
|
||||
'*:: :->args' && ret=0
|
||||
|
||||
case $state in
|
||||
(subcmd)
|
||||
_describe -t build-commands "Kamal build commands" build_subcommands && ret=0
|
||||
;;
|
||||
(args)
|
||||
case $words[1] in
|
||||
(create|deliver|details|dev|pull|push|remove)
|
||||
_arguments $_kamal_flags && ret=0
|
||||
;;
|
||||
(help)
|
||||
# Remove help itself from the list of commands
|
||||
build_subcommands=("${(@)build_subcommands:#help*}")
|
||||
_describe -t build-help-commands "Kamal build help commands" build_subcommands
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
esac
|
||||
|
||||
return ret
|
||||
}
|
||||
|
||||
_kamal_help() {
|
||||
local ret=1
|
||||
|
||||
# Make sure kamal_commands is initialized properly
|
||||
# if (( ${#kamal_commands} == 0 )); then
|
||||
# _kamal_commands >/dev/null
|
||||
# fi
|
||||
|
||||
# If we already have a command after "help", return without suggestions
|
||||
if (( CURRENT > 2 )); then
|
||||
ret=0
|
||||
else
|
||||
local -a help_commands
|
||||
# Filter out help from the list of commands
|
||||
help_commands=("${(@)_kamal_commands:#help}")
|
||||
|
||||
_values 'Kamal help' $help_commands && ret=0
|
||||
fi
|
||||
|
||||
return ret
|
||||
}
|
||||
|
||||
_kamal_lock() {
|
||||
local context state line
|
||||
typeset -A opt_args
|
||||
local ret=1
|
||||
|
||||
local -a lock_subcommands
|
||||
lock_subcommands=(
|
||||
"acquire:Acquire the deploy lock"
|
||||
"help:Describe subcommands or one specific subcommand"
|
||||
"release:Release the deploy lock"
|
||||
"status:Report lock status"
|
||||
)
|
||||
|
||||
_arguments -C \
|
||||
'1: :->subcmd' \
|
||||
'*:: :->args' && ret=0
|
||||
|
||||
case $state in
|
||||
(subcmd)
|
||||
_describe -t lock-commands "Kamal lock commands" lock_subcommands && ret=0
|
||||
;;
|
||||
(args)
|
||||
case $words[1] in
|
||||
(acquire)
|
||||
local -a acquire_flags
|
||||
acquire_flags=(
|
||||
$_kamal_flags
|
||||
'(-m --message)'{-m,--message=}'[A lock message]:message:' # Required flag
|
||||
)
|
||||
_arguments $acquire_flags && ret=0
|
||||
;;
|
||||
(release|status)
|
||||
_arguments $_kamal_flags && ret=0
|
||||
;;
|
||||
(help)
|
||||
# Remove help itself from the list of commands
|
||||
lock_subcommands=("${(@)lock_subcommands:#help*}")
|
||||
_describe -t lock-help-commands "Kamal lock help commands" lock_subcommands
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
esac
|
||||
|
||||
return ret
|
||||
}
|
||||
|
||||
_kamal_proxy() {
|
||||
local context state line
|
||||
typeset -A opt_args
|
||||
local ret=1
|
||||
|
||||
local -a proxy_subcommands
|
||||
proxy_subcommands=(
|
||||
"boot:Boot proxy on servers"
|
||||
"boot_config:Manage kamal-proxy boot configuration"
|
||||
"details:Show details about proxy container from servers"
|
||||
"help:Describe subcommands or one specific subcommand"
|
||||
"logs:Show log lines from proxy on servers"
|
||||
"reboot:Reboot proxy on servers (stop container, remove container, start new container)"
|
||||
"remove:Remove proxy container and image from servers"
|
||||
"restart:Restart existing proxy container on servers"
|
||||
"start:Start existing proxy container on servers"
|
||||
"stop:Stop existing proxy container on servers"
|
||||
)
|
||||
|
||||
_arguments -C \
|
||||
'1: :->subcmd' \
|
||||
'*:: :->args' && ret=0
|
||||
|
||||
case $state in
|
||||
(subcmd)
|
||||
_describe -t proxy-commands "Kamal proxy commands" proxy_subcommands && ret=0
|
||||
;;
|
||||
(args)
|
||||
case $words[1] in
|
||||
(boot|details|logs|reboot|remove|restart|start|stop)
|
||||
_arguments $_kamal_flags && ret=0
|
||||
;;
|
||||
(boot_config)
|
||||
if (( CURRENT == 2 )); then
|
||||
local -a boot_config_commands=(
|
||||
"set:Set boot configuration"
|
||||
"get:Get boot configuration"
|
||||
"reset:Reset boot configuration"
|
||||
)
|
||||
_describe -t boot-config-commands "Boot config commands" boot_config_commands && ret=0
|
||||
else
|
||||
_values $_kamal_flags && ret=0
|
||||
fi
|
||||
;;
|
||||
(help)
|
||||
# Remove help itself from the list of commands
|
||||
proxy_subcommands=("${(@)proxy_subcommands:#help*}")
|
||||
_describe -t proxy-help-commands "Kamal proxy help commands" proxy_subcommands
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
esac
|
||||
|
||||
return ret
|
||||
}
|
||||
|
||||
_kamal_prune() {
|
||||
local context state line
|
||||
typeset -A opt_args
|
||||
local ret=1
|
||||
|
||||
local -a prune_subcommands
|
||||
prune_subcommands=(
|
||||
"all:Prune unused images and stopped containers"
|
||||
"containers:Prune all stopped containers, except the last n (default 5)"
|
||||
"help:Describe subcommands or one specific subcommand"
|
||||
"images:Prune unused images"
|
||||
)
|
||||
|
||||
_arguments -C \
|
||||
'1: :->subcmd' \
|
||||
'*:: :->args' && ret=0
|
||||
|
||||
case $state in
|
||||
(subcmd)
|
||||
_describe -t prune-commands "Kamal prune commands" prune_subcommands && ret=0
|
||||
;;
|
||||
(args)
|
||||
case $words[1] in
|
||||
(all|containers|images)
|
||||
_arguments $_kamal_flags && ret=0
|
||||
;;
|
||||
(help)
|
||||
# Remove help itself from the list of commands
|
||||
prune_subcommands=("${(@)prune_subcommands:#help*}")
|
||||
_describe -t prune-help-commands "Kamal prune help commands" prune_subcommands
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
esac
|
||||
|
||||
return ret
|
||||
}
|
||||
|
||||
_kamal_registry() {
|
||||
local context state line
|
||||
typeset -A opt_args
|
||||
local ret=1
|
||||
|
||||
local -a registry_subcommands
|
||||
registry_subcommands=(
|
||||
"help:Describe subcommands or one specific subcommand"
|
||||
"login:Log in to registry locally and remotely"
|
||||
"logout:Log out of registry locally and remotely"
|
||||
)
|
||||
|
||||
_arguments -C \
|
||||
'1: :->subcmd' \
|
||||
'*:: :->args' && ret=0
|
||||
|
||||
case $state in
|
||||
(subcmd)
|
||||
_describe -t registry-commands "Kamal registry commands" registry_subcommands && ret=0
|
||||
;;
|
||||
(args)
|
||||
case $words[1] in
|
||||
(help)
|
||||
# Remove help itself from the list of commands
|
||||
registry_subcommands=("${(@)registry_subcommands:#help*}")
|
||||
_describe -t registry-help-commands "Kamal registry help commands" registry_subcommands
|
||||
;;
|
||||
(login|logout)
|
||||
_arguments $_kamal_flags && ret=0
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
esac
|
||||
|
||||
return ret
|
||||
}
|
||||
|
||||
_kamal_secrets() {
|
||||
local context state line
|
||||
typeset -A opt_args
|
||||
local ret=1
|
||||
|
||||
local -a secrets_subcommands
|
||||
secrets_subcommands=(
|
||||
"extract:Extract a single secret from the results of a fetch call"
|
||||
"fetch:Fetch secrets from a vault"
|
||||
"help:Describe subcommands or one specific subcommand"
|
||||
"print:Print the secrets (for debugging)"
|
||||
)
|
||||
|
||||
_arguments -C \
|
||||
'1: :->subcmd' \
|
||||
'*:: :->args' && ret=0
|
||||
|
||||
case $state in
|
||||
(subcmd)
|
||||
_describe -t secrets-commands "Kamal secrets commands" secrets_subcommands && ret=0
|
||||
;;
|
||||
(args)
|
||||
case $words[1] in
|
||||
(fetch)
|
||||
local -a fetch_flags
|
||||
fetch_flags=(
|
||||
$_kamal_flags
|
||||
'(-a --adapter)'{-a,--adapter=}'[Secret storage adapter]:adapter:(aws-parameter-store)'
|
||||
)
|
||||
_arguments $fetch_flags && ret=0
|
||||
;;
|
||||
(extract|print)
|
||||
_arguments $_kamal_flags && ret=0
|
||||
;;
|
||||
(help)
|
||||
# Remove help itself from the list of commands
|
||||
secrets_subcommands=("${(@)secrets_subcommands:#help*}")
|
||||
_describe -t secrets-help-commands "Kamal secrets help commands" secrets_subcommands
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
esac
|
||||
|
||||
return ret
|
||||
}
|
||||
|
||||
_kamal_server() {
|
||||
local context state line
|
||||
typeset -A opt_args
|
||||
local ret=1
|
||||
|
||||
local -a server_subcommands
|
||||
server_subcommands=(
|
||||
"bootstrap:Set up Docker to run Kamal apps"
|
||||
"exec:Run a custom command on the server (use --help to show options)"
|
||||
"help:Describe subcommands or one specific subcommand"
|
||||
)
|
||||
|
||||
local -a server_flags
|
||||
server_flags=(
|
||||
$_kamal_flags
|
||||
'(-i --interactive --no-interactive --skip-interactive)'{-i,--interactive}'[Run the command interactively]'
|
||||
'(-i --interactive --no-interactive --skip-interactive)--no-interactive[Do not run the command interactively]'
|
||||
'(-i --interactive --no-interactive --skip-interactive)--skip-interactive[Skip interactive mode]'
|
||||
)
|
||||
|
||||
_arguments -C \
|
||||
'1: :->subcmd' \
|
||||
'*:: :->args' && ret=0
|
||||
|
||||
case $state in
|
||||
(subcmd)
|
||||
_describe -t server-commands "Kamal server commands" server_subcommands && ret=0
|
||||
;;
|
||||
(args)
|
||||
case $words[1] in
|
||||
(bootstrap)
|
||||
_arguments $server_flags && ret=0
|
||||
;;
|
||||
(exec)
|
||||
if (( CURRENT == 2 )); then
|
||||
# For exec, the next argument is a command
|
||||
_kamal_message "Enter a command to execute" && ret=0
|
||||
else
|
||||
_values $server_flags && ret=0
|
||||
fi
|
||||
;;
|
||||
(help)
|
||||
# Remove help itself from the list of commands
|
||||
server_subcommands=("${(@)server_subcommands:#help*}")
|
||||
_describe -t server-help-commands "Kamal server help commands" server_subcommands
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
esac
|
||||
|
||||
return ret
|
||||
}
|
||||
|
||||
_kamal "$@"
|
||||
25
plugins/kamal/kamal.plugin.zsh
Normal file
25
plugins/kamal/kamal.plugin.zsh
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
# Find kamal binary (local ./bin/kamal or global)
|
||||
function _kamal_command () {
|
||||
if [ -x "./bin/kamal" ]; then
|
||||
./bin/kamal "$@"
|
||||
else
|
||||
command kamal "$@"
|
||||
fi
|
||||
}
|
||||
|
||||
function which-kamal() {
|
||||
if [ -x "./bin/kamal" ]; then
|
||||
echo "Using local ./bin/kamal"
|
||||
else
|
||||
echo "Using global $(command -v kamal)"
|
||||
fi
|
||||
}
|
||||
|
||||
# Use `_kamal_command`` function for `kamal` command
|
||||
alias kamal='_kamal_command'
|
||||
|
||||
# Aliases
|
||||
alias kad='kamal deploy'
|
||||
|
||||
# Hook up completion
|
||||
compdef _kamal_command=kamal
|
||||
|
|
@ -19,8 +19,15 @@ function {
|
|||
# load additional options
|
||||
zstyle -a :omz:plugins:keychain options options
|
||||
|
||||
# start keychain...
|
||||
keychain ${^options:-} --agents ${agents:-gpg} ${^identities} --host $SHORT_HOST
|
||||
# Check keychain version to decide whether to use --agents
|
||||
local version_string=$(keychain --version 2>&1 | head -n 2 | tail -n 1 | cut -d ' ' -f 4)
|
||||
# start keychain, only use --agents for versions below 2.9.0
|
||||
autoload -Uz is-at-least
|
||||
if is-at-least 2.9 "$version_string"; then
|
||||
keychain ${^options:-} ${^identities} --host $SHORT_HOST
|
||||
else
|
||||
keychain ${^options:-} --agents ${agents:-gpg} ${^identities} --host $SHORT_HOST
|
||||
fi
|
||||
|
||||
# Get the filenames to store/lookup the environment from
|
||||
_keychain_env_sh="$HOME/.keychain/$SHORT_HOST-sh"
|
||||
|
|
|
|||
|
|
@ -11,122 +11,126 @@ plugins=(... kubectl)
|
|||
|
||||
## Aliases
|
||||
|
||||
| Alias | Command | Description |
|
||||
|:--------|:------------------------------------|:-------------------------------------------------------------------------------------------------|
|
||||
| k | `kubectl` | The kubectl command |
|
||||
| kca | `kubectl --all-namespaces` | The kubectl command targeting all namespaces |
|
||||
| kaf | `kubectl apply -f` | Apply a YML file |
|
||||
| keti | `kubectl exec -ti` | Drop into an interactive terminal on a container |
|
||||
| | | **Manage configuration quickly to switch contexts between local, dev and staging** |
|
||||
| kcuc | `kubectl config use-context` | Set the current-context in a kubeconfig file |
|
||||
| kcsc | `kubectl config set-context` | Set a context entry in kubeconfig |
|
||||
| kcdc | `kubectl config delete-context` | Delete the specified context from the kubeconfig |
|
||||
| kccc | `kubectl config current-context` | Display the current-context |
|
||||
| kcgc | `kubectl config get-contexts` | List of contexts available |
|
||||
| | | **General aliases** |
|
||||
| kdel | `kubectl delete` | Delete resources by filenames, stdin, resources and names, or by resources and label selector |
|
||||
| kdelf | `kubectl delete -f` | Delete a pod using the type and name specified in -f argument |
|
||||
| | | **Pod management** |
|
||||
| kgp | `kubectl get pods` | List all pods in ps output format |
|
||||
| kgpw | `kgp --watch` | After listing/getting the requested object, watch for changes |
|
||||
| kgpwide | `kgp -o wide` | Output in plain-text format with any additional information. For pods, the node name is included |
|
||||
| kep | `kubectl edit pods` | Edit pods from the default editor |
|
||||
| kdp | `kubectl describe pods` | Describe all pods |
|
||||
| kdelp | `kubectl delete pods` | Delete all pods matching passed arguments |
|
||||
| kgpl | `kgp -l` | Get pods by label. Example: `kgpl "app=myapp" -n myns` |
|
||||
| kgpn | `kgp -n` | Get pods by namespace. Example: `kgpn kube-system` |
|
||||
| | | **Service management** |
|
||||
| kgs | `kubectl get svc` | List all services in ps output format |
|
||||
| kgsw | `kgs --watch` | After listing all services, watch for changes |
|
||||
| kgswide | `kgs -o wide` | After listing all services, output in plain-text format with any additional information |
|
||||
| kes | `kubectl edit svc` | Edit services(svc) from the default editor |
|
||||
| kds | `kubectl describe svc` | Describe all services in detail |
|
||||
| kdels | `kubectl delete svc` | Delete all services matching passed argument |
|
||||
| | | **Ingress management** |
|
||||
| kgi | `kubectl get ingress` | List ingress resources in ps output format |
|
||||
| kei | `kubectl edit ingress` | Edit ingress resource from the default editor |
|
||||
| kdi | `kubectl describe ingress` | Describe ingress resource in detail |
|
||||
| kdeli | `kubectl delete ingress` | Delete ingress resources matching passed argument |
|
||||
| | | **Namespace management** |
|
||||
| kgns | `kubectl get namespaces` | List the current namespaces in a cluster |
|
||||
| kcn | `kubectl config set-context --current --namespace` | Change current namespace |
|
||||
| kens | `kubectl edit namespace` | Edit namespace resource from the default editor |
|
||||
| kdns | `kubectl describe namespace` | Describe namespace resource in detail |
|
||||
| kdelns | `kubectl delete namespace` | Delete the namespace. WARNING! This deletes everything in the namespace |
|
||||
| | | **ConfigMap management** |
|
||||
| kgcm | `kubectl get configmaps` | List the configmaps in ps output format |
|
||||
| kecm | `kubectl edit configmap` | Edit configmap resource from the default editor |
|
||||
| kdcm | `kubectl describe configmap` | Describe configmap resource in detail |
|
||||
| kdelcm | `kubectl delete configmap` | Delete the configmap |
|
||||
| | | **Secret management** |
|
||||
| kgsec | `kubectl get secret` | Get secret for decoding |
|
||||
| kdsec | `kubectl describe secret` | Describe secret resource in detail |
|
||||
| kdelsec | `kubectl delete secret` | Delete the secret |
|
||||
| | | **Deployment management** |
|
||||
| kgd | `kubectl get deployment` | Get the deployment |
|
||||
| kgdw | `kgd --watch` | After getting the deployment, watch for changes |
|
||||
| kgdwide | `kgd -o wide` | After getting the deployment, output in plain-text format with any additional information |
|
||||
| ked | `kubectl edit deployment` | Edit deployment resource from the default editor |
|
||||
| kdd | `kubectl describe deployment` | Describe deployment resource in detail |
|
||||
| kdeld | `kubectl delete deployment` | Delete the deployment |
|
||||
| ksd | `kubectl scale deployment` | Scale a deployment |
|
||||
| krsd | `kubectl rollout status deployment` | Check the rollout status of a deployment |
|
||||
| kres | `kubectl set env $@ REFRESHED_AT=...` | Recreate all pods in deployment with zero-downtime |
|
||||
| | | **Rollout management** |
|
||||
| kgrs | `kubectl get replicaset` | List all ReplicaSets `rs` created by the deployment |
|
||||
| kdrs | `kubectl describe replicaset` | Describe ReplicaSet in detail |
|
||||
| kers | `kubectl edit replicaset` | Edit ReplicaSet from the default editor |
|
||||
| krh | `kubectl rollout history` | Check the revisions of this deployment |
|
||||
| kru | `kubectl rollout undo` | Rollback to the previous revision |
|
||||
| | | **Port forwarding** |
|
||||
| kpf | `kubectl port-forward` | Forward one or more local ports to a pod |
|
||||
| | | **Tools for accessing all information** |
|
||||
| kga | `kubectl get all` | List all resources in ps format |
|
||||
| kgaa | `kubectl get all --all-namespaces` | List the requested object(s) across all namespaces |
|
||||
| | | **Logs** |
|
||||
| kl | `kubectl logs` | Print the logs for a container or resource |
|
||||
| klf | `kubectl logs -f` | Stream the logs for a container or resource (follow) |
|
||||
| | | **File copy** |
|
||||
| kcp | `kubectl cp` | Copy files and directories to and from containers |
|
||||
| | | **Node management** |
|
||||
| kgno | `kubectl get nodes` | List the nodes in ps output format |
|
||||
| keno | `kubectl edit node` | Edit nodes resource from the default editor |
|
||||
| kdno | `kubectl describe node` | Describe node resource in detail |
|
||||
| kdelno | `kubectl delete node` | Delete the node |
|
||||
| | | **Persistent Volume Claim management** |
|
||||
| kgpvc | `kubectl get pvc` | List all PVCs |
|
||||
| kgpvcw | `kgpvc --watch` | After listing/getting the requested object, watch for changes |
|
||||
| kepvc | `kubectl edit pvc` | Edit pvcs from the default editor |
|
||||
| kdpvc | `kubectl describe pvc` | Describe all pvcs |
|
||||
| kdelpvc | `kubectl delete pvc` | Delete all pvcs matching passed arguments |
|
||||
| | | **StatefulSets management** |
|
||||
| kgss | `kubectl get statefulset` | List the statefulsets in ps format |
|
||||
| kgssw | `kgss --watch` | After getting the list of statefulsets, watch for changes |
|
||||
| kgsswide| `kgss -o wide` | After getting the statefulsets, output in plain-text format with any additional information |
|
||||
| kess | `kubectl edit statefulset` | Edit statefulset resource from the default editor |
|
||||
| kdss | `kubectl describe statefulset` | Describe statefulset resource in detail |
|
||||
| kdelss | `kubectl delete statefulset` | Delete the statefulset |
|
||||
| ksss | `kubectl scale statefulset` | Scale a statefulset |
|
||||
| krsss | `kubectl rollout status statefulset`| Check the rollout status of a deployment |
|
||||
| | | **Service Accounts management** |
|
||||
| kdsa | `kubectl describe sa` | Describe a service account in details |
|
||||
| kdelsa | `kubectl delete sa` | Delete the service account |
|
||||
| | | **DaemonSet management** |
|
||||
| kgds | `kubectl get daemonset` | List all DaemonSets in ps output format |
|
||||
| kgdsw | `kgds --watch` | After listing all DaemonSets, watch for changes |
|
||||
| keds | `kubectl edit daemonset` | Edit DaemonSets from the default editor |
|
||||
| kdds | `kubectl describe daemonset` | Describe all DaemonSets in detail |
|
||||
| kdelds | `kubectl delete daemonset` | Delete all DaemonSets matching passed argument |
|
||||
| | | **CronJob management** |
|
||||
| kgcj | `kubectl get cronjob` | List all CronJobs in ps output format |
|
||||
| kecj | `kubectl edit cronjob` | Edit CronJob from the default editor |
|
||||
| kdcj | `kubectl describe cronjob` | Describe a CronJob in details |
|
||||
| kdelcj | `kubectl delete cronjob` | Delete the CronJob |
|
||||
| | | **Job management** |
|
||||
| kgj | `kubectl get job` | List all Job in ps output format |
|
||||
| kej | `kubectl edit job` | Edit a Job in details |
|
||||
| kdj | `kubectl describe job` | Describe the Job |
|
||||
| kdelj | `kubectl delete job` | Delete the Job |
|
||||
| Alias | Command | Description |
|
||||
| :------- | :------------------------------------------------------ | :----------------------------------------------------------------------------------------------- |
|
||||
| k | `kubectl` | The kubectl command |
|
||||
| kca | `kubectl --all-namespaces` | The kubectl command targeting all namespaces |
|
||||
| kaf | `kubectl apply -f` | Apply a YML file |
|
||||
| keti | `kubectl exec -ti` | Drop into an interactive terminal on a container |
|
||||
| | | **Manage configuration quickly to switch contexts between local, dev and staging** |
|
||||
| kcuc | `kubectl config use-context` | Set the current-context in a kubeconfig file |
|
||||
| kcsc | `kubectl config set-context` | Set a context entry in kubeconfig |
|
||||
| kcdc | `kubectl config delete-context` | Delete the specified context from the kubeconfig |
|
||||
| kccc | `kubectl config current-context` | Display the current-context |
|
||||
| kcgc | `kubectl config get-contexts` | List of contexts available |
|
||||
| | | **General aliases** |
|
||||
| kdel | `kubectl delete` | Delete resources by filenames, stdin, resources and names, or by resources and label selector |
|
||||
| kdelf | `kubectl delete -f` | Delete a pod using the type and name specified in -f argument |
|
||||
| kge | `kubectl get events --sort-by=".lastTimestamp"` | Get events (sorted by timestamp) |
|
||||
| kgew | `kubectl get events --watch --sort-by=".lastTimestamp"` | Get events and watch as they occur (sorted by timestamp) |
|
||||
| | | **Pod management** |
|
||||
| kgp | `kubectl get pods` | List all pods in ps output format |
|
||||
| kgpl | `kgp -l` | Get pods by label. Example: `kgpl "app=myapp" -n myns` |
|
||||
| kgpn | `kgp -n` | Get pods by namespace. Example: `kgpn kube-system` |
|
||||
| kgpsl | `kubectl get pods --show-labels` | List all pods in ps output format with labels |
|
||||
| kgpw | `kgp --watch` | After listing/getting the requested object, watch for changes |
|
||||
| kgpwide | `kgp -o wide` | Output in plain-text format with any additional information. For pods, the node name is included |
|
||||
| kep | `kubectl edit pods` | Edit pods from the default editor |
|
||||
| kdp | `kubectl describe pods` | Describe all pods |
|
||||
| kdelp | `kubectl delete pods` | Delete all pods matching passed arguments |
|
||||
| | | **Service management** |
|
||||
| kgs | `kubectl get svc` | List all services in ps output format |
|
||||
| kgsw | `kgs --watch` | After listing all services, watch for changes |
|
||||
| kgswide | `kgs -o wide` | After listing all services, output in plain-text format with any additional information |
|
||||
| kes | `kubectl edit svc` | Edit services(svc) from the default editor |
|
||||
| kds | `kubectl describe svc` | Describe all services in detail |
|
||||
| kdels | `kubectl delete svc` | Delete all services matching passed argument |
|
||||
| | | **Ingress management** |
|
||||
| kgi | `kubectl get ingress` | List ingress resources in ps output format |
|
||||
| kei | `kubectl edit ingress` | Edit ingress resource from the default editor |
|
||||
| kdi | `kubectl describe ingress` | Describe ingress resource in detail |
|
||||
| kdeli | `kubectl delete ingress` | Delete ingress resources matching passed argument |
|
||||
| | | **Namespace management** |
|
||||
| kgns | `kubectl get namespaces` | List the current namespaces in a cluster |
|
||||
| kcn | `kubectl config set-context --current --namespace` | Change current namespace |
|
||||
| kens | `kubectl edit namespace` | Edit namespace resource from the default editor |
|
||||
| kdns | `kubectl describe namespace` | Describe namespace resource in detail |
|
||||
| kdelns | `kubectl delete namespace` | Delete the namespace. WARNING! This deletes everything in the namespace |
|
||||
| | | **ConfigMap management** |
|
||||
| kgcm | `kubectl get configmaps` | List the configmaps in ps output format |
|
||||
| kecm | `kubectl edit configmap` | Edit configmap resource from the default editor |
|
||||
| kdcm | `kubectl describe configmap` | Describe configmap resource in detail |
|
||||
| kdelcm | `kubectl delete configmap` | Delete the configmap |
|
||||
| | | **Secret management** |
|
||||
| kgsec | `kubectl get secret` | Get secret for decoding |
|
||||
| kdsec | `kubectl describe secret` | Describe secret resource in detail |
|
||||
| kdelsec | `kubectl delete secret` | Delete the secret |
|
||||
| | | **Deployment management** |
|
||||
| kgd | `kubectl get deployment` | Get the deployment |
|
||||
| kgdw | `kgd --watch` | After getting the deployment, watch for changes |
|
||||
| kgdwide | `kgd -o wide` | After getting the deployment, output in plain-text format with any additional information |
|
||||
| ked | `kubectl edit deployment` | Edit deployment resource from the default editor |
|
||||
| kdd | `kubectl describe deployment` | Describe deployment resource in detail |
|
||||
| kdeld | `kubectl delete deployment` | Delete the deployment |
|
||||
| ksd | `kubectl scale deployment` | Scale a deployment |
|
||||
| krsd | `kubectl rollout status deployment` | Check the rollout status of a deployment |
|
||||
| kres | `kubectl set env $@ REFRESHED_AT=...` | Recreate all pods in deployment with zero-downtime |
|
||||
| | | **Rollout management** |
|
||||
| kgrs | `kubectl get replicaset` | List all ReplicaSets `rs` created by the deployment |
|
||||
| kdrs | `kubectl describe replicaset` | Describe ReplicaSet in detail |
|
||||
| kers | `kubectl edit replicaset` | Edit ReplicaSet from the default editor |
|
||||
| krh | `kubectl rollout history` | Check the revisions of this deployment |
|
||||
| kru | `kubectl rollout undo` | Rollback to the previous revision |
|
||||
| | | **Port forwarding** |
|
||||
| kpf | `kubectl port-forward` | Forward one or more local ports to a pod |
|
||||
| | | **Tools for accessing all information** |
|
||||
| kga | `kubectl get all` | List all resources in ps format |
|
||||
| kgaa | `kubectl get all --all-namespaces` | List the requested object(s) across all namespaces |
|
||||
| | | **Logs** |
|
||||
| kl | `kubectl logs` | Print the logs for a container or resource |
|
||||
| klf | `kubectl logs -f` | Stream the logs for a container or resource (follow) |
|
||||
| | | **File copy** |
|
||||
| kcp | `kubectl cp` | Copy files and directories to and from containers |
|
||||
| | | **Node management** |
|
||||
| kgno | `kubectl get nodes` | List the nodes in ps output format |
|
||||
| kgnosl | `kubectl get nodes --show-labels` | List the nodes in ps output format with labels |
|
||||
| keno | `kubectl edit node` | Edit nodes resource from the default editor |
|
||||
| kdno | `kubectl describe node` | Describe node resource in detail |
|
||||
| kdelno | `kubectl delete node` | Delete the node |
|
||||
| | | **Persistent Volume Claim management** |
|
||||
| kgpvc | `kubectl get pvc` | List all PVCs |
|
||||
| kgpvcw | `kgpvc --watch` | After listing/getting the requested object, watch for changes |
|
||||
| kepvc | `kubectl edit pvc` | Edit pvcs from the default editor |
|
||||
| kdpvc | `kubectl describe pvc` | Describe all pvcs |
|
||||
| kdelpvc | `kubectl delete pvc` | Delete all pvcs matching passed arguments |
|
||||
| | | **StatefulSets management** |
|
||||
| kgss | `kubectl get statefulset` | List the statefulsets in ps format |
|
||||
| kgssw | `kgss --watch` | After getting the list of statefulsets, watch for changes |
|
||||
| kgsswide | `kgss -o wide` | After getting the statefulsets, output in plain-text format with any additional information |
|
||||
| kess | `kubectl edit statefulset` | Edit statefulset resource from the default editor |
|
||||
| kdss | `kubectl describe statefulset` | Describe statefulset resource in detail |
|
||||
| kdelss | `kubectl delete statefulset` | Delete the statefulset |
|
||||
| ksss | `kubectl scale statefulset` | Scale a statefulset |
|
||||
| krsss | `kubectl rollout status statefulset` | Check the rollout status of a deployment |
|
||||
| | | **Service Accounts management** |
|
||||
| kdsa | `kubectl describe sa` | Describe a service account in details |
|
||||
| kdelsa | `kubectl delete sa` | Delete the service account |
|
||||
| | | **DaemonSet management** |
|
||||
| kgds | `kubectl get daemonset` | List all DaemonSets in ps output format |
|
||||
| kgdsw | `kgds --watch` | After listing all DaemonSets, watch for changes |
|
||||
| keds | `kubectl edit daemonset` | Edit DaemonSets from the default editor |
|
||||
| kdds | `kubectl describe daemonset` | Describe all DaemonSets in detail |
|
||||
| kdelds | `kubectl delete daemonset` | Delete all DaemonSets matching passed argument |
|
||||
| | | **CronJob management** |
|
||||
| kgcj | `kubectl get cronjob` | List all CronJobs in ps output format |
|
||||
| kecj | `kubectl edit cronjob` | Edit CronJob from the default editor |
|
||||
| kdcj | `kubectl describe cronjob` | Describe a CronJob in details |
|
||||
| kdelcj | `kubectl delete cronjob` | Delete the CronJob |
|
||||
| | | **Job management** |
|
||||
| kgj | `kubectl get job` | List all Job in ps output format |
|
||||
| kej | `kubectl edit job` | Edit a Job in details |
|
||||
| kdj | `kubectl describe job` | Describe the Job |
|
||||
| kdelj | `kubectl delete job` | Delete the Job |
|
||||
|
||||
## Wrappers
|
||||
|
||||
|
|
|
|||
|
|
@ -36,9 +36,14 @@ alias kcgc='kubectl config get-contexts'
|
|||
# General aliases
|
||||
alias kdel='kubectl delete'
|
||||
alias kdelf='kubectl delete -f'
|
||||
alias kge='kubectl get events --sort-by=".lastTimestamp"'
|
||||
alias kgew='kubectl get events --sort-by=".lastTimestamp" --watch'
|
||||
|
||||
# Pod management.
|
||||
alias kgp='kubectl get pods'
|
||||
alias kgpl='kgp -l'
|
||||
alias kgpn='kgp -n'
|
||||
alias kgpsl='kubectl get pods --show-labels'
|
||||
alias kgpa='kubectl get pods --all-namespaces'
|
||||
alias kgpw='kgp --watch'
|
||||
alias kgpwide='kgp -o wide'
|
||||
|
|
@ -48,12 +53,6 @@ alias kdelp='kubectl delete pods'
|
|||
alias kgpall='kubectl get pods --all-namespaces -o wide'
|
||||
alias kclearevicted="kubectl get pods --all-namespaces -o json | jq '.items[] | select(.status.reason!=null) | select(.status.reason | contains(\"Evicted\")) | \"kubectl delete pods \(.metadata.name) -n \(.metadata.namespace)\"' | xargs -n 1 bash -c"
|
||||
|
||||
# get pod by label: kgpl "app=myapp" -n myns
|
||||
alias kgpl='kgp -l'
|
||||
|
||||
# get pod by namespace: kgpn kube-system"
|
||||
alias kgpn='kgp -n'
|
||||
|
||||
# Service management.
|
||||
alias kgs='kubectl get svc'
|
||||
alias kgsa='kubectl get svc --all-namespaces'
|
||||
|
|
@ -145,6 +144,7 @@ alias kcp='kubectl cp'
|
|||
|
||||
# Node Management
|
||||
alias kgno='kubectl get nodes'
|
||||
alias kgnosl='kubectl get nodes --show-labels'
|
||||
alias keno='kubectl edit node'
|
||||
alias kdno='kubectl describe node'
|
||||
alias kdelno='kubectl delete node'
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ plugins=(... laravel)
|
|||
| `pamfs` | `php artisan migrate:fresh --seed` |
|
||||
| `pamr` | `php artisan migrate:rollback` |
|
||||
| `pads` | `php artisan db:seed` |
|
||||
| `padw` | `php artisan db:wipe` |
|
||||
|
||||
## Makers
|
||||
|
||||
|
|
@ -49,6 +50,7 @@ plugins=(... laravel)
|
|||
| `pacoc` | `php artisan config:clear` |
|
||||
| `pavic` | `php artisan view:clear` |
|
||||
| `paroc` | `php artisan route:clear` |
|
||||
| `paopc` | `php artisan optimize:clear` |
|
||||
|
||||
## Queues
|
||||
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ alias pamf='php artisan migrate:fresh'
|
|||
alias pamfs='php artisan migrate:fresh --seed'
|
||||
alias pamr='php artisan migrate:rollback'
|
||||
alias pads='php artisan db:seed'
|
||||
alias padw='php artisan db:wipe'
|
||||
|
||||
# Makers
|
||||
alias pamm='php artisan make:model'
|
||||
|
|
@ -36,6 +37,7 @@ alias pacac='php artisan cache:clear'
|
|||
alias pacoc='php artisan config:clear'
|
||||
alias pavic='php artisan view:clear'
|
||||
alias paroc='php artisan route:clear'
|
||||
alias paopc='php artisan optimize:clear'
|
||||
|
||||
# queues
|
||||
alias paqf='php artisan queue:failed'
|
||||
|
|
|
|||
|
|
@ -9,20 +9,23 @@ chpwd_last_working_dir() {
|
|||
[[ "$ZSH_SUBSHELL" -eq 0 ]] || return 0
|
||||
# Add ".$SSH_USER" suffix to cache file if $SSH_USER is set and non-empty
|
||||
local cache_file="$ZSH_CACHE_DIR/last-working-dir${SSH_USER:+.$SSH_USER}"
|
||||
builtin pwd >| "$cache_file"
|
||||
'builtin' 'echo' '-E' "$PWD" >| "$cache_file"
|
||||
}
|
||||
|
||||
# Changes directory to the last working directory
|
||||
lwd() {
|
||||
# Add ".$SSH_USER" suffix to cache file if $SSH_USER is set and non-empty
|
||||
local cache_file="$ZSH_CACHE_DIR/last-working-dir${SSH_USER:+.$SSH_USER}"
|
||||
[[ -r "$cache_file" ]] && cd "$(cat "$cache_file")"
|
||||
[[ -r "$cache_file" ]] && cd "$(<"$cache_file")"
|
||||
}
|
||||
|
||||
# Jump to last directory automatically unless:
|
||||
# - this isn't the first time the plugin is loaded
|
||||
# - it's not in $HOME directory
|
||||
[[ -n "$ZSH_LAST_WORKING_DIRECTORY" ]] && return
|
||||
[[ "$PWD" != "$HOME" ]] && return
|
||||
#
|
||||
# - This isn't the first time the plugin is loaded
|
||||
# - We're not in the $HOME directory (e.g. if terminal opened a different folder)
|
||||
[[ -z "$ZSH_LAST_WORKING_DIRECTORY" ]] || return
|
||||
[[ "$PWD" == "$HOME" ]] || return
|
||||
|
||||
lwd 2>/dev/null && ZSH_LAST_WORKING_DIRECTORY=1 || true
|
||||
if lwd 2>/dev/null; then
|
||||
ZSH_LAST_WORKING_DIRECTORY=1
|
||||
fi
|
||||
|
|
|
|||
24
plugins/localstack/README.md
Normal file
24
plugins/localstack/README.md
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
# Localstack plugin #
|
||||
|
||||
CLI support for LOCALSTACK interaction
|
||||
|
||||
## Description ##
|
||||
To use it, add `localstack` to the plugins array in your zshrc file:
|
||||
|
||||
```zsh
|
||||
plugins=(... localstack)
|
||||
```
|
||||
|
||||
## Usage ##
|
||||
|
||||
This plugin supplies one command, `lsk`, through which all its features are exposed.
|
||||
|
||||
## Commands
|
||||
|
||||
| Command | Description |
|
||||
| :------------ | :-------------------------------------------------------------------- |
|
||||
| `lsk sqs-send <queue> <message.json>` | sends a given message in sqs to a given queue |
|
||||
|
||||
## Examples
|
||||
|
||||

|
||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue