Compare commits

..
Author SHA1 Message Date
Robby Russell b20d95c390 fix(gh): preserve valid completion cache on failure 2026-09-26 19:00:22 -05:00
221 changed files with 579 additions and 4114 deletions

No files matched your search

+15 -51
View File
@@ -1,57 +1,21 @@
<!-- ## 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.
Report only evidence you have. Distinguish agent-run checks from personal <!-- Fill with an x the ones that apply. Example: [x] -->
testing, identify missing checks or demos, and leave unconfirmed items
unchecked. Don't promise follow-up work on someone else's behalf.
-->
## What and why - [ ] The PR title is descriptive.
- [ ] The PR doesn't replicate another PR which is already open.
- [ ] I have read the contribution guide and followed all the instructions.
- [ ] The code follows the code style guide detailed in the wiki.
- [ ] The code is mine or it's from somewhere with an MIT-compatible license.
- [ ] 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.
<!-- What changes, who benefits, and how does it make their command-line ## Changes:
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. -->
## Demo and verification ## Other comments:
<!-- 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>
+4 -4
View File
@@ -12,7 +12,7 @@ dependencies:
plugins/gradle: plugins/gradle:
repo: gradle/gradle-completion repo: gradle/gradle-completion
branch: master branch: master
version: 05693a01fcb246bc4e8fc32a8d561dc537aaedf2 version: e7c881dbef7462bc35ad05328397e1582fe25cb8
precopy: | precopy: |
set -e set -e
find . ! -name _gradle ! -name LICENSE -delete find . ! -name _gradle ! -name LICENSE -delete
@@ -30,7 +30,7 @@ dependencies:
plugins/kube-ps1: plugins/kube-ps1:
repo: jonmosco/kube-ps1 repo: jonmosco/kube-ps1
branch: master branch: master
version: 7aaaeee5eaa29f920acd850ea63839d9f87b8ac5 version: b4cd09ec8d4dc007173e28da40aeebf8eff8c87f
precopy: | precopy: |
set -e set -e
find . ! -name kube-ps1.sh ! -name LICENSE ! -name README.md -delete find . ! -name kube-ps1.sh ! -name LICENSE ! -name README.md -delete
@@ -46,7 +46,7 @@ dependencies:
plugins/z: plugins/z:
branch: master branch: master
repo: agkozak/zsh-z repo: agkozak/zsh-z
version: 7f8ff4df11b50a14e3666c7cd212baa399c9b92a version: 102fb78036ed76feedf623907483691777a1d510
precopy: | precopy: |
set -e set -e
rm -r tests rm -r tests
@@ -75,7 +75,7 @@ dependencies:
plugins/zsh-syntax-highlighting: plugins/zsh-syntax-highlighting:
repo: zsh-users/zsh-syntax-highlighting repo: zsh-users/zsh-syntax-highlighting
branch: master branch: master
version: e6683f20e5c38d3e5447f45845d04ddda75d0f23 version: 2fc57d63067c18b1100ecdbf684fa5baf49459d1
precopy: | precopy: |
set -e set -e
version=$(<.version) version=$(<.version)
@@ -1,2 +0,0 @@
# default known collisions file
known_collisions.json
@@ -1,170 +0,0 @@
"""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())
@@ -1,2 +0,0 @@
pyfakefs
pytest
@@ -1,166 +0,0 @@
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
+3 -3
View File
@@ -16,7 +16,7 @@ jobs:
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@e14015d583714f6e62063499dc959a02595150a1 # v2.21.1
with: with:
egress-policy: audit egress-policy: audit
@@ -26,12 +26,12 @@ jobs:
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@bcd2ba49218906704ab6c1aa796996da409d3eb1 # v3.2.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 }}
- name: Setup Python - name: Setup Python
uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7.1.0 uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.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.7.22
charset-normalizer==3.5.2 charset-normalizer==3.5.1
idna==3.20 idna==3.19
PyYAML==6.0.3 PyYAML==6.0.3
requests==2.34.2 requests==2.34.2
semver==3.1.2 semver==3.1.0
urllib3==2.8.0 urllib3==2.8.0
+2 -2
View File
@@ -26,7 +26,7 @@ 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@e14015d583714f6e62063499dc959a02595150a1 # v2.21.1
with: with:
egress-policy: audit egress-policy: audit
@@ -47,7 +47,7 @@ jobs:
- 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@e14015d583714f6e62063499dc959a02595150a1 # v2.21.1
with: with:
egress-policy: audit egress-policy: audit
+1 -29
View File
@@ -24,7 +24,7 @@ jobs:
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@e14015d583714f6e62063499dc959a02595150a1 # v2.21.1
with: with:
egress-policy: audit egress-policy: audit
@@ -41,31 +41,3 @@ jobs:
./themes/*.zsh-theme; do ./themes/*.zsh-theme; do
zsh -n "$file" || return 1 zsh -n "$file" || return 1
done done
collisions:
name: Check alias collisions
runs-on: ubuntu-latest
steps:
- name: Set up git repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Set up Python
uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.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@3d3c42e5aac5ba805825da76410c181273ba90b1 # 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
+2 -2
View File
@@ -17,12 +17,12 @@ jobs:
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@e14015d583714f6e62063499dc959a02595150a1 # v2.21.1
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@bcd2ba49218906704ab6c1aa796996da409d3eb1 # v3.2.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 }}
+4 -4
View File
@@ -36,7 +36,7 @@ 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@e14015d583714f6e62063499dc959a02595150a1 # v2.21.1
with: with:
egress-policy: audit egress-policy: audit
@@ -46,20 +46,20 @@ jobs:
persist-credentials: false persist-credentials: false
- name: "Run analysis" - name: "Run analysis"
uses: ossf/scorecard-action@23f22cd43608bae7a1f1fa2603d7314dee9538a5 # v2.6.0 uses: ossf/scorecard-action@2d1146689b8cda280b9bc96326124645441f03bc # v2.4.4
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@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
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@b96794f015dfd88f77b49b1c93e0fa7110f94c63 # v4.38.0
with: with:
sarif_file: results.sarif sarif_file: results.sarif
-37
View File
@@ -18,7 +18,6 @@ you would make is not already covered.
- [You have a suggestion](#you-have-a-suggestion) - [You have a suggestion](#you-have-a-suggestion)
- [Submitting Pull Requests](#submitting-pull-requests) - [Submitting Pull Requests](#submitting-pull-requests)
- [Getting started](#getting-started) - [Getting started](#getting-started)
- [Writing your PR description](#writing-your-pr-description)
- [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)
- [A note on AI-assisted contributions](#a-note-on-ai-assisted-contributions) - [A note on AI-assisted contributions](#a-note-on-ai-assisted-contributions)
@@ -79,42 +78,6 @@ any issue that would be solved in the PR description body,
[for instance](https://help.github.com/articles/closing-issues-via-commit-messages/) [for instance](https://help.github.com/articles/closing-issues-via-commit-messages/)
_"Fixes #XXXX"_ for issue number XXXX. _"Fixes #XXXX"_ for issue number XXXX.
### 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.
**For coding agents:** read these guidelines and the PR template before drafting a
PR. Keep the description grounded in available evidence. Don't invent user requests,
test results, or demo links, and don't claim personal testing or confirmation on the
contributor's behalf. Leave unconfirmed checklist items unchecked and identify
missing testing or demos. Don't commit the contributor to follow-up work they
haven't agreed to. Disclose meaningful AI assistance in the template's "Other notes"
section, following the [AI contribution guidance](#a-note-on-ai-assisted-contributions).
### You have a solution ### You have a solution
Please be so kind as to [search](#use-the-search-luke) for any open issue already covering Please be so kind as to [search](#use-the-search-luke) for any open issue already covering
-42
View File
@@ -45,7 +45,6 @@ Twitter), and join us on [Discord](https://discord.gg/ohmyzsh).
- [Using Plugins](#using-plugins) - [Using Plugins](#using-plugins)
- [Themes](#themes) - [Themes](#themes)
- [Selecting A Theme](#selecting-a-theme) - [Selecting A Theme](#selecting-a-theme)
- [Shellsavers](#shellsavers)
- [FAQ](#faq) - [FAQ](#faq)
- [Advanced Topics](#advanced-topics) - [Advanced Topics](#advanced-topics)
- [Advanced Installation](#advanced-installation) - [Advanced Installation](#advanced-installation)
@@ -242,33 +241,6 @@ If you only know which themes you don't like, you can add them similarly to an i
ZSH_THEME_RANDOM_IGNORED=(pygmalion tjkirch_mod) ZSH_THEME_RANDOM_IGNORED=(pygmalion tjkirch_mod)
``` ```
### Shellsavers
Give your terminal a little downtime with `omz shellsaver`—our playful name for
terminal screensavers. The aquarium is the default; choose another scene to change the mood:
```zsh
omz shellsaver # A quiet aquarium full of sea shells
omz shellsaver logo # The updater's rainbow logo, bouncing around
omz shellsaver hermit # A slightly lost hermit crab
omz shellsaver party # A rainbow stage and a dancing crowd
```
Press any key or Ctrl-C to return to your shell. Screensavers run only when invoked
and restore the terminal when they exit. No plugin or configuration change is needed.
Use `omz help` to discover the command, and Tab to complete scene names and options.
```zsh
omz shellsaver aquarium --seconds 30 # Stop automatically after 30 seconds
omz shellsaver logo --mono # Use the terminal's foreground color
omz shellsaver --list # List scenes (aquarium is the default)
omz shellsaver --help # Show all scenes and options
```
Requires Zsh 5.8 or newer, `stty`, and an xterm-compatible terminal with alternate-screen
support. No additional animation package is required. `NO_COLOR` is respected.
A window of at least 49 columns by 18 rows is recommended.
### FAQ ### FAQ
If you have some more questions or issues, you might find a solution in our If you have some more questions or issues, you might find a solution in our
@@ -552,20 +524,6 @@ omz update
Magic! 🎉 Magic! 🎉
## Diagnostics
If something looks off (glitched characters, completions misbehaving), run:
```sh
omz diagnose
```
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
(see the [FAQ](https://github.com/ohmyzsh/ohmyzsh/wiki/FAQ#i-see-duplicate-typed-characters-after-i-complete-a-command)).
For a full report suitable for attaching to a bug report, use `omz_diagnostic_dump`.
## Uninstalling Oh My Zsh ## Uninstalling Oh My Zsh
Oh My Zsh isn't for everyone. We'll miss you, but we want to make this an easy breakup. Oh My Zsh isn't for everyone. We'll miss you, but we want to make this an easy breakup.
+2 -56
View File
@@ -24,30 +24,16 @@ function _omz {
local -a cmds subcmds local -a cmds subcmds
cmds=( cmds=(
'changelog:Print the changelog' 'changelog:Print the changelog'
'diagnose:Run configuration diagnostics'
'help:Usage information' 'help:Usage information'
'plugin:Manage plugins' 'plugin:Manage plugins'
'pr:Manage Oh My Zsh Pull Requests' 'pr:Manage Oh My Zsh Pull Requests'
'reload:Reload the current zsh session' 'reload:Reload the current zsh session'
'shellsaver:Launch a whimsical terminal screensaver'
'shop:Open the Oh My Zsh shop' 'shop:Open the Oh My Zsh shop'
'theme:Manage themes' 'theme:Manage themes'
'update:Update Oh My Zsh' 'update:Update Oh My Zsh'
'version:Show the version' 'version:Show the version'
) )
if [[ "$words[2]" == (screensaver|shellsaver) ]] && (( CURRENT > 2 )); then
_arguments \
'1:command:' \
'2::scene:(aquarium logo hermit party)' \
'--list[List available scenes]' \
'--mono[Use the default foreground color]' \
'--seconds[Exit after a number of seconds]:seconds:' \
'--snapshot[Print a plain-text still]::frame:' \
'--help[Show Shellsaver help]'
return
fi
if (( CURRENT == 2 )); then if (( CURRENT == 2 )); then
_describe 'command' cmds _describe 'command' cmds
elif (( CURRENT == 3 )); then elif (( CURRENT == 3 )); then
@@ -177,42 +163,17 @@ function _omz::log {
## User-facing commands ## User-facing commands
function _omz::diagnose {
# Check the runtime locale: non-UTF-8 charsets are known to cause glitches
# such as duplicated characters at the prompt after completions.
# https://github.com/ohmyzsh/ohmyzsh/wiki/FAQ#i-see-duplicate-typed-characters-after-i-complete-a-command
#
# `lib/functions.zsh` loads the zsh/langinfo module at startup, so the
# CODESET parameter is already available without any subprocess; only fall
# back to `locale charmap` when that module is unavailable (zsh built without it).
local codeset="${langinfo[CODESET]:-}"
if [[ -z "$codeset" ]] && (( $+commands[locale] )); then
codeset="$(locale charmap 2>/dev/null)"
fi
if [[ "${codeset:l}" = (utf-8|utf8) ]]; then
_omz::log info "locale charmap is UTF-8"
else
_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 "consider setting a UTF-8 locale, e.g.: export LANG=C.UTF-8"
return 1
fi
}
function _omz::help { function _omz::help {
cat >&2 <<EOF cat >&2 <<EOF
Usage: omz <command> [options] Usage: omz <command> [options]
Available commands: Available commands:
diagnose Run configuration diagnostics
help Print this help message help Print this help message
changelog Print the changelog changelog Print the changelog
plugin <command> Manage plugins plugin <command> Manage plugins
pr <command> Manage Oh My Zsh Pull Requests pr <command> Manage Oh My Zsh Pull Requests
reload Reload the current zsh session reload Reload the current zsh session
shellsaver [scene] Launch a Shellsaver (aquarium by default)
shop Open the Oh My Zsh shop shop Open the Oh My Zsh shop
theme <command> Manage themes theme <command> Manage themes
update Update Oh My Zsh update Update Oh My Zsh
@@ -221,15 +182,6 @@ Available commands:
EOF EOF
} }
function _omz::shellsaver {
command zsh -f "$ZSH/tools/shellsaver.zsh" "$@"
}
# Hidden alias; only shellsaver is advertised in help and command completion.
function _omz::screensaver {
_omz::shellsaver "$@"
}
function _omz::changelog { function _omz::changelog {
local version=${1:-HEAD} format=${3:-"--text"} local version=${1:-HEAD} format=${3:-"--text"}
@@ -295,12 +247,7 @@ 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="\
do {
prev = \$0
gsub(/[ \t]+(${(j:|:)dis_plugins})[ \t]+/, \" \") # with spaces before or after gsub(/[ \t]+(${(j:|:)dis_plugins})[ \t]+/, \" \") # with spaces before or after
gsub(/[ \t]+(${(j:|:)dis_plugins})$/, \"\") # with spaces before and EOL gsub(/[ \t]+(${(j:|:)dis_plugins})$/, \"\") # with spaces before and EOL
gsub(/^(${(j:|:)dis_plugins})[ \t]+/, \"\") # with BOL and spaces after gsub(/^(${(j:|:)dis_plugins})[ \t]+/, \"\") # with BOL and spaces after
@@ -311,7 +258,6 @@ function _omz::plugin::disable {
gsub(/^(${(j:|:)dis_plugins})\)/, \")\") # with BOL and closing parenthesis gsub(/^(${(j:|:)dis_plugins})\)/, \")\") # with BOL and closing parenthesis
gsub(/\((${(j:|:)dis_plugins})$/, \"(\") # with opening parenthesis and EOL gsub(/\((${(j:|:)dis_plugins})$/, \"(\") # with opening parenthesis and EOL
} while (\$0 != prev)
" "
# Disable plugins awk script # Disable plugins awk script
@@ -398,8 +344,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 (empty or not), substitute ) with new plugins and go to the next line # if plugins=() is in oneline form, 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
+1 -31
View File
@@ -16,10 +16,6 @@
# - 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.
# #
# Defines two functions, clipcopy and clippaste, based on the detected platform. # Defines two functions, clipcopy and clippaste, based on the detected platform.
## ##
@@ -52,22 +48,6 @@
# # 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
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
@@ -79,10 +59,7 @@ function detect-clipboard() {
function clippaste() { cat /dev/clipboard; } function clippaste() { cat /dev/clipboard; }
elif (( $+commands[clip.exe] )) && (( $+commands[powershell.exe] )); then elif (( $+commands[clip.exe] )) && (( $+commands[powershell.exe] )); then
function clipcopy() { cat "${1:-/dev/stdin}" | clip.exe; } function clipcopy() { cat "${1:-/dev/stdin}" | clip.exe; }
function clippaste() { function clippaste() { powershell.exe -noprofile -command Get-Clipboard; }
setopt localoptions pipefail
powershell.exe -noprofile -command Get-Clipboard | tr -d '\r'
}
elif [ -n "${WAYLAND_DISPLAY:-}" ] && (( ${+commands[wl-copy]} )) && (( ${+commands[wl-paste]} )); then elif [ -n "${WAYLAND_DISPLAY:-}" ] && (( ${+commands[wl-copy]} )) && (( ${+commands[wl-paste]} )); then
function clipcopy() { cat "${1:-/dev/stdin}" | wl-copy &>/dev/null &|; } function clipcopy() { cat "${1:-/dev/stdin}" | wl-copy &>/dev/null &|; }
function clippaste() { wl-paste --no-newline; } function clippaste() { wl-paste --no-newline; }
@@ -107,9 +84,6 @@ 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
@@ -124,10 +98,6 @@ 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 {
+1 -2
View File
@@ -178,8 +178,7 @@ function omz_urlencode() {
setopt norematchpcre setopt norematchpcre
local -a opts local -a opts
# Quote the specs so global aliases (e.g. common-aliases' P) don't expand here zparseopts -D -E -a opts r m P
zparseopts -D -E -a opts 'r' 'm' 'P'
local in_str="$@" local in_str="$@"
local url_str="" local url_str=""
-11
View File
@@ -2,8 +2,6 @@
# 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=(
@@ -20,16 +18,7 @@ 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} )
+5 -7
View File
@@ -5,6 +5,7 @@
# See: http://www.faqs.org/docs/Linux-mini/Xterm-Title.html#ss3.1 # See: http://www.faqs.org/docs/Linux-mini/Xterm-Title.html#ss3.1
# Fully supports screen, iterm, and probably most modern xterm and rxvt # Fully supports screen, iterm, and probably most modern xterm and rxvt
# (In screen, only short_tab_title is used) # (In screen, only short_tab_title is used)
# Limited support for Apple Terminal (Terminal can't set window and tab separately)
function title { function title {
setopt localoptions nopromptsubst setopt localoptions nopromptsubst
@@ -16,7 +17,7 @@ function title {
: ${2=$1} : ${2=$1}
case "$TERM" in case "$TERM" in
cygwin|xterm*|putty*|rxvt*|konsole*|ansi|mlterm*|alacritty*|st*|foot*|contour*|wezterm*|nsterm*) cygwin|xterm*|putty*|rxvt*|konsole*|ansi|mlterm*|alacritty*|st*|foot*|contour*|wezterm*)
print -Pn "\e]2;${2:q}\a" # set window name print -Pn "\e]2;${2:q}\a" # set window name
print -Pn "\e]1;${1:q}\a" # set tab name print -Pn "\e]1;${1:q}\a" # set tab name
;; ;;
@@ -25,12 +26,10 @@ function title {
print -Pn "\ek${1:q}\e\\" # set screen hardstatus/tmux window name if `allow-rename` is on print -Pn "\ek${1:q}\e\\" # set screen hardstatus/tmux window name if `allow-rename` is on
;; ;;
*) *)
case "$TERM_PROGRAM" in if [[ "$TERM_PROGRAM" == "iTerm.app" ]]; then
"iTerm.app"|"Apple_Terminal")
print -Pn "\e]2;${2:q}\a" # set window name print -Pn "\e]2;${2:q}\a" # set window name
print -Pn "\e]1;${1:q}\a" # set tab name print -Pn "\e]1;${1:q}\a" # set tab name
;; else
*)
# Try to use terminfo to set the title if the feature is available # Try to use terminfo to set the title if the feature is available
if (( ${+terminfo[fsl]} && ${+terminfo[tsl]} )); then if (( ${+terminfo[fsl]} && ${+terminfo[tsl]} )); then
# Emit the capabilities with echoti so terminfo does its own parameter # Emit the capabilities with echoti so terminfo does its own parameter
@@ -40,8 +39,7 @@ function title {
print -Pn "$1" print -Pn "$1"
echoti fsl echoti fsl
fi fi
;; fi
esac
;; ;;
esac esac
} }
-35
View File
@@ -7,9 +7,6 @@ run_awk() {
(( ! DEBUG )) || set -xv (( ! DEBUG )) || set -xv
local awk_subst_plugins="\ local awk_subst_plugins="\
do {
prev = \$0
gsub(/[ \t]+(${(j:|:)dis_plugins})[ \t]+/, \" \") # with spaces before or after gsub(/[ \t]+(${(j:|:)dis_plugins})[ \t]+/, \" \") # with spaces before or after
gsub(/[ \t]+(${(j:|:)dis_plugins})$/, \"\") # with spaces before and EOL gsub(/[ \t]+(${(j:|:)dis_plugins})$/, \"\") # with spaces before and EOL
gsub(/^(${(j:|:)dis_plugins})[ \t]+/, \"\") # with BOL and spaces after gsub(/^(${(j:|:)dis_plugins})[ \t]+/, \"\") # with BOL and spaces after
@@ -20,7 +17,6 @@ run_awk() {
gsub(/^(${(j:|:)dis_plugins})\)/, \")\") # with BOL and closing parenthesis gsub(/^(${(j:|:)dis_plugins})\)/, \")\") # with BOL and closing parenthesis
gsub(/\((${(j:|:)dis_plugins})$/, \"(\") # with opening parenthesis and EOL 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="
@@ -171,34 +167,3 @@ 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
)"
+2 -2
View File
@@ -11,8 +11,8 @@ fi
zmodload -F zsh/files b:zf_mv zmodload -F zsh/files b:zf_mv
() { () {
local TMPPREFIX="$ZSH_CACHE_DIR/completions/._op" local TMPPREFIX="$ZSH_CACHE_DIR/completions/_op"
zf_mv -f -- =( op completion zsh ) "$ZSH_CACHE_DIR/completions/_op" zf_mv -f -- =( op completion zsh ) "$TMPPREFIX"
} &| } &|
# Load opswd function # Load opswd function
+5 -9
View File
@@ -1,5 +1,5 @@
alias-finder() { alias-finder() {
local c="" cmd=" " exact="" longer="" cheaper="" wordEnd="'?$" finder="" filter="" cmdLen="" local cmd=" " exact="" longer="" cheaper="" wordEnd="'?$" finder="" filter=""
# build command and options # build command and options
for c in "$@"; do for c in "$@"; do
@@ -19,15 +19,11 @@ alias-finder() {
zstyle -t ':omz:plugins:alias-finder' cheaper && cheaper=true zstyle -t ':omz:plugins:alias-finder' cheaper && cheaper=true
# format cmd for grep # format cmd for grep
## - replace newlines and multiple spaces with one space ## - replace newlines with spaces
## - trim both ends ## - trim both ends
## - replace multiple spaces with one space
## - add escaping character to special characters ## - add escaping character to special characters
setopt localoptions extendedglob cmd=$(echo -n "$cmd" | tr '\n' ' ' | xargs | tr -s '[:space:]' | sed 's/[].\|$(){}?+*^[]/\\&/g')
cmd=${cmd//[[:space:]]##/ }
cmd=${cmd# }
cmd=${cmd% }
local esc_pattern='(#m)[][.\\|$(){}?+*^]' MATCH MBEGIN MEND
cmd=${cmd//${~esc_pattern}/\\$MATCH}
if [[ $longer == true ]]; then if [[ $longer == true ]]; then
wordEnd="" # remove wordEnd to find longer aliases wordEnd="" # remove wordEnd to find longer aliases
@@ -39,7 +35,7 @@ alias-finder() {
# make filter to find only shorter results than current cmd # make filter to find only shorter results than current cmd
if [[ $cheaper == true ]]; then if [[ $cheaper == true ]]; then
cmdLen=${#cmd} cmdLen=$(echo -n "$cmd" | wc -c)
if [[ $cmdLen -le 1 ]]; then if [[ $cmdLen -le 1 ]]; then
return return
fi fi
+2 -2
View File
@@ -13,6 +13,6 @@ fi
# Generate and load arduino-cli completion # Generate and load arduino-cli completion
zmodload -F zsh/files b:zf_mv zmodload -F zsh/files b:zf_mv
() { () {
local TMPPREFIX="$ZSH_CACHE_DIR/completions/._arduino-cli" local TMPPREFIX="$ZSH_CACHE_DIR/completions/_arduino-cli"
zf_mv -f -- =( arduino-cli completion zsh ) "$ZSH_CACHE_DIR/completions/_arduino-cli" zf_mv -f -- =( arduino-cli completion zsh ) "$TMPPREFIX"
} &| } &|
+2 -2
View File
@@ -13,6 +13,6 @@ fi
zmodload -F zsh/files b:zf_mv zmodload -F zsh/files b:zf_mv
() { () {
local TMPPREFIX="$ZSH_CACHE_DIR/completions/._argocd" local TMPPREFIX="$ZSH_CACHE_DIR/completions/_argocd"
zf_mv -f -- =( argocd completion zsh ) "$ZSH_CACHE_DIR/completions/_argocd" zf_mv -f -- =( argocd completion zsh ) "$TMPPREFIX"
} &| } &|
+2 -2
View File
@@ -14,6 +14,6 @@ if [[ ! -f "$ZSH_CACHE_DIR/completions/_asdf" ]]; then
fi fi
zmodload -F zsh/files b:zf_mv zmodload -F zsh/files b:zf_mv
() { () {
local TMPPREFIX="$ZSH_CACHE_DIR/completions/._asdf" local TMPPREFIX="$ZSH_CACHE_DIR/completions/_asdf"
zf_mv -f -- =( asdf completion zsh ) "$ZSH_CACHE_DIR/completions/_asdf" zf_mv -f -- =( asdf completion zsh ) "$TMPPREFIX"
} &| } &|
+1 -2
View File
@@ -35,8 +35,7 @@ plugins=(... aws)
* `aws_change_access_key`: changes the AWS access key of a profile. * `aws_change_access_key`: changes the AWS access key of a profile.
* `aws_profiles`: lists the available profiles in the `$AWS_CONFIG_FILE` (default: `~/.aws/config`) and * `aws_profiles`: lists the available profiles in the `$AWS_CONFIG_FILE` (default: `~/.aws/config`).
`$AWS_SHARED_CREDENTIALS_FILE` (default: `~/.aws/credentials`).
Used to provide completion for the `asp` function. Used to provide completion for the `asp` function.
* `aws_regions`: lists the available regions. * `aws_regions`: lists the available regions.
+5 -43
View File
@@ -42,7 +42,7 @@ function asp() {
export AWS_PROFILE=$1 export AWS_PROFILE=$1
export AWS_EB_PROFILE=$1 export AWS_EB_PROFILE=$1
export AWS_PROFILE_REGION=$(_aws_profile_region "$1") export AWS_PROFILE_REGION=$(aws configure get region)
_aws_update_state _aws_update_state
@@ -239,47 +239,9 @@ function aws_regions() {
} }
function aws_profiles() { function aws_profiles() {
emulate -L zsh aws --no-cli-pager configure list-profiles 2> /dev/null && return
local config="${AWS_CONFIG_FILE:-$HOME/.aws/config}" [[ -r "${AWS_CONFIG_FILE:-$HOME/.aws/config}" ]] || return 1
local creds="${AWS_SHARED_CREDENTIALS_FILE:-$HOME/.aws/credentials}" command grep -Eo '^[[:space:]]*\[[[:space:]]*(profile[[:space:]]+)?[^][:space:]]+[[:space:]]*\]' "${AWS_CONFIG_FILE:-$HOME/.aws/config}" | command sed -E 's/^[[:space:]]*\[[[:space:]]*(profile[[:space:]]+)?([^][:space:]]+)[[:space:]]*\]$/\2/'
# Read the files directly; the AWS CLI is slow to start
if [[ ! -r "$config" && ! -r "$creds" ]]; then
aws --no-cli-pager configure list-profiles 2> /dev/null
return
fi
local line words
# 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
line=${line#*\[} # drop up to the first [
line=${line%\]*} # drop from the last ] (comments, CR)
words=(${=line})
if (( $#words == 1 )); then
print -r -- $words[1] # [default], or [foo] in the credentials file
elif (( $#words == 2 )) && [[ $words[1] == profile ]]; then
print -r -- $words[2]
fi
done | command sort -u
}
# Read a profile's region from the config file, falling back to the AWS CLI
function _aws_profile_region() {
emulate -L zsh
local config="${AWS_CONFIG_FILE:-$HOME/.aws/config}" line words in_profile
if [[ -r "$config" ]]; then
# Only read headers and region lines, so any credentials never enter the shell
for line in "${(@f)$(command grep -e '\[' -e region -- "$config" 2> /dev/null)}"; do
line=${line%$'\r'}
words=(${=line//[\[\]=]/ }) # "[profile foo]" -> (profile foo), "region = x" -> (region x)
if [[ ${${=line}[1]} == \[* ]]; then # header, possibly indented
in_profile=
[[ "$words" == "profile $1" || ( $1 == default && "$words" == default ) ]] && in_profile=1
elif [[ -n $in_profile && $words[1] == region ]]; then
print -r -- $words[2]
return
fi
done
fi
aws configure get region
} }
function _aws_regions() { function _aws_regions() {
@@ -323,7 +285,7 @@ if [[ "$AWS_PROFILE_STATE_ENABLED" == true ]]; then
export AWS_PROFILE="$AWS_DEFAULT_PROFILE" export AWS_PROFILE="$AWS_DEFAULT_PROFILE"
export AWS_EB_PROFILE="$AWS_DEFAULT_PROFILE" export AWS_EB_PROFILE="$AWS_DEFAULT_PROFILE"
test -z "${aws_state[2]}" && AWS_REGION=$(_aws_profile_region "$AWS_PROFILE") test -z "${aws_state[2]}" && AWS_REGION=$(aws configure get region)
export AWS_REGION=${AWS_REGION:-$aws_state[2]} export AWS_REGION=${AWS_REGION:-$aws_state[2]}
export AWS_DEFAULT_REGION="$AWS_REGION" export AWS_DEFAULT_REGION="$AWS_REGION"
+5 -5
View File
@@ -25,10 +25,10 @@ if [[ "$OSTYPE" = darwin* ]]; then
echo "$(ioreg -rc AppleSmartBattery | grep -o '"Watts"=[0-9]\+' | head -1 | grep -o '[0-9]\+')W " echo "$(ioreg -rc AppleSmartBattery | grep -o '"Watts"=[0-9]\+' | head -1 | grep -o '[0-9]\+')W "
} }
function battery_is_charging() { function battery_is_charging() {
ioreg -rc AppleSmartBattery | command grep -q '^.*"ExternalConnected" = Yes' ioreg -rc AppleSmartBattery | command grep -q '^.*"ExternalConnected"\ =\ Yes'
} }
function battery_pct() { function battery_pct() {
pmset -g batt | grep -Eo "[0-9]+%" | cut -d% -f1 pmset -g batt | grep -Eo "\d+%" | cut -d% -f1
} }
function battery_pct_remaining() { function battery_pct_remaining() {
if battery_is_charging; then if battery_is_charging; then
@@ -39,8 +39,8 @@ if [[ "$OSTYPE" = darwin* ]]; then
} }
function battery_time_remaining() { function battery_time_remaining() {
local smart_battery_status="$(ioreg -rc "AppleSmartBattery")" local smart_battery_status="$(ioreg -rc "AppleSmartBattery")"
if [[ $(echo $smart_battery_status | command grep -c '^.*"ExternalConnected" = No') -eq 1 ]]; then if [[ $(echo $smart_battery_status | command grep -c '^.*"ExternalConnected"\ =\ No') -eq 1 ]]; then
timeremaining=$(echo $smart_battery_status | command grep '^.*"AvgTimeToEmpty" = ' | sed -e 's/^.*"AvgTimeToEmpty" = //') timeremaining=$(echo $smart_battery_status | command grep '^.*"AvgTimeToEmpty"\ =\ ' | sed -e 's/^.*"AvgTimeToEmpty"\ =\ //')
if [ $timeremaining -gt 720 ]; then if [ $timeremaining -gt 720 ]; then
echo "::" echo "::"
else else
@@ -52,7 +52,7 @@ if [[ "$OSTYPE" = darwin* ]]; then
} }
function battery_pct_prompt () { function battery_pct_prompt () {
local battery_pct color local battery_pct color
if ioreg -rc AppleSmartBattery | command grep -q '^.*"ExternalConnected" = No'; then if ioreg -rc AppleSmartBattery | command grep -q '^.*"ExternalConnected"\ =\ No'; then
battery_pct=$(battery_pct_remaining) battery_pct=$(battery_pct_remaining)
if [[ $battery_pct -gt 50 ]]; then if [[ $battery_pct -gt 50 ]]; then
color='green' color='green'
-16
View File
@@ -1,16 +0,0 @@
# Bitwarden plugin
This plugin adds Zsh completions for whichever Bitwarden CLIs are installed:
- [Bitwarden CLI (`bw`)](https://bitwarden.com/help/cli/)
- [Bitwarden Secrets Manager CLI (`bws`)](https://bitwarden.com/help/secrets-manager-cli/)
To enable it, add `bitwarden` to the plugins array in your `.zshrc`:
```zsh
plugins=(... bitwarden)
```
Each installed CLI generates and refreshes its own completion cache in the
background when the plugin loads. The cache files are
`$ZSH_CACHE_DIR/completions/_bw` and `$ZSH_CACHE_DIR/completions/_bws`.
-45
View File
@@ -1,45 +0,0 @@
# Autocompletion for the Bitwarden CLI (bw) and Secrets Manager CLI (bws).
() {
local cli completion cache_file
local -a generator_args
for cli in bw bws; do
completion="_$cli"
cache_file="$ZSH_CACHE_DIR/completions/$completion"
if (( ! $+commands[$cli] )); then
# compinit can register a cached completion after the CLI is removed.
if [[ -f "$cache_file" && ${_comps[$cli]-} == "$completion" ]]; then
unset "_comps[$cli]"
fi
continue
fi
case "$cli" in
bw)
generator_args=(completion --shell zsh)
# bw emits function definitions. Use ksh-style autoload to run _bw
# on the first Tab press as well as loading its helper functions.
autoload -Uk "$completion"
;;
bws)
generator_args=(completions zsh)
autoload -Uz "$completion"
;;
esac
# Register the completion if compinit hasn't picked it up yet.
if [[ -z ${_comps[$cli]-} ]]; then
_comps[$cli]=$completion
fi
() {
zmodload -F zsh/files b:zf_mv || return
local temp_file
temp_file=$(mktemp "${cache_file:h}/.$completion.XXXXXXXX") || return
if command "$cli" "$@" >| "$temp_file" && [[ -s "$temp_file" ]] &&
zf_mv -f -- "$temp_file" "$cache_file"; then
return
fi
rm -f -- "$temp_file"
} "${generator_args[@]}" &|
done
}
+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` | `bu && bup` | Update Homebrew data, then upgrade outdated, unpinned brews. | | `bubu` | `bubo && bup` | Do the last two operations above. |
| `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='bu && bup' alias bubu='bubo && 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'
+15 -25
View File
@@ -1,6 +1,6 @@
# Bridgetown plugin # Bridgetown plugin
This plugin adds aliases for common [Bridgetown](https://www.bridgetownrb.com/) commands. This plugin adds some aliases and autocompletion for common [Bridgetown](https://bridgetownrb.com/) commands.
To use it, add `bridgetown` to the plugins array in your zshrc file: To use it, add `bridgetown` to the plugins array in your zshrc file:
@@ -10,27 +10,17 @@ plugins=(... bridgetown)
## Aliases ## Aliases
Most aliases use the project's `bin/bridgetown` executable so the command runs with the Bridgetown version | Alias | Command |
locked in its `Gemfile`. The `br` and `brn` aliases use the globally installed executable and can be run |-------|----------------------------|
outside a Bridgetown project. | br | `bridgetown` |
| bra | `bin/bridgetown apply` |
| Alias | Command | Description | | brb | `bin/bridgetown build` |
| --------- | ---------------------------- | ---------------------------------------- | | brc | `bin/bridgetown console` |
| `br` | `bridgetown` | Run the globally installed CLI | | brclean | `bin/bridgetown clean` |
| `bra` | `bin/bridgetown apply` | Apply an automation | | brd | `bin/bridgetown deploy` |
| `brb` | `bin/bridgetown build` | Build the site | | brdoc | `bin/bridgetown doctor` |
| `brc` | `bin/bridgetown console` | Open the Bridgetown console | | brh | `bin/bridgetown help` |
| `brclean` | `bin/bridgetown clean` | Remove generated files and caches | | brn | `bridgetown new` |
| `brco` | `bin/bridgetown configure` | Apply a bundled configuration | | brp | `bridgetown plugins` |
| `brd` | `bin/bridgetown deploy` | Run the project's deployment task | | brpl | `bridgetown plugins list` |
| `brdev` | `bin/bridgetown dev` | Start the development server | | brs | `bin/bridgetown start` |
| `bre` | `bin/bridgetown esbuild` | Manage the esbuild configuration |
| `brh` | `bin/bridgetown help` | Show command help |
| `brn` | `bridgetown new` | Create a new Bridgetown site |
| `brp` | `bin/bridgetown plugins` | Access plugin commands |
| `brpl` | `bin/bridgetown plugins list` | List installed plugins |
| `brs` | `bin/bridgetown start` | Start the development server |
| `brt` | `bin/bridgetown test` | Run the project's test build task |
`deploy` and `test` are standard tasks from the `Rakefile` generated for a new Bridgetown site. If the project
customizes or removes those tasks, the corresponding aliases follow that project behavior.
+3 -6
View File
@@ -3,13 +3,10 @@ alias bra='bin/bridgetown apply'
alias brb='bin/bridgetown build' alias brb='bin/bridgetown build'
alias brc='bin/bridgetown console' alias brc='bin/bridgetown console'
alias brclean='bin/bridgetown clean' alias brclean='bin/bridgetown clean'
alias brco='bin/bridgetown configure'
alias brd='bin/bridgetown deploy' alias brd='bin/bridgetown deploy'
alias brdev='bin/bridgetown dev' alias brdoc='bin/bridgetown doctor'
alias bre='bin/bridgetown esbuild'
alias brh='bin/bridgetown help' alias brh='bin/bridgetown help'
alias brn='bridgetown new' alias brn='bridgetown new'
alias brp='bin/bridgetown plugins' alias brp='bridgetown plugins'
alias brpl='bin/bridgetown plugins list' alias brpl='bridgetown plugins list'
alias brs='bin/bridgetown start' alias brs='bin/bridgetown start'
alias brt='bin/bridgetown test'
+2 -2
View File
@@ -13,6 +13,6 @@ fi
# Generate and load buf completion # Generate and load buf completion
zmodload -F zsh/files b:zf_mv zmodload -F zsh/files b:zf_mv
() { () {
local TMPPREFIX="$ZSH_CACHE_DIR/completions/._buf" local TMPPREFIX="$ZSH_CACHE_DIR/completions/_buf"
zf_mv -f -- =( buf completion zsh ) "$ZSH_CACHE_DIR/completions/_buf" zf_mv -f -- =( buf completion zsh ) "$TMPPREFIX"
} &| } &|
+2 -2
View File
@@ -13,6 +13,6 @@ fi
zmodload -F zsh/files b:zf_mv zmodload -F zsh/files b:zf_mv
() { () {
local TMPPREFIX="$ZSH_CACHE_DIR/completions/._bun" local TMPPREFIX="$ZSH_CACHE_DIR/completions/_bun"
zf_mv -f -- =( SHELL=zsh bun completions ) "$ZSH_CACHE_DIR/completions/_bun" zf_mv -f -- =( SHELL=zsh bun completions ) "$TMPPREFIX"
} &| } &|
+2 -2
View File
@@ -13,6 +13,6 @@ fi
zmodload -F zsh/files b:zf_mv zmodload -F zsh/files b:zf_mv
() { () {
local TMPPREFIX="$ZSH_CACHE_DIR/completions/._charm" local TMPPREFIX="$ZSH_CACHE_DIR/completions/_charm"
zf_mv -f -- =( charm completion zsh ) "$ZSH_CACHE_DIR/completions/_charm" zf_mv -f -- =( charm completion zsh ) "$TMPPREFIX"
} &| } &|
+2 -2
View File
@@ -13,6 +13,6 @@ fi
zmodload -F zsh/files b:zf_mv zmodload -F zsh/files b:zf_mv
() { () {
local TMPPREFIX="$ZSH_CACHE_DIR/completions/._chezmoi" local TMPPREFIX="$ZSH_CACHE_DIR/completions/_chezmoi"
zf_mv -f -- =( chezmoi completion zsh ) "$ZSH_CACHE_DIR/completions/_chezmoi" zf_mv -f -- =( chezmoi completion zsh ) "$TMPPREFIX"
} &| } &|
+2 -2
View File
@@ -13,6 +13,6 @@ fi
zmodload -F zsh/files b:zf_mv zmodload -F zsh/files b:zf_mv
() { () {
local TMPPREFIX="$ZSH_CACHE_DIR/completions/._codex" local TMPPREFIX="$ZSH_CACHE_DIR/completions/_codex"
zf_mv -f -- =( codex completion zsh < /dev/null 2> /dev/null ) "$ZSH_CACHE_DIR/completions/_codex" zf_mv -f -- =( codex completion zsh < /dev/null 2> /dev/null ) "$TMPPREFIX"
} &| } &|
-1
View File
@@ -90,7 +90,6 @@ 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
+3 -11
View File
@@ -1,6 +1,6 @@
# conda plugin # conda plugin
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). The conda plugin provides [aliases](#aliases) for `conda`, usually installed via [anaconda](https://www.anaconda.com/) or [miniconda](https://docs.conda.io/en/latest/miniconda.html).
To use it, add `conda` to the plugins array in your zshrc file: To use it, add `conda` to the plugins array in your zshrc file:
@@ -28,18 +28,10 @@ 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`
+2 -21
View File
@@ -1,7 +1,4 @@
unalias cna cnrn 2>/dev/null alias cna='conda activate'
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'
@@ -17,26 +14,10 @@ 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
+1 -1
View File
@@ -14,6 +14,6 @@ function copyfile {
return 1 return 1
fi fi
clipcopy $1 || return 1 clipcopy $1
echo ${(%):-"%B$1%b copied to clipboard."} echo ${(%):-"%B$1%b copied to clipboard."}
} }
-74
View File
@@ -1,74 +0,0 @@
#!/usr/bin/env zsh
emulate -LR zsh
source "${1:-${0:A:h:h}/copyfile.plugin.zsh}"
test_dir=$(mktemp -d) || exit 1
trap 'command rm -rf -- "$test_dir"' EXIT
typeset -i clipboard_status=0 failures=0 tests=0
typeset output expected_output
clipcopy() {
print -r -- "$#" "$1" >| "$test_dir/call"
if (( clipboard_status )); then
print -u2 -r -- "clipboard backend failed"
return $clipboard_status
fi
command cat -- "$1" >| "$test_dir/clipboard"
}
check_copyfile() {
local description="$1" expected_status="$2" expected_stdout="$3" expected_stderr="$4"
shift 4
output=$(copyfile "$@" 2> "$test_dir/stderr")
local actual_status=$?
(( tests++ ))
if [[ $actual_status == $expected_status && $output == "$expected_stdout" && $(<"$test_dir/stderr") == "$expected_stderr" ]]; then
print -r -- "PASS: $description"
else
print -u2 -r -- "FAIL: $description"
print -u2 -r -- " status: $actual_status (expected $expected_status)"
print -u2 -r -- " stdout: ${(qqq)output} (expected ${(qqq)expected_stdout})"
print -u2 -r -- " stderr: $(<"$test_dir/stderr") (expected $expected_stderr)"
(( failures++ ))
fi
}
for filename in plain.txt 'file with spaces.txt' 'unicode-ą.txt' empty.txt; do
if [[ $filename == empty.txt ]]; then
: >| "$test_dir/$filename"
else
print -r -- "contents of $filename" >| "$test_dir/$filename"
fi
expected_output=${(%):-"%B$test_dir/$filename%b copied to clipboard."}
clipboard_status=0
check_copyfile "successful copy of $filename" 0 "$expected_output" '' "$test_dir/$filename"
if [[ $(<"$test_dir/call") != "1 $test_dir/$filename" ]] || ! command cmp -s -- "$test_dir/$filename" "$test_dir/clipboard"; then
print -u2 -r -- "FAIL: clipboard received a different argument or contents for $filename"
(( failures++ ))
fi
for clipboard_status in 1 42 127; do
check_copyfile "clipboard exit $clipboard_status for $filename" 1 '' 'clipboard backend failed' "$test_dir/$filename"
done
done
command rm -f -- "$test_dir/call"
check_copyfile 'missing argument' 1 'Usage: copyfile <file>' ''
check_copyfile 'empty argument' 1 'Usage: copyfile <file>' '' ''
check_copyfile 'nonexistent file' 1 "Error: '$test_dir/missing.txt' is not a valid file." '' "$test_dir/missing.txt"
check_copyfile 'directory argument' 1 "Error: '$test_dir' is not a valid file." '' "$test_dir"
if [[ -e "$test_dir/call" ]]; then
print -u2 -r -- 'FAIL: invalid input invoked the clipboard backend'
(( failures++ ))
fi
print -r -- "$tests tests, $failures failures"
(( failures == 0 ))
+2 -2
View File
@@ -27,6 +27,6 @@ fi
zmodload -F zsh/files b:zf_mv zmodload -F zsh/files b:zf_mv
() { () {
local TMPPREFIX="$ZSH_CACHE_DIR/completions/._deno" local TMPPREFIX="$ZSH_CACHE_DIR/completions/_deno"
zf_mv -f -- =( deno completions zsh ) "$ZSH_CACHE_DIR/completions/_deno" zf_mv -f -- =( deno completions zsh ) "$TMPPREFIX"
} &| } &|
+1 -1
View File
@@ -52,7 +52,7 @@ function push_future() {
if [[ $#dirhistory_future -ge $DIRHISTORY_SIZE ]]; then if [[ $#dirhistory_future -ge $DIRHISTORY_SIZE ]]; then
shift dirhistory_future shift dirhistory_future
fi fi
if [[ $#dirhistory_future -eq 0 || $dirhistory_future[$#dirhistory_future] != "$1" ]]; then if [[ $#dirhistory_future -eq 0 || $dirhistory_futuret[$#dirhistory_future] != "$1" ]]; then
dirhistory_future+=($1) dirhistory_future+=($1)
fi fi
} }
+1 -5
View File
@@ -14,7 +14,7 @@ plugins=(... docker-compose)
## Aliases ## Aliases
| Alias | Command | Description | | Alias | Command | Description |
|-----------|-------------------------------------|----------------------------------------------------------------------------------------------| |-----------|----------------------------------|----------------------------------------------------------------------------------|
| dco | `docker-compose` | Docker-compose main command | | dco | `docker-compose` | Docker-compose main command |
| dcb | `docker-compose build` | Build containers | | dcb | `docker-compose build` | Build containers |
| dcc | `docker-compose config` | Parse, resolve and render compose file in canonical format | | dcc | `docker-compose config` | Parse, resolve and render compose file in canonical format |
@@ -28,8 +28,6 @@ plugins=(... docker-compose)
| dcupb | `docker-compose up --build` | Same as `dcup`, but build images before starting containers | | dcupb | `docker-compose up --build` | Same as `dcup`, but build images before starting containers |
| dcupd | `docker-compose up -d` | Same as `dcup`, but starts as daemon | | dcupd | `docker-compose up -d` | Same as `dcup`, but starts as daemon |
| dcupdb | `docker-compose up -d --build` | Same as `dcup`, but build images before starting containers and starts as daemon | | dcupdb | `docker-compose up -d --build` | Same as `dcup`, but build images before starting containers and starts as daemon |
| dcupw | `docker-compose up --watch` | Watch changes in service and rebuild/restart accordingly (see [Use Compose Watch] for usage) |
| dcupwb | `docker-compose up --watch --build` | Same as `dcupw`, but build images before starting containers |
| dcdn | `docker-compose down` | Stop and remove containers | | dcdn | `docker-compose down` | Stop and remove containers |
| dcl | `docker-compose logs` | Show logs of container | | dcl | `docker-compose logs` | Show logs of container |
| dclf | `docker-compose logs -f` | Show logs and follow output | | dclf | `docker-compose logs -f` | Show logs and follow output |
@@ -40,5 +38,3 @@ plugins=(... docker-compose)
| dcv | `docker-compose version` | Show version information | | dcv | `docker-compose version` | Show version information |
| dcsts | `docker-compose stats` | Show stats of containers | | dcsts | `docker-compose stats` | Show stats of containers |
| dci | `docker-compose images` | List images | | dci | `docker-compose images` | List images |
[Use Compose Watch]: https://docs.docker.com/compose/how-tos/file-watch/
@@ -17,8 +17,6 @@ alias dcup="$dccmd up"
alias dcupb="$dccmd up --build" alias dcupb="$dccmd up --build"
alias dcupd="$dccmd up -d" alias dcupd="$dccmd up -d"
alias dcupdb="$dccmd up -d --build" alias dcupdb="$dccmd up -d --build"
alias dcupw="$dccmd up --watch"
alias dcupwb="$dccmd up --watch --build"
alias dcdn="$dccmd down" alias dcdn="$dccmd down"
alias dcl="$dccmd logs" alias dcl="$dccmd logs"
alias dclf="$dccmd logs -f" alias dclf="$dccmd logs -f"
-1
View File
@@ -84,7 +84,6 @@ If you use Podman's Docker wrapper, you need to enable legacy completion. See ab
| dtop | `docker top` | Display the running processes of a container | | dtop | `docker top` | Display the running processes of a container |
| dvi | `docker volume inspect` | Display detailed information about one or more volumes | | dvi | `docker volume inspect` | Display detailed information about one or more volumes |
| dvls | `docker volume ls` | List all the volumes known to docker | | dvls | `docker volume ls` | List all the volumes known to docker |
| dvrm | `docker volume rm` | Remove one or more volumes |
| dvprune | `docker volume prune` | Cleanup dangling volumes | | dvprune | `docker volume prune` | Cleanup dangling volumes |
| dxc | `docker container exec` | Run a new command in a running container | | dxc | `docker container exec` | Run a new command in a running container |
| dxcit | `docker container exec -it` | Run a new command in a running container in an interactive shell | | dxcit | `docker container exec -it` | Run a new command in a running container in an interactive shell |
+2 -8
View File
@@ -35,7 +35,6 @@ alias dsts='docker stats'
alias dtop='docker top' alias dtop='docker top'
alias dvi='docker volume inspect' alias dvi='docker volume inspect'
alias dvls='docker volume ls' alias dvls='docker volume ls'
alias dvrm='docker volume rm'
alias dvprune='docker volume prune' alias dvprune='docker volume prune'
alias dxc='docker container exec' alias dxc='docker container exec'
alias dxcit='docker container exec -it' alias dxcit='docker container exec -it'
@@ -49,11 +48,6 @@ fi
0="${${ZERO:-${0:#$ZSH_ARGZERO}}:-${(%):-%N}}" 0="${${ZERO:-${0:#$ZSH_ARGZERO}}:-${(%):-%N}}"
0="${${(M)0:#/*}:-$PWD/$0}" 0="${${(M)0:#/*}:-$PWD/$0}"
# Make sure the cache directory exists; when the plugin is loaded by a
# standalone plugin manager (e.g. antigen) the core is not sourced, so
# $ZSH_CACHE_DIR/completions may not have been created yet (#13679).
[[ -d "$ZSH_CACHE_DIR/completions" ]] || mkdir -p "$ZSH_CACHE_DIR/completions"
# If the completion file doesn't exist yet, we need to autoload it and # If the completion file doesn't exist yet, we need to autoload it and
# bind it to `docker`. Otherwise, compinit will have already done that. # bind it to `docker`. Otherwise, compinit will have already done that.
if [[ ! -f "$ZSH_CACHE_DIR/completions/_docker" ]]; then if [[ ! -f "$ZSH_CACHE_DIR/completions/_docker" ]]; then
@@ -74,7 +68,7 @@ zmodload -F zsh/files b:zf_mv
! is-at-least 23.0.0 ${${(s:,:z)"$(command docker --version)"}[3]}; then ! is-at-least 23.0.0 ${${(s:,:z)"$(command docker --version)"}[3]}; then
command cp "${plugin_dir}/completions/_docker" "$ZSH_CACHE_DIR/completions/_docker" command cp "${plugin_dir}/completions/_docker" "$ZSH_CACHE_DIR/completions/_docker"
else else
local TMPPREFIX="$ZSH_CACHE_DIR/completions/._docker" local TMPPREFIX="$ZSH_CACHE_DIR/completions/_docker"
zf_mv -f -- =( command docker completion zsh ) "$ZSH_CACHE_DIR/completions/_docker" zf_mv -f -- =( command docker completion zsh ) "$TMPPREFIX"
fi fi
} "${0:A:h}" &| } "${0:A:h}" &|
+2 -2
View File
@@ -16,6 +16,6 @@ fi
zmodload -F zsh/files b:zf_mv zmodload -F zsh/files b:zf_mv
() { () {
local TMPPREFIX="$ZSH_CACHE_DIR/completions/._doctl" local TMPPREFIX="$ZSH_CACHE_DIR/completions/_doctl"
zf_mv -f -- =( doctl completion zsh ) "$ZSH_CACHE_DIR/completions/_doctl" zf_mv -f -- =( doctl completion zsh ) "$TMPPREFIX"
} &| } &|
+1 -1
View File
@@ -100,7 +100,7 @@ takes preference, _i.e._ the .env file will never be sourced.
## Named Pipe (FIFO) Support ## Named Pipe (FIFO) Support
The plugin supports `.env` files provided as UNIX named pipes (FIFOs) in addition to regular files. The plugin supports `.env` files provided as UNIX named pipes (FIFOs) in addition to regular files.
This is useful when secrets managers like [1Password Environments](https://developer.1password.com/docs/environments/) This is useful when secrets managers like [1Password Environments](https://developer.1password.com/docs/environment/)
mount `.env` files as named pipes to inject secrets on-the-fly without writing them to disk. mount `.env` files as named pipes to inject secrets on-the-fly without writing them to disk.
No additional configuration is required — the plugin automatically detects and sources named pipes. No additional configuration is required — the plugin automatically detects and sources named pipes.
+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" | command zsh -fn /dev/stdin printf '%s' "$2" | zsh -fn /dev/stdin
else else
command zsh -fn -- "$filename" 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
+1 -1
View File
@@ -25,7 +25,7 @@ plugins=(... drush)
| `drcr` | `drush core-cron` | Run all cron hooks in all active modules for specified site | | `drcr` | `drush core-cron` | Run all cron hooks in all active modules for specified site |
| `drct` | `drush cc theme-registry` | Clear theme-registry cache | | `drct` | `drush cc theme-registry` | Clear theme-registry cache |
| `drcv` | `drush cc views` | Clear views cache _(make sure that the views module is enabled)_ | | `drcv` | `drush cc views` | Clear views cache _(make sure that the views module is enabled)_ |
| `drdmp` | `drush sql-dump --ordered-dump --result-file=dump.sql` | Backup database in a new dump.sql file | | `drdmp` | `drush drush sql-dump --ordered-dump --result-file=dumpsql` | Backup database in a new dump.sql file |
| `drf` | `drush features` | Display features status | | `drf` | `drush features` | Display features status |
| `drfr` | `drush features-revert -y` | Revert a feature module on your site | | `drfr` | `drush features-revert -y` | Revert a feature module on your site |
| `drfra` | `drush features-revert-all` | Revert all enabled feature module on your site | | `drfra` | `drush features-revert-all` | Revert all enabled feature module on your site |
+1 -3
View File
@@ -35,9 +35,7 @@ alias eeval="$EMACS_PLUGIN_LAUNCHER --eval"
alias eframe='emacsclient --alternate-editor="" --create-frame' alias eframe='emacsclient --alternate-editor="" --create-frame'
# Emacs ANSI Term tracking # Emacs ANSI Term tracking
local excluded_terms=(vterm ghostel) if [[ -n "$INSIDE_EMACS" ]] && [[ "$INSIDE_EMACS" != "vterm" ]]; then
local current_term="${INSIDE_EMACS%%,*}"
if [[ -n "$INSIDE_EMACS" ]] && (( ! ${excluded_terms[(Ie)$current_term]} )); then
chpwd_emacs() { print -P "\033AnSiTc %d"; } chpwd_emacs() { print -P "\033AnSiTc %d"; }
print -P "\033AnSiTc %d" # Track current working directory print -P "\033AnSiTc %d" # Track current working directory
print -P "\033AnSiTu %n" # Track username print -P "\033AnSiTu %n" # Track username
+2 -3
View File
@@ -32,9 +32,8 @@ emacsfun() {
# Check if there are suitable frames # Check if there are suitable frames
frames="$(emacsclient -a '' -n -e "$cmd" 2>/dev/null |sed 's/.*\x07//g' )" frames="$(emacsclient -a '' -n -e "$cmd" 2>/dev/null |sed 's/.*\x07//g' )"
# A bare emacs/e passes only --no-wait, so it still needs --create-frame. # Only create another X frame if there isn't one present
if [ -z "$frames" ] || [ "$frames" = nil ] || [ "$#" -eq 0 ] \ if [ -z "$frames" -o "$frames" = nil ]; then
|| { [ "$#" -eq 1 ] && [ "$1" = --no-wait ]; }; then
emacsclient --alternate-editor="" --create-frame "$@" emacsclient --alternate-editor="" --create-frame "$@"
return $? return $?
fi fi
+1 -1
View File
@@ -40,7 +40,7 @@ case $state in
'new' \ 'new' \
'serve' \ 'serve' \
'test' \ 'test' \
'version' && ret=0 'vesion' && ret=0
;; ;;
addon) addon)
_arguments \ _arguments \
+3 -3
View File
@@ -46,10 +46,10 @@ Encode a file's contents to base64 and save output to text file.
- From parameter - From parameter
```console ```console
$ encodefile64 oh-my-zsh $ encodefile64 ohmyzsh.icn
oh-my-zsh's content encoded in base64 and saved as oh-my-zsh.txt ohmyzsh.icn's content encoded in base64 and saved as ohmyzsh.icn.txt
$ ef64 "oh-my-zsh" $ ef64 "oh-my-zsh"
oh-my-zsh's content encoded in base64 and saved as oh-my-zsh.txt ohmyzsh.icn's content encoded in base64 and saved as ohmyzsh.icn.txt
``` ```
### Decoding ### Decoding
+8 -21
View File
@@ -2,37 +2,24 @@ encode64() {
if [[ $# -eq 0 ]]; then if [[ $# -eq 0 ]]; then
cat | base64 cat | base64
else else
printf '%s' "$1" | base64 printf '%s' $1 | base64
fi fi
} }
encodefile64() { encodefile64() {
if [[ $# -ne 1 || ! -f "$1" || ! -r "$1" ]]; then if [[ $# -eq 0 ]]; then
print -u2 -- 'Usage: encodefile64 <file>' echo "You must provide a filename"
return 1 else
base64 $1 > $1.txt
echo "${1}'s content encoded in base64 and saved as ${1}.txt"
fi fi
local file="$1" output="${1}.txt" tmp_file
[[ $output == /* ]] || output="./$output"
tmp_file=$(mktemp "${output}.XXXXXX") || return 1
if ! base64 < "$file" > "$tmp_file"; then
command rm -f "$tmp_file"
return 1
fi
if ! command mv "$tmp_file" "$output"; then
command rm -f "$tmp_file"
return 1
fi
print -- "$file's content encoded in base64 and saved as ${file}.txt"
} }
decode64() { decode64() {
if [[ $# -eq 0 ]]; then if [[ $# -eq 0 ]]; then
cat | base64 -d cat | base64 --decode
else else
printf '%s' "$1" | base64 -d printf '%s' $1 | base64 --decode
fi fi
} }
alias e64=encode64 alias e64=encode64
-77
View File
@@ -1,77 +0,0 @@
#!/usr/bin/env zsh
emulate -LR zsh
source "${1:-${0:A:h:h}/encode64.plugin.zsh}"
test_dir=$(mktemp -d) || exit 1
trap 'command rm -rf -- "$test_dir"' EXIT
cd "$test_dir" || exit 1
typeset -i failures=0 tests=0
typeset output expected_output
check_result() {
local description="$1" expected_status="$2" expected_stdout="$3" expected_stderr="$4"
shift 4
output=$("$@" 2> "$test_dir/stderr")
local actual_status=$?
(( tests++ ))
if [[ $actual_status == $expected_status && $output == "$expected_stdout" && $(<"$test_dir/stderr") == "$expected_stderr" ]]; then
print -r -- "PASS: $description"
else
print -u2 -r -- "FAIL: $description"
print -u2 -r -- " status: $actual_status (expected $expected_status)"
print -u2 -r -- " stdout: ${(qqq)output} (expected ${(qqq)expected_stdout})"
print -u2 -r -- " stderr: $(<"$test_dir/stderr") (expected $expected_stderr)"
(( failures++ ))
fi
}
check_encode_arg() { encode64 'oh-my-zsh'; }
check_encode_empty() { encode64 ''; }
check_decode_arg() { decode64 'b2gtbXktenNo'; }
expected_output=$(printf '%s' 'oh-my-zsh' | base64)
check_result 'encode argument' 0 "$expected_output" '' check_encode_arg
check_result 'encode empty argument' 0 '' '' check_encode_empty
check_result 'decode argument' 0 'oh-my-zsh' '' check_decode_arg
file="$test_dir/file with spaces.txt"
print -r -- 'file contents' >| "$file"
encodefile64 "$file" > "$test_dir/stdout" 2> "$test_dir/stderr"
file_status=$?
expected_output=$(base64 < "$file")
(( tests++ ))
if [[ $file_status == 0 && $(<"${file}.txt") == "$expected_output" && $(<"$test_dir/stdout") == "$file's content encoded in base64 and saved as ${file}.txt" && ! -s "$test_dir/stderr" ]]; then
print -r -- 'PASS: encode file with spaces'
else
print -u2 -r -- 'FAIL: encode file with spaces'
(( failures++ ))
fi
check_invalid_file() { encodefile64 ''; }
check_result 'empty filename' 1 '' 'Usage: encodefile64 <file>' check_invalid_file
if [[ -e .txt ]]; then
print -u2 -r -- 'FAIL: empty filename created .txt'
(( failures++ ))
command rm -f .txt
fi
print -r -- 'preserve existing output' >| "${file}.txt"
base64() { return 42; }
encodefile64 "$file" > "$test_dir/stdout" 2> "$test_dir/stderr"
file_status=$?
unset -f base64
(( tests++ ))
if [[ $file_status != 0 && $(<"${file}.txt") == 'preserve existing output' && ! -s "$test_dir/stdout" ]]; then
print -r -- 'PASS: failed encoding preserves existing output'
else
print -u2 -r -- 'FAIL: failed encoding preserves existing output'
(( failures++ ))
fi
print -r -- "$tests tests, $failures failures"
(( failures == 0 ))
-3
View File
@@ -45,12 +45,9 @@ 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,7 +31,6 @@ 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
+8 -56
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.lzma|*.tar.zma|*.tlz) (*.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,23 +97,16 @@ 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" ;;
(*.gz) (( $+commands[pigz] )) && pigz -cdk "$full_path" > "${file:t:r}" || gunzip -ck "$full_path" > "${file:t:r}" ;; (*.gz) (( $+commands[pigz] )) && pigz -cdk "$full_path" > "${file:t:r}" || gunzip -ck "$full_path" > "${file:t:r}" ;;
(*.bz2) (*.bz2) (( $+commands[pbzip2] )) && pbzip2 -d "$full_path" || bunzip2 "$full_path" ;;
(( $+commands[pbzip2] )) && pbzip2 -cd "$full_path" > "${file:t:r}" \
|| bunzip2 -c "$full_path" > "${file:t:r}" ;;
(*.xz) xzcat "$full_path" > "${file:t:r}" ;; (*.xz) xzcat "$full_path" > "${file:t:r}" ;;
(*.lrz) (( $+commands[lrunzip] )) && lrunzip "$full_path" ;; (*.lrz) (( $+commands[lrunzip] )) && lrunzip "$full_path" ;;
(*.lz4) lz4 -d "$full_path" ;; (*.lz4) lz4 -d "$full_path" ;;
(*.lzma) unlzma -c "$full_path" > "${file:t:r}" ;; (*.lzma) unlzma "$full_path" ;;
(*.z) uncompress -c "$full_path" > "${file:t:r}" ;; (*.z) uncompress "$full_path" ;;
(*.zip|*.war|*.jar|*.ear|*.sublime-package|*.ipa|*.ipsw|*.xpi|*.apk|*.aar|*.whl|*.vsix|*.crx|*.pk3|*.pk4) unzip "$full_path" ;; (*.zip|*.war|*.jar|*.ear|*.sublime-package|*.ipa|*.ipsw|*.xpi|*.apk|*.aar|*.whl|*.vsix|*.crx|*.pk3|*.pk4) unzip "$full_path" ;;
(*.rar) (*.rar)
if (( $+commands[unrar] )); then if (( $+commands[unrar] )); then
@@ -126,54 +119,13 @@ EOF
fi ;; fi ;;
(*.rpm) (*.rpm)
rpm2cpio "$full_path" | cpio --quiet -id ;; rpm2cpio "$full_path" | cpio --quiet -id ;;
(*.7z | *.7z.[0-9]* | *.pk7) (*.7z | *.7z.[0-9]* | *.pk7) 7za x "$full_path" ;;
if (( $+commands[7zz] )); then
7zz x "$full_path"
elif (( $+commands[7z] )); then
7z x "$full_path"
elif (( $+commands[7za] )); then
7za x "$full_path"
else
echo "extract: cannot extract 7z files: install 7zz, 7z or 7za" >&2
success=1
fi ;;
(*.deb) (*.deb)
command mkdir -p "control" "data" command mkdir -p "control" "data"
ar vx "$full_path" > /dev/null ar vx "$full_path" > /dev/null
local member= dest= failed=0 builtin cd -q control; extract ../control.tar.*
for member in control.tar.* data.tar.*; do builtin cd -q ../data; extract ../data.tar.*
dest="${member%%.*}" builtin cd -q ..; command rm *.tar.* debian-binary ;;
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" ;;
-188
View File
@@ -1,188 +0,0 @@
#!/usr/bin/env zsh
# Run with: zsh -df plugins/extract/tests/extract.test.zsh
emulate -L zsh
setopt err_return
for tool in ar lzma unlzma uncompress; do
(( $+commands[$tool] )) || {
print -u2 -r -- "These tests require $tool."
exit 1
}
done
source "${0:A:h:h}/extract.plugin.zsh"
local test_dir=$(mktemp -d) original_dir=$PWD
check_extract() {
local extension=$1 mode=$2
local case_dir="$test_dir/$extension-$mode"
mkdir -p "$case_dir/source files" "$case_dir/work/target dir"
local archive="$case_dir/source files/sample.txt.$extension"
cp "$test_dir/fixture.$extension" "$archive"
builtin cd "$case_dir/work"
local output="$PWD/sample.txt"
local -a args
case "$mode" in
target)
args=(-t 'target dir')
output="$PWD/target dir/sample.txt"
;;
remove) args=(-r) ;;
esac
# Run the plugin without the test's ERR_RETURN option.
() {
emulate -L zsh
extract "${args[@]}" "$archive"
} || return 1
cmp "$test_dir/plain" "$output"
if [[ $mode == remove ]]; then
[[ ! -e $archive ]]
else
[[ -f $archive ]]
fi
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"
lzma -c "$test_dir/plain" > "$test_dir/fixture.lzma"
# "hello\n" as a .Z stream, since many systems only ship uncompress.
printf '\037\235\220\150\312\260\141\363\106\001' \
> "$test_dir/fixture.Z"
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
check_extract "$extension" "$mode"
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.'
} always {
builtin cd "$original_dir"
rm -rf -- "$test_dir"
}
-18
View File
@@ -1,18 +0,0 @@
# 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
@@ -1,24 +0,0 @@
# 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"
} &|
+2 -2
View File
@@ -32,6 +32,6 @@ fi
zmodload -F zsh/files b:zf_mv zmodload -F zsh/files b:zf_mv
() { () {
local TMPPREFIX="$ZSH_CACHE_DIR/completions/._flutter" local TMPPREFIX="$ZSH_CACHE_DIR/completions/_flutter"
zf_mv -f -- =( flutter zsh-completion < /dev/null ) "$ZSH_CACHE_DIR/completions/_flutter" zf_mv -f -- =( flutter zsh-completion < /dev/null ) "$TMPPREFIX"
} &| } &|
+2 -2
View File
@@ -13,6 +13,6 @@ fi
zmodload -F zsh/files b:zf_mv zmodload -F zsh/files b:zf_mv
() { () {
local TMPPREFIX="$ZSH_CACHE_DIR/completions/._flux" local TMPPREFIX="$ZSH_CACHE_DIR/completions/_flux"
zf_mv -f -- =( flux completion zsh ) "$ZSH_CACHE_DIR/completions/_flux" zf_mv -f -- =( flux completion zsh ) "$TMPPREFIX"
} &| } &|
+2 -2
View File
@@ -12,8 +12,8 @@ fi
zmodload -F zsh/files b:zf_mv zmodload -F zsh/files b:zf_mv
() { () {
local TMPPREFIX="$ZSH_CACHE_DIR/completions/._fnm" local TMPPREFIX="$ZSH_CACHE_DIR/completions/_fnm"
zf_mv -f -- =( fnm completions --shell=zsh ) "$ZSH_CACHE_DIR/completions/_fnm" zf_mv -f -- =( fnm completions --shell=zsh ) "$TMPPREFIX"
} &| } &|
if zstyle -t ':omz:plugins:fnm' autostart; then if zstyle -t ':omz:plugins:fnm' autostart; then
-15
View File
@@ -1,15 +0,0 @@
# 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
@@ -1,23 +0,0 @@
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
-1
View File
@@ -7,7 +7,6 @@ if [[ -z "${CLOUDSDK_HOME}" ]]; then
search_locations=( search_locations=(
"$HOME/google-cloud-sdk" "$HOME/google-cloud-sdk"
"/usr/local/share/google-cloud-sdk" "/usr/local/share/google-cloud-sdk"
"/usr/local/google-cloud-sdk"
"/usr/local/Caskroom/google-cloud-sdk/latest/google-cloud-sdk" "/usr/local/Caskroom/google-cloud-sdk/latest/google-cloud-sdk"
"/opt/homebrew/Caskroom/google-cloud-sdk/latest/google-cloud-sdk" "/opt/homebrew/Caskroom/google-cloud-sdk/latest/google-cloud-sdk"
"/opt/homebrew/share/google-cloud-sdk" "/opt/homebrew/share/google-cloud-sdk"
+2 -2
View File
@@ -13,6 +13,6 @@ fi
zmodload -F zsh/files b:zf_mv zmodload -F zsh/files b:zf_mv
() { () {
local TMPPREFIX="$ZSH_CACHE_DIR/completions/._gcx" local TMPPREFIX="$ZSH_CACHE_DIR/completions/_gcx"
zf_mv -f -- =( gcx completion zsh ) "$ZSH_CACHE_DIR/completions/_gcx" zf_mv -f -- =( gcx completion zsh ) "$TMPPREFIX"
} &| } &|
+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.
+8 -2
View File
@@ -13,6 +13,12 @@ fi
zmodload -F zsh/files b:zf_mv zmodload -F zsh/files b:zf_mv
() { () {
local TMPPREFIX="$ZSH_CACHE_DIR/completions/._gh" local completion_file="$ZSH_CACHE_DIR/completions/_gh"
zf_mv -f -- =( gh completion --shell zsh ) "$ZSH_CACHE_DIR/completions/_gh" local completion_tmp="${completion_file}.$$.${RANDOM}"
if gh completion --shell zsh >| "$completion_tmp" && [[ -s "$completion_tmp" ]]; then
zf_mv -f -- "$completion_tmp" "$completion_file"
fi
command rm -f -- "$completion_tmp"
} &| } &|
+9 -10
View File
@@ -1,6 +1,7 @@
# git-commit plugin # git-commit plugin
The git-commit plugin adds several git subcommands for The git-commit plugin adds several
[git aliases](https://www.git-scm.com/docs/git-config#Documentation/git-config.txt-alias) for
[conventional commit](https://www.conventionalcommits.org/en/v1.0.0/#summary) messages. [conventional commit](https://www.conventionalcommits.org/en/v1.0.0/#summary) messages.
To use it, add `git-commit` to the plugins array in your zshrc file: To use it, add `git-commit` to the plugins array in your zshrc file:
@@ -12,7 +13,7 @@ plugins=(... git-commit)
## Syntax ## Syntax
```zsh ```zsh
git <type> [(-s, --scope) "<scope>"] [(-a, --attention)] [(-b, --body) "<body>"] "<message>" git <type> [(-s, --scope) "<scope>"] [(-a, --attention)] "<message>"
``` ```
Where `type` is one of the following: Where `type` is one of the following:
@@ -30,19 +31,17 @@ 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 > NOTE: the alias for `revert` type is `rev`, as otherwise it conflicts with the git command of the same name.
[Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/#summary). > It will still generate a commit message in the format `revert: <message>`
> NOTE: the subcommand for `revert` type is `rev`, as otherwise it conflicts with the > ⚠️ Enabling this plugin will (potentially) overwrite all `alias.<type>` that you manually set. Use with
> git command of the same name. It will still generate a commit message in the format > care!
> `revert: <message>`
## Examples ## Examples
| Git subcommand | Command | | Git alias | 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 "wip: work in progress"` | | `git wip "work in progress"` | `git commit -m "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."` |
@@ -1 +0,0 @@
./omz_git_commit
@@ -1 +0,0 @@
./omz_git_commit
-1
View File
@@ -1 +0,0 @@
./omz_git_commit
-1
View File
@@ -1 +0,0 @@
./omz_git_commit
-1
View File
@@ -1 +0,0 @@
./omz_git_commit
-1
View File
@@ -1 +0,0 @@
./omz_git_commit
-1
View File
@@ -1 +0,0 @@
./omz_git_commit
@@ -1 +0,0 @@
./omz_git_commit
-1
View File
@@ -1 +0,0 @@
./omz_git_commit
@@ -1 +0,0 @@
./omz_git_commit
-1
View File
@@ -1 +0,0 @@
./omz_git_commit
-1
View File
@@ -1 +0,0 @@
./omz_git_commit
@@ -1,46 +0,0 @@
#!/usr/bin/env zsh
_omz_git_commit() {
0=${(%):-%x}
if [[ "$0" != */git-* ]]; then
echo >&2 "Expecting command named git-foo. Got '$0'."
return 1
fi
local _type="${0##*/git-}"
# The subcommand is shortened to avoid Git's built-in revert command.
if [[ "$_type" == rev ]]; then
_type=revert
fi
local _scope _attention _message _body
while [ $# -ne 0 ]; do
case $1 in
-s | --scope )
if [ -z "$2" ]; then
echo >&2 "Missing scope!"
return 1
fi
_scope="$2"
shift 2
;;
-a | --attention )
_attention="!"
shift 1
;;
-b | --body )
if [ -z "$2" ]; then
echo >&2 "Missing body!"
return 1
fi
_body="$2"
shift 2
;;
* )
_message="${_message} $1"
shift 1
;;
esac
done
git commit -m "${_type}${_scope:+(${_scope})}${_attention}:${_message}" ${_body:+-m} ${_body:+"$_body"}
}
_omz_git_commit "$@"
+55 -42
View File
@@ -1,45 +1,58 @@
# Add git-commit commands directory to path local _rev="$(git -C $ZSH rev-parse HEAD 2> /dev/null)"
0="${${ZERO:-${0:#$ZSH_ARGZERO}}:-${(%):-%N}}" if [[ $_rev == $(git config --global --get oh-my-zsh.git-commit-alias 2> /dev/null) ]]; then
0="${${(M)0:#/*}:-$PWD/$0}" return
path=("${0:a:h}/git-commands" $path) fi
git config --global oh-my-zsh.git-commit-alias "$_rev"
# Append completions for custom git commands local -a _git_commit_aliases
() { _git_commit_aliases=(
local -a git_user_commands 'build'
zstyle -a ':completion:*:*:git:*' user-commands 'git_user_commands' \ 'chore'
|| git_user_commands=() 'ci'
git_user_commands+=( 'docs'
build:'Commit with a message indicating a build' \ 'feat'
chore:'Commit with a message indicating a chore' \ 'fix'
ci:'Commit with a message indicating a CI change' \ 'perf'
docs:'Commit with a message indicating an update to the documentation' \ 'refactor'
feat:'Commit with a message indicating a feature' \ 'revert'
fix:'Commit with a message indicating a fix' \ 'style'
perf:'Commit with a message indicating a performance enhancement' \ 'test'
refactor:'Commit with a message indicating a refactor' \ 'wip'
rev:'Commit with a message indicating a revert' \ )
style:'Commit with a message indicating a style change' \
test:'Commit with a message indicating updates to tests' \
wip:'Commit with a message indicating a work in progress'
)
zstyle ':completion:*:*:git:*' user-commands "${git_user_commands[@]}"
}
# Clean up aliases from the prior implementation of git-commit. Keep this migration local _alias _type
# for users upgrading from versions that still wrote aliases to .gitconfig. for _type in "${_git_commit_aliases[@]}"; do
() { # an alias can't be named "revert" because the git command takes precedence
git config --global --get oh-my-zsh.git-commit-alias &> /dev/null || return 0 # https://stackoverflow.com/a/3538791
local -a old_git_aliases=( case "$_type" in
'build' 'chore' 'ci' revert) _alias=rev ;;
'docs' 'feat' 'fix' *) _alias=$_type ;;
'perf' 'refactor' 'rev' esac
'style' 'test' 'wip'
) local _func='!a() {
local git_alias local _scope _attention _message
for git_alias in $old_git_aliases; do while [ $# -ne 0 ]; do
if [[ "$(git config --global --get alias.$git_alias | tr '\n' ' ')" == "!a() { local _scope _attention _message"* ]]; then case $1 in
git config --global --unset alias.$git_alias -s | --scope )
if [ -z $2 ]; then
echo "Missing scope!"
return 1
fi fi
done _scope="$2"
git config --global --unset oh-my-zsh.git-commit-alias shift 2
} ;;
-a | --attention )
_attention="!"
shift 1
;;
* )
_message="${_message} $1"
shift 1
;;
esac
done
git commit -m "'$_type'${_scope:+(${_scope})}${_attention}:${_message}"
}; a'
git config --global alias.$_alias "$_func"
done
+1 -8
View File
@@ -21,7 +21,7 @@ plugins=(... git)
| `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 commit --no-verify --no-gpg-sign --message "--wip-- [skip ci]"` | | `gwip` | `git add -A; git rm $(git ls-files --deleted) 2> /dev/null; 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` |
@@ -108,7 +108,6 @@ plugins=(... git)
| `glo` | `git log --oneline --decorate` | | `glo` | `git log --oneline --decorate` |
| `glog` | `git log --oneline --decorate --graph` | | `glog` | `git log --oneline --decorate --graph` |
| `gloga` | `git log --oneline --decorate --graph --all` | | `gloga` | `git log --oneline --decorate --graph --all` |
| `glom` | `git log --oneline --decorate --color $(git_main_branch)..` |
| `glp` | `git log --pretty=<format>` | | `glp` | `git log --pretty=<format>` |
| `glg` | `git log --stat` | | `glg` | `git log --stat` |
| `glgp` | `git log --stat --patch` | | `glgp` | `git log --stat --patch` |
@@ -156,8 +155,6 @@ plugins=(... git)
| `grba` | `git rebase --abort` | | `grba` | `git rebase --abort` |
| `grbc` | `git rebase --continue` | | `grbc` | `git rebase --continue` |
| `grbi` | `git rebase --interactive` | | `grbi` | `git rebase --interactive` |
| `grbmi` | `git rebase $(git_main_branch) --interactive` |
| `grbmia` | `git rebase $(git_main_branch) --interactive --autosquash` |
| `grbo` | `git rebase --onto` | | `grbo` | `git rebase --onto` |
| `grbs` | `git rebase --skip` | | `grbs` | `git rebase --skip` |
| `grbd` | `git rebase $(git_develop_branch)` | | `grbd` | `git rebase $(git_develop_branch)` |
@@ -191,7 +188,6 @@ plugins=(... git)
| `grmc` | `git rm --cached` | | `grmc` | `git rm --cached` |
| `gcount` | `git shortlog --summary -n` | | `gcount` | `git shortlog --summary -n` |
| `gsh` | `git show` | | `gsh` | `git show` |
| `gshs` | `git show --stat` |
| `gsps` | `git show --pretty=short --show-signature` | | `gsps` | `git show --pretty=short --show-signature` |
| `gstall` | `git stash --all` | | `gstall` | `git stash --all` |
| `gstu` | `git stash --include-untracked` | | `gstu` | `git stash --include-untracked` |
@@ -206,11 +202,8 @@ plugins=(... git)
| `gst` | `git status` | | `gst` | `git status` |
| `gss` | `git status --short` | | `gss` | `git status --short` |
| `gsb` | `git status --short -b` | | `gsb` | `git status --short -b` |
| `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` |
| `gsd` | `git svn dcommit` | | `gsd` | `git svn dcommit` |
| `git-svn-dcommit-push` | `git svn dcommit && git push github $(git_main_branch):svntrunk` | | `git-svn-dcommit-push` | `git svn dcommit && git push github $(git_main_branch):svntrunk` |
| `gsr` | `git svn rebase` | | `gsr` | `git svn rebase` |
+1 -8
View File
@@ -119,7 +119,7 @@ alias gaa='git add --all'
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 commit --no-verify --no-gpg-sign --message "--wip-- [skip ci]"' 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 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'
@@ -253,7 +253,6 @@ alias glolm='git log $(git_main_branch) --graph --pretty="%Cred%h%Creset -%C(aut
alias glo='git log --oneline --decorate' alias glo='git log --oneline --decorate'
alias glog='git log --oneline --decorate --graph' alias glog='git log --oneline --decorate --graph'
alias gloga='git log --oneline --decorate --graph --all' alias gloga='git log --oneline --decorate --graph --all'
alias glom='git log --oneline --decorate --color $(git_main_branch)..'
# Pretty log messages # Pretty log messages
function _git_log_prettily(){ function _git_log_prettily(){
@@ -363,8 +362,6 @@ alias grbd='git rebase $(git_develop_branch)'
alias grbm='git rebase $(git_main_branch)' alias grbm='git rebase $(git_main_branch)'
alias grbom='git rebase origin/$(git_main_branch)' alias grbom='git rebase origin/$(git_main_branch)'
alias grbum='git rebase upstream/$(git_main_branch)' alias grbum='git rebase upstream/$(git_main_branch)'
alias grbmi='git rebase $(git_main_branch) --interactive'
alias grbmia='git rebase $(git_main_branch) --interactive --autosquash'
alias grf='git reflog' alias grf='git reflog'
alias gr='git remote' alias gr='git remote'
alias grv='git remote --verbose' alias grv='git remote --verbose'
@@ -392,7 +389,6 @@ alias grm='git rm'
alias grmc='git rm --cached' alias grmc='git rm --cached'
alias gcount='git shortlog --summary --numbered' alias gcount='git shortlog --summary --numbered'
alias gsh='git show' alias gsh='git show'
alias gshs='git show --stat'
alias gsps='git show --pretty=short --show-signature' alias gsps='git show --pretty=short --show-signature'
alias gstall='git stash --all' alias gstall='git stash --all'
alias gstaa='git stash apply' alias gstaa='git stash apply'
@@ -408,11 +404,8 @@ alias gsts='git stash show --patch'
alias gst='git status' alias gst='git status'
alias gss='git status --short' 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 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 gsd='git svn dcommit' alias gsd='git svn dcommit'
alias git-svn-dcommit-push='git svn dcommit && git push github $(git_main_branch):svntrunk' alias git-svn-dcommit-push='git svn dcommit && git push github $(git_main_branch):svntrunk'
alias gsr='git svn rebase' alias gsr='git svn rebase'
+36 -34
View File
@@ -1,43 +1,45 @@
# github plugin # github plugin
> [!WARNING] This plugin supports working with GitHub from the command line. It provides a few things:
> This plugin is deprecated and will be removed in a future release. It supports
> the legacy [`hub`](https://github.com/mislav/hub) CLI, not the current GitHub
> CLI. For `gh` completion, use the [`gh` plugin](../gh) instead.
The plugin provides compatibility for existing `hub` users by: * Sets up the `hub` wrapper and completions for the `git` command if you have [`hub`](https://github.com/github/hub) installed.
* Completion for the [`github` Ruby gem](https://github.com/defunkt/github-gem).
* Convenience functions for working with repos and URLs.
- aliasing `git` to `hub` when `hub` is installed; ### Functions
- adding completion for `hub`; and
- defining convenience functions for creating repositories.
## Migrating to GitHub CLI * `empty_gh` - Creates a new empty repo (with a `README.md`) and pushes it to GitHub
* `new_gh` - Initializes an existing directory as a repo and pushes it to GitHub
* `exist_gh` - Takes an existing repo and pushes it to GitHub
Install [GitHub CLI](https://cli.github.com/), replace `github` with `gh` in
your plugin list, and restart your shell: ## Installation
[Hub](https://github.com/github/hub) needs to be installed if you want to use it. On OS X with Homebrew, this can be done with `brew install hub`. The `hub` completion definition needs to be added to your `$FPATH` before initializing OMZ.
The [`github` Ruby gem](https://github.com/defunkt/github-gem) needs to be installed if you want to use it.
### Configuration
These settings affect `github`'s behavior.
#### Environment variables
* `$GITHUB_USER`
* `$GITHUB_PASSWORD`
#### Git configuration options
* `github.user` - GitHub username for repo operations
See `man hub` for more details.
### Homebrew installation note
If you have installed `hub` using Homebrew, its completions may not be on your `$FPATH` if you are using the system `zsh`. Homebrew installs `zsh` completion definitions to `/usr/local/share/zsh/site-functions`, which will be on `$FPATH` for the Homebrew-installed `zsh`, but not for the system `zsh`. If you want it to work with the system `zsh`, add this to your `~/.zshrc` before it sources `oh-my-zsh.sh`.
```zsh ```zsh
plugins=(... gh) if (( ! ${fpath[(I)/usr/local/share/zsh/site-functions]} )); then
FPATH=/usr/local/share/zsh/site-functions:$FPATH
fi
``` ```
The `gh` plugin supplies completion for the installed GitHub CLI. It does not
alias `git`, because `gh` is not a Git wrapper.
The closest replacement for creating a GitHub repository from an existing
local repository is:
```zsh
gh repo create --source=. --push
```
## Deprecated functions
- `empty_gh` - creates a new repository with a `README.md` and pushes it to GitHub
- `new_gh` - initializes an existing directory and pushes it to GitHub
- `exist_gh` - pushes an existing Git repository to GitHub
These functions remain available during the deprecation period and require
`hub`. They will be removed with the plugin.
If you continue using `hub`, see its documentation for authentication and
configuration details.
+6 -9
View File
@@ -1,6 +1,3 @@
print -Pru2 -- '%F{yellow}[oh-my-zsh] The %Bgithub%b plugin is deprecated and will be removed in a future release.'
print -Pru2 -- 'It supports the legacy %Bhub%b CLI. Use the %Bgh%b plugin for GitHub CLI completion.%f'
# Set up hub wrapper for git, if it is available; https://github.com/github/hub # Set up hub wrapper for git, if it is available; https://github.com/github/hub
if (( $+commands[hub] )); then if (( $+commands[hub] )); then
alias git=hub alias git=hub
@@ -29,7 +26,7 @@ empty_gh() { # [NAME_OF_REPO]
# This function will add all non-hidden files to git. # This function will add all non-hidden files to git.
new_gh() { # [DIRECTORY] new_gh() { # [DIRECTORY]
emulate -L zsh emulate -L zsh
local repo="${1-.}" local repo="$1"
cd "$repo" \ cd "$repo" \
|| return || return
@@ -45,7 +42,7 @@ new_gh() { # [DIRECTORY]
|| return || return
hub create \ hub create \
|| return || return
git push -u origin HEAD \ git push -u origin master \
|| return || return
} }
@@ -55,13 +52,12 @@ new_gh() { # [DIRECTORY]
# to your GitHub. # to your GitHub.
exist_gh() { # [DIRECTORY] exist_gh() { # [DIRECTORY]
emulate -L zsh emulate -L zsh
local repo="${1:-.}" local repo=$1
cd "$repo" \ cd "$repo"
|| return
hub create \ hub create \
|| return || return
git push -u origin HEAD git push -u origin master
} }
# git.io "GitHub URL" # git.io "GitHub URL"
@@ -78,3 +74,4 @@ git.io() {
} }
# End Functions ############################################################# # End Functions #############################################################
+2 -2
View File
@@ -13,6 +13,6 @@ fi
zmodload -F zsh/files b:zf_mv zmodload -F zsh/files b:zf_mv
() { () {
local TMPPREFIX="$ZSH_CACHE_DIR/completions/._glab" local TMPPREFIX="$ZSH_CACHE_DIR/completions/_glab"
zf_mv -f -- =( glab completion -s zsh ) "$ZSH_CACHE_DIR/completions/_glab" zf_mv -f -- =( glab completion -s zsh ) "$TMPPREFIX"
} &| } &|
-4
View File
@@ -4,11 +4,7 @@ globalias() {
# (A) makes it an array even if there's only one element # (A) makes it an array even if there's only one element
local word=${${(Az)LBUFFER}[-1]} local word=${${(Az)LBUFFER}[-1]}
if [[ $GLOBALIAS_FILTER_VALUES[(Ie)$word] -eq 0 ]]; then if [[ $GLOBALIAS_FILTER_VALUES[(Ie)$word] -eq 0 ]]; then
# Completion also considers quoted strings and assignment values as aliases.
# Only expand when the complete shell word is an alias name.
if (( ${+aliases[$word]} || ${+galiases[$word]} )); then
zle _expand_alias zle _expand_alias
fi
zle expand-word zle expand-word
fi fi
zle self-insert zle self-insert
@@ -1,81 +0,0 @@
#!/usr/bin/env zsh
# Exercise the actual ZLE widgets in an isolated interactive shell.
emulate -L zsh
setopt err_return
zmodload zsh/zpty
zmodload zsh/zselect
local test_dir=$(mktemp -d)
export GLOBALIAS_TEST_PLUGIN=${0:A:h:h}/globalias.plugin.zsh
export GLOBALIAS_TEST_RESULT=$test_dir/result
wait_for_marker() {
local marker=$1 output received
local -i deadline=$(( SECONDS + 5 ))
while (( SECONDS < deadline )); do
if zpty -r globalias-test output; then
received+=$output
[[ $received == *$marker* ]] && return 0
else
zselect -t 1 || true
fi
done
print -u2 -r -- "Timed out waiting for ZLE: $received"
return 1
}
check_expansion() {
local input=$1 expected=$2 actual
zpty -w -n globalias-test "$input"$' \x18'
wait_for_marker GLOBALIAS_TEST_CAPTURED
actual=$(< "$GLOBALIAS_TEST_RESULT")
if [[ $actual != "$expected" ]]; then
print -u2 -r -- "Input: ${(qqq)input}"
print -u2 -r -- "Expected: ${(qqq)expected}; got: ${(qqq)actual}"
return 1
fi
}
{
cat > "$test_dir/setup.zsh" <<'SETUP'
autoload -Uz compinit
compinit -D
source "$GLOBALIAS_TEST_PLUGIN"
alias 1='cd -1'
alias ll='ls -l'
alias -g G='| grep'
GLOBALIAS_FILTER_VALUES=(ll)
_globalias_test_capture() {
print -rn -- "$BUFFER" > "$GLOBALIAS_TEST_RESULT"
print -r -- $'\nGLOBALIAS_TEST_CAPTURED'
BUFFER=
zle .accept-line
}
zle -N _globalias_test_capture
bindkey '^X' _globalias_test_capture
PS1='GLOBALIAS_TEST_READY> '
RPROMPT=
SETUP
zpty -b globalias-test zsh -dfi
zpty -w globalias-test "source ${(q)test_dir}/setup.zsh"
wait_for_marker GLOBALIAS_TEST_READY
check_expansion 'DEBUG=1' 'DEBUG=1 '
check_expansion 'DEBUG="1"' 'DEBUG="1" '
check_expansion "DEBUG='1'" "DEBUG='1' "
check_expansion '1' 'cd -1 '
check_expansion '"1"' '"1" '
check_expansion "'1'" "'1' "
check_expansion '\1' '\1 '
check_expansion 'echo G' 'echo | grep '
check_expansion 'DEBUG=1 1' 'DEBUG=1 cd -1 '
check_expansion 'll' 'll '
check_expansion 'echo $((1+2))' 'echo 3 '
check_expansion 'echo {a,b}' 'echo a b '
check_expansion '' ' '
print 'All globalias expansion tests passed.'
} always {
zpty -d globalias-test 2>/dev/null || true
rm -rf -- "$test_dir"
}
-2
View File
@@ -22,7 +22,6 @@ 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 |
@@ -55,4 +54,3 @@ changes your prompt to:
``` ```
~/go/project$ ▋ 1.22.3 ~/go/project$ ▋ 1.22.3
``` ```
-1
View File
@@ -19,7 +19,6 @@ 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'
+1 -31
View File
@@ -5,40 +5,10 @@ Applies some fixes for some common issues encountered with [GPG's gpg-agent](htt
More specifically, this plugin: More specifically, this plugin:
- Updates the `GPG_TTY` environment variable before each shell execution. - Updates the `GPG_TTY` environment variable before each shell execution.
- Updates the `SSH_AUTH_SOCK` environment variable if `gpg-agent` is your SSH - Updates the `SSH_AUTH_SOCK` environment variable if `enable-ssh-support` is turned on.
agent. By default the plugin checks whether `enable-ssh-support` is turned
on. The [`ssh-support` setting](#settings) lets you say so yourself.
To use it, add `gpg-agent` to the plugins array of your zshrc file: To use it, add `gpg-agent` to the plugins array of your zshrc file:
```zsh ```zsh
plugins=(... gpg-agent) plugins=(... gpg-agent)
``` ```
## Settings
Every time a shell starts, the plugin runs `gpgconf --list-options gpg-agent` to
find out whether `enable-ssh-support` is turned on. That check can be slow. If
you already know the answer, state it with the `ssh-support` style and the
plugin skips the check. Set it in your zshrc, before Oh My Zsh is sourced.
If you don't use `gpg-agent` as your SSH agent:
```zsh
zstyle ':omz:plugins:gpg-agent' ssh-support no
```
The plugin then only sets `GPG_TTY`. It leaves `SSH_AUTH_SOCK` alone, and it
doesn't update the agent's tty before each command, which only SSH support
needs.
If you do use `gpg-agent` as your SSH agent:
```zsh
zstyle ':omz:plugins:gpg-agent' ssh-support yes
```
The plugin then sets `SSH_AUTH_SOCK` without checking. `enable-ssh-support`
still has to be set in your `gpg-agent.conf` for SSH to work.
Leave the style unset to keep the automatic check.
Loaded 100 of 221 files, more files were not shown because too many files have changed in this diff. Show more