mirror of
https://github.com/robbyrussell/oh-my-zsh.git
synced 2026-12-03 21:58:56 +01:00
Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
dd852f0cfc |
No files matched your search
@@ -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>
|
|
||||||
@@ -6,8 +6,6 @@ updates:
|
|||||||
interval: "weekly"
|
interval: "weekly"
|
||||||
day: "sunday"
|
day: "sunday"
|
||||||
labels: []
|
labels: []
|
||||||
cooldown:
|
|
||||||
default-days: 7
|
|
||||||
groups:
|
groups:
|
||||||
gha-minor:
|
gha-minor:
|
||||||
patterns:
|
patterns:
|
||||||
@@ -21,8 +19,6 @@ updates:
|
|||||||
interval: "weekly"
|
interval: "weekly"
|
||||||
day: "sunday"
|
day: "sunday"
|
||||||
labels: []
|
labels: []
|
||||||
cooldown:
|
|
||||||
default-days: 7
|
|
||||||
groups:
|
groups:
|
||||||
py-minor:
|
py-minor:
|
||||||
patterns:
|
patterns:
|
||||||
@@ -30,19 +26,3 @@ updates:
|
|||||||
update-types:
|
update-types:
|
||||||
- minor
|
- minor
|
||||||
- patch
|
- patch
|
||||||
- package-ecosystem: npm
|
|
||||||
directory: "/.github/workflows/installer"
|
|
||||||
schedule:
|
|
||||||
interval: "weekly"
|
|
||||||
day: "sunday"
|
|
||||||
labels: []
|
|
||||||
cooldown:
|
|
||||||
default-days: 7
|
|
||||||
groups:
|
|
||||||
npm-minor:
|
|
||||||
patterns:
|
|
||||||
- "*"
|
|
||||||
update-types:
|
|
||||||
- major
|
|
||||||
- minor
|
|
||||||
- patch
|
|
||||||
@@ -1,66 +0,0 @@
|
|||||||
# Workflow checks
|
|
||||||
|
|
||||||
The `Workflow lint` workflow runs jactionlint on pull requests and pushes to
|
|
||||||
`master`. It checks workflows and Dependabot configuration with the default
|
|
||||||
profile, including ShellCheck for inline shell scripts. It runs without online
|
|
||||||
checks or publishing credentials.
|
|
||||||
|
|
||||||
To run the same checks locally, install jactionlint 2.6.0 and ShellCheck, then run
|
|
||||||
from the repository root:
|
|
||||||
|
|
||||||
```sh
|
|
||||||
jactionlint --profile=default --no-online
|
|
||||||
```
|
|
||||||
|
|
||||||
Keep the local jactionlint version aligned with the pinned action in `lint.yml`.
|
|
||||||
There is no baseline: new findings fail the check. Any rule exception should be
|
|
||||||
limited to the relevant line and explain why it is needed.
|
|
||||||
|
|
||||||
## Action lockfile
|
|
||||||
|
|
||||||
`actions.lock` records the commit for every action the workflows use, including
|
|
||||||
actions called by other actions. Workflows reference release tags; the lockfile
|
|
||||||
holds the commit that runs. Do not edit it by hand.
|
|
||||||
|
|
||||||
After adding a workflow or changing any `uses:` line, regenerate it with the
|
|
||||||
[`gh actions-lock`](https://github.com/github/gh-actions-lock) extension and
|
|
||||||
commit the result:
|
|
||||||
|
|
||||||
```sh
|
|
||||||
gh extension install github/gh-actions-lock
|
|
||||||
gh actions-lock
|
|
||||||
```
|
|
||||||
|
|
||||||
Dependabot updates the lockfile entry in the same pull request when it bumps an
|
|
||||||
action.
|
|
||||||
|
|
||||||
The `Workflow lint` workflow verifies the lockfile on every pull request and
|
|
||||||
fails when it does not match the workflows.
|
|
||||||
|
|
||||||
## Project tracking
|
|
||||||
|
|
||||||
`project.yml` intentionally uses `pull_request_target` so the GitHub App can add
|
|
||||||
fork contributions to the project board. It must not check out or execute PR
|
|
||||||
code. Project IDs are validated before passing them through step outputs, and
|
|
||||||
PR-derived plugin/theme names are restricted to letters, digits, dots, underscores
|
|
||||||
and hyphens.
|
|
||||||
|
|
||||||
The App tokens request explicit permissions: project tracking needs organization
|
|
||||||
projects write access and issues/pull requests read access; dependency updates
|
|
||||||
need contents read access and issues/pull requests write access. Dependency pushes
|
|
||||||
use the job's separate `GITHUB_TOKEN` with contents write access.
|
|
||||||
|
|
||||||
## Installer deployment
|
|
||||||
|
|
||||||
The Vercel CLI is pinned in `installer/package.json` and `installer/package-lock.json`.
|
|
||||||
Dependabot checks this dependency weekly, with a seven-day cooldown for version
|
|
||||||
updates, like the other configured ecosystems. Deployment installs the lockfile
|
|
||||||
with `npm ci --ignore-scripts`; `.vercelignore` uploads only `install.sh`.
|
|
||||||
|
|
||||||
After changing the CLI version, update its lockfile and verify the CLI locally:
|
|
||||||
|
|
||||||
```sh
|
|
||||||
npm install --package-lock-only --ignore-scripts --prefix .github/workflows/installer
|
|
||||||
npm ci --ignore-scripts --prefix .github/workflows/installer
|
|
||||||
.github/workflows/installer/node_modules/.bin/vercel --version
|
|
||||||
```
|
|
||||||
@@ -1,90 +0,0 @@
|
|||||||
# This file is machine-generated by `gh actions-lock`.
|
|
||||||
# Do not edit by hand; run `gh actions-lock` to update.
|
|
||||||
# Docs: https://gh.io/actions-lockfile
|
|
||||||
version: 'v0.0.3'
|
|
||||||
workflows:
|
|
||||||
'.github/workflows/dependencies.yml':
|
|
||||||
- 'actions/checkout@v7.0.1'
|
|
||||||
- 'actions/create-github-app-token@v3.4.0'
|
|
||||||
- 'actions/setup-python@v7.1.0'
|
|
||||||
- 'step-security/harden-runner@v2.23.0'
|
|
||||||
'.github/workflows/installer.yml':
|
|
||||||
- 'actions/checkout@v7.0.1'
|
|
||||||
- 'actions/setup-node@v7.1.0'
|
|
||||||
- 'step-security/harden-runner@v2.23.0'
|
|
||||||
'.github/workflows/lint.yml':
|
|
||||||
- 'actions/checkout@v7.0.1'
|
|
||||||
- 'github/gh-actions-lock@verify/v0.5.1'
|
|
||||||
- 'jdx/jactionlint@v2.6.0'
|
|
||||||
- 'step-security/harden-runner@v2.23.0'
|
|
||||||
'.github/workflows/main.yml':
|
|
||||||
- 'actions/checkout@v7.0.1'
|
|
||||||
- 'actions/setup-python@v7.1.0'
|
|
||||||
- 'step-security/harden-runner@v2.23.0'
|
|
||||||
'.github/workflows/project.yml':
|
|
||||||
- 'actions/create-github-app-token@v3.4.0'
|
|
||||||
- 'step-security/harden-runner@v2.23.0'
|
|
||||||
'.github/workflows/scorecard.yml':
|
|
||||||
- 'actions/checkout@v7.0.1'
|
|
||||||
- 'actions/upload-artifact@v7.0.2'
|
|
||||||
- 'github/codeql-action@v4.39.5'
|
|
||||||
- 'ossf/scorecard-action@v2.6.0'
|
|
||||||
- 'step-security/harden-runner@v2.23.0'
|
|
||||||
dependencies:
|
|
||||||
'actions/checkout@v7.0.1':
|
|
||||||
ref: 'v7.0.1'
|
|
||||||
commit: 'sha1-3d3c42e5aac5ba805825da76410c181273ba90b1'
|
|
||||||
owner_id: 44036562
|
|
||||||
repo_id: 197814629
|
|
||||||
'actions/create-github-app-token@v3.4.0':
|
|
||||||
ref: 'v3.4.0'
|
|
||||||
commit: 'sha1-f418cff399f7aef4c2f0ad47e25ca7a6abbdd6fc'
|
|
||||||
owner_id: 44036562
|
|
||||||
repo_id: 642580244
|
|
||||||
'actions/setup-node@v7.1.0':
|
|
||||||
ref: 'v7.1.0'
|
|
||||||
commit: 'sha1-949feb2413d6458794dcd2491c4babbbce0c15c1'
|
|
||||||
owner_id: 44036562
|
|
||||||
repo_id: 189476904
|
|
||||||
'actions/setup-python@v7.1.0':
|
|
||||||
ref: 'v7.1.0'
|
|
||||||
commit: 'sha1-6d4fd22b20465ccc0f7354476588e8df7c9ca0e0'
|
|
||||||
owner_id: 44036562
|
|
||||||
repo_id: 192625525
|
|
||||||
'actions/upload-artifact@v7.0.2':
|
|
||||||
ref: 'v7.0.2'
|
|
||||||
commit: 'sha1-cf430e030ddbb5b0abf93d22962f4752f3646cd9'
|
|
||||||
owner_id: 44036562
|
|
||||||
repo_id: 192625955
|
|
||||||
'github/codeql-action@2892aa5e19bbd11bc0cff5427e3b750a04d9e3c2':
|
|
||||||
ref: 'v4.38.2'
|
|
||||||
commit: 'sha1-2892aa5e19bbd11bc0cff5427e3b750a04d9e3c2'
|
|
||||||
owner_id: 9919
|
|
||||||
repo_id: 259445878
|
|
||||||
'github/codeql-action@v4.39.5':
|
|
||||||
ref: 'v4.39.5'
|
|
||||||
commit: 'sha1-915412ff23e8b7659517e607487dbeae018f2934'
|
|
||||||
owner_id: 9919
|
|
||||||
repo_id: 259445878
|
|
||||||
'github/gh-actions-lock@verify/v0.5.1':
|
|
||||||
ref: 'verify/v0.5.1'
|
|
||||||
commit: 'sha1-5fa07d19c267d19e29f4341f10fdf7f516375038'
|
|
||||||
owner_id: 9919
|
|
||||||
repo_id: 1217640442
|
|
||||||
'jdx/jactionlint@v2.6.0':
|
|
||||||
ref: 'v2.6.0'
|
|
||||||
commit: 'sha1-72c00452809bcca05b8bc12acdcf15dd7a9c1c5e'
|
|
||||||
owner_id: 216188
|
|
||||||
repo_id: 1404951382
|
|
||||||
uses:
|
|
||||||
- 'github/codeql-action@2892aa5e19bbd11bc0cff5427e3b750a04d9e3c2'
|
|
||||||
'ossf/scorecard-action@v2.6.0':
|
|
||||||
ref: 'v2.6.0'
|
|
||||||
commit: 'sha1-23f22cd43608bae7a1f1fa2603d7314dee9538a5'
|
|
||||||
owner_id: 67707773
|
|
||||||
repo_id: 421101922
|
|
||||||
'step-security/harden-runner@v2.23.0':
|
|
||||||
ref: 'v2.23.0'
|
|
||||||
commit: 'sha1-aebdcf6156ab6691adf63218240e476564a1ed4c'
|
|
||||||
owner_id: 88700172
|
|
||||||
repo_id: 422287306
|
|
||||||
@@ -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
|
|
||||||
@@ -11,31 +11,27 @@ jobs:
|
|||||||
check:
|
check:
|
||||||
name: Check for updates
|
name: Check for updates
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
timeout-minutes: 30
|
|
||||||
if: github.repository == 'ohmyzsh/ohmyzsh'
|
if: github.repository == 'ohmyzsh/ohmyzsh'
|
||||||
permissions:
|
permissions:
|
||||||
contents: write # this is needed to push commits and branches
|
contents: write # this is needed to push commits and branches
|
||||||
steps:
|
steps:
|
||||||
- name: Harden the runner (Audit all outbound calls)
|
- name: Harden the runner (Audit all outbound calls)
|
||||||
uses: step-security/harden-runner@v2.23.0
|
uses: step-security/harden-runner@aebdcf6156ab6691adf63218240e476564a1ed4c # v2.23.0
|
||||||
with:
|
with:
|
||||||
egress-policy: audit
|
egress-policy: audit
|
||||||
|
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v7.0.1
|
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
- name: Authenticate as @ohmyzsh
|
- name: Authenticate as @ohmyzsh
|
||||||
id: generate-token
|
id: generate-token
|
||||||
uses: actions/create-github-app-token@v3.4.0
|
uses: actions/create-github-app-token@f418cff399f7aef4c2f0ad47e25ca7a6abbdd6fc # v3.4.0
|
||||||
with:
|
with:
|
||||||
client-id: ${{ secrets.OHMYZSH_CLIENT_ID }}
|
client-id: ${{ secrets.OHMYZSH_CLIENT_ID }}
|
||||||
private-key: ${{ secrets.OHMYZSH_APP_PRIVATE_KEY }}
|
private-key: ${{ secrets.OHMYZSH_APP_PRIVATE_KEY }}
|
||||||
permission-contents: read
|
|
||||||
permission-issues: write
|
|
||||||
permission-pull-requests: write
|
|
||||||
- name: Setup Python
|
- name: Setup Python
|
||||||
uses: actions/setup-python@v7.1.0
|
uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7.1.0
|
||||||
with:
|
with:
|
||||||
python-version: "3.12"
|
python-version: "3.12"
|
||||||
cache: "pip"
|
cache: "pip"
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
certifi==2026.11.20
|
certifi==2026.10.23
|
||||||
charset-normalizer==3.5.3
|
charset-normalizer==3.5.2
|
||||||
idna==3.20
|
idna==3.20
|
||||||
PyYAML==6.0.4
|
PyYAML==6.0.3
|
||||||
requests==2.34.2
|
requests==2.34.2
|
||||||
semver==3.1.3
|
semver==3.1.2
|
||||||
urllib3==2.8.0
|
urllib3==2.8.0
|
||||||
@@ -19,7 +19,6 @@ jobs:
|
|||||||
name: Test installer
|
name: Test installer
|
||||||
if: github.repository == 'ohmyzsh/ohmyzsh'
|
if: github.repository == 'ohmyzsh/ohmyzsh'
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
timeout-minutes: 15
|
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
os:
|
os:
|
||||||
@@ -27,12 +26,12 @@ jobs:
|
|||||||
- macos-latest
|
- macos-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Harden the runner (Audit all outbound calls)
|
- name: Harden the runner (Audit all outbound calls)
|
||||||
uses: step-security/harden-runner@v2.23.0
|
uses: step-security/harden-runner@aebdcf6156ab6691adf63218240e476564a1ed4c # v2.23.0
|
||||||
with:
|
with:
|
||||||
egress-policy: audit
|
egress-policy: audit
|
||||||
|
|
||||||
- name: Set up git repository
|
- name: Set up git repository
|
||||||
uses: actions/checkout@v7.0.1
|
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||||
- name: Install zsh
|
- name: Install zsh
|
||||||
if: runner.os == 'Linux'
|
if: runner.os == 'Linux'
|
||||||
run: sudo apt-get update; sudo apt-get install zsh
|
run: sudo apt-get update; sudo apt-get install zsh
|
||||||
@@ -43,28 +42,19 @@ jobs:
|
|||||||
name: Deploy installer in install.ohmyz.sh
|
name: Deploy installer in install.ohmyz.sh
|
||||||
if: github.ref == 'refs/heads/master'
|
if: github.ref == 'refs/heads/master'
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
timeout-minutes: 15
|
|
||||||
environment: vercel
|
environment: vercel
|
||||||
needs:
|
needs:
|
||||||
- test
|
- test
|
||||||
steps:
|
steps:
|
||||||
- name: Harden the runner (Audit all outbound calls)
|
- name: Harden the runner (Audit all outbound calls)
|
||||||
uses: step-security/harden-runner@v2.23.0
|
uses: step-security/harden-runner@aebdcf6156ab6691adf63218240e476564a1ed4c # v2.23.0
|
||||||
with:
|
with:
|
||||||
egress-policy: audit
|
egress-policy: audit
|
||||||
|
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v7.0.1
|
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||||
with:
|
|
||||||
persist-credentials: false
|
|
||||||
- name: Set up Node.js
|
|
||||||
uses: actions/setup-node@v7.1.0
|
|
||||||
with:
|
|
||||||
node-version: "24"
|
|
||||||
package-manager-cache: false
|
|
||||||
- name: Install Vercel CLI
|
- name: Install Vercel CLI
|
||||||
working-directory: .github/workflows/installer
|
run: npm install -g vercel
|
||||||
run: npm ci --ignore-scripts --no-audit --no-fund
|
|
||||||
- name: Setup project and deploy
|
- name: Setup project and deploy
|
||||||
env:
|
env:
|
||||||
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
|
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
|
||||||
@@ -73,4 +63,4 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
cp tools/install.sh .github/workflows/installer/install.sh
|
cp tools/install.sh .github/workflows/installer/install.sh
|
||||||
cd .github/workflows/installer
|
cd .github/workflows/installer
|
||||||
./node_modules/.bin/vercel deploy --prod -t "$VERCEL_TOKEN"
|
vc deploy --prod -t "$VERCEL_TOKEN"
|
||||||
@@ -1,2 +1 @@
|
|||||||
install.sh
|
install.sh
|
||||||
node_modules/
|
|
||||||
-5585
File diff suppressed because it is too large.
Load diff
@@ -1,7 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "ohmyzsh-installer-deploy",
|
|
||||||
"private": true,
|
|
||||||
"devDependencies": {
|
|
||||||
"vercel": "66.6.0"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,35 +0,0 @@
|
|||||||
name: Workflow lint
|
|
||||||
on:
|
|
||||||
pull_request:
|
|
||||||
push:
|
|
||||||
branches:
|
|
||||||
- master
|
|
||||||
|
|
||||||
concurrency:
|
|
||||||
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
|
|
||||||
cancel-in-progress: true
|
|
||||||
|
|
||||||
permissions:
|
|
||||||
contents: read
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
jactionlint:
|
|
||||||
name: Lint GitHub Actions
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
timeout-minutes: 10
|
|
||||||
steps:
|
|
||||||
- name: Harden the runner (Audit all outbound calls)
|
|
||||||
uses: step-security/harden-runner@v2.23.0
|
|
||||||
with:
|
|
||||||
egress-policy: audit
|
|
||||||
- name: Checkout
|
|
||||||
uses: actions/checkout@v7.0.1
|
|
||||||
with:
|
|
||||||
persist-credentials: false
|
|
||||||
- name: Lint workflows and Dependabot configuration
|
|
||||||
uses: jdx/jactionlint@v2.6.0
|
|
||||||
with:
|
|
||||||
profile: default
|
|
||||||
online: "false"
|
|
||||||
- name: Verify action lockfile
|
|
||||||
uses: github/gh-actions-lock@verify/v0.5.1
|
|
||||||
@@ -21,55 +21,23 @@ jobs:
|
|||||||
tests:
|
tests:
|
||||||
name: Run tests
|
name: Run tests
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
timeout-minutes: 10
|
|
||||||
if: github.repository == 'ohmyzsh/ohmyzsh'
|
if: github.repository == 'ohmyzsh/ohmyzsh'
|
||||||
steps:
|
steps:
|
||||||
- name: Harden the runner (Audit all outbound calls)
|
- name: Harden the runner (Audit all outbound calls)
|
||||||
uses: step-security/harden-runner@v2.23.0
|
uses: step-security/harden-runner@aebdcf6156ab6691adf63218240e476564a1ed4c # v2.23.0
|
||||||
with:
|
with:
|
||||||
egress-policy: audit
|
egress-policy: audit
|
||||||
|
|
||||||
- name: Set up git repository
|
- name: Set up git repository
|
||||||
uses: actions/checkout@v7.0.1
|
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||||
- name: Install zsh
|
- name: Install zsh
|
||||||
run: sudo apt-get update; sudo apt-get install zsh
|
run: sudo apt-get update; sudo apt-get install zsh
|
||||||
- name: Check syntax
|
- name: Check syntax
|
||||||
run: |
|
run: |
|
||||||
for file in ./oh-my-zsh.sh \
|
for file in ./oh-my-zsh.sh \
|
||||||
./lib/*.zsh \
|
./lib/*.zsh \
|
||||||
./functions/* \
|
|
||||||
./completions/_* \
|
|
||||||
./plugins/*/*.plugin.zsh \
|
./plugins/*/*.plugin.zsh \
|
||||||
./plugins/*/_* \
|
./plugins/*/_* \
|
||||||
./themes/*.zsh-theme; do
|
./themes/*.zsh-theme; do
|
||||||
zsh -n "$file" || exit 1
|
zsh -n "$file" || return 1
|
||||||
done
|
done
|
||||||
|
|
||||||
collisions:
|
|
||||||
name: Check alias collisions
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
timeout-minutes: 10
|
|
||||||
steps:
|
|
||||||
- name: Set up git repository
|
|
||||||
uses: actions/checkout@v7.0.1
|
|
||||||
- name: Set up Python
|
|
||||||
uses: actions/setup-python@v7.1.0
|
|
||||||
with:
|
|
||||||
python-version: '3.14'
|
|
||||||
- name: Install dependencies
|
|
||||||
run: |
|
|
||||||
python -m pip install --upgrade pip
|
|
||||||
pip install -r .github/workflows/alias_collision/requirements.txt
|
|
||||||
- name: Run unit tests
|
|
||||||
run: |
|
|
||||||
cd .github/workflows/alias_collision/
|
|
||||||
python -m pytest
|
|
||||||
- name: Checkout target branch
|
|
||||||
uses: actions/checkout@v7.0.1
|
|
||||||
with:
|
|
||||||
path: ohmyzsh-target-branch
|
|
||||||
ref: master
|
|
||||||
- name: Check for alias collisions on target branch
|
|
||||||
run: python .github/workflows/alias_collision/check_alias_collision.py ohmyzsh-target-branch/plugins --known-collisions-output-path known_alias_collisions.json
|
|
||||||
- name: Compare known collisions to new collisions on source branch
|
|
||||||
run: python .github/workflows/alias_collision/check_alias_collision.py plugins --known-collisions known_alias_collisions.json
|
|
||||||
@@ -2,8 +2,6 @@ name: Project tracking
|
|||||||
on:
|
on:
|
||||||
issues:
|
issues:
|
||||||
types: [opened, reopened]
|
types: [opened, reopened]
|
||||||
# Board updates need an App token for fork PRs; no PR code is checked out or run.
|
|
||||||
# jactionlint ignore=dangerous-triggers
|
|
||||||
pull_request_target:
|
pull_request_target:
|
||||||
types: [opened, reopened, synchronize]
|
types: [opened, reopened, synchronize]
|
||||||
|
|
||||||
@@ -16,35 +14,25 @@ jobs:
|
|||||||
add-to-project:
|
add-to-project:
|
||||||
name: Add to project
|
name: Add to project
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
timeout-minutes: 10
|
|
||||||
defaults:
|
|
||||||
run:
|
|
||||||
shell: bash
|
|
||||||
if: github.repository == 'ohmyzsh/ohmyzsh'
|
if: github.repository == 'ohmyzsh/ohmyzsh'
|
||||||
steps:
|
steps:
|
||||||
- name: Harden the runner (Audit all outbound calls)
|
- name: Harden the runner (Audit all outbound calls)
|
||||||
uses: step-security/harden-runner@v2.23.0
|
uses: step-security/harden-runner@aebdcf6156ab6691adf63218240e476564a1ed4c # v2.23.0
|
||||||
with:
|
with:
|
||||||
egress-policy: audit
|
egress-policy: audit
|
||||||
- name: Authenticate as @ohmyzsh
|
- name: Authenticate as @ohmyzsh
|
||||||
id: generate-token
|
id: generate-token
|
||||||
uses: actions/create-github-app-token@v3.4.0
|
uses: actions/create-github-app-token@f418cff399f7aef4c2f0ad47e25ca7a6abbdd6fc # v3.4.0
|
||||||
with:
|
with:
|
||||||
client-id: ${{ secrets.OHMYZSH_CLIENT_ID }}
|
client-id: ${{ secrets.OHMYZSH_CLIENT_ID }}
|
||||||
private-key: ${{ secrets.OHMYZSH_APP_PRIVATE_KEY }}
|
private-key: ${{ secrets.OHMYZSH_APP_PRIVATE_KEY }}
|
||||||
permission-organization-projects: write
|
|
||||||
permission-issues: read
|
|
||||||
permission-pull-requests: read
|
|
||||||
- name: Read project data
|
- name: Read project data
|
||||||
id: project
|
|
||||||
env:
|
env:
|
||||||
GH_TOKEN: ${{ steps.generate-token.outputs.token }}
|
GH_TOKEN: ${{ steps.generate-token.outputs.token }}
|
||||||
ORGANIZATION: ohmyzsh
|
ORGANIZATION: ohmyzsh
|
||||||
PROJECT_NUMBER: "1"
|
PROJECT_NUMBER: "1"
|
||||||
run: |
|
run: |
|
||||||
# Get Project data
|
# Get Project data
|
||||||
# GraphQL variables must reach GitHub literally.
|
|
||||||
# shellcheck disable=SC2016
|
|
||||||
gh api graphql -f query='
|
gh api graphql -f query='
|
||||||
query($org: String!, $number: Int!) {
|
query($org: String!, $number: Int!) {
|
||||||
organization(login: $org){
|
organization(login: $org){
|
||||||
@@ -60,29 +48,19 @@ jobs:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}' -f org="$ORGANIZATION" -F number="$PROJECT_NUMBER" > project_data.json
|
}' -f org=$ORGANIZATION -F number=$PROJECT_NUMBER > project_data.json
|
||||||
|
|
||||||
# Parse project data
|
# Parse project data
|
||||||
PROJECT_ID=$(jq -er '.data.organization.projectV2.id' project_data.json)
|
cat >> "$GITHUB_ENV" <<EOF
|
||||||
PLUGIN_FIELD_ID=$(jq -er '.data.organization.projectV2.fields.nodes[] | select(.name == "Plugin") | .id' project_data.json)
|
PROJECT_ID=$(jq '.data.organization.projectV2.id' project_data.json)
|
||||||
THEME_FIELD_ID=$(jq -er '.data.organization.projectV2.fields.nodes[] | select(.name == "Theme") | .id' project_data.json)
|
PLUGIN_FIELD_ID=$(jq '.data.organization.projectV2.fields.nodes[] | select(.name == "Plugin") | .id' project_data.json)
|
||||||
for id in "$PROJECT_ID" "$PLUGIN_FIELD_ID" "$THEME_FIELD_ID"; do
|
THEME_FIELD_ID=$(jq '.data.organization.projectV2.fields.nodes[] | select(.name == "Theme") | .id' project_data.json)
|
||||||
[[ "$id" =~ ^[A-Za-z0-9_=/+-]+$ ]] || exit 1
|
EOF
|
||||||
done
|
|
||||||
{
|
|
||||||
echo "PROJECT_ID=$PROJECT_ID"
|
|
||||||
echo "PLUGIN_FIELD_ID=$PLUGIN_FIELD_ID"
|
|
||||||
echo "THEME_FIELD_ID=$THEME_FIELD_ID"
|
|
||||||
} >> "$GITHUB_OUTPUT"
|
|
||||||
- name: Add to project
|
- name: Add to project
|
||||||
id: item
|
|
||||||
env:
|
env:
|
||||||
GH_TOKEN: ${{ steps.generate-token.outputs.token }}
|
GH_TOKEN: ${{ steps.generate-token.outputs.token }}
|
||||||
ISSUE_OR_PR_ID: ${{ github.event.issue.node_id || github.event.pull_request.node_id }}
|
ISSUE_OR_PR_ID: ${{ github.event.issue.node_id || github.event.pull_request.node_id }}
|
||||||
PROJECT_ID: ${{ steps.project.outputs.PROJECT_ID }}
|
|
||||||
run: |
|
run: |
|
||||||
# GraphQL variables must reach GitHub literally.
|
|
||||||
# shellcheck disable=SC2016
|
|
||||||
item_id="$(gh api graphql -f query='
|
item_id="$(gh api graphql -f query='
|
||||||
mutation($project: ID!, $content: ID!) {
|
mutation($project: ID!, $content: ID!) {
|
||||||
addProjectV2ItemById(input: {projectId: $project, contentId: $content}) {
|
addProjectV2ItemById(input: {projectId: $project, contentId: $content}) {
|
||||||
@@ -91,12 +69,10 @@ jobs:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
' -f project="$PROJECT_ID" -f content="$ISSUE_OR_PR_ID" --jq '.data.addProjectV2ItemById.item.id // error("missing project item ID")')"
|
' -f project="$PROJECT_ID" -f content="$ISSUE_OR_PR_ID" --jq '.data.addProjectV2ItemById.item.id')"
|
||||||
|
|
||||||
[[ "$item_id" =~ ^[A-Za-z0-9_=/+-]+$ ]] || exit 1
|
echo "ITEM_ID=$item_id" >> $GITHUB_ENV
|
||||||
echo "ITEM_ID=$item_id" >> "$GITHUB_OUTPUT"
|
|
||||||
- name: Classify Pull Request
|
- name: Classify Pull Request
|
||||||
id: classify
|
|
||||||
if: github.event_name == 'pull_request_target'
|
if: github.event_name == 'pull_request_target'
|
||||||
env:
|
env:
|
||||||
GH_TOKEN: ${{ steps.generate-token.outputs.token }}
|
GH_TOKEN: ${{ steps.generate-token.outputs.token }}
|
||||||
@@ -133,20 +109,12 @@ jobs:
|
|||||||
print "THEME=" theme
|
print "THEME=" theme
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
' >> "$GITHUB_OUTPUT"
|
' >> "$GITHUB_ENV"
|
||||||
- name: Fill Pull Request fields in project
|
- name: Fill Pull Request fields in project
|
||||||
if: github.event_name == 'pull_request_target'
|
if: github.event_name == 'pull_request_target'
|
||||||
env:
|
env:
|
||||||
GH_TOKEN: ${{ steps.generate-token.outputs.token }}
|
GH_TOKEN: ${{ steps.generate-token.outputs.token }}
|
||||||
PROJECT_ID: ${{ steps.project.outputs.PROJECT_ID }}
|
|
||||||
ITEM_ID: ${{ steps.item.outputs.ITEM_ID }}
|
|
||||||
PLUGIN_FIELD_ID: ${{ steps.project.outputs.PLUGIN_FIELD_ID }}
|
|
||||||
PLUGIN: ${{ steps.classify.outputs.PLUGIN }}
|
|
||||||
THEME_FIELD_ID: ${{ steps.project.outputs.THEME_FIELD_ID }}
|
|
||||||
THEME: ${{ steps.classify.outputs.THEME }}
|
|
||||||
run: |
|
run: |
|
||||||
# GraphQL variables must reach GitHub literally.
|
|
||||||
# shellcheck disable=SC2016
|
|
||||||
gh api graphql -f query='
|
gh api graphql -f query='
|
||||||
mutation (
|
mutation (
|
||||||
$project: ID!
|
$project: ID!
|
||||||
|
|||||||
@@ -14,18 +14,13 @@ on:
|
|||||||
push:
|
push:
|
||||||
branches: ["master"]
|
branches: ["master"]
|
||||||
|
|
||||||
concurrency:
|
# Declare default permissions as read only.
|
||||||
group: ${{ github.workflow }}-${{ github.ref }}
|
permissions: read-all
|
||||||
cancel-in-progress: true
|
|
||||||
|
|
||||||
# Permissions are granted only to the analysis job.
|
|
||||||
permissions: {}
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
analysis:
|
analysis:
|
||||||
name: Scorecard analysis
|
name: Scorecard analysis
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
timeout-minutes: 15
|
|
||||||
permissions:
|
permissions:
|
||||||
# Needed to upload the results to code-scanning dashboard.
|
# Needed to upload the results to code-scanning dashboard.
|
||||||
security-events: write
|
security-events: write
|
||||||
@@ -41,30 +36,30 @@ jobs:
|
|||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Harden the runner (Audit all outbound calls)
|
- name: Harden the runner (Audit all outbound calls)
|
||||||
uses: step-security/harden-runner@v2.23.0
|
uses: step-security/harden-runner@aebdcf6156ab6691adf63218240e476564a1ed4c # v2.23.0
|
||||||
with:
|
with:
|
||||||
egress-policy: audit
|
egress-policy: audit
|
||||||
|
|
||||||
- name: "Checkout code"
|
- name: "Checkout code"
|
||||||
uses: actions/checkout@v7.0.1
|
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||||
with:
|
with:
|
||||||
persist-credentials: false
|
persist-credentials: false
|
||||||
|
|
||||||
- name: "Run analysis"
|
- name: "Run analysis"
|
||||||
uses: ossf/scorecard-action@v2.6.0
|
uses: ossf/scorecard-action@23f22cd43608bae7a1f1fa2603d7314dee9538a5 # v2.6.0
|
||||||
with:
|
with:
|
||||||
results_file: results.sarif
|
results_file: results.sarif
|
||||||
results_format: sarif
|
results_format: sarif
|
||||||
publish_results: true
|
publish_results: true
|
||||||
|
|
||||||
- name: "Upload artifact"
|
- name: "Upload artifact"
|
||||||
uses: actions/upload-artifact@v7.0.2
|
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
|
||||||
with:
|
with:
|
||||||
name: SARIF file
|
name: SARIF file
|
||||||
path: results.sarif
|
path: results.sarif
|
||||||
retention-days: 5
|
retention-days: 5
|
||||||
|
|
||||||
- name: "Upload to code-scanning"
|
- name: "Upload to code-scanning"
|
||||||
uses: github/codeql-action/upload-sarif@v4.39.5
|
uses: github/codeql-action/upload-sarif@33d7b85da1a04171e211befe2c739303b9a4c066 # v4.39.3
|
||||||
with:
|
with:
|
||||||
sarif_file: results.sarif
|
sarif_file: results.sarif
|
||||||
@@ -1,34 +0,0 @@
|
|||||||
# Instructions for coding agents
|
|
||||||
|
|
||||||
Oh My Zsh is maintained by a small team of volunteers. A person reviews every
|
|
||||||
pull request, so help the contributor send one that is easy to review.
|
|
||||||
|
|
||||||
## Before opening a pull request
|
|
||||||
|
|
||||||
1. Read [CONTRIBUTING.md](CONTRIBUTING.md) and follow it.
|
|
||||||
2. Search open pull requests and issues for the same change. If one exists,
|
|
||||||
tell the contributor instead of opening a duplicate.
|
|
||||||
3. Fill in [.github/PULL_REQUEST_TEMPLATE.md](.github/PULL_REQUEST_TEMPLATE.md).
|
|
||||||
Keep its sections and its checklist.
|
|
||||||
4. Use the [commit format](CONTRIBUTING.md#commit-guidelines) for commits and
|
|
||||||
for the pull request title.
|
|
||||||
|
|
||||||
## Writing the description
|
|
||||||
|
|
||||||
- Report only evidence you have. Don't invent user requests, test results,
|
|
||||||
or demo links.
|
|
||||||
- Separate checks you ran from testing the contributor did. Don't claim
|
|
||||||
personal testing or confirmation on their behalf.
|
|
||||||
- Leave unconfirmed checklist items unchecked, and name any missing testing
|
|
||||||
or demo.
|
|
||||||
- Don't commit the contributor to follow-up work they haven't agreed to.
|
|
||||||
- Disclose meaningful AI assistance in "Other notes".
|
|
||||||
- Put file names and paths in backticks so they render as code.
|
|
||||||
|
|
||||||
## Keeping the change reviewable
|
|
||||||
|
|
||||||
- One purpose per pull request. Keep the diff small, and leave unrelated
|
|
||||||
files alone.
|
|
||||||
- Follow the [code style guide](https://github.com/ohmyzsh/ohmyzsh/wiki/Code-Style-Guide).
|
|
||||||
- The contributor must be able to explain the change. If they can't yet,
|
|
||||||
explain it to them before the pull request is opened.
|
|
||||||
@@ -20,7 +20,6 @@ you would make is not already covered.
|
|||||||
- [Getting started](#getting-started)
|
- [Getting started](#getting-started)
|
||||||
- [You have a solution](#you-have-a-solution)
|
- [You have a solution](#you-have-a-solution)
|
||||||
- [You have an addition](#you-have-an-addition)
|
- [You have an addition](#you-have-an-addition)
|
||||||
- [Writing your PR description](#writing-your-pr-description)
|
|
||||||
- [A note on AI-assisted contributions](#a-note-on-ai-assisted-contributions)
|
- [A note on AI-assisted contributions](#a-note-on-ai-assisted-contributions)
|
||||||
- [Use the Search, Luke](#use-the-search-luke)
|
- [Use the Search, Luke](#use-the-search-luke)
|
||||||
- [Commit Guidelines](#commit-guidelines)
|
- [Commit Guidelines](#commit-guidelines)
|
||||||
@@ -127,34 +126,6 @@ Because of this, from now on, we require that new aliases follow these condition
|
|||||||
This list is not exhaustive! Please remember that your alias will be in the machines of many people,
|
This list is not exhaustive! Please remember that your alias will be in the machines of many people,
|
||||||
so it should be justified why they should have it.
|
so it should be justified why they should have it.
|
||||||
|
|
||||||
### Writing your PR description
|
|
||||||
|
|
||||||
Use the [PR template](.github/PULL_REQUEST_TEMPLATE.md) to help people understand
|
|
||||||
the purpose of your change before they reach the submission checklist. Keep answers
|
|
||||||
short and proportional to the change; a sentence or two per section is often enough.
|
|
||||||
|
|
||||||
Oh My Zsh should make the command line more delightful. Tell us whose day your
|
|
||||||
change makes easier, clearer, or more enjoyable, and how. Scratching your own itch
|
|
||||||
is a welcome starting point! Your change doesn't need to help everyone, but explain
|
|
||||||
why it would be useful to others and belongs in the shared project. Link relevant
|
|
||||||
requests or examples when you have them; otherwise, explain the expected benefit
|
|
||||||
without claiming demand you haven't seen.
|
|
||||||
|
|
||||||
For user-facing changes, include screenshots, a GIF, or a short video showing
|
|
||||||
before/after behavior. For a new feature, demonstrate it in use. Label the examples,
|
|
||||||
keep terminal text readable, and remove private information. For low-level or other
|
|
||||||
non-visual changes, explain why a visual wouldn't be useful. If a demo is needed
|
|
||||||
but you can't capture it yet, say so rather than marking it inapplicable.
|
|
||||||
|
|
||||||
Describe the checks actually run and their results, relevant environment versions,
|
|
||||||
and any testing gaps. Distinguish automated or agent-run checks from testing you
|
|
||||||
personally performed. For documentation-only changes, describe what you checked.
|
|
||||||
Only check the personal-testing item after you've done that testing yourself.
|
|
||||||
|
|
||||||
For features and enhancements, tell us how you'll help users discover and use them.
|
|
||||||
A plugin README update, a usage example, or sharing your demo are good ways to help.
|
|
||||||
Be clear about what's included in the PR and what's planned for later.
|
|
||||||
|
|
||||||
## A note on AI-assisted contributions
|
## A note on AI-assisted contributions
|
||||||
|
|
||||||
We'll admit it: AI tools can be pretty helpful for coding tasks, and we're not here to gatekeep how you get your work done. We use these tools ourselves! 🤖
|
We'll admit it: AI tools can be pretty helpful for coding tasks, and we're not here to gatekeep how you get your work done. We use these tools ourselves! 🤖
|
||||||
@@ -179,9 +150,6 @@ The disclosure helps us know how much guidance to offer. If we're just reviewing
|
|||||||
|
|
||||||
As always, we reserve the right to decline any contribution. PRs that appear to be unreviewed AI output, or code the contributor can't explain, may be closed without extensive feedback.
|
As always, we reserve the right to decline any contribution. PRs that appear to be unreviewed AI output, or code the contributor can't explain, may be closed without extensive feedback.
|
||||||
|
|
||||||
**For coding agents:** follow [AGENTS.md](AGENTS.md). It covers what to read
|
|
||||||
before drafting a PR and how to keep the description grounded in evidence.
|
|
||||||
|
|
||||||
----
|
----
|
||||||
|
|
||||||
## Use the Search, Luke
|
## Use the Search, Luke
|
||||||
|
|||||||
@@ -562,7 +562,8 @@ omz diagnose
|
|||||||
|
|
||||||
It runs a few quick checks and tells you what to fix — for example, it will warn you when
|
It runs a few quick checks and tells you what to fix — for example, it will warn you when
|
||||||
your locale is not UTF-8, which is a common cause of duplicated characters at the prompt
|
your locale is not UTF-8, which is a common cause of duplicated characters at the prompt
|
||||||
(see the [FAQ](https://github.com/ohmyzsh/ohmyzsh/wiki/FAQ#i-see-duplicate-typed-characters-after-i-complete-a-command)).
|
(see the [FAQ](https://github.com/ohmyzsh/ohmyzsh/wiki/FAQ#i-see-duplicate-typed-characters-after-i-complete-a-command)),
|
||||||
|
and it validates your `plugins=(...)` list, suggesting the closest name for any plugin it can't find.
|
||||||
|
|
||||||
For a full report suitable for attaching to a bug report, use `omz_diagnostic_dump`.
|
For a full report suitable for attaching to a bug report, use `omz_diagnostic_dump`.
|
||||||
|
|
||||||
|
|||||||
@@ -1,104 +0,0 @@
|
|||||||
#compdef omz
|
|
||||||
|
|
||||||
local -a cmds subcmds
|
|
||||||
cmds=(
|
|
||||||
'changelog:Print the changelog'
|
|
||||||
'diagnose:Run configuration diagnostics'
|
|
||||||
'help:Usage information'
|
|
||||||
'plugin:Manage plugins'
|
|
||||||
'pr:Manage Oh My Zsh Pull Requests'
|
|
||||||
'reload:Reload the current zsh session'
|
|
||||||
'shellsaver:Launch a whimsical terminal screensaver'
|
|
||||||
'shop:Open the Oh My Zsh shop'
|
|
||||||
'theme:Manage themes'
|
|
||||||
'update:Update Oh My Zsh'
|
|
||||||
'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
|
|
||||||
_describe 'command' cmds
|
|
||||||
elif (( CURRENT == 3 )); then
|
|
||||||
case "$words[2]" in
|
|
||||||
changelog) local -a refs
|
|
||||||
refs=("${(@f)$(builtin cd -q "$ZSH"; command git for-each-ref --format="%(refname:short):%(subject)" refs/heads refs/tags)}")
|
|
||||||
_describe 'command' refs ;;
|
|
||||||
plugin) subcmds=(
|
|
||||||
'disable:Disable plugin(s)'
|
|
||||||
'enable:Enable plugin(s)'
|
|
||||||
'info:Get plugin information'
|
|
||||||
'list:List plugins'
|
|
||||||
'load:Load plugin(s)'
|
|
||||||
)
|
|
||||||
_describe 'command' subcmds ;;
|
|
||||||
pr) subcmds=('clean:Delete all Pull Request branches' 'test:Test a Pull Request')
|
|
||||||
_describe 'command' subcmds ;;
|
|
||||||
theme) subcmds=('list:List themes' 'set:Set a theme in your .zshrc file' 'use:Load a theme')
|
|
||||||
_describe 'command' subcmds ;;
|
|
||||||
esac
|
|
||||||
elif (( CURRENT == 4 )); then
|
|
||||||
case "${words[2]}::${words[3]}" in
|
|
||||||
plugin::(disable|enable|load))
|
|
||||||
local -aU valid_plugins
|
|
||||||
|
|
||||||
if [[ "${words[3]}" = disable ]]; then
|
|
||||||
# if command is "disable", only offer already enabled plugins
|
|
||||||
valid_plugins=($plugins)
|
|
||||||
else
|
|
||||||
valid_plugins=("$ZSH"/plugins/*/{_*,*.plugin.zsh}(-.N:h:t) "$ZSH_CUSTOM"/plugins/*/{_*,*.plugin.zsh}(-.N:h:t))
|
|
||||||
# if command is "enable", remove already enabled plugins
|
|
||||||
[[ "${words[3]}" = enable ]] && valid_plugins=(${valid_plugins:|plugins})
|
|
||||||
fi
|
|
||||||
|
|
||||||
_describe 'plugin' valid_plugins ;;
|
|
||||||
plugin::info)
|
|
||||||
local -aU plugins
|
|
||||||
plugins=("$ZSH"/plugins/*/{_*,*.plugin.zsh}(-.N:h:t) "$ZSH_CUSTOM"/plugins/*/{_*,*.plugin.zsh}(-.N:h:t))
|
|
||||||
_describe 'plugin' plugins ;;
|
|
||||||
plugin::list)
|
|
||||||
local -a opts
|
|
||||||
opts=('--enabled:List enabled plugins only')
|
|
||||||
_describe -o 'options' opts ;;
|
|
||||||
theme::(set|use))
|
|
||||||
local -aU themes
|
|
||||||
themes=("$ZSH"/themes/*.zsh-theme(-.N:t:r) "$ZSH_CUSTOM"/**/*.zsh-theme(-.N:r:gs:"$ZSH_CUSTOM"/themes/:::gs:"$ZSH_CUSTOM"/:::))
|
|
||||||
_describe 'theme' themes ;;
|
|
||||||
esac
|
|
||||||
elif (( CURRENT > 4 )); then
|
|
||||||
case "${words[2]}::${words[3]}" in
|
|
||||||
plugin::(enable|disable|load))
|
|
||||||
local -aU valid_plugins
|
|
||||||
|
|
||||||
if [[ "${words[3]}" = disable ]]; then
|
|
||||||
# if command is "disable", only offer already enabled plugins
|
|
||||||
valid_plugins=($plugins)
|
|
||||||
else
|
|
||||||
valid_plugins=("$ZSH"/plugins/*/{_*,*.plugin.zsh}(-.N:h:t) "$ZSH_CUSTOM"/plugins/*/{_*,*.plugin.zsh}(-.N:h:t))
|
|
||||||
# if command is "enable", remove already enabled plugins
|
|
||||||
[[ "${words[3]}" = enable ]] && valid_plugins=(${valid_plugins:|plugins})
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Remove plugins already passed as arguments
|
|
||||||
# NOTE: $(( CURRENT - 1 )) is the last plugin argument completely passed, i.e. that which
|
|
||||||
# has a space after them. This is to avoid removing plugins partially passed, which makes
|
|
||||||
# the completion not add a space after the completed plugin.
|
|
||||||
local -a args
|
|
||||||
args=(${words[4,$(( CURRENT - 1))]})
|
|
||||||
valid_plugins=(${valid_plugins:|args})
|
|
||||||
|
|
||||||
_describe 'plugin' valid_plugins ;;
|
|
||||||
esac
|
|
||||||
fi
|
|
||||||
|
|
||||||
return 0
|
|
||||||
-897
@@ -1,897 +0,0 @@
|
|||||||
function omz {
|
|
||||||
setopt localoptions noksharrays
|
|
||||||
[[ $# -gt 0 ]] || {
|
|
||||||
_omz::help
|
|
||||||
return 1
|
|
||||||
}
|
|
||||||
|
|
||||||
local command="$1"
|
|
||||||
shift
|
|
||||||
|
|
||||||
# Subcommand functions start with _ so that they don't
|
|
||||||
# appear as completion entries when looking for `omz`
|
|
||||||
(( ${+functions[_omz::$command]} )) || {
|
|
||||||
_omz::help
|
|
||||||
return 1
|
|
||||||
}
|
|
||||||
|
|
||||||
_omz::$command "$@"
|
|
||||||
}
|
|
||||||
|
|
||||||
## Utility functions
|
|
||||||
|
|
||||||
function _omz::confirm {
|
|
||||||
# If question supplied, ask it before reading the answer
|
|
||||||
# NOTE: uses the logname of the caller function
|
|
||||||
if [[ -n "$1" ]]; then
|
|
||||||
_omz::log prompt "$1" "${${functrace[1]#_}%:*}"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Read one character
|
|
||||||
read -r -k 1
|
|
||||||
|
|
||||||
# If no newline entered, add a newline
|
|
||||||
if [[ "$REPLY" != $'\n' ]]; then
|
|
||||||
echo
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
function _omz::log {
|
|
||||||
# if promptsubst is set, a message with `` or $()
|
|
||||||
# will be run even if quoted due to `print -P`
|
|
||||||
setopt localoptions nopromptsubst
|
|
||||||
|
|
||||||
# $1 = info|warn|error|debug
|
|
||||||
# $2 = text
|
|
||||||
# $3 = (optional) name of the logger
|
|
||||||
|
|
||||||
local logtype=$1
|
|
||||||
local logname=${3:-${${functrace[1]#_}%:*}}
|
|
||||||
|
|
||||||
# Don't print anything if debug is not active
|
|
||||||
if [[ $logtype = debug && -z $_OMZ_DEBUG ]]; then
|
|
||||||
return
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Choose coloring based on log type
|
|
||||||
case "$logtype" in
|
|
||||||
prompt) print -Pn "%S%F{blue}$logname%f%s: $2" ;;
|
|
||||||
debug) print -P "%F{white}$logname%f: $2" ;;
|
|
||||||
info) print -P "%F{green}$logname%f: $2" ;;
|
|
||||||
warn) print -P "%S%F{yellow}$logname%f%s: $2" ;;
|
|
||||||
error) print -P "%S%F{red}$logname%f%s: $2" ;;
|
|
||||||
esac >&2
|
|
||||||
}
|
|
||||||
|
|
||||||
## User-facing commands
|
|
||||||
|
|
||||||
function _omz::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 {
|
|
||||||
cat >&2 <<EOF
|
|
||||||
Usage: omz <command> [options]
|
|
||||||
|
|
||||||
Available commands:
|
|
||||||
|
|
||||||
diagnose Run configuration diagnostics
|
|
||||||
help Print this help message
|
|
||||||
changelog Print the changelog
|
|
||||||
plugin <command> Manage plugins
|
|
||||||
pr <command> Manage Oh My Zsh Pull Requests
|
|
||||||
reload Reload the current zsh session
|
|
||||||
shellsaver [scene] Launch a Shellsaver (aquarium by default)
|
|
||||||
shop Open the Oh My Zsh shop
|
|
||||||
theme <command> Manage themes
|
|
||||||
update Update Oh My Zsh
|
|
||||||
version Show the version
|
|
||||||
|
|
||||||
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 {
|
|
||||||
local version=${1:-HEAD} format=${3:-"--text"}
|
|
||||||
|
|
||||||
if (
|
|
||||||
builtin cd -q "$ZSH"
|
|
||||||
! command git show-ref --verify refs/heads/$version && \
|
|
||||||
! command git show-ref --verify refs/tags/$version && \
|
|
||||||
! command git rev-parse --verify "${version}^{commit}"
|
|
||||||
) &>/dev/null; then
|
|
||||||
cat >&2 <<EOF
|
|
||||||
Usage: ${(j: :)${(s.::.)0#_}} [version]
|
|
||||||
|
|
||||||
NOTE: <version> must be a valid branch, tag or commit.
|
|
||||||
EOF
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
ZSH="$ZSH" command zsh -f "$ZSH/tools/changelog.sh" "$version" "${2:-}" "$format"
|
|
||||||
}
|
|
||||||
|
|
||||||
function _omz::plugin {
|
|
||||||
(( $# > 0 && $+functions[$0::$1] )) || {
|
|
||||||
cat >&2 <<EOF
|
|
||||||
Usage: ${(j: :)${(s.::.)0#_}} <command> [options]
|
|
||||||
|
|
||||||
Available commands:
|
|
||||||
|
|
||||||
disable <plugin> Disable plugin(s)
|
|
||||||
enable <plugin> Enable plugin(s)
|
|
||||||
info <plugin> Get information of a plugin
|
|
||||||
list [--enabled] List Oh My Zsh plugins
|
|
||||||
load <plugin> Load plugin(s)
|
|
||||||
|
|
||||||
EOF
|
|
||||||
return 1
|
|
||||||
}
|
|
||||||
|
|
||||||
local command="$1"
|
|
||||||
shift
|
|
||||||
|
|
||||||
$0::$command "$@"
|
|
||||||
}
|
|
||||||
|
|
||||||
function _omz::plugin::disable {
|
|
||||||
if [[ -z "$1" ]]; then
|
|
||||||
echo >&2 "Usage: ${(j: :)${(s.::.)0#_}} <plugin> [...]"
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Check that plugin is in $plugins
|
|
||||||
local -a dis_plugins
|
|
||||||
for plugin in "$@"; do
|
|
||||||
if [[ ${plugins[(Ie)$plugin]} -eq 0 ]]; then
|
|
||||||
_omz::log warn "plugin '$plugin' is not enabled."
|
|
||||||
continue
|
|
||||||
fi
|
|
||||||
dis_plugins+=("$plugin")
|
|
||||||
done
|
|
||||||
|
|
||||||
# Exit if there are no enabled plugins to disable
|
|
||||||
if [[ ${#dis_plugins} -eq 0 ]]; then
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Remove plugins substitution awk script
|
|
||||||
# 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="\
|
|
||||||
do {
|
|
||||||
prev = \$0
|
|
||||||
|
|
||||||
gsub(/[ \t]+(${(j:|:)dis_plugins})[ \t]+/, \" \") # with spaces before or after
|
|
||||||
gsub(/[ \t]+(${(j:|:)dis_plugins})$/, \"\") # with spaces before and EOL
|
|
||||||
gsub(/^(${(j:|:)dis_plugins})[ \t]+/, \"\") # with BOL and spaces after
|
|
||||||
|
|
||||||
gsub(/\((${(j:|:)dis_plugins})[ \t]+/, \"(\") # with parenthesis before and spaces after
|
|
||||||
gsub(/[ \t]+(${(j:|:)dis_plugins})\)/, \")\") # with spaces before or parenthesis after
|
|
||||||
gsub(/\((${(j:|:)dis_plugins})\)/, \"()\") # with only parentheses
|
|
||||||
|
|
||||||
gsub(/^(${(j:|:)dis_plugins})\)/, \")\") # with BOL and closing parenthesis
|
|
||||||
gsub(/\((${(j:|:)dis_plugins})$/, \"(\") # with opening parenthesis and EOL
|
|
||||||
} while (\$0 != prev)
|
|
||||||
"
|
|
||||||
|
|
||||||
# Disable plugins awk script
|
|
||||||
local awk_script="
|
|
||||||
# if plugins=() is in oneline form, substitute disabled plugins and go to next line
|
|
||||||
/^[ \t]*plugins=\([^#]+\).*\$/ {
|
|
||||||
$awk_subst_plugins
|
|
||||||
print \$0
|
|
||||||
next
|
|
||||||
}
|
|
||||||
|
|
||||||
# if plugins=() is in multiline form, enable multi flag and disable plugins if they're there
|
|
||||||
/^[ \t]*plugins=\(/ {
|
|
||||||
multi=1
|
|
||||||
$awk_subst_plugins
|
|
||||||
print \$0
|
|
||||||
next
|
|
||||||
}
|
|
||||||
|
|
||||||
# if multi flag is enabled and we find a valid closing parenthesis, remove plugins and disable multi flag
|
|
||||||
multi == 1 && /^[^#]*\)/ {
|
|
||||||
multi=0
|
|
||||||
$awk_subst_plugins
|
|
||||||
print \$0
|
|
||||||
next
|
|
||||||
}
|
|
||||||
|
|
||||||
multi == 1 && length(\$0) > 0 {
|
|
||||||
$awk_subst_plugins
|
|
||||||
if (length(\$0) > 0) print \$0
|
|
||||||
next
|
|
||||||
}
|
|
||||||
|
|
||||||
{ print \$0 }
|
|
||||||
"
|
|
||||||
|
|
||||||
local zdot="${ZDOTDIR:-$HOME}"
|
|
||||||
local zshrc="${${:-"${zdot}/.zshrc"}:A}"
|
|
||||||
awk "$awk_script" "$zshrc" > "$zdot/.zshrc.new" \
|
|
||||||
&& command cp -f "$zshrc" "$zdot/.zshrc.bck" \
|
|
||||||
&& command mv -f "$zdot/.zshrc.new" "$zshrc"
|
|
||||||
|
|
||||||
# Exit if the new .zshrc file wasn't created correctly
|
|
||||||
[[ $? -eq 0 ]] || {
|
|
||||||
local ret=$?
|
|
||||||
_omz::log error "error disabling plugins."
|
|
||||||
return $ret
|
|
||||||
}
|
|
||||||
|
|
||||||
# Exit if the new .zshrc file has syntax errors
|
|
||||||
if ! command zsh -n "$zdot/.zshrc"; then
|
|
||||||
_omz::log error "broken syntax in '"${zdot/#$HOME/\~}/.zshrc"'. Rolling back changes..."
|
|
||||||
command mv -f "$zdot/.zshrc.bck" "$zshrc"
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Restart the zsh session if there were no errors
|
|
||||||
_omz::log info "plugins disabled: ${(j:, :)dis_plugins}."
|
|
||||||
|
|
||||||
# Only reload zsh if run in an interactive session
|
|
||||||
[[ ! -o interactive ]] || _omz::reload
|
|
||||||
}
|
|
||||||
|
|
||||||
function _omz::plugin::enable {
|
|
||||||
if [[ -z "$1" ]]; then
|
|
||||||
echo >&2 "Usage: ${(j: :)${(s.::.)0#_}} <plugin> [...]"
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Check that plugin is not in $plugins
|
|
||||||
local -a add_plugins
|
|
||||||
for plugin in "$@"; do
|
|
||||||
if [[ ${plugins[(Ie)$plugin]} -ne 0 ]]; then
|
|
||||||
_omz::log warn "plugin '$plugin' is already enabled."
|
|
||||||
continue
|
|
||||||
fi
|
|
||||||
add_plugins+=("$plugin")
|
|
||||||
done
|
|
||||||
|
|
||||||
# Exit if there are no plugins to enable
|
|
||||||
if [[ ${#add_plugins} -eq 0 ]]; then
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Enable plugins awk script
|
|
||||||
local awk_script="
|
|
||||||
# if plugins=() is in oneline form (empty or not), substitute ) with new plugins and go to the next line
|
|
||||||
/^[ \t]*plugins=\([^#]*\).*\$/ {
|
|
||||||
sub(/\)/, \" $add_plugins&\")
|
|
||||||
print \$0
|
|
||||||
next
|
|
||||||
}
|
|
||||||
|
|
||||||
# if plugins=() is in multiline form, enable multi flag and indent by default with 2 spaces
|
|
||||||
/^[ \t]*plugins=\(/ {
|
|
||||||
multi=1
|
|
||||||
indent=\" \"
|
|
||||||
print \$0
|
|
||||||
next
|
|
||||||
}
|
|
||||||
|
|
||||||
# if multi flag is enabled and we find a valid closing parenthesis,
|
|
||||||
# add new plugins with proper indent and disable multi flag
|
|
||||||
multi == 1 && /^[^#]*\)/ {
|
|
||||||
multi=0
|
|
||||||
split(\"$add_plugins\",p,\" \")
|
|
||||||
for (i in p) {
|
|
||||||
print indent p[i]
|
|
||||||
}
|
|
||||||
print \$0
|
|
||||||
next
|
|
||||||
}
|
|
||||||
|
|
||||||
# if multi flag is enabled and we didn't find a closing parenthesis,
|
|
||||||
# get the indentation level to match when adding plugins
|
|
||||||
multi == 1 && /^[^#]*/ {
|
|
||||||
indent=\"\"
|
|
||||||
for (i = 1; i <= length(\$0); i++) {
|
|
||||||
char=substr(\$0, i, 1)
|
|
||||||
if (char == \" \" || char == \"\t\") {
|
|
||||||
indent = indent char
|
|
||||||
} else {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
{ print \$0 }
|
|
||||||
"
|
|
||||||
|
|
||||||
local zdot="${ZDOTDIR:-$HOME}"
|
|
||||||
local zshrc="${${:-"${zdot}/.zshrc"}:A}"
|
|
||||||
awk "$awk_script" "$zshrc" > "$zdot/.zshrc.new" \
|
|
||||||
&& command cp -f "$zshrc" "$zdot/.zshrc.bck" \
|
|
||||||
&& command mv -f "$zdot/.zshrc.new" "$zshrc"
|
|
||||||
|
|
||||||
# Exit if the new .zshrc file wasn't created correctly
|
|
||||||
[[ $? -eq 0 ]] || {
|
|
||||||
local ret=$?
|
|
||||||
_omz::log error "error enabling plugins."
|
|
||||||
return $ret
|
|
||||||
}
|
|
||||||
|
|
||||||
# Exit if the new .zshrc file has syntax errors
|
|
||||||
if ! command zsh -n "$zdot/.zshrc"; then
|
|
||||||
_omz::log error "broken syntax in '"${zdot/#$HOME/\~}/.zshrc"'. Rolling back changes..."
|
|
||||||
command mv -f "$zdot/.zshrc.bck" "$zshrc"
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Restart the zsh session if there were no errors
|
|
||||||
_omz::log info "plugins enabled: ${(j:, :)add_plugins}."
|
|
||||||
|
|
||||||
# Only reload zsh if run in an interactive session
|
|
||||||
[[ ! -o interactive ]] || _omz::reload
|
|
||||||
}
|
|
||||||
|
|
||||||
function _omz::plugin::info {
|
|
||||||
if [[ -z "$1" ]]; then
|
|
||||||
echo >&2 "Usage: ${(j: :)${(s.::.)0#_}} <plugin>"
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
local readme
|
|
||||||
for readme in "$ZSH_CUSTOM/plugins/$1/README.md" "$ZSH/plugins/$1/README.md"; do
|
|
||||||
if [[ -f "$readme" ]]; then
|
|
||||||
# If being piped, just cat the README
|
|
||||||
if [[ ! -t 1 ]]; then
|
|
||||||
cat "$readme"
|
|
||||||
return $?
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Enrich the README display depending on the tools we have
|
|
||||||
# - glow: https://github.com/charmbracelet/glow
|
|
||||||
# - bat: https://github.com/sharkdp/bat
|
|
||||||
# - less: typical pager command
|
|
||||||
case 1 in
|
|
||||||
${+commands[glow]}) glow -p "$readme" ;;
|
|
||||||
${+commands[bat]}) bat -l md --style plain "$readme" ;;
|
|
||||||
${+commands[less]}) less "$readme" ;;
|
|
||||||
*) cat "$readme" ;;
|
|
||||||
esac
|
|
||||||
return $?
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
if [[ -d "$ZSH_CUSTOM/plugins/$1" || -d "$ZSH/plugins/$1" ]]; then
|
|
||||||
_omz::log error "the '$1' plugin doesn't have a README file"
|
|
||||||
else
|
|
||||||
_omz::log error "'$1' plugin not found"
|
|
||||||
fi
|
|
||||||
|
|
||||||
return 1
|
|
||||||
}
|
|
||||||
|
|
||||||
function _omz::plugin::list {
|
|
||||||
local -a custom_plugins builtin_plugins
|
|
||||||
|
|
||||||
# If --enabled is provided, only list what's enabled
|
|
||||||
if [[ "$1" == "--enabled" ]]; then
|
|
||||||
local plugin
|
|
||||||
for plugin in "${plugins[@]}"; do
|
|
||||||
if [[ -d "${ZSH_CUSTOM}/plugins/${plugin}" ]]; then
|
|
||||||
custom_plugins+=("${plugin}")
|
|
||||||
elif [[ -d "${ZSH}/plugins/${plugin}" ]]; then
|
|
||||||
builtin_plugins+=("${plugin}")
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
else
|
|
||||||
custom_plugins=("$ZSH_CUSTOM"/plugins/*(-/N:t))
|
|
||||||
builtin_plugins=("$ZSH"/plugins/*(-/N:t))
|
|
||||||
fi
|
|
||||||
|
|
||||||
# If the command is being piped, print all found line by line
|
|
||||||
if [[ ! -t 1 ]]; then
|
|
||||||
print -l ${(q-)custom_plugins} ${(q-)builtin_plugins}
|
|
||||||
return
|
|
||||||
fi
|
|
||||||
|
|
||||||
if (( ${#custom_plugins} )); then
|
|
||||||
print -P "%U%BCustom plugins%b%u:"
|
|
||||||
print -lac ${(q-)custom_plugins}
|
|
||||||
fi
|
|
||||||
|
|
||||||
if (( ${#builtin_plugins} )); then
|
|
||||||
(( ${#custom_plugins} )) && echo # add a line of separation
|
|
||||||
|
|
||||||
print -P "%U%BBuilt-in plugins%b%u:"
|
|
||||||
print -lac ${(q-)builtin_plugins}
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
function _omz::plugin::load {
|
|
||||||
if [[ -z "$1" ]]; then
|
|
||||||
echo >&2 "Usage: ${(j: :)${(s.::.)0#_}} <plugin> [...]"
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
local plugin base has_completion=0
|
|
||||||
for plugin in "$@"; do
|
|
||||||
if [[ -d "$ZSH_CUSTOM/plugins/$plugin" ]]; then
|
|
||||||
base="$ZSH_CUSTOM/plugins/$plugin"
|
|
||||||
elif [[ -d "$ZSH/plugins/$plugin" ]]; then
|
|
||||||
base="$ZSH/plugins/$plugin"
|
|
||||||
else
|
|
||||||
_omz::log warn "plugin '$plugin' not found"
|
|
||||||
continue
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Check if its a valid plugin
|
|
||||||
if [[ ! -f "$base/_$plugin" && ! -f "$base/$plugin.plugin.zsh" ]]; then
|
|
||||||
_omz::log warn "'$plugin' is not a valid plugin"
|
|
||||||
continue
|
|
||||||
# It is a valid plugin, add its directory to $fpath unless it is already there
|
|
||||||
elif (( ! ${fpath[(Ie)$base]} )); then
|
|
||||||
fpath=("$base" $fpath)
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Check if it has completion to reload compinit
|
|
||||||
local -a comp_files
|
|
||||||
comp_files=($base/_*(N))
|
|
||||||
(( has_completion )) || has_completion=$(( $#comp_files > 0 ))
|
|
||||||
|
|
||||||
# Load the plugin
|
|
||||||
if [[ -f "$base/$plugin.plugin.zsh" ]]; then
|
|
||||||
source "$base/$plugin.plugin.zsh"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
# If we have completion, we need to reload the completion
|
|
||||||
# We pass -D to avoid generating a new dump file, which would overwrite our
|
|
||||||
# current one for the next session (and we don't want that because we're not
|
|
||||||
# actually enabling the plugins for the next session).
|
|
||||||
# Note that we still have to pass -d "$_comp_dumpfile", so that compinit
|
|
||||||
# doesn't use the default zcompdump location (${ZDOTDIR:-$HOME}/.zcompdump).
|
|
||||||
if (( has_completion )); then
|
|
||||||
compinit -D -d "$_comp_dumpfile"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
function _omz::pr {
|
|
||||||
(( $# > 0 && $+functions[$0::$1] )) || {
|
|
||||||
cat >&2 <<EOF
|
|
||||||
Usage: ${(j: :)${(s.::.)0#_}} <command> [options]
|
|
||||||
|
|
||||||
Available commands:
|
|
||||||
|
|
||||||
clean Delete all PR branches (ohmyzsh/pull-*)
|
|
||||||
test <PR_number_or_URL> Fetch PR #NUMBER and rebase against master
|
|
||||||
|
|
||||||
EOF
|
|
||||||
return 1
|
|
||||||
}
|
|
||||||
|
|
||||||
local command="$1"
|
|
||||||
shift
|
|
||||||
|
|
||||||
$0::$command "$@"
|
|
||||||
}
|
|
||||||
|
|
||||||
function _omz::pr::clean {
|
|
||||||
(
|
|
||||||
set -e
|
|
||||||
builtin cd -q "$ZSH"
|
|
||||||
|
|
||||||
# Check if there are PR branches
|
|
||||||
local fmt branches
|
|
||||||
fmt="%(color:bold blue)%(align:18,right)%(refname:short)%(end)%(color:reset) %(color:dim bold red)%(objectname:short)%(color:reset) %(color:yellow)%(contents:subject)"
|
|
||||||
branches="$(command git for-each-ref --sort=-committerdate --color --format="$fmt" "refs/heads/ohmyzsh/pull-*")"
|
|
||||||
|
|
||||||
# Exit if there are no PR branches
|
|
||||||
if [[ -z "$branches" ]]; then
|
|
||||||
_omz::log info "there are no Pull Request branches to remove."
|
|
||||||
return
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Print found PR branches
|
|
||||||
echo "$branches\n"
|
|
||||||
# Confirm before removing the branches
|
|
||||||
_omz::confirm "do you want remove these Pull Request branches? [Y/n] "
|
|
||||||
# Only proceed if the answer is a valid yes option
|
|
||||||
[[ "$REPLY" != [yY$'\n'] ]] && return
|
|
||||||
|
|
||||||
_omz::log info "removing all Oh My Zsh Pull Request branches..."
|
|
||||||
command git branch --list 'ohmyzsh/pull-*' | while read branch; do
|
|
||||||
command git branch -D "$branch"
|
|
||||||
done
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
function _omz::pr::test {
|
|
||||||
# Allow $1 to be a URL to the pull request
|
|
||||||
if [[ "$1" = https://* ]]; then
|
|
||||||
1="${1:t}"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Check the input
|
|
||||||
if ! [[ -n "$1" && "$1" =~ ^[[:digit:]]+$ ]]; then
|
|
||||||
echo >&2 "Usage: ${(j: :)${(s.::.)0#_}} <PR_NUMBER_or_URL>"
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Save current git HEAD
|
|
||||||
local branch
|
|
||||||
branch=$(builtin cd -q "$ZSH"; git symbolic-ref --short HEAD) || {
|
|
||||||
_omz::log error "error when getting the current git branch. Aborting..."
|
|
||||||
return 1
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
# Fetch PR onto ohmyzsh/pull-<PR_NUMBER> branch and rebase against master
|
|
||||||
# If any of these operations fail, undo the changes made
|
|
||||||
(
|
|
||||||
set -e
|
|
||||||
builtin cd -q "$ZSH"
|
|
||||||
|
|
||||||
# Get the ohmyzsh git remote
|
|
||||||
command git remote -v | while read remote url _; do
|
|
||||||
case "$url" in
|
|
||||||
https://github.com/ohmyzsh/ohmyzsh(|.git)) found=1; break ;;
|
|
||||||
git@github.com:ohmyzsh/ohmyzsh(|.git)) found=1; break ;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
|
|
||||||
(( $found )) || {
|
|
||||||
_omz::log error "could not find the ohmyzsh git remote. Aborting..."
|
|
||||||
return 1
|
|
||||||
}
|
|
||||||
|
|
||||||
# Check if Pull Request has the "testers needed" label
|
|
||||||
_omz::log info "checking if PR #$1 has the 'testers needed' label..."
|
|
||||||
local pr_json label label_id="MDU6TGFiZWw4NzY1NTkwNA=="
|
|
||||||
pr_json=$(
|
|
||||||
curl -fsSL \
|
|
||||||
-H "Accept: application/vnd.github+json" \
|
|
||||||
-H "X-GitHub-Api-Version: 2022-11-28" \
|
|
||||||
"https://api.github.com/repos/ohmyzsh/ohmyzsh/pulls/$1"
|
|
||||||
)
|
|
||||||
|
|
||||||
if [[ $? -gt 0 || -z "$pr_json" ]]; then
|
|
||||||
_omz::log error "error when trying to fetch PR #$1 from GitHub."
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Check if the label is present with jq or grep
|
|
||||||
if (( $+commands[jq] )); then
|
|
||||||
label="$(command jq ".labels.[] | select(.node_id == \"$label_id\")" <<< "$pr_json")"
|
|
||||||
else
|
|
||||||
label="$(command grep "\"$label_id\"" <<< "$pr_json" 2>/dev/null)"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# If a maintainer hasn't labeled the PR to test, explain the security risk
|
|
||||||
if [[ -z "$label" ]]; then
|
|
||||||
_omz::log warn "PR #$1 does not have the 'testers needed' label. This means that the PR"
|
|
||||||
_omz::log warn "has not been reviewed by a maintainer and may contain malicious code."
|
|
||||||
|
|
||||||
# Ask for explicit confirmation: user needs to type "yes" to continue
|
|
||||||
_omz::log prompt "Do you want to continue testing it? [yes/N] "
|
|
||||||
builtin read -r
|
|
||||||
if [[ "${REPLY:l}" != yes ]]; then
|
|
||||||
_omz::log error "PR test canceled. Please ask a maintainer to review and label the PR."
|
|
||||||
return 1
|
|
||||||
else
|
|
||||||
_omz::log warn "Continuing to check out and test PR #$1. Be careful!"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Fetch pull request head
|
|
||||||
_omz::log info "fetching PR #$1 to ohmyzsh/pull-$1..."
|
|
||||||
command git fetch -f "$remote" refs/pull/$1/head:ohmyzsh/pull-$1 || {
|
|
||||||
_omz::log error "error when trying to fetch PR #$1."
|
|
||||||
return 1
|
|
||||||
}
|
|
||||||
|
|
||||||
# Rebase pull request branch against the current master
|
|
||||||
_omz::log info "rebasing PR #$1..."
|
|
||||||
local ret gpgsign
|
|
||||||
{
|
|
||||||
# Back up commit.gpgsign setting: use --local to get the current repository
|
|
||||||
# setting, not the global one. If --local is not a known option, it will
|
|
||||||
# exit with a 129 status code.
|
|
||||||
gpgsign=$(command git config --local commit.gpgsign 2>/dev/null) || ret=$?
|
|
||||||
[[ $ret -ne 129 ]] || gpgsign=$(command git config commit.gpgsign 2>/dev/null)
|
|
||||||
command git config commit.gpgsign false
|
|
||||||
|
|
||||||
command git rebase master ohmyzsh/pull-$1 || {
|
|
||||||
command git rebase --abort &>/dev/null
|
|
||||||
_omz::log warn "could not rebase PR #$1 on top of master."
|
|
||||||
_omz::log warn "you might not see the latest stable changes."
|
|
||||||
_omz::log info "run \`zsh\` to test the changes."
|
|
||||||
return 1
|
|
||||||
}
|
|
||||||
} always {
|
|
||||||
case "$gpgsign" in
|
|
||||||
"") command git config --unset commit.gpgsign ;;
|
|
||||||
*) command git config commit.gpgsign "$gpgsign" ;;
|
|
||||||
esac
|
|
||||||
}
|
|
||||||
|
|
||||||
_omz::log info "fetch of PR #${1} successful."
|
|
||||||
)
|
|
||||||
|
|
||||||
# If there was an error, abort running zsh to test the PR
|
|
||||||
[[ $? -eq 0 ]] || return 1
|
|
||||||
|
|
||||||
# Run zsh to test the changes
|
|
||||||
_omz::log info "running \`zsh\` to test the changes. Run \`exit\` to go back."
|
|
||||||
command zsh -l
|
|
||||||
|
|
||||||
# After testing, go back to the previous HEAD if the user wants
|
|
||||||
_omz::confirm "do you want to go back to the previous branch? [Y/n] "
|
|
||||||
# Only proceed if the answer is a valid yes option
|
|
||||||
[[ "$REPLY" != [yY$'\n'] ]] && return
|
|
||||||
|
|
||||||
(
|
|
||||||
set -e
|
|
||||||
builtin cd -q "$ZSH"
|
|
||||||
|
|
||||||
command git checkout "$branch" -- || {
|
|
||||||
_omz::log error "could not go back to the previous branch ('$branch')."
|
|
||||||
return 1
|
|
||||||
}
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
function _omz::shop {
|
|
||||||
local shop_url="https://commitgoods.com/collections/oh-my-zsh"
|
|
||||||
|
|
||||||
_omz::log info "Opening Oh My Zsh shop in your browser..."
|
|
||||||
_omz::log info "$shop_url"
|
|
||||||
|
|
||||||
open_command "$shop_url"
|
|
||||||
}
|
|
||||||
|
|
||||||
function _omz::reload {
|
|
||||||
# Delete current completion cache
|
|
||||||
command rm -f $_comp_dumpfile $ZSH_COMPDUMP
|
|
||||||
|
|
||||||
# Old zsh versions don't have ZSH_ARGZERO
|
|
||||||
local zsh="${ZSH_ARGZERO:-${functrace[-1]%:*}}"
|
|
||||||
# ZSH_ARGZERO is how zsh was invoked, not the path to it, so re-resolve
|
|
||||||
# anything that is not absolute via $PATH at exec time (see #13919)
|
|
||||||
[[ "${zsh#-}" != /* ]] && (( $+commands[zsh] )) && zsh="zsh"
|
|
||||||
# Check whether to run a login shell
|
|
||||||
[[ "$zsh" = -* || -o login ]] && exec -l "${zsh#-}" || exec "$zsh"
|
|
||||||
}
|
|
||||||
|
|
||||||
function _omz::theme {
|
|
||||||
(( $# > 0 && $+functions[$0::$1] )) || {
|
|
||||||
cat >&2 <<EOF
|
|
||||||
Usage: ${(j: :)${(s.::.)0#_}} <command> [options]
|
|
||||||
|
|
||||||
Available commands:
|
|
||||||
|
|
||||||
list List all available Oh My Zsh themes
|
|
||||||
set <theme> Set a theme in your .zshrc file
|
|
||||||
use <theme> Load a theme
|
|
||||||
|
|
||||||
EOF
|
|
||||||
return 1
|
|
||||||
}
|
|
||||||
|
|
||||||
local command="$1"
|
|
||||||
shift
|
|
||||||
|
|
||||||
$0::$command "$@"
|
|
||||||
}
|
|
||||||
|
|
||||||
function _omz::theme::list {
|
|
||||||
local -a custom_themes builtin_themes
|
|
||||||
custom_themes=("$ZSH_CUSTOM"/**/*.zsh-theme(-.N:r:gs:"$ZSH_CUSTOM"/themes/:::gs:"$ZSH_CUSTOM"/:::))
|
|
||||||
builtin_themes=("$ZSH"/themes/*.zsh-theme(-.N:t:r))
|
|
||||||
|
|
||||||
# If the command is being piped, print all found line by line
|
|
||||||
if [[ ! -t 1 ]]; then
|
|
||||||
print -l ${(q-)custom_themes} ${(q-)builtin_themes}
|
|
||||||
return
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Print theme in use
|
|
||||||
if [[ -n "$ZSH_THEME" ]]; then
|
|
||||||
print -Pn "%U%BCurrent theme%b%u: "
|
|
||||||
[[ $ZSH_THEME = random ]] && echo "$RANDOM_THEME (via random)" || echo "$ZSH_THEME"
|
|
||||||
echo
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Print custom themes if there are any
|
|
||||||
if (( ${#custom_themes} )); then
|
|
||||||
print -P "%U%BCustom themes%b%u:"
|
|
||||||
print -lac ${(q-)custom_themes}
|
|
||||||
echo
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Print built-in themes
|
|
||||||
print -P "%U%BBuilt-in themes%b%u:"
|
|
||||||
print -lac ${(q-)builtin_themes}
|
|
||||||
}
|
|
||||||
|
|
||||||
function _omz::theme::set {
|
|
||||||
if [[ -z "$1" ]]; then
|
|
||||||
echo >&2 "Usage: ${(j: :)${(s.::.)0#_}} <theme>"
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Check that theme exists
|
|
||||||
if [[ ! -f "$ZSH_CUSTOM/$1.zsh-theme" ]] \
|
|
||||||
&& [[ ! -f "$ZSH_CUSTOM/themes/$1.zsh-theme" ]] \
|
|
||||||
&& [[ ! -f "$ZSH/themes/$1.zsh-theme" ]]; then
|
|
||||||
_omz::log error "%B$1%b theme not found"
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Enable theme in .zshrc
|
|
||||||
local awk_script='
|
|
||||||
!set && /^[ \t]*ZSH_THEME=[^#]+.*$/ {
|
|
||||||
set=1
|
|
||||||
sub(/^[ \t]*ZSH_THEME=[^#]+.*$/, "ZSH_THEME=\"'$1'\" # set by `omz`")
|
|
||||||
print $0
|
|
||||||
next
|
|
||||||
}
|
|
||||||
|
|
||||||
{ print $0 }
|
|
||||||
|
|
||||||
END {
|
|
||||||
# If no ZSH_THEME= line was found, return an error
|
|
||||||
if (!set) exit 1
|
|
||||||
}
|
|
||||||
'
|
|
||||||
|
|
||||||
local zdot="${ZDOTDIR:-$HOME}"
|
|
||||||
local zshrc="${${:-"${zdot}/.zshrc"}:A}"
|
|
||||||
awk "$awk_script" "$zshrc" > "$zdot/.zshrc.new" \
|
|
||||||
|| {
|
|
||||||
# Prepend ZSH_THEME= line to .zshrc if it doesn't exist
|
|
||||||
cat <<EOF
|
|
||||||
ZSH_THEME="$1" # set by \`omz\`
|
|
||||||
|
|
||||||
EOF
|
|
||||||
cat "$zdot/.zshrc"
|
|
||||||
} > "$zdot/.zshrc.new" \
|
|
||||||
&& command cp -f "$zshrc" "$zdot/.zshrc.bck" \
|
|
||||||
&& command mv -f "$zdot/.zshrc.new" "$zshrc"
|
|
||||||
|
|
||||||
# Exit if the new .zshrc file wasn't created correctly
|
|
||||||
[[ $? -eq 0 ]] || {
|
|
||||||
local ret=$?
|
|
||||||
_omz::log error "error setting theme."
|
|
||||||
return $ret
|
|
||||||
}
|
|
||||||
|
|
||||||
# Exit if the new .zshrc file has syntax errors
|
|
||||||
if ! command zsh -n "$zdot/.zshrc"; then
|
|
||||||
_omz::log error "broken syntax in '"${zdot/#$HOME/\~}/.zshrc"'. Rolling back changes..."
|
|
||||||
command mv -f "$zdot/.zshrc.bck" "$zshrc"
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Restart the zsh session if there were no errors
|
|
||||||
_omz::log info "'$1' theme set correctly."
|
|
||||||
|
|
||||||
# Only reload zsh if run in an interactive session
|
|
||||||
[[ ! -o interactive ]] || _omz::reload
|
|
||||||
}
|
|
||||||
|
|
||||||
function _omz::theme::use {
|
|
||||||
if [[ -z "$1" ]]; then
|
|
||||||
echo >&2 "Usage: ${(j: :)${(s.::.)0#_}} <theme>"
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Respect compatibility with old lookup order
|
|
||||||
if [[ -f "$ZSH_CUSTOM/$1.zsh-theme" ]]; then
|
|
||||||
source "$ZSH_CUSTOM/$1.zsh-theme"
|
|
||||||
elif [[ -f "$ZSH_CUSTOM/themes/$1.zsh-theme" ]]; then
|
|
||||||
source "$ZSH_CUSTOM/themes/$1.zsh-theme"
|
|
||||||
elif [[ -f "$ZSH/themes/$1.zsh-theme" ]]; then
|
|
||||||
source "$ZSH/themes/$1.zsh-theme"
|
|
||||||
else
|
|
||||||
_omz::log error "%B$1%b theme not found"
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Update theme settings
|
|
||||||
ZSH_THEME="$1"
|
|
||||||
[[ $1 = random ]] || unset RANDOM_THEME
|
|
||||||
}
|
|
||||||
|
|
||||||
function _omz::update {
|
|
||||||
# Check if git command is available
|
|
||||||
(( $+commands[git] )) || {
|
|
||||||
_omz::log error "git is not installed. Aborting..."
|
|
||||||
return 1
|
|
||||||
}
|
|
||||||
|
|
||||||
# Check if --unattended was passed
|
|
||||||
[[ "$1" != --unattended ]] || {
|
|
||||||
_omz::log error "the \`\e[2m--unattended\e[0m\` flag is no longer supported, use the \`\e[2mupgrade.sh\e[0m\` script instead."
|
|
||||||
_omz::log error "for more information see https://github.com/ohmyzsh/ohmyzsh/wiki/FAQ#how-do-i-update-oh-my-zsh"
|
|
||||||
return 1
|
|
||||||
}
|
|
||||||
|
|
||||||
local last_commit=$(builtin cd -q "$ZSH"; git rev-parse HEAD 2>/dev/null)
|
|
||||||
[[ $? -eq 0 ]] || {
|
|
||||||
_omz::log error "\`$ZSH\` is not a git directory. Aborting..."
|
|
||||||
return 1
|
|
||||||
}
|
|
||||||
|
|
||||||
# Run update script
|
|
||||||
local verbose_mode cooldown_days
|
|
||||||
zstyle -s ':omz:update' verbose verbose_mode || verbose_mode=default
|
|
||||||
zstyle -s ':omz:update' cooldown cooldown_days || cooldown_days=0
|
|
||||||
[[ $cooldown_days == <-> ]] || cooldown_days=0
|
|
||||||
ZSH="$ZSH" command zsh -f "$ZSH/tools/upgrade.sh" -i -v $verbose_mode -c $cooldown_days || return $?
|
|
||||||
|
|
||||||
# Update last updated file
|
|
||||||
zmodload zsh/datetime
|
|
||||||
echo "LAST_EPOCH=$(( EPOCHSECONDS / 60 / 60 / 24 ))" >! "${ZSH_CACHE_DIR}/.zsh-update"
|
|
||||||
# Remove update lock if it exists
|
|
||||||
command rm -rf "$ZSH/log/update.lock"
|
|
||||||
|
|
||||||
# Restart the zsh session if there were changes
|
|
||||||
if [[ "$(builtin cd -q "$ZSH"; git rev-parse HEAD)" != "$last_commit" ]]; then
|
|
||||||
# Old zsh versions don't have ZSH_ARGZERO
|
|
||||||
local zsh="${ZSH_ARGZERO:-${functrace[-1]%:*}}"
|
|
||||||
# ZSH_ARGZERO is how zsh was invoked, not the path to it, so re-resolve
|
|
||||||
# anything that is not absolute via $PATH at exec time (see #13919)
|
|
||||||
[[ "${zsh#-}" != /* ]] && (( $+commands[zsh] )) && zsh="zsh"
|
|
||||||
# Check whether to run a login shell
|
|
||||||
[[ "$zsh" = -* || -o login ]] && exec -l "${zsh#-}" || exec "$zsh"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
function _omz::version {
|
|
||||||
(
|
|
||||||
builtin cd -q "$ZSH"
|
|
||||||
|
|
||||||
# Get the version name:
|
|
||||||
# 1) try tag-like version
|
|
||||||
# 2) try branch name
|
|
||||||
# 3) try name-rev (tag~<rev> or branch~<rev>)
|
|
||||||
local version
|
|
||||||
version=$(command git describe --tags HEAD 2>/dev/null) \
|
|
||||||
|| version=$(command git symbolic-ref --quiet --short HEAD 2>/dev/null) \
|
|
||||||
|| version=$(command git name-rev --no-undefined --name-only --exclude="remotes/*" HEAD 2>/dev/null) \
|
|
||||||
|| version="<detached>"
|
|
||||||
|
|
||||||
# Get short hash for the current HEAD
|
|
||||||
local commit=$(command git rev-parse --short HEAD 2>/dev/null)
|
|
||||||
|
|
||||||
# Show version and commit hash
|
|
||||||
printf "%s (%s)\n" "$version" "$commit"
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
omz "$@"
|
|
||||||
@@ -1,356 +0,0 @@
|
|||||||
# omz_diagnostic_dump
|
|
||||||
#
|
|
||||||
# Diagnostic and debugging support for oh-my-zsh
|
|
||||||
|
|
||||||
# omz_diagnostic_dump()
|
|
||||||
#
|
|
||||||
# Author: Andrew Janke <andrew@apjanke.net>
|
|
||||||
#
|
|
||||||
# Usage:
|
|
||||||
#
|
|
||||||
# omz_diagnostic_dump [-v] [-V] [file]
|
|
||||||
#
|
|
||||||
# NOTE: This is a work in progress. Its interface and behavior are going to change,
|
|
||||||
# and probably in non-back-compatible ways.
|
|
||||||
#
|
|
||||||
# Outputs a bunch of information about the state and configuration of
|
|
||||||
# oh-my-zsh, zsh, and the user's system. This is intended to provide a
|
|
||||||
# bunch of context for diagnosing your own or a third party's problems, and to
|
|
||||||
# be suitable for posting to public bug reports.
|
|
||||||
#
|
|
||||||
# The output is human-readable and its format may change over time. It is not
|
|
||||||
# suitable for parsing. All the output is in one single file so it can be posted
|
|
||||||
# as a gist or bug comment on GitHub. GitHub doesn't support attaching tarballs
|
|
||||||
# or other files to bugs; otherwise, this would probably have an option to produce
|
|
||||||
# tarballs that contain copies of the config and customization files instead of
|
|
||||||
# catting them all in to one file.
|
|
||||||
#
|
|
||||||
# This is intended to be widely portable, and run anywhere that oh-my-zsh does.
|
|
||||||
# Feel free to report any portability issues as bugs.
|
|
||||||
#
|
|
||||||
# This is written in a defensive style so it still works (and can detect) cases when
|
|
||||||
# basic functionality like echo and which have been redefined. In particular, almost
|
|
||||||
# everything is invoked with "builtin" or "command", to work in the face of user
|
|
||||||
# redefinitions.
|
|
||||||
#
|
|
||||||
# OPTIONS
|
|
||||||
#
|
|
||||||
# [file] Specifies the output file. If not given, a file in the current directory
|
|
||||||
# is selected automatically.
|
|
||||||
#
|
|
||||||
# -v Increase the verbosity of the dump output. May be specified multiple times.
|
|
||||||
# Verbosity levels:
|
|
||||||
# 0 - Basic info, shell state, omz configuration, git state
|
|
||||||
# 1 - (default) Adds key binding info and configuration file contents
|
|
||||||
# 2 - Adds zcompdump file contents
|
|
||||||
#
|
|
||||||
# -V Reduce the verbosity of the dump output. May be specified multiple times.
|
|
||||||
#
|
|
||||||
# TODO:
|
|
||||||
# * Multi-file capture
|
|
||||||
# * Add automatic gist uploading
|
|
||||||
# * Consider whether to move default output file location to TMPDIR. More robust
|
|
||||||
# but less user friendly.
|
|
||||||
#
|
|
||||||
|
|
||||||
autoload -Uz is-at-least
|
|
||||||
|
|
||||||
function omz_diagnostic_dump() {
|
|
||||||
emulate -L zsh
|
|
||||||
|
|
||||||
builtin echo "Generating diagnostic dump; please be patient..."
|
|
||||||
|
|
||||||
local thisfcn=omz_diagnostic_dump
|
|
||||||
local -A opts
|
|
||||||
local opt_verbose opt_noverbose opt_outfile
|
|
||||||
local timestamp=$(date +%Y%m%d-%H%M%S)
|
|
||||||
local outfile=omz_diagdump_$timestamp.txt
|
|
||||||
builtin zparseopts -A opts -D -- "v+=opt_verbose" "V+=opt_noverbose"
|
|
||||||
local verbose n_verbose=${#opt_verbose} n_noverbose=${#opt_noverbose}
|
|
||||||
(( verbose = 1 + n_verbose - n_noverbose ))
|
|
||||||
|
|
||||||
if [[ ${#*} > 0 ]]; then
|
|
||||||
opt_outfile=$1
|
|
||||||
fi
|
|
||||||
if [[ ${#*} > 1 ]]; then
|
|
||||||
builtin echo "$thisfcn: error: too many arguments" >&2
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
if [[ -n "$opt_outfile" ]]; then
|
|
||||||
outfile="$opt_outfile"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Always write directly to a file so terminal escape sequences are
|
|
||||||
# captured cleanly
|
|
||||||
_omz_diag_dump_one_big_text &> "$outfile"
|
|
||||||
if [[ $? != 0 ]]; then
|
|
||||||
builtin echo "$thisfcn: error while creating diagnostic dump; see $outfile for details"
|
|
||||||
fi
|
|
||||||
|
|
||||||
builtin echo
|
|
||||||
builtin echo Diagnostic dump file created at: "$outfile"
|
|
||||||
builtin echo
|
|
||||||
builtin echo To share this with OMZ developers, post it as a gist on GitHub
|
|
||||||
builtin echo at "https://gist.github.com" and share the link to the gist.
|
|
||||||
builtin echo
|
|
||||||
builtin echo "WARNING: This dump file contains all your zsh and omz configuration files,"
|
|
||||||
builtin echo "so don't share it publicly if there's sensitive information in them."
|
|
||||||
builtin echo
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
function _omz_diag_dump_one_big_text() {
|
|
||||||
local program programs progfile md5
|
|
||||||
|
|
||||||
builtin echo oh-my-zsh diagnostic dump
|
|
||||||
builtin echo
|
|
||||||
builtin echo $outfile
|
|
||||||
builtin echo
|
|
||||||
|
|
||||||
# Basic system and zsh information
|
|
||||||
command date
|
|
||||||
command uname -a
|
|
||||||
builtin echo OSTYPE=$OSTYPE
|
|
||||||
builtin echo ZSH_VERSION=$ZSH_VERSION
|
|
||||||
builtin echo User: $USERNAME
|
|
||||||
builtin echo umask: $(umask)
|
|
||||||
builtin echo
|
|
||||||
_omz_diag_dump_os_specific_version
|
|
||||||
builtin echo
|
|
||||||
|
|
||||||
# Installed programs
|
|
||||||
programs=(sh zsh ksh bash sed cat grep ls find git posh)
|
|
||||||
local progfile="" extra_str="" sha_str=""
|
|
||||||
for program in $programs; do
|
|
||||||
extra_str="" sha_str=""
|
|
||||||
progfile=$(builtin which $program)
|
|
||||||
if [[ $? == 0 ]]; then
|
|
||||||
if [[ -e $progfile ]]; then
|
|
||||||
if builtin whence shasum &>/dev/null; then
|
|
||||||
sha_str=($(command shasum $progfile))
|
|
||||||
sha_str=$sha_str[1]
|
|
||||||
extra_str+=" SHA $sha_str"
|
|
||||||
fi
|
|
||||||
if [[ -h "$progfile" ]]; then
|
|
||||||
extra_str+=" ( -> ${progfile:A} )"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
builtin printf '%-9s %-20s %s\n' "$program is" "$progfile" "$extra_str"
|
|
||||||
else
|
|
||||||
builtin echo "$program: not found"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
builtin echo
|
|
||||||
builtin echo Command Versions:
|
|
||||||
builtin echo "zsh: $(zsh --version)"
|
|
||||||
builtin echo "this zsh session: $ZSH_VERSION"
|
|
||||||
builtin echo "bash: $(bash --version | command grep bash)"
|
|
||||||
builtin echo "git: $(git --version)"
|
|
||||||
builtin echo "grep: $(grep --version)"
|
|
||||||
builtin echo
|
|
||||||
|
|
||||||
# Core command definitions
|
|
||||||
_omz_diag_dump_check_core_commands || return 1
|
|
||||||
builtin echo
|
|
||||||
|
|
||||||
# ZSH Process state
|
|
||||||
builtin echo Process state:
|
|
||||||
builtin echo pwd: $PWD
|
|
||||||
if builtin whence pstree &>/dev/null; then
|
|
||||||
builtin echo Process tree for this shell:
|
|
||||||
pstree -p $$
|
|
||||||
else
|
|
||||||
ps -fT
|
|
||||||
fi
|
|
||||||
builtin set | command grep -a '^\(ZSH\|plugins\|TERM\|LC_\|LANG\|precmd\|chpwd\|preexec\|FPATH\|TTY\|DISPLAY\|PATH\)\|OMZ'
|
|
||||||
builtin echo
|
|
||||||
#TODO: Should this include `env` instead of or in addition to `export`?
|
|
||||||
builtin echo Exported:
|
|
||||||
builtin echo $(builtin export | command sed 's/=.*//')
|
|
||||||
builtin echo
|
|
||||||
builtin echo Locale:
|
|
||||||
command locale
|
|
||||||
builtin echo
|
|
||||||
|
|
||||||
# Zsh installation and configuration
|
|
||||||
builtin echo Zsh configuration:
|
|
||||||
builtin echo setopt: $(builtin setopt)
|
|
||||||
builtin echo
|
|
||||||
builtin echo zstyle:
|
|
||||||
builtin zstyle
|
|
||||||
builtin echo
|
|
||||||
builtin echo 'compaudit output:'
|
|
||||||
compaudit
|
|
||||||
builtin echo
|
|
||||||
builtin echo '$fpath directories:'
|
|
||||||
command ls -lad $fpath
|
|
||||||
builtin echo
|
|
||||||
|
|
||||||
# Oh-my-zsh installation
|
|
||||||
builtin echo oh-my-zsh installation:
|
|
||||||
command ls -ld ~/.z*
|
|
||||||
command ls -ld ~/.oh*
|
|
||||||
builtin echo
|
|
||||||
builtin echo oh-my-zsh git state:
|
|
||||||
(builtin cd $ZSH && builtin echo "HEAD: $(git rev-parse HEAD)" && git remote -v && git status | command grep "[^[:space:]]")
|
|
||||||
if [[ $verbose -ge 1 ]]; then
|
|
||||||
(builtin cd $ZSH && git reflog --date=default | command grep pull)
|
|
||||||
fi
|
|
||||||
builtin echo
|
|
||||||
if [[ -e $ZSH_CUSTOM ]]; then
|
|
||||||
local custom_dir=$ZSH_CUSTOM
|
|
||||||
if [[ -h $custom_dir ]]; then
|
|
||||||
custom_dir=$(builtin cd $custom_dir && pwd -P)
|
|
||||||
fi
|
|
||||||
builtin echo "oh-my-zsh custom dir:"
|
|
||||||
builtin echo " $ZSH_CUSTOM ($custom_dir)"
|
|
||||||
(builtin cd ${custom_dir:h} && command find ${custom_dir:t} -name .git -prune -o -print)
|
|
||||||
builtin echo
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Key binding and terminal info
|
|
||||||
if [[ $verbose -ge 1 ]]; then
|
|
||||||
builtin echo "bindkey:"
|
|
||||||
builtin bindkey
|
|
||||||
builtin echo
|
|
||||||
builtin echo "infocmp:"
|
|
||||||
command infocmp -L
|
|
||||||
builtin echo
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Configuration file info
|
|
||||||
local zdotdir=${ZDOTDIR:-$HOME}
|
|
||||||
builtin echo "Zsh configuration files:"
|
|
||||||
local cfgfile cfgfiles
|
|
||||||
# Some files for bash that zsh does not use are intentionally included
|
|
||||||
# to help with diagnosing behavior differences between bash and zsh
|
|
||||||
cfgfiles=( /etc/zshenv /etc/zprofile /etc/zshrc /etc/zlogin /etc/zlogout
|
|
||||||
$zdotdir/.zshenv $zdotdir/.zprofile $zdotdir/.zshrc $zdotdir/.zlogin $zdotdir/.zlogout
|
|
||||||
~/.zsh.pre-oh-my-zsh
|
|
||||||
/etc/bashrc /etc/profile ~/.bashrc ~/.profile ~/.bash_profile ~/.bash_logout )
|
|
||||||
command ls -lad $cfgfiles 2>&1
|
|
||||||
builtin echo
|
|
||||||
if [[ $verbose -ge 1 ]]; then
|
|
||||||
for cfgfile in $cfgfiles; do
|
|
||||||
_omz_diag_dump_echo_file_w_header $cfgfile
|
|
||||||
done
|
|
||||||
fi
|
|
||||||
builtin echo
|
|
||||||
builtin echo "Zsh compdump files:"
|
|
||||||
local dumpfile
|
|
||||||
local -U dumpfiles
|
|
||||||
dumpfiles=( $zdotdir/.zcompdump*(N) ${ZSH_COMPDUMP:h}/.zcompdump*(N) )
|
|
||||||
(( $#dumpfiles )) && command ls -lad $dumpfiles
|
|
||||||
if [[ $verbose -ge 2 ]]; then
|
|
||||||
for dumpfile in $dumpfiles; do
|
|
||||||
_omz_diag_dump_echo_file_w_header $dumpfile
|
|
||||||
done
|
|
||||||
fi
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
function _omz_diag_dump_check_core_commands() {
|
|
||||||
builtin echo "Core command check:"
|
|
||||||
local redefined name builtins externals reserved_words
|
|
||||||
redefined=()
|
|
||||||
# All the zsh non-module builtin commands
|
|
||||||
# These are taken from the zsh reference manual for 5.0.2
|
|
||||||
# Commands from modules should not be included.
|
|
||||||
# (For back-compatibility, if any of these are newish, they should be removed,
|
|
||||||
# or at least made conditional on the version of the current running zsh.)
|
|
||||||
# "history" is also excluded because OMZ is known to redefine that
|
|
||||||
reserved_words=( do done esac then elif else fi for case if while function
|
|
||||||
repeat time until select coproc nocorrect foreach end '!' '[[' '{' '}'
|
|
||||||
)
|
|
||||||
builtins=( alias autoload bg bindkey break builtin bye cd chdir command
|
|
||||||
comparguments compcall compctl compdescribe compfiles compgroups compquote comptags
|
|
||||||
comptry compvalues continue dirs disable disown echo echotc echoti emulate
|
|
||||||
enable eval exec exit false fc fg functions getln getopts hash
|
|
||||||
jobs kill let limit log logout noglob popd print printf
|
|
||||||
pushd pushln pwd r read rehash return sched set setopt shift
|
|
||||||
source suspend test times trap true ttyctl type ulimit umask unalias
|
|
||||||
unfunction unhash unlimit unset unsetopt vared wait whence where which zcompile
|
|
||||||
zle zmodload zparseopts zregexparse zstyle )
|
|
||||||
if is-at-least 5.1; then
|
|
||||||
reserved_words+=( declare export integer float local readonly typeset )
|
|
||||||
else
|
|
||||||
builtins+=( declare export integer float local readonly typeset )
|
|
||||||
fi
|
|
||||||
builtins_fatal=( builtin command local )
|
|
||||||
externals=( zsh )
|
|
||||||
for name in $reserved_words; do
|
|
||||||
if [[ $(builtin whence -w $name) != "$name: reserved" ]]; then
|
|
||||||
builtin echo "reserved word '$name' has been redefined"
|
|
||||||
builtin which $name
|
|
||||||
redefined+=$name
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
for name in $builtins; do
|
|
||||||
if [[ $(builtin whence -w $name) != "$name: builtin" ]]; then
|
|
||||||
builtin echo "builtin '$name' has been redefined"
|
|
||||||
builtin which $name
|
|
||||||
redefined+=$name
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
for name in $externals; do
|
|
||||||
if [[ $(builtin whence -w $name) != "$name: command" ]]; then
|
|
||||||
builtin echo "command '$name' has been redefined"
|
|
||||||
builtin which $name
|
|
||||||
redefined+=$name
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
if [[ -n "$redefined" ]]; then
|
|
||||||
builtin echo "SOME CORE COMMANDS HAVE BEEN REDEFINED: $redefined"
|
|
||||||
else
|
|
||||||
builtin echo "All core commands are defined normally"
|
|
||||||
fi
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
function _omz_diag_dump_echo_file_w_header() {
|
|
||||||
local file=$1
|
|
||||||
if [[ ( -f $file || -h $file ) ]]; then
|
|
||||||
builtin echo "========== $file =========="
|
|
||||||
if [[ -h $file ]]; then
|
|
||||||
builtin echo "========== ( => ${file:A} ) =========="
|
|
||||||
fi
|
|
||||||
command cat $file
|
|
||||||
builtin echo "========== end $file =========="
|
|
||||||
builtin echo
|
|
||||||
elif [[ -d $file ]]; then
|
|
||||||
builtin echo "File '$file' is a directory"
|
|
||||||
elif [[ ! -e $file ]]; then
|
|
||||||
builtin echo "File '$file' does not exist"
|
|
||||||
else
|
|
||||||
command ls -lad "$file"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
function _omz_diag_dump_os_specific_version() {
|
|
||||||
local osname osver version_file version_files
|
|
||||||
case "$OSTYPE" in
|
|
||||||
darwin*)
|
|
||||||
osname=$(command sw_vers -productName)
|
|
||||||
osver=$(command sw_vers -productVersion)
|
|
||||||
builtin echo "OS Version: $osname $osver build $(sw_vers -buildVersion)"
|
|
||||||
;;
|
|
||||||
cygwin)
|
|
||||||
command systeminfo | command head -n 4 | command tail -n 2
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
if builtin which lsb_release >/dev/null; then
|
|
||||||
builtin echo "OS Release: $(command lsb_release -s -d)"
|
|
||||||
fi
|
|
||||||
|
|
||||||
version_files=( /etc/*-release(N) /etc/*-version(N) /etc/*_version(N) )
|
|
||||||
for version_file in $version_files; do
|
|
||||||
builtin echo "$version_file:"
|
|
||||||
command cat "$version_file"
|
|
||||||
builtin echo
|
|
||||||
done
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
omz_diagnostic_dump "$@"
|
|
||||||
+1049
-3
File diff suppressed because it is too large.
Load diff
@@ -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
|
||||||
|
|
||||||
@@ -107,9 +87,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 +101,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 {
|
||||||
|
|||||||
+353
-3
@@ -1,3 +1,353 @@
|
|||||||
# Keep this library path available for custom overrides.
|
# diagnostics.zsh
|
||||||
# Force zsh-style autoloading so the first invocation runs once under kshautoload.
|
#
|
||||||
autoload -Uz omz_diagnostic_dump
|
# Diagnostic and debugging support for oh-my-zsh
|
||||||
|
|
||||||
|
# omz_diagnostic_dump()
|
||||||
|
#
|
||||||
|
# Author: Andrew Janke <andrew@apjanke.net>
|
||||||
|
#
|
||||||
|
# Usage:
|
||||||
|
#
|
||||||
|
# omz_diagnostic_dump [-v] [-V] [file]
|
||||||
|
#
|
||||||
|
# NOTE: This is a work in progress. Its interface and behavior are going to change,
|
||||||
|
# and probably in non-back-compatible ways.
|
||||||
|
#
|
||||||
|
# Outputs a bunch of information about the state and configuration of
|
||||||
|
# oh-my-zsh, zsh, and the user's system. This is intended to provide a
|
||||||
|
# bunch of context for diagnosing your own or a third party's problems, and to
|
||||||
|
# be suitable for posting to public bug reports.
|
||||||
|
#
|
||||||
|
# The output is human-readable and its format may change over time. It is not
|
||||||
|
# suitable for parsing. All the output is in one single file so it can be posted
|
||||||
|
# as a gist or bug comment on GitHub. GitHub doesn't support attaching tarballs
|
||||||
|
# or other files to bugs; otherwise, this would probably have an option to produce
|
||||||
|
# tarballs that contain copies of the config and customization files instead of
|
||||||
|
# catting them all in to one file.
|
||||||
|
#
|
||||||
|
# This is intended to be widely portable, and run anywhere that oh-my-zsh does.
|
||||||
|
# Feel free to report any portability issues as bugs.
|
||||||
|
#
|
||||||
|
# This is written in a defensive style so it still works (and can detect) cases when
|
||||||
|
# basic functionality like echo and which have been redefined. In particular, almost
|
||||||
|
# everything is invoked with "builtin" or "command", to work in the face of user
|
||||||
|
# redefinitions.
|
||||||
|
#
|
||||||
|
# OPTIONS
|
||||||
|
#
|
||||||
|
# [file] Specifies the output file. If not given, a file in the current directory
|
||||||
|
# is selected automatically.
|
||||||
|
#
|
||||||
|
# -v Increase the verbosity of the dump output. May be specified multiple times.
|
||||||
|
# Verbosity levels:
|
||||||
|
# 0 - Basic info, shell state, omz configuration, git state
|
||||||
|
# 1 - (default) Adds key binding info and configuration file contents
|
||||||
|
# 2 - Adds zcompdump file contents
|
||||||
|
#
|
||||||
|
# -V Reduce the verbosity of the dump output. May be specified multiple times.
|
||||||
|
#
|
||||||
|
# TODO:
|
||||||
|
# * Multi-file capture
|
||||||
|
# * Add automatic gist uploading
|
||||||
|
# * Consider whether to move default output file location to TMPDIR. More robust
|
||||||
|
# but less user friendly.
|
||||||
|
#
|
||||||
|
|
||||||
|
autoload -Uz is-at-least
|
||||||
|
|
||||||
|
function omz_diagnostic_dump() {
|
||||||
|
emulate -L zsh
|
||||||
|
|
||||||
|
builtin echo "Generating diagnostic dump; please be patient..."
|
||||||
|
|
||||||
|
local thisfcn=omz_diagnostic_dump
|
||||||
|
local -A opts
|
||||||
|
local opt_verbose opt_noverbose opt_outfile
|
||||||
|
local timestamp=$(date +%Y%m%d-%H%M%S)
|
||||||
|
local outfile=omz_diagdump_$timestamp.txt
|
||||||
|
builtin zparseopts -A opts -D -- "v+=opt_verbose" "V+=opt_noverbose"
|
||||||
|
local verbose n_verbose=${#opt_verbose} n_noverbose=${#opt_noverbose}
|
||||||
|
(( verbose = 1 + n_verbose - n_noverbose ))
|
||||||
|
|
||||||
|
if [[ ${#*} > 0 ]]; then
|
||||||
|
opt_outfile=$1
|
||||||
|
fi
|
||||||
|
if [[ ${#*} > 1 ]]; then
|
||||||
|
builtin echo "$thisfcn: error: too many arguments" >&2
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
if [[ -n "$opt_outfile" ]]; then
|
||||||
|
outfile="$opt_outfile"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Always write directly to a file so terminal escape sequences are
|
||||||
|
# captured cleanly
|
||||||
|
_omz_diag_dump_one_big_text &> "$outfile"
|
||||||
|
if [[ $? != 0 ]]; then
|
||||||
|
builtin echo "$thisfcn: error while creating diagnostic dump; see $outfile for details"
|
||||||
|
fi
|
||||||
|
|
||||||
|
builtin echo
|
||||||
|
builtin echo Diagnostic dump file created at: "$outfile"
|
||||||
|
builtin echo
|
||||||
|
builtin echo To share this with OMZ developers, post it as a gist on GitHub
|
||||||
|
builtin echo at "https://gist.github.com" and share the link to the gist.
|
||||||
|
builtin echo
|
||||||
|
builtin echo "WARNING: This dump file contains all your zsh and omz configuration files,"
|
||||||
|
builtin echo "so don't share it publicly if there's sensitive information in them."
|
||||||
|
builtin echo
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
function _omz_diag_dump_one_big_text() {
|
||||||
|
local program programs progfile md5
|
||||||
|
|
||||||
|
builtin echo oh-my-zsh diagnostic dump
|
||||||
|
builtin echo
|
||||||
|
builtin echo $outfile
|
||||||
|
builtin echo
|
||||||
|
|
||||||
|
# Basic system and zsh information
|
||||||
|
command date
|
||||||
|
command uname -a
|
||||||
|
builtin echo OSTYPE=$OSTYPE
|
||||||
|
builtin echo ZSH_VERSION=$ZSH_VERSION
|
||||||
|
builtin echo User: $USERNAME
|
||||||
|
builtin echo umask: $(umask)
|
||||||
|
builtin echo
|
||||||
|
_omz_diag_dump_os_specific_version
|
||||||
|
builtin echo
|
||||||
|
|
||||||
|
# Installed programs
|
||||||
|
programs=(sh zsh ksh bash sed cat grep ls find git posh)
|
||||||
|
local progfile="" extra_str="" sha_str=""
|
||||||
|
for program in $programs; do
|
||||||
|
extra_str="" sha_str=""
|
||||||
|
progfile=$(builtin which $program)
|
||||||
|
if [[ $? == 0 ]]; then
|
||||||
|
if [[ -e $progfile ]]; then
|
||||||
|
if builtin whence shasum &>/dev/null; then
|
||||||
|
sha_str=($(command shasum $progfile))
|
||||||
|
sha_str=$sha_str[1]
|
||||||
|
extra_str+=" SHA $sha_str"
|
||||||
|
fi
|
||||||
|
if [[ -h "$progfile" ]]; then
|
||||||
|
extra_str+=" ( -> ${progfile:A} )"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
builtin printf '%-9s %-20s %s\n' "$program is" "$progfile" "$extra_str"
|
||||||
|
else
|
||||||
|
builtin echo "$program: not found"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
builtin echo
|
||||||
|
builtin echo Command Versions:
|
||||||
|
builtin echo "zsh: $(zsh --version)"
|
||||||
|
builtin echo "this zsh session: $ZSH_VERSION"
|
||||||
|
builtin echo "bash: $(bash --version | command grep bash)"
|
||||||
|
builtin echo "git: $(git --version)"
|
||||||
|
builtin echo "grep: $(grep --version)"
|
||||||
|
builtin echo
|
||||||
|
|
||||||
|
# Core command definitions
|
||||||
|
_omz_diag_dump_check_core_commands || return 1
|
||||||
|
builtin echo
|
||||||
|
|
||||||
|
# ZSH Process state
|
||||||
|
builtin echo Process state:
|
||||||
|
builtin echo pwd: $PWD
|
||||||
|
if builtin whence pstree &>/dev/null; then
|
||||||
|
builtin echo Process tree for this shell:
|
||||||
|
pstree -p $$
|
||||||
|
else
|
||||||
|
ps -fT
|
||||||
|
fi
|
||||||
|
builtin set | command grep -a '^\(ZSH\|plugins\|TERM\|LC_\|LANG\|precmd\|chpwd\|preexec\|FPATH\|TTY\|DISPLAY\|PATH\)\|OMZ'
|
||||||
|
builtin echo
|
||||||
|
#TODO: Should this include `env` instead of or in addition to `export`?
|
||||||
|
builtin echo Exported:
|
||||||
|
builtin echo $(builtin export | command sed 's/=.*//')
|
||||||
|
builtin echo
|
||||||
|
builtin echo Locale:
|
||||||
|
command locale
|
||||||
|
builtin echo
|
||||||
|
|
||||||
|
# Zsh installation and configuration
|
||||||
|
builtin echo Zsh configuration:
|
||||||
|
builtin echo setopt: $(builtin setopt)
|
||||||
|
builtin echo
|
||||||
|
builtin echo zstyle:
|
||||||
|
builtin zstyle
|
||||||
|
builtin echo
|
||||||
|
builtin echo 'compaudit output:'
|
||||||
|
compaudit
|
||||||
|
builtin echo
|
||||||
|
builtin echo '$fpath directories:'
|
||||||
|
command ls -lad $fpath
|
||||||
|
builtin echo
|
||||||
|
|
||||||
|
# Oh-my-zsh installation
|
||||||
|
builtin echo oh-my-zsh installation:
|
||||||
|
command ls -ld ~/.z*
|
||||||
|
command ls -ld ~/.oh*
|
||||||
|
builtin echo
|
||||||
|
builtin echo oh-my-zsh git state:
|
||||||
|
(builtin cd $ZSH && builtin echo "HEAD: $(git rev-parse HEAD)" && git remote -v && git status | command grep "[^[:space:]]")
|
||||||
|
if [[ $verbose -ge 1 ]]; then
|
||||||
|
(builtin cd $ZSH && git reflog --date=default | command grep pull)
|
||||||
|
fi
|
||||||
|
builtin echo
|
||||||
|
if [[ -e $ZSH_CUSTOM ]]; then
|
||||||
|
local custom_dir=$ZSH_CUSTOM
|
||||||
|
if [[ -h $custom_dir ]]; then
|
||||||
|
custom_dir=$(builtin cd $custom_dir && pwd -P)
|
||||||
|
fi
|
||||||
|
builtin echo "oh-my-zsh custom dir:"
|
||||||
|
builtin echo " $ZSH_CUSTOM ($custom_dir)"
|
||||||
|
(builtin cd ${custom_dir:h} && command find ${custom_dir:t} -name .git -prune -o -print)
|
||||||
|
builtin echo
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Key binding and terminal info
|
||||||
|
if [[ $verbose -ge 1 ]]; then
|
||||||
|
builtin echo "bindkey:"
|
||||||
|
builtin bindkey
|
||||||
|
builtin echo
|
||||||
|
builtin echo "infocmp:"
|
||||||
|
command infocmp -L
|
||||||
|
builtin echo
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Configuration file info
|
||||||
|
local zdotdir=${ZDOTDIR:-$HOME}
|
||||||
|
builtin echo "Zsh configuration files:"
|
||||||
|
local cfgfile cfgfiles
|
||||||
|
# Some files for bash that zsh does not use are intentionally included
|
||||||
|
# to help with diagnosing behavior differences between bash and zsh
|
||||||
|
cfgfiles=( /etc/zshenv /etc/zprofile /etc/zshrc /etc/zlogin /etc/zlogout
|
||||||
|
$zdotdir/.zshenv $zdotdir/.zprofile $zdotdir/.zshrc $zdotdir/.zlogin $zdotdir/.zlogout
|
||||||
|
~/.zsh.pre-oh-my-zsh
|
||||||
|
/etc/bashrc /etc/profile ~/.bashrc ~/.profile ~/.bash_profile ~/.bash_logout )
|
||||||
|
command ls -lad $cfgfiles 2>&1
|
||||||
|
builtin echo
|
||||||
|
if [[ $verbose -ge 1 ]]; then
|
||||||
|
for cfgfile in $cfgfiles; do
|
||||||
|
_omz_diag_dump_echo_file_w_header $cfgfile
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
builtin echo
|
||||||
|
builtin echo "Zsh compdump files:"
|
||||||
|
local dumpfile dumpfiles
|
||||||
|
command ls -lad $zdotdir/.zcompdump*
|
||||||
|
dumpfiles=( $zdotdir/.zcompdump*(N) )
|
||||||
|
if [[ $verbose -ge 2 ]]; then
|
||||||
|
for dumpfile in $dumpfiles; do
|
||||||
|
_omz_diag_dump_echo_file_w_header $dumpfile
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
function _omz_diag_dump_check_core_commands() {
|
||||||
|
builtin echo "Core command check:"
|
||||||
|
local redefined name builtins externals reserved_words
|
||||||
|
redefined=()
|
||||||
|
# All the zsh non-module builtin commands
|
||||||
|
# These are taken from the zsh reference manual for 5.0.2
|
||||||
|
# Commands from modules should not be included.
|
||||||
|
# (For back-compatibility, if any of these are newish, they should be removed,
|
||||||
|
# or at least made conditional on the version of the current running zsh.)
|
||||||
|
# "history" is also excluded because OMZ is known to redefine that
|
||||||
|
reserved_words=( do done esac then elif else fi for case if while function
|
||||||
|
repeat time until select coproc nocorrect foreach end '!' '[[' '{' '}'
|
||||||
|
)
|
||||||
|
builtins=( alias autoload bg bindkey break builtin bye cd chdir command
|
||||||
|
comparguments compcall compctl compdescribe compfiles compgroups compquote comptags
|
||||||
|
comptry compvalues continue dirs disable disown echo echotc echoti emulate
|
||||||
|
enable eval exec exit false fc fg functions getln getopts hash
|
||||||
|
jobs kill let limit log logout noglob popd print printf
|
||||||
|
pushd pushln pwd r read rehash return sched set setopt shift
|
||||||
|
source suspend test times trap true ttyctl type ulimit umask unalias
|
||||||
|
unfunction unhash unlimit unset unsetopt vared wait whence where which zcompile
|
||||||
|
zle zmodload zparseopts zregexparse zstyle )
|
||||||
|
if is-at-least 5.1; then
|
||||||
|
reserved_words+=( declare export integer float local readonly typeset )
|
||||||
|
else
|
||||||
|
builtins+=( declare export integer float local readonly typeset )
|
||||||
|
fi
|
||||||
|
builtins_fatal=( builtin command local )
|
||||||
|
externals=( zsh )
|
||||||
|
for name in $reserved_words; do
|
||||||
|
if [[ $(builtin whence -w $name) != "$name: reserved" ]]; then
|
||||||
|
builtin echo "reserved word '$name' has been redefined"
|
||||||
|
builtin which $name
|
||||||
|
redefined+=$name
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
for name in $builtins; do
|
||||||
|
if [[ $(builtin whence -w $name) != "$name: builtin" ]]; then
|
||||||
|
builtin echo "builtin '$name' has been redefined"
|
||||||
|
builtin which $name
|
||||||
|
redefined+=$name
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
for name in $externals; do
|
||||||
|
if [[ $(builtin whence -w $name) != "$name: command" ]]; then
|
||||||
|
builtin echo "command '$name' has been redefined"
|
||||||
|
builtin which $name
|
||||||
|
redefined+=$name
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
if [[ -n "$redefined" ]]; then
|
||||||
|
builtin echo "SOME CORE COMMANDS HAVE BEEN REDEFINED: $redefined"
|
||||||
|
else
|
||||||
|
builtin echo "All core commands are defined normally"
|
||||||
|
fi
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
function _omz_diag_dump_echo_file_w_header() {
|
||||||
|
local file=$1
|
||||||
|
if [[ ( -f $file || -h $file ) ]]; then
|
||||||
|
builtin echo "========== $file =========="
|
||||||
|
if [[ -h $file ]]; then
|
||||||
|
builtin echo "========== ( => ${file:A} ) =========="
|
||||||
|
fi
|
||||||
|
command cat $file
|
||||||
|
builtin echo "========== end $file =========="
|
||||||
|
builtin echo
|
||||||
|
elif [[ -d $file ]]; then
|
||||||
|
builtin echo "File '$file' is a directory"
|
||||||
|
elif [[ ! -e $file ]]; then
|
||||||
|
builtin echo "File '$file' does not exist"
|
||||||
|
else
|
||||||
|
command ls -lad "$file"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
function _omz_diag_dump_os_specific_version() {
|
||||||
|
local osname osver version_file version_files
|
||||||
|
case "$OSTYPE" in
|
||||||
|
darwin*)
|
||||||
|
osname=$(command sw_vers -productName)
|
||||||
|
osver=$(command sw_vers -productVersion)
|
||||||
|
builtin echo "OS Version: $osname $osver build $(sw_vers -buildVersion)"
|
||||||
|
;;
|
||||||
|
cygwin)
|
||||||
|
command systeminfo | command head -n 4 | command tail -n 2
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
if builtin which lsb_release >/dev/null; then
|
||||||
|
builtin echo "OS Release: $(command lsb_release -s -d)"
|
||||||
|
fi
|
||||||
|
|
||||||
|
version_files=( /etc/*-release(N) /etc/*-version(N) /etc/*_version(N) )
|
||||||
|
for version_file in $version_files; do
|
||||||
|
builtin echo "$version_file:"
|
||||||
|
command cat "$version_file"
|
||||||
|
builtin echo
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
+1
-1
@@ -231,7 +231,7 @@ function omz_urlencode() {
|
|||||||
url_str+="$byte"
|
url_str+="$byte"
|
||||||
else
|
else
|
||||||
ord=$(( [##16] #byte ))
|
ord=$(( [##16] #byte ))
|
||||||
url_str+="%${(l:2::0:)ord}"
|
url_str+="%$ord"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|||||||
@@ -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} )
|
||||||
|
|||||||
+4
-11
@@ -154,23 +154,16 @@ esac
|
|||||||
# the host name to disambiguate local vs. remote paths.
|
# the host name to disambiguate local vs. remote paths.
|
||||||
function omz_termsupport_cwd {
|
function omz_termsupport_cwd {
|
||||||
setopt localoptions unset
|
setopt localoptions unset
|
||||||
# Percent-encode the host and path names. Encoding forks a subshell each,
|
# Percent-encode the host and path names.
|
||||||
# so keep the result and only redo it when its inputs change.
|
|
||||||
local cache_key="$HOST:$PWD:${langinfo[CODESET]}:${KONSOLE_PROFILE_NAME:+1}:${KONSOLE_DBUS_SESSION:+1}"
|
|
||||||
if [[ "$_omz_termsupport_cwd_key" != "$cache_key" ]]; then
|
|
||||||
local URL_HOST URL_PATH
|
local URL_HOST URL_PATH
|
||||||
URL_HOST="$(omz_urlencode -P "$HOST")" || return 1
|
URL_HOST="$(omz_urlencode -P $HOST)" || return 1
|
||||||
URL_PATH="$(omz_urlencode -P "$PWD")" || return 1
|
URL_PATH="$(omz_urlencode -P $PWD)" || return 1
|
||||||
|
|
||||||
# Konsole errors if the HOST is provided
|
# Konsole errors if the HOST is provided
|
||||||
[[ -z "$KONSOLE_PROFILE_NAME" && -z "$KONSOLE_DBUS_SESSION" ]] || URL_HOST=""
|
[[ -z "$KONSOLE_PROFILE_NAME" && -z "$KONSOLE_DBUS_SESSION" ]] || URL_HOST=""
|
||||||
|
|
||||||
typeset -g _omz_termsupport_cwd_key="$cache_key"
|
|
||||||
typeset -g _omz_termsupport_cwd_url="file://${URL_HOST}${URL_PATH}"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# common control sequence (OSC 7) to set current host and path
|
# common control sequence (OSC 7) to set current host and path
|
||||||
printf "\e]7;%s\e\\" "$_omz_termsupport_cwd_url"
|
printf "\e]7;file://%s%s\e\\" "${URL_HOST}" "${URL_PATH}"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Use a precmd hook instead of a chpwd hook to avoid contaminating output
|
# Use a precmd hook instead of a chpwd hook to avoid contaminating output
|
||||||
|
|||||||
+11
-42
@@ -38,47 +38,16 @@
|
|||||||
# due to malicious input as a consequence of CVE-2021-45444, which affects
|
# due to malicious input as a consequence of CVE-2021-45444, which affects
|
||||||
# zsh versions from 5.0.3 to 5.8.
|
# zsh versions from 5.0.3 to 5.8.
|
||||||
#
|
#
|
||||||
# The patch is applied when VCS_INFO_formats is first called, since loading
|
autoload -Uz +X regexp-replace VCS_INFO_formats 2>/dev/null || return 0
|
||||||
# and patching it on every startup costs time in shells that never use
|
|
||||||
# vcs_info. `autoload` doesn't replace an already defined function, so this
|
|
||||||
# wrapper survives a later `autoload -Uz vcs_info` in a theme or .zshrc, and
|
|
||||||
# vcs_info's own `autoload -Uz VCS_INFO_formats`.
|
|
||||||
function _omz_patch_vcs_info_formats {
|
|
||||||
local formatter
|
|
||||||
if (( $# )); then
|
|
||||||
formatter="$1"
|
|
||||||
else
|
|
||||||
# Load in a subshell so the wrapper stays installed if loading fails.
|
|
||||||
formatter="$(
|
|
||||||
unfunction VCS_INFO_formats 2>/dev/null
|
|
||||||
autoload -Uz +X VCS_INFO_formats 2>/dev/null || return 1
|
|
||||||
print -r -- "$functions[VCS_INFO_formats]"
|
|
||||||
)" || return 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# We use $tmp here because it's already a local variable in VCS_INFO_formats.
|
# We use $tmp here because it's already a local variable in VCS_INFO_formats
|
||||||
local patch='for tmp (base base-name branch misc revision subdir) hook_com[$tmp]="${hook_com[$tmp]//\%/%%}"'
|
typeset PATCH='for tmp (base base-name branch misc revision subdir) hook_com[$tmp]="${hook_com[$tmp]//\%/%%}"'
|
||||||
local patch_id=vcs_info-patch-9b9840f2-91e5-4471-af84-9e9a0dc68c1b
|
# Unique string to avoid reapplying the patch if this code gets called twice
|
||||||
local post_backend="VCS_INFO_hook 'post-backend'"
|
typeset PATCH_ID=vcs_info-patch-9b9840f2-91e5-4471-af84-9e9a0dc68c1b
|
||||||
if [[ $formatter != *"$patch_id"* ]]; then
|
# Only patch the VCS_INFO_formats function if not already patched
|
||||||
[[ $formatter == *"$post_backend"* ]] || return 1
|
if [[ "$functions[VCS_INFO_formats]" != *$PATCH_ID* ]]; then
|
||||||
local replacement=": $patch_id; $patch; $post_backend"
|
regexp-replace 'functions[VCS_INFO_formats]' \
|
||||||
formatter="${formatter//"$post_backend"/$replacement}"
|
"VCS_INFO_hook 'post-backend'" \
|
||||||
fi
|
': ${PATCH_ID}; ${PATCH}; ${MATCH}'
|
||||||
|
|
||||||
[[ $formatter != "$functions[VCS_INFO_formats]" ]] || return 0
|
|
||||||
# Assigning to functions reparses the body. Preserve autoload -U behavior.
|
|
||||||
setopt localoptions noaliases
|
|
||||||
functions[VCS_INFO_formats]="$formatter"
|
|
||||||
}
|
|
||||||
|
|
||||||
# An autoload stub counts as not loaded yet, so it gets the wrapper too.
|
|
||||||
if (( $+functions[VCS_INFO_formats] )) && [[ $functions[VCS_INFO_formats] != 'builtin autoload -X'* ]]; then
|
|
||||||
# A custom formatter may lack the stock hook call.
|
|
||||||
_omz_patch_vcs_info_formats "$functions[VCS_INFO_formats]" || true
|
|
||||||
else
|
|
||||||
function VCS_INFO_formats {
|
|
||||||
_omz_patch_vcs_info_formats || return 1
|
|
||||||
VCS_INFO_formats "$@"
|
|
||||||
}
|
|
||||||
fi
|
fi
|
||||||
|
unset PATCH PATCH_ID
|
||||||
+1
-1
@@ -128,7 +128,7 @@ fi
|
|||||||
|
|
||||||
# Save the location of the current completion dump file.
|
# Save the location of the current completion dump file.
|
||||||
if [[ -z "$ZSH_COMPDUMP" ]]; then
|
if [[ -z "$ZSH_COMPDUMP" ]]; then
|
||||||
ZSH_COMPDUMP="${ZSH_CACHE_DIR}/.zcompdump-${SHORT_HOST}-${ZSH_VERSION}"
|
ZSH_COMPDUMP="${ZDOTDIR:-$HOME}/.zcompdump-${SHORT_HOST}-${ZSH_VERSION}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Resolve the commit $ZSH is checked out at into $REPLY by reading the git
|
# Resolve the commit $ZSH is checked out at into $REPLY by reading the git
|
||||||
|
|||||||
@@ -58,8 +58,6 @@ Running the shortest `gs` shell alias that it found:
|
|||||||
|
|
||||||

|

|
||||||
|
|
||||||
It also looks through aliases you type, suggesting only ones that cover more of the command. With the kubectl plugin, `k get pods` suggests `kgp`, while `kgp` on its own suggests nothing.
|
|
||||||
|
|
||||||
|
|
||||||
### Options
|
### Options
|
||||||
|
|
||||||
|
|||||||
@@ -65,20 +65,9 @@ alias-finder() {
|
|||||||
|
|
||||||
preexec_alias-finder() {
|
preexec_alias-finder() {
|
||||||
# TODO: Remove backward compatibility (other than zstyle form)
|
# TODO: Remove backward compatibility (other than zstyle form)
|
||||||
zstyle -t ':omz:plugins:alias-finder' autoload || [[ $ZSH_ALIAS_FINDER_AUTOMATIC = true ]] || return
|
zstyle -t ':omz:plugins:alias-finder' autoload && alias-finder $1 || if [[ $ZSH_ALIAS_FINDER_AUTOMATIC = true ]]; then
|
||||||
|
alias-finder $1
|
||||||
# $3 has aliases expanded, so `k get pods` can suggest `kgp`
|
|
||||||
local -a words=(${(z)1}) found=(${(f)"$(alias-finder $3)"}) keep
|
|
||||||
local used=${aliases[$words[1]]} line
|
|
||||||
|
|
||||||
# If an alias was typed, only suggest aliases that cover more of the command
|
|
||||||
if [[ -n "$used" ]]; then
|
|
||||||
for line in $found; do
|
|
||||||
(( ${#${(Q)line#*=}} > ${#used} )) && keep+=("$line")
|
|
||||||
done
|
|
||||||
found=($keep)
|
|
||||||
fi
|
fi
|
||||||
(( $#found )) && print -rl -- $found
|
|
||||||
}
|
}
|
||||||
|
|
||||||
autoload -U add-zsh-hook
|
autoload -U add-zsh-hook
|
||||||
|
|||||||
@@ -103,34 +103,10 @@ upgrades were available. Use `pacman -Que` instead.
|
|||||||
| parep | `pacaur -Si` | Display information about a package in the repositories |
|
| parep | `pacaur -Si` | Display information about a package in the repositories |
|
||||||
| pareps | `pacaur -Ss` | Search for packages in the repositories |
|
| pareps | `pacaur -Ss` | Search for packages in the repositories |
|
||||||
| paupd | `pacaur -Sy` | Update and refresh local package, ABS and AUR databases |
|
| paupd | `pacaur -Sy` | Update and refresh local package, ABS and AUR databases |
|
||||||
| paupg | `pacaur -Syu` | Sync with repositories before upgrading all packages (from AUR too) |
|
| paupg | `pacaur -Syua` | Sync with repositories before upgrading all packages (from AUR too) |
|
||||||
| pasu | `pacaur -Syu --noconfirm` | Same as `paupg`, but without confirmation |
|
| pasu | `pacaur -Syua --no-confirm` | Same as `paupg`, but without confirmation |
|
||||||
| upgrade[¹](#f1) | `pacaur -Syu` | Sync with repositories before upgrading packages |
|
| upgrade[¹](#f1) | `pacaur -Syu` | Sync with repositories before upgrading packages |
|
||||||
|
|
||||||
#### Paru
|
|
||||||
|
|
||||||
| Alias | Command | Description |
|
|
||||||
|---------|--------------------------------|-------------------------------------------------------------------|
|
|
||||||
| puclean | `paru -Sc` | Clean out old and unused caches and packages |
|
|
||||||
| puclr | `paru -Scc` | Remove all files from the cache |
|
|
||||||
| pufiles | `paru -F` | Search the files database for packages that contain a file |
|
|
||||||
| puin | `paru -S` | Install packages from the repositories |
|
|
||||||
| puins | `paru -U` | Install a package from a local file |
|
|
||||||
| puinsd | `paru -S --asdeps` | Install packages as dependencies of another package |
|
|
||||||
| puloc | `paru -Qi` | Display information about a package in the local database |
|
|
||||||
| pulocs | `paru -Qs` | Search for packages in the local database |
|
|
||||||
| pulst | `paru -Qe` | List installed packages including from AUR (tagged as "local") |
|
|
||||||
| pumir | `paru -Syy` | Force refresh of all package lists after updating mirrorlist |
|
|
||||||
| puorph | `paru -Qtd` | List orphaned packages |
|
|
||||||
| pure | `paru -R` | Remove packages, keeping its settings and dependencies |
|
|
||||||
| purem | `paru -Rns` | Remove packages, including its settings and unneeded dependencies |
|
|
||||||
| purep | `paru -Si` | Display information about a package in the repositories |
|
|
||||||
| pureps | `paru -Ss` | Search for packages in the repositories |
|
|
||||||
| puupd | `paru -Sy` | Update and refresh local package, ABS and AUR databases |
|
|
||||||
| puupg | `paru -Syu` | Sync with repositories before upgrading packages |
|
|
||||||
| pusu | `paru -Syu --noconfirm` | Same as `puupg`, but without confirmation |
|
|
||||||
| upgrade[¹](#f1) | `paru -Syu` | Sync with repositories before upgrading packages |
|
|
||||||
|
|
||||||
#### Trizen
|
#### Trizen
|
||||||
|
|
||||||
| Alias | Command | Description |
|
| Alias | Command | Description |
|
||||||
@@ -152,7 +128,7 @@ upgrades were available. Use `pacman -Que` instead.
|
|||||||
| trreps | `trizen -Ss` | Search for packages in the repositories |
|
| trreps | `trizen -Ss` | Search for packages in the repositories |
|
||||||
| trupd | `trizen -Sy` | Update and refresh local package, ABS and AUR databases |
|
| trupd | `trizen -Sy` | Update and refresh local package, ABS and AUR databases |
|
||||||
| trupg | `trizen -Syua` | Sync with repositories before upgrading all packages (from AUR too) |
|
| trupg | `trizen -Syua` | Sync with repositories before upgrading all packages (from AUR too) |
|
||||||
| trsu | `trizen -Syua --noconfirm` | Same as `trupg`, but without confirmation |
|
| trsu | `trizen -Syua --no-confirm` | Same as `trupg`, but without confirmation |
|
||||||
| upgrade[¹](#f1) | `trizen -Syu` | Sync with repositories before upgrading packages |
|
| upgrade[¹](#f1) | `trizen -Syu` | Sync with repositories before upgrading packages |
|
||||||
|
|
||||||
#### Yay
|
#### Yay
|
||||||
@@ -176,7 +152,7 @@ upgrades were available. Use `pacman -Que` instead.
|
|||||||
| yareps | `yay -Ss` | Search for packages in the repositories |
|
| yareps | `yay -Ss` | Search for packages in the repositories |
|
||||||
| yaupd | `yay -Sy` | Update and refresh local package, ABS and AUR databases |
|
| yaupd | `yay -Sy` | Update and refresh local package, ABS and AUR databases |
|
||||||
| yaupg | `yay -Syu` | Sync with repositories before upgrading packages |
|
| yaupg | `yay -Syu` | Sync with repositories before upgrading packages |
|
||||||
| yasu | `yay -Syu --noconfirm` | Same as `yaupg`, but without confirmation |
|
| yasu | `yay -Syu --no-confirm` | Same as `yaupg`, but without confirmation |
|
||||||
| upgrade[¹](#f1) | `yay -Syu` | Sync with repositories before upgrading packages |
|
| upgrade[¹](#f1) | `yay -Syu` | Sync with repositories before upgrading packages |
|
||||||
|
|
||||||
---
|
---
|
||||||
@@ -187,10 +163,9 @@ whether the package manager is installed, checked in the following order:
|
|||||||
|
|
||||||
1. `yay`
|
1. `yay`
|
||||||
2. `trizen`
|
2. `trizen`
|
||||||
3. `paru`
|
3. `pacaur`
|
||||||
4. `pacaur`
|
4. `aura`
|
||||||
5. `aura`
|
5. `pacman`
|
||||||
6. `pacman`
|
|
||||||
|
|
||||||
## Contributors
|
## Contributors
|
||||||
|
|
||||||
@@ -207,4 +182,3 @@ whether the package manager is installed, checked in the following order:
|
|||||||
- Jeff M. Hubbard - jeffmhubbard@gmail.com
|
- Jeff M. Hubbard - jeffmhubbard@gmail.com
|
||||||
- K. Harishankar(harishnkr) - hari2menon1234@gmail.com
|
- K. Harishankar(harishnkr) - hari2menon1234@gmail.com
|
||||||
- WH-2099 - wh2099@outlook.com
|
- WH-2099 - wh2099@outlook.com
|
||||||
- Boris Frenkel - fobos2k@gmail.com
|
|
||||||
@@ -134,27 +134,6 @@ if (( $+commands[pacaur] )); then
|
|||||||
alias paupd="pacaur -Sy"
|
alias paupd="pacaur -Sy"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if (( $+commands[paru] )); then
|
|
||||||
alias puclean='paru -Sc'
|
|
||||||
alias puclr='paru -Scc'
|
|
||||||
alias pufiles='paru -F'
|
|
||||||
alias puin='paru -S'
|
|
||||||
alias puins='paru -U'
|
|
||||||
alias puinsd='paru -S --asdeps'
|
|
||||||
alias puloc='paru -Qi'
|
|
||||||
alias pulocs='paru -Qs'
|
|
||||||
alias pulst='paru -Qe'
|
|
||||||
alias pumir='paru -Syy'
|
|
||||||
alias puorph='paru -Qtd'
|
|
||||||
alias pure='paru -R'
|
|
||||||
alias purem='paru -Rns'
|
|
||||||
alias purep='paru -Si'
|
|
||||||
alias pureps='paru -Ss'
|
|
||||||
alias puupd='paru -Sy'
|
|
||||||
alias puupg='paru -Syu'
|
|
||||||
alias pusu='paru -Syu --noconfirm'
|
|
||||||
fi
|
|
||||||
|
|
||||||
if (( $+commands[trizen] )); then
|
if (( $+commands[trizen] )); then
|
||||||
alias trconf='trizen -C'
|
alias trconf='trizen -C'
|
||||||
alias trupg='trizen -Syua'
|
alias trupg='trizen -Syua'
|
||||||
@@ -215,8 +194,6 @@ function upgrade() {
|
|||||||
yay -Su
|
yay -Su
|
||||||
elif (( $+commands[trizen] )); then
|
elif (( $+commands[trizen] )); then
|
||||||
trizen -Su
|
trizen -Su
|
||||||
elif (( $+commands[paru] )); then
|
|
||||||
paru -Su
|
|
||||||
elif (( $+commands[pacaur] )); then
|
elif (( $+commands[pacaur] )); then
|
||||||
pacaur -Su
|
pacaur -Su
|
||||||
elif (( $+commands[aura] )); then
|
elif (( $+commands[aura] )); then
|
||||||
|
|||||||
@@ -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. |
|
||||||
|
|||||||
@@ -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'
|
||||||
|
|||||||
@@ -49,8 +49,6 @@ plugins=(... extract)
|
|||||||
| `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 |
|
||||||
|
|||||||
@@ -97,11 +97,6 @@ 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" ;;
|
||||||
|
|||||||
@@ -1,30 +1,7 @@
|
|||||||
## Fossil Plugin
|
## Fossil Plugin
|
||||||
|
|
||||||
This plugin adds completion support and prompt for fossil repositories.
|
This plugin adds completion support and prompt for fossil repositories.
|
||||||
|
The prompt will display the current branch and status been dirty or clean.
|
||||||
To use it, add `fossil` to the plugins array in your .zshrc file:
|
|
||||||
|
|
||||||
```zsh
|
|
||||||
plugins=(... fossil)
|
|
||||||
``
|
|
||||||
|
|
||||||
This plugin provides a prompt function named `fossil_prompt_info` that
|
|
||||||
will display the current branch and if there are changes (dirty) or not (clean).
|
|
||||||
|
|
||||||
### Prompt segments
|
|
||||||
|
|
||||||
These variables control how the prompt function looks:
|
|
||||||
|
|
||||||
```
|
|
||||||
ZSH_THEME_FOSSIL_PROMPT_PREFIX="%{$fg_bold[blue]%}fossil:(%{$fg_bold[red]%}"
|
|
||||||
ZSH_THEME_FOSSIL_PROMPT_SUFFIX="%{$fg_bold[blue]%})"
|
|
||||||
ZSH_THEME_FOSSIL_PROMPT_DIRTY="%{$fg_bold[red]%}✖"
|
|
||||||
ZSH_THEME_FOSSIL_PROMPT_CLEAN="%{$fg_bold[green]%}✔"
|
|
||||||
```
|
|
||||||
|
|
||||||
You can override their values in your .zshrc file, anywhere after the
|
|
||||||
`source $ZSH/oh-my-zsh.sh` line.
|
|
||||||
|
|
||||||
### CONTRIBUTOR
|
### CONTRIBUTOR
|
||||||
|
- Jefferson González ([jgmdev](https://github.com/jgmdev))
|
||||||
- Jefferson González ([jgmdev](https://github.com/jgmdev))
|
|
||||||
@@ -7,10 +7,10 @@ ZSH_THEME_FOSSIL_PROMPT_PREFIX="%{$fg_bold[blue]%}fossil:(%{$fg_bold[red]%}"
|
|||||||
ZSH_THEME_FOSSIL_PROMPT_SUFFIX="%{$fg_bold[blue]%})"
|
ZSH_THEME_FOSSIL_PROMPT_SUFFIX="%{$fg_bold[blue]%})"
|
||||||
|
|
||||||
# Text to display if the branch is dirty
|
# Text to display if the branch is dirty
|
||||||
ZSH_THEME_FOSSIL_PROMPT_DIRTY="%{$fg_bold[red]%}✖"
|
ZSH_THEME_FOSSIL_PROMPT_DIRTY=" %{$fg_bold[red]%}✖"
|
||||||
|
|
||||||
# Text to display if the branch is clean
|
# Text to display if the branch is clean
|
||||||
ZSH_THEME_FOSSIL_PROMPT_CLEAN="%{$fg_bold[green]%}✔"
|
ZSH_THEME_FOSSIL_PROMPT_CLEAN=" %{$fg_bold[green]%}✔"
|
||||||
|
|
||||||
function fossil_prompt_info() {
|
function fossil_prompt_info() {
|
||||||
local branch=$(fossil branch current 2>&1)
|
local branch=$(fossil branch current 2>&1)
|
||||||
@@ -25,35 +25,27 @@ function fossil_prompt_info() {
|
|||||||
dirty="$ZSH_THEME_FOSSIL_PROMPT_DIRTY"
|
dirty="$ZSH_THEME_FOSSIL_PROMPT_DIRTY"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
printf ' %s%s%s%s%s' \
|
printf '%s %s %s %s %s' \
|
||||||
"$ZSH_THEME_FOSSIL_PROMPT_PREFIX" \
|
"$ZSH_THEME_FOSSIL_PROMPT_PREFIX" \
|
||||||
"${branch:gs/%/%%}" \
|
"${branch:gs/%/%%}" \
|
||||||
"$dirty" \
|
|
||||||
"$ZSH_THEME_FOSSIL_PROMPT_SUFFIX" \
|
"$ZSH_THEME_FOSSIL_PROMPT_SUFFIX" \
|
||||||
|
"$dirty" \
|
||||||
"%{$reset_color%}"
|
"%{$reset_color%}"
|
||||||
}
|
}
|
||||||
|
|
||||||
function _fossil_prompt () {
|
function _fossil_prompt () {
|
||||||
# Re-check each time, in case the theme rebuilds its prompt in precmd
|
local current=`echo $PROMPT $RPROMPT | grep fossil`
|
||||||
if [ -z "$_FOSSIL_PROMPT" ] || [[ "$PROMPT$RPROMPT" != *fossil_prompt_info* ]]; then
|
|
||||||
# Use substitutions to work out what other plugins and themes have
|
if [ "$_FOSSIL_PROMPT" = "" -o "$current" = "" ]; then
|
||||||
# done ahead of us so we don't duplicate their work.
|
local _prompt=${PROMPT}
|
||||||
#
|
local _rprompt=${RPROMPT}
|
||||||
# If $fossil_prompt_info isn't in the prompt strings already but we
|
|
||||||
# can find $git_prompt_info, put it immediately afterward so that
|
local is_prompt=`echo $PROMPT | grep git`
|
||||||
# one or the other appears in the prompt. We're gambling that you
|
|
||||||
# aren't in a directory that's a checkout for both a Git repo and a
|
if [ "$is_prompt" = "" ]; then
|
||||||
# Fossil repo.
|
RPROMPT="$_rprompt"'$(fossil_prompt_info)'
|
||||||
#
|
else
|
||||||
# Otherwise, add it to the right prompt, as before.
|
PROMPT="$_prompt"'$(fossil_prompt_info) '
|
||||||
if [ "${PROMPT/fossil_prompt_info//}" = "$PROMPT" ]; then
|
|
||||||
PROMPT="${PROMPT/git_prompt_info/git_prompt_info)\$(fossil_prompt_info}"
|
|
||||||
fi
|
|
||||||
if [ "${RPROMPT/fossil_prompt_info//}" = "$RPROMPT" ]; then
|
|
||||||
RPROMPT="${RPROMPT/git_prompt_info/git_prompt_info)\$(fossil_prompt_info}"
|
|
||||||
fi
|
|
||||||
if [[ "$PROMPT$RPROMPT" != *fossil_prompt_info* ]]; then
|
|
||||||
RPROMPT+='$(fossil_prompt_info)'
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
_FOSSIL_PROMPT="1"
|
_FOSSIL_PROMPT="1"
|
||||||
|
|||||||
@@ -18,8 +18,6 @@ plugins=(... git)
|
|||||||
| `g` | `git` |
|
| `g` | `git` |
|
||||||
| `ga` | `git add` |
|
| `ga` | `git add` |
|
||||||
| `gaa` | `git add --all` |
|
| `gaa` | `git add --all` |
|
||||||
| `gan` | `git add --intent-to-add` |
|
|
||||||
| `ganpa` | `git add --intent-to-add . && git add --patch` |
|
|
||||||
| `gapa` | `git add --patch` |
|
| `gapa` | `git add --patch` |
|
||||||
| `gau` | `git add --update` |
|
| `gau` | `git add --update` |
|
||||||
| `gav` | `git add --verbose` |
|
| `gav` | `git add --verbose` |
|
||||||
|
|||||||
@@ -1,34 +1,6 @@
|
|||||||
# Git version checking
|
# Git version checking
|
||||||
autoload -Uz is-at-least
|
autoload -Uz is-at-least
|
||||||
# Running `git version` forks on every startup, so cache the result for a day
|
git_version="${${(As: :)$(git version 2>/dev/null)}[3]}"
|
||||||
# in $ZSH_CACHE_DIR, keyed on the resolved git binary's path and mtime.
|
|
||||||
# Run the fallback outside this function so its locals cannot shadow wrapper variables.
|
|
||||||
() {
|
|
||||||
# Shell overrides and relative PATH entries can make the command hash
|
|
||||||
# differ from the Git that Zsh actually runs.
|
|
||||||
(( $+functions[git] || $+aliases[git] || $+galiases[git] || ${path[(I)(|[^/]*)]} )) && return 1
|
|
||||||
|
|
||||||
local cache="$ZSH_CACHE_DIR/git-version" git_path="${commands[git]:+${commands[git]:A}}" key magic
|
|
||||||
local -a stat lines
|
|
||||||
# Shims and the macOS developer-tool dispatcher can select a different Git.
|
|
||||||
[[ "${git_path:t:r}" = 'git' ]] || return 1
|
|
||||||
[[ "$OSTYPE" == darwin* && "$git_path" = /usr/bin/git ]] && return 1
|
|
||||||
read -r -k 2 -u 0 magic 2>/dev/null < "$git_path" || return 1
|
|
||||||
[[ "$magic" = '#!' ]] && return 1
|
|
||||||
zmodload -F zsh/stat b:zstat && zstat -A stat +mtime -- "$git_path" 2>/dev/null || return 1
|
|
||||||
key="$git_path $stat[1]"
|
|
||||||
|
|
||||||
lines=("$cache"(Nm-1))
|
|
||||||
(( $#lines )) && lines=("${(@f)$(<"$cache")}")
|
|
||||||
if [[ "$lines[1]" = "$key" && "$lines[2]" == <->.<->* ]]; then
|
|
||||||
git_version="$lines[2]"
|
|
||||||
return 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
git_version="${${(As: :)$(git version 2>/dev/null)}[3]}"
|
|
||||||
[[ ! -w "$ZSH_CACHE_DIR" ]] || print -rl -- "$key" "$git_version" >| "$cache"
|
|
||||||
return 0
|
|
||||||
} || git_version="${${(As: :)$(git version 2>/dev/null)}[3]}"
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Functions Current
|
# Functions Current
|
||||||
@@ -144,8 +116,6 @@ alias ggpur='ggu'
|
|||||||
alias g='git'
|
alias g='git'
|
||||||
alias ga='git add'
|
alias ga='git add'
|
||||||
alias gaa='git add --all'
|
alias gaa='git add --all'
|
||||||
alias gan='git add --intent-to-add'
|
|
||||||
alias ganpa='git add --intent-to-add . && git add --patch'
|
|
||||||
alias gapa='git add --patch'
|
alias gapa='git add --patch'
|
||||||
alias gau='git add --update'
|
alias gau='git add --update'
|
||||||
alias gav='git add --verbose'
|
alias gav='git add --verbose'
|
||||||
|
|||||||
@@ -1,91 +0,0 @@
|
|||||||
#!/usr/bin/env zsh
|
|
||||||
|
|
||||||
emulate -LR zsh
|
|
||||||
|
|
||||||
plugin=${1:-${0:A:h:h}/git.plugin.zsh}
|
|
||||||
plugin=${plugin:A}
|
|
||||||
(( $+commands[git] )) || { print -u2 'Git is required for this test'; exit 1; }
|
|
||||||
real_version="${${(As: :)$(command git version)}[3]}"
|
|
||||||
test_dir=$(mktemp -d) || exit 1
|
|
||||||
trap 'command rm -rf -- "$test_dir"' EXIT
|
|
||||||
export ZSH_CACHE_DIR="$test_dir"
|
|
||||||
cache="$ZSH_CACHE_DIR/git-version"
|
|
||||||
|
|
||||||
typeset -i failures=0 tests=0
|
|
||||||
check() {
|
|
||||||
local description=$1
|
|
||||||
shift
|
|
||||||
(( tests++ ))
|
|
||||||
if "$@"; then
|
|
||||||
print -r -- "PASS: $description"
|
|
||||||
else
|
|
||||||
print -u2 -r -- "FAIL: $description"
|
|
||||||
(( failures++ ))
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
# Each source gets a fresh shell scope while sharing the persistent cache.
|
|
||||||
probe() (
|
|
||||||
local mode=$1 expected=$2 version
|
|
||||||
: > "$test_dir/versions"
|
|
||||||
autoload -Uz +X is-at-least
|
|
||||||
functions[_test_is_at_least]=$functions[is-at-least]
|
|
||||||
is-at-least() {
|
|
||||||
print -r -- "$2" >> "$test_dir/versions"
|
|
||||||
_test_is_at_least "$@"
|
|
||||||
}
|
|
||||||
compdef() { :; }
|
|
||||||
case $mode in
|
|
||||||
function) git() { print -r -- "git version $expected"; } ;;
|
|
||||||
alias) alias git="print -r -- 'git version $expected'" ;;
|
|
||||||
esac
|
|
||||||
source "$plugin"
|
|
||||||
local -a versions=("${(@f)$(<"$test_dir/versions")}")
|
|
||||||
(( $#versions == 4 )) || return 1
|
|
||||||
for version in "$versions[@]"; do
|
|
||||||
[[ "$version" == "$expected" ]] || return 1
|
|
||||||
done
|
|
||||||
if [[ "$expected" == 2.5.0 ]]; then
|
|
||||||
[[ "$aliases[gpf]" == 'git push --force-with-lease' \
|
|
||||||
&& "$aliases[gsta]" == 'git stash save' ]] || return 1
|
|
||||||
fi
|
|
||||||
)
|
|
||||||
|
|
||||||
check 'cold load probes the installed Git' probe binary "$real_version"
|
|
||||||
if [[ ! -f "$cache" ]]; then
|
|
||||||
print -u2 'This test requires a native Git executable eligible for caching'
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
key="${${(f)$(<"$cache")}[1]}"
|
|
||||||
|
|
||||||
check 'warm load uses the installed version' probe binary "$real_version"
|
|
||||||
check 'function override bypasses an existing binary cache' probe function 2.5.0
|
|
||||||
check 'alias override bypasses an existing binary cache' probe alias 2.5.0
|
|
||||||
check 'shell overrides do not replace the binary cache' probe binary "$real_version"
|
|
||||||
|
|
||||||
# A different cached version distinguishes a cache hit from a fresh probe.
|
|
||||||
print -rl -- "$key" 2.5.0 > "$cache"
|
|
||||||
check 'valid warm cache avoids a new version probe' probe binary 2.5.0
|
|
||||||
|
|
||||||
print -r -- "$key" > "$cache"
|
|
||||||
check 'missing version line triggers a fresh probe' probe binary "$real_version"
|
|
||||||
print -rl -- "$key" '' > "$cache"
|
|
||||||
check 'empty version line triggers a fresh probe' probe binary "$real_version"
|
|
||||||
print -rl -- "$key" invalid > "$cache"
|
|
||||||
check 'invalid version line triggers a fresh probe' probe binary "$real_version"
|
|
||||||
print -rl -- 'different executable' 2.5.0 > "$cache"
|
|
||||||
check 'different binary key triggers a fresh probe' probe binary "$real_version"
|
|
||||||
|
|
||||||
print -rl -- "$key" 2.5.0 > "$cache"
|
|
||||||
touch -t 200001010000 "$cache"
|
|
||||||
check 'expired cache triggers a fresh probe' probe binary "$real_version"
|
|
||||||
|
|
||||||
rm "$cache"
|
|
||||||
check 'function override works without a cache' probe function 2.5.0
|
|
||||||
check 'function override does not write a cache' test ! -e "$cache"
|
|
||||||
rm -f "$cache"
|
|
||||||
check 'alias override works without a cache' probe alias 2.5.0
|
|
||||||
check 'alias override does not write a cache' test ! -e "$cache"
|
|
||||||
|
|
||||||
print -r -- "$tests tests, $failures failures"
|
|
||||||
(( failures == 0 ))
|
|
||||||
@@ -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
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -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'
|
||||||
|
|||||||
@@ -31,8 +31,6 @@ plugins=(... kubectl)
|
|||||||
| kdelk | `kubectl delete -k` | Delete all resources defined in a kustomization directory |
|
| kdelk | `kubectl delete -k` | Delete all resources defined in a kustomization directory |
|
||||||
| kge | `kubectl get events --sort-by=".lastTimestamp"` | Get events (sorted by timestamp) |
|
| kge | `kubectl get events --sort-by=".lastTimestamp"` | Get events (sorted by timestamp) |
|
||||||
| kgew | `kubectl get events --watch --sort-by=".lastTimestamp"` | Get events and watch as they occur (sorted by timestamp) |
|
| kgew | `kubectl get events --watch --sort-by=".lastTimestamp"` | Get events and watch as they occur (sorted by timestamp) |
|
||||||
| kg | `kubectl get` | Get one or more resources |
|
|
||||||
| kd | `kubectl describe` | Describe one or more resources in detail |
|
|
||||||
| | | **Pod management** |
|
| | | **Pod management** |
|
||||||
| kgp | `kubectl get pods` | List all pods in ps output format |
|
| kgp | `kubectl get pods` | List all pods in ps output format |
|
||||||
| kgpl | `kgp -l` | Get pods by label. Example: `kgpl "app=myapp" -n myns` |
|
| kgpl | `kgp -l` | Get pods by label. Example: `kgpl "app=myapp" -n myns` |
|
||||||
@@ -62,7 +60,6 @@ plugins=(... kubectl)
|
|||||||
| | | **Namespace management** |
|
| | | **Namespace management** |
|
||||||
| kgns | `kubectl get namespaces` | List the current namespaces in a cluster |
|
| kgns | `kubectl get namespaces` | List the current namespaces in a cluster |
|
||||||
| kcn | `kubectl config set-context --current --namespace` | Change current namespace |
|
| kcn | `kubectl config set-context --current --namespace` | Change current namespace |
|
||||||
| kcgetns | `kubectl config view --minify -o jsonpath={.contexts[0].context.namespace}` | Get the current context's namespace |
|
|
||||||
| kens | `kubectl edit namespace` | Edit namespace resource from the default editor |
|
| kens | `kubectl edit namespace` | Edit namespace resource from the default editor |
|
||||||
| kdns | `kubectl describe namespace` | Describe namespace resource in detail |
|
| kdns | `kubectl describe namespace` | Describe namespace resource in detail |
|
||||||
| kdelns | `kubectl delete namespace` | Delete the namespace. WARNING! This deletes everything in the namespace |
|
| kdelns | `kubectl delete namespace` | Delete the namespace. WARNING! This deletes everything in the namespace |
|
||||||
@@ -115,7 +112,6 @@ plugins=(... kubectl)
|
|||||||
| | | **Node management** |
|
| | | **Node management** |
|
||||||
| kgno | `kubectl get nodes` | List the nodes in ps output format |
|
| kgno | `kubectl get nodes` | List the nodes in ps output format |
|
||||||
| kgnosl | `kubectl get nodes --show-labels` | List the nodes in ps output format with labels |
|
| kgnosl | `kubectl get nodes --show-labels` | List the nodes in ps output format with labels |
|
||||||
| kgnow | `kubectl get nodes --watch` | List the nodes, then watch for status changes (e.g. Ready/NotReady, cordoned, added or removed) |
|
|
||||||
| keno | `kubectl edit node` | Edit nodes resource from the default editor |
|
| keno | `kubectl edit node` | Edit nodes resource from the default editor |
|
||||||
| kdno | `kubectl describe node` | Describe node resource in detail |
|
| kdno | `kubectl describe node` | Describe node resource in detail |
|
||||||
| kdelno | `kubectl delete node` | Delete the node |
|
| kdelno | `kubectl delete node` | Delete the node |
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ alias kapk='kubectl apply -k'
|
|||||||
# Drop into an interactive terminal on a container
|
# Drop into an interactive terminal on a container
|
||||||
alias keti='kubectl exec -t -i'
|
alias keti='kubectl exec -t -i'
|
||||||
|
|
||||||
# Manage configuration quickly to switch contexts between local, dev and staging.
|
# Manage configuration quickly to switch contexts between local, dev ad staging.
|
||||||
alias kcuc='kubectl config use-context'
|
alias kcuc='kubectl config use-context'
|
||||||
alias kcsc='kubectl config set-context'
|
alias kcsc='kubectl config set-context'
|
||||||
alias kcdc='kubectl config delete-context'
|
alias kcdc='kubectl config delete-context'
|
||||||
@@ -47,8 +47,6 @@ alias kdelf='kubectl delete -f'
|
|||||||
alias kdelk='kubectl delete -k'
|
alias kdelk='kubectl delete -k'
|
||||||
alias kge='kubectl get events --sort-by=".lastTimestamp"'
|
alias kge='kubectl get events --sort-by=".lastTimestamp"'
|
||||||
alias kgew='kubectl get events --sort-by=".lastTimestamp" --watch'
|
alias kgew='kubectl get events --sort-by=".lastTimestamp" --watch'
|
||||||
alias kg='kubectl get'
|
|
||||||
alias kd='kubectl describe'
|
|
||||||
|
|
||||||
# Pod management.
|
# Pod management.
|
||||||
alias kgp='kubectl get pods'
|
alias kgp='kubectl get pods'
|
||||||
@@ -85,7 +83,6 @@ alias kens='kubectl edit namespace'
|
|||||||
alias kdns='kubectl describe namespace'
|
alias kdns='kubectl describe namespace'
|
||||||
alias kdelns='kubectl delete namespace'
|
alias kdelns='kubectl delete namespace'
|
||||||
alias kcn='kubectl config set-context --current --namespace'
|
alias kcn='kubectl config set-context --current --namespace'
|
||||||
alias kcgetns="kubectl config view --minify -o 'jsonpath={.contexts[0].context.namespace}'"
|
|
||||||
|
|
||||||
# ConfigMap management
|
# ConfigMap management
|
||||||
alias kgcm='kubectl get configmaps'
|
alias kgcm='kubectl get configmaps'
|
||||||
@@ -159,7 +156,6 @@ alias kcp='kubectl cp'
|
|||||||
# Node Management
|
# Node Management
|
||||||
alias kgno='kubectl get nodes'
|
alias kgno='kubectl get nodes'
|
||||||
alias kgnosl='kubectl get nodes --show-labels'
|
alias kgnosl='kubectl get nodes --show-labels'
|
||||||
alias kgnow='kubectl get nodes --watch'
|
|
||||||
alias keno='kubectl edit node'
|
alias keno='kubectl edit node'
|
||||||
alias kdno='kubectl describe node'
|
alias kdno='kubectl describe node'
|
||||||
alias kdelno='kubectl delete node'
|
alias kdelno='kubectl delete node'
|
||||||
|
|||||||
@@ -28,10 +28,10 @@ lsk() {
|
|||||||
# Example
|
# Example
|
||||||
# sqs-send user user.json
|
# sqs-send user user.json
|
||||||
sqs-send(){
|
sqs-send(){
|
||||||
if [ -z "$1" ] || [ -z "$2" ]; then
|
if [ -z "$1" ]; then
|
||||||
echo "Use: sqs-send <queue> <payload>" >&2
|
echo "Use: sqs-send <queue> <payload>"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
curl -X POST "http://localhost:4566/000000000000/$1" -d "Action=SendMessage" -d "MessageBody=$(cat "$2")"
|
curl -X POST "http://localhost:4566/000000000000/$1" -d "Action=SendMessage" -d "MessageBody=$(cat $2)"
|
||||||
}
|
}
|
||||||
+1
-1
@@ -110,7 +110,7 @@ EOF
|
|||||||
echo "\tlaunch|play|pause|stop|rewind|resume|quit"
|
echo "\tlaunch|play|pause|stop|rewind|resume|quit"
|
||||||
echo "\tmute|unmute\tMute or unmute $APP_NAME"
|
echo "\tmute|unmute\tMute or unmute $APP_NAME"
|
||||||
echo "\tnext|previous\tPlay next or previous track"
|
echo "\tnext|previous\tPlay next or previous track"
|
||||||
echo "\tshuf|shuffle [on|off|toggle]\tSet shuffled playback. Default: toggle."
|
echo "\tshuf|shuffle [on|off|toggle]\tSet shuffled playback. Default: toggle. Note: toggle doesn't support the MiniPlayer."
|
||||||
echo "\tvol [0-100|up|down]\tGet or set the volume. 0 to 100 sets the volume. 'up' / 'down' increases / decreases by 10 points. No argument displays current volume."
|
echo "\tvol [0-100|up|down]\tGet or set the volume. 0 to 100 sets the volume. 'up' / 'down' increases / decreases by 10 points. No argument displays current volume."
|
||||||
echo "\tplaying|status\tShow what song is currently playing in Music."
|
echo "\tplaying|status\tShow what song is currently playing in Music."
|
||||||
echo "\tplaylist [playlist name]\t Play specific playlist"
|
echo "\tplaylist [playlist name]\t Play specific playlist"
|
||||||
|
|||||||
@@ -1,16 +0,0 @@
|
|||||||
# Ollama
|
|
||||||
|
|
||||||
This plugin adds completion for [Ollama](https://ollama.com), the tool for running large language models locally.
|
|
||||||
|
|
||||||
To use it, add `ollama` to the plugins array in your zshrc file:
|
|
||||||
|
|
||||||
```zsh
|
|
||||||
plugins=(... ollama)
|
|
||||||
```
|
|
||||||
|
|
||||||
It completes `ollama` subcommands, their flags, and model names (from `ollama list`, or `ollama ps` for `ollama stop`).
|
|
||||||
|
|
||||||
## Credits
|
|
||||||
|
|
||||||
Adapted from [Grégoire Compagnon's gist](https://gist.github.com/obeone/9313811fd61a7cbb843e0001a4434c58)
|
|
||||||
by [Konstantin Gredeskoul](https://github.com/kigster).
|
|
||||||
@@ -1,123 +0,0 @@
|
|||||||
#compdef ollama
|
|
||||||
|
|
||||||
# Based on https://gist.github.com/obeone/9313811fd61a7cbb843e0001a4434c58 by Grégoire Compagnon (@obeone),
|
|
||||||
# adapted for Oh My Zsh by Konstantin Gredeskoul (@kigster)
|
|
||||||
|
|
||||||
# Complete model names from 'ollama list', or running models from 'ollama ps'
|
|
||||||
__ollama_models_from() {
|
|
||||||
local -a models
|
|
||||||
local output="$(ollama $1 2>/dev/null | sed 's/:/\\:/g')" # escape colons for _describe
|
|
||||||
if [[ -z "$output" ]]; then
|
|
||||||
_message "no models available or 'ollama $1' failed"
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
models=("${(@f)$(echo "$output" | awk 'NR>1 {print $1}')}")
|
|
||||||
if [[ ${#models} -eq 0 ]]; then
|
|
||||||
_message "no models found"
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
_describe 'model names' models
|
|
||||||
}
|
|
||||||
_ollama_models() { __ollama_models_from list }
|
|
||||||
_ollama_running_models() { __ollama_models_from ps }
|
|
||||||
|
|
||||||
_ollama() {
|
|
||||||
local -a commands
|
|
||||||
|
|
||||||
_arguments -C \
|
|
||||||
'(- *)'{-v,--version}'[Show version information]' \
|
|
||||||
'1: :->command' \
|
|
||||||
'*:: :->args'
|
|
||||||
|
|
||||||
commands=(
|
|
||||||
'serve:Start ollama'
|
|
||||||
'start:Start ollama (alias for serve)'
|
|
||||||
'create:Create a model'
|
|
||||||
'show:Show information for a model'
|
|
||||||
'run:Run a model'
|
|
||||||
'stop:Stop a running model'
|
|
||||||
'pull:Pull a model from a registry'
|
|
||||||
'push:Push a model to a registry'
|
|
||||||
'signin:Sign in to ollama.com'
|
|
||||||
'signout:Sign out from ollama.com'
|
|
||||||
'login:Sign in to ollama.com (alias for signin)'
|
|
||||||
'logout:Sign out from ollama.com (alias for signout)'
|
|
||||||
'list:List models'
|
|
||||||
'ls:List models (alias for list)'
|
|
||||||
'ps:List running models'
|
|
||||||
'cp:Copy a model'
|
|
||||||
'rm:Remove a model'
|
|
||||||
'launch:Launch an integration with ollama'
|
|
||||||
'help:Help about any command'
|
|
||||||
)
|
|
||||||
|
|
||||||
case $state in
|
|
||||||
command)
|
|
||||||
_describe -t commands 'ollama command' commands
|
|
||||||
;;
|
|
||||||
args)
|
|
||||||
case $words[1] in
|
|
||||||
create)
|
|
||||||
_arguments \
|
|
||||||
'(-f --file)'{-f+,--file=}'[Name of the Modelfile]:file:_files' \
|
|
||||||
'(-q --quantize)'{-q+,--quantize=}'[Quantize model to this level]:level:' \
|
|
||||||
'--force[Continue local creation when validation fails]' \
|
|
||||||
'1:model name:'
|
|
||||||
;;
|
|
||||||
show)
|
|
||||||
_arguments \
|
|
||||||
'--license[Show license of a model]' \
|
|
||||||
'--modelfile[Show Modelfile of a model]' \
|
|
||||||
'--parameters[Show parameters of a model]' \
|
|
||||||
'--system[Show system message of a model]' \
|
|
||||||
'--template[Show template of a model]' \
|
|
||||||
'(-v --verbose)'{-v,--verbose}'[Show detailed model information]' \
|
|
||||||
'1:model:_ollama_models'
|
|
||||||
;;
|
|
||||||
run)
|
|
||||||
_arguments \
|
|
||||||
'--format=[Response format]:format:(json)' \
|
|
||||||
'--keepalive=[Duration to keep a model loaded]:duration:' \
|
|
||||||
'--think=[Enable thinking mode]:level:(true false high medium low)' \
|
|
||||||
'--hidethinking[Hide thinking output]' \
|
|
||||||
'--truncate[Truncate embedding inputs exceeding context length]' \
|
|
||||||
'--dimensions=[Truncate output embeddings to this dimension]:dimensions:' \
|
|
||||||
'--insecure[Use an insecure registry]' \
|
|
||||||
'--nowordwrap[Disable word wrap]' \
|
|
||||||
'--verbose[Show timings for response]' \
|
|
||||||
'1:model:_ollama_models' \
|
|
||||||
'2:prompt:'
|
|
||||||
;;
|
|
||||||
stop)
|
|
||||||
_arguments '1:running model:_ollama_running_models'
|
|
||||||
;;
|
|
||||||
pull|push)
|
|
||||||
_arguments \
|
|
||||||
'--insecure[Use an insecure registry]' \
|
|
||||||
'1:model:_ollama_models'
|
|
||||||
;;
|
|
||||||
cp)
|
|
||||||
_arguments \
|
|
||||||
'1:source model:_ollama_models' \
|
|
||||||
'2:target model:'
|
|
||||||
;;
|
|
||||||
rm)
|
|
||||||
_arguments '*:model:_ollama_models'
|
|
||||||
;;
|
|
||||||
launch)
|
|
||||||
_arguments \
|
|
||||||
'(-m --model)'{-m+,--model=}'[Model to use]:model:_ollama_models' \
|
|
||||||
'--config[Configure the integration without launching it]' \
|
|
||||||
'--restore[Restore the integration configuration]' \
|
|
||||||
'(-y --yes)'{-y,--yes}'[Skip confirmation prompts]' \
|
|
||||||
'1:integration:'
|
|
||||||
;;
|
|
||||||
help)
|
|
||||||
_describe -t commands 'ollama command' commands
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
}
|
|
||||||
|
|
||||||
_ollama "$@"
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
# Completion for ollama lives in _ollama, which Oh My Zsh adds to fpath
|
|
||||||
@@ -46,7 +46,6 @@ You can set these variables in your `.zshrc` file, before Oh My Zsh is sourced.
|
|||||||
For example:
|
For example:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
PYTHON_AUTO_VRUN=true
|
|
||||||
PYTHON_VENV_NAME=".venv"
|
PYTHON_VENV_NAME=".venv"
|
||||||
PYTHON_VENV_NAMES=($PYTHON_VENV_NAME venv)
|
PYTHON_VENV_NAMES=($PYTHON_VENV_NAME venv)
|
||||||
...
|
...
|
||||||
@@ -55,14 +54,6 @@ source "$ZSH/oh-my-zsh.sh"
|
|||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
## `$PYTHON_AUTO_VRUN`
|
|
||||||
|
|
||||||
**Default**: `false`.
|
|
||||||
|
|
||||||
Enable automatic activation of virtual environments when entering a directory containing
|
|
||||||
`<venv-name>/bin/activate`, and automatically deactivate it when navigating out of it.
|
|
||||||
Set to `true` to enable this feature.
|
|
||||||
|
|
||||||
## `$PYTHON_VENV_NAME`
|
## `$PYTHON_VENV_NAME`
|
||||||
|
|
||||||
**Default**: `venv`.
|
**Default**: `venv`.
|
||||||
|
|||||||
@@ -1,20 +0,0 @@
|
|||||||
# sprite plugin
|
|
||||||
|
|
||||||
This plugin adds completion for the [Sprites CLI](https://docs.sprites.dev/cli/installation) (`sprite`).
|
|
||||||
|
|
||||||
To use it, add `sprite` to the plugins array in your zshrc file:
|
|
||||||
|
|
||||||
```zsh
|
|
||||||
plugins=(... sprite)
|
|
||||||
```
|
|
||||||
|
|
||||||
This plugin does not add any aliases.
|
|
||||||
|
|
||||||
## Cache
|
|
||||||
|
|
||||||
This plugin caches the completion script and is automatically updated asynchronously when the plugin is
|
|
||||||
loaded, which is usually when you start up a new terminal emulator.
|
|
||||||
|
|
||||||
The cache is stored at:
|
|
||||||
|
|
||||||
- `$ZSH_CACHE_DIR/completions/_sprite` completions script
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
# Autocompletion for sprite
|
|
||||||
if (( ! $+commands[sprite] )); then
|
|
||||||
return
|
|
||||||
fi
|
|
||||||
|
|
||||||
# If the completion file doesn't exist yet, we need to autoload it and
|
|
||||||
# bind it to `sprite`. Otherwise, compinit will have already done that.
|
|
||||||
if [[ ! -f "$ZSH_CACHE_DIR/completions/_sprite" ]]; then
|
|
||||||
typeset -g -A _comps
|
|
||||||
autoload -Uz _sprite
|
|
||||||
_comps[sprite]=_sprite
|
|
||||||
fi
|
|
||||||
|
|
||||||
() {
|
|
||||||
local tmpfile="$ZSH_CACHE_DIR/completions/_sprite.$$.tmp"
|
|
||||||
sprite completion zsh >| "$tmpfile" 2>/dev/null && command mv -f "$tmpfile" "$ZSH_CACHE_DIR/completions/_sprite" || command rm -f "$tmpfile"
|
|
||||||
} &|
|
|
||||||
@@ -153,34 +153,34 @@ function port_pro() {
|
|||||||
|
|
||||||
# top10 of gain access to the ip address
|
# top10 of gain access to the ip address
|
||||||
function accessip10() {
|
function accessip10() {
|
||||||
awk '{counts[$(11)]+=1}; END {for(url in counts) print counts[url], url}' "$(retlog "$1")"
|
awk '{counts[$(11)]+=1}; END {for(url in counts) print counts[url], url}' "$(retlog)"
|
||||||
}
|
}
|
||||||
|
|
||||||
# top20 of Most Visited file or page
|
# top20 of Most Visited file or page
|
||||||
function visitpage20() {
|
function visitpage20() {
|
||||||
awk '{print $11}' "$(retlog "$1")" | sort | uniq -c | sort -nr | head -n 20
|
awk '{print $11}' "$(retlog)" | sort | uniq -c | sort -nr | head -n 20
|
||||||
}
|
}
|
||||||
|
|
||||||
# top100 of Page lists the most time-consuming (more than 60 seconds) as well as the corresponding page number of occurrences
|
# top100 of Page lists the most time-consuming (more than 60 seconds) as well as the corresponding page number of occurrences
|
||||||
function consume100() {
|
function consume100() {
|
||||||
awk '($NF > 60 && $7~/\.php/){print $7}' "$(retlog "$1")" | sort -n | uniq -c | sort -nr | head -n 100
|
awk '($NF > 60 && $7~/\.php/){print $7}' "$(retlog)" | sort -n | uniq -c | sort -nr | head -n 100
|
||||||
# if django website or other website make by no suffix language
|
# if django website or other website make by no suffix language
|
||||||
# awk '{print $7}' "$(retlog "$1")" | sort -n | uniq -c | sort -nr | head -n 100
|
# awk '{print $7}' "$(retlog)" | sort -n | uniq -c | sort -nr | head -n 100
|
||||||
}
|
}
|
||||||
|
|
||||||
# Website traffic statistics (G)
|
# Website traffic statistics (G)
|
||||||
function webtraffic() {
|
function webtraffic() {
|
||||||
awk '{sum+=$10} END {print sum/1024/1024/1024}' "$(retlog "$1")"
|
awk '{sum+=$10} END {print sum/1024/1024/1024}' "$(retlog)"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Statistical connections 404
|
# Statistical connections 404
|
||||||
function c404() {
|
function c404() {
|
||||||
awk '($9 ~ /404/)' "$(retlog "$1")" | awk '{print $9,$7}' | sort
|
awk '($9 ~ /404/)' "$(retlog)" | awk '{print $9,$7}' | sort
|
||||||
}
|
}
|
||||||
|
|
||||||
# Statistical http status.
|
# Statistical http status.
|
||||||
function httpstatus() {
|
function httpstatus() {
|
||||||
awk '{counts[$(9)]+=1}; END {for(code in counts) print code, counts[code]}' "$(retlog "$1")"
|
awk '{counts[$(9)]+=1}; END {for(code in counts) print code, counts[code]}' "$(retlog)"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Delete 0 byte file
|
# Delete 0 byte file
|
||||||
@@ -211,5 +211,5 @@ function getip() {
|
|||||||
|
|
||||||
# Second concurrent
|
# Second concurrent
|
||||||
function conssec() {
|
function conssec() {
|
||||||
awk '{if($9~/200|30|404/)COUNT[$4]++}END{for( a in COUNT) print a,COUNT[a]}' "$(retlog "$1")" | sort -k 2 -nr | head -n10
|
awk '{if($9~/200|30|404/)COUNT[$4]++}END{for( a in COUNT) print a,COUNT[a]}' "$(retlog)" | sort -k 2 -nr | head -n10
|
||||||
}
|
}
|
||||||
@@ -12,14 +12,6 @@ plugins=(... terraform)
|
|||||||
## Requirements
|
## Requirements
|
||||||
|
|
||||||
- [Terraform](https://terraform.io/)
|
- [Terraform](https://terraform.io/)
|
||||||
- [terraform-docs](https://terraform-docs.io/) (optional, for completion)
|
|
||||||
|
|
||||||
## terraform-docs completion
|
|
||||||
|
|
||||||
If `terraform-docs` is installed, this plugin also enables its completion.
|
|
||||||
The completion script is generated from the installed version and cached in
|
|
||||||
`$ZSH_CACHE_DIR/completions/_terraform-docs`. It is refreshed in the background
|
|
||||||
each time the plugin loads, so completion stays in sync with the installed CLI.
|
|
||||||
|
|
||||||
## Aliases
|
## Aliases
|
||||||
|
|
||||||
|
|||||||
@@ -39,23 +39,3 @@ alias tfsh='terraform show'
|
|||||||
alias tfw='terraform workspace'
|
alias tfw='terraform workspace'
|
||||||
alias tfwl='terraform workspace list'
|
alias tfwl='terraform workspace list'
|
||||||
alias tfws='terraform workspace select'
|
alias tfws='terraform workspace select'
|
||||||
|
|
||||||
if (( $+commands[terraform-docs] )); then
|
|
||||||
# If the completion file doesn't exist yet, compinit hasn't registered it.
|
|
||||||
if [[ ! -f "$ZSH_CACHE_DIR/completions/_terraform-docs" ]]; then
|
|
||||||
typeset -g -A _comps
|
|
||||||
autoload -Uz _terraform-docs
|
|
||||||
_comps[terraform-docs]=_terraform-docs
|
|
||||||
fi
|
|
||||||
|
|
||||||
zmodload -F zsh/files b:zf_mv
|
|
||||||
() {
|
|
||||||
local completions
|
|
||||||
completions=$(command terraform-docs completion zsh) || return
|
|
||||||
[[ -n "$completions" ]] || return
|
|
||||||
|
|
||||||
local TMPPREFIX="$ZSH_CACHE_DIR/completions/._terraform-docs"
|
|
||||||
zf_mv -f -- =(print -r -- "$completions") \
|
|
||||||
"$ZSH_CACHE_DIR/completions/_terraform-docs"
|
|
||||||
} &|
|
|
||||||
fi
|
|
||||||
@@ -4,9 +4,7 @@
|
|||||||
|
|
||||||
To use it, add thefuck to the plugins array of your zshrc file:
|
To use it, add thefuck to the plugins array of your zshrc file:
|
||||||
|
|
||||||
```zsh
|
|
||||||
plugins=(... thefuck)
|
plugins=(... thefuck)
|
||||||
```
|
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
Press `ESC` twice to correct previous console command.
|
Press `ESC` twice to correct previous console command.
|
||||||
|
|||||||
@@ -43,32 +43,12 @@ function _vi-mode-set-cursor-shape-for-keymap() {
|
|||||||
printf $'\e[%d q' "${_shape}"
|
printf $'\e[%d q' "${_shape}"
|
||||||
}
|
}
|
||||||
|
|
||||||
autoload -Uz is-at-least
|
function _visual-mode {
|
||||||
if is-at-least 5.3; then
|
|
||||||
# Visual mode doesn't change $KEYMAP, it only activates the region, so
|
|
||||||
# zle-keymap-select never runs when it starts or ends
|
|
||||||
function _vi-mode-zle-line-pre-redraw() {
|
|
||||||
if [[ "$KEYMAP" = vicmd ]] && (( REGION_ACTIVE )); then
|
|
||||||
[[ "$VI_KEYMAP" != visual ]] || return 0
|
|
||||||
typeset -g VI_KEYMAP=visual
|
|
||||||
elif [[ "$VI_KEYMAP" = visual ]]; then
|
|
||||||
typeset -g VI_KEYMAP=$KEYMAP
|
|
||||||
else
|
|
||||||
return 0
|
|
||||||
fi
|
|
||||||
_vi-mode-set-cursor-shape-for-keymap "$VI_KEYMAP"
|
|
||||||
}
|
|
||||||
autoload -Uz add-zle-hook-widget
|
|
||||||
add-zle-hook-widget zle-line-pre-redraw _vi-mode-zle-line-pre-redraw
|
|
||||||
else
|
|
||||||
# zle-line-pre-redraw needs zsh 5.3
|
|
||||||
function _visual-mode {
|
|
||||||
typeset -g VI_KEYMAP=visual
|
typeset -g VI_KEYMAP=visual
|
||||||
_vi-mode-set-cursor-shape-for-keymap "$VI_KEYMAP"
|
_vi-mode-set-cursor-shape-for-keymap "$VI_KEYMAP"
|
||||||
zle .visual-mode
|
zle .visual-mode
|
||||||
}
|
}
|
||||||
zle -N visual-mode _visual-mode
|
zle -N visual-mode _visual-mode
|
||||||
fi
|
|
||||||
|
|
||||||
function _vi-mode-should-reset-prompt() {
|
function _vi-mode-should-reset-prompt() {
|
||||||
# If $VI_MODE_RESET_PROMPT_ON_MODE_CHANGE is unset (default), dynamically
|
# If $VI_MODE_RESET_PROMPT_ON_MODE_CHANGE is unset (default), dynamically
|
||||||
|
|||||||
+4
-33
@@ -23,47 +23,18 @@ fi
|
|||||||
|
|
||||||
if [ -e ~/.zshrc ]; then
|
if [ -e ~/.zshrc ]; then
|
||||||
ZSHRC_SAVE=~/.zshrc.omz-uninstalled-$(date +%Y-%m-%d_%H-%M-%S)
|
ZSHRC_SAVE=~/.zshrc.omz-uninstalled-$(date +%Y-%m-%d_%H-%M-%S)
|
||||||
echo "Found ~/.zshrc -- Saving your current config to ${ZSHRC_SAVE}"
|
echo "Found ~/.zshrc -- Renaming to ${ZSHRC_SAVE}"
|
||||||
echo " (this file contains your current zsh configuration)"
|
|
||||||
mv ~/.zshrc "${ZSHRC_SAVE}"
|
mv ~/.zshrc "${ZSHRC_SAVE}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "Looking for original zsh config..."
|
echo "Looking for original zsh config..."
|
||||||
ZSHRC_ORIG=~/.zshrc.pre-oh-my-zsh
|
ZSHRC_ORIG=~/.zshrc.pre-oh-my-zsh
|
||||||
if [ -e "$ZSHRC_ORIG" ]; then
|
if [ -e "$ZSHRC_ORIG" ]; then
|
||||||
ZSHRC_ORIG_DATE=$(date -r "$ZSHRC_ORIG" "+%Y-%m-%d" 2>/dev/null || date -d "@$(stat -c %Y "$ZSHRC_ORIG" 2>/dev/null)" "+%Y-%m-%d" 2>/dev/null || echo "unknown date")
|
echo "Found $ZSHRC_ORIG -- Restoring to ~/.zshrc"
|
||||||
echo "Found $ZSHRC_ORIG (last modified: ${ZSHRC_ORIG_DATE})"
|
|
||||||
echo "This is the zsh config that existed before Oh My Zsh was installed."
|
|
||||||
printf "Restore it as ~/.zshrc? [y/N] "
|
|
||||||
read -r restore_confirmation
|
|
||||||
if [ "$restore_confirmation" = y ] || [ "$restore_confirmation" = Y ]; then
|
|
||||||
mv "$ZSHRC_ORIG" ~/.zshrc
|
mv "$ZSHRC_ORIG" ~/.zshrc
|
||||||
echo "Your original zsh config was restored to ~/.zshrc."
|
echo "Your original zsh config was restored."
|
||||||
if [ -n "$ZSHRC_SAVE" ]; then
|
|
||||||
echo "Your Oh My Zsh config is saved at ${ZSHRC_SAVE} if you need it."
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
echo "Skipping restore."
|
|
||||||
if [ -n "$ZSHRC_SAVE" ]; then
|
|
||||||
mv "${ZSHRC_SAVE}" ~/.zshrc
|
|
||||||
echo "Your current zsh config has been kept at ~/.zshrc."
|
|
||||||
echo "Your pre-OMZ backup is still at ${ZSHRC_ORIG} if you need it."
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
else
|
else
|
||||||
echo "No original zsh config found."
|
echo "No original zsh config found"
|
||||||
if [ -n "$ZSHRC_SAVE" ]; then
|
|
||||||
mv "${ZSHRC_SAVE}" ~/.zshrc
|
|
||||||
echo "Your current zsh config has been kept at ~/.zshrc."
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Warn if the active .zshrc still sources oh-my-zsh
|
|
||||||
if [ -f ~/.zshrc ] && command grep -q 'source.*oh-my-zsh\.sh' ~/.zshrc 2>/dev/null; then
|
|
||||||
echo ""
|
|
||||||
echo "Note: ~/.zshrc still contains a line sourcing oh-my-zsh.sh."
|
|
||||||
echo "Since oh-my-zsh has been removed, that line will cause an error"
|
|
||||||
echo "on every new shell. You may want to remove or comment it out."
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "Thanks for trying out Oh My Zsh. It's been uninstalled."
|
echo "Thanks for trying out Oh My Zsh. It's been uninstalled."
|
||||||
|
|||||||
Reference in new issue
Block a user