mirror of
https://github.com/robbyrussell/oh-my-zsh.git
synced 2026-11-28 11:23:03 +01:00
Compare commits
10
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c7c3ad8379 | ||
|
|
b008e21f9c | ||
|
|
3d5a7b0df4 | ||
|
|
44a5decbc4 | ||
|
|
90f9fbc532 | ||
|
|
801782e8a6 | ||
|
|
e7a67d2e80 | ||
|
|
4ec1d17074 | ||
|
|
71679f351d | ||
|
|
5c7cd91615 |
No files matched your search
@@ -1,21 +1,57 @@
|
||||
## Standards checklist:
|
||||
<!--
|
||||
Thanks for contributing! Read CONTRIBUTING.md first.
|
||||
Keep this proportional to the change: short paragraphs or bullets are welcome.
|
||||
Remove these instructions before submitting.
|
||||
|
||||
<!-- Fill with an x the ones that apply. Example: [x] -->
|
||||
Report only evidence you have. Distinguish agent-run checks from personal
|
||||
testing, identify missing checks or demos, and leave unconfirmed items
|
||||
unchecked. Don't promise follow-up work on someone else's behalf.
|
||||
-->
|
||||
|
||||
- [ ] The PR title is descriptive.
|
||||
- [ ] 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 and why
|
||||
|
||||
## Changes:
|
||||
<!-- What changes, who benefits, and how does it make their command-line
|
||||
experience easier or more delightful? A few sentences are usually enough.
|
||||
Link related issues or requests if available; don't invent demand.
|
||||
|
||||
- [...]
|
||||
A personal itch is a welcome starting point. Explain why the change belongs
|
||||
in the shared project. For aliases, describe common workflows they support. -->
|
||||
|
||||
## Other comments:
|
||||
## Demo and verification
|
||||
|
||||
...
|
||||
<!-- For user-facing changes, include before/after screenshots, a GIF,
|
||||
or a short video. For new features, show an example in use.
|
||||
If a visual isn't useful, briefly explain why. If it's missing, say so.
|
||||
|
||||
Describe checks actually run and their results, relevant versions, and
|
||||
testing gaps. Distinguish agent-run checks from personal testing.
|
||||
For documentation-only changes, describe what you checked. -->
|
||||
|
||||
## Other notes
|
||||
|
||||
<!-- Include only what applies:
|
||||
- Compatibility concerns or areas needing particular attention.
|
||||
- How users can discover a feature: README update, example, or shared demo.
|
||||
- Meaningful AI assistance and its role; basic autocomplete doesn't count.
|
||||
|
||||
Delete this section if it isn't needed. -->
|
||||
|
||||
<details>
|
||||
<summary>Submission checklist</summary>
|
||||
|
||||
<!-- Check confirmed items with [x]. For conditional items, check them if
|
||||
the condition doesn't apply. Otherwise, mark inapplicable items "N/A"
|
||||
with a brief reason. -->
|
||||
|
||||
- [ ] The PR title follows the [commit conventions](https://github.com/ohmyzsh/ohmyzsh/blob/master/CONTRIBUTING.md#commit-guidelines) and clearly describes the change.
|
||||
- [ ] I've searched for existing PRs and confirmed this isn't a duplicate.
|
||||
- [ ] I've read and followed the [contribution guidelines](https://github.com/ohmyzsh/ohmyzsh/blob/master/CONTRIBUTING.md).
|
||||
- [ ] My code follows the [code style guide](https://github.com/ohmyzsh/ohmyzsh/wiki/Code-Style-Guide).
|
||||
- [ ] I wrote this code or can contribute it under an MIT-compatible license.
|
||||
- [ ] If I meaningfully used AI tools, I've disclosed their role above.
|
||||
- [ ] I've included a visual demonstration or explained why a visual isn't useful.
|
||||
- [ ] I've considered performance and avoided unnecessary work or resource use.
|
||||
- [ ] I've personally tested the change and described results and limitations above.
|
||||
- [ ] If I've added aliases, I've explained their usefulness for common workflows.
|
||||
|
||||
</details>
|
||||
@@ -0,0 +1,2 @@
|
||||
# default known collisions file
|
||||
known_collisions.json
|
||||
@@ -0,0 +1,170 @@
|
||||
"""Check for alias collisions within the codebase"""
|
||||
|
||||
from argparse import ArgumentDefaultsHelpFormatter, ArgumentParser
|
||||
from pathlib import Path
|
||||
from dataclasses import dataclass
|
||||
import itertools
|
||||
import re
|
||||
import json
|
||||
import sys
|
||||
|
||||
|
||||
ERROR_MESSAGE_TEMPLATE = (
|
||||
"Alias `%s` defined in `%s` already exists as alias `%s` in `%s`."
|
||||
)
|
||||
|
||||
KNOWN_COLLISIONS_PATH = Path(__file__).resolve().parent / "known_collisions.json"
|
||||
|
||||
|
||||
def dir_path(path_string: str) -> Path:
|
||||
if Path(path_string).is_dir():
|
||||
return Path(path_string)
|
||||
else:
|
||||
raise NotADirectoryError(path_string)
|
||||
|
||||
|
||||
def parse_arguments():
|
||||
parser = ArgumentParser(
|
||||
description=__doc__,
|
||||
formatter_class=ArgumentDefaultsHelpFormatter,
|
||||
)
|
||||
parser.add_argument(
|
||||
"folder",
|
||||
type=dir_path,
|
||||
help="Folder to check",
|
||||
)
|
||||
group = parser.add_mutually_exclusive_group(required=True)
|
||||
group.add_argument(
|
||||
"--known-collisions",
|
||||
type=Path,
|
||||
default=None,
|
||||
help="Json-serialized list of known collision to compare to",
|
||||
)
|
||||
group.add_argument(
|
||||
"--known-collisions-output-path",
|
||||
type=Path,
|
||||
default=KNOWN_COLLISIONS_PATH,
|
||||
help="Output path for a json-serialized list of known collisions",
|
||||
)
|
||||
return parser.parse_args()
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class Alias:
|
||||
alias: str
|
||||
value: str
|
||||
module: Path
|
||||
|
||||
def to_dict(self) -> dict:
|
||||
return {
|
||||
"alias": self.alias,
|
||||
"value": self.value,
|
||||
"module": str(self.module),
|
||||
}
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class Collision:
|
||||
existing_alias: Alias
|
||||
new_alias: Alias
|
||||
|
||||
def is_new_collision(self, known_collision_aliases: list[str]) -> bool:
|
||||
return self.new_alias.alias not in known_collision_aliases
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, collision_dict: dict) -> "Collision":
|
||||
return cls(
|
||||
Alias(**collision_dict["existing_alias"]),
|
||||
Alias(**collision_dict["new_alias"]),
|
||||
)
|
||||
|
||||
def to_dict(self) -> dict:
|
||||
return {
|
||||
"existing_alias": self.existing_alias.to_dict(),
|
||||
"new_alias": self.new_alias.to_dict(),
|
||||
}
|
||||
|
||||
|
||||
def find_aliases_in_file(file: Path) -> list[Alias]:
|
||||
matches = re.findall(
|
||||
r"^[ \t]*alias (?:-[gs] )?([^ =]+)=['\"]?(.*?)['\"]?$",
|
||||
file.read_text(),
|
||||
re.MULTILINE,
|
||||
)
|
||||
return [Alias(match[0], match[1], file) for match in matches]
|
||||
|
||||
|
||||
def load_known_collisions(collision_file: Path) -> list[Collision]:
|
||||
collision_list = json.loads(collision_file.read_text())
|
||||
return [Collision.from_dict(collision_dict) for collision_dict in collision_list]
|
||||
|
||||
|
||||
def find_all_aliases(path: Path) -> list:
|
||||
aliases = [find_aliases_in_file(file) for file in path.rglob("*.zsh")]
|
||||
return list(itertools.chain(*aliases))
|
||||
|
||||
|
||||
def check_for_duplicates(aliases: list[Alias]) -> list[Collision]:
|
||||
elements = {}
|
||||
collisions = []
|
||||
for alias in aliases:
|
||||
if alias.alias in elements:
|
||||
existing = elements[alias.alias]
|
||||
collisions.append(Collision(existing, alias))
|
||||
else:
|
||||
elements[alias.alias] = alias
|
||||
return collisions
|
||||
|
||||
|
||||
def print_collisions(collisions: dict[Alias, Alias]) -> None:
|
||||
if collisions:
|
||||
print(f"Found {len(collisions)} alias collisions:\n")
|
||||
for collision in collisions:
|
||||
print(
|
||||
ERROR_MESSAGE_TEMPLATE
|
||||
% (
|
||||
f"{collision.new_alias.alias}={collision.new_alias.value}",
|
||||
collision.new_alias.module.name,
|
||||
f"{collision.existing_alias.alias}={collision.existing_alias.value}",
|
||||
collision.existing_alias.module.name,
|
||||
)
|
||||
)
|
||||
print("\nConsider renaming your aliases.")
|
||||
else:
|
||||
print("Found no collisions")
|
||||
|
||||
|
||||
def check_for_new_collisions(
|
||||
known_collisions: Path, collisions: list[Collision]
|
||||
) -> list[Collision]:
|
||||
known_collisions = load_known_collisions(known_collisions)
|
||||
known_collision_aliases = [
|
||||
collision.new_alias.alias for collision in known_collisions
|
||||
]
|
||||
|
||||
return [
|
||||
collision
|
||||
for collision in collisions
|
||||
if collision.is_new_collision(known_collision_aliases)
|
||||
]
|
||||
|
||||
|
||||
def main() -> int:
|
||||
"""main"""
|
||||
args = parse_arguments()
|
||||
aliases = find_all_aliases(args.folder)
|
||||
collisions = check_for_duplicates(aliases)
|
||||
|
||||
if args.known_collisions is not None:
|
||||
new_collisions = check_for_new_collisions(args.known_collisions, collisions)
|
||||
print_collisions(new_collisions)
|
||||
return -1 if new_collisions else 0
|
||||
|
||||
args.known_collisions_output_path.write_text(
|
||||
json.dumps([collision.to_dict() for collision in collisions])
|
||||
)
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
@@ -0,0 +1,2 @@
|
||||
pyfakefs
|
||||
pytest
|
||||
@@ -0,0 +1,166 @@
|
||||
from pathlib import Path
|
||||
|
||||
from pyfakefs.fake_filesystem import FakeFilesystem
|
||||
import pytest
|
||||
|
||||
from check_alias_collision import (
|
||||
dir_path,
|
||||
find_all_aliases,
|
||||
find_aliases_in_file,
|
||||
check_for_duplicates,
|
||||
Alias,
|
||||
Collision,
|
||||
load_known_collisions,
|
||||
)
|
||||
|
||||
|
||||
THREE_ALIASES = """
|
||||
alias g='git'
|
||||
|
||||
alias ga='git add'
|
||||
alias gaa='git add --all'
|
||||
"""
|
||||
|
||||
CONDITIONAL_ALIAS = """
|
||||
is-at-least 2.8 "$git_version" \
|
||||
&& alias gfa='git fetch --all --prune --jobs=10' \
|
||||
|| alias gfa='git fetch --all --prune'
|
||||
"""
|
||||
|
||||
ONE_KNOWN_COLLISION = """
|
||||
[
|
||||
{
|
||||
"existing_alias": {
|
||||
"alias": "gcd",
|
||||
"value": "git checkout $(git_develop_branch)",
|
||||
"module": "plugins/git/git.plugin.zsh"
|
||||
},
|
||||
"new_alias": {
|
||||
"alias": "gcd",
|
||||
"value": "git checkout $(git config gitflow.branch.develop)",
|
||||
"module": "plugins/git-flow/git-flow.plugin.zsh"
|
||||
}
|
||||
}
|
||||
]
|
||||
"""
|
||||
|
||||
|
||||
def test_dir_path__is_dir__input_path(fs: FakeFilesystem) -> None:
|
||||
fs.create_dir("test")
|
||||
assert Path("test") == dir_path("test")
|
||||
|
||||
|
||||
def test_dir_path__is_file__raise_not_a_directory_error(fs: FakeFilesystem) -> None:
|
||||
fs.create_file("test")
|
||||
with pytest.raises(NotADirectoryError):
|
||||
dir_path("test")
|
||||
|
||||
|
||||
def test_dir_path__does_not_exist__raise_not_a_directory_error(
|
||||
fs: FakeFilesystem,
|
||||
) -> None:
|
||||
with pytest.raises(NotADirectoryError):
|
||||
dir_path("test")
|
||||
|
||||
|
||||
def test_find_all_aliases__empty_folder_should_return_empty_list(
|
||||
fs: FakeFilesystem,
|
||||
) -> None:
|
||||
fs.create_dir("test")
|
||||
result = find_all_aliases(Path("test"))
|
||||
assert [] == result
|
||||
|
||||
|
||||
def test_find_aliases_in_file__empty_text_should_return_empty_list(
|
||||
fs: FakeFilesystem,
|
||||
) -> None:
|
||||
fs.create_file("empty.zsh")
|
||||
result = find_aliases_in_file(Path("empty.zsh"))
|
||||
assert [] == result
|
||||
|
||||
|
||||
def test_find_aliases_in_file__one_alias_should_find_one(fs: FakeFilesystem) -> None:
|
||||
fs.create_file("one.zsh", contents="alias g='git'")
|
||||
result = find_aliases_in_file(Path("one.zsh"))
|
||||
assert [Alias("g", "git", Path("one.zsh"))] == result
|
||||
|
||||
|
||||
def test_find_aliases_in_file__three_aliases_should_find_three(
|
||||
fs: FakeFilesystem,
|
||||
) -> None:
|
||||
fs.create_file("three.zsh", contents=THREE_ALIASES)
|
||||
result = find_aliases_in_file(Path("three.zsh"))
|
||||
assert [
|
||||
Alias("g", "git", Path("three.zsh")),
|
||||
Alias("ga", "git add", Path("three.zsh")),
|
||||
Alias("gaa", "git add --all", Path("three.zsh")),
|
||||
] == result
|
||||
|
||||
|
||||
def test_find_aliases_in_file__one_conditional_alias_should_find_none(
|
||||
fs: FakeFilesystem,
|
||||
) -> None:
|
||||
fs.create_file("conditional.zsh", contents=CONDITIONAL_ALIAS)
|
||||
result = find_aliases_in_file(Path("conditional.zsh"))
|
||||
assert [] == result
|
||||
|
||||
|
||||
def test_check_for_duplicates__no_duplicates_should_return_empty_dict() -> None:
|
||||
result = check_for_duplicates(
|
||||
[
|
||||
Alias("g", "git", Path("git.zsh")),
|
||||
Alias("ga", "git add", Path("git.zsh")),
|
||||
Alias("gaa", "git add --all", Path("git.zsh")),
|
||||
]
|
||||
)
|
||||
assert result == []
|
||||
|
||||
|
||||
def test_check_for_duplicates__duplicates_should_have_one_collision() -> None:
|
||||
result = check_for_duplicates(
|
||||
[
|
||||
Alias("gc", "git commit", Path("git.zsh")),
|
||||
Alias("gc", "git clone", Path("git.zsh")),
|
||||
]
|
||||
)
|
||||
assert result == [
|
||||
Collision(
|
||||
Alias("gc", "git commit", Path("git.zsh")),
|
||||
Alias("gc", "git clone", Path("git.zsh")),
|
||||
)
|
||||
]
|
||||
|
||||
|
||||
def test_is_new_collision__new_alias_not_in_known_collisions__should_return_true() -> (
|
||||
None
|
||||
):
|
||||
known_collisions = ["gc", "gd"]
|
||||
new_alias = Alias("ga", "git add", Path("git.zsh"))
|
||||
collision = Collision(Alias("gd", "git diff", Path("git.zsh")), new_alias)
|
||||
assert collision.is_new_collision(known_collisions) is True
|
||||
|
||||
|
||||
def test_is_new_collision__new_alias_in_known_collisions__should_return_false() -> None:
|
||||
known_collisions = ["gc", "gd", "ga"]
|
||||
new_alias = Alias("ga", "git add", Path("git.zsh"))
|
||||
collision = Collision(Alias("gd", "git diff", Path("git.zsh")), new_alias)
|
||||
assert collision.is_new_collision(known_collisions) is False
|
||||
|
||||
|
||||
def test_load_known_collisions__empty_file__should_return_empty_list(
|
||||
fs: FakeFilesystem,
|
||||
) -> None:
|
||||
empty_list = Path("empty.json")
|
||||
fs.create_file(empty_list, contents="[]")
|
||||
result = load_known_collisions(empty_list)
|
||||
assert [] == result
|
||||
|
||||
|
||||
def test_load_known_collisions__one_collision__should_return_one_collision(
|
||||
fs: FakeFilesystem,
|
||||
) -> None:
|
||||
known_collisions_file = Path("known_collisions.json")
|
||||
fs.create_file(known_collisions_file, contents=ONE_KNOWN_COLLISION)
|
||||
result = load_known_collisions(known_collisions_file)
|
||||
assert 1 == len(result)
|
||||
assert "gcd" == result[0].existing_alias.alias
|
||||
@@ -41,3 +41,31 @@ jobs:
|
||||
./themes/*.zsh-theme; do
|
||||
zsh -n "$file" || return 1
|
||||
done
|
||||
|
||||
collisions:
|
||||
name: Check alias collisions
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Set up git repository
|
||||
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||
- name: Set up Python
|
||||
uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
|
||||
with:
|
||||
python-version: '3.14'
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
python -m pip install --upgrade pip
|
||||
pip install -r .github/workflows/alias_collision/requirements.txt
|
||||
- name: Run unit tests
|
||||
run: |
|
||||
cd .github/workflows/alias_collision/
|
||||
python -m pytest
|
||||
- name: Checkout target branch
|
||||
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||
with:
|
||||
path: ohmyzsh-target-branch
|
||||
ref: master
|
||||
- name: Check for alias collisions on target branch
|
||||
run: python .github/workflows/alias_collision/check_alias_collision.py ohmyzsh-target-branch/plugins --known-collisions-output-path known_alias_collisions.json
|
||||
- name: Compare known collisions to new collisions on source branch
|
||||
run: python .github/workflows/alias_collision/check_alias_collision.py plugins --known-collisions known_alias_collisions.json
|
||||
@@ -18,6 +18,7 @@ you would make is not already covered.
|
||||
- [You have a suggestion](#you-have-a-suggestion)
|
||||
- [Submitting Pull Requests](#submitting-pull-requests)
|
||||
- [Getting started](#getting-started)
|
||||
- [Writing your PR description](#writing-your-pr-description)
|
||||
- [You have a solution](#you-have-a-solution)
|
||||
- [You have an addition](#you-have-an-addition)
|
||||
- [A note on AI-assisted contributions](#a-note-on-ai-assisted-contributions)
|
||||
@@ -78,6 +79,42 @@ any issue that would be solved in the PR description body,
|
||||
[for instance](https://help.github.com/articles/closing-issues-via-commit-messages/)
|
||||
_"Fixes #XXXX"_ for issue number XXXX.
|
||||
|
||||
### Writing your PR description
|
||||
|
||||
Use the [PR template](.github/PULL_REQUEST_TEMPLATE.md) to help people understand
|
||||
the purpose of your change before they reach the submission checklist. Keep answers
|
||||
short and proportional to the change; a sentence or two per section is often enough.
|
||||
|
||||
Oh My Zsh should make the command line more delightful. Tell us whose day your
|
||||
change makes easier, clearer, or more enjoyable, and how. Scratching your own itch
|
||||
is a welcome starting point! Your change doesn't need to help everyone, but explain
|
||||
why it would be useful to others and belongs in the shared project. Link relevant
|
||||
requests or examples when you have them; otherwise, explain the expected benefit
|
||||
without claiming demand you haven't seen.
|
||||
|
||||
For user-facing changes, include screenshots, a GIF, or a short video showing
|
||||
before/after behavior. For a new feature, demonstrate it in use. Label the examples,
|
||||
keep terminal text readable, and remove private information. For low-level or other
|
||||
non-visual changes, explain why a visual wouldn't be useful. If a demo is needed
|
||||
but you can't capture it yet, say so rather than marking it inapplicable.
|
||||
|
||||
Describe the checks actually run and their results, relevant environment versions,
|
||||
and any testing gaps. Distinguish automated or agent-run checks from testing you
|
||||
personally performed. For documentation-only changes, describe what you checked.
|
||||
Only check the personal-testing item after you've done that testing yourself.
|
||||
|
||||
For features and enhancements, tell us how you'll help users discover and use them.
|
||||
A plugin README update, a usage example, or sharing your demo are good ways to help.
|
||||
Be clear about what's included in the PR and what's planned for later.
|
||||
|
||||
**For coding agents:** read these guidelines and the PR template before drafting a
|
||||
PR. Keep the description grounded in available evidence. Don't invent user requests,
|
||||
test results, or demo links, and don't claim personal testing or confirmation on the
|
||||
contributor's behalf. Leave unconfirmed checklist items unchecked and identify
|
||||
missing testing or demos. Don't commit the contributor to follow-up work they
|
||||
haven't agreed to. Disclose meaningful AI assistance in the template's "Other notes"
|
||||
section, following the [AI contribution guidance](#a-note-on-ai-assisted-contributions).
|
||||
|
||||
### You have a solution
|
||||
|
||||
Please be so kind as to [search](#use-the-search-luke) for any open issue already covering
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
# P.C. Shyamshankar <sykora@lucentbeing.com>
|
||||
# Copied from https://github.com/sykora/etc/blob/master/zsh/functions/spectrum/
|
||||
|
||||
autoload -Uz is-at-least
|
||||
|
||||
typeset -AHg FX FG BG
|
||||
|
||||
FX=(
|
||||
@@ -18,7 +20,16 @@ FX=(
|
||||
() {
|
||||
setopt localoptions noksharrays
|
||||
local -a codes fg bg
|
||||
local code
|
||||
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%}" )
|
||||
bg=( "%{"$'\e'"[48;5;"${^codes}"m%}" )
|
||||
FG=( ${codes:^fg} )
|
||||
|
||||
@@ -22,6 +22,7 @@ plugins=(... golang)
|
||||
| gofx | `go fix` | Update packages to use a new API |
|
||||
| gog | `go get` | Downloads packages and then installs them to $GOPATH |
|
||||
| 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 |
|
||||
| gol | `go list` | Lists Go packages |
|
||||
| gom | `go mod` | Access to operations on modules |
|
||||
@@ -54,3 +55,4 @@ changes your prompt to:
|
||||
```
|
||||
~/go/project$ ▋ 1.22.3
|
||||
```
|
||||
|
||||
@@ -19,6 +19,7 @@ alias gofa='go fmt ./...'
|
||||
alias gofx='go fix'
|
||||
alias gog='go get'
|
||||
alias goga='go get ./...'
|
||||
alias goge='go generate'
|
||||
alias goi='go install'
|
||||
alias gol='go list'
|
||||
alias gom='go mod'
|
||||
|
||||
@@ -60,6 +60,7 @@ plugins=(... kubectl)
|
||||
| | | **Namespace management** |
|
||||
| kgns | `kubectl get namespaces` | List the current namespaces in a cluster |
|
||||
| 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 |
|
||||
| kdns | `kubectl describe namespace` | Describe namespace resource in detail |
|
||||
| kdelns | `kubectl delete namespace` | Delete the namespace. WARNING! This deletes everything in the namespace |
|
||||
|
||||
@@ -31,7 +31,7 @@ alias kapk='kubectl apply -k'
|
||||
# Drop into an interactive terminal on a container
|
||||
alias keti='kubectl exec -t -i'
|
||||
|
||||
# Manage configuration quickly to switch contexts between local, dev ad staging.
|
||||
# Manage configuration quickly to switch contexts between local, dev and staging.
|
||||
alias kcuc='kubectl config use-context'
|
||||
alias kcsc='kubectl config set-context'
|
||||
alias kcdc='kubectl config delete-context'
|
||||
@@ -83,6 +83,7 @@ alias kens='kubectl edit namespace'
|
||||
alias kdns='kubectl describe namespace'
|
||||
alias kdelns='kubectl delete namespace'
|
||||
alias kcn='kubectl config set-context --current --namespace'
|
||||
alias kcgetns="kubectl config view --minify -o 'jsonpath={.contexts[0].context.namespace}'"
|
||||
|
||||
# ConfigMap management
|
||||
alias kgcm='kubectl get configmaps'
|
||||
|
||||
@@ -12,6 +12,14 @@ plugins=(... terraform)
|
||||
## Requirements
|
||||
|
||||
- [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
|
||||
|
||||
|
||||
@@ -39,3 +39,23 @@ alias tfsh='terraform show'
|
||||
alias tfw='terraform workspace'
|
||||
alias tfwl='terraform workspace list'
|
||||
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,7 +4,9 @@
|
||||
|
||||
To use it, add thefuck to the plugins array of your zshrc file:
|
||||
|
||||
```zsh
|
||||
plugins=(... thefuck)
|
||||
```
|
||||
|
||||
## Usage
|
||||
Press `ESC` twice to correct previous console command.
|
||||
|
||||
+34
-5
@@ -23,18 +23,47 @@ fi
|
||||
|
||||
if [ -e ~/.zshrc ]; then
|
||||
ZSHRC_SAVE=~/.zshrc.omz-uninstalled-$(date +%Y-%m-%d_%H-%M-%S)
|
||||
echo "Found ~/.zshrc -- Renaming to ${ZSHRC_SAVE}"
|
||||
echo "Found ~/.zshrc -- Saving your current config to ${ZSHRC_SAVE}"
|
||||
echo " (this file contains your current zsh configuration)"
|
||||
mv ~/.zshrc "${ZSHRC_SAVE}"
|
||||
fi
|
||||
|
||||
echo "Looking for original zsh config..."
|
||||
ZSHRC_ORIG=~/.zshrc.pre-oh-my-zsh
|
||||
if [ -e "$ZSHRC_ORIG" ]; then
|
||||
echo "Found $ZSHRC_ORIG -- Restoring to ~/.zshrc"
|
||||
mv "$ZSHRC_ORIG" ~/.zshrc
|
||||
echo "Your original zsh config was restored."
|
||||
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 (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
|
||||
echo "Your original zsh config was restored to ~/.zshrc."
|
||||
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
|
||||
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
|
||||
|
||||
echo "Thanks for trying out Oh My Zsh. It's been uninstalled."
|
||||
|
||||
Reference in new issue
Block a user