Compare commits

..
Author SHA1 Message Date
Carlo Sala 2dee1cb94f fix(lib): restore startup loading for the omz CLI (#14328) 2026-12-04 21:28:45 +01:00
Robby RussellandCarlo Sala bb9193fa45 fix(gh): preserve valid completion cache on failure (#14131)
Co-authored-by: Carlo Sala <carlosalag@protonmail.com>
2026-12-04 12:58:34 +01:00
Robby RussellandCarlo Sala 6527e23542 perf(nvm): skip resolution for an already-active exact version (#14291)
Co-authored-by: Carlo Sala <carlosalag@protonmail.com>
2026-12-04 12:18:13 +01:00
Robby RussellandCarlo Sala d7046e0511 feat(cli): validate the plugins list in omz diagnose (#14306)
Co-authored-by: Carlo Sala <carlosalag@protonmail.com>
2026-12-04 12:12:50 +01:00
Enrico Maria Crisostomo 5b2db7b495 feat(macos): add low power mode management functions (#13517) 2026-12-04 11:59:24 +01:00
Robby Russell 6d5348a397 fix(clipboard): cap OSC 52 copies at 100 KB (#14307) 2026-12-04 11:56:26 +01:00
0714031cf8 feat(kubectl): add generic get and describe aliases (#8851)
Co-authored-by: Mirco Haug <git@mircohaug.de>
Co-authored-by: Robby Russell <robby@planetargon.com>
2026-12-03 20:34:59 +01:00
Robby RussellandClaude Fable 5.2 5b5bf2c51a chore: improve PR guidance for contributors and reviewers (#14310)
* docs: make the PR template human-first

* chore: reference title conventions in the PR checklist

* chore: simplify PR sections and collapse the checklist

* docs: add AGENTS.md and move PR description guidance later

Agents read AGENTS.md on their own, so the rules for drafting a PR
live there and CONTRIBUTING.md points to it from the AI section.
The PR description section now follows the sections on what to
contribute.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>

* docs: ask agents to backtick file names in PR descriptions

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>

---------

Co-authored-by: Claude Fable 5.2 <noreply@anthropic.com>
2026-12-03 20:20:13 +01:00
c0bd15e9cb feat(ollama): add completion plugin (#13269)
Co-authored-by: Robby Russell <robby@planetargon.com>
Co-authored-by: Carlo Sala <carlosalag@protonmail.com>
2026-12-03 15:26:35 +01:00
da3967b1f1 feat(git): add gan and ganpa aliases (#14288)
Co-authored-by: Charles Dunda <241828233+cdunda-perchwell@users.noreply.github.com>
Co-authored-by: Karl Horky <1935696+karlhorky@users.noreply.github.com>
2026-12-03 15:24:49 +01:00
Jonathan StacksandRobby Russell 35902fc3a1 feat(sprite): add completion plugin (#13703)
Co-authored-by: Robby Russell <robby@planetargon.com>
Signed-off-by: Jonathan Stacks <jonstacks@users.noreply.github.com>
2026-12-03 15:24:06 +01:00
Robby Russell e6647fae62 fix(alias-finder): suggest when the command starts with alias (#14309) 2026-12-03 15:21:29 +01:00
Robby RussellandBoris Frenkel dcc89a8063 feat(archlinux): add aliases for paru (#14290)
Co-authored-by: Boris Frenkel <fobos2k@gmail.com>
2026-12-03 15:13:40 +01:00
Robby RussellandCarlo Sala 5aef87b346 perf(lib): autoload the omz CLI and omz_diagnostic_dump (#14071)
Co-authored-by: Carlo Sala <carlosalag@protonmail.com>
2026-12-03 15:10:42 +01:00
Robby RussellandCarlo Sala d932d7ba24 perf(vcs_info): apply the %-quoting patch on first use (#14072)
Co-authored-by: Carlo Sala <carlosalag@protonmail.com>
2026-12-03 14:58:20 +01:00
Robby RussellandCarlo Sala ab9cf2989f perf(git): cache the git version used for alias selection (#14068)
Co-authored-by: Carlo Sala <carlosalag@protonmail.com>
2026-12-03 14:24:03 +01:00
Robby RussellandCarlo Sala 3d55d66d8b perf(termsupport): don't re-encode the cwd URL on every prompt (#14070)
Co-authored-by: Carlo Sala <carlosalag@protonmail.com>
2026-12-03 14:13:53 +01:00
8ba0ed4ede fix(fossil): improve placement of the fossil prompt info (#11139)
* Better placement of Fossil prompt info

Instead of blindly tacking `$fossil_prompt_info` onto the end of the
prompt string and making assumptions about whether `$PROMPT` or
`$RPROMPT` are in use here, assume the user is using a theme that puts
`$git_prompt_info` in there somewhere and inject our info immediately
afterward.  The theme creator decided that's a good place for Git prompt
info, so that's a good place for Fossil prompt info, too.

This also replaces some calls out to `grep` with internal Zsh string
manipulation for less overhead.

* fix(fossil): fall back to RPROMPT when the theme has no git_prompt_info

Keeps today's behaviour for themes without git_prompt_info, and re-checks on
each prompt in case the theme rebuilds its prompt.

---------

Co-authored-by: Robby Russell <robby@planetargon.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-12-02 19:30:07 +01:00
10ffeda6b5 fix(fossil)!: reduce prompt spacing (#11141)
BREAKING CHANGE: the fossil plugin now ships a prompt function that
removes spacing between segments. Spaces can always be added by
changing the setting variables. Check out the README for details.

* Reduced unnecessary space in Fossil plugin prompt

The prior version was way too opinionated, adding space between each element of the prompt string, unlike common Git prompt strings.  If the user wants more space, they can override our public variables to suit.  The inverse argument doesn't hold: it's easy to add space to existing variables, but not as easy to remove it after the fact.

As part of this, changed the branch name from red to blue (matching the preceding part of the prompt) so the red "X" added to indicate a dirty branch doesn't get lost in the branch name.

* fix(fossil): keep the branch name red
* Document fossil prompt settings

---------

Co-authored-by: Robby Russell <robby@planetargon.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Marc Cornellà <marc@mcornella.com>
2026-12-02 19:27:35 +01:00
Robby Russell 9ffcf687ef chore(macos): drop stale MiniPlayer note from music shuffle help (#14286)
The note described the old System Events button click, which #13365
replaces with Music's `shuffle enabled` property.
2026-12-02 18:57:58 +01:00
Robby RussellandMonson Shao 65badb0e63 feat(init): keep the zcompdump file in $ZSH_CACHE_DIR (#14289)
The default dump file moves from `${ZDOTDIR:-$HOME}` to `$ZSH_CACHE_DIR`,
so it no longer clutters the home directory. `ZSH_COMPDUMP` still
overrides the location, and `omz reload` already deletes the dump
wherever it lives. Diagnostics list dump files in both places.

The first shell after updating rebuilds the dump once. Old
`~/.zcompdump-*` files are left in place and can be deleted.

Closes #13406

Co-authored-by: Monson Shao <holymonson@gmail.com>
2026-12-02 18:54:14 +01:00
8da770db74 ci: add jactionlint and address workflow findings (#14304)
* ci: add jactionlint and address workflow findings

* ci(installer): pin vercel 66.6.0 and group major updates

68.0.0 was released the same day it was pinned, which skips the
seven-day cooldown this branch adds. Vercel ships a major version
about weekly, so majors join the npm group to keep it to one PR.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* ci: lock workflow action dependencies

Add .github/workflows/actions.lock, generated by gh actions-lock. It
records the commit for every action the workflows use, including
actions called by other actions. Workflows now reference release
tags and the lockfile holds the commit that runs.

Verify the lockfile in the Workflow lint job so a workflow change
that skips regenerating it fails the pull request.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>

* ci: lock and time-limit the alias collision job

The job arrived from master in #10859 after this branch was cut, so
it had no timeout and its setup-python version was missing from the
lockfile.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: mcornella <1441704+mcornella@users.noreply.github.com>
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
2026-12-02 18:52:53 +01:00
Kaustubh PhatakandClaude Opus 5.5 ccf23f54ea feat(kubectl): add kgnow alias to watch nodes (#14321)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-12-02 06:24:59 -08:00
Shreyansh Jain 81a38b0075 fix(systemadmin): use the log file passed to the access log functions (#14320) 2026-12-02 06:04:37 -08:00
Divya ff3767f564 fix(lib): pad omz_urlencode escapes to two hex digits (#14319) 2026-12-02 06:02:34 -08:00
Sanjay Doppalapudi 3cf60fdc97 docs(archlinux): match the README to the upgrade aliases (#14322) 2026-12-02 06:01:47 -08:00
Yahya Kayaal f8277e5043 fix(localstack): require message file argument in sqs-send (#14315) 2026-11-29 09:09:43 -08:00
dependabot[bot] ec7622cfbc chore(deps): bump the py-minor group (#14317)
Bumps the py-minor group in /.github/workflows/dependencies with 4 updates: [certifi](https://github.com/certifi/python-certifi), [charset-normalizer](https://github.com/jawah/charset_normalizer), [pyyaml](https://github.com/yaml/pyyaml) and [semver](https://github.com/python-semver/python-semver).


Updates `certifi` from 2026.10.23 to 2026.11.20
- [Commits](https://github.com/certifi/python-certifi/compare/2026.10.23...2026.11.20)

Updates `charset-normalizer` from 3.5.2 to 3.5.3
- [Release notes](https://github.com/jawah/charset_normalizer/releases)
- [Changelog](https://github.com/jawah/charset_normalizer/blob/master/CHANGELOG.md)
- [Commits](https://github.com/jawah/charset_normalizer/compare/3.5.2...3.5.3)

Updates `pyyaml` from 6.0.3 to 6.0.4
- [Release notes](https://github.com/yaml/pyyaml/releases)
- [Changelog](https://github.com/yaml/pyyaml/blob/6.0.4/CHANGES)
- [Commits](https://github.com/yaml/pyyaml/compare/6.0.3...6.0.4)

Updates `semver` from 3.1.2 to 3.1.3
- [Release notes](https://github.com/python-semver/python-semver/releases)
- [Changelog](https://github.com/python-semver/python-semver/blob/master/CHANGELOG.rst)
- [Commits](https://github.com/python-semver/python-semver/compare/3.1.2...3.1.3)

---
updated-dependencies:
- dependency-name: certifi
  dependency-version: 2026.11.20
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: py-minor
- dependency-name: charset-normalizer
  dependency-version: 3.5.3
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: py-minor
- dependency-name: pyyaml
  dependency-version: 6.0.4
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: py-minor
- dependency-name: semver
  dependency-version: 3.1.3
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: py-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-11-29 09:08:31 -08:00
dependabot[bot] e0bc2c99c4 chore(deps): bump the gha-minor group with 2 updates (#14316)
Bumps the gha-minor group with 2 updates: [actions/setup-python](https://github.com/actions/setup-python) and [github/codeql-action/upload-sarif](https://github.com/github/codeql-action).


Updates `actions/setup-python` from 7.0.0 to 7.1.0
- [Release notes](https://github.com/actions/setup-python/releases)
- [Commits](https://github.com/actions/setup-python/compare/v7...6d4fd22b20465ccc0f7354476588e8df7c9ca0e0)

Updates `github/codeql-action/upload-sarif` from 4.39.3 to 4.39.5
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](https://github.com/github/codeql-action/compare/33d7b85da1a04171e211befe2c739303b9a4c066...915412ff23e8b7659517e607487dbeae018f2934)

---
updated-dependencies:
- dependency-name: actions/setup-python
  dependency-version: 7.1.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: gha-minor
- dependency-name: github/codeql-action/upload-sarif
  dependency-version: 4.39.5
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: gha-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-11-29 09:04:57 -08:00
YourNeelsOG e0fb74a8e2 fix(vi-mode): restore cursor shape when leaving visual mode (#14313)
Fixes #11705
2026-11-28 13:55:09 -08:00
Calion 44a5decbc4 docs(thefuck): put the plugins line in a code block (#13272)
Added copybox for plugin code
2026-11-27 19:23:33 -08:00
Abdullah Ahmed 90f9fbc532 feat(terraform): add terraform-docs completion (#14185)
Generate completions from the installed terraform-docs CLI in the background and preserve a valid cache when generation fails or returns no output.

Fixes #12138

AI-assisted with OpenAI Codex.
2026-11-27 19:01:52 -08:00
Tien Nguyen Minh 801782e8a6 fix(spectrum): fall back to a loop on zsh older than 5.0.6 (#14278) 2026-11-27 18:54:18 -08:00
Markus Hofbauer e7a67d2e80 ci: add alias collision check (#10859)
* first draft alias collision

* add collision check to github actions

* run python unit tests in CI

* update actions to latest major version

* rename test to tests

* improve error message

* print all collisions found before failing

* disable failing of collision checker temporarily

* fix CI

* refactor to pytest

* add filter for known collisions

* read known collisions from file

* removed resolved collision

* remove known collisions

* better use checkout

* explicitly use master

* fix plugin path

* move tool to .github workflows

* review comments

* pin actions
2026-11-27 18:34:48 -08:00
Jans Rautenbach 4ec1d17074 feat(kubectl): add kcgetns alias to show the current namespace (#13215)
* rebase and review changes

* full command in readme

* space
2026-11-27 18:33:03 -08:00
180909 71679f351d feat(golang): add goge alias for go generate (#11528)
* feat(golang): add `goge` alias for `go generate`

* feat(golang):update  sequence
2026-11-27 18:32:08 -08:00
Sri Harsha Ponukumati 5c7cd91615 fix(uninstall): prompt before restoring pre-OMZ zshrc backup (#13849)
Fixes #13156
Fixes #13328
2026-11-27 18:30:43 -08:00
Jakub Boukal 5873e1cfec docs(python): add PYTHON_AUTO_VRUN to settings (#14233) 2026-11-27 16:20:27 -08:00
alexanderxc 03ba23c9f6 chore(brew): use bu instead of bubo in bubu (#14229) 2026-11-27 16:19:51 -08:00
PerryLink 597dff9477 fix(extract): untar .tar.Z and .taz archives (#14223) 2026-11-27 16:19:46 -08:00
Marco Trevisan 80ec81e340 feat(clipboard): add OSC 52 fallback (#14251)
OSC 52 makes the terminal emulator set the clipboard of the machine the
user is connected from, which is the only way to copy to it when running
over SSH or inside a container with no access to the local display
server.

Use it when no other clipboard tool is available, or when
ZSH_CLIPBOARD_OSC52 is set to "always"; set it to "never" to disable the
fallback. OSC 52 is write-only in practice, so clippaste keeps failing
unless a real clipboard tool is available.

Closes #13459
2026-11-27 16:19:24 -08:00
Sam Thomas 22c883efa4 fix(dotenv): bypass aliases when checking .env syntax (#14179) 2026-11-27 15:33:11 -08:00
Sam Thomas da85047297 fix(updater): bypass aliases when calling zsh in update check (#14178) 2026-11-27 15:33:06 -08:00
Jay Pokale 113f9b2475 fix(cli): remove adjacent plugins in omz plugin disable (#14303) 2026-11-27 15:19:41 -08:00
Martin Darmüntzel 507561c236 fix(macos): set shuffle with Music's shuffle property in music shuffle (#13365) 2026-11-27 14:58:20 -08:00
Hobeom Jeon d419792761 feat(conda): add environment completion for cna and cnrn (#13632) 2026-11-27 14:54:10 -08:00
Hobeom Jeon 90e5779f1f feat(zellij): add zellij plugin (#13624) 2026-11-27 14:54:06 -08:00
gbaian10 1dc43bfe53 fix(pre-commit): use autoupdate for prek (#14295)
Closes #14294
2026-11-27 14:46:13 -08:00
Rasmus Skovgaard Lauritsen 387dfe0bfb feat(fizzy): add completion plugin (#14297) 2026-11-27 14:46:09 -08:00
Sanjay Doppalapudi 32726ad0a5 fix(extract): unpack .tar.lzma archives (#14298) 2026-11-27 14:46:04 -08:00
Hegui Dai 2cd4cc21fc feat(jj): add jjgpb alias for jj git push --bookmark (#14302) 2026-11-27 14:45:52 -08:00
anacletoTM aa9ca00520 refactor(laravel): consolidate versioned plugins (#14282)
* refactor(laravel): consolidate versioned plugins

* fix(laravel): scope legacy aliases and defer command discovery
2026-11-27 13:31:49 -08:00
Alexander Schaber 924db8c81b refactor(plugins): use cached background completion generation (#13662)
Move invoke, istioctl, kn, kompose, kops, oc, operator-sdk, please and
svcat off sourcing `<($cmd completion ...)` on every startup. The
completion script is now cached under $ZSH_CACHE_DIR/completions and
regenerated in the background, following the pattern used by the helm
plugin.

Writes go through a temp file (prefixed with a dot to keep it out of
$fpath) that is moved into place atomically with `zf_mv`, so a
half-written file is never sourced.
2026-11-27 13:23:29 -08:00
원영 53f0790157 feat(git): add gsms alias for git submodule status (#13586) 2026-11-27 13:22:57 -08:00
Jim Weller abfce729ab feat(terragrunt): add terragrunt plugin (#13261) 2026-11-26 07:29:16 -08:00
Shahab Ahmed 070831e592 fix(extract): extract .deb members without double nesting (#14199)
Closes #14200
2026-11-26 07:29:06 -08:00
Federico Tensi e333686c2a feat(git-commit): support optional commit body (#14169) 2026-11-26 07:28:56 -08:00
Nuri Jung b1d468701a fix(git): remove unnecessary git rm from gwip (#13410) 2026-11-26 07:28:45 -08:00
kang 12a6ce7e42 feat(python): add recursive parent directory search for auto_vrun (#13523) 2026-11-26 07:20:36 -08:00
Kennan LeJeune f5a74e0347 feat(fnox): add plugin (#13593) 2026-11-26 07:20:27 -08:00
Randommisha13 0876f10264 feat(systemd): support other privilege elevation tools (#13695) 2026-11-26 07:20:17 -08:00
Thejesh 4d643a3c86 fix(web-search): escape reserved characters like + and & (#14275) 2026-11-26 07:20:09 -08:00
Thejesh 1a05a1091b fix(cli): add plugins to an empty plugins=() list (#14276) 2026-11-26 06:51:15 -08:00
Jonathan Stacks ad66117d08 feat(talosctl): add completions for talosctl (#13682) 2026-11-26 06:50:09 -08:00
Morningstar202604 964e5b65c6 fix(vi-mode): fix stale clipboard retry after failed push (#14141) 2026-11-26 06:45:29 -08:00
Ngonidzashe Mangudya 1eebae3a3f feat(laravel): add aliases for nWidart/laravel-modules (#14293) 2026-11-25 06:15:06 -08:00
mattmc3 ca5b808de8 feat(zsh-patina): add completions (#14296) 2026-11-25 06:11:57 -08:00
mattmc3 c8aea70a11 feat(zsh-patina): add completions (#14296) 2026-11-25 06:02:51 -08:00
Ininsico 799f9a8a8a fix(colorize): pass ZSH_COLORIZE_CHROMA_FORMATTER to cless (#13781)
Closes #12650
2026-11-24 21:22:08 -08:00
Mai-Lapyst 7140fedbfa docs(pre-commit): fix prek repository link (#13630) 2026-11-24 15:56:32 -08:00
Arbian Shkodra b5cb2fe952 feat(hcloud): add hcloud_prompt_info function (#13535) 2026-11-24 15:32:52 -08:00
117 changed files with 8437 additions and 332 deletions

No files matched your search

+51 -15
View File
@@ -1,21 +1,57 @@
## Standards checklist: <!--
Thanks for contributing! Read CONTRIBUTING.md first.
Keep this proportional to the change: short paragraphs or bullets are welcome.
Remove these instructions before submitting.
<!-- Fill with an x the ones that apply. Example: [x] --> Report only evidence you have. Distinguish agent-run checks from personal
testing, identify missing checks or demos, and leave unconfirmed items
unchecked. Don't promise follow-up work on someone else's behalf.
-->
- [ ] The PR title is descriptive. ## What and why
- [ ] The PR doesn't replicate another PR which is already open.
- [ ] I have read the contribution guide and followed all the instructions.
- [ ] The code follows the code style guide detailed in the wiki.
- [ ] The code is mine or it's from somewhere with an MIT-compatible license.
- [ ] If I used AI tools (ChatGPT, Claude, Gemini, etc.) to assist with this contribution, I've disclosed it below.
- [ ] The code is efficient, to the best of my ability, and does not waste computer resources.
- [ ] The code is stable and I have tested it myself, to the best of my abilities.
- [ ] If the code introduces new aliases, I provide a valid use case for all plugin users down below.
## Changes: <!-- What changes, who benefits, and how does it make their command-line
experience easier or more delightful? A few sentences are usually enough.
Link related issues or requests if available; don't invent demand.
- [...] A personal itch is a welcome starting point. Explain why the change belongs
in the shared project. For aliases, describe common workflows they support. -->
## Other comments: ## Demo and verification
... <!-- For user-facing changes, include before/after screenshots, a GIF,
or a short video. For new features, show an example in use.
If a visual isn't useful, briefly explain why. If it's missing, say so.
Describe checks actually run and their results, relevant versions, and
testing gaps. Distinguish agent-run checks from personal testing.
For documentation-only changes, describe what you checked. -->
## Other notes
<!-- Include only what applies:
- Compatibility concerns or areas needing particular attention.
- How users can discover a feature: README update, example, or shared demo.
- Meaningful AI assistance and its role; basic autocomplete doesn't count.
Delete this section if it isn't needed. -->
<details>
<summary>Submission checklist</summary>
<!-- Check confirmed items with [x]. For conditional items, check them if
the condition doesn't apply. Otherwise, mark inapplicable items "N/A"
with a brief reason. -->
- [ ] The PR title follows the [commit conventions](https://github.com/ohmyzsh/ohmyzsh/blob/master/CONTRIBUTING.md#commit-guidelines) and clearly describes the change.
- [ ] I've searched for existing PRs and confirmed this isn't a duplicate.
- [ ] I've read and followed the [contribution guidelines](https://github.com/ohmyzsh/ohmyzsh/blob/master/CONTRIBUTING.md).
- [ ] My code follows the [code style guide](https://github.com/ohmyzsh/ohmyzsh/wiki/Code-Style-Guide).
- [ ] I wrote this code or can contribute it under an MIT-compatible license.
- [ ] If I meaningfully used AI tools, I've disclosed their role above.
- [ ] I've included a visual demonstration or explained why a visual isn't useful.
- [ ] I've considered performance and avoided unnecessary work or resource use.
- [ ] I've personally tested the change and described results and limitations above.
- [ ] If I've added aliases, I've explained their usefulness for common workflows.
</details>
+20
View File
@@ -6,6 +6,8 @@ updates:
interval: "weekly" interval: "weekly"
day: "sunday" day: "sunday"
labels: [] labels: []
cooldown:
default-days: 7
groups: groups:
gha-minor: gha-minor:
patterns: patterns:
@@ -19,6 +21,8 @@ updates:
interval: "weekly" interval: "weekly"
day: "sunday" day: "sunday"
labels: [] labels: []
cooldown:
default-days: 7
groups: groups:
py-minor: py-minor:
patterns: patterns:
@@ -26,3 +30,19 @@ updates:
update-types: update-types:
- minor - minor
- patch - patch
- package-ecosystem: npm
directory: "/.github/workflows/installer"
schedule:
interval: "weekly"
day: "sunday"
labels: []
cooldown:
default-days: 7
groups:
npm-minor:
patterns:
- "*"
update-types:
- major
- minor
- patch
+66
View File
@@ -0,0 +1,66 @@
# Workflow checks
The `Workflow lint` workflow runs jactionlint on pull requests and pushes to
`master`. It checks workflows and Dependabot configuration with the default
profile, including ShellCheck for inline shell scripts. It runs without online
checks or publishing credentials.
To run the same checks locally, install jactionlint 2.6.0 and ShellCheck, then run
from the repository root:
```sh
jactionlint --profile=default --no-online
```
Keep the local jactionlint version aligned with the pinned action in `lint.yml`.
There is no baseline: new findings fail the check. Any rule exception should be
limited to the relevant line and explain why it is needed.
## Action lockfile
`actions.lock` records the commit for every action the workflows use, including
actions called by other actions. Workflows reference release tags; the lockfile
holds the commit that runs. Do not edit it by hand.
After adding a workflow or changing any `uses:` line, regenerate it with the
[`gh actions-lock`](https://github.com/github/gh-actions-lock) extension and
commit the result:
```sh
gh extension install github/gh-actions-lock
gh actions-lock
```
Dependabot updates the lockfile entry in the same pull request when it bumps an
action.
The `Workflow lint` workflow verifies the lockfile on every pull request and
fails when it does not match the workflows.
## Project tracking
`project.yml` intentionally uses `pull_request_target` so the GitHub App can add
fork contributions to the project board. It must not check out or execute PR
code. Project IDs are validated before passing them through step outputs, and
PR-derived plugin/theme names are restricted to letters, digits, dots, underscores
and hyphens.
The App tokens request explicit permissions: project tracking needs organization
projects write access and issues/pull requests read access; dependency updates
need contents read access and issues/pull requests write access. Dependency pushes
use the job's separate `GITHUB_TOKEN` with contents write access.
## Installer deployment
The Vercel CLI is pinned in `installer/package.json` and `installer/package-lock.json`.
Dependabot checks this dependency weekly, with a seven-day cooldown for version
updates, like the other configured ecosystems. Deployment installs the lockfile
with `npm ci --ignore-scripts`; `.vercelignore` uploads only `install.sh`.
After changing the CLI version, update its lockfile and verify the CLI locally:
```sh
npm install --package-lock-only --ignore-scripts --prefix .github/workflows/installer
npm ci --ignore-scripts --prefix .github/workflows/installer
.github/workflows/installer/node_modules/.bin/vercel --version
```
+90
View File
@@ -0,0 +1,90 @@
# This file is machine-generated by `gh actions-lock`.
# Do not edit by hand; run `gh actions-lock` to update.
# Docs: https://gh.io/actions-lockfile
version: 'v0.0.3'
workflows:
'.github/workflows/dependencies.yml':
- 'actions/checkout@v7.0.1'
- 'actions/create-github-app-token@v3.4.0'
- 'actions/setup-python@v7.1.0'
- 'step-security/harden-runner@v2.23.0'
'.github/workflows/installer.yml':
- 'actions/checkout@v7.0.1'
- 'actions/setup-node@v7.1.0'
- 'step-security/harden-runner@v2.23.0'
'.github/workflows/lint.yml':
- 'actions/checkout@v7.0.1'
- 'github/gh-actions-lock@verify/v0.5.1'
- 'jdx/jactionlint@v2.6.0'
- 'step-security/harden-runner@v2.23.0'
'.github/workflows/main.yml':
- 'actions/checkout@v7.0.1'
- 'actions/setup-python@v7.1.0'
- 'step-security/harden-runner@v2.23.0'
'.github/workflows/project.yml':
- 'actions/create-github-app-token@v3.4.0'
- 'step-security/harden-runner@v2.23.0'
'.github/workflows/scorecard.yml':
- 'actions/checkout@v7.0.1'
- 'actions/upload-artifact@v7.0.2'
- 'github/codeql-action@v4.39.5'
- 'ossf/scorecard-action@v2.6.0'
- 'step-security/harden-runner@v2.23.0'
dependencies:
'actions/checkout@v7.0.1':
ref: 'v7.0.1'
commit: 'sha1-3d3c42e5aac5ba805825da76410c181273ba90b1'
owner_id: 44036562
repo_id: 197814629
'actions/create-github-app-token@v3.4.0':
ref: 'v3.4.0'
commit: 'sha1-f418cff399f7aef4c2f0ad47e25ca7a6abbdd6fc'
owner_id: 44036562
repo_id: 642580244
'actions/setup-node@v7.1.0':
ref: 'v7.1.0'
commit: 'sha1-949feb2413d6458794dcd2491c4babbbce0c15c1'
owner_id: 44036562
repo_id: 189476904
'actions/setup-python@v7.1.0':
ref: 'v7.1.0'
commit: 'sha1-6d4fd22b20465ccc0f7354476588e8df7c9ca0e0'
owner_id: 44036562
repo_id: 192625525
'actions/upload-artifact@v7.0.2':
ref: 'v7.0.2'
commit: 'sha1-cf430e030ddbb5b0abf93d22962f4752f3646cd9'
owner_id: 44036562
repo_id: 192625955
'github/codeql-action@2892aa5e19bbd11bc0cff5427e3b750a04d9e3c2':
ref: 'v4.38.2'
commit: 'sha1-2892aa5e19bbd11bc0cff5427e3b750a04d9e3c2'
owner_id: 9919
repo_id: 259445878
'github/codeql-action@v4.39.5':
ref: 'v4.39.5'
commit: 'sha1-915412ff23e8b7659517e607487dbeae018f2934'
owner_id: 9919
repo_id: 259445878
'github/gh-actions-lock@verify/v0.5.1':
ref: 'verify/v0.5.1'
commit: 'sha1-5fa07d19c267d19e29f4341f10fdf7f516375038'
owner_id: 9919
repo_id: 1217640442
'jdx/jactionlint@v2.6.0':
ref: 'v2.6.0'
commit: 'sha1-72c00452809bcca05b8bc12acdcf15dd7a9c1c5e'
owner_id: 216188
repo_id: 1404951382
uses:
- 'github/codeql-action@2892aa5e19bbd11bc0cff5427e3b750a04d9e3c2'
'ossf/scorecard-action@v2.6.0':
ref: 'v2.6.0'
commit: 'sha1-23f22cd43608bae7a1f1fa2603d7314dee9538a5'
owner_id: 67707773
repo_id: 421101922
'step-security/harden-runner@v2.23.0':
ref: 'v2.23.0'
commit: 'sha1-aebdcf6156ab6691adf63218240e476564a1ed4c'
owner_id: 88700172
repo_id: 422287306
@@ -0,0 +1,2 @@
# default known collisions file
known_collisions.json
@@ -0,0 +1,170 @@
"""Check for alias collisions within the codebase"""
from argparse import ArgumentDefaultsHelpFormatter, ArgumentParser
from pathlib import Path
from dataclasses import dataclass
import itertools
import re
import json
import sys
ERROR_MESSAGE_TEMPLATE = (
"Alias `%s` defined in `%s` already exists as alias `%s` in `%s`."
)
KNOWN_COLLISIONS_PATH = Path(__file__).resolve().parent / "known_collisions.json"
def dir_path(path_string: str) -> Path:
if Path(path_string).is_dir():
return Path(path_string)
else:
raise NotADirectoryError(path_string)
def parse_arguments():
parser = ArgumentParser(
description=__doc__,
formatter_class=ArgumentDefaultsHelpFormatter,
)
parser.add_argument(
"folder",
type=dir_path,
help="Folder to check",
)
group = parser.add_mutually_exclusive_group(required=True)
group.add_argument(
"--known-collisions",
type=Path,
default=None,
help="Json-serialized list of known collision to compare to",
)
group.add_argument(
"--known-collisions-output-path",
type=Path,
default=KNOWN_COLLISIONS_PATH,
help="Output path for a json-serialized list of known collisions",
)
return parser.parse_args()
@dataclass(frozen=True)
class Alias:
alias: str
value: str
module: Path
def to_dict(self) -> dict:
return {
"alias": self.alias,
"value": self.value,
"module": str(self.module),
}
@dataclass(frozen=True)
class Collision:
existing_alias: Alias
new_alias: Alias
def is_new_collision(self, known_collision_aliases: list[str]) -> bool:
return self.new_alias.alias not in known_collision_aliases
@classmethod
def from_dict(cls, collision_dict: dict) -> "Collision":
return cls(
Alias(**collision_dict["existing_alias"]),
Alias(**collision_dict["new_alias"]),
)
def to_dict(self) -> dict:
return {
"existing_alias": self.existing_alias.to_dict(),
"new_alias": self.new_alias.to_dict(),
}
def find_aliases_in_file(file: Path) -> list[Alias]:
matches = re.findall(
r"^[ \t]*alias (?:-[gs] )?([^ =]+)=['\"]?(.*?)['\"]?$",
file.read_text(),
re.MULTILINE,
)
return [Alias(match[0], match[1], file) for match in matches]
def load_known_collisions(collision_file: Path) -> list[Collision]:
collision_list = json.loads(collision_file.read_text())
return [Collision.from_dict(collision_dict) for collision_dict in collision_list]
def find_all_aliases(path: Path) -> list:
aliases = [find_aliases_in_file(file) for file in path.rglob("*.zsh")]
return list(itertools.chain(*aliases))
def check_for_duplicates(aliases: list[Alias]) -> list[Collision]:
elements = {}
collisions = []
for alias in aliases:
if alias.alias in elements:
existing = elements[alias.alias]
collisions.append(Collision(existing, alias))
else:
elements[alias.alias] = alias
return collisions
def print_collisions(collisions: dict[Alias, Alias]) -> None:
if collisions:
print(f"Found {len(collisions)} alias collisions:\n")
for collision in collisions:
print(
ERROR_MESSAGE_TEMPLATE
% (
f"{collision.new_alias.alias}={collision.new_alias.value}",
collision.new_alias.module.name,
f"{collision.existing_alias.alias}={collision.existing_alias.value}",
collision.existing_alias.module.name,
)
)
print("\nConsider renaming your aliases.")
else:
print("Found no collisions")
def check_for_new_collisions(
known_collisions: Path, collisions: list[Collision]
) -> list[Collision]:
known_collisions = load_known_collisions(known_collisions)
known_collision_aliases = [
collision.new_alias.alias for collision in known_collisions
]
return [
collision
for collision in collisions
if collision.is_new_collision(known_collision_aliases)
]
def main() -> int:
"""main"""
args = parse_arguments()
aliases = find_all_aliases(args.folder)
collisions = check_for_duplicates(aliases)
if args.known_collisions is not None:
new_collisions = check_for_new_collisions(args.known_collisions, collisions)
print_collisions(new_collisions)
return -1 if new_collisions else 0
args.known_collisions_output_path.write_text(
json.dumps([collision.to_dict() for collision in collisions])
)
return 0
if __name__ == "__main__":
sys.exit(main())
@@ -0,0 +1,2 @@
pyfakefs
pytest
@@ -0,0 +1,166 @@
from pathlib import Path
from pyfakefs.fake_filesystem import FakeFilesystem
import pytest
from check_alias_collision import (
dir_path,
find_all_aliases,
find_aliases_in_file,
check_for_duplicates,
Alias,
Collision,
load_known_collisions,
)
THREE_ALIASES = """
alias g='git'
alias ga='git add'
alias gaa='git add --all'
"""
CONDITIONAL_ALIAS = """
is-at-least 2.8 "$git_version" \
&& alias gfa='git fetch --all --prune --jobs=10' \
|| alias gfa='git fetch --all --prune'
"""
ONE_KNOWN_COLLISION = """
[
{
"existing_alias": {
"alias": "gcd",
"value": "git checkout $(git_develop_branch)",
"module": "plugins/git/git.plugin.zsh"
},
"new_alias": {
"alias": "gcd",
"value": "git checkout $(git config gitflow.branch.develop)",
"module": "plugins/git-flow/git-flow.plugin.zsh"
}
}
]
"""
def test_dir_path__is_dir__input_path(fs: FakeFilesystem) -> None:
fs.create_dir("test")
assert Path("test") == dir_path("test")
def test_dir_path__is_file__raise_not_a_directory_error(fs: FakeFilesystem) -> None:
fs.create_file("test")
with pytest.raises(NotADirectoryError):
dir_path("test")
def test_dir_path__does_not_exist__raise_not_a_directory_error(
fs: FakeFilesystem,
) -> None:
with pytest.raises(NotADirectoryError):
dir_path("test")
def test_find_all_aliases__empty_folder_should_return_empty_list(
fs: FakeFilesystem,
) -> None:
fs.create_dir("test")
result = find_all_aliases(Path("test"))
assert [] == result
def test_find_aliases_in_file__empty_text_should_return_empty_list(
fs: FakeFilesystem,
) -> None:
fs.create_file("empty.zsh")
result = find_aliases_in_file(Path("empty.zsh"))
assert [] == result
def test_find_aliases_in_file__one_alias_should_find_one(fs: FakeFilesystem) -> None:
fs.create_file("one.zsh", contents="alias g='git'")
result = find_aliases_in_file(Path("one.zsh"))
assert [Alias("g", "git", Path("one.zsh"))] == result
def test_find_aliases_in_file__three_aliases_should_find_three(
fs: FakeFilesystem,
) -> None:
fs.create_file("three.zsh", contents=THREE_ALIASES)
result = find_aliases_in_file(Path("three.zsh"))
assert [
Alias("g", "git", Path("three.zsh")),
Alias("ga", "git add", Path("three.zsh")),
Alias("gaa", "git add --all", Path("three.zsh")),
] == result
def test_find_aliases_in_file__one_conditional_alias_should_find_none(
fs: FakeFilesystem,
) -> None:
fs.create_file("conditional.zsh", contents=CONDITIONAL_ALIAS)
result = find_aliases_in_file(Path("conditional.zsh"))
assert [] == result
def test_check_for_duplicates__no_duplicates_should_return_empty_dict() -> None:
result = check_for_duplicates(
[
Alias("g", "git", Path("git.zsh")),
Alias("ga", "git add", Path("git.zsh")),
Alias("gaa", "git add --all", Path("git.zsh")),
]
)
assert result == []
def test_check_for_duplicates__duplicates_should_have_one_collision() -> None:
result = check_for_duplicates(
[
Alias("gc", "git commit", Path("git.zsh")),
Alias("gc", "git clone", Path("git.zsh")),
]
)
assert result == [
Collision(
Alias("gc", "git commit", Path("git.zsh")),
Alias("gc", "git clone", Path("git.zsh")),
)
]
def test_is_new_collision__new_alias_not_in_known_collisions__should_return_true() -> (
None
):
known_collisions = ["gc", "gd"]
new_alias = Alias("ga", "git add", Path("git.zsh"))
collision = Collision(Alias("gd", "git diff", Path("git.zsh")), new_alias)
assert collision.is_new_collision(known_collisions) is True
def test_is_new_collision__new_alias_in_known_collisions__should_return_false() -> None:
known_collisions = ["gc", "gd", "ga"]
new_alias = Alias("ga", "git add", Path("git.zsh"))
collision = Collision(Alias("gd", "git diff", Path("git.zsh")), new_alias)
assert collision.is_new_collision(known_collisions) is False
def test_load_known_collisions__empty_file__should_return_empty_list(
fs: FakeFilesystem,
) -> None:
empty_list = Path("empty.json")
fs.create_file(empty_list, contents="[]")
result = load_known_collisions(empty_list)
assert [] == result
def test_load_known_collisions__one_collision__should_return_one_collision(
fs: FakeFilesystem,
) -> None:
known_collisions_file = Path("known_collisions.json")
fs.create_file(known_collisions_file, contents=ONE_KNOWN_COLLISION)
result = load_known_collisions(known_collisions_file)
assert 1 == len(result)
assert "gcd" == result[0].existing_alias.alias
+8 -4
View File
@@ -11,27 +11,31 @@ jobs:
check: check:
name: Check for updates name: Check for updates
runs-on: ubuntu-latest runs-on: ubuntu-latest
timeout-minutes: 30
if: github.repository == 'ohmyzsh/ohmyzsh' if: github.repository == 'ohmyzsh/ohmyzsh'
permissions: permissions:
contents: write # this is needed to push commits and branches contents: write # this is needed to push commits and branches
steps: steps:
- name: Harden the runner (Audit all outbound calls) - name: Harden the runner (Audit all outbound calls)
uses: step-security/harden-runner@aebdcf6156ab6691adf63218240e476564a1ed4c # v2.23.0 uses: step-security/harden-runner@v2.23.0
with: with:
egress-policy: audit egress-policy: audit
- name: Checkout - name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 uses: actions/checkout@v7.0.1
with: with:
fetch-depth: 0 fetch-depth: 0
- name: Authenticate as @ohmyzsh - name: Authenticate as @ohmyzsh
id: generate-token id: generate-token
uses: actions/create-github-app-token@f418cff399f7aef4c2f0ad47e25ca7a6abbdd6fc # v3.4.0 uses: actions/create-github-app-token@v3.4.0
with: with:
client-id: ${{ secrets.OHMYZSH_CLIENT_ID }} client-id: ${{ secrets.OHMYZSH_CLIENT_ID }}
private-key: ${{ secrets.OHMYZSH_APP_PRIVATE_KEY }} private-key: ${{ secrets.OHMYZSH_APP_PRIVATE_KEY }}
permission-contents: read
permission-issues: write
permission-pull-requests: write
- name: Setup Python - name: Setup Python
uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7.1.0 uses: actions/setup-python@v7.1.0
with: with:
python-version: "3.12" python-version: "3.12"
cache: "pip" cache: "pip"
@@ -1,7 +1,7 @@
certifi==2026.10.23 certifi==2026.11.20
charset-normalizer==3.5.2 charset-normalizer==3.5.3
idna==3.20 idna==3.20
PyYAML==6.0.3 PyYAML==6.0.4
requests==2.34.2 requests==2.34.2
semver==3.1.2 semver==3.1.3
urllib3==2.8.0 urllib3==2.8.0
+16 -6
View File
@@ -19,6 +19,7 @@ jobs:
name: Test installer name: Test installer
if: github.repository == 'ohmyzsh/ohmyzsh' if: github.repository == 'ohmyzsh/ohmyzsh'
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}
timeout-minutes: 15
strategy: strategy:
matrix: matrix:
os: os:
@@ -26,12 +27,12 @@ jobs:
- macos-latest - macos-latest
steps: steps:
- name: Harden the runner (Audit all outbound calls) - name: Harden the runner (Audit all outbound calls)
uses: step-security/harden-runner@aebdcf6156ab6691adf63218240e476564a1ed4c # v2.23.0 uses: step-security/harden-runner@v2.23.0
with: with:
egress-policy: audit egress-policy: audit
- name: Set up git repository - name: Set up git repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 uses: actions/checkout@v7.0.1
- name: Install zsh - name: Install zsh
if: runner.os == 'Linux' if: runner.os == 'Linux'
run: sudo apt-get update; sudo apt-get install zsh run: sudo apt-get update; sudo apt-get install zsh
@@ -42,19 +43,28 @@ jobs:
name: Deploy installer in install.ohmyz.sh name: Deploy installer in install.ohmyz.sh
if: github.ref == 'refs/heads/master' if: github.ref == 'refs/heads/master'
runs-on: ubuntu-latest runs-on: ubuntu-latest
timeout-minutes: 15
environment: vercel environment: vercel
needs: needs:
- test - test
steps: steps:
- name: Harden the runner (Audit all outbound calls) - name: Harden the runner (Audit all outbound calls)
uses: step-security/harden-runner@aebdcf6156ab6691adf63218240e476564a1ed4c # v2.23.0 uses: step-security/harden-runner@v2.23.0
with: with:
egress-policy: audit egress-policy: audit
- name: Checkout - name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 uses: actions/checkout@v7.0.1
with:
persist-credentials: false
- name: Set up Node.js
uses: actions/setup-node@v7.1.0
with:
node-version: "24"
package-manager-cache: false
- name: Install Vercel CLI - name: Install Vercel CLI
run: npm install -g vercel working-directory: .github/workflows/installer
run: npm ci --ignore-scripts --no-audit --no-fund
- name: Setup project and deploy - name: Setup project and deploy
env: env:
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }} VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
@@ -63,4 +73,4 @@ jobs:
run: | run: |
cp tools/install.sh .github/workflows/installer/install.sh cp tools/install.sh .github/workflows/installer/install.sh
cd .github/workflows/installer cd .github/workflows/installer
vc deploy --prod -t "$VERCEL_TOKEN" ./node_modules/.bin/vercel deploy --prod -t "$VERCEL_TOKEN"
+1
View File
@@ -1 +1,2 @@
install.sh install.sh
node_modules/
File diff suppressed because it is too large. Load diff
+7
View File
@@ -0,0 +1,7 @@
{
"name": "ohmyzsh-installer-deploy",
"private": true,
"devDependencies": {
"vercel": "66.6.0"
}
}
+35
View File
@@ -0,0 +1,35 @@
name: Workflow lint
on:
pull_request:
push:
branches:
- master
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
permissions:
contents: read
jobs:
jactionlint:
name: Lint GitHub Actions
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Harden the runner (Audit all outbound calls)
uses: step-security/harden-runner@v2.23.0
with:
egress-policy: audit
- name: Checkout
uses: actions/checkout@v7.0.1
with:
persist-credentials: false
- name: Lint workflows and Dependabot configuration
uses: jdx/jactionlint@v2.6.0
with:
profile: default
online: "false"
- name: Verify action lockfile
uses: github/gh-actions-lock@verify/v0.5.1
+33 -3
View File
@@ -21,15 +21,16 @@ jobs:
tests: tests:
name: Run tests name: Run tests
runs-on: ubuntu-latest runs-on: ubuntu-latest
timeout-minutes: 10
if: github.repository == 'ohmyzsh/ohmyzsh' if: github.repository == 'ohmyzsh/ohmyzsh'
steps: steps:
- name: Harden the runner (Audit all outbound calls) - name: Harden the runner (Audit all outbound calls)
uses: step-security/harden-runner@aebdcf6156ab6691adf63218240e476564a1ed4c # v2.23.0 uses: step-security/harden-runner@v2.23.0
with: with:
egress-policy: audit egress-policy: audit
- name: Set up git repository - name: Set up git repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 uses: actions/checkout@v7.0.1
- name: Install zsh - name: Install zsh
run: sudo apt-get update; sudo apt-get install zsh run: sudo apt-get update; sudo apt-get install zsh
- name: Check syntax - name: Check syntax
@@ -39,5 +40,34 @@ jobs:
./plugins/*/*.plugin.zsh \ ./plugins/*/*.plugin.zsh \
./plugins/*/_* \ ./plugins/*/_* \
./themes/*.zsh-theme; do ./themes/*.zsh-theme; do
zsh -n "$file" || return 1 zsh -n "$file" || exit 1
done done
collisions:
name: Check alias collisions
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Set up git repository
uses: actions/checkout@v7.0.1
- name: Set up Python
uses: actions/setup-python@v7.1.0
with:
python-version: '3.14'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r .github/workflows/alias_collision/requirements.txt
- name: Run unit tests
run: |
cd .github/workflows/alias_collision/
python -m pytest
- name: Checkout target branch
uses: actions/checkout@v7.0.1
with:
path: ohmyzsh-target-branch
ref: master
- name: Check for alias collisions on target branch
run: python .github/workflows/alias_collision/check_alias_collision.py ohmyzsh-target-branch/plugins --known-collisions-output-path known_alias_collisions.json
- name: Compare known collisions to new collisions on source branch
run: python .github/workflows/alias_collision/check_alias_collision.py plugins --known-collisions known_alias_collisions.json
+43 -11
View File
@@ -2,6 +2,8 @@ name: Project tracking
on: on:
issues: issues:
types: [opened, reopened] types: [opened, reopened]
# Board updates need an App token for fork PRs; no PR code is checked out or run.
# jactionlint ignore=dangerous-triggers
pull_request_target: pull_request_target:
types: [opened, reopened, synchronize] types: [opened, reopened, synchronize]
@@ -14,25 +16,35 @@ jobs:
add-to-project: add-to-project:
name: Add to project name: Add to project
runs-on: ubuntu-latest runs-on: ubuntu-latest
timeout-minutes: 10
defaults:
run:
shell: bash
if: github.repository == 'ohmyzsh/ohmyzsh' if: github.repository == 'ohmyzsh/ohmyzsh'
steps: steps:
- name: Harden the runner (Audit all outbound calls) - name: Harden the runner (Audit all outbound calls)
uses: step-security/harden-runner@aebdcf6156ab6691adf63218240e476564a1ed4c # v2.23.0 uses: step-security/harden-runner@v2.23.0
with: with:
egress-policy: audit egress-policy: audit
- name: Authenticate as @ohmyzsh - name: Authenticate as @ohmyzsh
id: generate-token id: generate-token
uses: actions/create-github-app-token@f418cff399f7aef4c2f0ad47e25ca7a6abbdd6fc # v3.4.0 uses: actions/create-github-app-token@v3.4.0
with: with:
client-id: ${{ secrets.OHMYZSH_CLIENT_ID }} client-id: ${{ secrets.OHMYZSH_CLIENT_ID }}
private-key: ${{ secrets.OHMYZSH_APP_PRIVATE_KEY }} private-key: ${{ secrets.OHMYZSH_APP_PRIVATE_KEY }}
permission-organization-projects: write
permission-issues: read
permission-pull-requests: read
- name: Read project data - name: Read project data
id: project
env: env:
GH_TOKEN: ${{ steps.generate-token.outputs.token }} GH_TOKEN: ${{ steps.generate-token.outputs.token }}
ORGANIZATION: ohmyzsh ORGANIZATION: ohmyzsh
PROJECT_NUMBER: "1" PROJECT_NUMBER: "1"
run: | run: |
# Get Project data # Get Project data
# GraphQL variables must reach GitHub literally.
# shellcheck disable=SC2016
gh api graphql -f query=' gh api graphql -f query='
query($org: String!, $number: Int!) { query($org: String!, $number: Int!) {
organization(login: $org){ organization(login: $org){
@@ -48,19 +60,29 @@ jobs:
} }
} }
} }
}' -f org=$ORGANIZATION -F number=$PROJECT_NUMBER > project_data.json }' -f org="$ORGANIZATION" -F number="$PROJECT_NUMBER" > project_data.json
# Parse project data # Parse project data
cat >> "$GITHUB_ENV" <<EOF PROJECT_ID=$(jq -er '.data.organization.projectV2.id' project_data.json)
PROJECT_ID=$(jq '.data.organization.projectV2.id' project_data.json) PLUGIN_FIELD_ID=$(jq -er '.data.organization.projectV2.fields.nodes[] | select(.name == "Plugin") | .id' project_data.json)
PLUGIN_FIELD_ID=$(jq '.data.organization.projectV2.fields.nodes[] | select(.name == "Plugin") | .id' project_data.json) THEME_FIELD_ID=$(jq -er '.data.organization.projectV2.fields.nodes[] | select(.name == "Theme") | .id' project_data.json)
THEME_FIELD_ID=$(jq '.data.organization.projectV2.fields.nodes[] | select(.name == "Theme") | .id' project_data.json) for id in "$PROJECT_ID" "$PLUGIN_FIELD_ID" "$THEME_FIELD_ID"; do
EOF [[ "$id" =~ ^[A-Za-z0-9_=/+-]+$ ]] || exit 1
done
{
echo "PROJECT_ID=$PROJECT_ID"
echo "PLUGIN_FIELD_ID=$PLUGIN_FIELD_ID"
echo "THEME_FIELD_ID=$THEME_FIELD_ID"
} >> "$GITHUB_OUTPUT"
- name: Add to project - name: Add to project
id: item
env: env:
GH_TOKEN: ${{ steps.generate-token.outputs.token }} GH_TOKEN: ${{ steps.generate-token.outputs.token }}
ISSUE_OR_PR_ID: ${{ github.event.issue.node_id || github.event.pull_request.node_id }} ISSUE_OR_PR_ID: ${{ github.event.issue.node_id || github.event.pull_request.node_id }}
PROJECT_ID: ${{ steps.project.outputs.PROJECT_ID }}
run: | run: |
# GraphQL variables must reach GitHub literally.
# shellcheck disable=SC2016
item_id="$(gh api graphql -f query=' item_id="$(gh api graphql -f query='
mutation($project: ID!, $content: ID!) { mutation($project: ID!, $content: ID!) {
addProjectV2ItemById(input: {projectId: $project, contentId: $content}) { addProjectV2ItemById(input: {projectId: $project, contentId: $content}) {
@@ -69,10 +91,12 @@ jobs:
} }
} }
} }
' -f project="$PROJECT_ID" -f content="$ISSUE_OR_PR_ID" --jq '.data.addProjectV2ItemById.item.id')" ' -f project="$PROJECT_ID" -f content="$ISSUE_OR_PR_ID" --jq '.data.addProjectV2ItemById.item.id // error("missing project item ID")')"
echo "ITEM_ID=$item_id" >> $GITHUB_ENV [[ "$item_id" =~ ^[A-Za-z0-9_=/+-]+$ ]] || exit 1
echo "ITEM_ID=$item_id" >> "$GITHUB_OUTPUT"
- name: Classify Pull Request - name: Classify Pull Request
id: classify
if: github.event_name == 'pull_request_target' if: github.event_name == 'pull_request_target'
env: env:
GH_TOKEN: ${{ steps.generate-token.outputs.token }} GH_TOKEN: ${{ steps.generate-token.outputs.token }}
@@ -109,12 +133,20 @@ jobs:
print "THEME=" theme print "THEME=" theme
} }
} }
' >> "$GITHUB_ENV" ' >> "$GITHUB_OUTPUT"
- name: Fill Pull Request fields in project - name: Fill Pull Request fields in project
if: github.event_name == 'pull_request_target' if: github.event_name == 'pull_request_target'
env: env:
GH_TOKEN: ${{ steps.generate-token.outputs.token }} GH_TOKEN: ${{ steps.generate-token.outputs.token }}
PROJECT_ID: ${{ steps.project.outputs.PROJECT_ID }}
ITEM_ID: ${{ steps.item.outputs.ITEM_ID }}
PLUGIN_FIELD_ID: ${{ steps.project.outputs.PLUGIN_FIELD_ID }}
PLUGIN: ${{ steps.classify.outputs.PLUGIN }}
THEME_FIELD_ID: ${{ steps.project.outputs.THEME_FIELD_ID }}
THEME: ${{ steps.classify.outputs.THEME }}
run: | run: |
# GraphQL variables must reach GitHub literally.
# shellcheck disable=SC2016
gh api graphql -f query=' gh api graphql -f query='
mutation ( mutation (
$project: ID! $project: ID!
+12 -7
View File
@@ -14,13 +14,18 @@ on:
push: push:
branches: ["master"] branches: ["master"]
# Declare default permissions as read only. concurrency:
permissions: read-all group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
# Permissions are granted only to the analysis job.
permissions: {}
jobs: jobs:
analysis: analysis:
name: Scorecard analysis name: Scorecard analysis
runs-on: ubuntu-latest runs-on: ubuntu-latest
timeout-minutes: 15
permissions: permissions:
# Needed to upload the results to code-scanning dashboard. # Needed to upload the results to code-scanning dashboard.
security-events: write security-events: write
@@ -36,30 +41,30 @@ jobs:
steps: steps:
- name: Harden the runner (Audit all outbound calls) - name: Harden the runner (Audit all outbound calls)
uses: step-security/harden-runner@aebdcf6156ab6691adf63218240e476564a1ed4c # v2.23.0 uses: step-security/harden-runner@v2.23.0
with: with:
egress-policy: audit egress-policy: audit
- name: "Checkout code" - name: "Checkout code"
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 uses: actions/checkout@v7.0.1
with: with:
persist-credentials: false persist-credentials: false
- name: "Run analysis" - name: "Run analysis"
uses: ossf/scorecard-action@23f22cd43608bae7a1f1fa2603d7314dee9538a5 # v2.6.0 uses: ossf/scorecard-action@v2.6.0
with: with:
results_file: results.sarif results_file: results.sarif
results_format: sarif results_format: sarif
publish_results: true publish_results: true
- name: "Upload artifact" - name: "Upload artifact"
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 uses: actions/upload-artifact@v7.0.2
with: with:
name: SARIF file name: SARIF file
path: results.sarif path: results.sarif
retention-days: 5 retention-days: 5
- name: "Upload to code-scanning" - name: "Upload to code-scanning"
uses: github/codeql-action/upload-sarif@33d7b85da1a04171e211befe2c739303b9a4c066 # v4.39.3 uses: github/codeql-action/upload-sarif@v4.39.5
with: with:
sarif_file: results.sarif sarif_file: results.sarif
+34
View File
@@ -0,0 +1,34 @@
# Instructions for coding agents
Oh My Zsh is maintained by a small team of volunteers. A person reviews every
pull request, so help the contributor send one that is easy to review.
## Before opening a pull request
1. Read [CONTRIBUTING.md](CONTRIBUTING.md) and follow it.
2. Search open pull requests and issues for the same change. If one exists,
tell the contributor instead of opening a duplicate.
3. Fill in [.github/PULL_REQUEST_TEMPLATE.md](.github/PULL_REQUEST_TEMPLATE.md).
Keep its sections and its checklist.
4. Use the [commit format](CONTRIBUTING.md#commit-guidelines) for commits and
for the pull request title.
## Writing the description
- Report only evidence you have. Don't invent user requests, test results,
or demo links.
- Separate checks you ran from testing the contributor did. Don't claim
personal testing or confirmation on their behalf.
- Leave unconfirmed checklist items unchecked, and name any missing testing
or demo.
- Don't commit the contributor to follow-up work they haven't agreed to.
- Disclose meaningful AI assistance in "Other notes".
- Put file names and paths in backticks so they render as code.
## Keeping the change reviewable
- One purpose per pull request. Keep the diff small, and leave unrelated
files alone.
- Follow the [code style guide](https://github.com/ohmyzsh/ohmyzsh/wiki/Code-Style-Guide).
- The contributor must be able to explain the change. If they can't yet,
explain it to them before the pull request is opened.
+32
View File
@@ -20,6 +20,7 @@ you would make is not already covered.
- [Getting started](#getting-started) - [Getting started](#getting-started)
- [You have a solution](#you-have-a-solution) - [You have a solution](#you-have-a-solution)
- [You have an addition](#you-have-an-addition) - [You have an addition](#you-have-an-addition)
- [Writing your PR description](#writing-your-pr-description)
- [A note on AI-assisted contributions](#a-note-on-ai-assisted-contributions) - [A note on AI-assisted contributions](#a-note-on-ai-assisted-contributions)
- [Use the Search, Luke](#use-the-search-luke) - [Use the Search, Luke](#use-the-search-luke)
- [Commit Guidelines](#commit-guidelines) - [Commit Guidelines](#commit-guidelines)
@@ -126,6 +127,34 @@ Because of this, from now on, we require that new aliases follow these condition
This list is not exhaustive! Please remember that your alias will be in the machines of many people, This list is not exhaustive! Please remember that your alias will be in the machines of many people,
so it should be justified why they should have it. so it should be justified why they should have it.
### Writing your PR description
Use the [PR template](.github/PULL_REQUEST_TEMPLATE.md) to help people understand
the purpose of your change before they reach the submission checklist. Keep answers
short and proportional to the change; a sentence or two per section is often enough.
Oh My Zsh should make the command line more delightful. Tell us whose day your
change makes easier, clearer, or more enjoyable, and how. Scratching your own itch
is a welcome starting point! Your change doesn't need to help everyone, but explain
why it would be useful to others and belongs in the shared project. Link relevant
requests or examples when you have them; otherwise, explain the expected benefit
without claiming demand you haven't seen.
For user-facing changes, include screenshots, a GIF, or a short video showing
before/after behavior. For a new feature, demonstrate it in use. Label the examples,
keep terminal text readable, and remove private information. For low-level or other
non-visual changes, explain why a visual wouldn't be useful. If a demo is needed
but you can't capture it yet, say so rather than marking it inapplicable.
Describe the checks actually run and their results, relevant environment versions,
and any testing gaps. Distinguish automated or agent-run checks from testing you
personally performed. For documentation-only changes, describe what you checked.
Only check the personal-testing item after you've done that testing yourself.
For features and enhancements, tell us how you'll help users discover and use them.
A plugin README update, a usage example, or sharing your demo are good ways to help.
Be clear about what's included in the PR and what's planned for later.
## A note on AI-assisted contributions ## A note on AI-assisted contributions
We'll admit it: AI tools can be pretty helpful for coding tasks, and we're not here to gatekeep how you get your work done. We use these tools ourselves! 🤖 We'll admit it: AI tools can be pretty helpful for coding tasks, and we're not here to gatekeep how you get your work done. We use these tools ourselves! 🤖
@@ -150,6 +179,9 @@ The disclosure helps us know how much guidance to offer. If we're just reviewing
As always, we reserve the right to decline any contribution. PRs that appear to be unreviewed AI output, or code the contributor can't explain, may be closed without extensive feedback. As always, we reserve the right to decline any contribution. PRs that appear to be unreviewed AI output, or code the contributor can't explain, may be closed without extensive feedback.
**For coding agents:** follow [AGENTS.md](AGENTS.md). It covers what to read
before drafting a PR and how to keep the description grounded in evidence.
---- ----
## Use the Search, Luke ## Use the Search, Luke
+2 -1
View File
@@ -562,7 +562,8 @@ omz diagnose
It runs a few quick checks and tells you what to fix — for example, it will warn you when It runs a few quick checks and tells you what to fix — for example, it will warn you when
your locale is not UTF-8, which is a common cause of duplicated characters at the prompt your locale is not UTF-8, which is a common cause of duplicated characters at the prompt
(see the [FAQ](https://github.com/ohmyzsh/ohmyzsh/wiki/FAQ#i-see-duplicate-typed-characters-after-i-complete-a-command)). (see the [FAQ](https://github.com/ohmyzsh/ohmyzsh/wiki/FAQ#i-see-duplicate-typed-characters-after-i-complete-a-command)),
and it validates your `plugins=(...)` list, suggesting the closest name for any plugin it can't find.
For a full report suitable for attaching to a bug report, use `omz_diagnostic_dump`. For a full report suitable for attaching to a bug report, use `omz_diagnostic_dump`.
+68 -12
View File
@@ -190,14 +190,64 @@ function _omz::diagnose {
codeset="$(locale charmap 2>/dev/null)" codeset="$(locale charmap 2>/dev/null)"
fi fi
local ret=0
if [[ "${codeset:l}" = (utf-8|utf8) ]]; then if [[ "${codeset:l}" = (utf-8|utf8) ]]; then
_omz::log info "locale charmap is UTF-8" _omz::log info "locale charmap is UTF-8"
else else
_omz::log warn "your locale is not UTF-8 (charmap: ${codeset:-unknown})" _omz::log warn "your locale is not UTF-8 (charmap: ${codeset:-unknown})"
_omz::log info "non-UTF-8 locales may cause glitches in completions and international characters" _omz::log info "non-UTF-8 locales may cause glitches in completions and international characters"
_omz::log info "consider setting a UTF-8 locale, e.g.: export LANG=C.UTF-8" _omz::log info "consider setting a UTF-8 locale, e.g.: export LANG=C.UTF-8"
ret=1
fi
_omz::diagnose::plugins || ret=1
return $ret
}
function _omz::diagnose::plugins {
# Validate the plugins array: flag entries with no matching plugin folder,
# and suggest the closest plugin name (up to 2 typos) for each one.
setopt localoptions extendedglob
local plugin base distance candidate suggestion found=0
local -a missing
for plugin ($plugins); do
if is_plugin "$ZSH_CUSTOM" "$plugin" || is_plugin "$ZSH" "$plugin"; then
(( ++found ))
continue
fi
missing+=("$plugin")
done
for plugin ($missing); do
suggestion=
# Check both roots at each distance, with custom plugins first for ties.
for distance in 1 2; do
for base in "$ZSH_CUSTOM" "$ZSH"; do
for candidate in \
"$base"/plugins/(#a$distance)${(b)plugin}(#qN-/); do
if is_plugin "$base" "${candidate:t}"; then
suggestion=${candidate:t}
break 3
fi
done
done
done
if [[ -n "$suggestion" ]]; then
_omz::log warn "plugin '$plugin' not found (did you mean '$suggestion'?)" \
omz::diagnose
else
_omz::log warn "plugin '$plugin' not found" omz::diagnose
fi
done
if (( $#missing )); then
_omz::log info "$found of ${#plugins} plugins found" omz::diagnose
return 1 return 1
fi fi
(( $#plugins )) && _omz::log info "all ${#plugins} plugins found" omz::diagnose
return 0
} }
function _omz::help { function _omz::help {
@@ -295,17 +345,23 @@ function _omz::plugin::disable {
fi fi
# Remove plugins substitution awk script # Remove plugins substitution awk script
# A match consumes the whitespace around the plugin, so adjacent plugins
# can't match in the same pass: repeat until the line stops changing.
local awk_subst_plugins="\ local awk_subst_plugins="\
gsub(/[ \t]+(${(j:|:)dis_plugins})[ \t]+/, \" \") # with spaces before or after do {
gsub(/[ \t]+(${(j:|:)dis_plugins})$/, \"\") # with spaces before and EOL prev = \$0
gsub(/^(${(j:|:)dis_plugins})[ \t]+/, \"\") # with BOL and spaces after
gsub(/\((${(j:|:)dis_plugins})[ \t]+/, \"(\") # with parenthesis before and spaces after gsub(/[ \t]+(${(j:|:)dis_plugins})[ \t]+/, \" \") # with spaces before or after
gsub(/[ \t]+(${(j:|:)dis_plugins})\)/, \")\") # with spaces before or parenthesis after gsub(/[ \t]+(${(j:|:)dis_plugins})$/, \"\") # with spaces before and EOL
gsub(/\((${(j:|:)dis_plugins})\)/, \"()\") # with only parentheses gsub(/^(${(j:|:)dis_plugins})[ \t]+/, \"\") # with BOL and spaces after
gsub(/^(${(j:|:)dis_plugins})\)/, \")\") # with BOL and closing parenthesis gsub(/\((${(j:|:)dis_plugins})[ \t]+/, \"(\") # with parenthesis before and spaces after
gsub(/\((${(j:|:)dis_plugins})$/, \"(\") # with opening parenthesis and EOL gsub(/[ \t]+(${(j:|:)dis_plugins})\)/, \")\") # with spaces before or parenthesis after
gsub(/\((${(j:|:)dis_plugins})\)/, \"()\") # with only parentheses
gsub(/^(${(j:|:)dis_plugins})\)/, \")\") # with BOL and closing parenthesis
gsub(/\((${(j:|:)dis_plugins})$/, \"(\") # with opening parenthesis and EOL
} while (\$0 != prev)
" "
# Disable plugins awk script # Disable plugins awk script
@@ -392,8 +448,8 @@ function _omz::plugin::enable {
# Enable plugins awk script # Enable plugins awk script
local awk_script=" local awk_script="
# if plugins=() is in oneline form, substitute ) with new plugins and go to the next line # if plugins=() is in oneline form (empty or not), substitute ) with new plugins and go to the next line
/^[ \t]*plugins=\([^#]+\).*\$/ { /^[ \t]*plugins=\([^#]*\).*\$/ {
sub(/\)/, \" $add_plugins&\") sub(/\)/, \" $add_plugins&\")
print \$0 print \$0
next next
@@ -773,10 +829,10 @@ function _omz::pr::test {
function _omz::shop { function _omz::shop {
local shop_url="https://commitgoods.com/collections/oh-my-zsh" local shop_url="https://commitgoods.com/collections/oh-my-zsh"
_omz::log info "Opening Oh My Zsh shop in your browser..." _omz::log info "Opening Oh My Zsh shop in your browser..."
_omz::log info "$shop_url" _omz::log info "$shop_url"
open_command "$shop_url" open_command "$shop_url"
} }
+33
View File
@@ -16,6 +16,12 @@
# - doitclient (for SSH) http://www.chiark.greenend.org.uk/~sgtatham/doit/ # - doitclient (for SSH) http://www.chiark.greenend.org.uk/~sgtatham/doit/
# - win32yank (Windows) # - win32yank (Windows)
# - tmux (if $TMUX is set) # - tmux (if $TMUX is set)
# - OSC 52 (when no clipboard tool is available, e.g. over SSH or in a container)
#
# Set ZSH_CLIPBOARD_OSC52 to "always" to copy through OSC 52 even if a
# clipboard tool is available, or to "never" to disable the fallback.
# OSC 52 copies larger than 100 KB (after base64 encoding) fail with an error,
# since many terminals drop or truncate payloads that size.
# #
# Defines two functions, clipcopy and clippaste, based on the detected platform. # Defines two functions, clipcopy and clippaste, based on the detected platform.
## ##
@@ -48,6 +54,26 @@
# # Paste to a file # # Paste to a file
# clippaste > file.txt # clippaste > file.txt
# #
function _has_osc52_clipboard() {
[[ -n "${TTY:-}" ]] && [[ -w "${TTY}" ]] && (( ${+commands[base64]} ))
}
function _clipcopy_osc52() {
emulate -L zsh
local content
content=$(cat "${1:-/dev/stdin}" | base64 | tr -d '\n') || return 1
if (( ${#content} > 100000 )); then
print "clipcopy: too large for OSC 52 (${#content} bytes encoded, limit 100000)" >&2
return 1
fi
print -rn -- $'\e]52;c;'"${content}"$'\e\\' > /dev/tty
}
function _clippaste_osc52() {
print 'clippaste: OSC 52 is write-only and no other clipboard tool was found' >&2
return 1
}
function detect-clipboard() { function detect-clipboard() {
emulate -L zsh emulate -L zsh
@@ -87,6 +113,9 @@ function detect-clipboard() {
elif [ -n "${TMUX:-}" ] && (( ${+commands[tmux]} )); then elif [ -n "${TMUX:-}" ] && (( ${+commands[tmux]} )); then
function clipcopy() { tmux load-buffer -w "${1:--}"; } function clipcopy() { tmux load-buffer -w "${1:--}"; }
function clippaste() { tmux save-buffer -; } function clippaste() { tmux save-buffer -; }
elif [[ "${ZSH_CLIPBOARD_OSC52:-}" != never ]] && _has_osc52_clipboard; then
function clipcopy() { _clipcopy_osc52 "$@"; }
function clippaste() { _clippaste_osc52; }
else else
function _retry_clipboard_detection_or_fail() { function _retry_clipboard_detection_or_fail() {
local clipcmd="${1}"; shift local clipcmd="${1}"; shift
@@ -101,6 +130,10 @@ function detect-clipboard() {
function clippaste() { _retry_clipboard_detection_or_fail clippaste "$@"; } function clippaste() { _retry_clipboard_detection_or_fail clippaste "$@"; }
return 1 return 1
fi fi
if [[ "${ZSH_CLIPBOARD_OSC52:-}" == always ]] && _has_osc52_clipboard; then
function clipcopy() { _clipcopy_osc52 "$@"; }
fi
} }
function clipcopy clippaste { function clipcopy clippaste {
+4 -4
View File
@@ -237,9 +237,10 @@ function _omz_diag_dump_one_big_text() {
fi fi
builtin echo builtin echo
builtin echo "Zsh compdump files:" builtin echo "Zsh compdump files:"
local dumpfile dumpfiles local dumpfile
command ls -lad $zdotdir/.zcompdump* local -U dumpfiles
dumpfiles=( $zdotdir/.zcompdump*(N) ) dumpfiles=( $zdotdir/.zcompdump*(N) ${ZSH_COMPDUMP:h}/.zcompdump*(N) )
(( $#dumpfiles )) && command ls -lad $dumpfiles
if [[ $verbose -ge 2 ]]; then if [[ $verbose -ge 2 ]]; then
for dumpfile in $dumpfiles; do for dumpfile in $dumpfiles; do
_omz_diag_dump_echo_file_w_header $dumpfile _omz_diag_dump_echo_file_w_header $dumpfile
@@ -350,4 +351,3 @@ function _omz_diag_dump_os_specific_version() {
builtin echo builtin echo
done done
} }
+1 -1
View File
@@ -231,7 +231,7 @@ function omz_urlencode() {
url_str+="$byte" url_str+="$byte"
else else
ord=$(( [##16] #byte )) ord=$(( [##16] #byte ))
url_str+="%$ord" url_str+="%${(l:2::0:)ord}"
fi fi
fi fi
done done
+11
View File
@@ -2,6 +2,8 @@
# P.C. Shyamshankar <sykora@lucentbeing.com> # P.C. Shyamshankar <sykora@lucentbeing.com>
# Copied from https://github.com/sykora/etc/blob/master/zsh/functions/spectrum/ # Copied from https://github.com/sykora/etc/blob/master/zsh/functions/spectrum/
autoload -Uz is-at-least
typeset -AHg FX FG BG typeset -AHg FX FG BG
FX=( FX=(
@@ -18,7 +20,16 @@ FX=(
() { () {
setopt localoptions noksharrays setopt localoptions noksharrays
local -a codes fg bg local -a codes fg bg
local code
codes=({000..255}) codes=({000..255})
# ${a:^b} array zipping needs zsh 5.0.6
if ! is-at-least 5.0.6; then
for code in $codes; do
FG[$code]="%{"$'\e'"[38;5;${code}m%}"
BG[$code]="%{"$'\e'"[48;5;${code}m%}"
done
return
fi
fg=( "%{"$'\e'"[38;5;"${^codes}"m%}" ) fg=( "%{"$'\e'"[38;5;"${^codes}"m%}" )
bg=( "%{"$'\e'"[48;5;"${^codes}"m%}" ) bg=( "%{"$'\e'"[48;5;"${^codes}"m%}" )
FG=( ${codes:^fg} ) FG=( ${codes:^fg} )
+14 -7
View File
@@ -154,16 +154,23 @@ esac
# the host name to disambiguate local vs. remote paths. # the host name to disambiguate local vs. remote paths.
function omz_termsupport_cwd { function omz_termsupport_cwd {
setopt localoptions unset setopt localoptions unset
# Percent-encode the host and path names. # Percent-encode the host and path names. Encoding forks a subshell each,
local URL_HOST URL_PATH # so keep the result and only redo it when its inputs change.
URL_HOST="$(omz_urlencode -P $HOST)" || return 1 local cache_key="$HOST:$PWD:${langinfo[CODESET]}:${KONSOLE_PROFILE_NAME:+1}:${KONSOLE_DBUS_SESSION:+1}"
URL_PATH="$(omz_urlencode -P $PWD)" || return 1 if [[ "$_omz_termsupport_cwd_key" != "$cache_key" ]]; then
local URL_HOST URL_PATH
URL_HOST="$(omz_urlencode -P "$HOST")" || return 1
URL_PATH="$(omz_urlencode -P "$PWD")" || return 1
# Konsole errors if the HOST is provided # Konsole errors if the HOST is provided
[[ -z "$KONSOLE_PROFILE_NAME" && -z "$KONSOLE_DBUS_SESSION" ]] || URL_HOST="" [[ -z "$KONSOLE_PROFILE_NAME" && -z "$KONSOLE_DBUS_SESSION" ]] || URL_HOST=""
typeset -g _omz_termsupport_cwd_key="$cache_key"
typeset -g _omz_termsupport_cwd_url="file://${URL_HOST}${URL_PATH}"
fi
# common control sequence (OSC 7) to set current host and path # common control sequence (OSC 7) to set current host and path
printf "\e]7;file://%s%s\e\\" "${URL_HOST}" "${URL_PATH}" printf "\e]7;%s\e\\" "$_omz_termsupport_cwd_url"
} }
# Use a precmd hook instead of a chpwd hook to avoid contaminating output # Use a precmd hook instead of a chpwd hook to avoid contaminating output
+43 -8
View File
@@ -7,16 +7,20 @@ run_awk() {
(( ! DEBUG )) || set -xv (( ! DEBUG )) || set -xv
local awk_subst_plugins="\ local awk_subst_plugins="\
gsub(/[ \t]+(${(j:|:)dis_plugins})[ \t]+/, \" \") # with spaces before or after do {
gsub(/[ \t]+(${(j:|:)dis_plugins})$/, \"\") # with spaces before and EOL prev = \$0
gsub(/^(${(j:|:)dis_plugins})[ \t]+/, \"\") # with BOL and spaces after
gsub(/\((${(j:|:)dis_plugins})[ \t]+/, \"(\") # with parenthesis before and spaces after gsub(/[ \t]+(${(j:|:)dis_plugins})[ \t]+/, \" \") # with spaces before or after
gsub(/[ \t]+(${(j:|:)dis_plugins})\)/, \")\") # with spaces before or parenthesis after gsub(/[ \t]+(${(j:|:)dis_plugins})$/, \"\") # with spaces before and EOL
gsub(/\((${(j:|:)dis_plugins})\)/, \"()\") # with only parentheses gsub(/^(${(j:|:)dis_plugins})[ \t]+/, \"\") # with BOL and spaces after
gsub(/^(${(j:|:)dis_plugins})\)/, \")\") # with BOL and closing parenthesis gsub(/\((${(j:|:)dis_plugins})[ \t]+/, \"(\") # with parenthesis before and spaces after
gsub(/\((${(j:|:)dis_plugins})$/, \"(\") # with opening parenthesis and EOL gsub(/[ \t]+(${(j:|:)dis_plugins})\)/, \")\") # with spaces before or parenthesis after
gsub(/\((${(j:|:)dis_plugins})\)/, \"()\") # with only parentheses
gsub(/^(${(j:|:)dis_plugins})\)/, \")\") # with BOL and closing parenthesis
gsub(/\((${(j:|:)dis_plugins})$/, \"(\") # with opening parenthesis and EOL
} while (\$0 != prev)
" "
# Disable plugins awk script # Disable plugins awk script
local awk_script=" local awk_script="
@@ -167,3 +171,34 @@ z)" \
"plugins=( "plugins=(
git git
)" )"
run_awk_and_test \
"it should delete two adjacent plugins among others in oneline format" \
"docker kubectl" \
"plugins=(git docker kubectl npm)" \
"plugins=(git npm)"
run_awk_and_test \
"it should delete three adjacent plugins among others in oneline format" \
"docker kubectl aws" \
"plugins=(git docker kubectl aws npm)" \
"plugins=(git npm)"
run_awk_and_test \
"it should delete every plugin of a long oneline list" \
"git docker kubectl aws npm z" \
"plugins=(git docker kubectl aws npm z)" \
"plugins=()"
run_awk_and_test \
"it should delete adjacent plugins sharing a line in multiline format" \
"docker kubectl aws" \
"plugins=(
git
docker kubectl aws
npm
)" \
"plugins=(
git
npm
)"
+42 -11
View File
@@ -38,16 +38,47 @@
# due to malicious input as a consequence of CVE-2021-45444, which affects # due to malicious input as a consequence of CVE-2021-45444, which affects
# zsh versions from 5.0.3 to 5.8. # zsh versions from 5.0.3 to 5.8.
# #
autoload -Uz +X regexp-replace VCS_INFO_formats 2>/dev/null || return 0 # The patch is applied when VCS_INFO_formats is first called, since loading
# and patching it on every startup costs time in shells that never use
# vcs_info. `autoload` doesn't replace an already defined function, so this
# wrapper survives a later `autoload -Uz vcs_info` in a theme or .zshrc, and
# vcs_info's own `autoload -Uz VCS_INFO_formats`.
function _omz_patch_vcs_info_formats {
local formatter
if (( $# )); then
formatter="$1"
else
# Load in a subshell so the wrapper stays installed if loading fails.
formatter="$(
unfunction VCS_INFO_formats 2>/dev/null
autoload -Uz +X VCS_INFO_formats 2>/dev/null || return 1
print -r -- "$functions[VCS_INFO_formats]"
)" || return 1
fi
# We use $tmp here because it's already a local variable in VCS_INFO_formats # We use $tmp here because it's already a local variable in VCS_INFO_formats.
typeset PATCH='for tmp (base base-name branch misc revision subdir) hook_com[$tmp]="${hook_com[$tmp]//\%/%%}"' local patch='for tmp (base base-name branch misc revision subdir) hook_com[$tmp]="${hook_com[$tmp]//\%/%%}"'
# Unique string to avoid reapplying the patch if this code gets called twice local patch_id=vcs_info-patch-9b9840f2-91e5-4471-af84-9e9a0dc68c1b
typeset PATCH_ID=vcs_info-patch-9b9840f2-91e5-4471-af84-9e9a0dc68c1b local post_backend="VCS_INFO_hook 'post-backend'"
# Only patch the VCS_INFO_formats function if not already patched if [[ $formatter != *"$patch_id"* ]]; then
if [[ "$functions[VCS_INFO_formats]" != *$PATCH_ID* ]]; then [[ $formatter == *"$post_backend"* ]] || return 1
regexp-replace 'functions[VCS_INFO_formats]' \ local replacement=": $patch_id; $patch; $post_backend"
"VCS_INFO_hook 'post-backend'" \ formatter="${formatter//"$post_backend"/$replacement}"
': ${PATCH_ID}; ${PATCH}; ${MATCH}' fi
[[ $formatter != "$functions[VCS_INFO_formats]" ]] || return 0
# Assigning to functions reparses the body. Preserve autoload -U behavior.
setopt localoptions noaliases
functions[VCS_INFO_formats]="$formatter"
}
# An autoload stub counts as not loaded yet, so it gets the wrapper too.
if (( $+functions[VCS_INFO_formats] )) && [[ $functions[VCS_INFO_formats] != 'builtin autoload -X'* ]]; then
# A custom formatter may lack the stock hook call.
_omz_patch_vcs_info_formats "$functions[VCS_INFO_formats]" || true
else
function VCS_INFO_formats {
_omz_patch_vcs_info_formats || return 1
VCS_INFO_formats "$@"
}
fi fi
unset PATCH PATCH_ID
+10 -2
View File
@@ -128,7 +128,7 @@ fi
# Save the location of the current completion dump file. # Save the location of the current completion dump file.
if [[ -z "$ZSH_COMPDUMP" ]]; then if [[ -z "$ZSH_COMPDUMP" ]]; then
ZSH_COMPDUMP="${ZDOTDIR:-$HOME}/.zcompdump-${SHORT_HOST}-${ZSH_VERSION}" ZSH_COMPDUMP="${ZSH_CACHE_DIR}/.zcompdump-${SHORT_HOST}-${ZSH_VERSION}"
fi fi
# Resolve the commit $ZSH is checked out at into $REPLY by reading the git # Resolve the commit $ZSH is checked out at into $REPLY by reading the git
@@ -232,12 +232,20 @@ fi
if [[ "$ZSH_DISABLE_COMPFIX" != true ]]; then if [[ "$ZSH_DISABLE_COMPFIX" != true ]]; then
source "$ZSH/lib/compfix.zsh" source "$ZSH/lib/compfix.zsh"
# Keep the original search path for the warning because compinit can prune it.
_omz_compfix_fpath=("${fpath[@]}")
# Load only from secure directories # Load only from secure directories
# Reset the flag compinit sets when -i excludes insecure entries # Reset the flag compinit sets when -i excludes insecure entries
unset _comp_secure unset _comp_secure
compinit -i -d "$ZSH_COMPDUMP" compinit -i -d "$ZSH_COMPDUMP"
# If completion insecurities exist, warn the user # If completion insecurities exist, warn the user
[[ "$_comp_secure" == yes ]] && handle_completion_insecurities &| if [[ "$_comp_secure" == yes ]]; then
{
fpath=("${_omz_compfix_fpath[@]}")
handle_completion_insecurities
} &|
fi
unset _omz_compfix_fpath
else else
# If the user wants it, load from all found directories # If the user wants it, load from all found directories
compinit -u -d "$ZSH_COMPDUMP" compinit -u -d "$ZSH_COMPDUMP"
+2
View File
@@ -58,6 +58,8 @@ Running the shortest `gs` shell alias that it found:
![image](https://github.com/ohmyzsh/ohmyzsh/assets/19378/39642750-fb10-4f1a-b7f9-f36789eeb01b) ![image](https://github.com/ohmyzsh/ohmyzsh/assets/19378/39642750-fb10-4f1a-b7f9-f36789eeb01b)
It also looks through aliases you type, suggesting only ones that cover more of the command. With the kubectl plugin, `k get pods` suggests `kgp`, while `kgp` on its own suggests nothing.
### Options ### Options
+13 -2
View File
@@ -65,9 +65,20 @@ alias-finder() {
preexec_alias-finder() { preexec_alias-finder() {
# TODO: Remove backward compatibility (other than zstyle form) # TODO: Remove backward compatibility (other than zstyle form)
zstyle -t ':omz:plugins:alias-finder' autoload && alias-finder $1 || if [[ $ZSH_ALIAS_FINDER_AUTOMATIC = true ]]; then zstyle -t ':omz:plugins:alias-finder' autoload || [[ $ZSH_ALIAS_FINDER_AUTOMATIC = true ]] || return
alias-finder $1
# $3 has aliases expanded, so `k get pods` can suggest `kgp`
local -a words=(${(z)1}) found=(${(f)"$(alias-finder $3)"}) keep
local used=${aliases[$words[1]]} line
# If an alias was typed, only suggest aliases that cover more of the command
if [[ -n "$used" ]]; then
for line in $found; do
(( ${#${(Q)line#*=}} > ${#used} )) && keep+=("$line")
done
found=($keep)
fi fi
(( $#found )) && print -rl -- $found
} }
autoload -U add-zsh-hook autoload -U add-zsh-hook
+34 -8
View File
@@ -103,10 +103,34 @@ upgrades were available. Use `pacman -Que` instead.
| parep | `pacaur -Si` | Display information about a package in the repositories | | parep | `pacaur -Si` | Display information about a package in the repositories |
| pareps | `pacaur -Ss` | Search for packages in the repositories | | pareps | `pacaur -Ss` | Search for packages in the repositories |
| paupd | `pacaur -Sy` | Update and refresh local package, ABS and AUR databases | | paupd | `pacaur -Sy` | Update and refresh local package, ABS and AUR databases |
| paupg | `pacaur -Syua` | Sync with repositories before upgrading all packages (from AUR too) | | paupg | `pacaur -Syu` | Sync with repositories before upgrading all packages (from AUR too) |
| pasu | `pacaur -Syua --no-confirm` | Same as `paupg`, but without confirmation | | pasu | `pacaur -Syu --noconfirm` | Same as `paupg`, but without confirmation |
| upgrade[¹](#f1) | `pacaur -Syu` | Sync with repositories before upgrading packages | | upgrade[¹](#f1) | `pacaur -Syu` | Sync with repositories before upgrading packages |
#### Paru
| Alias | Command | Description |
|---------|--------------------------------|-------------------------------------------------------------------|
| puclean | `paru -Sc` | Clean out old and unused caches and packages |
| puclr | `paru -Scc` | Remove all files from the cache |
| pufiles | `paru -F` | Search the files database for packages that contain a file |
| puin | `paru -S` | Install packages from the repositories |
| puins | `paru -U` | Install a package from a local file |
| puinsd | `paru -S --asdeps` | Install packages as dependencies of another package |
| puloc | `paru -Qi` | Display information about a package in the local database |
| pulocs | `paru -Qs` | Search for packages in the local database |
| pulst | `paru -Qe` | List installed packages including from AUR (tagged as "local") |
| pumir | `paru -Syy` | Force refresh of all package lists after updating mirrorlist |
| puorph | `paru -Qtd` | List orphaned packages |
| pure | `paru -R` | Remove packages, keeping its settings and dependencies |
| purem | `paru -Rns` | Remove packages, including its settings and unneeded dependencies |
| purep | `paru -Si` | Display information about a package in the repositories |
| pureps | `paru -Ss` | Search for packages in the repositories |
| puupd | `paru -Sy` | Update and refresh local package, ABS and AUR databases |
| puupg | `paru -Syu` | Sync with repositories before upgrading packages |
| pusu | `paru -Syu --noconfirm` | Same as `puupg`, but without confirmation |
| upgrade[¹](#f1) | `paru -Syu` | Sync with repositories before upgrading packages |
#### Trizen #### Trizen
| Alias | Command | Description | | Alias | Command | Description |
@@ -128,7 +152,7 @@ upgrades were available. Use `pacman -Que` instead.
| trreps | `trizen -Ss` | Search for packages in the repositories | | trreps | `trizen -Ss` | Search for packages in the repositories |
| trupd | `trizen -Sy` | Update and refresh local package, ABS and AUR databases | | trupd | `trizen -Sy` | Update and refresh local package, ABS and AUR databases |
| trupg | `trizen -Syua` | Sync with repositories before upgrading all packages (from AUR too) | | trupg | `trizen -Syua` | Sync with repositories before upgrading all packages (from AUR too) |
| trsu | `trizen -Syua --no-confirm` | Same as `trupg`, but without confirmation | | trsu | `trizen -Syua --noconfirm` | Same as `trupg`, but without confirmation |
| upgrade[¹](#f1) | `trizen -Syu` | Sync with repositories before upgrading packages | | upgrade[¹](#f1) | `trizen -Syu` | Sync with repositories before upgrading packages |
#### Yay #### Yay
@@ -152,7 +176,7 @@ upgrades were available. Use `pacman -Que` instead.
| yareps | `yay -Ss` | Search for packages in the repositories | | yareps | `yay -Ss` | Search for packages in the repositories |
| yaupd | `yay -Sy` | Update and refresh local package, ABS and AUR databases | | yaupd | `yay -Sy` | Update and refresh local package, ABS and AUR databases |
| yaupg | `yay -Syu` | Sync with repositories before upgrading packages | | yaupg | `yay -Syu` | Sync with repositories before upgrading packages |
| yasu | `yay -Syu --no-confirm` | Same as `yaupg`, but without confirmation | | yasu | `yay -Syu --noconfirm` | Same as `yaupg`, but without confirmation |
| upgrade[¹](#f1) | `yay -Syu` | Sync with repositories before upgrading packages | | upgrade[¹](#f1) | `yay -Syu` | Sync with repositories before upgrading packages |
--- ---
@@ -163,9 +187,10 @@ whether the package manager is installed, checked in the following order:
1. `yay` 1. `yay`
2. `trizen` 2. `trizen`
3. `pacaur` 3. `paru`
4. `aura` 4. `pacaur`
5. `pacman` 5. `aura`
6. `pacman`
## Contributors ## Contributors
@@ -181,4 +206,5 @@ whether the package manager is installed, checked in the following order:
- Ybalrid (Arthur Brainville) - ybalrid@ybalrid.info - Ybalrid (Arthur Brainville) - ybalrid@ybalrid.info
- Jeff M. Hubbard - jeffmhubbard@gmail.com - Jeff M. Hubbard - jeffmhubbard@gmail.com
- K. Harishankar(harishnkr) - hari2menon1234@gmail.com - K. Harishankar(harishnkr) - hari2menon1234@gmail.com
- WH-2099 - wh2099@outlook.com - WH-2099 - wh2099@outlook.com
- Boris Frenkel - fobos2k@gmail.com
+23
View File
@@ -134,6 +134,27 @@ if (( $+commands[pacaur] )); then
alias paupd="pacaur -Sy" alias paupd="pacaur -Sy"
fi fi
if (( $+commands[paru] )); then
alias puclean='paru -Sc'
alias puclr='paru -Scc'
alias pufiles='paru -F'
alias puin='paru -S'
alias puins='paru -U'
alias puinsd='paru -S --asdeps'
alias puloc='paru -Qi'
alias pulocs='paru -Qs'
alias pulst='paru -Qe'
alias pumir='paru -Syy'
alias puorph='paru -Qtd'
alias pure='paru -R'
alias purem='paru -Rns'
alias purep='paru -Si'
alias pureps='paru -Ss'
alias puupd='paru -Sy'
alias puupg='paru -Syu'
alias pusu='paru -Syu --noconfirm'
fi
if (( $+commands[trizen] )); then if (( $+commands[trizen] )); then
alias trconf='trizen -C' alias trconf='trizen -C'
alias trupg='trizen -Syua' alias trupg='trizen -Syua'
@@ -194,6 +215,8 @@ function upgrade() {
yay -Su yay -Su
elif (( $+commands[trizen] )); then elif (( $+commands[trizen] )); then
trizen -Su trizen -Su
elif (( $+commands[paru] )); then
paru -Su
elif (( $+commands[pacaur] )); then elif (( $+commands[pacaur] )); then
pacaur -Su pacaur -Su
elif (( $+commands[aura] )); then elif (( $+commands[aura] )); then
+11 -14
View File
@@ -247,20 +247,17 @@ function aws_profiles() {
aws --no-cli-pager configure list-profiles 2> /dev/null aws --no-cli-pager configure list-profiles 2> /dev/null
return return
fi fi
local file line words local line words
for file in "$config" "$creds"; do # Only read the section headers, so the credentials never enter the shell
# Only read the section headers, so the credentials never enter the shell for line in "${(@f)$(command grep -h '^[[:space:]]*\[' -- "$config" "$creds" 2> /dev/null)}"; do
for line in "${(@f)$(command grep '^[[:space:]]*\[' -- "$file" 2> /dev/null)}"; do line=${line#*\[} # drop up to the first [
line=${line#*\[} # drop up to the first [ line=${line%\]*} # drop from the last ] (comments, CR)
line=${line%\]*} # drop from the last ] (comments, CR) words=(${=line})
words=(${=line}) if (( $#words == 1 )); then
if (( $#words == 1 )); then print -r -- $words[1] # [default], or [foo] in the credentials file
# [default], or any [foo] in the credentials file elif (( $#words == 2 )) && [[ $words[1] == profile ]]; then
[[ $file == $creds || $words[1] == default ]] && print -r -- $words[1] print -r -- $words[2]
elif (( $#words == 2 )) && [[ $words[1] == profile ]]; then fi
print -r -- $words[2]
fi
done
done | command sort -u done | command sort -u
} }
+1 -1
View File
@@ -59,7 +59,7 @@ ensures the `bdr` alias runs without warnings.
| `bsra` | `bsr --all` | Run all stopped services. | | `bsra` | `bsr --all` | Run all stopped services. |
| `bu` | `brew update` | Update brew and all installed formulae. | | `bu` | `brew update` | Update brew and all installed formulae. |
| `bubo` | `brew update && brew outdated` | Update Homebrew data, then list outdated formulae and casks. | | `bubo` | `brew update && brew outdated` | Update Homebrew data, then list outdated formulae and casks. |
| `bubu` | `bubo && bup` | Do the last two operations above. | | `bubu` | `bu && bup` | Update Homebrew data, then upgrade outdated, unpinned brews. |
| `bugbc` | `brew upgrade --greedy && brew cleanup` | Upgrade outdated formulae and casks (greedy), then run cleanup. | | `bugbc` | `brew upgrade --greedy && brew cleanup` | Upgrade outdated formulae and casks (greedy), then run cleanup. |
| `bup` | `brew upgrade` | Upgrade outdated, unpinned brews. | | `bup` | `brew upgrade` | Upgrade outdated, unpinned brews. |
| `buz` | `brew uninstall --zap` | Remove all files associated with a cask. | | `buz` | `brew uninstall --zap` | Remove all files associated with a cask. |
+1 -1
View File
@@ -75,7 +75,7 @@ alias bsr='brew services run'
alias bsra='bsr --all' alias bsra='bsr --all'
alias bu='brew update' alias bu='brew update'
alias bubo='brew update && brew outdated' alias bubo='brew update && brew outdated'
alias bubu='bubo && bup' alias bubu='bu && bup'
alias bubug='bubo && bugbc' alias bubug='bubo && bugbc'
alias bugbc='brew upgrade --greedy && brew cleanup' alias bugbc='brew upgrade --greedy && brew cleanup'
alias bup='brew upgrade' alias bup='brew upgrade'
+1
View File
@@ -90,6 +90,7 @@ colorize_less() {
# (e.g. when not scrolled to the bottom) while already the next file will be displayed. # (e.g. when not scrolled to the bottom) while already the next file will be displayed.
local LESSOPEN="| zsh -c 'source \"$ZSH_COLORIZE_PLUGIN_PATH\"; \ local LESSOPEN="| zsh -c 'source \"$ZSH_COLORIZE_PLUGIN_PATH\"; \
ZSH_COLORIZE_TOOL=$ZSH_COLORIZE_TOOL ZSH_COLORIZE_STYLE=$ZSH_COLORIZE_STYLE \ ZSH_COLORIZE_TOOL=$ZSH_COLORIZE_TOOL ZSH_COLORIZE_STYLE=$ZSH_COLORIZE_STYLE \
ZSH_COLORIZE_CHROMA_FORMATTER=$ZSH_COLORIZE_CHROMA_FORMATTER \
colorize_cat %s 2> /dev/null'" colorize_cat %s 2> /dev/null'"
# LESSCLOSE will be set to prevent any errors by executing a user script # LESSCLOSE will be set to prevent any errors by executing a user script
+11 -3
View File
@@ -1,6 +1,6 @@
# conda plugin # 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). The conda plugin provides [aliases](#aliases) and [completion](#completion) 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: To use it, add `conda` to the plugins array in your zshrc file:
@@ -28,10 +28,18 @@ plugins=(... conda)
| `cnle` | `conda list --export` | Export the list of 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 | | `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 | | `cnr` | `conda remove` | Remove given package |
| `cnrn` | `conda remove -y -all -n` | Remove all packages in the specified environment | | `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 | | `cnrp` | `conda remove -y --all -p` | Remove all packages in the specified prefix |
| `cnry` | `conda remove -y` | Remove given package without confirmation | | `cnry` | `conda remove -y` | Remove given package without confirmation |
| `cnsr` | `conda search` | Search conda repositories for package | | `cnsr` | `conda search` | Search conda repositories for package |
| `cnu` | `conda update` | Update conda package manager | | `cnu` | `conda update` | Update conda package manager |
| `cnua` | `conda update --all` | Update all installed packages | | `cnua` | `conda update --all` | Update all installed packages |
| `cnuc` | `conda update conda` | Update conda package manager | | `cnuc` | `conda update conda` | Update conda package manager |
## Completion
Tab completion is available for the following commands, using the environment list conda keeps in
`~/.conda/environments.txt`:
- `cna`: completes environment names for `conda activate`
- `cnrn`: completes environment names for `conda remove -y --all -n`
+21 -2
View File
@@ -1,4 +1,7 @@
alias cna='conda activate' unalias cna cnrn 2>/dev/null
cna() { conda activate "$@"; }
cnrn() { conda remove -y --all -n "$@"; }
alias cnab='conda activate base' alias cnab='conda activate base'
alias cncf='conda env create -f' alias cncf='conda env create -f'
alias cncn='conda create -y -n' alias cncn='conda create -y -n'
@@ -14,10 +17,26 @@ alias cnl='conda list'
alias cnle='conda list --export' alias cnle='conda list --export'
alias cnles='conda list --explicit > spec-file.txt' alias cnles='conda list --explicit > spec-file.txt'
alias cnr='conda remove' alias cnr='conda remove'
alias cnrn='conda remove -y --all -n'
alias cnrp='conda remove -y --all -p' alias cnrp='conda remove -y --all -p'
alias cnry='conda remove -y' alias cnry='conda remove -y'
alias cnsr='conda search' alias cnsr='conda search'
alias cnu='conda update' alias cnu='conda update'
alias cnua='conda update --all' alias cnua='conda update --all'
alias cnuc='conda update conda' alias cnuc='conda update conda'
_omz_conda_envs() {
emulate -L zsh -o extended_glob
local envs_file="$HOME/.conda/environments.txt"
[[ -r "$envs_file" ]] || return 1
# Each line is an env prefix; named envs live under <dir>/envs/<name>.
# The root prefix (base) and envs created with -p have no name and are skipped.
local -aU envs
envs=(${(f)"$(<$envs_file)"})
envs=(${${(M)envs:#*/envs/[^/]##}:t})
(( ${#envs} )) && compadd -Q -a envs
}
if (( $+functions[compdef] )); then
compdef _omz_conda_envs cna cnrn
fi
+2 -2
View File
@@ -263,9 +263,9 @@ _dotenv_check_syntax() {
local filename="$1" local filename="$1"
if (( $# == 2 )); then if (( $# == 2 )); then
printf '%s' "$2" | zsh -fn /dev/stdin printf '%s' "$2" | command zsh -fn /dev/stdin
else else
zsh -fn -- "$filename" command zsh -fn -- "$filename"
fi || { fi || {
echo "dotenv: error when sourcing '$filename' file" >&2 echo "dotenv: error when sourcing '$filename' file" >&2
return 1 return 1
+3
View File
@@ -45,9 +45,12 @@ plugins=(... extract)
| `tar.lrz` | Tarball with lrzip compression | | `tar.lrz` | Tarball with lrzip compression |
| `tar.lz` | Tarball with lzip compression | | `tar.lz` | Tarball with lzip compression |
| `tar.lz4` | Tarball with lz4 compression | | `tar.lz4` | Tarball with lz4 compression |
| `tar.lzma` | Tarball with lzma compression |
| `tar.xz` | Tarball with lzma2 compression | | `tar.xz` | Tarball with lzma2 compression |
| `tar.zma` | Tarball with lzma compression | | `tar.zma` | Tarball with lzma compression |
| `tar.zst` | Tarball with zstd compression | | `tar.zst` | Tarball with zstd compression |
| `tar.Z` | Tarball with compress (LZW) compression |
| `taz` | Tarball with compress (LZW) compression |
| `tbz` | Tarball with bzip compression | | `tbz` | Tarball with bzip compression |
| `tbz2` | Tarball with bzip2 compression | | `tbz2` | Tarball with bzip2 compression |
| `tgz` | Tarball with gzip compression | | `tgz` | Tarball with gzip compression |
+1
View File
@@ -31,6 +31,7 @@ local -a exts=(
tar.lrz tar.lrz
tar.lz tar.lz
tar.lz4 tar.lz4
tar.lzma
tar.xz tar.xz
tar.zma tar.zma
tar.zst tar.zst
+40 -4
View File
@@ -88,7 +88,7 @@ EOF
tar --xz --help &> /dev/null \ tar --xz --help &> /dev/null \
&& tar --xz -xvf "$full_path" \ && tar --xz -xvf "$full_path" \
|| xzcat "$full_path" | tar xvf - } ;; || xzcat "$full_path" | tar xvf - } ;;
(*.tar.zma|*.tlz) (*.tar.lzma|*.tar.zma|*.tlz)
tar --lzma --help &> /dev/null \ tar --lzma --help &> /dev/null \
&& tar --lzma -xvf "$full_path" \ && tar --lzma -xvf "$full_path" \
|| lzcat "$full_path" | tar xvf - ;; || lzcat "$full_path" | tar xvf - ;;
@@ -97,6 +97,11 @@ EOF
&& tar --zstd -xvf "$full_path" \ && tar --zstd -xvf "$full_path" \
|| zstdcat "$full_path" | tar xvf - ;; || zstdcat "$full_path" | tar xvf - ;;
(*.tar) tar xvf "$full_path" ;; (*.tar) tar xvf "$full_path" ;;
# `tar cf - dir | compress > dir.tar.Z`: the plain `.Z` arm below only decompresses the
# stream back to `dir.tar`, so the combined form has to untar it in one step. `.taz` is the
# historic name for the same file, next to `.tgz`/`.tbz`/`.tlz`/`.txz`/`.tzst`. Matching is
# on the lowercased name, so `.tar.Z` lands here too.
(*.tar.z|*.taz) uncompress -c "$full_path" | tar xvf - ;;
(*.tar.lz) (( $+commands[lzip] )) && tar xvf "$full_path" ;; (*.tar.lz) (( $+commands[lzip] )) && tar xvf "$full_path" ;;
(*.tar.lz4) lz4 -c -d "$full_path" | tar xvf - ;; (*.tar.lz4) lz4 -c -d "$full_path" | tar xvf - ;;
(*.tar.lrz) (( $+commands[lrzuntar] )) && lrzuntar "$full_path" ;; (*.tar.lrz) (( $+commands[lrzuntar] )) && lrzuntar "$full_path" ;;
@@ -135,9 +140,40 @@ EOF
(*.deb) (*.deb)
command mkdir -p "control" "data" command mkdir -p "control" "data"
ar vx "$full_path" > /dev/null ar vx "$full_path" > /dev/null
builtin cd -q control; extract ../control.tar.* local member= dest= failed=0
builtin cd -q ../data; extract ../data.tar.* for member in control.tar.* data.tar.*; do
builtin cd -q ..; command rm *.tar.* debian-binary ;; dest="${member%%.*}"
case "${member:l}" in
(*.tar.gz)
(( $+commands[pigz] )) && { tar -I pigz -xvf "$member" -C "$dest" } \
|| tar zxvf "$member" -C "$dest" ;;
(*.tar.bz2)
(( $+commands[pbzip2] )) && { tar -I pbzip2 -xvf "$member" -C "$dest" } \
|| tar xvjf "$member" -C "$dest" ;;
(*.tar.xz)
# .deb members are small, so skip extract()'s pixz fast path and
# let tar use its built-in xz support (or a plain pipe).
tar --xz --help &> /dev/null \
&& tar --xz -xvf "$member" -C "$dest" \
|| xzcat "$member" | tar xvf - -C "$dest" ;;
(*.tar.zst)
tar --zstd --help &> /dev/null \
&& tar --zstd -xvf "$member" -C "$dest" \
|| zstdcat "$member" | tar xvf - -C "$dest" ;;
(*.tar)
tar xvf "$member" -C "$dest" ;;
(*)
echo "extract: cannot extract unexpected .deb member '$member'" >&2
failed=1
success=1 ;;
esac
done
if (( failed )); then
# Keep the archive members so the unexpected one can be inspected.
echo "extract: leaving .deb members in place" >&2
else
command rm *.tar.* debian-binary
fi ;;
(*.zst) unzstd --stdout "$full_path" > "${file:t:r}" ;; (*.zst) unzstd --stdout "$full_path" > "${file:t:r}" ;;
(*.cab|*.exe) cabextract "$full_path" ;; (*.cab|*.exe) cabextract "$full_path" ;;
(*.cpio|*.obscpio) cpio -idmvF "$full_path" ;; (*.cpio|*.obscpio) cpio -idmvF "$full_path" ;;
+125 -2
View File
@@ -4,7 +4,7 @@
emulate -L zsh emulate -L zsh
setopt err_return setopt err_return
for tool in lzma unlzma uncompress; do for tool in ar lzma unlzma uncompress; do
(( $+commands[$tool] )) || { (( $+commands[$tool] )) || {
print -u2 -r -- "These tests require $tool." print -u2 -r -- "These tests require $tool."
exit 1 exit 1
@@ -46,6 +46,120 @@ check_extract() {
print -r -- "PASS: $extension ($mode)" print -r -- "PASS: $extension ($mode)"
} }
# Extracting a .deb must place the control members directly in <name>/control
# and the data members directly in <name>/data, whatever their member count.
check_deb_extract() {
local mode=$1
local case_dir="$test_dir/deb-$mode"
mkdir -p "$case_dir/source files" "$case_dir/work/target dir" \
"$case_dir/src/ctl" "$case_dir/src/data/usr/bin"
print -r -- "postinst script" > "$case_dir/src/ctl/postinst"
print -r -- "conf:1" > "$case_dir/src/ctl/conffiles"
print -r -- "app main" > "$case_dir/src/data/usr/bin/app"
tar czf "$case_dir/src/control.tar.gz" -C "$case_dir/src/ctl" conffiles postinst
tar czf "$case_dir/src/data.tar.gz" -C "$case_dir/src/data" usr
print -r -- "2.0" > "$case_dir/src/debian-binary"
(
builtin cd "$case_dir/src"
rm -f "$case_dir/source files/pkg.deb"
ar rS "$case_dir/source files/pkg.deb" debian-binary control.tar.gz data.tar.gz
)
local archive="$case_dir/source files/pkg.deb"
builtin cd "$case_dir/work"
local base="$PWD/pkg"
local -a args
case "$mode" in
target)
args=(-t 'target dir')
base="$PWD/target dir/pkg"
;;
remove) args=(-r) ;;
esac
() {
emulate -L zsh
extract "${args[@]}" "$archive"
} || return 1
[[ -f "$base/control/conffiles" && -f "$base/control/postinst" ]] ||
{ print -u2 -r -- "$mode: control members not extracted into $base/control"; return 1 }
[[ -f "$base/data/usr/bin/app" ]] ||
{ print -u2 -r -- "$mode: data members not extracted into $base/data"; return 1 }
[[ ! -d "$base/control/control" && ! -d "$base/data/data" ]] ||
{ print -u2 -r -- "$mode: deb extraction double-nested the member directories"; return 1 }
[[ ! -e "$base/control.tar.gz" && ! -e "$base/data.tar.gz" && ! -e "$base/debian-binary" ]] ||
{ print -u2 -r -- "$mode: deb member debris left behind"; return 1 }
if [[ $mode == remove ]]; then
[[ ! -e $archive ]]
else
[[ -f $archive ]]
fi
print -r -- "PASS: deb ($mode)"
}
# An unexpected member must be reported and left on disk for inspection, and
# the cleanup must not delete the other members around it either.
check_deb_unexpected_member() {
local case_dir="$test_dir/deb-unexpected"
mkdir -p "$case_dir/src/ctl" "$case_dir/src/data/usr/bin"
print -r -- "postinst script" > "$case_dir/src/ctl/postinst"
print -r -- "app main" > "$case_dir/src/data/usr/bin/app"
tar czf "$case_dir/src/control.tar.gz" -C "$case_dir/src/ctl" postinst
print -r -- "unknown compression" > "$case_dir/src/control.tar.weird"
tar czf "$case_dir/src/data.tar.gz" -C "$case_dir/src/data" usr
print -r -- "2.0" > "$case_dir/src/debian-binary"
(
builtin cd "$case_dir/src"
ar rS "$case_dir/pkg.deb" debian-binary control.tar.weird data.tar.gz
)
builtin cd "$case_dir"
() {
emulate -L zsh
extract "$case_dir/pkg.deb"
} || return 1
[[ -f "$case_dir/pkg/data/usr/bin/app" ]] ||
{ print -u2 -r -- "deb-unexpected: known members were not extracted"; return 1 }
[[ -f "$case_dir/pkg/control.tar.weird" && -f "$case_dir/pkg/data.tar.gz" &&
-f "$case_dir/pkg/debian-binary" ]] ||
{ print -u2 -r -- "deb-unexpected: archive members were deleted"; return 1 }
print -r -- "PASS: deb (unexpected member)"
}
# Passing more than one .deb in a single call must not leak the loop variables
# between archives; the stale `member`/`dest` locals used to be printed by the
# second archive.
check_deb_multiple() {
local case_dir="$test_dir/deb-multiple"
mkdir -p "$case_dir/src/ctl" "$case_dir/src/data/usr/bin"
print -r -- "postinst script" > "$case_dir/src/ctl/postinst"
print -r -- "app main" > "$case_dir/src/data/usr/bin/app"
tar czf "$case_dir/src/control.tar.gz" -C "$case_dir/src/ctl" postinst
tar czf "$case_dir/src/data.tar.gz" -C "$case_dir/src/data" usr
print -r -- "2.0" > "$case_dir/src/debian-binary"
(
builtin cd "$case_dir/src"
ar rS "$case_dir/one.deb" debian-binary control.tar.gz data.tar.gz
ar rS "$case_dir/two.deb" debian-binary control.tar.gz data.tar.gz
)
builtin cd "$case_dir"
local output
output=$( () {
emulate -L zsh
extract one.deb two.deb
} 2>&1 ) || return 1
[[ $output != *member=* && $output != *dest=* ]] ||
{ print -u2 -r -- "deb-multiple: stale loop variables were printed"; return 1 }
[[ -f one/control/postinst && -f one/data/usr/bin/app &&
-f two/control/postinst && -f two/data/usr/bin/app ]] ||
{ print -u2 -r -- "deb-multiple: both archives were not extracted"; return 1 }
print -r -- "PASS: deb (multiple archives)"
}
{ {
print -r -- hello > "$test_dir/plain" print -r -- hello > "$test_dir/plain"
lzma -c "$test_dir/plain" > "$test_dir/fixture.lzma" lzma -c "$test_dir/plain" > "$test_dir/fixture.lzma"
@@ -53,11 +167,20 @@ check_extract() {
printf '\037\235\220\150\312\260\141\363\106\001' \ printf '\037\235\220\150\312\260\141\363\106\001' \
> "$test_dir/fixture.Z" > "$test_dir/fixture.Z"
for extension in lzma Z; do cp "$test_dir/plain" "$test_dir/sample.txt"
tar -cf "$test_dir/fixture.tar" -C "$test_dir" sample.txt
lzma -c "$test_dir/fixture.tar" > "$test_dir/fixture.tar.lzma"
for extension in lzma Z tar.lzma; do
for mode in default target remove; do for mode in default target remove; do
check_extract "$extension" "$mode" check_extract "$extension" "$mode"
done done
done done
check_deb_extract default
check_deb_extract target
check_deb_extract remove
check_deb_unexpected_member
check_deb_multiple
print 'All extract compressed-file tests passed.' print 'All extract compressed-file tests passed.'
} always { } always {
builtin cd "$original_dir" builtin cd "$original_dir"
+18
View File
@@ -0,0 +1,18 @@
# Fizzy CLI plugin
This plugin adds completion for the [Fizzy CLI (fizzy)](https://github.com/basecamp/fizzy-cli).
To use it, add `fizzy` to the plugins array in your zshrc file:
```zsh
plugins=(... fizzy)
```
This plugin does not add any aliases.
## Cache
This plugin caches the completion script and automatically updates it when the
plugin is loaded, which is usually when you start a new terminal emulator.
The cache is stored at `$ZSH_CACHE_DIR/completions/_fizzy`.
+24
View File
@@ -0,0 +1,24 @@
# Autocompletion for the Fizzy CLI (fizzy).
if (( ! $+commands[fizzy] )); then
return
fi
# If the completion isn't registered yet, autoload it and bind it to `fizzy`.
# Otherwise, compinit will have already done that from the cache.
if [[ -z ${_comps[fizzy]-} ]]; then
typeset -g -A _comps
autoload -Uz _fizzy
_comps[fizzy]=_fizzy
fi
zmodload -F zsh/files b:zf_mv || return
() {
local cache_file="$ZSH_CACHE_DIR/completions/_fizzy"
local temp_file
temp_file=$(mktemp "$ZSH_CACHE_DIR/completions/._fizzy.XXXXXXXX") || return
if command fizzy completion zsh >| "$temp_file" && [[ -s "$temp_file" ]] &&
zf_mv -f -- "$temp_file" "$cache_file"; then
return
fi
rm -f -- "$temp_file"
} &|
+15
View File
@@ -0,0 +1,15 @@
# fnox
Adds shell integration and completions for [fnox](https://github.com/jdx/fnox), a tool for provider-agnostic secret injection.
## Installation
[Install fnox](https://fnox.jdx.dev/guide/quick-start.html), then add it to your plugins in `~/.zshrc`:
```zsh
plugins=(fnox)
```
## Usage
See the [fnox documentation](https://fnox.jdx.dev/guide/shell-integration.html) for shell integration and usage.
+23
View File
@@ -0,0 +1,23 @@
if (( ! $+commands[fnox] )); then
# if we don't have fnox at all just bail out
return
fi
eval "$(fnox activate zsh)"
# If the completion file doesn't exist yet, we need to autoload it and
# bind it to `fnox`. Otherwise, compinit will have already done that.
if [[ ! -f "$ZSH_CACHE_DIR/completions/_fnox" ]]; then
typeset -g -A _comps
autoload -Uz _fnox
_comps[fnox]=_fnox
fi
# Regenerate completions when the executable changes.
if [[ ! -s "$ZSH_CACHE_DIR/completions/_fnox" || "$commands[fnox]" -nt "$ZSH_CACHE_DIR/completions/_fnox" ]]; then
zmodload -F zsh/files b:zf_mv
() {
local TMPPREFIX="$ZSH_CACHE_DIR/completions/._fnox"
zf_mv -f -- =( fnox completion zsh ) "$ZSH_CACHE_DIR/completions/_fnox"
} &|
fi
+25 -2
View File
@@ -1,7 +1,30 @@
## Fossil Plugin ## Fossil Plugin
This plugin adds completion support and prompt for fossil repositories. This plugin adds completion support and prompt for fossil repositories.
The prompt will display the current branch and status been dirty or clean.
To use it, add `fossil` to the plugins array in your .zshrc file:
```zsh
plugins=(... fossil)
``
This plugin provides a prompt function named `fossil_prompt_info` that
will display the current branch and if there are changes (dirty) or not (clean).
### Prompt segments
These variables control how the prompt function looks:
```
ZSH_THEME_FOSSIL_PROMPT_PREFIX="%{$fg_bold[blue]%}fossil:(%{$fg_bold[red]%}"
ZSH_THEME_FOSSIL_PROMPT_SUFFIX="%{$fg_bold[blue]%})"
ZSH_THEME_FOSSIL_PROMPT_DIRTY="%{$fg_bold[red]%}✖"
ZSH_THEME_FOSSIL_PROMPT_CLEAN="%{$fg_bold[green]%}✔"
```
You can override their values in your .zshrc file, anywhere after the
`source $ZSH/oh-my-zsh.sh` line.
### CONTRIBUTOR ### CONTRIBUTOR
- Jefferson González ([jgmdev](https://github.com/jgmdev))
- Jefferson González ([jgmdev](https://github.com/jgmdev))
+24 -16
View File
@@ -7,10 +7,10 @@ ZSH_THEME_FOSSIL_PROMPT_PREFIX="%{$fg_bold[blue]%}fossil:(%{$fg_bold[red]%}"
ZSH_THEME_FOSSIL_PROMPT_SUFFIX="%{$fg_bold[blue]%})" ZSH_THEME_FOSSIL_PROMPT_SUFFIX="%{$fg_bold[blue]%})"
# Text to display if the branch is dirty # Text to display if the branch is dirty
ZSH_THEME_FOSSIL_PROMPT_DIRTY=" %{$fg_bold[red]%}✖" ZSH_THEME_FOSSIL_PROMPT_DIRTY="%{$fg_bold[red]%}✖"
# Text to display if the branch is clean # Text to display if the branch is clean
ZSH_THEME_FOSSIL_PROMPT_CLEAN=" %{$fg_bold[green]%}✔" ZSH_THEME_FOSSIL_PROMPT_CLEAN="%{$fg_bold[green]%}✔"
function fossil_prompt_info() { function fossil_prompt_info() {
local branch=$(fossil branch current 2>&1) local branch=$(fossil branch current 2>&1)
@@ -25,27 +25,35 @@ function fossil_prompt_info() {
dirty="$ZSH_THEME_FOSSIL_PROMPT_DIRTY" dirty="$ZSH_THEME_FOSSIL_PROMPT_DIRTY"
fi fi
printf '%s %s %s %s %s' \ printf ' %s%s%s%s%s' \
"$ZSH_THEME_FOSSIL_PROMPT_PREFIX" \ "$ZSH_THEME_FOSSIL_PROMPT_PREFIX" \
"${branch:gs/%/%%}" \ "${branch:gs/%/%%}" \
"$ZSH_THEME_FOSSIL_PROMPT_SUFFIX" \
"$dirty" \ "$dirty" \
"$ZSH_THEME_FOSSIL_PROMPT_SUFFIX" \
"%{$reset_color%}" "%{$reset_color%}"
} }
function _fossil_prompt () { function _fossil_prompt () {
local current=`echo $PROMPT $RPROMPT | grep fossil` # Re-check each time, in case the theme rebuilds its prompt in precmd
if [ -z "$_FOSSIL_PROMPT" ] || [[ "$PROMPT$RPROMPT" != *fossil_prompt_info* ]]; then
if [ "$_FOSSIL_PROMPT" = "" -o "$current" = "" ]; then # Use substitutions to work out what other plugins and themes have
local _prompt=${PROMPT} # done ahead of us so we don't duplicate their work.
local _rprompt=${RPROMPT} #
# If $fossil_prompt_info isn't in the prompt strings already but we
local is_prompt=`echo $PROMPT | grep git` # can find $git_prompt_info, put it immediately afterward so that
# one or the other appears in the prompt. We're gambling that you
if [ "$is_prompt" = "" ]; then # aren't in a directory that's a checkout for both a Git repo and a
RPROMPT="$_rprompt"'$(fossil_prompt_info)' # Fossil repo.
else #
PROMPT="$_prompt"'$(fossil_prompt_info) ' # Otherwise, add it to the right prompt, as before.
if [ "${PROMPT/fossil_prompt_info//}" = "$PROMPT" ]; then
PROMPT="${PROMPT/git_prompt_info/git_prompt_info)\$(fossil_prompt_info}"
fi
if [ "${RPROMPT/fossil_prompt_info//}" = "$RPROMPT" ]; then
RPROMPT="${RPROMPT/git_prompt_info/git_prompt_info)\$(fossil_prompt_info}"
fi
if [[ "$PROMPT$RPROMPT" != *fossil_prompt_info* ]]; then
RPROMPT+='$(fossil_prompt_info)'
fi fi
_FOSSIL_PROMPT="1" _FOSSIL_PROMPT="1"
+2
View File
@@ -18,3 +18,5 @@ plugin is loaded, which is usually when you start up a new terminal emulator.
The cache is stored at: The cache is stored at:
- `$ZSH_CACHE_DIR/completions/_gh` completions script - `$ZSH_CACHE_DIR/completions/_gh` completions script
If an update fails, the last successfully generated completion script is kept.
+4 -1
View File
@@ -14,5 +14,8 @@ fi
zmodload -F zsh/files b:zf_mv zmodload -F zsh/files b:zf_mv
() { () {
local TMPPREFIX="$ZSH_CACHE_DIR/completions/._gh" local TMPPREFIX="$ZSH_CACHE_DIR/completions/._gh"
zf_mv -f -- =( gh completion --shell zsh ) "$ZSH_CACHE_DIR/completions/_gh" () {
gh completion --shell zsh >| "$1" && [[ -s "$1" ]] \
&& zf_mv -f -- "$1" "$ZSH_CACHE_DIR/completions/_gh"
} =(:) || return
} &| } &|
+6 -2
View File
@@ -12,7 +12,7 @@ plugins=(... git-commit)
## Syntax ## Syntax
```zsh ```zsh
git <type> [(-s, --scope) "<scope>"] [(-a, --attention)] "<message>" git <type> [(-s, --scope) "<scope>"] [(-a, --attention)] [(-b, --body) "<body>"] "<message>"
``` ```
Where `type` is one of the following: Where `type` is one of the following:
@@ -30,6 +30,9 @@ Where `type` is one of the following:
- `test` - `test`
- `wip` - `wip`
The optional `-b` / `--body` becomes the commit body (a blank line after the subject), as defined by
[Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/#summary).
> NOTE: the subcommand for `revert` type is `rev`, as otherwise it conflicts with the > NOTE: the subcommand for `revert` type is `rev`, as otherwise it conflicts with the
> git command of the same name. It will still generate a commit message in the format > git command of the same name. It will still generate a commit message in the format
> `revert: <message>` > `revert: <message>`
@@ -39,6 +42,7 @@ Where `type` is one of the following:
| Git subcommand | Command | | Git subcommand | Command |
| --------------------------------------------- | ---------------------------------------------------- | | --------------------------------------------- | ---------------------------------------------------- |
| `git style "remove trailing whitespace"` | `git commit -m "style: remove trailing whitespace"` | | `git style "remove trailing whitespace"` | `git commit -m "style: remove trailing whitespace"` |
| `git wip "work in progress"` | `git commit -m "work in progress"` | | `git wip "work in progress"` | `git commit -m "wip: work in progress"` |
| `git fix -s "router" "correct redirect link"` | `git commit -m "fix(router): correct redirect link"` | | `git fix -s "router" "correct redirect link"` | `git commit -m "fix(router): correct redirect link"` |
| `git rev -s "api" "rollback v2"` | `git commit -m "revert(api): rollback v2"` | | `git rev -s "api" "rollback v2"` | `git commit -m "revert(api): rollback v2"` |
| `git feat -s "auth" -b "Keep session across redirects." "add login redirect"` | `git commit -m "feat(auth): add login redirect" -m "Keep session across redirects."` |
+11 -3
View File
@@ -12,11 +12,11 @@ _omz_git_commit() {
if [[ "$_type" == rev ]]; then if [[ "$_type" == rev ]]; then
_type=revert _type=revert
fi fi
local _scope _attention _message local _scope _attention _message _body
while [ $# -ne 0 ]; do while [ $# -ne 0 ]; do
case $1 in case $1 in
-s | --scope ) -s | --scope )
if [ -z $2 ]; then if [ -z "$2" ]; then
echo >&2 "Missing scope!" echo >&2 "Missing scope!"
return 1 return 1
fi fi
@@ -27,12 +27,20 @@ _omz_git_commit() {
_attention="!" _attention="!"
shift 1 shift 1
;; ;;
-b | --body )
if [ -z "$2" ]; then
echo >&2 "Missing body!"
return 1
fi
_body="$2"
shift 2
;;
* ) * )
_message="${_message} $1" _message="${_message} $1"
shift 1 shift 1
;; ;;
esac esac
done done
git commit -m "${_type}${_scope:+(${_scope})}${_attention}:${_message}" git commit -m "${_type}${_scope:+(${_scope})}${_attention}:${_message}" ${_body:+-m} ${_body:+"$_body"}
} }
_omz_git_commit "$@" _omz_git_commit "$@"
+4 -1
View File
@@ -18,10 +18,12 @@ plugins=(... git)
| `g` | `git` | | `g` | `git` |
| `ga` | `git add` | | `ga` | `git add` |
| `gaa` | `git add --all` | | `gaa` | `git add --all` |
| `gan` | `git add --intent-to-add` |
| `ganpa` | `git add --intent-to-add . && git add --patch` |
| `gapa` | `git add --patch` | | `gapa` | `git add --patch` |
| `gau` | `git add --update` | | `gau` | `git add --update` |
| `gav` | `git add --verbose` | | `gav` | `git add --verbose` |
| `gwip` | `git add -A; git rm $(git ls-files --deleted) 2> /dev/null; git commit --no-verify --no-gpg-sign --message "--wip-- [skip ci]"` | | `gwip` | `git add -A; git commit --no-verify --no-gpg-sign --message "--wip-- [skip ci]"` |
| `gam` | `git am` | | `gam` | `git am` |
| `gama` | `git am --abort` | | `gama` | `git am --abort` |
| `gamc` | `git am --continue` | | `gamc` | `git am --continue` |
@@ -208,6 +210,7 @@ plugins=(... git)
| `gsb` | `git status --short -b` | | `gsb` | `git status --short -b` |
| `gsnut` | `git status --untracked-files=no` | | `gsnut` | `git status --untracked-files=no` |
| `gsi` | `git submodule init` | | `gsi` | `git submodule init` |
| `gsms` | `git submodule status` |
| `gsu` | `git submodule update` | | `gsu` | `git submodule update` |
| `gsuri` | `git submodule update --recursive --init` | | `gsuri` | `git submodule update --recursive --init` |
| `gsd` | `git svn dcommit` | | `gsd` | `git svn dcommit` |
+33 -2
View File
@@ -1,6 +1,34 @@
# Git version checking # Git version checking
autoload -Uz is-at-least autoload -Uz is-at-least
git_version="${${(As: :)$(git version 2>/dev/null)}[3]}" # Running `git version` forks on every startup, so cache the result for a day
# in $ZSH_CACHE_DIR, keyed on the resolved git binary's path and mtime.
# Run the fallback outside this function so its locals cannot shadow wrapper variables.
() {
# Shell overrides and relative PATH entries can make the command hash
# differ from the Git that Zsh actually runs.
(( $+functions[git] || $+aliases[git] || $+galiases[git] || ${path[(I)(|[^/]*)]} )) && return 1
local cache="$ZSH_CACHE_DIR/git-version" git_path="${commands[git]:+${commands[git]:A}}" key magic
local -a stat lines
# Shims and the macOS developer-tool dispatcher can select a different Git.
[[ "${git_path:t:r}" = 'git' ]] || return 1
[[ "$OSTYPE" == darwin* && "$git_path" = /usr/bin/git ]] && return 1
read -r -k 2 -u 0 magic 2>/dev/null < "$git_path" || return 1
[[ "$magic" = '#!' ]] && return 1
zmodload -F zsh/stat b:zstat && zstat -A stat +mtime -- "$git_path" 2>/dev/null || return 1
key="$git_path $stat[1]"
lines=("$cache"(Nm-1))
(( $#lines )) && lines=("${(@f)$(<"$cache")}")
if [[ "$lines[1]" = "$key" && "$lines[2]" == <->.<->* ]]; then
git_version="$lines[2]"
return 0
fi
git_version="${${(As: :)$(git version 2>/dev/null)}[3]}"
[[ ! -w "$ZSH_CACHE_DIR" ]] || print -rl -- "$key" "$git_version" >| "$cache"
return 0
} || git_version="${${(As: :)$(git version 2>/dev/null)}[3]}"
# #
# Functions Current # Functions Current
@@ -116,10 +144,12 @@ alias ggpur='ggu'
alias g='git' alias g='git'
alias ga='git add' alias ga='git add'
alias gaa='git add --all' alias gaa='git add --all'
alias gan='git add --intent-to-add'
alias ganpa='git add --intent-to-add . && git add --patch'
alias gapa='git add --patch' alias gapa='git add --patch'
alias gau='git add --update' alias gau='git add --update'
alias gav='git add --verbose' alias gav='git add --verbose'
alias gwip='git add -A; git rm $(git ls-files --deleted) 2> /dev/null; git commit --no-verify --no-gpg-sign --message "--wip-- [skip ci]"' alias gwip='git add -A; git commit --no-verify --no-gpg-sign --message "--wip-- [skip ci]"'
alias gam='git am' alias gam='git am'
alias gama='git am --abort' alias gama='git am --abort'
alias gamc='git am --continue' alias gamc='git am --continue'
@@ -410,6 +440,7 @@ alias gss='git status --short'
alias gsb='git status --short --branch' alias gsb='git status --short --branch'
alias gsnut='git status --untracked-files=no' alias gsnut='git status --untracked-files=no'
alias gsi='git submodule init' alias gsi='git submodule init'
alias gsms='git submodule status'
alias gsu='git submodule update' alias gsu='git submodule update'
alias gsuri='git submodule update --recursive --init' alias gsuri='git submodule update --recursive --init'
alias gsd='git svn dcommit' alias gsd='git svn dcommit'
+91
View File
@@ -0,0 +1,91 @@
#!/usr/bin/env zsh
emulate -LR zsh
plugin=${1:-${0:A:h:h}/git.plugin.zsh}
plugin=${plugin:A}
(( $+commands[git] )) || { print -u2 'Git is required for this test'; exit 1; }
real_version="${${(As: :)$(command git version)}[3]}"
test_dir=$(mktemp -d) || exit 1
trap 'command rm -rf -- "$test_dir"' EXIT
export ZSH_CACHE_DIR="$test_dir"
cache="$ZSH_CACHE_DIR/git-version"
typeset -i failures=0 tests=0
check() {
local description=$1
shift
(( tests++ ))
if "$@"; then
print -r -- "PASS: $description"
else
print -u2 -r -- "FAIL: $description"
(( failures++ ))
fi
}
# Each source gets a fresh shell scope while sharing the persistent cache.
probe() (
local mode=$1 expected=$2 version
: > "$test_dir/versions"
autoload -Uz +X is-at-least
functions[_test_is_at_least]=$functions[is-at-least]
is-at-least() {
print -r -- "$2" >> "$test_dir/versions"
_test_is_at_least "$@"
}
compdef() { :; }
case $mode in
function) git() { print -r -- "git version $expected"; } ;;
alias) alias git="print -r -- 'git version $expected'" ;;
esac
source "$plugin"
local -a versions=("${(@f)$(<"$test_dir/versions")}")
(( $#versions == 4 )) || return 1
for version in "$versions[@]"; do
[[ "$version" == "$expected" ]] || return 1
done
if [[ "$expected" == 2.5.0 ]]; then
[[ "$aliases[gpf]" == 'git push --force-with-lease' \
&& "$aliases[gsta]" == 'git stash save' ]] || return 1
fi
)
check 'cold load probes the installed Git' probe binary "$real_version"
if [[ ! -f "$cache" ]]; then
print -u2 'This test requires a native Git executable eligible for caching'
exit 1
fi
key="${${(f)$(<"$cache")}[1]}"
check 'warm load uses the installed version' probe binary "$real_version"
check 'function override bypasses an existing binary cache' probe function 2.5.0
check 'alias override bypasses an existing binary cache' probe alias 2.5.0
check 'shell overrides do not replace the binary cache' probe binary "$real_version"
# A different cached version distinguishes a cache hit from a fresh probe.
print -rl -- "$key" 2.5.0 > "$cache"
check 'valid warm cache avoids a new version probe' probe binary 2.5.0
print -r -- "$key" > "$cache"
check 'missing version line triggers a fresh probe' probe binary "$real_version"
print -rl -- "$key" '' > "$cache"
check 'empty version line triggers a fresh probe' probe binary "$real_version"
print -rl -- "$key" invalid > "$cache"
check 'invalid version line triggers a fresh probe' probe binary "$real_version"
print -rl -- 'different executable' 2.5.0 > "$cache"
check 'different binary key triggers a fresh probe' probe binary "$real_version"
print -rl -- "$key" 2.5.0 > "$cache"
touch -t 200001010000 "$cache"
check 'expired cache triggers a fresh probe' probe binary "$real_version"
rm "$cache"
check 'function override works without a cache' probe function 2.5.0
check 'function override does not write a cache' test ! -e "$cache"
rm -f "$cache"
check 'alias override works without a cache' probe alias 2.5.0
check 'alias override does not write a cache' test ! -e "$cache"
print -r -- "$tests tests, $failures failures"
(( failures == 0 ))
+2
View File
@@ -22,6 +22,7 @@ plugins=(... golang)
| gofx | `go fix` | Update packages to use a new API | | gofx | `go fix` | Update packages to use a new API |
| gog | `go get` | Downloads packages and then installs them to $GOPATH | | gog | `go get` | Downloads packages and then installs them to $GOPATH |
| goga | `go get ./...` | Installs all dependencies in current directory, recursively | | goga | `go get ./...` | Installs all dependencies in current directory, recursively |
| goge | `go generate` | Generate Go files by processing source |
| goi | `go install` | Compiles and installs packages to $GOPATH | | goi | `go install` | Compiles and installs packages to $GOPATH |
| gol | `go list` | Lists Go packages | | gol | `go list` | Lists Go packages |
| gom | `go mod` | Access to operations on modules | | gom | `go mod` | Access to operations on modules |
@@ -54,3 +55,4 @@ changes your prompt to:
``` ```
~/go/project$ ▋ 1.22.3 ~/go/project$ ▋ 1.22.3
``` ```
+1
View File
@@ -19,6 +19,7 @@ alias gofa='go fmt ./...'
alias gofx='go fix' alias gofx='go fix'
alias gog='go get' alias gog='go get'
alias goga='go get ./...' alias goga='go get ./...'
alias goge='go generate'
alias goi='go install' alias goi='go install'
alias gol='go list' alias gol='go list'
alias gom='go mod' alias gom='go mod'
+31
View File
@@ -112,6 +112,37 @@ plugins=(... hcloud)
| hcst | `hcloud server-type list` | List all server types | | hcst | `hcloud server-type list` | List all server types |
| hcit | `hcloud image list --type system` | List all system images | | hcit | `hcloud image list --type system` | List all system images |
## Prompt function
This plugin provides `hcloud_prompt_info` which can be added to your prompt to display the current Hetzner Cloud context.
- If `HCLOUD_TOKEN` environment variable is set, it displays `HCLOUD_TOKEN` (indicating direct token usage)
- Otherwise, it displays the active context name
### Usage
Add `$(hcloud_prompt_info)` to your `PROMPT` or `RPROMPT` in your `.zshrc`:
```zsh
RPROMPT='$(hcloud_prompt_info)'
```
### Theme variables
| Variable | Default | Description |
| :----------------------------- | :-------------- | :----------------------------------------------- |
| `ZSH_THEME_HCLOUD_PREFIX` | `<hcloud:` | Prefix before the context name |
| `ZSH_THEME_HCLOUD_SUFFIX` | `>` | Suffix after the context name |
| `ZSH_THEME_HCLOUD_TOKEN_TEXT` | `HCLOUD_TOKEN` | Text shown when `HCLOUD_TOKEN` env var is set |
### Example with custom styling
```zsh
ZSH_THEME_HCLOUD_PREFIX="%{$fg[blue]%}hcloud:("
ZSH_THEME_HCLOUD_SUFFIX=")%{$reset_color%}"
RPROMPT='$(hcloud_prompt_info)'
```
## Requirements ## Requirements
This plugin requires the [Hetzner Cloud CLI](https://github.com/hetznercloud/cli) to be installed. This plugin requires the [Hetzner Cloud CLI](https://github.com/hetznercloud/cli) to be installed.
+17
View File
@@ -131,3 +131,20 @@ alias hcdc='hcloud datacenter list'
alias hcloc='hcloud location list' alias hcloc='hcloud location list'
alias hcst='hcloud server-type list' alias hcst='hcloud server-type list'
alias hcit='hcloud image list --type system' alias hcit='hcloud image list --type system'
# Prompt function to display current hcloud context
# Usage: add $(hcloud_prompt_info) to your PROMPT or RPROMPT
function hcloud_prompt_info() {
# Check if HCLOUD_TOKEN is set (overrides context)
if [[ -n "$HCLOUD_TOKEN" ]]; then
echo "${ZSH_THEME_HCLOUD_PREFIX=<hcloud:}${ZSH_THEME_HCLOUD_TOKEN_TEXT=HCLOUD_TOKEN}${ZSH_THEME_HCLOUD_SUFFIX=>}"
return
fi
# Get active context
local context
context=$(hcloud context active 2>/dev/null)
[[ -n "$context" ]] || return
echo "${ZSH_THEME_HCLOUD_PREFIX=<hcloud:}${context}${ZSH_THEME_HCLOUD_SUFFIX=>}"
}
+17 -4
View File
@@ -1,5 +1,18 @@
# Autocompletion for invoke. # Autocompletion for the Invoke CLI (invoke).
# if (( ! $+commands[invoke] )); then
if [ $commands[invoke] ]; then return
source <(invoke --print-completion-script=zsh) fi
# If the completion file does not exist, generate it and then source it
# Otherwise, source it and regenerate in the background
if [[ ! -f "$ZSH_CACHE_DIR/completions/_invoke" ]]; then
invoke --print-completion-script=zsh | tee "$ZSH_CACHE_DIR/completions/_invoke" >/dev/null
source "$ZSH_CACHE_DIR/completions/_invoke"
else
source "$ZSH_CACHE_DIR/completions/_invoke"
zmodload -F zsh/files b:zf_mv
() {
local TMPPREFIX="$ZSH_CACHE_DIR/completions/._invoke"
zf_mv -f -- =( invoke --print-completion-script=zsh ) "$ZSH_CACHE_DIR/completions/_invoke"
} &|
fi fi
+17 -3
View File
@@ -1,4 +1,18 @@
if [ $commands[istioctl] ]; then # Autocompletion for the Istio CLI (istioctl).
source <(istioctl completion zsh) if (( ! $+commands[istioctl] )); then
compdef _istioctl istioctl return
fi
# If the completion file does not exist, generate it and then source it
# Otherwise, source it and regenerate in the background
if [[ ! -f "$ZSH_CACHE_DIR/completions/_istioctl" ]]; then
istioctl completion zsh | tee "$ZSH_CACHE_DIR/completions/_istioctl" >/dev/null
source "$ZSH_CACHE_DIR/completions/_istioctl"
else
source "$ZSH_CACHE_DIR/completions/_istioctl"
zmodload -F zsh/files b:zf_mv
() {
local TMPPREFIX="$ZSH_CACHE_DIR/completions/._istioctl"
zf_mv -f -- =( istioctl completion zsh ) "$ZSH_CACHE_DIR/completions/_istioctl"
} &|
fi fi
+1
View File
@@ -44,6 +44,7 @@ plugins=(... jj)
| jjgi | `jj git init` | | jjgi | `jj git init` |
| jjgp | `jj git push` | | jjgp | `jj git push` |
| jjgpa | `jj git push --all` | | jjgpa | `jj git push --all` |
| jjgpb | `jj git push --bookmark` |
| jjgpd | `jj git push --deleted` | | jjgpd | `jj git push --deleted` |
| jjgpt | `jj git push --tracked` | | jjgpt | `jj git push --tracked` |
| jjgrl | `jj git remote list` | | jjgrl | `jj git remote list` |
+1
View File
@@ -70,6 +70,7 @@ alias jjgfa='jj git fetch --all-remotes'
alias jjgi='jj git init' alias jjgi='jj git init'
alias jjgp='jj git push' alias jjgp='jj git push'
alias jjgpa='jj git push --all' alias jjgpa='jj git push --all'
alias jjgpb='jj git push --bookmark'
alias jjgpd='jj git push --deleted' alias jjgpd='jj git push --deleted'
alias jjgpt='jj git push --tracked' alias jjgpt='jj git push --tracked'
alias jjgrl='jj git remote list' alias jjgrl='jj git remote list'
+17 -4
View File
@@ -1,8 +1,21 @@
# Autocompletion for kn, the command line interface for knative # Autocompletion for kn, the command line interface for Knative.
# #
# Author: https://github.com/btannous # Author: https://github.com/btannous
if [ $commands[kn] ]; then if (( ! $+commands[kn] )); then
source <(kn completion zsh) return
compdef _kn kn fi
# If the completion file does not exist, generate it and then source it
# Otherwise, source it and regenerate in the background
if [[ ! -f "$ZSH_CACHE_DIR/completions/_kn" ]]; then
kn completion zsh | tee "$ZSH_CACHE_DIR/completions/_kn" >/dev/null
source "$ZSH_CACHE_DIR/completions/_kn"
else
source "$ZSH_CACHE_DIR/completions/_kn"
zmodload -F zsh/files b:zf_mv
() {
local TMPPREFIX="$ZSH_CACHE_DIR/completions/._kn"
zf_mv -f -- =( kn completion zsh ) "$ZSH_CACHE_DIR/completions/_kn"
} &|
fi fi
+17 -2
View File
@@ -1,3 +1,18 @@
if [ $commands[kompose] ]; then # Autocompletion for the Kompose CLI (kompose).
source <(kompose completion zsh) if (( ! $+commands[kompose] )); then
return
fi
# If the completion file does not exist, generate it and then source it
# Otherwise, source it and regenerate in the background
if [[ ! -f "$ZSH_CACHE_DIR/completions/_kompose" ]]; then
kompose completion zsh | tee "$ZSH_CACHE_DIR/completions/_kompose" >/dev/null
source "$ZSH_CACHE_DIR/completions/_kompose"
else
source "$ZSH_CACHE_DIR/completions/_kompose"
zmodload -F zsh/files b:zf_mv
() {
local TMPPREFIX="$ZSH_CACHE_DIR/completions/._kompose"
zf_mv -f -- =( kompose completion zsh ) "$ZSH_CACHE_DIR/completions/_kompose"
} &|
fi fi
+17 -2
View File
@@ -1,3 +1,18 @@
if [ $commands[kops] ]; then # Autocompletion for the Kubernetes Operations CLI (kops).
source <(kops completion zsh) if (( ! $+commands[kops] )); then
return
fi
# If the completion file does not exist, generate it and then source it
# Otherwise, source it and regenerate in the background
if [[ ! -f "$ZSH_CACHE_DIR/completions/_kops" ]]; then
kops completion zsh | tee "$ZSH_CACHE_DIR/completions/_kops" >/dev/null
source "$ZSH_CACHE_DIR/completions/_kops"
else
source "$ZSH_CACHE_DIR/completions/_kops"
zmodload -F zsh/files b:zf_mv
() {
local TMPPREFIX="$ZSH_CACHE_DIR/completions/._kops"
zf_mv -f -- =( kops completion zsh ) "$ZSH_CACHE_DIR/completions/_kops"
} &|
fi fi
+4
View File
@@ -31,6 +31,8 @@ plugins=(... kubectl)
| kdelk | `kubectl delete -k` | Delete all resources defined in a kustomization directory | | kdelk | `kubectl delete -k` | Delete all resources defined in a kustomization directory |
| kge | `kubectl get events --sort-by=".lastTimestamp"` | Get events (sorted by timestamp) | | 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) | | kgew | `kubectl get events --watch --sort-by=".lastTimestamp"` | Get events and watch as they occur (sorted by timestamp) |
| kg | `kubectl get` | Get one or more resources |
| kd | `kubectl describe` | Describe one or more resources in detail |
| | | **Pod management** | | | | **Pod management** |
| kgp | `kubectl get pods` | List all pods in ps output format | | kgp | `kubectl get pods` | List all pods in ps output format |
| kgpl | `kgp -l` | Get pods by label. Example: `kgpl "app=myapp" -n myns` | | kgpl | `kgp -l` | Get pods by label. Example: `kgpl "app=myapp" -n myns` |
@@ -60,6 +62,7 @@ plugins=(... kubectl)
| | | **Namespace management** | | | | **Namespace management** |
| kgns | `kubectl get namespaces` | List the current namespaces in a cluster | | kgns | `kubectl get namespaces` | List the current namespaces in a cluster |
| kcn | `kubectl config set-context --current --namespace` | Change current namespace | | kcn | `kubectl config set-context --current --namespace` | Change current namespace |
| kcgetns | `kubectl config view --minify -o jsonpath={.contexts[0].context.namespace}` | Get the current context's namespace |
| kens | `kubectl edit namespace` | Edit namespace resource from the default editor | | kens | `kubectl edit namespace` | Edit namespace resource from the default editor |
| kdns | `kubectl describe namespace` | Describe namespace resource in detail | | kdns | `kubectl describe namespace` | Describe namespace resource in detail |
| kdelns | `kubectl delete namespace` | Delete the namespace. WARNING! This deletes everything in the namespace | | kdelns | `kubectl delete namespace` | Delete the namespace. WARNING! This deletes everything in the namespace |
@@ -112,6 +115,7 @@ plugins=(... kubectl)
| | | **Node management** | | | | **Node management** |
| kgno | `kubectl get nodes` | List the nodes in ps output format | | 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 | | kgnosl | `kubectl get nodes --show-labels` | List the nodes in ps output format with labels |
| kgnow | `kubectl get nodes --watch` | List the nodes, then watch for status changes (e.g. Ready/NotReady, cordoned, added or removed) |
| keno | `kubectl edit node` | Edit nodes resource from the default editor | | keno | `kubectl edit node` | Edit nodes resource from the default editor |
| kdno | `kubectl describe node` | Describe node resource in detail | | kdno | `kubectl describe node` | Describe node resource in detail |
| kdelno | `kubectl delete node` | Delete the node | | kdelno | `kubectl delete node` | Delete the node |
+5 -1
View File
@@ -31,7 +31,7 @@ alias kapk='kubectl apply -k'
# Drop into an interactive terminal on a container # Drop into an interactive terminal on a container
alias keti='kubectl exec -t -i' alias keti='kubectl exec -t -i'
# Manage configuration quickly to switch contexts between local, dev ad staging. # Manage configuration quickly to switch contexts between local, dev and staging.
alias kcuc='kubectl config use-context' alias kcuc='kubectl config use-context'
alias kcsc='kubectl config set-context' alias kcsc='kubectl config set-context'
alias kcdc='kubectl config delete-context' alias kcdc='kubectl config delete-context'
@@ -47,6 +47,8 @@ alias kdelf='kubectl delete -f'
alias kdelk='kubectl delete -k' alias kdelk='kubectl delete -k'
alias kge='kubectl get events --sort-by=".lastTimestamp"' alias kge='kubectl get events --sort-by=".lastTimestamp"'
alias kgew='kubectl get events --sort-by=".lastTimestamp" --watch' alias kgew='kubectl get events --sort-by=".lastTimestamp" --watch'
alias kg='kubectl get'
alias kd='kubectl describe'
# Pod management. # Pod management.
alias kgp='kubectl get pods' alias kgp='kubectl get pods'
@@ -83,6 +85,7 @@ alias kens='kubectl edit namespace'
alias kdns='kubectl describe namespace' alias kdns='kubectl describe namespace'
alias kdelns='kubectl delete namespace' alias kdelns='kubectl delete namespace'
alias kcn='kubectl config set-context --current --namespace' alias kcn='kubectl config set-context --current --namespace'
alias kcgetns="kubectl config view --minify -o 'jsonpath={.contexts[0].context.namespace}'"
# ConfigMap management # ConfigMap management
alias kgcm='kubectl get configmaps' alias kgcm='kubectl get configmaps'
@@ -156,6 +159,7 @@ alias kcp='kubectl cp'
# Node Management # Node Management
alias kgno='kubectl get nodes' alias kgno='kubectl get nodes'
alias kgnosl='kubectl get nodes --show-labels' alias kgnosl='kubectl get nodes --show-labels'
alias kgnow='kubectl get nodes --watch'
alias keno='kubectl edit node' alias keno='kubectl edit node'
alias kdno='kubectl describe node' alias kdno='kubectl describe node'
alias kdelno='kubectl delete node' alias kdelno='kubectl delete node'
+58
View File
@@ -2,10 +2,44 @@
This plugin adds aliases and autocompletion for Laravel [Artisan](https://laravel.com/docs/artisan) and [Bob](http://daylerees.github.io/laravel-bob/) command-line interfaces. This plugin adds aliases and autocompletion for Laravel [Artisan](https://laravel.com/docs/artisan) and [Bob](http://daylerees.github.io/laravel-bob/) command-line interfaces.
It replaces the `laravel4` and `laravel5` plugins. Enable only `laravel` to use
the shared aliases and completion with Laravel projects of different versions.
``` ```
plugins=(... laravel) plugins=(... laravel)
``` ```
## Completion
For Laravel 4 and later, completion reads the available commands from
`artisan list --raw --no-ansi` in the current project, including custom commands.
The legacy static command-name completion is retained for Laravel 3, which does
not support that command. Artisan runs only when completing a command name;
command arguments use file completion without booting the application.
No Laravel command runs when the plugin is loaded.
## Migrating from laravel4 or laravel5
Replace `laravel4` or `laravel5` in your `plugins` array with `laravel`.
The old plugin names still load `laravel`, with a deprecation notice, and retain
their own version-specific aliases listed below. These aliases are available
only while the corresponding legacy plugin is enabled. When switching to
`laravel` alone, use `artisan` or the shared aliases instead; add any shortcuts
you still need to your own configuration.
| Alias | Command |
|-------|---------|
| `la4`, `la5` | `php artisan` |
| `la4dump` | `php artisan dump-autoload` |
| `la4cache`, `la5cache` | `php artisan cache:clear` |
| `la4routes` | `php artisan routes` (Laravel 4) |
| `la5routes` | `php artisan route:list` (Laravel 5 and later) |
| `la5vendor` | `php artisan vendor:publish` |
Only commands supported by your project's Laravel version can be run. The
version-specific aliases keep their original meaning; they do not translate
commands between versions.
## Settings ## Settings
By default the aliases run `php artisan`. To use a different PHP command, such as By default the aliases run `php artisan`. To use a different PHP command, such as
@@ -19,6 +53,16 @@ zstyle ':omz:plugins:laravel' php 'herd php'
`php` in the aliases below is then replaced with that command. `php` in the aliases below is then replaced with that command.
For a wrapper such as `herd php`, Zsh normally attempts completion for the
wrapper after expanding the alias. To complete `artisan`, `la4`, and `la5`
directly with this plugin instead, enable Zsh's `COMPLETE_ALIASES` option:
```zsh
setopt COMPLETE_ALIASES
```
This option applies to all aliases in your shell.
## Aliases ## Aliases
| Alias | Description | | Alias | Description |
@@ -80,3 +124,17 @@ zstyle ':omz:plugins:laravel' php 'herd php'
| `paqr` | `php artisan queue:retry` | | `paqr` | `php artisan queue:retry` |
| `paqt` | `php artisan queue:table` | | `paqt` | `php artisan queue:table` |
| `paqw` | `php artisan queue:work` | | `paqw` | `php artisan queue:work` |
## Modules
Aliases for [nWidart/laravel-modules](https://github.com/nWidart/laravel-modules).
| Alias | Description |
|:-:|:-:|
| `pamol` | `php artisan module:list` |
| `pamomk` | `php artisan module:make` |
| `pamoe` | `php artisan module:enable` |
| `pamod` | `php artisan module:disable` |
| `pamom` | `php artisan module:migrate` |
| `pamomr` | `php artisan module:migrate-rollback` |
| `pamos` | `php artisan module:seed` |
+20 -10
View File
@@ -8,6 +8,9 @@
# - Adds aliases and autocompletion for bob # - Adds aliases and autocompletion for bob
local curcontext="$curcontext" state line _opts _bundles ret=1 local curcontext="$curcontext" state line _opts _bundles ret=1
local php_command command_list
local -a artisan_commands
_arguments -C \ _arguments -C \
'1: :->cmds' \ '1: :->cmds' \
'*:: :->args' && ret=0 '*:: :->args' && ret=0
@@ -15,6 +18,21 @@ _arguments -C \
case $state in case $state in
cmds) cmds)
# Boot the application only to discover command names, not file arguments.
# Laravel 3 falls back to the static command names below.
zstyle -s ':omz:plugins:laravel' php php_command || php_command=php
if [[ -f artisan ]] && command_list=$(
"${(@Q)${(z)php_command}}" artisan list --raw --no-ansi 2>/dev/null
); then
artisan_commands=("${(@f)command_list}")
artisan_commands=(${artisan_commands[@]%%[[:space:]]*})
fi
if (( ${#artisan_commands} )); then
compadd -- "${artisan_commands[@]}"
return $?
fi
_values "Artisan command" \ _values "Artisan command" \
'session\:install[Create a session table]' \ 'session\:install[Create a session table]' \
'migrate[Manage Migrations]' \ 'migrate[Manage Migrations]' \
@@ -24,16 +42,8 @@ case $state in
ret=0 ret=0
;; ;;
args) args)
case $line[1] in _files
migrate) return $?
_values \
'install[Create the Laravel migration table' \
'make[Create a migration]' \
'rollback[Roll back to the last migration operation]' \
'reset[Roll back all migrations that have ever run]'
ret=0
;;
esac
;; ;;
esac esac
+16
View File
@@ -53,4 +53,20 @@ alias paqr="$_omz_laravel_php artisan queue:retry"
alias paqt="$_omz_laravel_php artisan queue:table" alias paqt="$_omz_laravel_php artisan queue:table"
alias paqw="$_omz_laravel_php artisan queue:work" alias paqw="$_omz_laravel_php artisan queue:work"
# Modules (nWidart/laravel-modules)
alias pamol="$_omz_laravel_php artisan module:list"
alias pamomk="$_omz_laravel_php artisan module:make"
alias pamoe="$_omz_laravel_php artisan module:enable"
alias pamod="$_omz_laravel_php artisan module:disable"
alias pamom="$_omz_laravel_php artisan module:migrate"
alias pamomr="$_omz_laravel_php artisan module:migrate-rollback"
alias pamos="$_omz_laravel_php artisan module:seed"
unset _omz_laravel_php unset _omz_laravel_php
# Also load completion when reached through a legacy plugin name.
if (( ! ${fpath[(Ie)${0:A:h}]} )); then
fpath+=("${0:A:h}")
fi
autoload -Uz _artisan
compdef _artisan artisan
+171
View File
@@ -0,0 +1,171 @@
#!/usr/bin/env zsh
# Run with: zsh -df plugins/laravel/tests/laravel.test.zsh
emulate -LR zsh
plugin_dir=${0:A:h:h}
test_dir=$(mktemp -d) || exit 1
trap 'command rm -rf -- "$test_dir"' EXIT
typeset -i tests=0 failures=0 fixture_status=0
typeset completion_state=cmds fixture_output output
autoload -Uz compinit
compinit -D -u
# Record the interpreter's arguments even when invoked in a subshell.
php() {
print -rl -- "$@" >| "$test_dir/call"
print -r -- "$fixture_output"
return $fixture_status
}
check() {
local description=$1
shift
(( tests++ ))
if "$@"; then
print -r -- "PASS: $description"
else
print -u2 -r -- "FAIL: $description"
(( failures++ ))
fi
}
source "$plugin_dir/laravel.plugin.zsh"
check 'plugin loading does not execute PHP' test ! -e "$test_dir/call"
check 'completion is registered for artisan' \
test "${_comps[artisan]}" = _artisan
for name in la4 la4dump la4cache la4routes la5 la5cache la5routes la5vendor; do
check "laravel alone does not add $name" test "${+aliases[$name]}" = 0
done
for name in la4 la5; do
check "laravel alone does not register $name completion" \
test "${+_comps[$name]}" = 0
done
for entry in \
'pas:serve' 'pam:migrate' 'pamm:make:model' 'bob:bob::build'; do
name=${entry%%:*}
expected_command=${entry#*:}
expected_call=$'artisan\n'"$expected_command"$'\nargument with spaces'
eval "$name 'argument with spaces'" > /dev/null
check "$name preserves its command and arguments" \
test "$(command cat -- "$test_dir/call")" = "$expected_call"
done
# Exercise completion dispatch without requiring an interactive ZLE session.
_arguments() { state=$completion_state; line=(migrate); return 1; }
compadd() { [[ $1 == -- ]] && shift; print -rl -- "$@"; }
_values() { print -rl -- "$@"; }
_files() { print -r -- file-completion; }
mkdir "$test_dir/project with spaces"
builtin cd "$test_dir/project with spaces"
touch artisan
fixture_output='cache:clear Clear the application cache
migrate Run migrations
project:custom Run a custom command'
output=$(_artisan)
check 'project commands, namespaces and custom commands are completed' \
test "$output" = $'cache:clear\nmigrate\nproject:custom'
check 'completion uses the portable raw list interface' \
test "$(command cat -- "$test_dir/call")" = $'artisan\nlist\n--raw\n--no-ansi'
fixture_output='routes List Laravel 4 routes
dump-autoload Regenerate autoload files'
output=$(_artisan)
check 'Laravel 4 commands are discovered rather than hardcoded' \
test "$output" = $'routes\ndump-autoload'
completion_state=args
for fixture_status in 0 1; do
command rm -f -- "$test_dir/call"
output=$(_artisan)
check "command arguments use file completion (PHP status $fixture_status)" \
test "$output" = file-completion
check "argument completion never boots Artisan (PHP status $fixture_status)" \
test ! -e "$test_dir/call"
done
completion_state=cmds
fixture_status=1
fixture_output='Unsupported option: --raw'
output=$(_artisan)
check 'legacy Artisan retains its static completion when raw listing fails' \
test "${output[(f)-1]}" = 'key\:\:generate[Generate a key]'
fixture_status=0
fixture_output=''
output=$(_artisan)
check 'an empty command list falls back to legacy completion' \
test "${output[(f)-1]}" = 'key\:\:generate[Generate a key]'
command rm "$test_dir/call"
builtin cd "$test_dir"
output=$(_artisan)
check 'completion outside a project does not execute PHP' \
test ! -e "$test_dir/call"
# A configured command may contain multiple words and quoted arguments.
wrapper() {
print -rl -- "$@" >| "$test_dir/wrapper-call"
print -r -- "$fixture_output"
}
zstyle ':omz:plugins:laravel' php 'wrapper --site "site with spaces" php'
source "$plugin_dir/../laravel5/laravel5.plugin.zsh" 2> "$test_dir/warning"
eval 'la5routes "argument with spaces"' > /dev/null
expected_call=$'--site\nsite with spaces\nphp\nartisan\nroute:list'
expected_call+=$'\nargument with spaces'
check 'legacy aliases honor a configured PHP wrapper' \
test "$(command cat -- "$test_dir/wrapper-call")" = "$expected_call"
builtin cd "$test_dir/project with spaces"
fixture_output=$'project:custom Run a custom command'
output=$(_artisan)
expected_call=$'--site\nsite with spaces\nphp\nartisan\nlist\n--raw\n--no-ansi'
check 'completion honors a configured PHP wrapper' \
test "$(command cat -- "$test_dir/wrapper-call")" = "$expected_call"
check 'wrapper output is completed' test "$output" = project:custom
zstyle -d ':omz:plugins:laravel' php
for plugin in laravel4 laravel5; do
# Start a separate shell so no previously loaded completion can hide a
# missing autoload path in the compatibility plugin.
output=$(zsh -df -c '
autoload -Uz compinit
compinit -D -u
source "$1" 2> "$2"
prefix=la${3#laravel}
for name in artisan $prefix; do
[[ ${_comps[$name]} == _artisan ]] || exit 1
done
if [[ $prefix == la4 ]]; then
[[ ${+aliases[la5]} == 0 ]] || exit 1
expected_aliases=(
la4 "php artisan" la4dump "php artisan dump-autoload"
la4cache "php artisan cache:clear" la4routes "php artisan routes"
)
else
[[ ${+aliases[la4]} == 0 ]] || exit 1
expected_aliases=(
la5 "php artisan" la5cache "php artisan cache:clear"
la5routes "php artisan route:list"
la5vendor "php artisan vendor:publish"
)
fi
for name expected in "${expected_aliases[@]}"; do
[[ ${aliases[$name]} == "$expected" ]] || exit 1
done
autoload +X _artisan || exit 1
[[ ${functions_source[_artisan]} == */laravel/_artisan ]] || exit 1
print -r -- loaded
' zsh "$plugin_dir/../$plugin/$plugin.plugin.zsh" \
"$test_dir/warning" "$plugin")
result=$?
check "$plugin loads the unified completion and original aliases" \
test "$result:$output" = '0:loaded'
check "$plugin explains how to migrate" \
test "$(command cat -- "$test_dir/warning")" != ''
done
print -r -- "$tests tests, $failures failures"
(( failures == 0 ))
+7 -12
View File
@@ -1,18 +1,13 @@
# Laravel 4 plugin # Laravel 4 plugin
This plugin adds some aliases for common [Laravel 4](https://laravel.com/docs/4.2) commands. This plugin is deprecated. Use the [laravel plugin](../laravel) instead:
To use it, add `laravel4` to the plugins array in your zshrc file:
```zsh ```zsh
plugins=(... laravel4) plugins=(... laravel)
``` ```
## Aliases This compatibility loader sources `laravel` for shared aliases and completion,
then adds the original `la4`, `la4dump`, `la4cache`, and `la4routes` aliases.
| Alias | Command | Description | These version-specific aliases are only available while `laravel4` is enabled.
|-----------|-----------------------------|-------------------------------------| When switching to `laravel` alone, use `artisan` or the shared aliases, or define
| la4 | `php artisan` | Main Artisan command | any shortcuts you still need in your own configuration.
| la4dump | `php artisan dump-autoload` | Regenerate framework autoload files |
| la4cache | `php artisan cache:clear` | Flush the application cache |
| la4routes | `php artisan routes` | List all registered routes |
+12 -17
View File
@@ -1,20 +1,15 @@
# Laravel4 basic command completion print -Pru2 -- \
_laravel4_get_command_list () { '%F{yellow}[oh-my-zsh] The %Blaravel4%b plugin is deprecated.' \
php artisan --no-ansi | sed "1,/Available commands/d" | awk '/^ +[a-z]+/ { print $1 }' 'Use %Blaravel%b instead.%f'
}
_laravel4 () { source "${0:A:h:h}/laravel/laravel.plugin.zsh"
if [ -f artisan ]; then
compadd `_laravel4_get_command_list`
fi
}
compdef _laravel4 artisan # Keep compatibility aliases scoped to users of this legacy plugin.
compdef _laravel4 la4 zstyle -s ':omz:plugins:laravel' php _omz_laravel_php || _omz_laravel_php=php
alias la4="$_omz_laravel_php artisan"
alias la4dump="$_omz_laravel_php artisan dump-autoload"
alias la4cache="$_omz_laravel_php artisan cache:clear"
alias la4routes="$_omz_laravel_php artisan routes"
unset _omz_laravel_php
#Alias compdef _artisan la4
alias la4='php artisan'
alias la4dump='php artisan dump-autoload'
alias la4cache='php artisan cache:clear'
alias la4routes='php artisan routes'
+7 -12
View File
@@ -1,18 +1,13 @@
# Laravel 5 plugin # Laravel 5 plugin
This plugin adds some aliases for common [Laravel 5](https://laravel.com/docs) commands. This plugin is deprecated. Use the [laravel plugin](../laravel) instead:
To use it, add `laravel5` to the plugins array in your zshrc file:
```zsh ```zsh
plugins=(... laravel5) plugins=(... laravel)
``` ```
## Aliases This compatibility loader sources `laravel` for shared aliases and completion,
then adds the original `la5`, `la5cache`, `la5routes`, and `la5vendor` aliases.
| Alias | Command | Description | These version-specific aliases are only available while `laravel5` is enabled.
|-----------|------------------------------|----------------------------------------------------| When switching to `laravel` alone, use `artisan` or the shared aliases, or define
| la5 | `php artisan` | Main Artisan command | any shortcuts you still need in your own configuration.
| la5cache | `php artisan cache:clear` | Flush the application cache |
| la5routes | `php artisan route:list` | List all registered routes |
| la5vendor | `php artisan vendor:publish` | Publish any publishable assets from vendor package |
+12 -16
View File
@@ -1,19 +1,15 @@
# Alias print -Pru2 -- \
alias la5='php artisan' '%F{yellow}[oh-my-zsh] The %Blaravel5%b plugin is deprecated.' \
alias la5cache='php artisan cache:clear' 'Use %Blaravel%b instead.%f'
alias la5routes='php artisan route:list'
alias la5vendor='php artisan vendor:publish'
# Laravel5 basic command completion source "${0:A:h:h}/laravel/laravel.plugin.zsh"
_laravel5_get_command_list () {
php artisan --raw --no-ansi list | sed "s/[[:space:]].*//g"
}
_laravel5 () { # Keep compatibility aliases scoped to users of this legacy plugin.
if [[ -f artisan ]]; then zstyle -s ':omz:plugins:laravel' php _omz_laravel_php || _omz_laravel_php=php
compadd $(_laravel5_get_command_list) alias la5="$_omz_laravel_php artisan"
fi alias la5cache="$_omz_laravel_php artisan cache:clear"
} alias la5routes="$_omz_laravel_php artisan route:list"
alias la5vendor="$_omz_laravel_php artisan vendor:publish"
unset _omz_laravel_php
compdef _laravel5 artisan compdef _artisan la5
compdef _laravel5 la5
+3 -3
View File
@@ -28,10 +28,10 @@ lsk() {
# Example # Example
# sqs-send user user.json # sqs-send user user.json
sqs-send(){ sqs-send(){
if [ -z "$1" ]; then if [ -z "$1" ] || [ -z "$2" ]; then
echo "Use: sqs-send <queue> <payload>" echo "Use: sqs-send <queue> <payload>" >&2
return 1 return 1
fi fi
curl -X POST "http://localhost:4566/000000000000/$1" -d "Action=SendMessage" -d "MessageBody=$(cat $2)" curl -X POST "http://localhost:4566/000000000000/$1" -d "Action=SendMessage" -d "MessageBody=$(cat "$2")"
} }
+24 -22
View File
@@ -9,6 +9,7 @@ plugins=(... macos)
``` ```
## Supported Terminals ## Supported Terminals
- [iTerm](https://iterm.sourceforge.net/) - [iTerm](https://iterm.sourceforge.net/)
- [iTerm2](https://iterm2.com/) - [iTerm2](https://iterm2.com/)
- [Hyper](https://hyper.is/) - [Hyper](https://hyper.is/)
@@ -17,28 +18,29 @@ plugins=(... macos)
## Commands ## Commands
| Command | Description | | Command | Description |
| :------------ | :------------------------------------------------------- | | :------------ | :------------------------------------------------------------- |
| `tab` | Open the current directory in a new tab | | `tab` | Open the current directory in a new tab |
| `split_tab` | Split the current terminal tab horizontally | | `split_tab` | Split the current terminal tab horizontally |
| `vsplit_tab` | Split the current terminal tab vertically | | `vsplit_tab` | Split the current terminal tab vertically |
| `ofd` | Open passed directories (or $PWD by default) in Finder | | `ofd` | Open passed directories (or $PWD by default) in Finder |
| `pfd` | Return the path of the frontmost Finder window | | `pfd` | Return the path of the frontmost Finder window |
| `pfs` | Return the current Finder selection | | `pfs` | Return the current Finder selection |
| `cdf` | `cd` to the current Finder directory | | `cdf` | `cd` to the current Finder directory |
| `pushdf` | `pushd` to the current Finder directory | | `pushdf` | `pushd` to the current Finder directory |
| `pxd` | Return the current Xcode project directory | | `pxd` | Return the current Xcode project directory |
| `cdx` | `cd` to the current Xcode project directory | | `cdx` | `cd` to the current Xcode project directory |
| `quick-look` | Quick-Look a specified file | | `quick-look` | Quick-Look a specified file |
| `man-preview` | Open man pages in Preview app | | `man-preview` | Open man pages in Preview app |
| `showfiles` | Show hidden files in Finder | | `showfiles` | Show hidden files in Finder |
| `hidefiles` | Hide the hidden files in Finder | | `hidefiles` | Hide the hidden files in Finder |
| `itunes` | _DEPRECATED_. Use `music` from macOS Catalina on | | `itunes` | _DEPRECATED_. Use `music` from macOS Catalina on |
| `music` | Control Apple Music. Use `music -h` for usage details | | `music` | Control Apple Music. Use `music -h` for usage details |
| `spotify` | Control Spotify and search by artist, album, track… | | `spotify` | Control Spotify and search by artist, album, track… |
| `rmdsstore` | Remove .DS_Store files recursively in a directory | | `lpm` | Toggle Low Power Mode. Use `lpm on\|off\|status` (macOS 12.0+) |
| `btrestart` | Restart the Bluetooth daemon | | `rmdsstore` | Remove .DS_Store files recursively in a directory |
| `freespace` | Erases purgeable disk space with 0s on the selected disk | | `btrestart` | Restart the Bluetooth daemon |
| `freespace` | Erases purgeable disk space with 0s on the selected disk |
## Acknowledgements ## Acknowledgements
+47
View File
@@ -0,0 +1,47 @@
function lpm() {
local sw_vers=$(sw_vers -productVersion 2>/dev/null)
autoload is-at-least
if [[ -z "$sw_vers" ]] || ! is-at-least 12.0 $sw_vers; then
echo "Error: Low Power Mode requires macOS 12.0 (Monterey) or later" >&2
echo "Current version: ${sw_vers:-unknown}" >&2
return 1
fi
local lpm_status
case "${1:-toggle}" in
on)
sudo pmset -a lowpowermode 1
;;
off)
sudo pmset -a lowpowermode 0
;;
status)
lpm_status=$(pmset -g | awk '/lowpowermode/ {print $2}')
if [[ "$lpm_status" == "1" ]]; then
echo "enabled"
elif [[ "$lpm_status" == "0" ]]; then
echo "disabled"
else
echo "unknown" >&2
return 3
fi
;;
toggle)
lpm_status=$(pmset -g | awk '/lowpowermode/ {print $2}')
if [[ "$lpm_status" == "1" ]]; then
sudo pmset -a lowpowermode 0
elif [[ "$lpm_status" == "0" ]]; then
sudo pmset -a lowpowermode 1
else
echo "Unable to determine current status to toggle" >&2
return 3
fi
;;
*)
echo "usage: lpm [on|off|status|toggle]" >&2
return 2
;;
esac
}
+3
View File
@@ -314,3 +314,6 @@ source "${0:h:A}/music"
# Spotify control function # Spotify control function
source "${0:h:A}/spotify" source "${0:h:A}/spotify"
# low power mode toggle-switch function
source "${0:h:A}/lpm"
+16 -13
View File
@@ -72,11 +72,6 @@ EOF
return 0 return 0
;; ;;
shuf|shuff|shuffle) shuf|shuff|shuffle)
# The shuffle property of current playlist can't be changed in iTunes 12,
# so this workaround uses AppleScript to simulate user input instead.
# Defaults to toggling when no options are given.
# The toggle option depends on the shuffle button being visible in the Now playing area.
# On and off use the menu bar items.
local state=$1 local state=$1
if [[ -n "$state" && "$state" != (on|off|toggle) ]]; then if [[ -n "$state" && "$state" != (on|off|toggle) ]]; then
@@ -85,16 +80,24 @@ EOF
fi fi
case "$state" in case "$state" in
on|off) # Inspired by: https://stackoverflow.com/a/43942013/2396771
# Inspired by: https://stackoverflow.com/a/14675583 on)
osascript >/dev/null 2>&1 <<EOF osascript -e "tell application \"$APP_NAME\" to set shuffle enabled to true";
tell application "System Events" to perform action "AXPress" of (menu item "${state}" of menu "Shuffle" of menu item "Shuffle" of menu "Controls" of menu bar item "Controls" of menu bar 1 of application process "iTunes" ) return 0
EOF ;;
off)
osascript -e "tell application \"$APP_NAME\" to set shuffle enabled to false";
return 0 return 0
;; ;;
toggle|*) toggle|*)
osascript >/dev/null 2>&1 <<EOF osascript 2>/dev/null <<EOF
tell application "System Events" to perform action "AXPress" of (button 2 of process "iTunes"'s window "iTunes"'s scroll area 1) tell application "$APP_NAME"
if shuffle enabled then
set shuffle enabled to false
else
set shuffle enabled to true
end
end tell
EOF EOF
return 0 return 0
;; ;;
@@ -107,7 +110,7 @@ EOF
echo "\tlaunch|play|pause|stop|rewind|resume|quit" echo "\tlaunch|play|pause|stop|rewind|resume|quit"
echo "\tmute|unmute\tMute or unmute $APP_NAME" echo "\tmute|unmute\tMute or unmute $APP_NAME"
echo "\tnext|previous\tPlay next or previous track" echo "\tnext|previous\tPlay next or previous track"
echo "\tshuf|shuffle [on|off|toggle]\tSet shuffled playback. Default: toggle. Note: toggle doesn't support the MiniPlayer." echo "\tshuf|shuffle [on|off|toggle]\tSet shuffled playback. Default: toggle."
echo "\tvol [0-100|up|down]\tGet or set the volume. 0 to 100 sets the volume. 'up' / 'down' increases / decreases by 10 points. No argument displays current volume." echo "\tvol [0-100|up|down]\tGet or set the volume. 0 to 100 sets the volume. 'up' / 'down' increases / decreases by 10 points. No argument displays current volume."
echo "\tplaying|status\tShow what song is currently playing in Music." echo "\tplaying|status\tShow what song is currently playing in Music."
echo "\tplaylist [playlist name]\t Play specific playlist" echo "\tplaylist [playlist name]\t Play specific playlist"
+10
View File
@@ -50,6 +50,16 @@ function _omz_nvm_setup_autoload {
zstyle -t ':omz:plugins:nvm' silent-autoload && nvm_silent="--silent" zstyle -t ':omz:plugins:nvm' silent-autoload && nvm_silent="--silent"
if [[ -n "$nvmrc_path" ]]; then if [[ -n "$nvmrc_path" ]]; then
# Skip version resolution when an exact, unaliased version is already active.
local nvmrc_version="$(<"$nvmrc_path")"
if [[ "$nvmrc_version" == v<->.<->.<-> \
&& ! -e "$NVM_DIR/alias/$nvmrc_version" \
&& "${commands[node]-}" == "$NVM_DIR/versions/node/$nvmrc_version/bin/node" \
&& -x "${commands[node]-}" ]] \
&& (( ! $+functions[node] && ! $+aliases[node] )) \
&& [[ "$nvmrc_version" == "$(command node --version 2>/dev/null)" ]]; then
return
fi
local nvmrc_node_version=$(nvm version $(command cat "$nvmrc_path" | tr -dc '[:print:]')) local nvmrc_node_version=$(nvm version $(command cat "$nvmrc_path" | tr -dc '[:print:]'))
if [[ "$nvmrc_node_version" = "N/A" ]]; then if [[ "$nvmrc_node_version" = "N/A" ]]; then
+16 -3
View File
@@ -2,7 +2,20 @@
# #
# Author: https://github.com/kevinkirkup # Author: https://github.com/kevinkirkup
if [ $commands[oc] ]; then if (( ! $+commands[oc] )); then
source <(oc completion zsh) return
compdef _oc oc fi
# If the completion file does not exist, generate it and then source it
# Otherwise, source it and regenerate in the background
if [[ ! -f "$ZSH_CACHE_DIR/completions/_oc" ]]; then
oc completion zsh | tee "$ZSH_CACHE_DIR/completions/_oc" >/dev/null
source "$ZSH_CACHE_DIR/completions/_oc"
else
source "$ZSH_CACHE_DIR/completions/_oc"
zmodload -F zsh/files b:zf_mv
() {
local TMPPREFIX="$ZSH_CACHE_DIR/completions/._oc"
zf_mv -f -- =( oc completion zsh ) "$ZSH_CACHE_DIR/completions/_oc"
} &|
fi fi
+16
View File
@@ -0,0 +1,16 @@
# Ollama
This plugin adds completion for [Ollama](https://ollama.com), the tool for running large language models locally.
To use it, add `ollama` to the plugins array in your zshrc file:
```zsh
plugins=(... ollama)
```
It completes `ollama` subcommands, their flags, and model names (from `ollama list`, or `ollama ps` for `ollama stop`).
## Credits
Adapted from [Grégoire Compagnon's gist](https://gist.github.com/obeone/9313811fd61a7cbb843e0001a4434c58)
by [Konstantin Gredeskoul](https://github.com/kigster).
+123
View File
@@ -0,0 +1,123 @@
#compdef ollama
# Based on https://gist.github.com/obeone/9313811fd61a7cbb843e0001a4434c58 by Grégoire Compagnon (@obeone),
# adapted for Oh My Zsh by Konstantin Gredeskoul (@kigster)
# Complete model names from 'ollama list', or running models from 'ollama ps'
__ollama_models_from() {
local -a models
local output="$(ollama $1 2>/dev/null | sed 's/:/\\:/g')" # escape colons for _describe
if [[ -z "$output" ]]; then
_message "no models available or 'ollama $1' failed"
return 1
fi
models=("${(@f)$(echo "$output" | awk 'NR>1 {print $1}')}")
if [[ ${#models} -eq 0 ]]; then
_message "no models found"
return 1
fi
_describe 'model names' models
}
_ollama_models() { __ollama_models_from list }
_ollama_running_models() { __ollama_models_from ps }
_ollama() {
local -a commands
_arguments -C \
'(- *)'{-v,--version}'[Show version information]' \
'1: :->command' \
'*:: :->args'
commands=(
'serve:Start ollama'
'start:Start ollama (alias for serve)'
'create:Create a model'
'show:Show information for a model'
'run:Run a model'
'stop:Stop a running model'
'pull:Pull a model from a registry'
'push:Push a model to a registry'
'signin:Sign in to ollama.com'
'signout:Sign out from ollama.com'
'login:Sign in to ollama.com (alias for signin)'
'logout:Sign out from ollama.com (alias for signout)'
'list:List models'
'ls:List models (alias for list)'
'ps:List running models'
'cp:Copy a model'
'rm:Remove a model'
'launch:Launch an integration with ollama'
'help:Help about any command'
)
case $state in
command)
_describe -t commands 'ollama command' commands
;;
args)
case $words[1] in
create)
_arguments \
'(-f --file)'{-f+,--file=}'[Name of the Modelfile]:file:_files' \
'(-q --quantize)'{-q+,--quantize=}'[Quantize model to this level]:level:' \
'--force[Continue local creation when validation fails]' \
'1:model name:'
;;
show)
_arguments \
'--license[Show license of a model]' \
'--modelfile[Show Modelfile of a model]' \
'--parameters[Show parameters of a model]' \
'--system[Show system message of a model]' \
'--template[Show template of a model]' \
'(-v --verbose)'{-v,--verbose}'[Show detailed model information]' \
'1:model:_ollama_models'
;;
run)
_arguments \
'--format=[Response format]:format:(json)' \
'--keepalive=[Duration to keep a model loaded]:duration:' \
'--think=[Enable thinking mode]:level:(true false high medium low)' \
'--hidethinking[Hide thinking output]' \
'--truncate[Truncate embedding inputs exceeding context length]' \
'--dimensions=[Truncate output embeddings to this dimension]:dimensions:' \
'--insecure[Use an insecure registry]' \
'--nowordwrap[Disable word wrap]' \
'--verbose[Show timings for response]' \
'1:model:_ollama_models' \
'2:prompt:'
;;
stop)
_arguments '1:running model:_ollama_running_models'
;;
pull|push)
_arguments \
'--insecure[Use an insecure registry]' \
'1:model:_ollama_models'
;;
cp)
_arguments \
'1:source model:_ollama_models' \
'2:target model:'
;;
rm)
_arguments '*:model:_ollama_models'
;;
launch)
_arguments \
'(-m --model)'{-m+,--model=}'[Model to use]:model:_ollama_models' \
'--config[Configure the integration without launching it]' \
'--restore[Restore the integration configuration]' \
'(-y --yes)'{-y,--yes}'[Skip confirmation prompts]' \
'1:integration:'
;;
help)
_describe -t commands 'ollama command' commands
;;
esac
;;
esac
}
_ollama "$@"
+1
View File
@@ -0,0 +1 @@
# Completion for ollama lives in _ollama, which Oh My Zsh adds to fpath
+17 -3
View File
@@ -1,4 +1,18 @@
if [ $commands[operator-sdk] ]; then # Autocompletion for the Operator SDK CLI (operator-sdk).
source <(operator-sdk completion zsh) if (( ! $+commands[operator-sdk] )); then
compdef _operator-sdk operator-sdk return
fi
# If the completion file does not exist, generate it and then source it
# Otherwise, source it and regenerate in the background
if [[ ! -f "$ZSH_CACHE_DIR/completions/_operator-sdk" ]]; then
operator-sdk completion zsh | tee "$ZSH_CACHE_DIR/completions/_operator-sdk" >/dev/null
source "$ZSH_CACHE_DIR/completions/_operator-sdk"
else
source "$ZSH_CACHE_DIR/completions/_operator-sdk"
zmodload -F zsh/files b:zf_mv
() {
local TMPPREFIX="$ZSH_CACHE_DIR/completions/._operator-sdk"
zf_mv -f -- =( operator-sdk completion zsh ) "$ZSH_CACHE_DIR/completions/_operator-sdk"
} &|
fi fi
+17 -2
View File
@@ -1,5 +1,20 @@
if (( $+commands[plz] )); then # Autocompletion for the Please build system CLI (plz).
source <(plz --completion_script) if (( ! $+commands[plz] )); then
return
fi
# If the completion file does not exist, generate it and then source it
# Otherwise, source it and regenerate in the background
if [[ ! -f "$ZSH_CACHE_DIR/completions/_plz" ]]; then
plz --completion_script | tee "$ZSH_CACHE_DIR/completions/_plz" >/dev/null
source "$ZSH_CACHE_DIR/completions/_plz"
else
source "$ZSH_CACHE_DIR/completions/_plz"
zmodload -F zsh/files b:zf_mv
() {
local TMPPREFIX="$ZSH_CACHE_DIR/completions/._plz"
zf_mv -f -- =( plz --completion_script ) "$ZSH_CACHE_DIR/completions/_plz"
} &|
fi fi
alias pb='plz build' alias pb='plz build'
+2 -2
View File
@@ -1,7 +1,7 @@
# Pre-commit plugin # Pre-commit plugin
This plugin adds aliases for common commands of [pre-commit](https://pre-commit.com/). This plugin adds aliases for common commands of [pre-commit](https://pre-commit.com/).
It also supports [prek](https://github.com/prek/prek) as a drop-in replacement. It also supports [prek](https://github.com/j178/prek) as a drop-in replacement.
If `prek` is available, it will be used; otherwise, `pre-commit` is used as fallback. If `prek` is available, it will be used; otherwise, `pre-commit` is used as fallback.
To use this plugin, add it to the plugins array in your zshrc file: To use this plugin, add it to the plugins array in your zshrc file:
@@ -15,7 +15,7 @@ plugins=(... pre-commit)
| Alias | Command | Description | | Alias | Command | Description |
| ----- | ------------------------------------------------------ | --------------------------------------------- | | ----- | ------------------------------------------------------ | --------------------------------------------- |
| prc | `prek` or `pre-commit` | The pre-commit command | | prc | `prek` or `pre-commit` | The pre-commit command |
| prcau | `prek auto-update` or `pre-commit autoupdate` | Update hooks automatically | | prcau | `prek autoupdate` or `pre-commit autoupdate` | Update hooks automatically |
| prcr | `prek run` or `pre-commit run` | The pre-commit run command | | prcr | `prek run` or `pre-commit run` | The pre-commit run command |
| prcra | `prek run --all-files` or `pre-commit run --all-files` | Run pre-commit hooks on all files | | prcra | `prek run --all-files` or `pre-commit run --all-files` | Run pre-commit hooks on all files |
| prcrf | `prek run --files` or `pre-commit run --files` | Run pre-commit hooks on a given list of files | | prcrf | `prek run --files` or `pre-commit run --files` | Run pre-commit hooks on a given list of files |
+1 -3
View File
@@ -1,15 +1,13 @@
# Aliases for pre-commit (uses prek if available, else pre-commit) # Aliases for pre-commit (uses prek if available, else pre-commit)
if command -v prek &> /dev/null; then if command -v prek &> /dev/null; then
_prc_cmd='prek' _prc_cmd='prek'
_prc_autoupdate='auto-update'
else else
_prc_cmd='pre-commit' _prc_cmd='pre-commit'
_prc_autoupdate='autoupdate'
fi fi
alias prc="$_prc_cmd" alias prc="$_prc_cmd"
alias prcau="$_prc_cmd $_prc_autoupdate" alias prcau="$_prc_cmd autoupdate"
alias prcr="$_prc_cmd run" alias prcr="$_prc_cmd run"
alias prcra="$_prc_cmd run --all-files" alias prcra="$_prc_cmd run --all-files"
+11
View File
@@ -34,6 +34,8 @@ virtual environments:
`<venv-name>/bin/activate`, and automatically deactivate it when navigating out of it (keeps venv activated `<venv-name>/bin/activate`, and automatically deactivate it when navigating out of it (keeps venv activated
in subdirectories). in subdirectories).
- To enable the feature, set `PYTHON_AUTO_VRUN=true` before sourcing oh-my-zsh. - To enable the feature, set `PYTHON_AUTO_VRUN=true` before sourcing oh-my-zsh.
- To also search parent directories (useful for monorepos), set `PYTHON_AUTO_VRUN_RECURSIVE=true` as well.
The search stops before `$HOME`, so a venv in your home directory is not activated in every folder under it.
- The plugin activates the first existing virtual environment, in order, appearing in `$PYTHON_VENV_NAMES`. - The plugin activates the first existing virtual environment, in order, appearing in `$PYTHON_VENV_NAMES`.
The default virtual environment name is `venv`. To use a different name, set The default virtual environment name is `venv`. To use a different name, set
`PYTHON_VENV_NAME=<venv-name>`. For example: `PYTHON_VENV_NAME=".venv"` `PYTHON_VENV_NAME=<venv-name>`. For example: `PYTHON_VENV_NAME=".venv"`
@@ -44,6 +46,7 @@ You can set these variables in your `.zshrc` file, before Oh My Zsh is sourced.
For example: For example:
```sh ```sh
PYTHON_AUTO_VRUN=true
PYTHON_VENV_NAME=".venv" PYTHON_VENV_NAME=".venv"
PYTHON_VENV_NAMES=($PYTHON_VENV_NAME venv) PYTHON_VENV_NAMES=($PYTHON_VENV_NAME venv)
... ...
@@ -52,6 +55,14 @@ source "$ZSH/oh-my-zsh.sh"
``` ```
## `$PYTHON_AUTO_VRUN`
**Default**: `false`.
Enable automatic activation of virtual environments when entering a directory containing
`<venv-name>/bin/activate`, and automatically deactivate it when navigating out of it.
Set to `true` to enable this feature.
## `$PYTHON_VENV_NAME` ## `$PYTHON_VENV_NAME`
**Default**: `venv`. **Default**: `venv`.
+16 -1
View File
@@ -113,8 +113,23 @@ if [[ "$PYTHON_AUTO_VRUN" == "true" ]]; then
# make sure we're not in a venv already # make sure we're not in a venv already
(( $+functions[deactivate] )) && deactivate > /dev/null 2>&1 (( $+functions[deactivate] )) && deactivate > /dev/null 2>&1
source $file > /dev/null 2>&1 source $file > /dev/null 2>&1
break return
done done
# Search parent directories if recursive mode is enabled, stopping before $HOME
if [[ "$PYTHON_AUTO_VRUN_RECURSIVE" == "true" ]]; then
local search_dir="$PWD:h"
while [[ "$search_dir" != "/" && "$search_dir" != "." && "$search_dir" != "$HOME" ]]; do
for file in "${search_dir}/"${^PYTHON_VENV_NAMES[@]}"/bin/activate"(N.); do
# the venv found is already active
[[ "${file:h:h:A}" == "${VIRTUAL_ENV:A}" ]] && return
(( $+functions[deactivate] )) && deactivate > /dev/null 2>&1
source $file > /dev/null 2>&1
return
done
search_dir="${search_dir:h}"
done
fi
fi fi
} }
add-zsh-hook chpwd auto_vrun add-zsh-hook chpwd auto_vrun
+20
View File
@@ -0,0 +1,20 @@
# sprite plugin
This plugin adds completion for the [Sprites CLI](https://docs.sprites.dev/cli/installation) (`sprite`).
To use it, add `sprite` to the plugins array in your zshrc file:
```zsh
plugins=(... sprite)
```
This plugin does not add any aliases.
## Cache
This plugin caches the completion script and is automatically updated asynchronously when the plugin is
loaded, which is usually when you start up a new terminal emulator.
The cache is stored at:
- `$ZSH_CACHE_DIR/completions/_sprite` completions script
+17
View File
@@ -0,0 +1,17 @@
# Autocompletion for sprite
if (( ! $+commands[sprite] )); then
return
fi
# If the completion file doesn't exist yet, we need to autoload it and
# bind it to `sprite`. Otherwise, compinit will have already done that.
if [[ ! -f "$ZSH_CACHE_DIR/completions/_sprite" ]]; then
typeset -g -A _comps
autoload -Uz _sprite
_comps[sprite]=_sprite
fi
() {
local tmpfile="$ZSH_CACHE_DIR/completions/_sprite.$$.tmp"
sprite completion zsh >| "$tmpfile" 2>/dev/null && command mv -f "$tmpfile" "$ZSH_CACHE_DIR/completions/_sprite" || command rm -f "$tmpfile"
} &|
+16 -4
View File
@@ -1,6 +1,18 @@
# Autocompletion for svcat. # Autocompletion for the Service Catalog CLI (svcat).
# if (( ! $+commands[svcat] )); then
return
fi
if [ $commands[svcat] ]; then # If the completion file does not exist, generate it and then source it
source <(svcat completion zsh) # Otherwise, source it and regenerate in the background
if [[ ! -f "$ZSH_CACHE_DIR/completions/_svcat" ]]; then
svcat completion zsh | tee "$ZSH_CACHE_DIR/completions/_svcat" >/dev/null
source "$ZSH_CACHE_DIR/completions/_svcat"
else
source "$ZSH_CACHE_DIR/completions/_svcat"
zmodload -F zsh/files b:zf_mv
() {
local TMPPREFIX="$ZSH_CACHE_DIR/completions/._svcat"
zf_mv -f -- =( svcat completion zsh ) "$ZSH_CACHE_DIR/completions/_svcat"
} &|
fi fi
+8 -8
View File
@@ -153,34 +153,34 @@ function port_pro() {
# top10 of gain access to the ip address # top10 of gain access to the ip address
function accessip10() { function accessip10() {
awk '{counts[$(11)]+=1}; END {for(url in counts) print counts[url], url}' "$(retlog)" awk '{counts[$(11)]+=1}; END {for(url in counts) print counts[url], url}' "$(retlog "$1")"
} }
# top20 of Most Visited file or page # top20 of Most Visited file or page
function visitpage20() { function visitpage20() {
awk '{print $11}' "$(retlog)" | sort | uniq -c | sort -nr | head -n 20 awk '{print $11}' "$(retlog "$1")" | sort | uniq -c | sort -nr | head -n 20
} }
# top100 of Page lists the most time-consuming (more than 60 seconds) as well as the corresponding page number of occurrences # top100 of Page lists the most time-consuming (more than 60 seconds) as well as the corresponding page number of occurrences
function consume100() { function consume100() {
awk '($NF > 60 && $7~/\.php/){print $7}' "$(retlog)" | sort -n | uniq -c | sort -nr | head -n 100 awk '($NF > 60 && $7~/\.php/){print $7}' "$(retlog "$1")" | sort -n | uniq -c | sort -nr | head -n 100
# if django website or other website make by no suffix language # if django website or other website make by no suffix language
# awk '{print $7}' "$(retlog)" | sort -n | uniq -c | sort -nr | head -n 100 # awk '{print $7}' "$(retlog "$1")" | sort -n | uniq -c | sort -nr | head -n 100
} }
# Website traffic statistics (G) # Website traffic statistics (G)
function webtraffic() { function webtraffic() {
awk '{sum+=$10} END {print sum/1024/1024/1024}' "$(retlog)" awk '{sum+=$10} END {print sum/1024/1024/1024}' "$(retlog "$1")"
} }
# Statistical connections 404 # Statistical connections 404
function c404() { function c404() {
awk '($9 ~ /404/)' "$(retlog)" | awk '{print $9,$7}' | sort awk '($9 ~ /404/)' "$(retlog "$1")" | awk '{print $9,$7}' | sort
} }
# Statistical http status. # Statistical http status.
function httpstatus() { function httpstatus() {
awk '{counts[$(9)]+=1}; END {for(code in counts) print code, counts[code]}' "$(retlog)" awk '{counts[$(9)]+=1}; END {for(code in counts) print code, counts[code]}' "$(retlog "$1")"
} }
# Delete 0 byte file # Delete 0 byte file
@@ -211,5 +211,5 @@ function getip() {
# Second concurrent # Second concurrent
function conssec() { function conssec() {
awk '{if($9~/200|30|404/)COUNT[$4]++}END{for( a in COUNT) print a,COUNT[a]}' "$(retlog)" | sort -k 2 -nr | head -n10 awk '{if($9~/200|30|404/)COUNT[$4]++}END{for( a in COUNT) print a,COUNT[a]}' "$(retlog "$1")" | sort -k 2 -nr | head -n10
} }
+23 -1
View File
@@ -24,7 +24,7 @@ plugins=(... systemd)
| `sc-show-environment` | `systemctl show-environment` | Dump the systemd manager environment block | | `sc-show-environment` | `systemctl show-environment` | Dump the systemd manager environment block |
| `sc-cat` | `systemctl cat` | Show backing files of one or more units | | `sc-cat` | `systemctl cat` | Show backing files of one or more units |
| `sc-list-timers` | `systemctl list-timers` | List timer units currently in memory | | `sc-list-timers` | `systemctl list-timers` | List timer units currently in memory |
| **Aliases with sudo** ||| | **Privileged aliases** |||
| `sc-start` | `sudo systemctl start` | Start Unit(s) | | `sc-start` | `sudo systemctl start` | Start Unit(s) |
| `sc-stop` | `sudo systemctl stop` | Stop Unit(s) | | `sc-stop` | `sudo systemctl stop` | Stop Unit(s) |
| `sc-reload` | `sudo systemctl reload` | Reload Unit(s) | | `sc-reload` | `sudo systemctl reload` | Reload Unit(s) |
@@ -50,6 +50,28 @@ plugins=(... systemd)
| `sc-disable-now` | `sudo systemctl disable --now` | Disable and stop unit(s) | | `sc-disable-now` | `sudo systemctl disable --now` | Disable and stop unit(s) |
| `sc-mask-now` | `sudo systemctl mask --now` | Mask and stop unit(s) | | `sc-mask-now` | `sudo systemctl mask --now` | Mask and stop unit(s) |
### Privileged aliases
systemd plugin supports alternative privilege elevation tools. You can prepend an arbitrary string,
replacing `sudo`, to the privileged aliases by setting `$ZSH_SYSTEMD_SUDO` variable. You can leave
authorization to systemd by setting `$ZSH_SYSTEMD_SUDO` to an empty string.
To use `doas` as your elevation tool you will need to add the following line to your zshrc;
```zsh
ZSH_SYSTEMD_SUDO="doas"
```
After shell restart, you will see that alias for `sc-enable` is changed:
```sh
$ which sc-enable
sc-enable: aliased to doas systemctl enable
```
These aliases are evaluated during oh-my-zsh startup, and can't be changed interactively (you will
need to restart shell to see changes).
### User aliases ### User aliases
You can use the above aliases as `--user` by using the prefix `scu` instead of `sc`. You can use the above aliases as `--user` by using the prefix `scu` instead of `sc`.
Loaded 100 of 117 files, more files were not shown because too many files have changed in this diff. Show more