mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2025-12-05 01:46:46 +01:00
Merge branch 'ohmyzsh:master' into master
This commit is contained in:
commit
6d97234f3a
360 changed files with 8613 additions and 5675 deletions
20
.devcontainer/devcontainer.json
Normal file
20
.devcontainer/devcontainer.json
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
{
|
||||
"image": "mcr.microsoft.com/devcontainers/base:noble",
|
||||
"features": {
|
||||
"ghcr.io/devcontainers/features/common-utils": {
|
||||
"installZsh": true,
|
||||
"configureZshAsDefaultShell": true,
|
||||
"username": "vscode",
|
||||
"userUid": 1000,
|
||||
"userGid": 1000
|
||||
}
|
||||
},
|
||||
"postCreateCommand": "dir=/workspaces/ohmyzsh; rm -rf $HOME/.oh-my-zsh && ln -s $dir $HOME/.oh-my-zsh && cp $dir/templates/minimal.zshrc $HOME/.zshrc && chgrp -R 1000 $dir && chmod g-w,o-w $dir",
|
||||
"customizations": {
|
||||
"codespaces": {
|
||||
"openFiles": [
|
||||
"README.md"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -6,3 +6,10 @@ insert_final_newline = true
|
|||
charset = utf-8
|
||||
indent_size = 2
|
||||
indent_style = space
|
||||
|
||||
[*.py]
|
||||
indent_size = 4
|
||||
|
||||
[devcontainer.json]
|
||||
indent_size = 4
|
||||
indent_style = tab
|
||||
|
|
|
|||
10
.github/CODEOWNERS
vendored
10
.github/CODEOWNERS
vendored
|
|
@ -1,13 +1,19 @@
|
|||
# Plugin owners
|
||||
plugins/archlinux/ @ratijas
|
||||
plugins/dbt/ @msempere
|
||||
plugins/eza/ @pepoluan
|
||||
plugins/genpass/ @atoponce
|
||||
plugins/git-lfs/ @hellovietduc
|
||||
plugins/gitfast/ @felipec
|
||||
plugins/kube-ps1/ @mcornella
|
||||
plugins/kubectl/ @mcornella
|
||||
plugins/kubectx/ @mcornella
|
||||
plugins/opentofu/ @mcornella
|
||||
plugins/react-native @esthor
|
||||
plugins/sdk/ @rgoldberg
|
||||
plugins/shell-proxy/ @septs
|
||||
plugins/starship/ @axieax
|
||||
plugins/terraform/ @mcornella
|
||||
plugins/universalarchive/ @Konfekt
|
||||
plugins/wp-cli/ @joshmedeski
|
||||
plugins/zoxide/ @ajeetdsouza
|
||||
plugins/starship/ @axieax
|
||||
plugins/dbt/ @msempere
|
||||
|
|
|
|||
14
.github/dependabot.yml
vendored
Normal file
14
.github/dependabot.yml
vendored
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
version: 2
|
||||
updates:
|
||||
- package-ecosystem: github-actions
|
||||
directory: /
|
||||
schedule:
|
||||
interval: "weekly"
|
||||
day: "sunday"
|
||||
labels: []
|
||||
- package-ecosystem: "pip"
|
||||
directory: "/.github/workflows/dependencies"
|
||||
schedule:
|
||||
interval: "weekly"
|
||||
day: "sunday"
|
||||
labels: []
|
||||
36
.github/dependencies.yml
vendored
36
.github/dependencies.yml
vendored
|
|
@ -2,15 +2,43 @@ dependencies:
|
|||
plugins/gitfast:
|
||||
repo: felipec/git-completion
|
||||
branch: master
|
||||
version: tag:v2.0
|
||||
version: tag:v2.2
|
||||
postcopy: |
|
||||
set -e
|
||||
rm -rf git-completion.plugin.zsh Makefile README.adoc t tools
|
||||
test -e git-completion.zsh && mv -f git-completion.zsh _git
|
||||
rm -rf git-completion.plugin.zsh Makefile t tools
|
||||
mv README.adoc MANUAL.adoc
|
||||
mv -f src/* .
|
||||
rmdir src
|
||||
plugins/gradle:
|
||||
repo: gradle/gradle-completion
|
||||
branch: master
|
||||
version: 25da917cf5a88f3e58f05be3868a7b2748c8afe6
|
||||
precopy: |
|
||||
set -e
|
||||
find . ! -name _gradle ! -name LICENSE -delete
|
||||
plugins/history-substring-search:
|
||||
repo: zsh-users/zsh-history-substring-search
|
||||
branch: master
|
||||
version: 87ce96b1862928d84b1afe7c173316614b30e301
|
||||
precopy: |
|
||||
set -e
|
||||
rm -f zsh-history-substring-search.plugin.zsh
|
||||
test -e zsh-history-substring-search.zsh && mv zsh-history-substring-search.zsh history-substring-search.zsh
|
||||
postcopy: |
|
||||
set -e
|
||||
test -e dependencies/OMZ-README.md && cat dependencies/OMZ-README.md >> README.md
|
||||
plugins/wd:
|
||||
repo: mfaerevaag/wd
|
||||
branch: master
|
||||
version: tag:v0.10.0
|
||||
precopy: |
|
||||
set -e
|
||||
rm -r test
|
||||
rm install.sh tty.gif wd.1
|
||||
plugins/z:
|
||||
branch: master
|
||||
repo: agkozak/zsh-z
|
||||
version: afaf2965b41fdc6ca66066e09382726aa0b6aa04
|
||||
version: cf9225feebfae55e557e103e95ce20eca5eff270
|
||||
precopy: |
|
||||
set -e
|
||||
test -e README.md && mv -f README.md MANUAL.md
|
||||
|
|
|
|||
11
.github/workflows/dependencies.yml
vendored
11
.github/workflows/dependencies.yml
vendored
|
|
@ -1,8 +1,8 @@
|
|||
name: Update dependencies
|
||||
on:
|
||||
workflow_dispatch: {}
|
||||
# schedule:
|
||||
# - cron: '34 3 * * */8'
|
||||
schedule:
|
||||
- cron: "0 6 * * 0"
|
||||
|
||||
jobs:
|
||||
check:
|
||||
|
|
@ -12,12 +12,19 @@ jobs:
|
|||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- name: Authenticate as @ohmyzsh
|
||||
id: generate_token
|
||||
uses: ohmyzsh/github-app-token@v2
|
||||
with:
|
||||
app_id: ${{ secrets.OHMYZSH_APP_ID }}
|
||||
private_key: ${{ secrets.OHMYZSH_APP_PRIVATE_KEY }}
|
||||
- name: Setup Python
|
||||
uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: "3.12"
|
||||
cache: "pip"
|
||||
- name: Process dependencies
|
||||
env:
|
||||
GH_TOKEN: ${{ steps.generate_token.outputs.token }}
|
||||
|
|
|
|||
1
.github/workflows/dependencies/.gitignore
vendored
Normal file
1
.github/workflows/dependencies/.gitignore
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
.venv
|
||||
|
|
@ -1,2 +1,7 @@
|
|||
PyYAML~=6.0.1
|
||||
requests~=2.31.0
|
||||
certifi==2025.4.26
|
||||
charset-normalizer==3.4.2
|
||||
idna==3.10
|
||||
PyYAML==6.0.2
|
||||
requests==2.32.3
|
||||
semver==3.0.4
|
||||
urllib3==2.4.0
|
||||
|
|
|
|||
810
.github/workflows/dependencies/updater.py
vendored
810
.github/workflows/dependencies/updater.py
vendored
|
|
@ -1,11 +1,16 @@
|
|||
import json
|
||||
import os
|
||||
import re
|
||||
import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
import requests
|
||||
import shutil
|
||||
import yaml
|
||||
import timeit
|
||||
from copy import deepcopy
|
||||
from typing import Optional, TypedDict
|
||||
from typing import Literal, NotRequired, Optional, TypedDict
|
||||
|
||||
import requests
|
||||
import yaml
|
||||
from semver import Version
|
||||
|
||||
# Get TMP_DIR variable from environment
|
||||
TMP_DIR = os.path.join(os.environ.get("TMP_DIR", "/tmp"), "ohmyzsh")
|
||||
|
|
@ -14,28 +19,58 @@ DEPS_YAML_FILE = ".github/dependencies.yml"
|
|||
# Dry run flag
|
||||
DRY_RUN = os.environ.get("DRY_RUN", "0") == "1"
|
||||
|
||||
import timeit
|
||||
# utils for tag comparison
|
||||
BASEVERSION = re.compile(
|
||||
r"""[vV]?
|
||||
(?P<major>(0|[1-9])\d*)
|
||||
(\.
|
||||
(?P<minor>(0|[1-9])\d*)
|
||||
(\.
|
||||
(?P<patch>(0|[1-9])\d*)
|
||||
)?
|
||||
)?
|
||||
""",
|
||||
re.VERBOSE,
|
||||
)
|
||||
|
||||
|
||||
def coerce(version: str) -> Optional[Version]:
|
||||
match = BASEVERSION.search(version)
|
||||
if not match:
|
||||
return None
|
||||
|
||||
# BASEVERSION looks for `MAJOR.minor.patch` in the string given
|
||||
# it fills with None if any of them is missing (for example `2.1`)
|
||||
ver = {
|
||||
key: 0 if value is None else value for key, value in match.groupdict().items()
|
||||
}
|
||||
# Version takes `major`, `minor`, `patch` arguments
|
||||
ver = Version(**ver) # pyright: ignore[reportArgumentType]
|
||||
return ver
|
||||
|
||||
|
||||
class CodeTimer:
|
||||
def __init__(self, name=None):
|
||||
self.name = " '" + name + "'" if name else ''
|
||||
def __init__(self, name=None):
|
||||
self.name = " '" + name + "'" if name else ""
|
||||
|
||||
def __enter__(self):
|
||||
self.start = timeit.default_timer()
|
||||
def __enter__(self):
|
||||
self.start = timeit.default_timer()
|
||||
|
||||
def __exit__(self, exc_type, exc_value, traceback):
|
||||
self.took = (timeit.default_timer() - self.start) * 1000.0
|
||||
print('Code block' + self.name + ' took: ' + str(self.took) + ' ms')
|
||||
def __exit__(self, exc_type, exc_value, traceback):
|
||||
self.took = (timeit.default_timer() - self.start) * 1000.0
|
||||
print("Code block" + self.name + " took: " + str(self.took) + " ms")
|
||||
|
||||
|
||||
### YAML representation
|
||||
def str_presenter(dumper, data):
|
||||
"""
|
||||
Configures yaml for dumping multiline strings
|
||||
Ref: https://stackoverflow.com/a/33300001
|
||||
"""
|
||||
if len(data.splitlines()) > 1: # check for multiline string
|
||||
return dumper.represent_scalar('tag:yaml.org,2002:str', data, style='|')
|
||||
return dumper.represent_scalar('tag:yaml.org,2002:str', data)
|
||||
"""
|
||||
Configures yaml for dumping multiline strings
|
||||
Ref: https://stackoverflow.com/a/33300001
|
||||
"""
|
||||
if len(data.splitlines()) > 1: # check for multiline string
|
||||
return dumper.represent_scalar("tag:yaml.org,2002:str", data, style="|")
|
||||
return dumper.represent_scalar("tag:yaml.org,2002:str", data)
|
||||
|
||||
|
||||
yaml.add_representer(str, str_presenter)
|
||||
yaml.representer.SafeRepresenter.add_representer(str, str_presenter)
|
||||
|
|
@ -43,408 +78,521 @@ yaml.representer.SafeRepresenter.add_representer(str, str_presenter)
|
|||
|
||||
# Types
|
||||
class DependencyDict(TypedDict):
|
||||
repo: str
|
||||
branch: str
|
||||
version: str
|
||||
precopy: Optional[str]
|
||||
postcopy: Optional[str]
|
||||
repo: str
|
||||
branch: str
|
||||
version: str
|
||||
precopy: NotRequired[str]
|
||||
postcopy: NotRequired[str]
|
||||
|
||||
|
||||
class DependencyYAML(TypedDict):
|
||||
dependencies: dict[str, DependencyDict]
|
||||
dependencies: dict[str, DependencyDict]
|
||||
|
||||
class UpdateStatus(TypedDict):
|
||||
has_updates: bool
|
||||
version: Optional[str]
|
||||
compare_url: Optional[str]
|
||||
head_ref: Optional[str]
|
||||
head_url: Optional[str]
|
||||
|
||||
class UpdateStatusFalse(TypedDict):
|
||||
has_updates: Literal[False]
|
||||
|
||||
|
||||
class UpdateStatusTrue(TypedDict):
|
||||
has_updates: Literal[True]
|
||||
version: str
|
||||
compare_url: str
|
||||
head_ref: str
|
||||
head_url: str
|
||||
|
||||
|
||||
class CommandRunner:
|
||||
class Exception(Exception):
|
||||
def __init__(self, message, returncode, stage, stdout, stderr):
|
||||
super().__init__(message)
|
||||
self.returncode = returncode
|
||||
self.stage = stage
|
||||
self.stdout = stdout
|
||||
self.stderr = stderr
|
||||
class Exception(Exception):
|
||||
def __init__(self, message, returncode, stage, stdout, stderr):
|
||||
super().__init__(message)
|
||||
self.returncode = returncode
|
||||
self.stage = stage
|
||||
self.stdout = stdout
|
||||
self.stderr = stderr
|
||||
|
||||
@staticmethod
|
||||
def run_or_fail(command: list[str], stage: str, *args, **kwargs):
|
||||
if DRY_RUN and command[0] == "gh":
|
||||
command.insert(0, "echo")
|
||||
@staticmethod
|
||||
def run_or_fail(command: list[str], stage: str, *args, **kwargs):
|
||||
if DRY_RUN and command[0] == "gh":
|
||||
command.insert(0, "echo")
|
||||
|
||||
result = subprocess.run(command, *args, capture_output=True, **kwargs)
|
||||
result = subprocess.run(command, *args, capture_output=True, **kwargs)
|
||||
|
||||
if result.returncode != 0:
|
||||
raise CommandRunner.Exception(
|
||||
f"{stage} command failed with exit code {result.returncode}", returncode=result.returncode,
|
||||
stage=stage,
|
||||
stdout=result.stdout.decode("utf-8"),
|
||||
stderr=result.stderr.decode("utf-8")
|
||||
)
|
||||
if result.returncode != 0:
|
||||
raise CommandRunner.Exception(
|
||||
f"{stage} command failed with exit code {result.returncode}",
|
||||
returncode=result.returncode,
|
||||
stage=stage,
|
||||
stdout=result.stdout.decode("utf-8"),
|
||||
stderr=result.stderr.decode("utf-8"),
|
||||
)
|
||||
|
||||
return result
|
||||
return result
|
||||
|
||||
|
||||
class DependencyStore:
|
||||
store: DependencyYAML = {
|
||||
"dependencies": {}
|
||||
}
|
||||
store: DependencyYAML = {"dependencies": {}}
|
||||
|
||||
@staticmethod
|
||||
def set(data: DependencyYAML):
|
||||
DependencyStore.store = data
|
||||
@staticmethod
|
||||
def set(data: DependencyYAML):
|
||||
DependencyStore.store = data
|
||||
|
||||
@staticmethod
|
||||
def update_dependency_version(path: str, version: str) -> DependencyYAML:
|
||||
with CodeTimer(f"store deepcopy: {path}"):
|
||||
store_copy = deepcopy(DependencyStore.store)
|
||||
@staticmethod
|
||||
def update_dependency_version(path: str, version: str) -> DependencyYAML:
|
||||
with CodeTimer(f"store deepcopy: {path}"):
|
||||
store_copy = deepcopy(DependencyStore.store)
|
||||
|
||||
dependency = store_copy["dependencies"].get(path, {})
|
||||
dependency["version"] = version
|
||||
store_copy["dependencies"][path] = dependency
|
||||
dependency = store_copy["dependencies"].get(path)
|
||||
if dependency is None:
|
||||
raise ValueError(f"Dependency {path} {version} not found")
|
||||
dependency["version"] = version
|
||||
store_copy["dependencies"][path] = dependency
|
||||
|
||||
return store_copy
|
||||
return store_copy
|
||||
|
||||
@staticmethod
|
||||
def write_store(file: str, data: DependencyYAML):
|
||||
with open(file, "w") as yaml_file:
|
||||
yaml.safe_dump(data, yaml_file, sort_keys=False)
|
||||
@staticmethod
|
||||
def write_store(file: str, data: DependencyYAML):
|
||||
with open(file, "w") as yaml_file:
|
||||
yaml.safe_dump(data, yaml_file, sort_keys=False)
|
||||
|
||||
|
||||
class Dependency:
|
||||
def __init__(self, path: str, values: DependencyDict):
|
||||
self.path = path
|
||||
self.values = values
|
||||
def __init__(self, path: str, values: DependencyDict):
|
||||
self.path = path
|
||||
self.values = values
|
||||
|
||||
self.name: str = ""
|
||||
self.desc: str = ""
|
||||
self.kind: str = ""
|
||||
self.name: str = ""
|
||||
self.desc: str = ""
|
||||
self.kind: str = ""
|
||||
|
||||
match path.split("/"):
|
||||
case ["plugins", name]:
|
||||
self.name = name
|
||||
self.kind = "plugin"
|
||||
self.desc = f"{name} plugin"
|
||||
case ["themes", name]:
|
||||
self.name = name.replace(".zsh-theme", "")
|
||||
self.kind = "theme"
|
||||
self.desc = f"{self.name} theme"
|
||||
case _:
|
||||
self.name = self.desc = path
|
||||
match path.split("/"):
|
||||
case ["plugins", name]:
|
||||
self.name = name
|
||||
self.kind = "plugin"
|
||||
self.desc = f"{name} plugin"
|
||||
case ["themes", name]:
|
||||
self.name = name.replace(".zsh-theme", "")
|
||||
self.kind = "theme"
|
||||
self.desc = f"{self.name} theme"
|
||||
case _:
|
||||
self.name = self.desc = path
|
||||
|
||||
def __str__(self):
|
||||
output: str = ""
|
||||
for key in DependencyDict.__dict__['__annotations__'].keys():
|
||||
if key not in self.values:
|
||||
output += f"{key}: None\n"
|
||||
continue
|
||||
def __str__(self):
|
||||
output: str = ""
|
||||
for key in DependencyDict.__dict__["__annotations__"].keys():
|
||||
if key not in self.values:
|
||||
output += f"{key}: None\n"
|
||||
continue
|
||||
|
||||
value = self.values[key]
|
||||
if "\n" not in value:
|
||||
output += f"{key}: {value}\n"
|
||||
else:
|
||||
output += f"{key}:\n "
|
||||
output += value.replace("\n", "\n ", value.count("\n") - 1)
|
||||
return output
|
||||
value = self.values[key]
|
||||
if "\n" not in value:
|
||||
output += f"{key}: {value}\n"
|
||||
else:
|
||||
output += f"{key}:\n "
|
||||
output += value.replace("\n", "\n ", value.count("\n") - 1)
|
||||
return output
|
||||
|
||||
def update_or_notify(self):
|
||||
# Print dependency settings
|
||||
print(f"Processing {self.desc}...", file=sys.stderr)
|
||||
print(self, file=sys.stderr)
|
||||
def update_or_notify(self):
|
||||
# Print dependency settings
|
||||
print(f"Processing {self.desc}...", file=sys.stderr)
|
||||
print(self, file=sys.stderr)
|
||||
|
||||
# Check for updates
|
||||
repo = self.values["repo"]
|
||||
remote_branch = self.values["branch"]
|
||||
version = self.values["version"]
|
||||
is_tag = version.startswith("tag:")
|
||||
|
||||
try:
|
||||
with CodeTimer(f"update check: {repo}"):
|
||||
if is_tag:
|
||||
status = GitHub.check_newer_tag(repo, version.replace("tag:", ""))
|
||||
else:
|
||||
status = GitHub.check_updates(repo, remote_branch, version)
|
||||
|
||||
if status["has_updates"]:
|
||||
short_sha = status["head_ref"][:8]
|
||||
new_version = status["version"] if is_tag else short_sha
|
||||
# Check for updates
|
||||
repo = self.values["repo"]
|
||||
remote_branch = self.values["branch"]
|
||||
version = self.values["version"]
|
||||
is_tag = version.startswith("tag:")
|
||||
|
||||
try:
|
||||
# Create new branch
|
||||
branch = Git.create_branch(self.path, new_version)
|
||||
with CodeTimer(f"update check: {repo}"):
|
||||
if is_tag:
|
||||
status = GitHub.check_newer_tag(repo, version.replace("tag:", ""))
|
||||
else:
|
||||
status = GitHub.check_updates(repo, remote_branch, version)
|
||||
|
||||
# Update dependencies.yml file
|
||||
self.__update_yaml(f"tag:{new_version}" if is_tag else status["version"])
|
||||
if status["has_updates"] is True:
|
||||
short_sha = status["head_ref"][:8]
|
||||
new_version = status["version"] if is_tag else short_sha
|
||||
|
||||
# Update dependency files
|
||||
self.__apply_upstream_changes()
|
||||
try:
|
||||
branch_name = f"update/{self.path}/{new_version}"
|
||||
|
||||
# Add all changes and commit
|
||||
Git.add_and_commit(self.name, short_sha)
|
||||
# Create new branch
|
||||
branch = Git.checkout_or_create_branch(branch_name)
|
||||
|
||||
# Push changes to remote
|
||||
Git.push(branch)
|
||||
# Update dependencies.yml file
|
||||
self.__update_yaml(
|
||||
f"tag:{new_version}" if is_tag else status["version"]
|
||||
)
|
||||
|
||||
# Create GitHub PR
|
||||
GitHub.create_pr(
|
||||
branch,
|
||||
f"feat({self.name}): update to version {new_version}",
|
||||
f"""## Description
|
||||
# Update dependency files
|
||||
self.__apply_upstream_changes()
|
||||
|
||||
# Add all changes and commit
|
||||
has_new_commit = Git.add_and_commit(self.name, new_version)
|
||||
|
||||
if has_new_commit:
|
||||
# Push changes to remote
|
||||
Git.push(branch)
|
||||
|
||||
# Create GitHub PR
|
||||
GitHub.create_pr(
|
||||
branch,
|
||||
f"feat({self.name}): update to version {new_version}",
|
||||
f"""## Description
|
||||
|
||||
Update for **{self.desc}**: update to version [{new_version}]({status['head_url']}).
|
||||
Check out the [list of changes]({status['compare_url']}).
|
||||
"""
|
||||
)
|
||||
""",
|
||||
)
|
||||
|
||||
# Clean up repository
|
||||
Git.clean_repo()
|
||||
except (CommandRunner.Exception, shutil.Error) as e:
|
||||
# Handle exception on automatic update
|
||||
match type(e):
|
||||
case CommandRunner.Exception:
|
||||
# Print error message
|
||||
print(f"Error running {e.stage} command: {e.returncode}", file=sys.stderr)
|
||||
print(e.stderr, file=sys.stderr)
|
||||
case shutil.Error:
|
||||
print(f"Error copying files: {e}", file=sys.stderr)
|
||||
# Clean up repository
|
||||
Git.clean_repo()
|
||||
except (CommandRunner.Exception, shutil.Error) as e:
|
||||
# Handle exception on automatic update
|
||||
match type(e):
|
||||
case CommandRunner.Exception:
|
||||
# Print error message
|
||||
print(
|
||||
f"Error running {e.stage} command: {e.returncode}", # pyright: ignore[reportAttributeAccessIssue]
|
||||
file=sys.stderr,
|
||||
)
|
||||
print(e.stderr, file=sys.stderr) # pyright: ignore[reportAttributeAccessIssue]
|
||||
case shutil.Error:
|
||||
print(f"Error copying files: {e}", file=sys.stderr)
|
||||
|
||||
try:
|
||||
Git.clean_repo()
|
||||
except CommandRunner.Exception as e:
|
||||
print(f"Error reverting repository to clean state: {e}", file=sys.stderr)
|
||||
sys.exit(1)
|
||||
try:
|
||||
Git.clean_repo()
|
||||
except CommandRunner.Exception as e:
|
||||
print(
|
||||
f"Error reverting repository to clean state: {e}",
|
||||
file=sys.stderr,
|
||||
)
|
||||
sys.exit(1)
|
||||
|
||||
# Create a GitHub issue to notify maintainer
|
||||
title = f"{self.path}: update to {new_version}"
|
||||
body = (
|
||||
f"""## Description
|
||||
# Create a GitHub issue to notify maintainer
|
||||
title = f"{self.path}: update to {new_version}"
|
||||
body = f"""## Description
|
||||
|
||||
There is a new version of `{self.name}` {self.kind} available.
|
||||
|
||||
New version: [{new_version}]({status['head_url']})
|
||||
Check out the [list of changes]({status['compare_url']}).
|
||||
"""
|
||||
)
|
||||
|
||||
print(f"Creating GitHub issue", file=sys.stderr)
|
||||
print(f"{title}\n\n{body}", file=sys.stderr)
|
||||
GitHub.create_issue(title, body)
|
||||
except Exception as e:
|
||||
print(e, file=sys.stderr)
|
||||
print("Creating GitHub issue", file=sys.stderr)
|
||||
print(f"{title}\n\n{body}", file=sys.stderr)
|
||||
GitHub.create_issue(title, body)
|
||||
except Exception as e:
|
||||
print(e, file=sys.stderr)
|
||||
|
||||
def __update_yaml(self, new_version: str) -> None:
|
||||
dep_yaml = DependencyStore.update_dependency_version(self.path, new_version)
|
||||
DependencyStore.write_store(DEPS_YAML_FILE, dep_yaml)
|
||||
def __update_yaml(self, new_version: str) -> None:
|
||||
dep_yaml = DependencyStore.update_dependency_version(self.path, new_version)
|
||||
DependencyStore.write_store(DEPS_YAML_FILE, dep_yaml)
|
||||
|
||||
def __apply_upstream_changes(self) -> None:
|
||||
# Patterns to ignore in copying files from upstream repo
|
||||
GLOBAL_IGNORE = [
|
||||
".git",
|
||||
".github",
|
||||
".gitignore"
|
||||
]
|
||||
def __apply_upstream_changes(self) -> None:
|
||||
# Patterns to ignore in copying files from upstream repo
|
||||
GLOBAL_IGNORE = [".git", ".github", ".gitignore"]
|
||||
|
||||
path = os.path.abspath(self.path)
|
||||
precopy = self.values.get("precopy")
|
||||
postcopy = self.values.get("postcopy")
|
||||
path = os.path.abspath(self.path)
|
||||
precopy = self.values.get("precopy")
|
||||
postcopy = self.values.get("postcopy")
|
||||
|
||||
repo = self.values["repo"]
|
||||
branch = self.values["branch"]
|
||||
remote_url = f"https://github.com/{repo}.git"
|
||||
repo_dir = os.path.join(TMP_DIR, repo)
|
||||
repo = self.values["repo"]
|
||||
branch = self.values["branch"]
|
||||
remote_url = f"https://github.com/{repo}.git"
|
||||
repo_dir = os.path.join(TMP_DIR, repo)
|
||||
|
||||
# Clone repository
|
||||
Git.clone(remote_url, branch, repo_dir, reclone=True)
|
||||
# Clone repository
|
||||
Git.clone(remote_url, branch, repo_dir, reclone=True)
|
||||
|
||||
# Run precopy on tmp repo
|
||||
if precopy is not None:
|
||||
print("Running precopy script:", end="\n ", file=sys.stderr)
|
||||
print(precopy.replace("\n", "\n ", precopy.count("\n") - 1), file=sys.stderr)
|
||||
CommandRunner.run_or_fail(["bash", "-c", precopy], cwd=repo_dir, stage="Precopy")
|
||||
# Run precopy on tmp repo
|
||||
if precopy is not None:
|
||||
print("Running precopy script:", end="\n ", file=sys.stderr)
|
||||
print(
|
||||
precopy.replace("\n", "\n ", precopy.count("\n") - 1), file=sys.stderr
|
||||
)
|
||||
CommandRunner.run_or_fail(
|
||||
["bash", "-c", precopy], cwd=repo_dir, stage="Precopy"
|
||||
)
|
||||
|
||||
# Copy files from upstream repo
|
||||
print(f"Copying files from {repo_dir} to {path}", file=sys.stderr)
|
||||
shutil.copytree(repo_dir, path, dirs_exist_ok=True, ignore=shutil.ignore_patterns(*GLOBAL_IGNORE))
|
||||
# Copy files from upstream repo
|
||||
print(f"Copying files from {repo_dir} to {path}", file=sys.stderr)
|
||||
shutil.copytree(
|
||||
repo_dir,
|
||||
path,
|
||||
dirs_exist_ok=True,
|
||||
ignore=shutil.ignore_patterns(*GLOBAL_IGNORE),
|
||||
)
|
||||
|
||||
# Run postcopy on our repository
|
||||
if postcopy is not None:
|
||||
print("Running postcopy script:", end="\n ", file=sys.stderr)
|
||||
print(postcopy.replace("\n", "\n ", postcopy.count("\n") - 1), file=sys.stderr)
|
||||
CommandRunner.run_or_fail(["bash", "-c", postcopy], cwd=path, stage="Postcopy")
|
||||
# Run postcopy on our repository
|
||||
if postcopy is not None:
|
||||
print("Running postcopy script:", end="\n ", file=sys.stderr)
|
||||
print(
|
||||
postcopy.replace("\n", "\n ", postcopy.count("\n") - 1),
|
||||
file=sys.stderr,
|
||||
)
|
||||
CommandRunner.run_or_fail(
|
||||
["bash", "-c", postcopy], cwd=path, stage="Postcopy"
|
||||
)
|
||||
|
||||
|
||||
class Git:
|
||||
default_branch = "master"
|
||||
default_branch = "master"
|
||||
|
||||
@staticmethod
|
||||
def clone(remote_url: str, branch: str, repo_dir: str, reclone=False):
|
||||
# If repo needs to be fresh
|
||||
if reclone and os.path.exists(repo_dir):
|
||||
shutil.rmtree(repo_dir)
|
||||
@staticmethod
|
||||
def clone(remote_url: str, branch: str, repo_dir: str, reclone=False):
|
||||
# If repo needs to be fresh
|
||||
if reclone and os.path.exists(repo_dir):
|
||||
shutil.rmtree(repo_dir)
|
||||
|
||||
# Clone repo in tmp directory and checkout branch
|
||||
if not os.path.exists(repo_dir):
|
||||
print(f"Cloning {remote_url} to {repo_dir} and checking out {branch}", file=sys.stderr)
|
||||
CommandRunner.run_or_fail(["git", "clone", "--depth=1", "-b", branch, remote_url, repo_dir], stage="Clone")
|
||||
# Clone repo in tmp directory and checkout branch
|
||||
if not os.path.exists(repo_dir):
|
||||
print(
|
||||
f"Cloning {remote_url} to {repo_dir} and checking out {branch}",
|
||||
file=sys.stderr,
|
||||
)
|
||||
CommandRunner.run_or_fail(
|
||||
["git", "clone", "--depth=1", "-b", branch, remote_url, repo_dir],
|
||||
stage="Clone",
|
||||
)
|
||||
|
||||
@staticmethod
|
||||
def create_branch(path: str, version: str):
|
||||
# Get current branch name
|
||||
result = CommandRunner.run_or_fail(["git", "rev-parse", "--abbrev-ref", "HEAD"], stage="GetDefaultBranch")
|
||||
Git.default_branch = result.stdout.decode("utf-8").strip()
|
||||
@staticmethod
|
||||
def checkout_or_create_branch(branch_name: str):
|
||||
# Get current branch name
|
||||
result = CommandRunner.run_or_fail(
|
||||
["git", "rev-parse", "--abbrev-ref", "HEAD"], stage="GetDefaultBranch"
|
||||
)
|
||||
Git.default_branch = result.stdout.decode("utf-8").strip()
|
||||
|
||||
# Create new branch and return created branch name
|
||||
branch_name = f"update/{path}/{version}"
|
||||
CommandRunner.run_or_fail(["git", "checkout", "-b", branch_name], stage="CreateBranch")
|
||||
return branch_name
|
||||
# Create new branch and return created branch name
|
||||
try:
|
||||
# try to checkout already existing branch
|
||||
CommandRunner.run_or_fail(
|
||||
["git", "checkout", branch_name], stage="CreateBranch"
|
||||
)
|
||||
except CommandRunner.Exception:
|
||||
# otherwise create new branch
|
||||
CommandRunner.run_or_fail(
|
||||
["git", "checkout", "-b", branch_name], stage="CreateBranch"
|
||||
)
|
||||
return branch_name
|
||||
|
||||
@staticmethod
|
||||
def add_and_commit(scope: str, version: str):
|
||||
user_name = os.environ.get("GIT_APP_NAME")
|
||||
user_email = os.environ.get("GIT_APP_EMAIL")
|
||||
@staticmethod
|
||||
def add_and_commit(scope: str, version: str) -> bool:
|
||||
"""
|
||||
Returns `True` if there were changes and were indeed commited.
|
||||
Returns `False` if the repo was clean and no changes were commited.
|
||||
"""
|
||||
# check if repo is clean (clean => no error, no commit)
|
||||
try:
|
||||
CommandRunner.run_or_fail(
|
||||
["git", "diff", "--exit-code"], stage="CheckRepoClean"
|
||||
)
|
||||
return False
|
||||
except CommandRunner.Exception:
|
||||
# if it's other kind of error just throw!
|
||||
pass
|
||||
|
||||
# Add all files to git staging
|
||||
CommandRunner.run_or_fail(["git", "add", "-A", "-v"], stage="AddFiles")
|
||||
user_name = os.environ.get("GIT_APP_NAME")
|
||||
user_email = os.environ.get("GIT_APP_EMAIL")
|
||||
|
||||
# Reset environment and git config
|
||||
clean_env = os.environ.copy()
|
||||
clean_env["LANG"]="C.UTF-8"
|
||||
clean_env["GIT_CONFIG_GLOBAL"]="/dev/null"
|
||||
clean_env["GIT_CONFIG_NOSYSTEM"]="1"
|
||||
# Add all files to git staging
|
||||
CommandRunner.run_or_fail(["git", "add", "-A", "-v"], stage="AddFiles")
|
||||
|
||||
# Commit with settings above
|
||||
CommandRunner.run_or_fail([
|
||||
"git",
|
||||
"-c", f"user.name={user_name}",
|
||||
"-c", f"user.email={user_email}",
|
||||
"commit",
|
||||
"-m", f"feat({scope}): update to {version}"
|
||||
], stage="CreateCommit", env=clean_env)
|
||||
# Reset environment and git config
|
||||
clean_env = os.environ.copy()
|
||||
clean_env["LANG"] = "C.UTF-8"
|
||||
clean_env["GIT_CONFIG_GLOBAL"] = "/dev/null"
|
||||
clean_env["GIT_CONFIG_NOSYSTEM"] = "1"
|
||||
|
||||
@staticmethod
|
||||
def push(branch: str):
|
||||
CommandRunner.run_or_fail(["git", "push", "-u", "origin", branch], stage="PushBranch")
|
||||
# Commit with settings above
|
||||
CommandRunner.run_or_fail(
|
||||
[
|
||||
"git",
|
||||
"-c",
|
||||
f"user.name={user_name}",
|
||||
"-c",
|
||||
f"user.email={user_email}",
|
||||
"commit",
|
||||
"-m",
|
||||
f"feat({scope}): update to {version}",
|
||||
],
|
||||
stage="CreateCommit",
|
||||
env=clean_env,
|
||||
)
|
||||
return True
|
||||
|
||||
@staticmethod
|
||||
def clean_repo():
|
||||
CommandRunner.run_or_fail(["git", "reset", "--hard", "HEAD"], stage="ResetRepository")
|
||||
CommandRunner.run_or_fail(["git", "checkout", Git.default_branch], stage="CheckoutDefaultBranch")
|
||||
@staticmethod
|
||||
def push(branch: str):
|
||||
CommandRunner.run_or_fail(
|
||||
["git", "push", "-u", "origin", branch], stage="PushBranch"
|
||||
)
|
||||
|
||||
@staticmethod
|
||||
def clean_repo():
|
||||
CommandRunner.run_or_fail(
|
||||
["git", "reset", "--hard", "HEAD"], stage="ResetRepository"
|
||||
)
|
||||
CommandRunner.run_or_fail(
|
||||
["git", "checkout", Git.default_branch], stage="CheckoutDefaultBranch"
|
||||
)
|
||||
|
||||
|
||||
class GitHub:
|
||||
@staticmethod
|
||||
def check_newer_tag(repo, current_tag) -> UpdateStatus:
|
||||
# GET /repos/:owner/:repo/git/refs/tags
|
||||
url = f"https://api.github.com/repos/{repo}/git/refs/tags"
|
||||
@staticmethod
|
||||
def check_newer_tag(repo, current_tag) -> UpdateStatusFalse | UpdateStatusTrue:
|
||||
# GET /repos/:owner/:repo/git/refs/tags
|
||||
url = f"https://api.github.com/repos/{repo}/git/refs/tags"
|
||||
|
||||
# Send a GET request to the GitHub API
|
||||
response = requests.get(url)
|
||||
# Send a GET request to the GitHub API
|
||||
response = requests.get(url)
|
||||
current_version = coerce(current_tag)
|
||||
if current_version is None:
|
||||
raise ValueError(
|
||||
f"Stored {current_version} from {repo} does not follow semver"
|
||||
)
|
||||
|
||||
# If the request was successful
|
||||
if response.status_code == 200:
|
||||
# Parse the JSON response
|
||||
data = response.json()
|
||||
# If the request was successful
|
||||
if response.status_code == 200:
|
||||
# Parse the JSON response
|
||||
data = response.json()
|
||||
|
||||
if len(data) == 0:
|
||||
return {
|
||||
"has_updates": False,
|
||||
}
|
||||
if len(data) == 0:
|
||||
return {
|
||||
"has_updates": False,
|
||||
}
|
||||
|
||||
latest_ref = data[-1]
|
||||
latest_tag = latest_ref["ref"].replace("refs/tags/", "")
|
||||
latest_ref = None
|
||||
latest_version: Optional[Version] = None
|
||||
for ref in data:
|
||||
# we find the tag since GitHub returns it as plain git ref
|
||||
tag_version = coerce(ref["ref"].replace("refs/tags/", ""))
|
||||
if tag_version is None:
|
||||
# we skip every tag that is not semver-complaint
|
||||
continue
|
||||
if latest_version is None or tag_version.compare(latest_version) > 0:
|
||||
# if we have a "greater" semver version, set it as latest
|
||||
latest_version = tag_version
|
||||
latest_ref = ref
|
||||
|
||||
if latest_tag == current_tag:
|
||||
return {
|
||||
"has_updates": False,
|
||||
}
|
||||
# raise if no valid semver tag is found
|
||||
if latest_ref is None or latest_version is None:
|
||||
raise ValueError(f"No tags following semver found in {repo}")
|
||||
|
||||
return {
|
||||
"has_updates": True,
|
||||
"version": latest_tag,
|
||||
"compare_url": f"https://github.com/{repo}/compare/{current_tag}...{latest_tag}",
|
||||
"head_ref": latest_ref["object"]["sha"],
|
||||
"head_url": f"https://github.com/{repo}/releases/tag/{latest_tag}",
|
||||
}
|
||||
else:
|
||||
# If the request was not successful, raise an exception
|
||||
raise Exception(f"GitHub API request failed with status code {response.status_code}: {response.json()}")
|
||||
# we get the tag since GitHub returns it as plain git ref
|
||||
latest_tag = latest_ref["ref"].replace("refs/tags/", "")
|
||||
|
||||
@staticmethod
|
||||
def check_updates(repo, branch, version) -> UpdateStatus:
|
||||
# TODO: add support for semver updating (based on tags)
|
||||
# Check if upstream github repo has a new version
|
||||
# GitHub API URL for comparing two commits
|
||||
url = f"https://api.github.com/repos/{repo}/compare/{version}...{branch}"
|
||||
if latest_version.compare(current_version) <= 0:
|
||||
return {
|
||||
"has_updates": False,
|
||||
}
|
||||
|
||||
# Send a GET request to the GitHub API
|
||||
response = requests.get(url)
|
||||
return {
|
||||
"has_updates": True,
|
||||
"version": latest_tag,
|
||||
"compare_url": f"https://github.com/{repo}/compare/{current_tag}...{latest_tag}",
|
||||
"head_ref": latest_ref["object"]["sha"],
|
||||
"head_url": f"https://github.com/{repo}/releases/tag/{latest_tag}",
|
||||
}
|
||||
else:
|
||||
# If the request was not successful, raise an exception
|
||||
raise Exception(
|
||||
f"GitHub API request failed with status code {response.status_code}: {response.json()}"
|
||||
)
|
||||
|
||||
# If the request was successful
|
||||
if response.status_code == 200:
|
||||
# Parse the JSON response
|
||||
data = response.json()
|
||||
@staticmethod
|
||||
def check_updates(repo, branch, version) -> UpdateStatusFalse | UpdateStatusTrue:
|
||||
url = f"https://api.github.com/repos/{repo}/compare/{version}...{branch}"
|
||||
|
||||
# If the base is behind the head, there is a newer version
|
||||
has_updates = data["status"] != "identical"
|
||||
# Send a GET request to the GitHub API
|
||||
response = requests.get(url)
|
||||
|
||||
if not has_updates:
|
||||
return {
|
||||
"has_updates": False,
|
||||
}
|
||||
# If the request was successful
|
||||
if response.status_code == 200:
|
||||
# Parse the JSON response
|
||||
data = response.json()
|
||||
|
||||
return {
|
||||
"has_updates": data["status"] != "identical",
|
||||
"version": data["commits"][-1]["sha"],
|
||||
"compare_url": data["permalink_url"],
|
||||
"head_ref": data["commits"][-1]["sha"],
|
||||
"head_url": data["commits"][-1]["html_url"]
|
||||
}
|
||||
else:
|
||||
# If the request was not successful, raise an exception
|
||||
raise Exception(f"GitHub API request failed with status code {response.status_code}: {response.json()}")
|
||||
# If the base is behind the head, there is a newer version
|
||||
has_updates = data["status"] != "identical"
|
||||
|
||||
@staticmethod
|
||||
def create_issue(title: str, body: str) -> None:
|
||||
cmd = [
|
||||
"gh",
|
||||
"issue",
|
||||
"create",
|
||||
"-t", title,
|
||||
"-b", body
|
||||
]
|
||||
CommandRunner.run_or_fail(cmd, stage="CreateIssue")
|
||||
if not has_updates:
|
||||
return {
|
||||
"has_updates": False,
|
||||
}
|
||||
|
||||
@staticmethod
|
||||
def create_pr(branch: str, title: str, body: str) -> None:
|
||||
cmd = [
|
||||
"gh",
|
||||
"pr",
|
||||
"create",
|
||||
"-B", Git.default_branch,
|
||||
"-H", branch,
|
||||
"-t", title,
|
||||
"-b", body
|
||||
]
|
||||
CommandRunner.run_or_fail(cmd, stage="CreatePullRequest")
|
||||
return {
|
||||
"has_updates": data["status"] != "identical",
|
||||
"version": data["commits"][-1]["sha"],
|
||||
"compare_url": data["permalink_url"],
|
||||
"head_ref": data["commits"][-1]["sha"],
|
||||
"head_url": data["commits"][-1]["html_url"],
|
||||
}
|
||||
else:
|
||||
# If the request was not successful, raise an exception
|
||||
raise Exception(
|
||||
f"GitHub API request failed with status code {response.status_code}: {response.json()}"
|
||||
)
|
||||
|
||||
@staticmethod
|
||||
def create_issue(title: str, body: str) -> None:
|
||||
cmd = ["gh", "issue", "create", "-t", title, "-b", body]
|
||||
CommandRunner.run_or_fail(cmd, stage="CreateIssue")
|
||||
|
||||
@staticmethod
|
||||
def create_pr(branch: str, title: str, body: str) -> None:
|
||||
# first of all let's check if PR is already open
|
||||
check_cmd = [
|
||||
"gh",
|
||||
"pr",
|
||||
"list",
|
||||
"--state",
|
||||
"open",
|
||||
"--head",
|
||||
branch,
|
||||
"--json",
|
||||
"title",
|
||||
]
|
||||
# returncode is 0 also if no PRs are found
|
||||
output = json.loads(
|
||||
CommandRunner.run_or_fail(check_cmd, stage="CheckPullRequestOpen")
|
||||
.stdout.decode("utf-8")
|
||||
.strip()
|
||||
)
|
||||
# we have PR in this case!
|
||||
if len(output) > 0:
|
||||
return
|
||||
cmd = [
|
||||
"gh",
|
||||
"pr",
|
||||
"create",
|
||||
"-B",
|
||||
Git.default_branch,
|
||||
"-H",
|
||||
branch,
|
||||
"-t",
|
||||
title,
|
||||
"-b",
|
||||
body,
|
||||
]
|
||||
CommandRunner.run_or_fail(cmd, stage="CreatePullRequest")
|
||||
|
||||
|
||||
def main():
|
||||
# Load the YAML file
|
||||
with open(DEPS_YAML_FILE, "r") as yaml_file:
|
||||
data: DependencyYAML = yaml.safe_load(yaml_file)
|
||||
# Load the YAML file
|
||||
with open(DEPS_YAML_FILE, "r") as yaml_file:
|
||||
data: DependencyYAML = yaml.safe_load(yaml_file)
|
||||
|
||||
if "dependencies" not in data:
|
||||
raise Exception(f"dependencies.yml not properly formatted")
|
||||
if "dependencies" not in data:
|
||||
raise Exception("dependencies.yml not properly formatted")
|
||||
|
||||
# Cache YAML version
|
||||
DependencyStore.set(data)
|
||||
# Cache YAML version
|
||||
DependencyStore.set(data)
|
||||
|
||||
dependencies = data["dependencies"]
|
||||
for path in dependencies:
|
||||
dependency = Dependency(path, dependencies[path])
|
||||
dependency.update_or_notify()
|
||||
|
||||
dependencies = data["dependencies"]
|
||||
for path in dependencies:
|
||||
dependency = Dependency(path, dependencies[path])
|
||||
dependency.update_or_notify()
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
main()
|
||||
|
|
|
|||
4
.github/workflows/installer.yml
vendored
4
.github/workflows/installer.yml
vendored
|
|
@ -26,7 +26,7 @@ jobs:
|
|||
- macos-latest
|
||||
steps:
|
||||
- name: Set up git repository
|
||||
uses: actions/checkout@v3
|
||||
uses: actions/checkout@v4
|
||||
- name: Install zsh
|
||||
if: runner.os == 'Linux'
|
||||
run: sudo apt-get update; sudo apt-get install zsh
|
||||
|
|
@ -42,7 +42,7 @@ jobs:
|
|||
- test
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
uses: actions/checkout@v4
|
||||
- name: Install Vercel CLI
|
||||
run: npm install -g vercel
|
||||
- name: Setup project and deploy
|
||||
|
|
|
|||
4
.github/workflows/installer/vercel.json
vendored
4
.github/workflows/installer/vercel.json
vendored
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"headers": [
|
||||
{
|
||||
"source": "/((?!favicon.ico).*)",
|
||||
"source": "/(|install.sh)",
|
||||
"headers": [
|
||||
{
|
||||
"key": "Content-Type",
|
||||
|
|
@ -16,7 +16,7 @@
|
|||
],
|
||||
"rewrites": [
|
||||
{
|
||||
"source": "/((?!favicon.ico|install.sh).*)",
|
||||
"source": "/",
|
||||
"destination": "/install.sh"
|
||||
}
|
||||
]
|
||||
|
|
|
|||
2
.github/workflows/main.yml
vendored
2
.github/workflows/main.yml
vendored
|
|
@ -24,7 +24,7 @@ jobs:
|
|||
if: github.repository == 'ohmyzsh/ohmyzsh'
|
||||
steps:
|
||||
- name: Set up git repository
|
||||
uses: actions/checkout@v3
|
||||
uses: actions/checkout@v4
|
||||
- name: Install zsh
|
||||
run: sudo apt-get update; sudo apt-get install zsh
|
||||
- name: Check syntax
|
||||
|
|
|
|||
3
.gitignore
vendored
3
.gitignore
vendored
|
|
@ -10,3 +10,6 @@ log/
|
|||
# editor configs
|
||||
.vscode
|
||||
.idea
|
||||
|
||||
# zcompile cached files
|
||||
*.zwc
|
||||
|
|
|
|||
253
README.md
253
README.md
|
|
@ -1,16 +1,21 @@
|
|||
<p align="center"><img src="https://ohmyzsh.s3.amazonaws.com/omz-ansi-github.png" alt="Oh My Zsh"></p>
|
||||
|
||||
Oh My Zsh is an open source, community-driven framework for managing your [zsh](https://www.zsh.org/) configuration.
|
||||
Oh My Zsh is an open source, community-driven framework for managing your [zsh](https://www.zsh.org/)
|
||||
configuration.
|
||||
|
||||
Sounds boring. Let's try again.
|
||||
|
||||
**Oh My Zsh will not make you a 10x developer...but you may feel like one.**
|
||||
|
||||
Once installed, your terminal shell will become the talk of the town _or your money back!_ With each keystroke in your command prompt, you'll take advantage of the hundreds of powerful plugins and beautiful themes. Strangers will come up to you in cafés and ask you, _"that is amazing! are you some sort of genius?"_
|
||||
Once installed, your terminal shell will become the talk of the town _or your money back!_ With each keystroke
|
||||
in your command prompt, you'll take advantage of the hundreds of powerful plugins and beautiful themes.
|
||||
Strangers will come up to you in cafés and ask you, _"that is amazing! are you some sort of genius?"_
|
||||
|
||||
Finally, you'll begin to get the sort of attention that you have always felt you deserved. ...or maybe you'll use the time that you're saving to start flossing more often. 😬
|
||||
Finally, you'll begin to get the sort of attention that you have always felt you deserved. ...or maybe you'll
|
||||
use the time that you're saving to start flossing more often. 😬
|
||||
|
||||
To learn more, visit [ohmyz.sh](https://ohmyz.sh), follow [@ohmyzsh](https://twitter.com/ohmyzsh) on Twitter, and join us on [Discord](https://discord.gg/ohmyzsh).
|
||||
To learn more, visit [ohmyz.sh](https://ohmyz.sh), follow [@ohmyzsh](https://x.com/ohmyzsh) on X (formerly
|
||||
Twitter), and join us on [Discord](https://discord.gg/ohmyzsh).
|
||||
|
||||
[](https://github.com/ohmyzsh/ohmyzsh/actions?query=workflow%3ACI)
|
||||
[](https://twitter.com/intent/follow?screen_name=ohmyzsh)
|
||||
|
|
@ -43,6 +48,7 @@ To learn more, visit [ohmyz.sh](https://ohmyz.sh), follow [@ohmyzsh](https://twi
|
|||
- [Custom Plugins And Themes](#custom-plugins-and-themes)
|
||||
- [Enable GNU ls In macOS And freeBSD Systems](#enable-gnu-ls-in-macos-and-freebsd-systems)
|
||||
- [Skip Aliases](#skip-aliases)
|
||||
- [Async git prompt](#async-git-prompt)
|
||||
- [Getting Updates](#getting-updates)
|
||||
- [Updates Verbosity](#updates-verbosity)
|
||||
- [Manual Updates](#manual-updates)
|
||||
|
|
@ -61,26 +67,28 @@ To learn more, visit [ohmyz.sh](https://ohmyz.sh), follow [@ohmyzsh](https://twi
|
|||
|
||||
### Operating System Compatibility
|
||||
|
||||
| O/S | Status |
|
||||
| :------------- | :-----: |
|
||||
| Android | ✅ |
|
||||
| freeBSD | ✅ |
|
||||
| LCARS | 🛸 |
|
||||
| Linux | ✅ |
|
||||
| macOS | ✅ |
|
||||
| OS/2 Warp | ❌ |
|
||||
| Windows (WSL2) | ✅ |
|
||||
|
||||
| O/S | Status |
|
||||
| :------------- | :----: |
|
||||
| Android | ✅ |
|
||||
| freeBSD | ✅ |
|
||||
| LCARS | 🛸 |
|
||||
| Linux | ✅ |
|
||||
| macOS | ✅ |
|
||||
| OS/2 Warp | ❌ |
|
||||
| Windows (WSL2) | ✅ |
|
||||
|
||||
### Prerequisites
|
||||
|
||||
- [Zsh](https://www.zsh.org) should be installed (v4.3.9 or more recent is fine but we prefer 5.0.8 and newer). If not pre-installed (run `zsh --version` to confirm), check the following wiki instructions here: [Installing ZSH](https://github.com/ohmyzsh/ohmyzsh/wiki/Installing-ZSH)
|
||||
- [Zsh](https://www.zsh.org) should be installed (v4.3.9 or more recent is fine but we prefer 5.0.8 and
|
||||
newer). If not pre-installed (run `zsh --version` to confirm), check the following wiki instructions here:
|
||||
[Installing ZSH](https://github.com/ohmyzsh/ohmyzsh/wiki/Installing-ZSH)
|
||||
- `curl` or `wget` should be installed
|
||||
- `git` should be installed (recommended v2.4.11 or higher)
|
||||
|
||||
### Basic Installation
|
||||
|
||||
Oh My Zsh is installed by running one of the following commands in your terminal. You can install this via the command-line with either `curl`, `wget` or another similar tool.
|
||||
Oh My Zsh is installed by running one of the following commands in your terminal. You can install this via the
|
||||
command-line with either `curl`, `wget` or another similar tool.
|
||||
|
||||
| Method | Command |
|
||||
| :-------- | :------------------------------------------------------------------------------------------------ |
|
||||
|
|
@ -88,38 +96,44 @@ Oh My Zsh is installed by running one of the following commands in your terminal
|
|||
| **wget** | `sh -c "$(wget -O- https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"` |
|
||||
| **fetch** | `sh -c "$(fetch -o - https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"` |
|
||||
|
||||
Alternatively, the installer is also mirrored outside GitHub. Using this URL instead may be required if you're in a country like India or China, that blocks `raw.githubusercontent.com`:
|
||||
Alternatively, the installer is also mirrored outside GitHub. Using this URL instead may be required if you're
|
||||
in a country like China or India (for certain ISPs), that blocks `raw.githubusercontent.com`:
|
||||
|
||||
| Method | Command |
|
||||
| :-------- | :------------------------------------------------------------------------------------------------ |
|
||||
| **curl** | `sh -c "$(curl -fsSL https://install.ohmyz.sh/)"` |
|
||||
| **wget** | `sh -c "$(wget -O- https://install.ohmyz.sh/)"` |
|
||||
| **fetch** | `sh -c "$(fetch -o - https://install.ohmyz.sh/)"` |
|
||||
| Method | Command |
|
||||
| :-------- | :------------------------------------------------ |
|
||||
| **curl** | `sh -c "$(curl -fsSL https://install.ohmyz.sh/)"` |
|
||||
| **wget** | `sh -c "$(wget -O- https://install.ohmyz.sh/)"` |
|
||||
| **fetch** | `sh -c "$(fetch -o - https://install.ohmyz.sh/)"` |
|
||||
|
||||
_Note that any previous `.zshrc` will be renamed to `.zshrc.pre-oh-my-zsh`. After installation, you can move the configuration you want to preserve into the new `.zshrc`._
|
||||
_Note that any previous `.zshrc` will be renamed to `.zshrc.pre-oh-my-zsh`. After installation, you can move
|
||||
the configuration you want to preserve into the new `.zshrc`._
|
||||
|
||||
#### Manual Inspection
|
||||
|
||||
It's a good idea to inspect the install script from projects you don't yet know. You can do
|
||||
that by downloading the install script first, looking through it so everything looks normal,
|
||||
then running it:
|
||||
It's a good idea to inspect the install script from projects you don't yet know. You can do that by
|
||||
downloading the install script first, looking through it so everything looks normal, then running it:
|
||||
|
||||
```sh
|
||||
wget https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh
|
||||
sh install.sh
|
||||
```
|
||||
|
||||
If the above URL times out or otherwise fails, you may have to substitute the URL for `https://install.ohmyz.sh` to be able to get the script.
|
||||
If the above URL times out or otherwise fails, you may have to substitute the URL for
|
||||
`https://install.ohmyz.sh` to be able to get the script.
|
||||
|
||||
## Using Oh My Zsh
|
||||
|
||||
### Plugins
|
||||
|
||||
Oh My Zsh comes with a shitload of plugins for you to take advantage of. You can take a look in the [plugins](https://github.com/ohmyzsh/ohmyzsh/tree/master/plugins) directory and/or the [wiki](https://github.com/ohmyzsh/ohmyzsh/wiki/Plugins) to see what's currently available.
|
||||
Oh My Zsh comes with a shitload of plugins for you to take advantage of. You can take a look in the
|
||||
[plugins](https://github.com/ohmyzsh/ohmyzsh/tree/master/plugins) directory and/or the
|
||||
[wiki](https://github.com/ohmyzsh/ohmyzsh/wiki/Plugins) to see what's currently available.
|
||||
|
||||
#### Enabling Plugins
|
||||
|
||||
Once you spot a plugin (or several) that you'd like to use with Oh My Zsh, you'll need to enable them in the `.zshrc` file. You'll find the zshrc file in your `$HOME` directory. Open it with your favorite text editor and you'll see a spot to list all the plugins you want to load.
|
||||
Once you spot a plugin (or several) that you'd like to use with Oh My Zsh, you'll need to enable them in the
|
||||
`.zshrc` file. You'll find the zshrc file in your `$HOME` directory. Open it with your favorite text editor
|
||||
and you'll see a spot to list all the plugins you want to load.
|
||||
|
||||
```sh
|
||||
vi ~/.zshrc
|
||||
|
|
@ -139,21 +153,28 @@ plugins=(
|
|||
)
|
||||
```
|
||||
|
||||
_Note that the plugins are separated by whitespace (spaces, tabs, new lines...). **Do not** use commas between them or it will break._
|
||||
_Note that the plugins are separated by whitespace (spaces, tabs, new lines...). **Do not** use commas between
|
||||
them or it will break._
|
||||
|
||||
#### Using Plugins
|
||||
|
||||
Each built-in plugin includes a **README**, documenting it. This README should show the aliases (if the plugin adds any) and extra goodies that are included in that particular plugin.
|
||||
Each built-in plugin includes a **README**, documenting it. This README should show the aliases (if the plugin
|
||||
adds any) and extra goodies that are included in that particular plugin.
|
||||
|
||||
### Themes
|
||||
|
||||
We'll admit it. Early in the Oh My Zsh world, we may have gotten a bit too theme happy. We have over one hundred and fifty themes now bundled. Most of them have [screenshots](https://github.com/ohmyzsh/ohmyzsh/wiki/Themes) on the wiki (We are working on updating this!). Check them out!
|
||||
We'll admit it. Early in the Oh My Zsh world, we may have gotten a bit too theme-happy. We have over one
|
||||
hundred and fifty themes now bundled. Most of them have
|
||||
[screenshots](https://github.com/ohmyzsh/ohmyzsh/wiki/Themes) on the wiki (We are working on updating this!).
|
||||
Check them out!
|
||||
|
||||
#### Selecting A Theme
|
||||
|
||||
_Robby's theme is the default one. It's not the fanciest one. It's not the simplest one. It's just the right one (for him)._
|
||||
_Robby's theme is the default one. It's not the fanciest one. It's not the simplest one. It's just the right
|
||||
one (for him)._
|
||||
|
||||
Once you find a theme that you'd like to use, you will need to edit the `~/.zshrc` file. You'll see an environment variable (all caps) in there that looks like:
|
||||
Once you find a theme that you'd like to use, you will need to edit the `~/.zshrc` file. You'll see an
|
||||
environment variable (all caps) in there that looks like:
|
||||
|
||||
```sh
|
||||
ZSH_THEME="robbyrussell"
|
||||
|
|
@ -166,21 +187,38 @@ ZSH_THEME="agnoster" # (this is one of the fancy ones)
|
|||
# see https://github.com/ohmyzsh/ohmyzsh/wiki/Themes#agnoster
|
||||
```
|
||||
|
||||
_Note: many themes require installing a [Powerline Font](https://github.com/powerline/fonts) or a [Nerd Font](https://github.com/ryanoasis/nerd-fonts) in order to render properly. Without them, these themes will render [weird prompt symbols](https://github.com/ohmyzsh/ohmyzsh/wiki/FAQ#i-have-a-weird-character-in-my-prompt)_
|
||||
<!-- prettier-ignore-start -->
|
||||
> [!NOTE]
|
||||
> You will many times see screenshots for a zsh theme, and try it out, and find that it doesn't look the same for you.
|
||||
>
|
||||
> This is because many themes require installing a [Powerline Font](https://github.com/powerline/fonts) or a
|
||||
> [Nerd Font](https://github.com/ryanoasis/nerd-fonts) in order to render properly. Without them, these themes
|
||||
> will render weird prompt symbols. Check out
|
||||
> [the FAQ](https://github.com/ohmyzsh/ohmyzsh/wiki/FAQ#i-have-a-weird-character-in-my-prompt) for more
|
||||
> information.
|
||||
>
|
||||
> Also, beware that themes only control what your prompt looks like. This is, the text you see before or after
|
||||
> your cursor, where you'll type your commands. Themes don't control things such as the colors of your
|
||||
> terminal window (known as _color scheme_) or the font of your terminal. These are settings that you can
|
||||
> change in your terminal emulator. For more information, see
|
||||
> [what is a zsh theme](https://github.com/ohmyzsh/ohmyzsh/wiki/FAQ#what-is-a-zsh-theme).
|
||||
<!-- prettier-ignore-end -->
|
||||
|
||||
Open up a new terminal window and your prompt should look something like this:
|
||||
|
||||

|
||||
|
||||
In case you did not find a suitable theme for your needs, please have a look at the wiki for [more of them](https://github.com/ohmyzsh/ohmyzsh/wiki/External-themes).
|
||||
In case you did not find a suitable theme for your needs, please have a look at the wiki for
|
||||
[more of them](https://github.com/ohmyzsh/ohmyzsh/wiki/External-themes).
|
||||
|
||||
If you're feeling feisty, you can let the computer select one randomly for you each time you open a new terminal window.
|
||||
If you're feeling feisty, you can let the computer select one randomly for you each time you open a new
|
||||
terminal window.
|
||||
|
||||
```sh
|
||||
ZSH_THEME="random" # (...please let it be pie... please be some pie..)
|
||||
```
|
||||
|
||||
And if you want to pick random theme from a list of your favorite themes:
|
||||
And if you want to pick a random theme from a list of your favorite themes:
|
||||
|
||||
```sh
|
||||
ZSH_THEME_RANDOM_CANDIDATES=(
|
||||
|
|
@ -197,7 +235,8 @@ ZSH_THEME_RANDOM_IGNORED=(pygmalion tjkirch_mod)
|
|||
|
||||
### FAQ
|
||||
|
||||
If you have some more questions or issues, you might find a solution in our [FAQ](https://github.com/ohmyzsh/ohmyzsh/wiki/FAQ).
|
||||
If you have some more questions or issues, you might find a solution in our
|
||||
[FAQ](https://github.com/ohmyzsh/ohmyzsh/wiki/FAQ).
|
||||
|
||||
## Advanced Topics
|
||||
|
||||
|
|
@ -205,16 +244,16 @@ If you're the type that likes to get their hands dirty, these sections might res
|
|||
|
||||
### Advanced Installation
|
||||
|
||||
Some users may want to manually install Oh My Zsh, or change the default path or other settings that
|
||||
the installer accepts (these settings are also documented at the top of the install script).
|
||||
Some users may want to manually install Oh My Zsh, or change the default path or other settings that the
|
||||
installer accepts (these settings are also documented at the top of the install script).
|
||||
|
||||
#### Custom Directory
|
||||
|
||||
The default location is `~/.oh-my-zsh` (hidden in your home directory, you can access it with `cd ~/.oh-my-zsh`)
|
||||
The default location is `~/.oh-my-zsh` (hidden in your home directory, you can access it with
|
||||
`cd ~/.oh-my-zsh`)
|
||||
|
||||
If you'd like to change the install directory with the `ZSH` environment variable, either by running
|
||||
`export ZSH=/your/path` before installing, or by setting it before the end of the install pipeline
|
||||
like this:
|
||||
`export ZSH=/your/path` before installing, or by setting it before the end of the install pipeline like this:
|
||||
|
||||
```sh
|
||||
ZSH="$HOME/.dotfiles/oh-my-zsh" sh install.sh
|
||||
|
|
@ -222,32 +261,33 @@ ZSH="$HOME/.dotfiles/oh-my-zsh" sh install.sh
|
|||
|
||||
#### Unattended Install
|
||||
|
||||
If you're running the Oh My Zsh install script as part of an automated install, you can pass the `--unattended`
|
||||
flag to the `install.sh` script. This will have the effect of not trying to change
|
||||
the default shell, and it also won't run `zsh` when the installation has finished.
|
||||
If you're running the Oh My Zsh install script as part of an automated install, you can pass the
|
||||
`--unattended` flag to the `install.sh` script. This will have the effect of not trying to change the default
|
||||
shell, and it also won't run `zsh` when the installation has finished.
|
||||
|
||||
```sh
|
||||
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" "" --unattended
|
||||
```
|
||||
|
||||
If you're in China, India, or another country that blocks `raw.githubusercontent.com`, you may have to substitute the URL for `https://install.ohmyz.sh` for it to install.
|
||||
If you're in China, India, or another country that blocks `raw.githubusercontent.com`, you may have to
|
||||
substitute the URL for `https://install.ohmyz.sh` for it to install.
|
||||
|
||||
#### Installing From A Forked Repository
|
||||
|
||||
The install script also accepts these variables to allow installation of a different repository:
|
||||
The install script also accepts these variables to allow the installation of a different repository:
|
||||
|
||||
- `REPO` (default: `ohmyzsh/ohmyzsh`): this takes the form of `owner/repository`. If you set
|
||||
this variable, the installer will look for a repository at `https://github.com/{owner}/{repository}`.
|
||||
- `REPO` (default: `ohmyzsh/ohmyzsh`): this takes the form of `owner/repository`. If you set this variable,
|
||||
the installer will look for a repository at `https://github.com/{owner}/{repository}`.
|
||||
|
||||
- `REMOTE` (default: `https://github.com/${REPO}.git`): this is the full URL of the git repository
|
||||
clone. You can use this setting if you want to install from a fork that is not on GitHub (GitLab,
|
||||
Bitbucket...) or if you want to clone with SSH instead of HTTPS (`git@github.com:user/project.git`).
|
||||
- `REMOTE` (default: `https://github.com/${REPO}.git`): this is the full URL of the git repository clone. You
|
||||
can use this setting if you want to install from a fork that is not on GitHub (GitLab, Bitbucket...) or if
|
||||
you want to clone with SSH instead of HTTPS (`git@github.com:user/project.git`).
|
||||
|
||||
_NOTE: it's incompatible with setting the `REPO` variable. This setting will take precedence._
|
||||
|
||||
- `BRANCH` (default: `master`): you can use this setting if you want to change the default branch to be
|
||||
checked out when cloning the repository. This might be useful for testing a Pull Request, or if you
|
||||
want to use a branch other than `master`.
|
||||
checked out when cloning the repository. This might be useful for testing a Pull Request, or if you want to
|
||||
use a branch other than `master`.
|
||||
|
||||
For example:
|
||||
|
||||
|
|
@ -293,22 +333,27 @@ Once you open up a new terminal window, it should load zsh with Oh My Zsh's conf
|
|||
|
||||
If you have any hiccups installing, here are a few common fixes.
|
||||
|
||||
- You _might_ need to modify your `PATH` in `~/.zshrc` if you're not able to find some commands after switching to `oh-my-zsh`.
|
||||
- If you installed manually or changed the install location, check the `ZSH` environment variable in `~/.zshrc`.
|
||||
- You _might_ need to modify your `PATH` in `~/.zshrc` if you're not able to find some commands after
|
||||
switching to `oh-my-zsh`.
|
||||
- If you installed manually or changed the install location, check the `ZSH` environment variable in
|
||||
`~/.zshrc`.
|
||||
|
||||
### Custom Plugins And Themes
|
||||
|
||||
If you want to override any of the default behaviors, just add a new file (ending in `.zsh`) in the `custom/` directory.
|
||||
If you want to override any of the default behaviors, just add a new file (ending in `.zsh`) in the `custom/`
|
||||
directory.
|
||||
|
||||
If you have many functions that go well together, you can put them as a `XYZ.plugin.zsh` file in the `custom/plugins/` directory and then enable this plugin.
|
||||
If you have many functions that go well together, you can put them as a `XYZ.plugin.zsh` file in the
|
||||
`custom/plugins/` directory and then enable this plugin.
|
||||
|
||||
If you would like to override the functionality of a plugin distributed with Oh My Zsh, create a plugin of the same name in the `custom/plugins/` directory and it will be loaded instead of the one in `plugins/`.
|
||||
If you would like to override the functionality of a plugin distributed with Oh My Zsh, create a plugin of the
|
||||
same name in the `custom/plugins/` directory and it will be loaded instead of the one in `plugins/`.
|
||||
|
||||
### Enable GNU ls In macOS And freeBSD Systems
|
||||
|
||||
<a name="enable-gnu-ls"></a>
|
||||
|
||||
The default behaviour in Oh My Zsh is to use BSD `ls` in macOS and freeBSD systems. If GNU `ls` is installed
|
||||
The default behaviour in Oh My Zsh is to use BSD `ls` in macOS and FreeBSD systems. If GNU `ls` is installed
|
||||
(as `gls` command), you can choose to use it instead. To do it, you can use zstyle-based config before
|
||||
sourcing `oh-my-zsh.sh`:
|
||||
|
||||
|
|
@ -322,9 +367,9 @@ _Note: this is not compatible with `DISABLE_LS_COLORS=true`_
|
|||
|
||||
<a name="remove-directories-aliases"></a>
|
||||
|
||||
If you want to skip default Oh My Zsh aliases (those defined in `lib/*` files) or plugin aliases,
|
||||
you can use the settings below in your `~/.zshrc` file, **before Oh My Zsh is loaded**. Note that
|
||||
there are many different ways to skip aliases, depending on your needs.
|
||||
If you want to skip default Oh My Zsh aliases (those defined in `lib/*` files) or plugin aliases, you can use
|
||||
the settings below in your `~/.zshrc` file, **before Oh My Zsh is loaded**. Note that there are many different
|
||||
ways to skip aliases, depending on your needs.
|
||||
|
||||
```sh
|
||||
# Skip all aliases, in lib files and enabled plugins
|
||||
|
|
@ -341,7 +386,7 @@ zstyle ':omz:plugins:*' aliases no
|
|||
zstyle ':omz:plugins:git' aliases no
|
||||
```
|
||||
|
||||
You can combine these in other ways taking into account that more specific scopes takes precedence:
|
||||
You can combine these in other ways taking into account that more specific scopes take precedence:
|
||||
|
||||
```sh
|
||||
# Skip all plugin aliases, except for the git plugin
|
||||
|
|
@ -363,16 +408,36 @@ zstyle ':omz:lib:directories' aliases no
|
|||
|
||||
#### Notice <!-- omit in toc -->
|
||||
|
||||
> This feature is currently in a testing phase and it may be subject to change in the future.
|
||||
> It is also not currently compatible with plugin managers such as zpm or zinit, which don't
|
||||
> source the init script (`oh-my-zsh.sh`) where this feature is implemented in.
|
||||
> This feature is currently in a testing phase and it may be subject to change in the future. It is also not
|
||||
> currently compatible with plugin managers such as zpm or zinit, which don't source the init script
|
||||
> (`oh-my-zsh.sh`) where this feature is implemented in.
|
||||
|
||||
> It is also not currently aware of "aliases" that are defined as functions. Example of such
|
||||
> are `gccd`, `ggf`, or `ggl` functions from the git plugin.
|
||||
> It is also not currently aware of "aliases" that are defined as functions. Example of such are `gccd`,
|
||||
> `ggf`, or `ggl` functions from the git plugin.
|
||||
|
||||
### Async git prompt
|
||||
|
||||
Async prompt functions are an experimental feature (included on April 3, 2024) that allows Oh My Zsh to render
|
||||
prompt information asynchronously. This can improve prompt rendering performance, but it might not work well
|
||||
with some setups. We hope that's not an issue, but if you're seeing problems with this new feature, you can
|
||||
turn it off by setting the following in your .zshrc file, before Oh My Zsh is sourced:
|
||||
|
||||
```sh
|
||||
zstyle ':omz:alpha:lib:git' async-prompt no
|
||||
```
|
||||
|
||||
If your problem is that the git prompt just stopped appearing, you can try to force it by setting the following
|
||||
configuration before `oh-my-zsh.sh` is sourced. If it still does not work, please open an issue with your
|
||||
case.
|
||||
|
||||
```sh
|
||||
zstyle ':omz:alpha:lib:git' async-prompt force
|
||||
```
|
||||
|
||||
## Getting Updates
|
||||
|
||||
By default, you will be prompted to check for updates every 2 weeks. You can choose other update modes by adding a line to your `~/.zshrc` file, **before Oh My Zsh is loaded**:
|
||||
By default, you will be prompted to check for updates every 2 weeks. You can choose other update modes by
|
||||
adding a line to your `~/.zshrc` file, **before Oh My Zsh is loaded**:
|
||||
|
||||
1. Automatic update without confirmation prompt:
|
||||
|
||||
|
|
@ -415,52 +480,76 @@ zstyle ':omz:update' verbose silent # only errors
|
|||
|
||||
### Manual Updates
|
||||
|
||||
If you'd like to update at any point in time (maybe someone just released a new plugin and you don't want to wait a week?) you just need to run:
|
||||
If you'd like to update at any point in time (maybe someone just released a new plugin and you don't want to
|
||||
wait a week?) you just need to run:
|
||||
|
||||
```sh
|
||||
omz update
|
||||
```
|
||||
|
||||
> [!NOTE]
|
||||
> If you want to automate this process in a script, you should call directly the `upgrade` script, like this:
|
||||
>
|
||||
> ```sh
|
||||
> $ZSH/tools/upgrade.sh
|
||||
> ```
|
||||
>
|
||||
> See more options in the [FAQ: How do I update Oh My Zsh?](https://github.com/ohmyzsh/ohmyzsh/wiki/FAQ#how-do-i-update-oh-my-zsh).
|
||||
>
|
||||
> **USE OF `omz update --unattended` HAS BEEN REMOVED, AS IT HAS SIDE EFFECTS**.
|
||||
|
||||
Magic! 🎉
|
||||
|
||||
## Uninstalling Oh My Zsh
|
||||
|
||||
Oh My Zsh isn't for everyone. We'll miss you, but we want to make this an easy breakup.
|
||||
|
||||
If you want to uninstall `oh-my-zsh`, just run `uninstall_oh_my_zsh` from the command-line. It will remove itself and revert your previous `bash` or `zsh` configuration.
|
||||
If you want to uninstall `oh-my-zsh`, just run `uninstall_oh_my_zsh` from the command-line. It will remove
|
||||
itself and revert your previous `bash` or `zsh` configuration.
|
||||
|
||||
## How Do I Contribute To Oh My Zsh?
|
||||
|
||||
Before you participate in our delightful community, please read the [code of conduct](CODE_OF_CONDUCT.md).
|
||||
|
||||
I'm far from being a [Zsh](https://www.zsh.org/) expert and suspect there are many ways to improve – if you have ideas on how to make the configuration easier to maintain (and faster), don't hesitate to fork and send pull requests!
|
||||
I'm far from being a [Zsh](https://www.zsh.org/) expert and suspect there are many ways to improve – if you
|
||||
have ideas on how to make the configuration easier to maintain (and faster), don't hesitate to fork and send
|
||||
pull requests!
|
||||
|
||||
We also need people to test out pull requests. So take a look through [the open issues](https://github.com/ohmyzsh/ohmyzsh/issues) and help where you can.
|
||||
We also need people to test out pull requests. So take a look through
|
||||
[the open issues](https://github.com/ohmyzsh/ohmyzsh/issues) and help where you can.
|
||||
|
||||
See [Contributing](CONTRIBUTING.md) for more details.
|
||||
|
||||
### Do Not Send Us Themes
|
||||
|
||||
We have (more than) enough themes for the time being. Please add your theme to the [external themes](https://github.com/ohmyzsh/ohmyzsh/wiki/External-themes) wiki page.
|
||||
We have (more than) enough themes for the time being. Please add your theme to the
|
||||
[external themes](https://github.com/ohmyzsh/ohmyzsh/wiki/External-themes) wiki page.
|
||||
|
||||
## Contributors
|
||||
|
||||
Oh My Zsh has a vibrant community of happy users and delightful contributors. Without all the time and help from our contributors, it wouldn't be so awesome.
|
||||
Oh My Zsh has a vibrant community of happy users and delightful contributors. Without all the time and help
|
||||
from our contributors, it wouldn't be so awesome.
|
||||
|
||||
Thank you so much!
|
||||
|
||||
<a href="https://github.com/ohmyzsh/ohmyzsh/graphs/contributors">
|
||||
<img src="https://contrib.rocks/image?repo=ohmyzsh/ohmyzsh" width="100%"/>
|
||||
</a>
|
||||
|
||||
## Follow Us
|
||||
|
||||
We're on social media:
|
||||
|
||||
- [@ohmyzsh](https://twitter.com/ohmyzsh) on Twitter. You should follow it.
|
||||
- [@ohmyzsh](https://x.com/ohmyzsh) on X (formerly Twitter). You should follow it.
|
||||
- [Facebook](https://www.facebook.com/Oh-My-Zsh-296616263819290/) poke us.
|
||||
- [Instagram](https://www.instagram.com/_ohmyzsh/) tag us in your post showing Oh My Zsh!
|
||||
- [Discord](https://discord.gg/ohmyzsh) to chat with us!
|
||||
|
||||
## Merchandise
|
||||
|
||||
We have [stickers, shirts, and coffee mugs available](https://shop.planetargon.com/collections/oh-my-zsh?utm_source=github) for you to show off your love of Oh My Zsh. Again, you will become the talk of the town!
|
||||
We have
|
||||
[stickers, shirts, and coffee mugs available](https://shop.planetargon.com/collections/oh-my-zsh?utm_source=github)
|
||||
for you to show off your love of Oh My Zsh. Again, you will become the talk of the town!
|
||||
|
||||
## License
|
||||
|
||||
|
|
@ -470,4 +559,6 @@ Oh My Zsh is released under the [MIT license](LICENSE.txt).
|
|||
|
||||

|
||||
|
||||
Oh My Zsh was started by the team at [Planet Argon](https://www.planetargon.com/?utm_source=github), a [Ruby on Rails development agency](http://www.planetargon.com/services/ruby-on-rails-development?utm_source=github). Check out our [other open source projects](https://www.planetargon.com/open-source?utm_source=github).
|
||||
Oh My Zsh was started by the team at [Planet Argon](https://www.planetargon.com/?utm_source=github), a
|
||||
[Ruby on Rails development agency](https://www.planetargon.com/services/ruby-on-rails-development?utm_source=github).
|
||||
Check out our [other open source projects](https://www.planetargon.com/open-source?utm_source=github).
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ In the near future we will introduce versioning, so expect this section to chang
|
|||
|
||||
**Do not submit an issue or pull request**: this might reveal the vulnerability.
|
||||
|
||||
Instead, you should email the maintainers directly at: [**security@ohmyz.sh**](mailto:security@ohmyz.sh),
|
||||
or using the link to [privately report a vulnerability with GitHub](https://github.com/ohmyzsh/ohmyzsh/security/advisories/new).
|
||||
Instead, you should use the form to [privately report a vulnerability to us via GitHub](https://github.com/ohmyzsh/ohmyzsh/security/advisories/new)
|
||||
or email the maintainers directly at: [**security@ohmyz.sh**](mailto:security@ohmyz.sh).
|
||||
|
||||
We will deal with the vulnerability privately and submit a patch as soon as possible.
|
||||
|
|
|
|||
|
|
@ -1,12 +1,12 @@
|
|||
# Put files in this folder to add your own custom functionality.
|
||||
# See: https://github.com/ohmyzsh/ohmyzsh/wiki/Customization
|
||||
#
|
||||
#
|
||||
# Files in the custom/ directory will be:
|
||||
# - loaded automatically by the init script, in alphabetical order
|
||||
# - loaded last, after all built-ins in the lib/ directory, to override them
|
||||
# - ignored by git by default
|
||||
#
|
||||
#
|
||||
# Example: add custom/shortcuts.zsh for shortcuts to your local projects
|
||||
#
|
||||
#
|
||||
# brainstormr=~/Projects/development/planetargon/brainstormr
|
||||
# cd $brainstormr
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
# Put your custom themes in this folder.
|
||||
# See: https://github.com/ohmyzsh/ohmyzsh/wiki/Customization#overriding-and-adding-themes
|
||||
#
|
||||
#
|
||||
# Example:
|
||||
|
||||
PROMPT="%{$fg[red]%}%n%{$reset_color%}@%{$fg[blue]%}%m %{$fg[yellow]%}%~ %{$reset_color%}%% "
|
||||
|
|
|
|||
145
lib/async_prompt.zsh
Normal file
145
lib/async_prompt.zsh
Normal file
|
|
@ -0,0 +1,145 @@
|
|||
# The async code is taken from
|
||||
# https://github.com/zsh-users/zsh-autosuggestions/blob/master/src/async.zsh
|
||||
# https://github.com/woefe/git-prompt.zsh/blob/master/git-prompt.zsh
|
||||
|
||||
zmodload zsh/system
|
||||
autoload -Uz is-at-least
|
||||
|
||||
# For now, async prompt function handlers are set up like so:
|
||||
# First, define the async function handler and register the handler
|
||||
# with _omz_register_handler:
|
||||
#
|
||||
# function _git_prompt_status_async {
|
||||
# # Do some expensive operation that outputs to stdout
|
||||
# }
|
||||
# _omz_register_handler _git_prompt_status_async
|
||||
#
|
||||
# Then add a stub prompt function in `$PROMPT` or similar prompt variables,
|
||||
# which will show the output of "$_OMZ_ASYNC_OUTPUT[handler_name]":
|
||||
#
|
||||
# function git_prompt_status {
|
||||
# echo -n $_OMZ_ASYNC_OUTPUT[_git_prompt_status_async]
|
||||
# }
|
||||
#
|
||||
# RPROMPT='$(git_prompt_status)'
|
||||
#
|
||||
# This API is subject to change and optimization. Rely on it at your own risk.
|
||||
|
||||
function _omz_register_handler {
|
||||
setopt localoptions noksharrays unset
|
||||
typeset -ga _omz_async_functions
|
||||
# we want to do nothing if there's no $1 function or we already set it up
|
||||
if [[ -z "$1" ]] || (( ! ${+functions[$1]} )) \
|
||||
|| (( ${_omz_async_functions[(Ie)$1]} )); then
|
||||
return
|
||||
fi
|
||||
_omz_async_functions+=("$1")
|
||||
# let's add the hook to async_request if it's not there yet
|
||||
if (( ! ${precmd_functions[(Ie)_omz_async_request]} )) \
|
||||
&& (( ${+functions[_omz_async_request]})); then
|
||||
autoload -Uz add-zsh-hook
|
||||
add-zsh-hook precmd _omz_async_request
|
||||
fi
|
||||
}
|
||||
|
||||
# Set up async handlers and callbacks
|
||||
function _omz_async_request {
|
||||
setopt localoptions noksharrays unset
|
||||
local -i ret=$?
|
||||
typeset -gA _OMZ_ASYNC_FDS _OMZ_ASYNC_PIDS _OMZ_ASYNC_OUTPUT
|
||||
|
||||
# executor runs a subshell for all async requests based on key
|
||||
local handler
|
||||
for handler in ${_omz_async_functions}; do
|
||||
(( ${+functions[$handler]} )) || continue
|
||||
|
||||
local fd=${_OMZ_ASYNC_FDS[$handler]:--1}
|
||||
local pid=${_OMZ_ASYNC_PIDS[$handler]:--1}
|
||||
|
||||
# If we've got a pending request, cancel it
|
||||
if (( fd != -1 && pid != -1 )) && { true <&$fd } 2>/dev/null; then
|
||||
# Close the file descriptor and remove the handler
|
||||
exec {fd}<&-
|
||||
zle -F $fd
|
||||
|
||||
# Zsh will make a new process group for the child process only if job
|
||||
# control is enabled (MONITOR option)
|
||||
if [[ -o MONITOR ]]; then
|
||||
# Send the signal to the process group to kill any processes that may
|
||||
# have been forked by the async function handler
|
||||
kill -TERM -$pid 2>/dev/null
|
||||
else
|
||||
# Kill just the child process since it wasn't placed in a new process
|
||||
# group. If the async function handler forked any child processes they may
|
||||
# be orphaned and left behind.
|
||||
kill -TERM $pid 2>/dev/null
|
||||
fi
|
||||
fi
|
||||
|
||||
# Define global variables to store the file descriptor, PID and output
|
||||
_OMZ_ASYNC_FDS[$handler]=-1
|
||||
_OMZ_ASYNC_PIDS[$handler]=-1
|
||||
|
||||
# Fork a process to fetch the git status and open a pipe to read from it
|
||||
exec {fd}< <(
|
||||
# Tell parent process our PID
|
||||
builtin echo ${sysparams[pid]}
|
||||
# Set exit code for the handler if used
|
||||
() { return $ret }
|
||||
# Run the async function handler
|
||||
$handler
|
||||
)
|
||||
|
||||
# Save FD for handler
|
||||
_OMZ_ASYNC_FDS[$handler]=$fd
|
||||
|
||||
# There's a weird bug here where ^C stops working unless we force a fork
|
||||
# See https://github.com/zsh-users/zsh-autosuggestions/issues/364
|
||||
# and https://github.com/zsh-users/zsh-autosuggestions/pull/612
|
||||
is-at-least 5.8 || command true
|
||||
|
||||
# Save the PID from the handler child process
|
||||
read -u $fd "_OMZ_ASYNC_PIDS[$handler]"
|
||||
|
||||
# When the fd is readable, call the response handler
|
||||
zle -F "$fd" _omz_async_callback
|
||||
done
|
||||
}
|
||||
|
||||
# Called when new data is ready to be read from the pipe
|
||||
function _omz_async_callback() {
|
||||
emulate -L zsh
|
||||
|
||||
local fd=$1 # First arg will be fd ready for reading
|
||||
local err=$2 # Second arg will be passed in case of error
|
||||
|
||||
if [[ -z "$err" || "$err" == "hup" ]]; then
|
||||
# Get handler name from fd
|
||||
local handler="${(k)_OMZ_ASYNC_FDS[(r)$fd]}"
|
||||
|
||||
# Store old output which is supposed to be already printed
|
||||
local old_output="${_OMZ_ASYNC_OUTPUT[$handler]}"
|
||||
|
||||
# Read output from fd
|
||||
IFS= read -r -u $fd -d '' "_OMZ_ASYNC_OUTPUT[$handler]"
|
||||
|
||||
# Repaint prompt if output has changed
|
||||
if [[ "$old_output" != "${_OMZ_ASYNC_OUTPUT[$handler]}" ]]; then
|
||||
zle .reset-prompt
|
||||
zle -R
|
||||
fi
|
||||
|
||||
# Close the fd
|
||||
exec {fd}<&-
|
||||
fi
|
||||
|
||||
# Always remove the handler
|
||||
zle -F "$fd"
|
||||
|
||||
# Unset global FD variable to prevent closing user created FDs in the precmd hook
|
||||
_OMZ_ASYNC_FDS[$handler]=-1
|
||||
_OMZ_ASYNC_PIDS[$handler]=-1
|
||||
}
|
||||
|
||||
autoload -Uz add-zsh-hook
|
||||
add-zsh-hook precmd _omz_async_request
|
||||
20
lib/bzr.zsh
20
lib/bzr.zsh
|
|
@ -1,10 +1,14 @@
|
|||
## Bazaar integration
|
||||
## Just works with the GIT integration just add $(bzr_prompt_info) to the PROMPT
|
||||
## Just works with the GIT integration. Add $(bzr_prompt_info) to the PROMPT
|
||||
function bzr_prompt_info() {
|
||||
BZR_CB=`bzr nick 2> /dev/null | grep -v "ERROR" | cut -d ":" -f2 | awk -F / '{print "bzr::"$1}'`
|
||||
if [ -n "$BZR_CB" ]; then
|
||||
BZR_DIRTY=""
|
||||
[[ -n `bzr status` ]] && BZR_DIRTY=" %{$fg[red]%} * %{$fg[green]%}"
|
||||
echo "$ZSH_THEME_SCM_PROMPT_PREFIX$BZR_CB$BZR_DIRTY$ZSH_THEME_GIT_PROMPT_SUFFIX"
|
||||
fi
|
||||
}
|
||||
local bzr_branch
|
||||
bzr_branch=$(bzr nick 2>/dev/null) || return
|
||||
|
||||
if [[ -n "$bzr_branch" ]]; then
|
||||
local bzr_dirty=""
|
||||
if [[ -n $(bzr status 2>/dev/null) ]]; then
|
||||
bzr_dirty=" %{$fg[red]%}*%{$reset_color%}"
|
||||
fi
|
||||
printf "%s%s%s%s" "$ZSH_THEME_SCM_PROMPT_PREFIX" "bzr::${bzr_branch##*:}" "$bzr_dirty" "$ZSH_THEME_GIT_PROMPT_SUFFIX"
|
||||
fi
|
||||
}
|
||||
|
|
|
|||
114
lib/cli.zsh
114
lib/cli.zsh
|
|
@ -1,6 +1,7 @@
|
|||
#!/usr/bin/env zsh
|
||||
|
||||
function omz {
|
||||
setopt localoptions noksharrays
|
||||
[[ $# -gt 0 ]] || {
|
||||
_omz::help
|
||||
return 1
|
||||
|
|
@ -71,6 +72,10 @@ function _omz {
|
|||
local -aU plugins
|
||||
plugins=("$ZSH"/plugins/*/{_*,*.plugin.zsh}(-.N:h:t) "$ZSH_CUSTOM"/plugins/*/{_*,*.plugin.zsh}(-.N:h:t))
|
||||
_describe 'plugin' plugins ;;
|
||||
plugin::list)
|
||||
local -a opts
|
||||
opts=('--enabled:List enabled plugins only')
|
||||
_describe -o 'options' opts ;;
|
||||
theme::(set|use))
|
||||
local -aU themes
|
||||
themes=("$ZSH"/themes/*.zsh-theme(-.N:t:r) "$ZSH_CUSTOM"/**/*.zsh-theme(-.N:r:gs:"$ZSH_CUSTOM"/themes/:::gs:"$ZSH_CUSTOM"/:::))
|
||||
|
|
@ -192,7 +197,7 @@ EOF
|
|||
return 1
|
||||
fi
|
||||
|
||||
"$ZSH/tools/changelog.sh" "$version" "${2:-}" "$format"
|
||||
ZSH="$ZSH" command zsh -f "$ZSH/tools/changelog.sh" "$version" "${2:-}" "$format"
|
||||
}
|
||||
|
||||
function _omz::plugin {
|
||||
|
|
@ -205,7 +210,7 @@ Available commands:
|
|||
disable <plugin> Disable plugin(s)
|
||||
enable <plugin> Enable plugin(s)
|
||||
info <plugin> Get information of a plugin
|
||||
list List all available Oh My Zsh plugins
|
||||
list [--enabled] List Oh My Zsh plugins
|
||||
load <plugin> Load plugin(s)
|
||||
|
||||
EOF
|
||||
|
|
@ -241,10 +246,18 @@ function _omz::plugin::disable {
|
|||
|
||||
# Remove plugins substitution awk script
|
||||
local awk_subst_plugins="\
|
||||
gsub(/[ \t]+(${(j:|:)dis_plugins})/, \"\") # with spaces before
|
||||
gsub(/(${(j:|:)dis_plugins})[ \t]+/, \"\") # with spaces after
|
||||
gsub(/\((${(j:|:)dis_plugins})\)/, \"\") # without spaces (only plugin)
|
||||
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
|
||||
"
|
||||
|
||||
# Disable plugins awk script
|
||||
local awk_script="
|
||||
# if plugins=() is in oneline form, substitute disabled plugins and go to next line
|
||||
|
|
@ -336,20 +349,40 @@ function _omz::plugin::enable {
|
|||
next
|
||||
}
|
||||
|
||||
# if plugins=() is in multiline form, enable multi flag
|
||||
# if plugins=() is in multiline form, enable multi flag and indent by default with 2 spaces
|
||||
/^[ \t]*plugins=\(/ {
|
||||
multi=1
|
||||
indent=\" \"
|
||||
print \$0
|
||||
next
|
||||
}
|
||||
|
||||
# if multi flag is enabled and we find a valid closing parenthesis,
|
||||
# add new plugins and disable multi flag
|
||||
# add new plugins with proper indent and disable multi flag
|
||||
multi == 1 && /^[^#]*\)/ {
|
||||
multi=0
|
||||
sub(/\)/, \" $add_plugins&\")
|
||||
split(\"$add_plugins\",p,\" \")
|
||||
for (i in p) {
|
||||
print indent p[i]
|
||||
}
|
||||
print \$0
|
||||
next
|
||||
}
|
||||
|
||||
# if multi flag is enabled and we didnt find a closing parenthesis,
|
||||
# get the indentation level to match when adding plugins
|
||||
multi == 1 && /^[^#]*/ {
|
||||
indent=\"\"
|
||||
for (i = 1; i <= length(\$0); i++) {
|
||||
char=substr(\$0, i, 1)
|
||||
if (char == \" \" || char == \"\t\") {
|
||||
indent = indent char
|
||||
} else {
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
{ print \$0 }
|
||||
"
|
||||
|
||||
|
|
@ -389,8 +422,23 @@ function _omz::plugin::info {
|
|||
local readme
|
||||
for readme in "$ZSH_CUSTOM/plugins/$1/README.md" "$ZSH/plugins/$1/README.md"; do
|
||||
if [[ -f "$readme" ]]; then
|
||||
(( ${+commands[less]} )) && less "$readme" || cat "$readme"
|
||||
return 0
|
||||
# If being piped, just cat the README
|
||||
if [[ ! -t 1 ]]; then
|
||||
cat "$readme"
|
||||
return $?
|
||||
fi
|
||||
|
||||
# Enrich the README display depending on the tools we have
|
||||
# - glow: https://github.com/charmbracelet/glow
|
||||
# - bat: https://github.com/sharkdp/bat
|
||||
# - less: typical pager command
|
||||
case 1 in
|
||||
${+commands[glow]}) glow -p "$readme" ;;
|
||||
${+commands[bat]}) bat -l md --style plain "$readme" ;;
|
||||
${+commands[less]}) less "$readme" ;;
|
||||
*) cat "$readme" ;;
|
||||
esac
|
||||
return $?
|
||||
fi
|
||||
done
|
||||
|
||||
|
|
@ -405,8 +453,21 @@ function _omz::plugin::info {
|
|||
|
||||
function _omz::plugin::list {
|
||||
local -a custom_plugins builtin_plugins
|
||||
custom_plugins=("$ZSH_CUSTOM"/plugins/*(-/N:t))
|
||||
builtin_plugins=("$ZSH"/plugins/*(-/N:t))
|
||||
|
||||
# If --enabled is provided, only list what's enabled
|
||||
if [[ "$1" == "--enabled" ]]; then
|
||||
local plugin
|
||||
for plugin in "${plugins[@]}"; do
|
||||
if [[ -d "${ZSH_CUSTOM}/plugins/${plugin}" ]]; then
|
||||
custom_plugins+=("${plugin}")
|
||||
elif [[ -d "${ZSH}/plugins/${plugin}" ]]; then
|
||||
builtin_plugins+=("${plugin}")
|
||||
fi
|
||||
done
|
||||
else
|
||||
custom_plugins=("$ZSH_CUSTOM"/plugins/*(-/N:t))
|
||||
builtin_plugins=("$ZSH"/plugins/*(-/N:t))
|
||||
fi
|
||||
|
||||
# If the command is being piped, print all found line by line
|
||||
if [[ ! -t 1 ]]; then
|
||||
|
|
@ -448,7 +509,7 @@ function _omz::plugin::load {
|
|||
if [[ ! -f "$base/_$plugin" && ! -f "$base/$plugin.plugin.zsh" ]]; then
|
||||
_omz::log warn "'$plugin' is not a valid plugin"
|
||||
continue
|
||||
# It it is a valid plugin, add its directory to $fpath unless it is already there
|
||||
# It is a valid plugin, add its directory to $fpath unless it is already there
|
||||
elif (( ! ${fpath[(Ie)$base]} )); then
|
||||
fpath=("$base" $fpath)
|
||||
fi
|
||||
|
|
@ -773,15 +834,28 @@ function _omz::theme::use {
|
|||
}
|
||||
|
||||
function _omz::update {
|
||||
local last_commit=$(builtin cd -q "$ZSH"; git rev-parse HEAD)
|
||||
# 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
|
||||
zstyle -s ':omz:update' verbose verbose_mode || verbose_mode=default
|
||||
if [[ "$1" != --unattended ]]; then
|
||||
ZSH="$ZSH" command zsh -f "$ZSH/tools/upgrade.sh" -i -v $verbose_mode || return $?
|
||||
else
|
||||
ZSH="$ZSH" command zsh -f "$ZSH/tools/upgrade.sh" -v $verbose_mode || return $?
|
||||
fi
|
||||
ZSH="$ZSH" command zsh -f "$ZSH/tools/upgrade.sh" -i -v $verbose_mode || return $?
|
||||
|
||||
# Update last updated file
|
||||
zmodload zsh/datetime
|
||||
|
|
@ -790,7 +864,7 @@ function _omz::update {
|
|||
command rm -rf "$ZSH/log/update.lock"
|
||||
|
||||
# Restart the zsh session if there were changes
|
||||
if [[ "$1" != --unattended && "$(builtin cd -q "$ZSH"; git rev-parse HEAD)" != "$last_commit" ]]; then
|
||||
if [[ "$(builtin cd -q "$ZSH"; git rev-parse HEAD)" != "$last_commit" ]]; then
|
||||
# Old zsh versions don't have ZSH_ARGZERO
|
||||
local zsh="${ZSH_ARGZERO:-${functrace[-1]%:*}}"
|
||||
# Check whether to run a login shell
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ function handle_completion_insecurities() {
|
|||
# /usr/share/zsh/5.0.6
|
||||
#
|
||||
# Since the ignorable first line is printed to stderr and thus not captured,
|
||||
# stderr is squelched to prevent this output from leaking to the user.
|
||||
# stderr is squelched to prevent this output from leaking to the user.
|
||||
local -aU insecure_dirs
|
||||
insecure_dirs=( ${(f@):-"$(compaudit 2>/dev/null)"} )
|
||||
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ zstyle ':completion:*:*:*:users' ignored-patterns \
|
|||
adm amanda apache at avahi avahi-autoipd beaglidx bin cacti canna \
|
||||
clamav daemon dbus distcache dnsmasq dovecot fax ftp games gdm \
|
||||
gkrellmd gopher hacluster haldaemon halt hsqldb ident junkbust kdm \
|
||||
ldap lp mail mailman mailnull man messagebus mldonkey mysql nagios \
|
||||
ldap lp mail mailman mailnull man messagebus mldonkey mysql nagios \
|
||||
named netdump news nfsnobody nobody nscd ntp nut nx obsrun openvpn \
|
||||
operator pcap polkitd postfix postgres privoxy pulse pvm quagga radvd \
|
||||
rpc rpcuser rpm rtkit scard shutdown squid sshd statd svn sync tftp \
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@
|
|||
#
|
||||
# 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
|
||||
# everything is invoked with "builtin" or "command", to work in the face of user
|
||||
# redefinitions.
|
||||
#
|
||||
# OPTIONS
|
||||
|
|
@ -59,7 +59,7 @@ 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
|
||||
|
|
@ -90,7 +90,7 @@ function omz_diagnostic_dump() {
|
|||
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 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,"
|
||||
|
|
@ -105,8 +105,8 @@ function _omz_diag_dump_one_big_text() {
|
|||
builtin echo oh-my-zsh diagnostic dump
|
||||
builtin echo
|
||||
builtin echo $outfile
|
||||
builtin echo
|
||||
|
||||
builtin echo
|
||||
|
||||
# Basic system and zsh information
|
||||
command date
|
||||
command uname -a
|
||||
|
|
@ -151,7 +151,7 @@ function _omz_diag_dump_one_big_text() {
|
|||
|
||||
# Core command definitions
|
||||
_omz_diag_dump_check_core_commands || return 1
|
||||
builtin echo
|
||||
builtin echo
|
||||
|
||||
# ZSH Process state
|
||||
builtin echo Process state:
|
||||
|
|
@ -167,7 +167,7 @@ function _omz_diag_dump_one_big_text() {
|
|||
#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
|
||||
builtin echo Locale:
|
||||
command locale
|
||||
builtin echo
|
||||
|
|
@ -181,7 +181,7 @@ function _omz_diag_dump_one_big_text() {
|
|||
builtin echo
|
||||
builtin echo 'compaudit output:'
|
||||
compaudit
|
||||
builtin echo
|
||||
builtin echo
|
||||
builtin echo '$fpath directories:'
|
||||
command ls -lad $fpath
|
||||
builtin echo
|
||||
|
|
@ -224,7 +224,7 @@ function _omz_diag_dump_one_big_text() {
|
|||
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
|
||||
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 )
|
||||
|
|
@ -258,8 +258,8 @@ function _omz_diag_dump_check_core_commands() {
|
|||
# (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 '!' '[[' '{' '}'
|
||||
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
|
||||
|
|
@ -331,7 +331,7 @@ function _omz_diag_dump_os_specific_version() {
|
|||
case "$OSTYPE" in
|
||||
darwin*)
|
||||
osname=$(command sw_vers -productName)
|
||||
osver=$(command sw_vers -productVersion)
|
||||
osver=$(command sw_vers -productVersion)
|
||||
builtin echo "OS Version: $osname $osver build $(sw_vers -buildVersion)"
|
||||
;;
|
||||
cygwin)
|
||||
|
|
|
|||
|
|
@ -57,6 +57,16 @@ function takeurl() {
|
|||
cd "$thedir"
|
||||
}
|
||||
|
||||
function takezip() {
|
||||
local data thedir
|
||||
data="$(mktemp)"
|
||||
curl -L "$1" > "$data"
|
||||
unzip "$data" -d "./"
|
||||
thedir="$(unzip -l "$data" | awk 'NR==4 {print $4}' | sed 's/\/.*//')"
|
||||
rm "$data"
|
||||
cd "$thedir"
|
||||
}
|
||||
|
||||
function takegit() {
|
||||
git clone "$1"
|
||||
cd "$(basename ${1%%.git})"
|
||||
|
|
@ -65,6 +75,8 @@ function takegit() {
|
|||
function take() {
|
||||
if [[ $1 =~ ^(https?|ftp).*\.(tar\.(gz|bz2|xz)|tgz)$ ]]; then
|
||||
takeurl "$1"
|
||||
elif [[ $1 =~ ^(https?|ftp).*\.(zip)$ ]]; then
|
||||
takezip "$1"
|
||||
elif [[ $1 =~ ^([A-Za-z0-9]\+@|https?|git|ssh|ftps?|rsync).*\.git/?$ ]]; then
|
||||
takegit "$1"
|
||||
else
|
||||
|
|
@ -160,6 +172,8 @@ zmodload zsh/langinfo
|
|||
# -P causes spaces to be encoded as '%20' instead of '+'
|
||||
function omz_urlencode() {
|
||||
emulate -L zsh
|
||||
setopt norematchpcre
|
||||
|
||||
local -a opts
|
||||
zparseopts -D -E -a opts r m P
|
||||
|
||||
|
|
|
|||
349
lib/git.zsh
349
lib/git.zsh
|
|
@ -1,3 +1,5 @@
|
|||
autoload -Uz is-at-least
|
||||
|
||||
# The git prompt's git commands are read-only and should not interfere with
|
||||
# other processes. This environment variable is equivalent to running with `git
|
||||
# --no-optional-locks`, but falls back gracefully for older versions of git.
|
||||
|
|
@ -9,14 +11,18 @@ function __git_prompt_git() {
|
|||
GIT_OPTIONAL_LOCKS=0 command git "$@"
|
||||
}
|
||||
|
||||
function git_prompt_info() {
|
||||
function _omz_git_prompt_info() {
|
||||
# If we are on a folder not tracked by git, get out.
|
||||
# Otherwise, check for hide-info at global and local repository level
|
||||
if ! __git_prompt_git rev-parse --git-dir &> /dev/null \
|
||||
|| [[ "$(__git_prompt_git config --get oh-my-zsh.hide-info 2>/dev/null)" == 1 ]]; then
|
||||
|| [[ "$(__git_prompt_git config --get oh-my-zsh.hide-info 2>/dev/null)" == 1 ]]; then
|
||||
return 0
|
||||
fi
|
||||
|
||||
# Get either:
|
||||
# - the current branch name
|
||||
# - the tag name if we are on a tag
|
||||
# - the short SHA of the current commit
|
||||
local ref
|
||||
ref=$(__git_prompt_git symbolic-ref --short HEAD 2> /dev/null) \
|
||||
|| ref=$(__git_prompt_git describe --tags --exact-match HEAD 2> /dev/null) \
|
||||
|
|
@ -33,135 +39,7 @@ function git_prompt_info() {
|
|||
echo "${ZSH_THEME_GIT_PROMPT_PREFIX}${ref:gs/%/%%}${upstream:gs/%/%%}$(parse_git_dirty)${ZSH_THEME_GIT_PROMPT_SUFFIX}"
|
||||
}
|
||||
|
||||
# Checks if working tree is dirty
|
||||
function parse_git_dirty() {
|
||||
local STATUS
|
||||
local -a FLAGS
|
||||
FLAGS=('--porcelain')
|
||||
if [[ "$(__git_prompt_git config --get oh-my-zsh.hide-dirty)" != "1" ]]; then
|
||||
if [[ "${DISABLE_UNTRACKED_FILES_DIRTY:-}" == "true" ]]; then
|
||||
FLAGS+='--untracked-files=no'
|
||||
fi
|
||||
case "${GIT_STATUS_IGNORE_SUBMODULES:-}" in
|
||||
git)
|
||||
# let git decide (this respects per-repo config in .gitmodules)
|
||||
;;
|
||||
*)
|
||||
# if unset: ignore dirty submodules
|
||||
# other values are passed to --ignore-submodules
|
||||
FLAGS+="--ignore-submodules=${GIT_STATUS_IGNORE_SUBMODULES:-dirty}"
|
||||
;;
|
||||
esac
|
||||
STATUS=$(__git_prompt_git status ${FLAGS} 2> /dev/null | tail -n 1)
|
||||
fi
|
||||
if [[ -n $STATUS ]]; then
|
||||
echo "$ZSH_THEME_GIT_PROMPT_DIRTY"
|
||||
else
|
||||
echo "$ZSH_THEME_GIT_PROMPT_CLEAN"
|
||||
fi
|
||||
}
|
||||
|
||||
# Gets the difference between the local and remote branches
|
||||
function git_remote_status() {
|
||||
local remote ahead behind git_remote_status git_remote_status_detailed
|
||||
remote=${$(__git_prompt_git rev-parse --verify ${hook_com[branch]}@{upstream} --symbolic-full-name 2>/dev/null)/refs\/remotes\/}
|
||||
if [[ -n ${remote} ]]; then
|
||||
ahead=$(__git_prompt_git rev-list ${hook_com[branch]}@{upstream}..HEAD 2>/dev/null | wc -l)
|
||||
behind=$(__git_prompt_git rev-list HEAD..${hook_com[branch]}@{upstream} 2>/dev/null | wc -l)
|
||||
|
||||
if [[ $ahead -eq 0 ]] && [[ $behind -eq 0 ]]; then
|
||||
git_remote_status="$ZSH_THEME_GIT_PROMPT_EQUAL_REMOTE"
|
||||
elif [[ $ahead -gt 0 ]] && [[ $behind -eq 0 ]]; then
|
||||
git_remote_status="$ZSH_THEME_GIT_PROMPT_AHEAD_REMOTE"
|
||||
git_remote_status_detailed="$ZSH_THEME_GIT_PROMPT_AHEAD_REMOTE_COLOR$ZSH_THEME_GIT_PROMPT_AHEAD_REMOTE$((ahead))%{$reset_color%}"
|
||||
elif [[ $behind -gt 0 ]] && [[ $ahead -eq 0 ]]; then
|
||||
git_remote_status="$ZSH_THEME_GIT_PROMPT_BEHIND_REMOTE"
|
||||
git_remote_status_detailed="$ZSH_THEME_GIT_PROMPT_BEHIND_REMOTE_COLOR$ZSH_THEME_GIT_PROMPT_BEHIND_REMOTE$((behind))%{$reset_color%}"
|
||||
elif [[ $ahead -gt 0 ]] && [[ $behind -gt 0 ]]; then
|
||||
git_remote_status="$ZSH_THEME_GIT_PROMPT_DIVERGED_REMOTE"
|
||||
git_remote_status_detailed="$ZSH_THEME_GIT_PROMPT_AHEAD_REMOTE_COLOR$ZSH_THEME_GIT_PROMPT_AHEAD_REMOTE$((ahead))%{$reset_color%}$ZSH_THEME_GIT_PROMPT_BEHIND_REMOTE_COLOR$ZSH_THEME_GIT_PROMPT_BEHIND_REMOTE$((behind))%{$reset_color%}"
|
||||
fi
|
||||
|
||||
if [[ -n $ZSH_THEME_GIT_PROMPT_REMOTE_STATUS_DETAILED ]]; then
|
||||
git_remote_status="$ZSH_THEME_GIT_PROMPT_REMOTE_STATUS_PREFIX${remote:gs/%/%%}$git_remote_status_detailed$ZSH_THEME_GIT_PROMPT_REMOTE_STATUS_SUFFIX"
|
||||
fi
|
||||
|
||||
echo $git_remote_status
|
||||
fi
|
||||
}
|
||||
|
||||
# Outputs the name of the current branch
|
||||
# Usage example: git pull origin $(git_current_branch)
|
||||
# Using '--quiet' with 'symbolic-ref' will not cause a fatal error (128) if
|
||||
# it's not a symbolic ref, but in a Git repo.
|
||||
function git_current_branch() {
|
||||
local ref
|
||||
ref=$(__git_prompt_git symbolic-ref --quiet HEAD 2> /dev/null)
|
||||
local ret=$?
|
||||
if [[ $ret != 0 ]]; then
|
||||
[[ $ret == 128 ]] && return # no git repo.
|
||||
ref=$(__git_prompt_git rev-parse --short HEAD 2> /dev/null) || return
|
||||
fi
|
||||
echo ${ref#refs/heads/}
|
||||
}
|
||||
|
||||
|
||||
# Gets the number of commits ahead from remote
|
||||
function git_commits_ahead() {
|
||||
if __git_prompt_git rev-parse --git-dir &>/dev/null; then
|
||||
local commits="$(__git_prompt_git rev-list --count @{upstream}..HEAD 2>/dev/null)"
|
||||
if [[ -n "$commits" && "$commits" != 0 ]]; then
|
||||
echo "$ZSH_THEME_GIT_COMMITS_AHEAD_PREFIX$commits$ZSH_THEME_GIT_COMMITS_AHEAD_SUFFIX"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
# Gets the number of commits behind remote
|
||||
function git_commits_behind() {
|
||||
if __git_prompt_git rev-parse --git-dir &>/dev/null; then
|
||||
local commits="$(__git_prompt_git rev-list --count HEAD..@{upstream} 2>/dev/null)"
|
||||
if [[ -n "$commits" && "$commits" != 0 ]]; then
|
||||
echo "$ZSH_THEME_GIT_COMMITS_BEHIND_PREFIX$commits$ZSH_THEME_GIT_COMMITS_BEHIND_SUFFIX"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
# Outputs if current branch is ahead of remote
|
||||
function git_prompt_ahead() {
|
||||
if [[ -n "$(__git_prompt_git rev-list origin/$(git_current_branch)..HEAD 2> /dev/null)" ]]; then
|
||||
echo "$ZSH_THEME_GIT_PROMPT_AHEAD"
|
||||
fi
|
||||
}
|
||||
|
||||
# Outputs if current branch is behind remote
|
||||
function git_prompt_behind() {
|
||||
if [[ -n "$(__git_prompt_git rev-list HEAD..origin/$(git_current_branch) 2> /dev/null)" ]]; then
|
||||
echo "$ZSH_THEME_GIT_PROMPT_BEHIND"
|
||||
fi
|
||||
}
|
||||
|
||||
# Outputs if current branch exists on remote or not
|
||||
function git_prompt_remote() {
|
||||
if [[ -n "$(__git_prompt_git show-ref origin/$(git_current_branch) 2> /dev/null)" ]]; then
|
||||
echo "$ZSH_THEME_GIT_PROMPT_REMOTE_EXISTS"
|
||||
else
|
||||
echo "$ZSH_THEME_GIT_PROMPT_REMOTE_MISSING"
|
||||
fi
|
||||
}
|
||||
|
||||
# Formats prompt string for current git commit short SHA
|
||||
function git_prompt_short_sha() {
|
||||
local SHA
|
||||
SHA=$(__git_prompt_git rev-parse --short HEAD 2> /dev/null) && echo "$ZSH_THEME_GIT_PROMPT_SHA_BEFORE$SHA$ZSH_THEME_GIT_PROMPT_SHA_AFTER"
|
||||
}
|
||||
|
||||
# Formats prompt string for current git commit long SHA
|
||||
function git_prompt_long_sha() {
|
||||
local SHA
|
||||
SHA=$(__git_prompt_git rev-parse HEAD 2> /dev/null) && echo "$ZSH_THEME_GIT_PROMPT_SHA_BEFORE$SHA$ZSH_THEME_GIT_PROMPT_SHA_AFTER"
|
||||
}
|
||||
|
||||
function git_prompt_status() {
|
||||
function _omz_git_prompt_status() {
|
||||
[[ "$(__git_prompt_git config --get oh-my-zsh.hide-status 2>/dev/null)" = 1 ]] && return
|
||||
|
||||
# Maps a git status prefix to an internal constant
|
||||
|
|
@ -170,7 +48,7 @@ function git_prompt_status() {
|
|||
prefix_constant_map=(
|
||||
'\?\? ' 'UNTRACKED'
|
||||
'A ' 'ADDED'
|
||||
'M ' 'ADDED'
|
||||
'M ' 'MODIFIED'
|
||||
'MM ' 'MODIFIED'
|
||||
' M ' 'MODIFIED'
|
||||
'AM ' 'MODIFIED'
|
||||
|
|
@ -260,6 +138,213 @@ function git_prompt_status() {
|
|||
echo $status_prompt
|
||||
}
|
||||
|
||||
# Use async version if setting is enabled, or unset but zsh version is at least 5.0.6.
|
||||
# This avoids async prompt issues caused by previous zsh versions:
|
||||
# - https://github.com/ohmyzsh/ohmyzsh/issues/12331
|
||||
# - https://github.com/ohmyzsh/ohmyzsh/issues/12360
|
||||
# TODO(2024-06-12): @mcornella remove workaround when CentOS 7 reaches EOL
|
||||
local _style
|
||||
if zstyle -t ':omz:alpha:lib:git' async-prompt \
|
||||
|| { is-at-least 5.0.6 && zstyle -T ':omz:alpha:lib:git' async-prompt }; then
|
||||
function git_prompt_info() {
|
||||
if [[ -n "${_OMZ_ASYNC_OUTPUT[_omz_git_prompt_info]}" ]]; then
|
||||
echo -n "${_OMZ_ASYNC_OUTPUT[_omz_git_prompt_info]}"
|
||||
fi
|
||||
}
|
||||
|
||||
function git_prompt_status() {
|
||||
if [[ -n "${_OMZ_ASYNC_OUTPUT[_omz_git_prompt_status]}" ]]; then
|
||||
echo -n "${_OMZ_ASYNC_OUTPUT[_omz_git_prompt_status]}"
|
||||
fi
|
||||
}
|
||||
|
||||
# Conditionally register the async handler, only if it's needed in $PROMPT
|
||||
# or any of the other prompt variables
|
||||
function _defer_async_git_register() {
|
||||
# Check if git_prompt_info is used in a prompt variable
|
||||
case "${PS1}:${PS2}:${PS3}:${PS4}:${RPROMPT}:${RPS1}:${RPS2}:${RPS3}:${RPS4}" in
|
||||
*(\$\(git_prompt_info\)|\`git_prompt_info\`)*)
|
||||
_omz_register_handler _omz_git_prompt_info
|
||||
;;
|
||||
esac
|
||||
|
||||
case "${PS1}:${PS2}:${PS3}:${PS4}:${RPROMPT}:${RPS1}:${RPS2}:${RPS3}:${RPS4}" in
|
||||
*(\$\(git_prompt_status\)|\`git_prompt_status\`)*)
|
||||
_omz_register_handler _omz_git_prompt_status
|
||||
;;
|
||||
esac
|
||||
|
||||
add-zsh-hook -d precmd _defer_async_git_register
|
||||
unset -f _defer_async_git_register
|
||||
}
|
||||
|
||||
# Register the async handler first. This needs to be done before
|
||||
# the async request prompt is run
|
||||
precmd_functions=(_defer_async_git_register $precmd_functions)
|
||||
elif zstyle -s ':omz:alpha:lib:git' async-prompt _style && [[ $_style == "force" ]]; then
|
||||
function git_prompt_info() {
|
||||
if [[ -n "${_OMZ_ASYNC_OUTPUT[_omz_git_prompt_info]}" ]]; then
|
||||
echo -n "${_OMZ_ASYNC_OUTPUT[_omz_git_prompt_info]}"
|
||||
fi
|
||||
}
|
||||
|
||||
function git_prompt_status() {
|
||||
if [[ -n "${_OMZ_ASYNC_OUTPUT[_omz_git_prompt_status]}" ]]; then
|
||||
echo -n "${_OMZ_ASYNC_OUTPUT[_omz_git_prompt_status]}"
|
||||
fi
|
||||
}
|
||||
|
||||
_omz_register_handler _omz_git_prompt_info
|
||||
_omz_register_handler _omz_git_prompt_status
|
||||
else
|
||||
function git_prompt_info() {
|
||||
_omz_git_prompt_info
|
||||
}
|
||||
function git_prompt_status() {
|
||||
_omz_git_prompt_status
|
||||
}
|
||||
fi
|
||||
|
||||
# Checks if working tree is dirty
|
||||
function parse_git_dirty() {
|
||||
local STATUS
|
||||
local -a FLAGS
|
||||
FLAGS=('--porcelain')
|
||||
if [[ "$(__git_prompt_git config --get oh-my-zsh.hide-dirty)" != "1" ]]; then
|
||||
if [[ "${DISABLE_UNTRACKED_FILES_DIRTY:-}" == "true" ]]; then
|
||||
FLAGS+='--untracked-files=no'
|
||||
fi
|
||||
case "${GIT_STATUS_IGNORE_SUBMODULES:-}" in
|
||||
git)
|
||||
# let git decide (this respects per-repo config in .gitmodules)
|
||||
;;
|
||||
*)
|
||||
# if unset: ignore dirty submodules
|
||||
# other values are passed to --ignore-submodules
|
||||
FLAGS+="--ignore-submodules=${GIT_STATUS_IGNORE_SUBMODULES:-dirty}"
|
||||
;;
|
||||
esac
|
||||
STATUS=$(__git_prompt_git status ${FLAGS} 2> /dev/null | tail -n 1)
|
||||
fi
|
||||
if [[ -n $STATUS ]]; then
|
||||
echo "$ZSH_THEME_GIT_PROMPT_DIRTY"
|
||||
else
|
||||
echo "$ZSH_THEME_GIT_PROMPT_CLEAN"
|
||||
fi
|
||||
}
|
||||
|
||||
# Gets the difference between the local and remote branches
|
||||
function git_remote_status() {
|
||||
local remote ahead behind git_remote_status git_remote_status_detailed
|
||||
remote=${$(__git_prompt_git rev-parse --verify ${hook_com[branch]}@{upstream} --symbolic-full-name 2>/dev/null)/refs\/remotes\/}
|
||||
if [[ -n ${remote} ]]; then
|
||||
ahead=$(__git_prompt_git rev-list ${hook_com[branch]}@{upstream}..HEAD 2>/dev/null | wc -l)
|
||||
behind=$(__git_prompt_git rev-list HEAD..${hook_com[branch]}@{upstream} 2>/dev/null | wc -l)
|
||||
|
||||
if [[ $ahead -eq 0 ]] && [[ $behind -eq 0 ]]; then
|
||||
git_remote_status="$ZSH_THEME_GIT_PROMPT_EQUAL_REMOTE"
|
||||
elif [[ $ahead -gt 0 ]] && [[ $behind -eq 0 ]]; then
|
||||
git_remote_status="$ZSH_THEME_GIT_PROMPT_AHEAD_REMOTE"
|
||||
git_remote_status_detailed="$ZSH_THEME_GIT_PROMPT_AHEAD_REMOTE_COLOR$ZSH_THEME_GIT_PROMPT_AHEAD_REMOTE$((ahead))%{$reset_color%}"
|
||||
elif [[ $behind -gt 0 ]] && [[ $ahead -eq 0 ]]; then
|
||||
git_remote_status="$ZSH_THEME_GIT_PROMPT_BEHIND_REMOTE"
|
||||
git_remote_status_detailed="$ZSH_THEME_GIT_PROMPT_BEHIND_REMOTE_COLOR$ZSH_THEME_GIT_PROMPT_BEHIND_REMOTE$((behind))%{$reset_color%}"
|
||||
elif [[ $ahead -gt 0 ]] && [[ $behind -gt 0 ]]; then
|
||||
git_remote_status="$ZSH_THEME_GIT_PROMPT_DIVERGED_REMOTE"
|
||||
git_remote_status_detailed="$ZSH_THEME_GIT_PROMPT_AHEAD_REMOTE_COLOR$ZSH_THEME_GIT_PROMPT_AHEAD_REMOTE$((ahead))%{$reset_color%}$ZSH_THEME_GIT_PROMPT_BEHIND_REMOTE_COLOR$ZSH_THEME_GIT_PROMPT_BEHIND_REMOTE$((behind))%{$reset_color%}"
|
||||
fi
|
||||
|
||||
if [[ -n $ZSH_THEME_GIT_PROMPT_REMOTE_STATUS_DETAILED ]]; then
|
||||
git_remote_status="$ZSH_THEME_GIT_PROMPT_REMOTE_STATUS_PREFIX${remote:gs/%/%%}$git_remote_status_detailed$ZSH_THEME_GIT_PROMPT_REMOTE_STATUS_SUFFIX"
|
||||
fi
|
||||
|
||||
echo $git_remote_status
|
||||
fi
|
||||
}
|
||||
|
||||
# Outputs the name of the current branch
|
||||
# Usage example: git pull origin $(git_current_branch)
|
||||
# Using '--quiet' with 'symbolic-ref' will not cause a fatal error (128) if
|
||||
# it's not a symbolic ref, but in a Git repo.
|
||||
function git_current_branch() {
|
||||
local ref
|
||||
ref=$(__git_prompt_git symbolic-ref --quiet HEAD 2> /dev/null)
|
||||
local ret=$?
|
||||
if [[ $ret != 0 ]]; then
|
||||
[[ $ret == 128 ]] && return # no git repo.
|
||||
ref=$(__git_prompt_git rev-parse --short HEAD 2> /dev/null) || return
|
||||
fi
|
||||
echo ${ref#refs/heads/}
|
||||
}
|
||||
|
||||
# Outputs the name of the previously checked out branch
|
||||
# Usage example: git pull origin $(git_previous_branch)
|
||||
# rev-parse --symbolic-full-name @{-1} only prints if it is a branch
|
||||
function git_previous_branch() {
|
||||
local ref
|
||||
ref=$(__git_prompt_git rev-parse --quiet --symbolic-full-name @{-1} 2> /dev/null)
|
||||
local ret=$?
|
||||
if [[ $ret != 0 ]] || [[ -z $ref ]]; then
|
||||
return # no git repo or non-branch previous ref
|
||||
fi
|
||||
echo ${ref#refs/heads/}
|
||||
}
|
||||
|
||||
# Gets the number of commits ahead from remote
|
||||
function git_commits_ahead() {
|
||||
if __git_prompt_git rev-parse --git-dir &>/dev/null; then
|
||||
local commits="$(__git_prompt_git rev-list --count @{upstream}..HEAD 2>/dev/null)"
|
||||
if [[ -n "$commits" && "$commits" != 0 ]]; then
|
||||
echo "$ZSH_THEME_GIT_COMMITS_AHEAD_PREFIX$commits$ZSH_THEME_GIT_COMMITS_AHEAD_SUFFIX"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
# Gets the number of commits behind remote
|
||||
function git_commits_behind() {
|
||||
if __git_prompt_git rev-parse --git-dir &>/dev/null; then
|
||||
local commits="$(__git_prompt_git rev-list --count HEAD..@{upstream} 2>/dev/null)"
|
||||
if [[ -n "$commits" && "$commits" != 0 ]]; then
|
||||
echo "$ZSH_THEME_GIT_COMMITS_BEHIND_PREFIX$commits$ZSH_THEME_GIT_COMMITS_BEHIND_SUFFIX"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
# Outputs if current branch is ahead of remote
|
||||
function git_prompt_ahead() {
|
||||
if [[ -n "$(__git_prompt_git rev-list origin/$(git_current_branch)..HEAD 2> /dev/null)" ]]; then
|
||||
echo "$ZSH_THEME_GIT_PROMPT_AHEAD"
|
||||
fi
|
||||
}
|
||||
|
||||
# Outputs if current branch is behind remote
|
||||
function git_prompt_behind() {
|
||||
if [[ -n "$(__git_prompt_git rev-list HEAD..origin/$(git_current_branch) 2> /dev/null)" ]]; then
|
||||
echo "$ZSH_THEME_GIT_PROMPT_BEHIND"
|
||||
fi
|
||||
}
|
||||
|
||||
# Outputs if current branch exists on remote or not
|
||||
function git_prompt_remote() {
|
||||
if [[ -n "$(__git_prompt_git show-ref origin/$(git_current_branch) 2> /dev/null)" ]]; then
|
||||
echo "$ZSH_THEME_GIT_PROMPT_REMOTE_EXISTS"
|
||||
else
|
||||
echo "$ZSH_THEME_GIT_PROMPT_REMOTE_MISSING"
|
||||
fi
|
||||
}
|
||||
|
||||
# Formats prompt string for current git commit short SHA
|
||||
function git_prompt_short_sha() {
|
||||
local SHA
|
||||
SHA=$(__git_prompt_git rev-parse --short HEAD 2> /dev/null) && echo "$ZSH_THEME_GIT_PROMPT_SHA_BEFORE$SHA$ZSH_THEME_GIT_PROMPT_SHA_AFTER"
|
||||
}
|
||||
|
||||
# Formats prompt string for current git commit long SHA
|
||||
function git_prompt_long_sha() {
|
||||
local SHA
|
||||
SHA=$(__git_prompt_git rev-parse HEAD 2> /dev/null) && echo "$ZSH_THEME_GIT_PROMPT_SHA_BEFORE$SHA$ZSH_THEME_GIT_PROMPT_SHA_AFTER"
|
||||
}
|
||||
|
||||
# Outputs the name of the current user
|
||||
# Usage example: $(git_current_user_name)
|
||||
function git_current_user_name() {
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ else
|
|||
}
|
||||
|
||||
# Ignore these folders (if the necessary grep flags are available)
|
||||
EXC_FOLDERS="{.bzr,CVS,.git,.hg,.svn,.idea,.tox}"
|
||||
EXC_FOLDERS="{.bzr,CVS,.git,.hg,.svn,.idea,.tox,.venv,venv}"
|
||||
|
||||
# Check for --exclude-dir, otherwise check for --exclude. If --exclude
|
||||
# isn't available, --color won't be either (they were released at the same
|
||||
|
|
@ -24,8 +24,8 @@ else
|
|||
if [[ -n "$GREP_OPTIONS" ]]; then
|
||||
# export grep, egrep and fgrep settings
|
||||
alias grep="grep $GREP_OPTIONS"
|
||||
alias egrep="grep -E $GREP_OPTIONS"
|
||||
alias fgrep="grep -F $GREP_OPTIONS"
|
||||
alias egrep="grep -E"
|
||||
alias fgrep="grep -F"
|
||||
|
||||
# write to cache file if cache directory is writable
|
||||
if [[ -w "$ZSH_CACHE_DIR" ]]; then
|
||||
|
|
|
|||
|
|
@ -1,19 +1,27 @@
|
|||
## History wrapper
|
||||
function omz_history {
|
||||
local clear list
|
||||
zparseopts -E c=clear l=list
|
||||
# parse arguments and remove from $@
|
||||
local clear list stamp REPLY
|
||||
zparseopts -E -D c=clear l=list f=stamp E=stamp i=stamp t:=stamp
|
||||
|
||||
if [[ -n "$clear" ]]; then
|
||||
# if -c provided, clobber the history file
|
||||
echo -n >| "$HISTFILE"
|
||||
|
||||
# confirm action before deleting history
|
||||
print -nu2 "This action will irreversibly delete your command history. Are you sure? [y/N] "
|
||||
builtin read -E
|
||||
[[ "$REPLY" = [yY] ]] || return 0
|
||||
|
||||
print -nu2 >| "$HISTFILE"
|
||||
fc -p "$HISTFILE"
|
||||
echo >&2 History file deleted.
|
||||
elif [[ -n "$list" ]]; then
|
||||
# if -l provided, run as if calling `fc' directly
|
||||
builtin fc "$@"
|
||||
|
||||
print -u2 History file deleted.
|
||||
elif [[ $# -eq 0 ]]; then
|
||||
# if no arguments provided, show full history starting from 1
|
||||
builtin fc "${stamp[@]}" -l 1
|
||||
else
|
||||
# unless a number is provided, show all history events (starting from 1)
|
||||
[[ ${@[-1]-} = *[0-9]* ]] && builtin fc -l "$@" || builtin fc -l "$@" 1
|
||||
# otherwise, run `fc -l` with a custom format
|
||||
builtin fc "${stamp[@]}" -l "$@"
|
||||
fi
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -32,19 +32,26 @@ if [[ -n "${terminfo[knp]}" ]]; then
|
|||
fi
|
||||
|
||||
# Start typing + [Up-Arrow] - fuzzy find history forward
|
||||
if [[ -n "${terminfo[kcuu1]}" ]]; then
|
||||
autoload -U up-line-or-beginning-search
|
||||
zle -N up-line-or-beginning-search
|
||||
autoload -U up-line-or-beginning-search
|
||||
zle -N up-line-or-beginning-search
|
||||
|
||||
bindkey -M emacs "^[[A" up-line-or-beginning-search
|
||||
bindkey -M viins "^[[A" up-line-or-beginning-search
|
||||
bindkey -M vicmd "^[[A" up-line-or-beginning-search
|
||||
if [[ -n "${terminfo[kcuu1]}" ]]; then
|
||||
bindkey -M emacs "${terminfo[kcuu1]}" up-line-or-beginning-search
|
||||
bindkey -M viins "${terminfo[kcuu1]}" up-line-or-beginning-search
|
||||
bindkey -M vicmd "${terminfo[kcuu1]}" up-line-or-beginning-search
|
||||
fi
|
||||
# Start typing + [Down-Arrow] - fuzzy find history backward
|
||||
if [[ -n "${terminfo[kcud1]}" ]]; then
|
||||
autoload -U down-line-or-beginning-search
|
||||
zle -N down-line-or-beginning-search
|
||||
|
||||
# Start typing + [Down-Arrow] - fuzzy find history backward
|
||||
autoload -U down-line-or-beginning-search
|
||||
zle -N down-line-or-beginning-search
|
||||
|
||||
bindkey -M emacs "^[[B" down-line-or-beginning-search
|
||||
bindkey -M viins "^[[B" down-line-or-beginning-search
|
||||
bindkey -M vicmd "^[[B" down-line-or-beginning-search
|
||||
if [[ -n "${terminfo[kcud1]}" ]]; then
|
||||
bindkey -M emacs "${terminfo[kcud1]}" down-line-or-beginning-search
|
||||
bindkey -M viins "${terminfo[kcud1]}" down-line-or-beginning-search
|
||||
bindkey -M vicmd "${terminfo[kcud1]}" down-line-or-beginning-search
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ setopt multios # enable redirect to multiple streams: echo >file1 >
|
|||
setopt long_list_jobs # show long list format job notifications
|
||||
setopt interactivecomments # recognize comments
|
||||
|
||||
# define pager dependant on what is available (less or more)
|
||||
# define pager depending on what is available (less or more)
|
||||
if (( ${+commands[less]} )); then
|
||||
env_default 'PAGER' 'less'
|
||||
env_default 'LESS' '-R'
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ function chruby_prompt_info \
|
|||
jenv_prompt_info \
|
||||
azure_prompt_info \
|
||||
tf_prompt_info \
|
||||
conda_prompt_info \
|
||||
{
|
||||
return 1
|
||||
}
|
||||
|
|
@ -40,5 +41,5 @@ ZSH_THEME_RVM_PROMPT_OPTIONS="i v g"
|
|||
# use this to enable users to see their ruby version, no matter which
|
||||
# version management system they use
|
||||
function ruby_prompt_info() {
|
||||
echo $(rvm_prompt_info || rbenv_prompt_info || chruby_prompt_info)
|
||||
echo "$(rvm_prompt_info || rbenv_prompt_info || chruby_prompt_info)"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ typeset -AHg FX FG BG
|
|||
FX=(
|
||||
reset "%{[00m%}"
|
||||
bold "%{[01m%}" no-bold "%{[22m%}"
|
||||
dim "%{[02m%}" no-dim "%{[22m%}"
|
||||
italic "%{[03m%}" no-italic "%{[23m%}"
|
||||
underline "%{[04m%}" no-underline "%{[24m%}"
|
||||
blink "%{[05m%}" no-blink "%{[25m%}"
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ function title {
|
|||
: ${2=$1}
|
||||
|
||||
case "$TERM" in
|
||||
cygwin|xterm*|putty*|rxvt*|konsole*|ansi|mlterm*|alacritty|st*|foot*|contour*)
|
||||
cygwin|xterm*|putty*|rxvt*|konsole*|ansi|mlterm*|alacritty*|st*|foot*|contour*|wezterm*)
|
||||
print -Pn "\e]2;${2:q}\a" # set window name
|
||||
print -Pn "\e]1;${1:q}\a" # set tab name
|
||||
;;
|
||||
|
|
@ -47,7 +47,7 @@ fi
|
|||
|
||||
# Runs before showing the prompt
|
||||
function omz_termsupport_precmd {
|
||||
[[ "${DISABLE_AUTO_TITLE:-}" != true ]] || return
|
||||
[[ "${DISABLE_AUTO_TITLE:-}" != true ]] || return 0
|
||||
title "$ZSH_THEME_TERM_TAB_TITLE_IDLE" "$ZSH_THEME_TERM_TITLE_IDLE"
|
||||
}
|
||||
|
||||
|
|
@ -129,7 +129,7 @@ fi
|
|||
# Don't define the function if we're in an unsupported terminal
|
||||
case "$TERM" in
|
||||
# all of these either process OSC 7 correctly or ignore entirely
|
||||
xterm*|putty*|rxvt*|konsole*|mlterm*|alacritty|screen*|tmux*) ;;
|
||||
xterm*|putty*|rxvt*|konsole*|mlterm*|alacritty*|screen*|tmux*) ;;
|
||||
contour*|foot*) ;;
|
||||
*)
|
||||
# Terminal.app and iTerm2 process OSC 7 correctly
|
||||
|
|
@ -145,6 +145,7 @@ esac
|
|||
# Identifies the directory using a file: URI scheme, including
|
||||
# the host name to disambiguate local vs. remote paths.
|
||||
function omz_termsupport_cwd {
|
||||
setopt localoptions unset
|
||||
# Percent-encode the host and path names.
|
||||
local URL_HOST URL_PATH
|
||||
URL_HOST="$(omz_urlencode -P $HOST)" || return 1
|
||||
|
|
|
|||
169
lib/tests/cli.test.zsh
Normal file
169
lib/tests/cli.test.zsh
Normal file
|
|
@ -0,0 +1,169 @@
|
|||
#!/usr/bin/zsh -df
|
||||
|
||||
run_awk() {
|
||||
local -a dis_plugins=(${=1})
|
||||
local input_text="$2"
|
||||
|
||||
(( ! DEBUG )) || set -xv
|
||||
|
||||
local awk_subst_plugins="\
|
||||
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
|
||||
"
|
||||
# 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 }
|
||||
"
|
||||
|
||||
command awk "$awk_script" <<< "$input_text"
|
||||
|
||||
(( ! DEBUG )) || set +xv
|
||||
}
|
||||
|
||||
# runs awk against stdin, checks if the resulting file is not empty and then checks if the file has valid zsh syntax
|
||||
run_awk_and_test() {
|
||||
local description="$1"
|
||||
local plugins_to_disable="$2"
|
||||
local input_text="$3"
|
||||
local expected_output="$4"
|
||||
|
||||
local tmpfile==(:)
|
||||
|
||||
{
|
||||
print -u2 "Test: $description"
|
||||
DEBUG=0 run_awk "$plugins_to_disable" "$input_text" >| $tmpfile
|
||||
|
||||
if [[ ! -s "$tmpfile" ]]; then
|
||||
print -u2 "\e[31mError\e[0m: output file empty"
|
||||
return 1
|
||||
fi
|
||||
|
||||
if ! zsh -n $tmpfile; then
|
||||
print -u2 "\e[31mError\e[0m: zsh syntax error"
|
||||
diff -u $tmpfile <(echo "$expected_output")
|
||||
return 1
|
||||
fi
|
||||
|
||||
if ! diff -u --color=always $tmpfile <(echo "$expected_output"); then
|
||||
if (( DEBUG )); then
|
||||
print -u2 ""
|
||||
DEBUG=1 run_awk "$plugins_to_disable" "$input_text"
|
||||
print -u2 ""
|
||||
fi
|
||||
print -u2 "\e[31mError\e[0m: output file does not match expected output"
|
||||
return 1
|
||||
fi
|
||||
|
||||
print -u2 "\e[32mSuccess\e[0m"
|
||||
} always {
|
||||
print -u2 ""
|
||||
command rm -f "$tmpfile"
|
||||
}
|
||||
}
|
||||
|
||||
# These tests are for the `omz plugin disable` command
|
||||
run_awk_and_test \
|
||||
"it should delete a single plugin in oneline format" \
|
||||
"git" \
|
||||
"plugins=(git)" \
|
||||
"plugins=()"
|
||||
|
||||
run_awk_and_test \
|
||||
"it should delete a single plugin in multiline format" \
|
||||
"github" \
|
||||
"plugins=(
|
||||
github
|
||||
)" \
|
||||
"plugins=(
|
||||
)"
|
||||
|
||||
run_awk_and_test \
|
||||
"it should delete multiple plugins in oneline format" \
|
||||
"github git z" \
|
||||
"plugins=(github git z)" \
|
||||
"plugins=()"
|
||||
|
||||
run_awk_and_test \
|
||||
"it should delete multiple plugins in multiline format" \
|
||||
"github git z" \
|
||||
"plugins=(
|
||||
github
|
||||
git
|
||||
z
|
||||
)" \
|
||||
"plugins=(
|
||||
)"
|
||||
|
||||
run_awk_and_test \
|
||||
"it should delete a single plugin among multiple in oneline format" \
|
||||
"git" \
|
||||
"plugins=(github git z)" \
|
||||
"plugins=(github z)"
|
||||
|
||||
run_awk_and_test \
|
||||
"it should delete a single plugin among multiple in multiline format" \
|
||||
"git" \
|
||||
"plugins=(
|
||||
github
|
||||
git
|
||||
z
|
||||
)" \
|
||||
"plugins=(
|
||||
github
|
||||
z
|
||||
)"
|
||||
|
||||
run_awk_and_test \
|
||||
"it should delete multiple plugins in mixed format" \
|
||||
"git z" \
|
||||
"plugins=(github
|
||||
git z)" \
|
||||
"plugins=(github
|
||||
)"
|
||||
|
||||
run_awk_and_test \
|
||||
"it should delete multiple plugins in mixed format 2" \
|
||||
"github z" \
|
||||
"plugins=(github
|
||||
git
|
||||
z)" \
|
||||
"plugins=(
|
||||
git
|
||||
)"
|
||||
24
oh-my-zsh.sh
24
oh-my-zsh.sh
|
|
@ -48,13 +48,15 @@ omz_f() {
|
|||
unset -f omz_f
|
||||
|
||||
# If ZSH is not defined, use the current script's directory.
|
||||
[[ -z "$ZSH" ]] && export ZSH="${${(%):-%x}:a:h}"
|
||||
[[ -n "$ZSH" ]] || export ZSH="${${(%):-%x}:a:h}"
|
||||
|
||||
# Set ZSH_CUSTOM to the path where your custom config files
|
||||
# and plugins exists, or else we will use the default custom/
|
||||
[[ -n "$ZSH_CUSTOM" ]] || ZSH_CUSTOM="$ZSH/custom"
|
||||
|
||||
# Set ZSH_CACHE_DIR to the path where cache files should be created
|
||||
# or else we will use the default cache/
|
||||
if [[ -z "$ZSH_CACHE_DIR" ]]; then
|
||||
ZSH_CACHE_DIR="$ZSH/cache"
|
||||
fi
|
||||
[[ -n "$ZSH_CACHE_DIR" ]] || ZSH_CACHE_DIR="$ZSH/cache"
|
||||
|
||||
# Make sure $ZSH_CACHE_DIR is writable, otherwise use a directory in $HOME
|
||||
if [[ ! -w "$ZSH_CACHE_DIR" ]]; then
|
||||
|
|
@ -63,7 +65,7 @@ fi
|
|||
|
||||
# Create cache and completions dir and add to $fpath
|
||||
mkdir -p "$ZSH_CACHE_DIR/completions"
|
||||
(( ${fpath[(Ie)"$ZSH_CACHE_DIR/completions"]} )) || fpath=("$ZSH_CACHE_DIR/completions" $fpath)
|
||||
(( ${fpath[(Ie)$ZSH_CACHE_DIR/completions]} )) || fpath=("$ZSH_CACHE_DIR/completions" $fpath)
|
||||
|
||||
# Check for updates on initial load...
|
||||
source "$ZSH/tools/check_for_upgrade.sh"
|
||||
|
|
@ -71,17 +73,11 @@ source "$ZSH/tools/check_for_upgrade.sh"
|
|||
# Initializes Oh My Zsh
|
||||
|
||||
# add a function path
|
||||
fpath=("$ZSH/functions" "$ZSH/completions" $fpath)
|
||||
fpath=($ZSH/{functions,completions} $ZSH_CUSTOM/{functions,completions} $fpath)
|
||||
|
||||
# Load all stock functions (from $fpath files) called below.
|
||||
autoload -U compaudit compinit zrecompile
|
||||
|
||||
# Set ZSH_CUSTOM to the path where your custom config files
|
||||
# and plugins exists, or else we will use the default custom/
|
||||
if [[ -z "$ZSH_CUSTOM" ]]; then
|
||||
ZSH_CUSTOM="$ZSH/custom"
|
||||
fi
|
||||
|
||||
is_plugin() {
|
||||
local base_dir=$1
|
||||
local name=$2
|
||||
|
|
@ -152,7 +148,7 @@ unset zcompdump_revision zcompdump_fpath zcompdump_refresh
|
|||
# zcompile the completion dump file if the .zwc is older or missing.
|
||||
if command mkdir "${ZSH_COMPDUMP}.lock" 2>/dev/null; then
|
||||
zrecompile -q -p "$ZSH_COMPDUMP"
|
||||
command rm -rf "$ZSH_COMPDUMP.zwc.old" "${ZSH_COMPDUMP}.lock"
|
||||
command rm -rf "$ZSH_COMPDUMP.zwc.old" "${ZSH_COMPDUMP}.lock"
|
||||
fi
|
||||
|
||||
_omz_source() {
|
||||
|
|
@ -196,7 +192,7 @@ _omz_source() {
|
|||
fi
|
||||
}
|
||||
|
||||
# Load all of the lib files in ~/oh-my-zsh/lib that end in .zsh
|
||||
# Load all of the lib files in ~/.oh-my-zsh/lib that end in .zsh
|
||||
# TIP: Add files you don't want in git to .gitignore
|
||||
for lib_file ("$ZSH"/lib/*.zsh); do
|
||||
_omz_source "lib/${lib_file:t}"
|
||||
|
|
|
|||
|
|
@ -1,9 +1,15 @@
|
|||
# Do nothing if op is not installed
|
||||
(( ${+commands[op]} )) || return
|
||||
|
||||
# Load op completion
|
||||
eval "$(op completion zsh)"
|
||||
compdef _op op
|
||||
# If the completion file doesn't exist yet, we need to autoload it and
|
||||
# bind it to `op`. Otherwise, compinit will have already done that.
|
||||
if [[ ! -f "$ZSH_CACHE_DIR/completions/_op" ]]; then
|
||||
typeset -g -A _comps
|
||||
autoload -Uz _op
|
||||
_comps[op]=_op
|
||||
fi
|
||||
|
||||
op completion zsh >| "$ZSH_CACHE_DIR/completions/_op" &|
|
||||
|
||||
# Load opswd function
|
||||
autoload -Uz opswd
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ function opswd() {
|
|||
|
||||
local password
|
||||
# Copy the password to the clipboard
|
||||
if ! password=$(op item get "$service" --fields password 2>/dev/null); then
|
||||
if ! password=$(op item get "$service" --reveal --fields password 2>/dev/null); then
|
||||
echo "error: could not obtain password for $service"
|
||||
return 1
|
||||
fi
|
||||
|
|
|
|||
|
|
@ -1,8 +0,0 @@
|
|||
# adb autocomplete plugin
|
||||
|
||||
* Adds autocomplete options for all adb commands.
|
||||
* Add autocomplete for `adb -s`
|
||||
|
||||
## Requirements
|
||||
|
||||
In order to make this work, you will need to have the Android adb tools set up in your path.
|
||||
|
|
@ -1,67 +0,0 @@
|
|||
#compdef adb
|
||||
#autoload
|
||||
|
||||
# in order to make this work, you will need to have the android adb tools
|
||||
|
||||
# adb zsh completion, based on homebrew completion
|
||||
|
||||
local -a _1st_arguments
|
||||
_1st_arguments=(
|
||||
'bugreport:return all information from the device that should be included in a bug report.'
|
||||
'connect:connect to a device via TCP/IP Port 5555 is default.'
|
||||
'devices:list all connected devices'
|
||||
'disconnect:disconnect from a TCP/IP device. Port 5555 is default.'
|
||||
'emu:run emulator console command'
|
||||
'forward:forward socket connections'
|
||||
'get-devpath:print the device path'
|
||||
'get-serialno:print the serial number of the device'
|
||||
'get-state:print the current state of the device: offline | bootloader | device'
|
||||
'help:show the help message'
|
||||
'install:push this package file to the device and install it'
|
||||
'jdwp:list PIDs of processes hosting a JDWP transport'
|
||||
'keygen:generate adb public/private key'
|
||||
'kill-server:kill the server if it is running'
|
||||
'logcat:view device log'
|
||||
'pull:copy file/dir from device'
|
||||
'push:copy file/dir to device'
|
||||
'reboot:reboots the device, optionally into the bootloader or recovery program'
|
||||
'reboot-bootloader:reboots the device into the bootloader'
|
||||
'remount:remounts the partitions on the device read-write'
|
||||
'root:restarts the adbd daemon with root permissions'
|
||||
'sideload:push a ZIP to device and install it'
|
||||
'shell:run remote shell interactively'
|
||||
'sync:copy host->device only if changed (-l means list but dont copy)'
|
||||
'start-server:ensure that there is a server running'
|
||||
'tcpip:restart host adb in tcpip mode'
|
||||
'uninstall:remove this app package from the device'
|
||||
'usb:restart the adbd daemon listing on USB'
|
||||
'version:show version num'
|
||||
'wait-for-device:block until device is online'
|
||||
)
|
||||
|
||||
local expl
|
||||
local -a pkgs installed_pkgs
|
||||
|
||||
_arguments \
|
||||
'-s[devices]:specify device:->specify_device' \
|
||||
'*:: :->subcmds' && return 0
|
||||
|
||||
case "$state" in
|
||||
specify_device)
|
||||
_values -C 'devices' ${$(adb devices -l|awk 'NR>1&& $1 \
|
||||
{sub(/ +/," ",$0); \
|
||||
gsub(":","\\:",$1); \
|
||||
for(i=1;i<=NF;i++) {
|
||||
if($i ~ /model:/) { split($i,m,":") } \
|
||||
else if($i ~ /product:/) { split($i,p,":") } } \
|
||||
printf "%s[%s(%s)] ",$1, p[2], m[2]}'):-""}
|
||||
return
|
||||
;;
|
||||
esac
|
||||
|
||||
if (( CURRENT == 1 )); then
|
||||
_describe -t commands "adb subcommand" _1st_arguments
|
||||
return
|
||||
fi
|
||||
|
||||
_files
|
||||
|
|
@ -1,13 +0,0 @@
|
|||
# The Silver Searcher
|
||||
|
||||
This plugin provides completion support for [`ag`](https://github.com/ggreer/the_silver_searcher).
|
||||
|
||||
To use it, add ag to the plugins array in your zshrc file.
|
||||
|
||||
```zsh
|
||||
plugins=(... ag)
|
||||
```
|
||||
|
||||
## INSTALLATION NOTES
|
||||
|
||||
Besides oh-my-zsh, `ag` needs to be installed by following these steps: https://github.com/ggreer/the_silver_searcher#installing.
|
||||
|
|
@ -1,66 +0,0 @@
|
|||
#compdef ag
|
||||
#autoload
|
||||
|
||||
typeset -A opt_args
|
||||
|
||||
# Took the liberty of not listing every option… specially aliases and -D
|
||||
_ag () {
|
||||
local -a _1st_arguments
|
||||
_1st_arguments=(
|
||||
'--ackmate:Print results in AckMate-parseable format'
|
||||
{'-A','--after'}':[LINES] Print lines after match (Default: 2)'
|
||||
{'-B','--before'}':[LINES] Print lines before match (Default: 2)'
|
||||
'--break:Print newlines between matches in different files'
|
||||
'--nobreak:Do not print newlines between matches in different files'
|
||||
{'-c','--count'}':Only print the number of matches in each file'
|
||||
'--color:Print color codes in results (Default: On)'
|
||||
'--nocolor:Do not print color codes in results'
|
||||
'--color-line-number:Color codes for line numbers (Default: 1;33)'
|
||||
'--color-match:Color codes for result match numbers (Default: 30;43)'
|
||||
'--color-path:Color codes for path names (Default: 1;32)'
|
||||
'--column:Print column numbers in results'
|
||||
{'-H','--heading'}':Print file names (On unless searching a single file)'
|
||||
'--noheading:Do not print file names (On unless searching a single file)'
|
||||
'--line-numbers:Print line numbers even for streams'
|
||||
{'-C','--context'}':[LINES] Print lines before and after matches (Default: 2)'
|
||||
'-g:[PATTERN] Print filenames matching PATTERN'
|
||||
{'-l','--files-with-matches'}':Only print filenames that contain matches'
|
||||
{'-L','--files-without-matches'}':Only print filenames that do not contain matches'
|
||||
'--no-numbers:Do not print line numbers'
|
||||
{'-o','--only-matching'}':Prints only the matching part of the lines'
|
||||
'--print-long-lines:Print matches on very long lines (Default: 2k characters)'
|
||||
'--passthrough:When searching a stream, print all lines even if they do not match'
|
||||
'--silent:Suppress all log messages, including errors'
|
||||
'--stats:Print stats (files scanned, time taken, etc.)'
|
||||
'--vimgrep:Print results like vim :vimgrep /pattern/g would'
|
||||
{'-0','--null'}':Separate filenames with null (for "xargs -0")'
|
||||
|
||||
{'-a','--all-types'}':Search all files (does not include hidden files / .gitignore)'
|
||||
'--depth:[NUM] Search up to NUM directories deep (Default: 25)'
|
||||
{'-f','--follow'}':Follow symlinks'
|
||||
{'-G','--file-search-regex'}':[PATTERN] Limit search to filenames matching PATTERN'
|
||||
'--hidden:Search hidden files (obeys .*ignore files)'
|
||||
{'-i','--ignore-case'}':Match case insensitively'
|
||||
'--ignore:[PATTERN] Ignore files/directories matching PATTERN'
|
||||
{'-m','--max-count'}':[NUM] Skip the rest of a file after NUM matches (Default: 10k)'
|
||||
{'-p','--path-to-agignore'}':[PATH] Use .agignore file at PATH'
|
||||
{'-Q','--literal'}':Do not parse PATTERN as a regular expression'
|
||||
{'-s','--case-sensitive'}':Match case'
|
||||
{'-S','--smart-case'}':Insensitive match unless PATTERN has uppercase (Default: On)'
|
||||
'--search-binary:Search binary files for matches'
|
||||
{'-t','--all-text'}':Search all text files (Hidden files not included)'
|
||||
{'-u','--unrestricted'}':Search all files (ignore .agignore and _all_)'
|
||||
{'-U','--skip-vcs-ignores'}':Ignore VCS files (stil obey .agignore)'
|
||||
{'-v','--invert-match'}':Invert match'
|
||||
{'-w','--word-regexp'}':Only match whole words'
|
||||
{'-z','--search-zip'}':Search contents of compressed (e.g., gzip) files'
|
||||
|
||||
'--list-file-types:list of supported file types'
|
||||
)
|
||||
|
||||
if [[ $words[-1] =~ "^-" ]]; then
|
||||
_describe -t commands "ag options" _1st_arguments && ret=0
|
||||
else
|
||||
_files && ret=0
|
||||
fi
|
||||
}
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
This plugin searches the defined aliases and outputs any that match the command inputted. This makes learning new aliases easier.
|
||||
|
||||
## Usage
|
||||
## Setup
|
||||
|
||||
To use it, add `alias-finder` to the `plugins` array of your zshrc file:
|
||||
```
|
||||
|
|
@ -22,6 +22,41 @@ zstyle ':omz:plugins:alias-finder' cheaper yes # disabled by default
|
|||
|
||||
As you can see, options are also available with zstyle.
|
||||
|
||||
## Usage
|
||||
|
||||
When you execute a command alias finder will look at your defined aliases and suggest shorter aliases you could have used, for example:
|
||||
|
||||
Running the un-aliased `git status` command:
|
||||
```sh
|
||||
╭─tim@fox ~/repo/gitopolis ‹main›
|
||||
╰─$ git status
|
||||
|
||||
gst='git status' # <=== shorter suggestion from alias-finder
|
||||
|
||||
On branch main
|
||||
Your branch is up-to-date with 'origin/main'.
|
||||
nothing to commit, working tree clean
|
||||
```
|
||||
|
||||
Running a shorter `git st` alias from `.gitconfig` that it suggested :
|
||||
```sh
|
||||
╭─tim@fox ~/repo/gitopolis ‹main›
|
||||
╰─$ git st
|
||||
gs='git st' # <=== shorter suggestion from alias-finder
|
||||
## main...origin/main
|
||||
```
|
||||
|
||||
Running the shortest `gs` shell alias that it found:
|
||||
```sh
|
||||
╭─tim@fox ~/repo/gitopolis ‹main›
|
||||
╰─$ gs
|
||||
# <=== no suggestions alias-finder because this is the shortest
|
||||
## main...origin/main
|
||||
```
|
||||
|
||||

|
||||
|
||||
|
||||
### Options
|
||||
|
||||
> In order to clarify, let's say `alias a=abc` has source 'abc' and destination 'a'.
|
||||
|
|
|
|||
|
|
@ -36,14 +36,18 @@ alias-finder() {
|
|||
# make filter to find only shorter results than current cmd
|
||||
if [[ $cheaper == true ]]; then
|
||||
cmdLen=$(echo -n "$cmd" | wc -c)
|
||||
filter="^'{0,1}.{0,$((cmdLen - 1))}="
|
||||
if [[ $cmdLen -le 1 ]]; then
|
||||
return
|
||||
fi
|
||||
|
||||
filter="^'?.{1,$((cmdLen - 1))}'?=" # some aliases is surrounded by single quotes
|
||||
fi
|
||||
|
||||
alias | grep -E "$filter" | grep -E "=$finder"
|
||||
|
||||
if [[ $exact == true ]]; then
|
||||
break # because exact case is only one
|
||||
elif [[ $longer = true ]]; then
|
||||
elif [[ $longer == true ]]; then
|
||||
break # because above grep command already found every longer aliases during first cycle
|
||||
fi
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,5 @@
|
|||
# Aliases cheatsheet
|
||||
|
||||
**Maintainer:** [@hqingyi](https://github.com/hqingyi)
|
||||
|
||||
With lots of 3rd-party amazing aliases installed, this plugin helps list the shortcuts
|
||||
that are currently available based on the plugins you have enabled.
|
||||
|
||||
|
|
@ -13,6 +11,8 @@ plugins=(aliases)
|
|||
|
||||
Requirements: Python needs to be installed.
|
||||
|
||||
**Maintainer:** [@hqingyi](https://github.com/hqingyi)
|
||||
|
||||
## Usage
|
||||
|
||||
- `als`: show all aliases by group
|
||||
|
|
|
|||
|
|
@ -1,7 +1,5 @@
|
|||
# ansible plugin
|
||||
|
||||
## Introduction
|
||||
|
||||
The `ansible plugin` adds several aliases for useful [ansible](https://docs.ansible.com/ansible/latest/index.html) commands and [aliases](#aliases).
|
||||
|
||||
To use it, add `ansible` to the plugins array of your zshrc file:
|
||||
|
|
@ -21,7 +19,6 @@ plugins=(... ansible)
|
|||
| `acon` | command `ansible-console` |
|
||||
| `ainv` | command `ansible-inventory` |
|
||||
| `aplaybook` | command `ansible-playbook` |
|
||||
| `ainv` | command `ansible-inventory` |
|
||||
| `adoc` | command `ansible-doc` |
|
||||
| `agal` | command `ansible-galaxy` |
|
||||
| `apull` | command `ansible-pull` |
|
||||
|
|
@ -29,6 +26,6 @@ plugins=(... ansible)
|
|||
|
||||
## Maintainer
|
||||
|
||||
### [Deepankumar](https://github.com/deepan10)
|
||||
### [Deepankumar](https://github.com/deepan10)
|
||||
|
||||
[https://github.com/deepan10/oh-my-zsh/tree/features/ansible-plugin](https://github.com/deepan10/oh-my-zsh/tree/features/ansible-plugin)
|
||||
|
|
|
|||
|
|
@ -178,26 +178,27 @@ fi
|
|||
|
||||
# Check Arch Linux PGP Keyring before System Upgrade to prevent failure.
|
||||
function upgrade() {
|
||||
sudo pacman -Sy
|
||||
echo ":: Checking Arch Linux PGP Keyring..."
|
||||
local installedver="$(sudo pacman -Qi archlinux-keyring | grep -Po '(?<=Version : ).*')"
|
||||
local currentver="$(sudo pacman -Si archlinux-keyring | grep -Po '(?<=Version : ).*')"
|
||||
local installedver="$(LANG= sudo pacman -Qi archlinux-keyring | grep -Po '(?<=Version : ).*')"
|
||||
local currentver="$(LANG= sudo pacman -Si archlinux-keyring | grep -Po '(?<=Version : ).*')"
|
||||
if [ $installedver != $currentver ]; then
|
||||
echo " Arch Linux PGP Keyring is out of date."
|
||||
echo " Updating before full system upgrade."
|
||||
sudo pacman -Sy --needed --noconfirm archlinux-keyring
|
||||
sudo pacman -S --needed --noconfirm archlinux-keyring
|
||||
else
|
||||
echo " Arch Linux PGP Keyring is up to date."
|
||||
echo " Proceeding with full system upgrade."
|
||||
fi
|
||||
if (( $+commands[yay] )); then
|
||||
yay -Syu
|
||||
yay -Su
|
||||
elif (( $+commands[trizen] )); then
|
||||
trizen -Syu
|
||||
trizen -Su
|
||||
elif (( $+commands[pacaur] )); then
|
||||
pacaur -Syu
|
||||
pacaur -Su
|
||||
elif (( $+commands[aura] )); then
|
||||
sudo aura -Syu
|
||||
sudo aura -Su
|
||||
else
|
||||
sudo pacman -Syu
|
||||
sudo pacman -Su
|
||||
fi
|
||||
}
|
||||
|
|
|
|||
9
plugins/arduino-cli/README.md
Normal file
9
plugins/arduino-cli/README.md
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
# Arduino CLI plugin
|
||||
|
||||
This plugin adds completion for the [arduino-cli](https://github.com/arduino/arduino-cli) tool.
|
||||
|
||||
To use it, add `arduino-cli` to the plugins array in your zshrc file:
|
||||
|
||||
```zsh
|
||||
plugins=(... arduino-cli)
|
||||
```
|
||||
14
plugins/arduino-cli/arduino-cli.plugin.zsh
Normal file
14
plugins/arduino-cli/arduino-cli.plugin.zsh
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
if (( ! $+commands[arduino-cli] )); then
|
||||
return
|
||||
fi
|
||||
|
||||
# If the completion file doesn't exist yet, we need to autoload it and
|
||||
# bind it to `arduino-cli`. Otherwise, compinit will have already done that.
|
||||
if [[ ! -f "$ZSH_CACHE_DIR/completions/_arduino-cli" ]]; then
|
||||
typeset -g -A _comps
|
||||
autoload -Uz _arduino-cli
|
||||
_comps[arduino-cli]=_arduino-cli
|
||||
fi
|
||||
|
||||
# Generate and load arduino-cli completion
|
||||
arduino-cli completion zsh >! "$ZSH_CACHE_DIR/completions/_arduino-cli" &|
|
||||
|
|
@ -1,30 +1,48 @@
|
|||
## asdf
|
||||
|
||||
**Maintainer:** [@RobLoach](https://github.com/RobLoach)
|
||||
# asdf
|
||||
|
||||
Adds integration with [asdf](https://github.com/asdf-vm/asdf), the extendable version manager, with support for Ruby, Node.js, Elixir, Erlang and more.
|
||||
|
||||
### Installation
|
||||
## Installation
|
||||
|
||||
1. [Download asdf](https://asdf-vm.com/guide/getting-started.html#_2-download-asdf) by running the following:
|
||||
|
||||
```
|
||||
git clone https://github.com/asdf-vm/asdf.git ~/.asdf
|
||||
```
|
||||
|
||||
2. [Enable asdf](https://asdf-vm.com/guide/getting-started.html#_3-install-asdf) by adding it to your `plugins` definition in `~/.zshrc`.
|
||||
|
||||
```
|
||||
plugins=(asdf)
|
||||
```
|
||||
|
||||
### Usage
|
||||
|
||||
See the [asdf documentation](https://asdf-vm.com/guide/getting-started.html#_4-install-a-plugin) for information on how to use asdf:
|
||||
1. [Install](https://asdf-vm.com/guide/getting-started.html#_1-install-asdf) asdf and ensure that's it's discoverable on `$PATH`;
|
||||
2. Enable it by adding it to your `plugins` definition in `~/.zshrc`:
|
||||
|
||||
```sh
|
||||
plugins=(asdf)
|
||||
```
|
||||
asdf plugin add nodejs https://github.com/asdf-vm/asdf-nodejs.git
|
||||
|
||||
## Usage
|
||||
|
||||
Refer to the [asdf plugin documentation](https://asdf-vm.com/guide/getting-started.html#_4-install-a-plugin) for information on how to add a plugin and install the many runtime versions for it.
|
||||
|
||||
Example for installing the nodejs plugin and the many runtimes for it:
|
||||
|
||||
```sh
|
||||
# Add plugin to asdf
|
||||
asdf plugin add nodejs
|
||||
|
||||
# Install the latest available version
|
||||
asdf install nodejs latest
|
||||
asdf global nodejs latest
|
||||
asdf local nodejs latest
|
||||
|
||||
# Uninstall the latest version
|
||||
asdf uninstall nodejs latest
|
||||
|
||||
# Install a specific version
|
||||
asdf install nodejs 16.5.0
|
||||
|
||||
# Set the latest version in .tool-versions of the `current directory`
|
||||
asdf set nodejs latest
|
||||
|
||||
# Set a specific version in the `parent directory`
|
||||
asdf set -p nodejs 16.5.0 # -p is shorthand for --parent
|
||||
|
||||
# Set a global version under `$HOME`
|
||||
asdf set -u nodejs 16.5.0 # -u is shorthand for --home
|
||||
```
|
||||
|
||||
For more commands, run `asdf help` or refer to the
|
||||
[asdf CLI documentation](https://asdf-vm.com/manage/commands.html#all-commands).
|
||||
|
||||
## Maintainer
|
||||
|
||||
- [@RobLoach](https://github.com/RobLoach)
|
||||
|
|
|
|||
|
|
@ -1,30 +1,13 @@
|
|||
# Find where asdf should be installed
|
||||
ASDF_DIR="${ASDF_DIR:-$HOME/.asdf}"
|
||||
ASDF_COMPLETIONS="$ASDF_DIR/completions"
|
||||
(( ! $+commands[asdf] )) && return
|
||||
|
||||
if [[ ! -f "$ASDF_DIR/asdf.sh" || ! -f "$ASDF_COMPLETIONS/_asdf" ]]; then
|
||||
# If not found, check for archlinux/AUR package (/opt/asdf-vm/)
|
||||
if [[ -f "/opt/asdf-vm/asdf.sh" ]]; then
|
||||
ASDF_DIR="/opt/asdf-vm"
|
||||
ASDF_COMPLETIONS="$ASDF_DIR"
|
||||
# If not found, check for Homebrew package
|
||||
elif (( $+commands[brew] )); then
|
||||
_ASDF_PREFIX="$(brew --prefix asdf)"
|
||||
ASDF_DIR="${_ASDF_PREFIX}/libexec"
|
||||
ASDF_COMPLETIONS="${_ASDF_PREFIX}/share/zsh/site-functions"
|
||||
unset _ASDF_PREFIX
|
||||
else
|
||||
return
|
||||
fi
|
||||
fi
|
||||
export ASDF_DATA_DIR="${ASDF_DATA_DIR:-$HOME/.asdf}"
|
||||
path=("$ASDF_DATA_DIR/shims" $path)
|
||||
|
||||
# Load command
|
||||
if [[ -f "$ASDF_DIR/asdf.sh" ]]; then
|
||||
source "$ASDF_DIR/asdf.sh"
|
||||
# Load completions
|
||||
if [[ -f "$ASDF_COMPLETIONS/_asdf" ]]; then
|
||||
fpath+=("$ASDF_COMPLETIONS")
|
||||
autoload -Uz _asdf
|
||||
compdef _asdf asdf # compdef is already loaded before loading plugins
|
||||
fi
|
||||
# If the completion file doesn't exist yet, we need to autoload it and
|
||||
# bind it to `asdf`. Otherwise, compinit will have already done that.
|
||||
if [[ ! -f "$ZSH_CACHE_DIR/completions/_asdf" ]]; then
|
||||
typeset -g -A _comps
|
||||
autoload -Uz _asdf
|
||||
_comps[asdf]=_asdf
|
||||
fi
|
||||
asdf completion zsh >| "$ZSH_CACHE_DIR/completions/_asdf" &|
|
||||
|
|
|
|||
|
|
@ -1,18 +1,22 @@
|
|||
declare -a autojump_paths
|
||||
autojump_paths=(
|
||||
$HOME/.autojump/etc/profile.d/autojump.zsh # manual installation
|
||||
$HOME/.autojump/share/autojump/autojump.zsh # manual installation
|
||||
$HOME/.nix-profile/etc/profile.d/autojump.sh # NixOS installation
|
||||
/run/current-system/sw/share/autojump/autojump.zsh # NixOS installation
|
||||
/usr/share/autojump/autojump.zsh # Debian and Ubuntu package
|
||||
/etc/profile.d/autojump.zsh # manual installation
|
||||
/etc/profile.d/autojump.sh # Gentoo installation
|
||||
/usr/local/share/autojump/autojump.zsh # FreeBSD installation
|
||||
/usr/pkg/share/autojump/autojump.zsh # NetBSD installation
|
||||
/opt/local/etc/profile.d/autojump.sh # macOS with MacPorts
|
||||
/usr/local/etc/profile.d/autojump.sh # macOS with Homebrew (default)
|
||||
/opt/homebrew/etc/profile.d/autojump.sh # macOS with Homebrew (default on M1 macs)
|
||||
/etc/profiles/per-user/$USER/etc/profile.d/autojump.sh # macOS Nix, Home Manager and flakes
|
||||
$HOME/.autojump/etc/profile.d/autojump.zsh # manual installation
|
||||
$HOME/.autojump/share/autojump/autojump.zsh # manual installation
|
||||
$HOME/.nix-profile/etc/profile.d/autojump.sh # NixOS installation
|
||||
/run/current-system/sw/share/autojump/autojump.zsh # NixOS installation
|
||||
/etc/profiles/per-user/$USER/share/autojump/autojump.zsh # Home Manager, NixOS with user-scoped packages
|
||||
/usr/share/autojump/autojump.zsh # Debian and Ubuntu package
|
||||
$PREFIX/share/autojump/autojump.zsh # Termux package
|
||||
/etc/profile.d/autojump.zsh # manual installation
|
||||
/etc/profile.d/autojump.sh # Gentoo installation
|
||||
/usr/local/share/autojump/autojump.zsh # FreeBSD installation
|
||||
/usr/pkg/share/autojump/autojump.zsh # NetBSD installation
|
||||
/opt/local/etc/profile.d/autojump.sh # macOS with MacPorts
|
||||
/usr/local/etc/profile.d/autojump.sh # macOS with Homebrew (default)
|
||||
/opt/homebrew/etc/profile.d/autojump.sh # macOS with Homebrew (default on M1 macs)
|
||||
/opt/pkg/share/autojump/autojump.zsh # macOS with pkgsrc
|
||||
/etc/profiles/per-user/$USER/etc/profile.d/autojump.sh # macOS Nix, Home Manager and flakes
|
||||
/nix/var/nix/gcroots/current-system/sw/share/zsh/site-functions/autojump.zsh # macOS Nix, nix-darwin
|
||||
)
|
||||
|
||||
for file in $autojump_paths; do
|
||||
|
|
|
|||
|
|
@ -47,6 +47,11 @@ plugins=(... aws)
|
|||
Some themes might overwrite the value of RPROMPT instead of appending to it, so they'll need to be fixed to
|
||||
see the AWS profile/region prompt.
|
||||
|
||||
* Set `AWS_PROFILE_STATE_ENABLED=true` in your zshrc file if you want the aws profile to persist between shell sessions.
|
||||
This option might slow down your shell startup time.
|
||||
By default the state file path is `/tmp/.aws_current_profile`. This means that the state won't survive a reboot or otherwise GC.
|
||||
You can control the state file path using the `AWS_STATE_FILE` environment variable.
|
||||
|
||||
## Theme
|
||||
|
||||
The plugin creates an `aws_prompt_info` function that you can use in your theme, which displays
|
||||
|
|
|
|||
|
|
@ -6,10 +6,26 @@ function agr() {
|
|||
echo $AWS_REGION
|
||||
}
|
||||
|
||||
# Update state file if enabled
|
||||
function _aws_update_state() {
|
||||
if [[ "$AWS_PROFILE_STATE_ENABLED" == true ]]; then
|
||||
test -d $(dirname ${AWS_STATE_FILE}) || exit 1
|
||||
echo "${AWS_PROFILE} ${AWS_REGION}" > "${AWS_STATE_FILE}"
|
||||
fi
|
||||
}
|
||||
|
||||
function _aws_clear_state() {
|
||||
if [[ "$AWS_PROFILE_STATE_ENABLED" == true ]]; then
|
||||
test -d $(dirname ${AWS_STATE_FILE}) || exit 1
|
||||
echo -n > "${AWS_STATE_FILE}"
|
||||
fi
|
||||
}
|
||||
|
||||
# AWS profile selection
|
||||
function asp() {
|
||||
if [[ -z "$1" ]]; then
|
||||
unset AWS_DEFAULT_PROFILE AWS_PROFILE AWS_EB_PROFILE AWS_PROFILE_REGION
|
||||
_aws_clear_state
|
||||
echo AWS profile cleared.
|
||||
return
|
||||
fi
|
||||
|
|
@ -28,6 +44,8 @@ function asp() {
|
|||
|
||||
export AWS_PROFILE_REGION=$(aws configure get region)
|
||||
|
||||
_aws_update_state
|
||||
|
||||
if [[ "$2" == "login" ]]; then
|
||||
if [[ -n "$3" ]]; then
|
||||
aws sso login --sso-session $3
|
||||
|
|
@ -43,6 +61,7 @@ function asp() {
|
|||
function asr() {
|
||||
if [[ -z "$1" ]]; then
|
||||
unset AWS_DEFAULT_REGION AWS_REGION
|
||||
_aws_update_state
|
||||
echo AWS region cleared.
|
||||
return
|
||||
fi
|
||||
|
|
@ -56,6 +75,7 @@ function asr() {
|
|||
|
||||
export AWS_REGION=$1
|
||||
export AWS_DEFAULT_REGION=$1
|
||||
_aws_update_state
|
||||
}
|
||||
|
||||
# AWS profile switch
|
||||
|
|
@ -202,8 +222,17 @@ function aws_change_access_key() {
|
|||
}
|
||||
|
||||
function aws_regions() {
|
||||
local region
|
||||
if [[ $AWS_DEFAULT_REGION ]];then
|
||||
region="$AWS_DEFAULT_REGION"
|
||||
elif [[ $AWS_REGION ]];then
|
||||
region="$AWS_REGION"
|
||||
else
|
||||
region="us-west-1"
|
||||
fi
|
||||
|
||||
if [[ $AWS_DEFAULT_PROFILE || $AWS_PROFILE ]];then
|
||||
aws ec2 describe-regions |grep RegionName | awk -F ':' '{gsub(/"/, "", $2);gsub(/,/, "", $2);gsub(/ /, "", $2); print $2}'
|
||||
aws ec2 describe-regions --region $region |grep RegionName | awk -F ':' '{gsub(/"/, "", $2);gsub(/,/, "", $2);gsub(/ /, "", $2); print $2}'
|
||||
else
|
||||
echo "You must specify a AWS profile."
|
||||
fi
|
||||
|
|
@ -246,6 +275,22 @@ if [[ "$SHOW_AWS_PROMPT" != false && "$RPROMPT" != *'$(aws_prompt_info)'* ]]; th
|
|||
RPROMPT='$(aws_prompt_info)'"$RPROMPT"
|
||||
fi
|
||||
|
||||
if [[ "$AWS_PROFILE_STATE_ENABLED" == true ]]; then
|
||||
AWS_STATE_FILE="${AWS_STATE_FILE:-/tmp/.aws_current_profile}"
|
||||
test -s "${AWS_STATE_FILE}" || return
|
||||
|
||||
aws_state=($(cat $AWS_STATE_FILE))
|
||||
|
||||
export AWS_DEFAULT_PROFILE="${aws_state[1]}"
|
||||
export AWS_PROFILE="$AWS_DEFAULT_PROFILE"
|
||||
export AWS_EB_PROFILE="$AWS_DEFAULT_PROFILE"
|
||||
|
||||
test -z "${aws_state[2]}" && AWS_REGION=$(aws configure get region)
|
||||
|
||||
export AWS_REGION=${AWS_REGION:-$aws_state[2]}
|
||||
export AWS_DEFAULT_REGION="$AWS_REGION"
|
||||
fi
|
||||
|
||||
# Load awscli completions
|
||||
|
||||
# AWS CLI v2 comes with its own autocompletion. Check if that is there, otherwise fall back
|
||||
|
|
|
|||
|
|
@ -12,6 +12,13 @@ Then, add the `battery_pct_prompt` function to your custom theme. For example:
|
|||
RPROMPT='$(battery_pct_prompt) ...'
|
||||
```
|
||||
|
||||
Also, you set the `BATTERY_CHARGING` variable to your favor.
|
||||
For example:
|
||||
|
||||
```zsh
|
||||
BATTERY_CHARGING="⚡️"
|
||||
```
|
||||
|
||||
## Requirements
|
||||
|
||||
- On Linux, you must have the `acpi` or `acpitool` commands installed on your operating system.
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ if [[ "$OSTYPE" = darwin* ]]; then
|
|||
fi
|
||||
echo "%{$fg[$color]%}[${battery_pct}%%]%{$reset_color%}"
|
||||
else
|
||||
echo "∞"
|
||||
echo "${BATTERY_CHARGING-⚡️}"
|
||||
fi
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
# Bazel plugin
|
||||
|
||||
This plugin adds completion for [bazel](https://bazel.build), an open-source build and
|
||||
test tool that scalably supports multi-language and multi-platform projects.
|
||||
This plugin adds completion and aliases for [bazel](https://bazel.build), an open-source build and test tool
|
||||
that scalably supports multi-language and multi-platform projects.
|
||||
|
||||
To use it, add `bazel` to the plugins array in your zshrc file:
|
||||
|
||||
|
|
@ -12,3 +12,18 @@ plugins=(... bazel)
|
|||
The plugin has a copy of [the completion script from the git repository][1].
|
||||
|
||||
[1]: https://github.com/bazelbuild/bazel/blob/master/scripts/zsh_completion/_bazel
|
||||
|
||||
## Aliases
|
||||
|
||||
| Alias | Command | Description |
|
||||
| ----- | ------------- | ------------------------- |
|
||||
| bzb | `bazel build` | The `bazel build` command |
|
||||
| bzt | `bazel test` | The `bazel test` command |
|
||||
| bzr | `bazel run` | The `bazel run` command |
|
||||
| bzq | `bazel query` | The `bazel query` command |
|
||||
|
||||
## Functions
|
||||
|
||||
| Function | Description |
|
||||
| -------- | -------------------------------- |
|
||||
| sri-hash | Generate SRI hash used by bzlmod |
|
||||
|
|
|
|||
9
plugins/bazel/bazel.plugin.zsh
Normal file
9
plugins/bazel/bazel.plugin.zsh
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
# Aliases for bazel
|
||||
alias bzb='bazel build'
|
||||
alias bzt='bazel test'
|
||||
alias bzr='bazel run'
|
||||
alias bzq='bazel query'
|
||||
|
||||
sri-hash() {
|
||||
openssl dgst -sha256 -binary $1 | openssl base64 -A | sed 's/^/sha256-/'
|
||||
}
|
||||
|
|
@ -47,7 +47,7 @@ case $state in
|
|||
"random[Generate random intervals in a genome.]" \
|
||||
"reldist[Calculate the distribution of relative distances b/w two files.]" \
|
||||
"sample[Sample random records from file using reservoir sampling.]" \
|
||||
"shuffle[Randomly redistrubute intervals in a genome.]" \
|
||||
"shuffle[Randomly redistribute intervals in a genome.]" \
|
||||
"slop[Adjust the size of intervals.]" \
|
||||
"sort[Order the intervals in a file.]" \
|
||||
"subtract[Remove intervals based on overlaps b/w two files.]" \
|
||||
|
|
|
|||
|
|
@ -38,6 +38,7 @@ One can configure a few things:
|
|||
- `bgnotify_bell` enabled or disables the terminal bell (default true)
|
||||
- `bgnotify_threshold` sets the notification threshold time (default 6 seconds)
|
||||
- `function bgnotify_formatted` lets you change the notification. You can for instance customize the message and pass in an icon.
|
||||
- `bgnotify_extraargs` appends extra args to notifier (e.g. `-e` for notify-send to create a transient notification)
|
||||
|
||||
Use these by adding a function definition before the your call to source. Example:
|
||||
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ function bgnotify_formatted {
|
|||
function bgnotify_appid {
|
||||
if (( ${+commands[osascript]} )); then
|
||||
osascript -e "tell application id \"$(bgnotify_programid)\" to get the {id, frontmost, id of front window, visible of front window}" 2>/dev/null
|
||||
elif [[ -n $WAYLAND_DISPLAY ]] && (( ${+commands[swaymsg]} )); then # wayland+sway
|
||||
elif [[ -n $WAYLAND_DISPLAY ]] && ([[ -n $SWAYSOCK ]] || [[ -n $I3SOCK ]]) && (( ${+commands[swaymsg]} )); then # wayland+sway
|
||||
local app_id=$(bgnotify_find_sway_appid)
|
||||
[[ -n "$app_id" ]] && echo "$app_id" || echo $EPOCHSECONDS
|
||||
elif [[ -z $WAYLAND_DISPLAY ]] && [[ -n $DISPLAY ]] && (( ${+commands[xprop]} )); then
|
||||
|
|
@ -117,15 +117,15 @@ function bgnotify {
|
|||
local icon="$3"
|
||||
if (( ${+commands[terminal-notifier]} )); then # macOS
|
||||
local term_id=$(bgnotify_programid)
|
||||
terminal-notifier -message "$message" -title "$title" ${=icon:+-appIcon "$icon"} ${=term_id:+-activate "$term_id" -sender "$term_id"} &>/dev/null
|
||||
terminal-notifier -message "$message" -title "$title" ${=icon:+-appIcon "$icon"} ${=term_id:+-activate "$term_id"} ${=bgnotify_extraargs:-} &>/dev/null
|
||||
elif (( ${+commands[growlnotify]} )); then # macOS growl
|
||||
growlnotify -m "$title" "$message"
|
||||
growlnotify -m "$title" "$message" ${=bgnotify_extraargs:-}
|
||||
elif (( ${+commands[notify-send]} )); then
|
||||
notify-send "$title" "$message" ${=icon:+--icon "$icon"}
|
||||
notify-send "$title" "$message" ${=icon:+--icon "$icon"} ${=bgnotify_extraargs:-}
|
||||
elif (( ${+commands[kdialog]} )); then # KDE
|
||||
kdialog --title "$title" --passivepopup "$message" 5
|
||||
kdialog --title "$title" --passivepopup "$message" 5 ${=bgnotify_extraargs:-}
|
||||
elif (( ${+commands[notifu]} )); then # cygwin
|
||||
notifu /m "$message" /p "$title" ${=icon:+/i "$icon"}
|
||||
notifu /m "$message" /p "$title" ${=icon:+/i "$icon"} ${=bgnotify_extraargs:-}
|
||||
fi
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ index 2fd5f2cd..9d89a464 100644
|
|||
PROMPT="%(?:%{$fg_bold[green]%}➜ :%{$fg_bold[red]%}➜ )"
|
||||
-PROMPT+=' %{$fg[cyan]%}%c%{$reset_color%} $(git_prompt_info)'
|
||||
+PROMPT+=' %{$fg[cyan]%}%c%{$reset_color%} $(branch_prompt_info)'
|
||||
|
||||
|
||||
ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg_bold[blue]%}git:(%{$fg[red]%}"
|
||||
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%} "
|
||||
```
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ function branch_prompt_info() {
|
|||
while [[ "$dir" != '/' ]]; do
|
||||
# Found .git directory
|
||||
if [[ -d "${dir}/.git" ]]; then
|
||||
branch="${"$(<"${dir}/.git/HEAD")"##*/}"
|
||||
branch="${"$(<"${dir}/.git/HEAD")"##ref: refs/heads/}"
|
||||
echo '±' "${branch:gs/%/%%}"
|
||||
return
|
||||
fi
|
||||
|
|
|
|||
|
|
@ -19,19 +19,38 @@ the `brew` binary before sourcing `oh-my-zsh.sh` and it'll set up the environmen
|
|||
|
||||
## Aliases
|
||||
|
||||
| Alias | Command | Description |
|
||||
| -------- | --------------------------------------- | ------------------------------------------------------------------- |
|
||||
| `bcubc` | `brew upgrade --cask && brew cleanup` | Update outdated casks, then run cleanup. |
|
||||
| `bcubo` | `brew update && brew outdated --cask` | Update Homebrew data, then list outdated casks. |
|
||||
| `brewp` | `brew pin` | Pin a specified formula so that it's not upgraded. |
|
||||
| `brews` | `brew list -1` | List installed formulae or the installed files for a given formula. |
|
||||
| `brewsp` | `brew list --pinned` | List pinned formulae, or show the version of a given formula. |
|
||||
| `bubc` | `brew upgrade && brew cleanup` | Upgrade outdated formulae and casks, then run cleanup. |
|
||||
| `bugbc` | `brew upgrade --greedy && brew cleanup` | Upgrade outdated formulae and casks (greedy), then run cleanup. |
|
||||
| `bubo` | `brew update && brew outdated` | Update Homebrew data, then list outdated formulae and casks. |
|
||||
| `bubu` | `bubo && bubc` | Do the last two operations above. |
|
||||
| `bfu` | `brew upgrade --formula` | Upgrade only formulas (not casks). |
|
||||
| `buz` | `brew uninstall --zap` | Remove all files associated with a cask. |
|
||||
| Alias | Command | Description |
|
||||
| -------- | --------------------------------------- | --------------------------------------------------------------------- |
|
||||
| `ba` | `brew autoremove` | Uninstall unnecessary formulae. |
|
||||
| `bci` | `brew info --cask` | Display information about the given cask. |
|
||||
| `bcin` | `brew install --cask` | Install the given cask. |
|
||||
| `bcl` | `brew list --cask` | List installed casks. |
|
||||
| `bcn` | `brew cleanup` | Run cleanup. |
|
||||
| `bco` | `brew outdated --cask` | Report all outdated casks. |
|
||||
| `bcrin` | `brew reinstall --cask` | Reinstall the given cask. |
|
||||
| `bcubc` | `brew upgrade --cask && brew cleanup` | Upgrade outdated casks, then run cleanup. |
|
||||
| `bcubo` | `brew update && brew outdated --cask` | Update Homebrew data, then list outdated casks. |
|
||||
| `bcup` | `brew upgrade --cask` | Upgrade all outdated casks. |
|
||||
| `bfu` | `brew upgrade --formula` | Upgrade only formulae (not casks). |
|
||||
| `bi` | `brew install` | Install a formula. |
|
||||
| `bl` | `brew list` | List all installed formulae. |
|
||||
| `bo` | `brew outdated` | List installed formulae that have an updated version available. |
|
||||
| `brewp` | `brew pin` | Pin a specified formula so that it's not upgraded. |
|
||||
| `brews` | `brew list -1` | List installed formulae or the installed files for a given formula. |
|
||||
| `brewsp` | `brew list --pinned` | List pinned formulae, or show the version of a given formula. |
|
||||
| `bsl` | `brew services list` | List all running services. |
|
||||
| `bsoff` | `brew services stop` | Stop the service and unregister it from launching at login (or boot). |
|
||||
| `bsoffa` | `bsoff --all` | Stop all started services. |
|
||||
| `bson` | `brew services start` | Start the service and register it to launch at login (or boot). |
|
||||
| `bsona` | `bson --all` | Start all stopped services. |
|
||||
| `bsr` | `brew services run` | Run the service without registering to launch at login (or boot). |
|
||||
| `bsra` | `bsr --all` | Run all stopped services. |
|
||||
| `bu` | `brew update` | Update brew and all installed formulae. |
|
||||
| `bubo` | `brew update && brew outdated` | Update Homebrew data, then list outdated formulae and casks. |
|
||||
| `bubu` | `bubo && bup` | Do the last two operations above. |
|
||||
| `bugbc` | `brew upgrade --greedy && brew cleanup` | Upgrade outdated formulae and casks (greedy), then run cleanup. |
|
||||
| `bup` | `brew upgrade` | Upgrade outdated, unpinned brews. |
|
||||
| `buz` | `brew uninstall --zap` | Remove all files associated with a cask. |
|
||||
|
||||
## Completion
|
||||
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ if (( ! $+commands[brew] )); then
|
|||
fi
|
||||
|
||||
if [[ -z "$HOMEBREW_PREFIX" ]]; then
|
||||
# Maintain compatability with potential custom user profiles, where we had
|
||||
# Maintain compatibility with potential custom user profiles, where we had
|
||||
# previously relied on always sourcing shellenv. OMZ plugins should not rely
|
||||
# on this to be defined due to out of order processing.
|
||||
export HOMEBREW_PREFIX="$(brew --prefix)"
|
||||
|
|
@ -34,17 +34,35 @@ if [[ -d "$HOMEBREW_PREFIX/share/zsh/site-functions" ]]; then
|
|||
fpath+=("$HOMEBREW_PREFIX/share/zsh/site-functions")
|
||||
fi
|
||||
|
||||
alias ba='brew autoremove'
|
||||
alias bci='brew info --cask'
|
||||
alias bcin='brew install --cask'
|
||||
alias bcl='brew list --cask'
|
||||
alias bcn='brew cleanup'
|
||||
alias bco='brew outdated --cask'
|
||||
alias bcrin='brew reinstall --cask'
|
||||
alias bcubc='brew upgrade --cask && brew cleanup'
|
||||
alias bcubo='brew update && brew outdated --cask'
|
||||
alias bcubc='brew upgrade --cask && brew cleanup'
|
||||
alias bcup='brew upgrade --cask'
|
||||
alias bfu='brew upgrade --formula'
|
||||
alias bi='brew install'
|
||||
alias bl='brew list'
|
||||
alias bo='brew outdated'
|
||||
alias brewp='brew pin'
|
||||
alias brewsp='brew list --pinned'
|
||||
alias bubc='brew upgrade && brew cleanup'
|
||||
alias bugbc='brew upgrade --greedy && brew cleanup'
|
||||
alias bsl='brew services list'
|
||||
alias bsoff='brew services stop'
|
||||
alias bsoffa='bsoff --all'
|
||||
alias bson='brew services start'
|
||||
alias bsona='bson --all'
|
||||
alias bsr='brew services run'
|
||||
alias bsra='bsr --all'
|
||||
alias bu='brew update'
|
||||
alias bubo='brew update && brew outdated'
|
||||
alias bubu='bubo && bubc'
|
||||
alias bubu='bubo && bup'
|
||||
alias bubug='bubo && bugbc'
|
||||
alias bfu='brew upgrade --formula'
|
||||
alias bugbc='brew upgrade --greedy && brew cleanup'
|
||||
alias bup='brew upgrade'
|
||||
alias buz='brew uninstall --zap'
|
||||
|
||||
function brews() {
|
||||
|
|
|
|||
9
plugins/buf/README.md
Normal file
9
plugins/buf/README.md
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
# Buf plugin
|
||||
|
||||
This plugin adds completion for [Buf CLI](https://github.com/bufbuild/buf), a tool working with Protocol Buffers.
|
||||
|
||||
To use it, add `buf` to the plugins array in your zshrc file:
|
||||
|
||||
```zsh
|
||||
plugins=(... buf)
|
||||
```
|
||||
14
plugins/buf/buf.plugin.zsh
Normal file
14
plugins/buf/buf.plugin.zsh
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
# Autocompletion for the Buf CLI (buf).
|
||||
if (( !$+commands[buf] )); then
|
||||
return
|
||||
fi
|
||||
# If the completion file doesn't exist yet, we need to autoload it and
|
||||
# bind it to `buf`. Otherwise, compinit will have already done that.
|
||||
if [[ ! -f "$ZSH_CACHE_DIR/completions/_buf" ]]; then
|
||||
typeset -g -A _comps
|
||||
autoload -Uz _buf
|
||||
_comps[buf]=_buf
|
||||
fi
|
||||
|
||||
# Generate and load buf completion
|
||||
buf completion zsh >! "$ZSH_CACHE_DIR/completions/_buf" &|
|
||||
|
|
@ -11,4 +11,4 @@ if [[ ! -f "$ZSH_CACHE_DIR/completions/_bun" ]]; then
|
|||
_comps[bun]=_bun
|
||||
fi
|
||||
|
||||
bun completions >| "$ZSH_CACHE_DIR/completions/_bun" &|
|
||||
SHELL=zsh bun completions >| "$ZSH_CACHE_DIR/completions/_bun" &|
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#compdef bundle
|
||||
#compdef bundle bundler
|
||||
|
||||
local curcontext="$curcontext" state line _gems _opts ret=1
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
# catimg
|
||||
|
||||
Plugin for displaying images on the terminal using the the `catimg.sh` script provided by [posva](https://github.com/posva/catimg)
|
||||
Plugin for displaying images on the terminal using the `catimg.sh` script provided by
|
||||
[posva](https://github.com/posva/catimg)
|
||||
|
||||
To use it, add `catimg` to the plugins array in your zshrc file:
|
||||
|
||||
|
|
@ -10,7 +11,7 @@ plugins=(... catimg)
|
|||
|
||||
## Requirements
|
||||
|
||||
- `convert` (ImageMagick)
|
||||
- `magick convert` (ImageMagick)
|
||||
|
||||
## Functions
|
||||
|
||||
|
|
|
|||
|
|
@ -9,9 +9,11 @@
|
|||
|
||||
|
||||
function catimg() {
|
||||
if [[ -x `which convert` ]]; then
|
||||
zsh $ZSH/plugins/catimg/catimg.sh $@
|
||||
if (( $+commands[magick] )); then
|
||||
CONVERT_CMD="magick" zsh $ZSH/plugins/catimg/catimg.sh $@
|
||||
elif (( $+commands[convert] )); then
|
||||
CONVERT_CMD="convert" zsh $ZSH/plugins/catimg/catimg.sh $@
|
||||
else
|
||||
echo "catimg need convert (ImageMagick) to work)"
|
||||
echo "catimg need magick/convert (ImageMagick) to work)"
|
||||
fi
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,6 +7,10 @@
|
|||
# GitHub: https://github.com/posva/catimg #
|
||||
################################################################################
|
||||
|
||||
# this should come from outside, either `magick` or `convert`
|
||||
# from imagemagick v7 and ahead `convert` is deprecated
|
||||
: ${CONVERT_CMD:=convert}
|
||||
|
||||
function help() {
|
||||
echo "Usage catimg [-h] [-w width] [-c char] img"
|
||||
echo "By default char is \" \" and w is the terminal width"
|
||||
|
|
@ -43,23 +47,23 @@ if [ ! "$WIDTH" ]; then
|
|||
else
|
||||
COLS=$(expr $WIDTH "/" $(echo -n "$CHAR" | wc -c))
|
||||
fi
|
||||
WIDTH=$(convert "$IMG" -print "%w\n" /dev/null)
|
||||
WIDTH=$($CONVERT_CMD "$IMG" -print "%w\n" /dev/null)
|
||||
if [ "$WIDTH" -gt "$COLS" ]; then
|
||||
WIDTH=$COLS
|
||||
fi
|
||||
|
||||
REMAP=""
|
||||
if convert "$IMG" -resize $COLS\> +dither -remap $COLOR_FILE /dev/null ; then
|
||||
if $CONVERT_CMD "$IMG" -resize $COLS\> +dither -remap $COLOR_FILE /dev/null ; then
|
||||
REMAP="-remap $COLOR_FILE"
|
||||
else
|
||||
echo "The version of convert is too old, don't expect good results :(" >&2
|
||||
#convert "$IMG" -colors 256 PNG8:tmp.png
|
||||
#IMG="tmp.png"
|
||||
# $CONVERT_CMD "$IMG" -colors 256 PNG8:tmp.png
|
||||
# IMG="tmp.png"
|
||||
fi
|
||||
|
||||
# Display the image
|
||||
I=0
|
||||
convert "$IMG" -resize $COLS\> +dither `echo $REMAP` txt:- 2>/dev/null |
|
||||
$CONVERT_CMD "$IMG" -resize $COLS\> +dither `echo $REMAP` txt:- 2>/dev/null |
|
||||
sed -e 's/.*none.*/NO NO NO/g' -e '1d;s/^.*(\(.*\)[,)].*$/\1/g;y/,/ /' |
|
||||
while read R G B f; do
|
||||
if [ ! "$R" = "NO" ]; then
|
||||
|
|
|
|||
11
plugins/chezmoi/README.md
Normal file
11
plugins/chezmoi/README.md
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
# chezmoi Plugin
|
||||
|
||||
## Introduction
|
||||
|
||||
This `chezmoi` plugin sets up completion for [chezmoi](https://chezmoi.io).
|
||||
|
||||
To use it, add `chezmoi` to the plugins array of your zshrc file:
|
||||
|
||||
```bash
|
||||
plugins=(... chezmoi)
|
||||
```
|
||||
14
plugins/chezmoi/chezmoi.plugin.zsh
Normal file
14
plugins/chezmoi/chezmoi.plugin.zsh
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
# COMPLETION FUNCTION
|
||||
if (( ! $+commands[chezmoi] )); then
|
||||
return
|
||||
fi
|
||||
|
||||
# If the completion file doesn't exist yet, we need to autoload it and
|
||||
# bind it to `chezmoi`. Otherwise, compinit will have already done that.
|
||||
if [[ ! -f "$ZSH_CACHE_DIR/completions/_chezmoi" ]]; then
|
||||
typeset -g -A _comps
|
||||
autoload -Uz _chezmoi
|
||||
_comps[chezmoi]=_chezmoi
|
||||
fi
|
||||
|
||||
chezmoi completion zsh >| "$ZSH_CACHE_DIR/completions/_chezmoi" &|
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
_source-from-omz-settings() {
|
||||
local _chruby_path _chruby_auto
|
||||
|
||||
|
||||
zstyle -s :omz:plugins:chruby path _chruby_path || return 1
|
||||
zstyle -s :omz:plugins:chruby auto _chruby_auto || return 1
|
||||
|
||||
|
|
@ -22,8 +22,10 @@ _source-from-homebrew() {
|
|||
# check default brew prefix
|
||||
if [[ -h /usr/local/opt/chruby ]];then
|
||||
_brew_prefix="/usr/local/opt/chruby"
|
||||
elif [[ -h /opt/homebrew/opt/chruby ]]; then
|
||||
_brew_prefix="/opt/homebrew/opt/chruby"
|
||||
else
|
||||
# ok , it is not default prefix
|
||||
# ok , it is not default prefix
|
||||
# this call to brew is expensive ( about 400 ms ), so at least let's make it only once
|
||||
_brew_prefix=$(brew --prefix chruby)
|
||||
fi
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
# chucknorris
|
||||
|
||||
Chuck Norris fortunes plugin for Oh My Zsh. Perfectly suitable as MOTD.
|
||||
Fortunes plugin for Chuck Norris for Oh My Zsh. Perfectly suitable as MOTD.
|
||||
|
||||
To use it add `chucknorris` to the plugins array in you zshrc file.
|
||||
|
||||
|
|
@ -36,3 +36,10 @@ Last login: Fri Jan 30 23:12:26 on ttys001
|
|||
- `cowsay` if using `chuck_cow`
|
||||
|
||||
Available via homebrew, apt, ...
|
||||
|
||||
> [!NOTE]
|
||||
> In addition to installing `fortune`, it may be necessary to run:
|
||||
>
|
||||
> `strfile $ZSH/plugins/chucknorris/fortunes/chucknorris\n`
|
||||
>
|
||||
> (include the "\n" literally) to write the fortune data to the proper directory.
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ Alternatively, seek out the [online documentation][3]. And don't forget, there a
|
|||
|
||||
## Contributors
|
||||
|
||||
Contributed to `oh_my_zsh` by [benwilcock][2].
|
||||
Contributed to `oh_my_zsh` by [benwilcock][2].
|
||||
|
||||
[1]: https://docs.cloudfoundry.org/cf-cli/install-go-cli.html
|
||||
[2]: https://github.com/benwilcock
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ Also provides the following aliases:
|
|||
* **cfc:** Copies the compiled JS to your clipboard. Very useful when you want
|
||||
to run the code in a JS console.
|
||||
|
||||
* **cfp:** Compiles from your currently copied clipboard. Useful when you want
|
||||
* **cfp:** Compiles from your currently copied clipboard. Useful when you want
|
||||
to compile large/multi-line snippets
|
||||
|
||||
* **cfpc:** Paste coffeescript from clipboard, compile to JS, then copy the
|
||||
|
|
|
|||
|
|
@ -42,12 +42,12 @@ colorize_cat() {
|
|||
ZSH_COLORIZE_STYLE="emacs"
|
||||
fi
|
||||
|
||||
# Use stdin if no arguments have been passed.
|
||||
if [ $# -eq 0 ]; then
|
||||
# Use stdin if stdin is not attached to a terminal.
|
||||
if [ ! -t 0 ]; then
|
||||
if [[ "$ZSH_COLORIZE_TOOL" == "pygmentize" ]]; then
|
||||
pygmentize -O style="$ZSH_COLORIZE_STYLE" -g
|
||||
else
|
||||
chroma --style="$ZSH_COLORIZE_STYLE" --formatter="${ZSH_COLORIZE_CHROMA_FORMATTER:-terminal}"
|
||||
chroma --style="$ZSH_COLORIZE_STYLE" --formatter="${ZSH_COLORIZE_CHROMA_FORMATTER:-terminal}" "$@"
|
||||
fi
|
||||
return $?
|
||||
fi
|
||||
|
|
|
|||
|
|
@ -30,5 +30,6 @@ It works out of the box with the command-not-found packages for:
|
|||
- [NixOS](https://github.com/NixOS/nixpkgs/tree/master/nixos/modules/programs/command-not-found)
|
||||
- [Termux](https://github.com/termux/command-not-found)
|
||||
- [SUSE](https://www.unix.com/man-page/suse/1/command-not-found/)
|
||||
- [Gentoo](https://github.com/AndrewAmmerlaan/command-not-found-gentoo/tree/main)
|
||||
|
||||
You can add support for other platforms by submitting a Pull Request.
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
if (( ${+commands[compleat]} )); then
|
||||
local prefix="${commands[compleat]:h:h}"
|
||||
local setup="${prefix}/share/compleat-1.0/compleat_setup"
|
||||
local setup="${prefix}/share/compleat-1.0/compleat_setup"
|
||||
|
||||
if [[ -f "$setup" ]]; then
|
||||
if ! bashcompinit >/dev/null 2>&1; then
|
||||
|
|
@ -15,6 +15,6 @@ if (( ${+commands[compleat]} )); then
|
|||
bashcompinit -i
|
||||
fi
|
||||
|
||||
source "$setup"
|
||||
source "$setup"
|
||||
fi
|
||||
fi
|
||||
|
|
|
|||
44
plugins/conda-env/README.md
Normal file
44
plugins/conda-env/README.md
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
# conda-env
|
||||
|
||||
The plugin displays information of the created virtual container of conda and allows background theming.
|
||||
|
||||
To use it, add `conda-env` to the plugins array of your zshrc file:
|
||||
```
|
||||
plugins=(... conda-env)
|
||||
```
|
||||
|
||||
The plugin creates a `conda_prompt_info` function that you can use in your theme, which displays the
|
||||
basename of the current `$CONDA_DEFAULT_ENV`.
|
||||
|
||||
You can use this prompt function in your themes, by adding it to the `PROMPT` or `RPROMPT` variables. See [Example](#example) for more information.
|
||||
|
||||
## Settings
|
||||
|
||||
It uses two variables to control how the information is shown:
|
||||
|
||||
- `ZSH_THEME_CONDA_PREFIX`: sets the prefix of the CONDA_DEFAULT_ENV.
|
||||
Defaults to `[`.
|
||||
|
||||
- `ZSH_THEME_CONDA_SUFFIX`: sets the suffix of the CONDA_DEFAULT_ENV.
|
||||
Defaults to `]`.
|
||||
|
||||
## Example
|
||||
|
||||
```sh
|
||||
ZSH_THEME_CONDA_PREFIX='conda:%F{green}'
|
||||
ZSH_THEME_CONDA_SUFFIX='%f'
|
||||
RPROMPT='$(conda_prompt_info)'
|
||||
```
|
||||
|
||||
## `CONDA_CHANGEPS1`
|
||||
|
||||
This plugin also automatically sets the `CONDA_CHANGEPS1` variable to `false` to avoid conda changing the prompt
|
||||
automatically. This has the same effect as running `conda config --set changeps1 false`.
|
||||
|
||||
You can override this behavior by adding `unset CONDA_CHANGEPS1` in your `.zshrc` file, after Oh My Zsh has been
|
||||
sourced.
|
||||
|
||||
References:
|
||||
|
||||
- https://conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html#determining-your-current-environment
|
||||
- https://conda.io/projects/conda/en/latest/user-guide/configuration/use-condarc.html#precedence
|
||||
9
plugins/conda-env/conda-env.plugin.zsh
Normal file
9
plugins/conda-env/conda-env.plugin.zsh
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
function conda_prompt_info(){
|
||||
[[ -n ${CONDA_DEFAULT_ENV} ]] || return
|
||||
echo "${ZSH_THEME_CONDA_PREFIX=[}${CONDA_DEFAULT_ENV:t:gs/%/%%}${ZSH_THEME_CONDA_SUFFIX=]}"
|
||||
}
|
||||
|
||||
# Has the same effect as `conda config --set changeps1 false`
|
||||
# - https://conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html#determining-your-current-environment
|
||||
# - https://conda.io/projects/conda/en/latest/user-guide/configuration/use-condarc.html#precedence
|
||||
export CONDA_CHANGEPS1=false
|
||||
37
plugins/conda/README.md
Normal file
37
plugins/conda/README.md
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
# conda plugin
|
||||
|
||||
The conda plugin provides [aliases](#aliases) for `conda`, usually installed via [anaconda](https://www.anaconda.com/) or [miniconda](https://docs.conda.io/en/latest/miniconda.html).
|
||||
|
||||
To use it, add `conda` to the plugins array in your zshrc file:
|
||||
|
||||
```zsh
|
||||
plugins=(... conda)
|
||||
```
|
||||
|
||||
## Aliases
|
||||
|
||||
| Alias | Command | Description |
|
||||
| :------- | :-------------------------------------- | :------------------------------------------------------------------------------ |
|
||||
| `cna` | `conda activate` | Activate the specified conda environment |
|
||||
| `cnab` | `conda activate base` | Activate the base conda environment |
|
||||
| `cncf` | `conda env create -f` | Create a new conda environment from a YAML file |
|
||||
| `cncn` | `conda create -y -n` | Create a new conda environment with the given name |
|
||||
| `cnconf` | `conda config` | View or modify conda configuration |
|
||||
| `cncp` | `conda create -y -p` | Create a new conda environment with the given prefix |
|
||||
| `cncr` | `conda create -n` | Create new virtual environment with given name |
|
||||
| `cncss` | `conda config --show-source` | Show the locations of conda configuration sources |
|
||||
| `cnde` | `conda deactivate` | Deactivate the current conda environment |
|
||||
| `cnel` | `conda env list` | List all available conda environments |
|
||||
| `cni` | `conda install` | Install given package |
|
||||
| `cniy` | `conda install -y` | Install given package without confirmation |
|
||||
| `cnl` | `conda list` | List installed packages in the current environment |
|
||||
| `cnle` | `conda list --export` | Export the list of installed packages in the current environment |
|
||||
| `cnles` | `conda list --explicit > spec-file.txt` | Export the list of installed packages in the current environment to a spec file |
|
||||
| `cnr` | `conda remove` | Remove given package |
|
||||
| `cnrn` | `conda remove -y -all -n` | Remove all packages in the specified environment |
|
||||
| `cnrp` | `conda remove -y -all -p` | Remove all packages in the specified prefix |
|
||||
| `cnry` | `conda remove -y` | Remove given package without confirmation |
|
||||
| `cnsr` | `conda search` | Search conda repositories for package |
|
||||
| `cnu` | `conda update` | Update conda package manager |
|
||||
| `cnua` | `conda update --all` | Update all installed packages |
|
||||
| `cnuc` | `conda update conda` | Update conda package manager |
|
||||
23
plugins/conda/conda.plugin.zsh
Normal file
23
plugins/conda/conda.plugin.zsh
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
alias cna='conda activate'
|
||||
alias cnab='conda activate base'
|
||||
alias cncf='conda env create -f'
|
||||
alias cncn='conda create -y -n'
|
||||
alias cnconf='conda config'
|
||||
alias cncp='conda create -y -p'
|
||||
alias cncr='conda create -n'
|
||||
alias cncss='conda config --show-source'
|
||||
alias cnde='conda deactivate'
|
||||
alias cnel='conda env list'
|
||||
alias cni='conda install'
|
||||
alias cniy='conda install -y'
|
||||
alias cnl='conda list'
|
||||
alias cnle='conda list --export'
|
||||
alias cnles='conda list --explicit > spec-file.txt'
|
||||
alias cnr='conda remove'
|
||||
alias cnrn='conda remove -y --all -n'
|
||||
alias cnrp='conda remove -y --all -p'
|
||||
alias cnry='conda remove -y'
|
||||
alias cnsr='conda search'
|
||||
alias cnu='conda update'
|
||||
alias cnua='conda update --all'
|
||||
alias cnuc='conda update conda'
|
||||
|
|
@ -1,8 +1,8 @@
|
|||
# copy the active line from the command line buffer
|
||||
# copy the active line from the command line buffer
|
||||
# onto the system clipboard
|
||||
|
||||
copybuffer () {
|
||||
if which clipcopy &>/dev/null; then
|
||||
if builtin which clipcopy &>/dev/null; then
|
||||
printf "%s" "$BUFFER" | clipcopy
|
||||
else
|
||||
zle -M "clipcopy not found. Please make sure you have Oh My Zsh installed correctly."
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ dash
|
|||
|
||||
- Query for something in dash app: `dash query`
|
||||
```
|
||||
dash golang
|
||||
dash golang
|
||||
```
|
||||
|
||||
- You can optionally provide a keyword: `dash [keyword:]query`
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
# Usage: dash [keyword:]query
|
||||
dash() { open -a Dash.app dash://"$*" }
|
||||
dash() { open -a Dash.app "dash://$(omz_urlencode -r $*)" }
|
||||
compdef _dash dash
|
||||
|
||||
_dash() {
|
||||
|
|
|
|||
|
|
@ -1,13 +1,11 @@
|
|||
# dbt plugin
|
||||
|
||||
## Introduction
|
||||
|
||||
The `dbt plugin` adds several aliases for useful [dbt](https://docs.getdbt.com/) commands and
|
||||
[aliases](#aliases).
|
||||
|
||||
To use it, add `dbt` to the plugins array of your zshrc file:
|
||||
|
||||
```
|
||||
```zsh
|
||||
plugins=(... dbt)
|
||||
```
|
||||
|
||||
|
|
@ -26,4 +24,4 @@ plugins=(... dbt)
|
|||
|
||||
## Maintainer
|
||||
|
||||
### [msempere](https://github.com/msempere)
|
||||
- [msempere](https://github.com/msempere)
|
||||
|
|
|
|||
|
|
@ -83,9 +83,9 @@ else
|
|||
}
|
||||
alias ac="su -ls '$apt_pref clean' root"
|
||||
alias ad="su -lc '$apt_pref update' root"
|
||||
alias adg="su -lc '$apt_pref update && aptitude $apt_upgr' root"
|
||||
alias adu="su -lc '$apt_pref update && aptitude dist-upgrade' root"
|
||||
alias afu="su -lc '$apt-file update'"
|
||||
alias adg="su -lc '$apt_pref update && $apt_pref $apt_upgr' root"
|
||||
alias adu="su -lc '$apt_pref update && $apt_pref dist-upgrade' root"
|
||||
alias afu="su -lc 'apt-file update'"
|
||||
alias au="su -lc '$apt_pref $apt_upgr' root"
|
||||
function ai() {
|
||||
cmd="su -lc '$apt_pref install $@' root"
|
||||
|
|
|
|||
|
|
@ -37,13 +37,13 @@ Say you opened these directories on the terminal:
|
|||
3 ~
|
||||
```
|
||||
|
||||
By pressing <kbd>Ctrl</kbd> + <kbd>Shift</kbd> + <kbd>Left</kbd>, the current working directory or `$CWD` will be from `oh-my-zsh` to `Hacktoberfest`. Press it again and it will be at `Projects`.
|
||||
By pressing <kbd>Ctrl</kbd> + <kbd>Shift</kbd> + <kbd>Left</kbd>, the current working directory or `$PWD` will be from `oh-my-zsh` to `Hacktoberfest`. Press it again and it will be at `Projects`.
|
||||
|
||||
And by pressing <kbd>Ctrl</kbd> + <kbd>Shift</kbd> + <kbd>Right</kbd>, the `$CWD` will be from `Projects` to `Hacktoberfest`. Press it again and it will be at `oh-my-zsh`.
|
||||
And by pressing <kbd>Ctrl</kbd> + <kbd>Shift</kbd> + <kbd>Right</kbd>, the `$PWD` will be from `Projects` to `Hacktoberfest`. Press it again and it will be at `oh-my-zsh`.
|
||||
|
||||
Here's a example history table with the same accessed directories like above:
|
||||
|
||||
| Current `$CWD` | Key press | New `$CWD` |
|
||||
| Current `$PWD` | Key press | New `$PWD` |
|
||||
| --------------- | ----------------------------------------------------- | --------------- |
|
||||
| `oh-my-zsh` | <kbd>Ctrl</kbd> + <kbd>Shift</kbd> + <kbd>Left</kbd> | `Hacktoberfest` |
|
||||
| `Hacktoberfest` | <kbd>Ctrl</kbd> + <kbd>Shift</kbd> + <kbd>Left</kbd> | `Projects` |
|
||||
|
|
@ -53,7 +53,7 @@ Here's a example history table with the same accessed directories like above:
|
|||
| `Hacktoberfest` | <kbd>Ctrl</kbd> + <kbd>Shift</kbd> + <kbd>Right</kbd> | `oh-my-zsh` |
|
||||
| `oh-my-zsh` | <kbd>Ctrl</kbd> + <kbd>Shift</kbd> + <kbd>Right</kbd> | `~` |
|
||||
|
||||
Note the last traversal, when pressing <kbd>Ctrl</kbd> + <kbd>Shift</kbd> + <kbd>Right</kbd> on a last known `$CWD`, it will change back to the first known `$CWD`, which in the example is `~`.
|
||||
Note the last traversal, when pressing <kbd>Ctrl</kbd> + <kbd>Shift</kbd> + <kbd>Right</kbd> on a last known `$PWD`, it will change back to the first known `$PWD`, which in the example is `~`.
|
||||
|
||||
Here's an asciinema cast demonstrating the example above:
|
||||
|
||||
|
|
@ -61,18 +61,22 @@ Here's an asciinema cast demonstrating the example above:
|
|||
|
||||
## Functions
|
||||
|
||||
| Function | Description |
|
||||
| -------------------- | --------------------------------------------------------------------------------------------------------- |
|
||||
| `insert-cycledleft` | Change `$CWD` to the previous known stack, binded on <kbd>Ctrl</kbd> + <kbd>Shift</kbd> + <kbd>Left</kbd> |
|
||||
| `insert-cycledright` | Change `$CWD` to the next known stack, binded on <kbd>Ctrl</kbd> + <kbd>Shift</kbd> + <kbd>Right</kbd> |
|
||||
| Function | Description |
|
||||
| -------------------- | ------------------------------------------------------------------------------------------------------------------- |
|
||||
| `insert-cycledleft` | Change `$PWD` to the previous known stack, bound to <kbd>Ctrl</kbd> + <kbd>Shift</kbd> + <kbd>Left</kbd> |
|
||||
| `insert-cycledright` | Change `$PWD` to the next known stack, bound to <kbd>Ctrl</kbd> + <kbd>Shift</kbd> + <kbd>Right</kbd> |
|
||||
| `insert-cycledup` | Change `$PWD` to the parent folder, bound to <kbd>Ctrl</kbd> + <kbd>Shift</kbd> + <kbd>Up</kbd> |
|
||||
| `insert-cycleddown` | Change `$PWD` to the first alphabetical child folder, bound to <kbd>Ctrl</kbd> + <kbd>Shift</kbd> + <kbd>Down</kbd> |
|
||||
|
||||
## Rebinding keys
|
||||
|
||||
You can bind these functions to other key sequences, as long as you know the bindkey sequence. For example, these commands bind to <kbd>Alt</kbd> + <kbd>Shift</kbd> + <kbd>Left</kbd> / <kbd>Right</kbd> in `xterm-256color`:
|
||||
You can bind these functions to other key sequences, as long as you know the bindkey sequence. For example, these commands bind to <kbd>Alt</kbd> + <kbd>Shift</kbd> + <kbd>key</kbd> in `xterm-256color`:
|
||||
|
||||
```zsh
|
||||
bindkey '^[[1;4D' insert-cycledleft
|
||||
bindkey '^[[1;4C' insert-cycledright
|
||||
bindkey "\e[1;4A" insert-cycledup
|
||||
bindkey "\e[1;4B" insert-cycleddown
|
||||
```
|
||||
|
||||
You can get the bindkey sequence by pressing <kbd>Ctrl</kbd> + <kbd>V</kbd>, then pressing the keyboard shortcut you want to use.
|
||||
|
|
|
|||
|
|
@ -8,7 +8,16 @@
|
|||
# pushd +N: start counting from left of `dirs' output
|
||||
# pushd -N: start counting from right of `dirs' output
|
||||
|
||||
# Either switch to a directory from dirstack, using +N or -N syntax
|
||||
# or switch to a directory by path, using `switch-to-dir -- <path>`
|
||||
switch-to-dir () {
|
||||
# If $1 is --, then treat $2 as a directory path
|
||||
if [[ $1 == -- ]]; then
|
||||
# We use `-q` because we don't want chpwd to run, we'll do it manually
|
||||
[[ -d "$2" ]] && builtin pushd -q "$2" &>/dev/null
|
||||
return $?
|
||||
fi
|
||||
|
||||
setopt localoptions nopushdminus
|
||||
[[ ${#dirstack} -eq 0 ]] && return 1
|
||||
|
||||
|
|
@ -22,10 +31,10 @@ switch-to-dir () {
|
|||
}
|
||||
|
||||
insert-cycledleft () {
|
||||
switch-to-dir +1 || return
|
||||
switch-to-dir +1 || return $?
|
||||
|
||||
local fn
|
||||
for fn (chpwd $chpwd_functions precmd $precmd_functions); do
|
||||
for fn in chpwd $chpwd_functions precmd $precmd_functions; do
|
||||
(( $+functions[$fn] )) && $fn
|
||||
done
|
||||
zle reset-prompt
|
||||
|
|
@ -33,22 +42,46 @@ insert-cycledleft () {
|
|||
zle -N insert-cycledleft
|
||||
|
||||
insert-cycledright () {
|
||||
switch-to-dir -0 || return
|
||||
switch-to-dir -0 || return $?
|
||||
|
||||
local fn
|
||||
for fn (chpwd $chpwd_functions precmd $precmd_functions); do
|
||||
for fn in chpwd $chpwd_functions precmd $precmd_functions; do
|
||||
(( $+functions[$fn] )) && $fn
|
||||
done
|
||||
zle reset-prompt
|
||||
}
|
||||
zle -N insert-cycledright
|
||||
|
||||
insert-cycledup () {
|
||||
switch-to-dir -- .. || return $?
|
||||
|
||||
local fn
|
||||
for fn in chpwd $chpwd_functions precmd $precmd_functions; do
|
||||
(( $+functions[$fn] )) && $fn
|
||||
done
|
||||
zle reset-prompt
|
||||
}
|
||||
zle -N insert-cycledup
|
||||
|
||||
insert-cycleddown () {
|
||||
switch-to-dir -- "$(find . -mindepth 1 -maxdepth 1 -type d | sort -n | head -n 1)" || return $?
|
||||
|
||||
local fn
|
||||
for fn in chpwd $chpwd_functions precmd $precmd_functions; do
|
||||
(( $+functions[$fn] )) && $fn
|
||||
done
|
||||
zle reset-prompt
|
||||
}
|
||||
zle -N insert-cycleddown
|
||||
|
||||
# These sequences work for xterm, Apple Terminal.app, and probably others.
|
||||
# Not for rxvt-unicode, but it doesn't seem differentiate Ctrl-Shift-Arrow
|
||||
# from plain Shift-Arrow, at least by default.
|
||||
#
|
||||
# iTerm2 does not have these key combinations defined by default; you will need
|
||||
# to add them under "Keys" in your profile if you want to use this. You can do
|
||||
# this conveniently by loading the "xterm with Numeric Keypad" preset.
|
||||
bindkey "\e[1;6D" insert-cycledleft
|
||||
bindkey "\e[1;6C" insert-cycledright
|
||||
bindkey "\e[1;6D" insert-cycledleft # Ctrl+Shift+Left
|
||||
bindkey "\e[1;6C" insert-cycledright # Ctrl+Shift+Right
|
||||
bindkey "\e[1;6A" insert-cycledup # Ctrl+Shift+Up
|
||||
bindkey "\e[1;6B" insert-cycleddown # Ctrl+Shift+Down
|
||||
|
|
|
|||
|
|
@ -1,5 +1,8 @@
|
|||
# Don't continue if direnv is not found
|
||||
command -v direnv &>/dev/null || return
|
||||
# If direnv is not found, don't continue and print a warning
|
||||
if (( ! $+commands[direnv] )); then
|
||||
echo "Warning: direnv not found. Please install direnv and ensure it's in your PATH before using this plugin."
|
||||
return
|
||||
fi
|
||||
|
||||
_direnv_hook() {
|
||||
trap -- '' SIGINT;
|
||||
|
|
|
|||
|
|
@ -60,3 +60,46 @@ to `/usr` again.
|
|||
After that, <kbd>Alt</kbd> + <kbd>Down</kbd> will probably go to `/usr/bin` if `bin` is the first directory in alphabetical
|
||||
order (depends on your `/usr` folder structure). <kbd>Alt</kbd> + <kbd>Up</kbd> will return to `/usr`, and once more will get
|
||||
you to the root folder (`/`).
|
||||
|
||||
### cde
|
||||
|
||||
This plugin also provides a `cde` alias that allows you to change to a directory without clearing the next directory stack.
|
||||
This changes the default behavior of `dirhistory`, which is to clear the next directory stack when changing directories.
|
||||
|
||||
For example, if the shell was started, and the following commands were entered:
|
||||
|
||||
```shell
|
||||
cd ~
|
||||
cd /usr
|
||||
cd share
|
||||
cd doc
|
||||
|
||||
# <Alt + Left>
|
||||
# <Alt + Left>
|
||||
```
|
||||
|
||||
The directory stack would look like this:
|
||||
|
||||
```sh
|
||||
➜ /usr typeset -pm dirhistory_\*
|
||||
typeset -ax dirhistory_past=( /home/user /usr )
|
||||
typeset -ax dirhistory_future=( /usr/share/doc /usr/share )
|
||||
```
|
||||
|
||||
This means that pressing <kbd>Alt</kbd> + <kbd>Right</kbd>, you'd go to `/usr/share` and `/usr/share/doc` (the "future" directories).
|
||||
|
||||
If you run `cd /usr/bin`, the "future" directories will be removed, and you won't be able to access them with <kbd>Alt</kbd> + <kbd>Right</kbd>:
|
||||
|
||||
```sh
|
||||
➜ /u/bin typeset -pm dirhistory_\*
|
||||
typeset -ax dirhistory_past=( /home/user /usr )
|
||||
typeset -ax dirhistory_future=( /usr/bin )
|
||||
```
|
||||
|
||||
If you instead run `cde /usr/bin`, the "future" directories will be preserved:
|
||||
|
||||
```sh
|
||||
➜ /u/bin typeset -pm dirhistory_\*
|
||||
typeset -ax dirhistory_past=( /home/user /usr /usr/bin )
|
||||
typeset -ax dirhistory_future=( /usr/share/doc /usr/share )
|
||||
```
|
||||
|
|
|
|||
|
|
@ -11,9 +11,10 @@ dirhistory_past=($PWD)
|
|||
dirhistory_future=()
|
||||
export dirhistory_past
|
||||
export dirhistory_future
|
||||
|
||||
export DIRHISTORY_SIZE=30
|
||||
|
||||
alias cde='dirhistory_cd'
|
||||
|
||||
# Pop the last element of dirhistory_past.
|
||||
# Pass the name of the variable to return the result in.
|
||||
# Returns the element if the array was not empty,
|
||||
|
|
@ -136,7 +137,11 @@ for keymap in emacs vicmd viins; do
|
|||
|
||||
case "$TERM_PROGRAM" in
|
||||
Apple_Terminal) bindkey -M $keymap "^[b" dirhistory_zle_dirhistory_back ;; # Terminal.app
|
||||
iTerm.app) bindkey -M $keymap "^[^[[D" dirhistory_zle_dirhistory_back ;; # iTerm2
|
||||
ghostty) bindkey -M $keymap "^[b" dirhistory_zle_dirhistory_back ;; # ghostty
|
||||
iTerm.app)
|
||||
bindkey -M $keymap "^[^[[D" dirhistory_zle_dirhistory_back
|
||||
bindkey -M $keymap "^[b" dirhistory_zle_dirhistory_back
|
||||
;;
|
||||
esac
|
||||
|
||||
if (( ${+terminfo[kcub1]} )); then
|
||||
|
|
@ -151,7 +156,11 @@ for keymap in emacs vicmd viins; do
|
|||
|
||||
case "$TERM_PROGRAM" in
|
||||
Apple_Terminal) bindkey -M $keymap "^[f" dirhistory_zle_dirhistory_future ;; # Terminal.app
|
||||
iTerm.app) bindkey -M $keymap "^[^[[C" dirhistory_zle_dirhistory_future ;; # iTerm2
|
||||
ghostty) bindkey -M $keymap "^[f" dirhistory_zle_dirhistory_future ;; # ghostty
|
||||
iTerm.app)
|
||||
bindkey -M $keymap "^[^[[C" dirhistory_zle_dirhistory_future
|
||||
bindkey -M $keymap "^[f" dirhistory_zle_dirhistory_future
|
||||
;;
|
||||
esac
|
||||
|
||||
if (( ${+terminfo[kcuf1]} )); then
|
||||
|
|
@ -200,6 +209,7 @@ for keymap in emacs vicmd viins; do
|
|||
case "$TERM_PROGRAM" in
|
||||
Apple_Terminal) bindkey -M $keymap "^[[A" dirhistory_zle_dirhistory_up ;; # Terminal.app
|
||||
iTerm.app) bindkey -M $keymap "^[^[[A" dirhistory_zle_dirhistory_up ;; # iTerm2
|
||||
ghostty) bindkey -M $keymap "^[[1;3A" dirhistory_zle_dirhistory_up ;; # ghostty
|
||||
esac
|
||||
|
||||
if (( ${+terminfo[kcuu1]} )); then
|
||||
|
|
@ -215,6 +225,7 @@ for keymap in emacs vicmd viins; do
|
|||
case "$TERM_PROGRAM" in
|
||||
Apple_Terminal) bindkey -M $keymap "^[[B" dirhistory_zle_dirhistory_down ;; # Terminal.app
|
||||
iTerm.app) bindkey -M $keymap "^[^[[B" dirhistory_zle_dirhistory_down ;; # iTerm2
|
||||
ghostty) bindkey -M $keymap "^[[1;3B" dirhistory_zle_dirhistory_down ;; # ghostty
|
||||
esac
|
||||
|
||||
if (( ${+terminfo[kcud1]} )); then
|
||||
|
|
|
|||
570
plugins/dnf/_dnf5
Normal file
570
plugins/dnf/_dnf5
Normal file
|
|
@ -0,0 +1,570 @@
|
|||
#compdef dnf5
|
||||
# based on dnf-5.2.6.2
|
||||
|
||||
# utility functions
|
||||
|
||||
_dnf5_helper() {
|
||||
_call_program specs $service "${(q-)@}" "${(q-)PREFIX}\*" \
|
||||
-qC --assumeno --nogpgcheck 2>/dev/null </dev/null
|
||||
}
|
||||
|
||||
_dnf5_repositories() {
|
||||
# required option: -T (all|disabled|enabled)
|
||||
local selected expl
|
||||
zparseopts -D -E - T:=selected
|
||||
selected=$selected[2]
|
||||
_wanted $selected-repositories expl "$selected repository" \
|
||||
compadd "$@" - "${(@)${(f)$(_dnf5_helper repo list --$selected)}[2,-1]%% *}"
|
||||
}
|
||||
|
||||
_dnf5_packages() {
|
||||
# required option: -T (all|available|installed|upgradable)
|
||||
local selected opt expl
|
||||
zparseopts -D -E - T:=selected
|
||||
selected=$selected[2]
|
||||
case $selected in
|
||||
all) opt='' ;; # option --all does not exist
|
||||
upgradable) opt='--upgrades' ;;
|
||||
*) opt="--$selected" ;;
|
||||
esac
|
||||
_wanted $selected-packages expl "$selected package" \
|
||||
compadd "$@" - $(_dnf5_helper repoquery $opt --qf='%{name} ')
|
||||
}
|
||||
|
||||
_dnf5_rpm_files() {
|
||||
local expl
|
||||
_wanted rpm-files expl 'rpm file' _files -g '(#i)*.rpm(-.)'
|
||||
}
|
||||
|
||||
_dnf5_packages_or_rpms() {
|
||||
if [[ "$words[CURRENT]" = (*/*|\~*) ]]; then # if looks like a path name
|
||||
_dnf5_rpm_files
|
||||
else
|
||||
_dnf5_packages "$@"
|
||||
fi
|
||||
}
|
||||
|
||||
_dnf5_groups() {
|
||||
# optional option: -T (available|installed)
|
||||
local update_policy selected line pat groups
|
||||
zparseopts -D -E - T:=selected
|
||||
selected=$selected[2]
|
||||
if [[ -z $selected ]]; then
|
||||
selected=all
|
||||
opt= # option --all does not exist
|
||||
else
|
||||
opt=--$selected
|
||||
fi
|
||||
# XXX hidden groups are not included
|
||||
for line in ${${(f)"$(_dnf5_helper group list $opt)"}[2,-1]}; do
|
||||
line=( ${(z)line} )
|
||||
groups+=( "$line[1]:$line[2,-2]" )
|
||||
done
|
||||
_describe -t $selected-groups "$selected group" groups
|
||||
}
|
||||
|
||||
_dnf5_environments() {
|
||||
local line envs
|
||||
for line in ${${(f)"$(_dnf5_helper environment list)"}[2,-1]}; do
|
||||
line=( ${(z)line} )
|
||||
envs+=( "$line[1]:$line[2,-2]" )
|
||||
done
|
||||
_describe -t environments 'environment' envs
|
||||
}
|
||||
|
||||
# completers for (several) dnf commands
|
||||
|
||||
_dnf5-advisory () {
|
||||
_arguments : \
|
||||
$advisory_opts \
|
||||
'--contains-pkgs=[only show advisories containing specified packages]: : _sequence _dnf5_packages -T installed' \
|
||||
+ '(with)' \
|
||||
'--with-cve[show only advisories referencing CVE ticket]' \
|
||||
'--with-bz[show only advisories referencing Bugzilla ticket]' \
|
||||
+ '(type)' \
|
||||
'--all[show all advisories]' \
|
||||
'--available[show advisories containing newer versions of installed packages (default)]' \
|
||||
'--installed[show advisories containing equal and older version of installed packages]' \
|
||||
'--updates[show advisories containing upgradable packages]' \
|
||||
+ args \
|
||||
':subcommand:(list info summary)' '*:advisory spec:'
|
||||
}
|
||||
|
||||
_dnf5-group() {
|
||||
local -a tmp
|
||||
if (( CURRENT == 2 )); then
|
||||
tmp=(
|
||||
'list:list all matching groups'
|
||||
'info:print detailed information about groups'
|
||||
'install:install packages from specified groups'
|
||||
'remove:remove removable packages in specified groups'
|
||||
'upgrade:upgrade specified groups and packages in them'
|
||||
)
|
||||
_describe -t subcommands 'subcommand' tmp
|
||||
else
|
||||
case $words[2] in
|
||||
list|info)
|
||||
tmp=(
|
||||
'(--installed)--available[show only available groups]'
|
||||
'(--available)--installed[show only installed groups]'
|
||||
'--hidden[show also hidden groups]'
|
||||
'--contains-pkgs=[show only groups containing specified packages]: : _sequence _dnf5_packages -T all'
|
||||
'*: : _dnf5_groups'
|
||||
)
|
||||
;;
|
||||
install)
|
||||
tmp=( $common_opts
|
||||
'--with-optional[include optional packages from the groups]'
|
||||
'*: : _dnf5_groups -T available' )
|
||||
;|
|
||||
upgrade)
|
||||
tmp=( ${common_opts:#--skip-broken*}
|
||||
'*: : _dnf5_groups -T installed' )
|
||||
;|
|
||||
remove)
|
||||
tmp=( $offline_opts
|
||||
'*: : _dnf5_groups -T installed' )
|
||||
;|
|
||||
install|remove)
|
||||
tmp+=( '--no-packages[operate on groups only, not manipulate any packages]' )
|
||||
;|
|
||||
install|upgrade)
|
||||
tmp+=( $downgrade_opts )
|
||||
;;
|
||||
esac
|
||||
_arguments : $tmp
|
||||
fi
|
||||
}
|
||||
|
||||
_dnf5-history() {
|
||||
local -a tmp
|
||||
if (( CURRENT == 2 )); then
|
||||
tmp=(
|
||||
'list:list info about recorded transactions'
|
||||
'info:print detailed about specific transactions'
|
||||
'undo:revert all actions from the specified transaction'
|
||||
'redo:repeat the specified transaction'
|
||||
'rollback:undo all transactions performed after the specified transaction'
|
||||
'store:store the transaction into a directory'
|
||||
)
|
||||
_describe -t subcommands 'subcommand' tmp
|
||||
else
|
||||
case $words[2] in
|
||||
list|info)
|
||||
tmp=( '--reverse[reverse the order of transactions in output]' )
|
||||
;;
|
||||
undo|rollback|redo)
|
||||
tmp=( '--skip-unavailable[allow skipping impossible actions]' )
|
||||
;|
|
||||
undo|rollback)
|
||||
tmp+=( $replay_opts )
|
||||
;;
|
||||
store)
|
||||
tmp=( {-o,--output=}'[directory for storing the transaction (default ./transaction)]: : _directories')
|
||||
esac
|
||||
_arguments : $tmp '2:transaction:( )'
|
||||
fi
|
||||
}
|
||||
|
||||
_dnf5-mark() {
|
||||
local -a tmp
|
||||
if (( CURRENT == 2 )); then
|
||||
tmp=(
|
||||
'user:mark the package as user-installed'
|
||||
'dependency:mark the package as a dependency'
|
||||
'weak:mark the package as a weak dependency'
|
||||
'group:mark the package as installed by the specified group'
|
||||
)
|
||||
_describe -t subcommands 'subcommand' tmp
|
||||
else
|
||||
tmp=(
|
||||
'--skip-unavailable[skip packages not installed on the system]'
|
||||
'--store=[store the transaction in specified directory]: : _directories'
|
||||
)
|
||||
if [[ $words[2] = group ]]; then
|
||||
tmp+=( '2:group-id: _dnf5_groups -T installed' )
|
||||
fi
|
||||
_arguments : $tmp '*: : _dnf5_packages -T installed'
|
||||
fi
|
||||
}
|
||||
|
||||
_dnf5-module() {
|
||||
local -a tmp
|
||||
if (( CURRENT == 2 )); then
|
||||
tmp=(
|
||||
'list:list module streams'
|
||||
'info:print details about module streams'
|
||||
'enable:enable module streams'
|
||||
'disable:disable modules including all their streams'
|
||||
"reset:reset module state so it's no longer enabled or disabled"
|
||||
)
|
||||
_describe -t subcommands 'subcommand' tmp
|
||||
elif (( CURRENT == 3 )) && [[ $cur = -* ]]; then
|
||||
case $words[2] in
|
||||
list|info) tmp=( --enabled --disabled ) ;;
|
||||
enable) tmp=( --skip-broken --skip-unavailable ) ;;
|
||||
*) tmp=( --skip-unavailable ) ;;
|
||||
esac
|
||||
_wanted options expl 'option' compadd -a tmp
|
||||
else
|
||||
_message 'module spec'
|
||||
fi
|
||||
}
|
||||
|
||||
_dnf5-offline() { # also used by the 'system-upgrade' command
|
||||
local -a tmp
|
||||
if (( CURRENT == 2 )); then
|
||||
tmp=(
|
||||
'clean:remove any stored offline transactions and cached packages'
|
||||
'log:list boots during which offline transaction was attempted'
|
||||
'reboot:prepare the system for offline transaction and reboot'
|
||||
)
|
||||
if [[ $cmd = offline ]]; then
|
||||
tmp+=( 'status:show status of the current offline transaction' )
|
||||
else
|
||||
tmp+=( 'download:download all packages needed for upgrade' )
|
||||
fi
|
||||
_describe -t subcommands 'subcommand' tmp && ret=0
|
||||
else
|
||||
case $words[2] in
|
||||
download)
|
||||
_arguments : \
|
||||
'--releasever=[the version to upgrade to]:version number:' \
|
||||
'--no-downgrade:do not install packages older than currently installed' '*: :' && ret=0
|
||||
;;
|
||||
log)
|
||||
_arguments : \
|
||||
'--number=[show log of transaction specified by number]:transaction number:' '*: :' && ret=0
|
||||
;;
|
||||
reboot)
|
||||
_wanted options expl 'option' compadd -- --poweroff && ret=0
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
}
|
||||
|
||||
_dnf5-repoquery() {
|
||||
local v
|
||||
local -a opts=(
|
||||
$advisory_opts
|
||||
'--arch=[limit results to specified architectures]:list of archs: '
|
||||
'--available[limit results to available packages]'
|
||||
'--disable-modular-filtering[include packages of inactive module streams]'
|
||||
'--duplicates[limit to installed duplicate packages]'
|
||||
'--exactdeps[limit to packages that require capability specified by ==what{requires,depends}]'
|
||||
'--extras[limit to installed packages that are not present in any available repository]'
|
||||
'--file=[limit results to packages which own specified file]:list of files: _sequence _files'
|
||||
'--installed[query installed packages]'
|
||||
'--installonly[limit to installed installonly packages]'
|
||||
'--latest-limit=[limit to latest packages of specified number]:number:'
|
||||
'--leaves[limit to groups of installed packages not required by other installed packages]'
|
||||
'--providers-of=[select packages that provide specified attribute]:attribute:(conflicts depends enhances obsoletes provides recommends requires requires_pre suggests supplement)'
|
||||
'--recent[limit to only recently changed packages]'
|
||||
'--recursive[make --whatrequires/--providers-of work recursively]'
|
||||
'--security[limit to packages in security advisories]'
|
||||
'--srpm[use the corresponding source RPM]'
|
||||
'--unneeded[limit to unneeded installed packages]'
|
||||
'--upgrades[limit to available packages that provide upgrade for installed packages]'
|
||||
'--userinstalled[limit to packages that are not installed as dependencies]'
|
||||
'--whatdepends=[limit to packages that require, enhance, recommend, suggest of supplement specified capability]:list of capability:'
|
||||
'--whatconflicts=[limit to packages that conflicts with specified capabilities]:list of capability: '
|
||||
)
|
||||
for v in enhance obsolete provide recommend require suggest supplement; do
|
||||
opts+=( "--what${v}s=[limit to packages that $v specified capabilities]:list of capability: ")
|
||||
done
|
||||
# mutually exclusive formating options
|
||||
opts+=(
|
||||
+ '(format)'
|
||||
'--conflicts[display capabilities that the package conflicts with]'
|
||||
'--depends[display capabilities that the package depends on, enables, recommends, suggests or supplements]'
|
||||
'--files[show files in the package]'
|
||||
'--requires-pre[display capabilities required to run pre/post scripts of the package]'
|
||||
'--sourcerpm[display source RPM of the package]'
|
||||
'--location[display location of the package]'
|
||||
'--info[show detailed information about the package]'
|
||||
'--changelogs[print the package changelogs]'
|
||||
'(- *)--querytags[list tags recognized by --queryformat]'
|
||||
'--queryformat=[specify output format]:format:'
|
||||
)
|
||||
for v in enhance obsolete provide recommend require suggest supplement; do
|
||||
opts+=( "--${v}s[display capabilities ${v}ed by the package]" )
|
||||
done
|
||||
|
||||
_arguments : '*: : _dnf5_packages -T all' $opts
|
||||
}
|
||||
|
||||
# dnf commands
|
||||
|
||||
_dnf5_commands() {
|
||||
local -a dnf_cmds=(
|
||||
'advisory:manage advisories'
|
||||
'autoremove:remove unneeded packages'
|
||||
'check:check for problems in package database'
|
||||
'check-upgrade:check for available package upgrades'
|
||||
'clean:remove or invalidate cached data'
|
||||
'distro-sync:up/downgrade installed packages to the latest available'
|
||||
'downgrade:downgrade packages'
|
||||
'download:download packages'
|
||||
'environment:manage comps environments'
|
||||
'group:manage comps groups'
|
||||
'history:manage transaction history'
|
||||
'info:provide detailed information about packages'
|
||||
'install:install packages'
|
||||
'leaves:list groups of leaf packages'
|
||||
'list:list installed or available packages'
|
||||
'makecache:generate the metadata cache'
|
||||
'mark:change the reason of an installed package'
|
||||
'module:manage modules'
|
||||
'offline:manage offline transactions'
|
||||
'provides:find what package provides the given value'
|
||||
'reinstall:reinstall packages'
|
||||
'remove:remove packages'
|
||||
'replay:replay stored transactions'
|
||||
'repo:manage repositories'
|
||||
'repoquery:search for packages in repositories'
|
||||
'search:search for packages using keywords'
|
||||
'swap:remove software and install another in the single transaction'
|
||||
'system-upgrade:upgrade the system to a new major release'
|
||||
'upgrade:upgrade packages'
|
||||
'versionlock:protect packages from updates to newer versions'
|
||||
)
|
||||
_describe -t dnf-commands 'dnf command' dnf_cmds
|
||||
}
|
||||
|
||||
# subcommands and options
|
||||
|
||||
_dnf5_subcmds_opts() {
|
||||
local cur=$words[CURRENT] cmd=$words[1] expl ret=1
|
||||
local -a tmp
|
||||
# common options
|
||||
local -a offline_opts=(
|
||||
'(--store)--offline[store the transaction to be performed offline]'
|
||||
'(--offline)--store=[store the transaction in specified directory]: : _directories'
|
||||
)
|
||||
local -a common_opts=(
|
||||
$offline_opts
|
||||
'--allowerasing[allow erasing of installed packages]'
|
||||
'--skip-broken[resolve dependency problems by skipping problematic packages]'
|
||||
"--skip-unavailable[skip packages that can't be synchronized]"
|
||||
'--downloadonly[download packages without executing transaction]'
|
||||
)
|
||||
local -a advisory_opts=(
|
||||
'--advisories=[consider only specified advisories]:list of advisories:'
|
||||
'--advisory-severities=[limit to advisories with specified severity]:severity:_sequence compadd - critical important moderate low none'
|
||||
'--bzs=[limit to advisories that fix specified Bugzilla ID]:list of Bugzilla ID:'
|
||||
'--cves=[limit to advisories that fix specified CVE ID]:list of CVD ID]:'
|
||||
'--security[limit to security advisories]'
|
||||
'--bugfix[limit to bugfix advisories]'
|
||||
'--enhancement[limit to enhancement advisories]'
|
||||
'--newpackage[limit to newpackage advisories]'
|
||||
)
|
||||
local -a downgrade_opts=(
|
||||
'(--no-allow-downgrade)--allow-downgrade[enable downgrade of dependencies]'
|
||||
'(--allow-downgrade)--no-allow-downgrade[disable downgrade of dependencies]'
|
||||
)
|
||||
local -a replay_opts=(
|
||||
'--ignore-extras[not consider extra packages]'
|
||||
'--ignore-installed[mismatches between installed and stored transaction are not errors]'
|
||||
)
|
||||
# Deal with some aliases (not comprehensive)
|
||||
case $cmd in
|
||||
check-updgrade) cmd=check-update;;
|
||||
dg) cmd=downgrade;;
|
||||
dsync) cmd=distro-sync;;
|
||||
grp) cmd=group;;
|
||||
if) cmd=info;;
|
||||
in) cmd=install;;
|
||||
ls) cmd=list;;
|
||||
mc) cmd=makecache;;
|
||||
rei) cmd=reinstall;;
|
||||
rm) cmd=remove ;;
|
||||
rq) cmd=repoquery;;
|
||||
se) cmd=search;;
|
||||
update|up) cmd=upgrade;;
|
||||
esac
|
||||
local curcontext="${curcontext%:*:*}:dnf-${cmd}:"
|
||||
|
||||
case $cmd in
|
||||
advisory|group|history|mark|module|offline|repoquery)
|
||||
_dnf5-$cmd && ret=0
|
||||
;;
|
||||
system-upgrade)
|
||||
_dnf5-offline && ret=0
|
||||
;;
|
||||
autoremove)
|
||||
_arguments : $offline_opts && ret=0
|
||||
;;
|
||||
check)
|
||||
_arguments : \
|
||||
'--dependencies[show missing dependencies and conflicts]' \
|
||||
'--duplicates[show duplicated packages]' \
|
||||
'--obsoleted[show obsoleted packages]' && ret=0
|
||||
;;
|
||||
check-upgrade)
|
||||
_arguments : \
|
||||
$advisory_opts \
|
||||
'--changelogs[print package changelogs]' \
|
||||
'--minimal[reports the lowest versions of packages that fix advisories]' \
|
||||
'*: : _dnf5_packages -T installed' && ret=0
|
||||
;;
|
||||
clean)
|
||||
tmp=(
|
||||
'dbcache:remove cache files generated from the repository metadata'
|
||||
'expire-cache:mark the repository metadata expired'
|
||||
'metadata:remove the repository metadata'
|
||||
'packages:remove any cached packages'
|
||||
'all:clean all'
|
||||
)
|
||||
_describe -t cache-types 'cache type' tmp && ret=0
|
||||
;;
|
||||
distro-sync)
|
||||
_arguments : $common_opts '*: : _dnf5_packages -T installed' && ret=0
|
||||
;;
|
||||
downgrade)
|
||||
_arguments : \
|
||||
$common_opts $downgrade_opts \
|
||||
'*: : _dnf5_packages -T installed' && ret=0
|
||||
;;
|
||||
download)
|
||||
_arguments : \
|
||||
'--arch=[limit to packages of specified architecture]:list of architectures:' \
|
||||
'--resolve[resolve and download needed dependencies]' \
|
||||
'--alldeps[with --resolve, also download already installed dependencies]' \
|
||||
'--destdir=[download to the specified directory]: : _directories' \
|
||||
'--srpm[download the source rpm]' \
|
||||
'--url[print the list of URLs where the rpms can be downloaded]' \
|
||||
'*--urlprotocol=[with --url, limit to specified protocols]:protocol:_sequence compadd - http https ftp file' \
|
||||
'*: : _dnf5_packages -T all' && ret=0
|
||||
;;
|
||||
environment)
|
||||
_arguments : \
|
||||
'--available[show only available environments]' \
|
||||
'--installed[show only installed environments]' \
|
||||
':subcommand:(list info)' \
|
||||
'*: : _dnf5_environments' && ret=0
|
||||
;;
|
||||
info|list)
|
||||
_arguments : \
|
||||
'--showduplicates[show all versions of the packages]' \
|
||||
'*: : _dnf5_packages -T all' \
|
||||
+ '(type)' \
|
||||
'--installed[list only installed packages]:*: : _dnf5_packages -T installed' \
|
||||
'--available[list only available packages]:*: : _dnf5_packages -T available' \
|
||||
'--extras[list only extras]' \
|
||||
'--obsoletes[list only installed but obsoleted packages]:*: : _dnf5_packages -T installed' \
|
||||
'--recent[list only recently added packages]' \
|
||||
'--upgrades[list only available upgrades of installed packages]:*: : _dnf5_packages -T upgradable' \
|
||||
'--autoremove[list only packages that will be autoremoved]:*: : _dnf5_packages -T installed' &&ret=0
|
||||
;;
|
||||
install)
|
||||
_arguments : \
|
||||
$common_opts $downgrade_opts $advisory_opts \
|
||||
'*: : _dnf5_packages_or_rpms -T available' && ret=0
|
||||
;;
|
||||
leaves|makecache)
|
||||
# nothing to complete
|
||||
;;
|
||||
provides)
|
||||
_files && ret=0
|
||||
;;
|
||||
reinstall)
|
||||
_arguments : \
|
||||
$common_opts $downgrade_opts \
|
||||
'*: : _dnf5_packages_or_rpms -T installed' && ret=0
|
||||
;;
|
||||
remove)
|
||||
_arguments : \
|
||||
$offline_opts \
|
||||
'--no-autoremove[not remove dependencies that are no longer used]' \
|
||||
'*: : _dnf5_packages -T installed' && ret=0
|
||||
;;
|
||||
replay)
|
||||
_arguments : \
|
||||
$replay_opts \
|
||||
':transaction path:_directories' && ret=0
|
||||
;;
|
||||
repo)
|
||||
_arguments : \
|
||||
'--all[show info about all repositories]' \
|
||||
'--enabled[show info only about enabled repositories]' \
|
||||
'--disabled[show info only about disabled repositories]' \
|
||||
':subcommand:(list info)' && ret=0
|
||||
;;
|
||||
search)
|
||||
_arguments : \
|
||||
'--all[search patterns also inside description and URL fields]' \
|
||||
'--showduplicates[show all versions of packages, not only the latest ones]' \
|
||||
'*:search pattern:' && ret=0
|
||||
;;
|
||||
swap)
|
||||
_arguments : \
|
||||
$offline_opts \
|
||||
'--allowerasing[allow erasing of installed packages]' \
|
||||
': : _dnf5_packages -T installed' \
|
||||
': : _dnf5_packages -T available' && ret=0
|
||||
;;
|
||||
upgrade)
|
||||
_arguments : \
|
||||
${common_opts:#--skip-broken*} $downgrade_opts $advisory_opts \
|
||||
'--minimal[upgrade only to the lowest available versions that fix advisories]' \
|
||||
'--destdir=[specify directory into which downloading packages]: : _directories' \
|
||||
'*: : _dnf5_packages_or_rpms -T upgradable' && ret=0
|
||||
;;
|
||||
versionlock)
|
||||
_arguments : \
|
||||
':subcommand:(add exclude clear delete list)' \
|
||||
'*: : _dnf5_packages -T all' && ret=0
|
||||
;;
|
||||
esac
|
||||
return ret
|
||||
}
|
||||
|
||||
# main completer
|
||||
|
||||
_dnf5() {
|
||||
local curcontext="$curcontext" state state_descr line ret=1
|
||||
typeset -A opt_args
|
||||
local -a opts=(
|
||||
'(-y --assumeyes)--assumeno[answer no for all questions]'
|
||||
'--best[try the best available package version]'
|
||||
'(-C --cacheonly)'{-C,--cacheonly}"[run entirely from system cache, don't update cache]"
|
||||
'--comment=[add comment to transaction history]:comment:'
|
||||
'(-c --config)'{-c+,--config=}'[specify configuration file]:config file:_files'
|
||||
'--debugsolver[dump detailed solving results in file ./debugdata]'
|
||||
'*--disable-plugin=[disable specified plugins]:list of plugin names:'
|
||||
'(--repo)*--disable-repo=[disable specified repos]: : _sequence _dnf5_repositories -T enabled'
|
||||
'--dump-main-config[print main configuration values to stdout]'
|
||||
'*--dump-repo-config=[print repository configuration values to stdout]:repi id'
|
||||
'--dump-variables[print variable values to stdout]'
|
||||
'*--enable-plugin=[enable specified plugins]:list of plugin names:'
|
||||
'*--enable-repo=[enable additional repos]: : _sequence _dnf5_repositories -T disabled'
|
||||
'--forcearch=[force the use of the specified arch]:arch:'
|
||||
'(-)'{-h,--help}'[show the help message]'
|
||||
'--installroot=[set install root]: : _directories'
|
||||
'--no-best[do not limit transactions to best candidates]'
|
||||
'--no-docs[do not install documentation]'
|
||||
'--no-gpgcheck[skip checking GPG signatures on packages]'
|
||||
'--no-plugins[disable all plugins]'
|
||||
'(-q --quiet)'{-q,--quiet}'[show just the relevant content]'
|
||||
'--refresh[force refreshing metadata before running the command]'
|
||||
'--releasever=[override distribution release in config files]:release ver:'
|
||||
'(--disablerepo)*--repo=[enable just the specified repo]: : _sequence _dnf5_repositories -T all'
|
||||
'*--repofrompath=[specify additional repos]:repository_label,path_or_url: '
|
||||
'*--setopt=[override option in config file]:repoid.option=value:'
|
||||
'*--setvar=[override DNF5 variable value]'
|
||||
'--show-new-leaves[show newly installed leaf packages]'
|
||||
'--use-host-config[use config files and variables from host system]'
|
||||
'(- *)--version[show dnf version]'
|
||||
'(-y --assumeyes --assumeno)'{-y,--assumeyes}'[answer yes for all questions]'
|
||||
'*'{-x+,--exclude=}'[exclude specified packages from transaction]: : _sequence _dnf5_packages -T all'
|
||||
)
|
||||
_arguments -C -s : $opts ': :->command' '*:: :->cmd_args' && ret=0
|
||||
|
||||
case $state in
|
||||
command) _dnf5_commands && ret=0 ;;
|
||||
cmd_args) _dnf5_subcmds_opts && ret=0 ;;
|
||||
esac
|
||||
return ret
|
||||
}
|
||||
|
||||
_dnf5 "$@"
|
||||
|
|
@ -128,7 +128,7 @@ __docker-compose_subcommand() {
|
|||
'--resolve-image-digests[Pin image tags to digests.]' \
|
||||
'--services[Print the service names, one per line.]' \
|
||||
'--volumes[Print the volume names, one per line.]' \
|
||||
'--hash[Print the service config hash, one per line. Set "service1,service2" for a list of specified services.]' \ && ret=0
|
||||
'--hash[Print the service config hash, one per line. Set "service1,service2" for a list of specified services.]' && ret=0
|
||||
;;
|
||||
(create)
|
||||
_arguments \
|
||||
|
|
|
|||
|
|
@ -1,5 +1,8 @@
|
|||
# support Compose v2 as docker CLI plugin
|
||||
(( ${+commands[docker-compose]} )) && dccmd='docker-compose' || dccmd='docker compose'
|
||||
# Support Compose v2 as docker CLI plugin
|
||||
#
|
||||
# This tests that the (old) docker-compose command is in $PATH and that
|
||||
# it resolves to an existing executable file if it's a symlink.
|
||||
[[ -x "${commands[docker-compose]:A}" ]] && dccmd='docker-compose' || dccmd='docker compose'
|
||||
|
||||
alias dco="$dccmd"
|
||||
alias dcb="$dccmd build"
|
||||
|
|
|
|||
|
|
@ -1,19 +0,0 @@
|
|||
# docker-machine plugin for oh my zsh
|
||||
|
||||
### Usage
|
||||
|
||||
#### docker-vm
|
||||
Will create a docker-machine with the name "dev" (required only once)
|
||||
To create a second machine call "docker-vm foobar" or pass any other name
|
||||
|
||||
#### docker-up
|
||||
This will start your "dev" docker-machine (if necessary) and set it as the active one
|
||||
To start a named machine use "docker-up foobar"
|
||||
|
||||
#### docker-switch dev
|
||||
Use this to activate a running docker-machine (or to switch between multiple machines)
|
||||
You need to call either this or docker-up when opening a new terminal
|
||||
|
||||
#### docker-stop
|
||||
This will stop your "dev" docker-machine
|
||||
To stop a named machine use "docker-stop foobar"
|
||||
|
|
@ -1,359 +0,0 @@
|
|||
#compdef docker-machine
|
||||
# Description
|
||||
# -----------
|
||||
# zsh completion for docker-machine
|
||||
# https://github.com/leonhartX/docker-machine-zsh-completion
|
||||
# -------------------------------------------------------------------------
|
||||
# Version
|
||||
# -------
|
||||
# 0.1.1
|
||||
# -------------------------------------------------------------------------
|
||||
# Authors
|
||||
# -------
|
||||
# * Ke Xu <leonhartx.k@gmail.com>
|
||||
# -------------------------------------------------------------------------
|
||||
# Inspiration
|
||||
# -----------
|
||||
# * @sdurrheimer docker-compose-zsh-completion https://github.com/sdurrheimer/docker-compose-zsh-completion
|
||||
# * @ilkka _docker-machine
|
||||
|
||||
|
||||
__docker-machine_get_hosts() {
|
||||
[[ $PREFIX = -* ]] && return 1
|
||||
local state
|
||||
declare -a hosts
|
||||
state=$1; shift
|
||||
if [[ $state != all ]]; then
|
||||
hosts=(${(f)"$(_call_program commands docker-machine ls -q --filter state=$state)"})
|
||||
else
|
||||
hosts=(${(f)"$(_call_program commands docker-machine ls -q)"})
|
||||
fi
|
||||
_describe 'host' hosts "$@" && ret=0
|
||||
return ret
|
||||
}
|
||||
|
||||
__docker-machine_hosts_with_state() {
|
||||
declare -a hosts
|
||||
hosts=(${(f)"$(_call_program commands docker-machine ls -f '{{.Name}}\:{{.DriverName}}\({{.State}}\)\ {{.URL}}')"})
|
||||
_describe 'host' hosts
|
||||
}
|
||||
|
||||
__docker-machine_hosts_all() {
|
||||
__docker-machine_get_hosts all "$@"
|
||||
}
|
||||
|
||||
__docker-machine_hosts_running() {
|
||||
__docker-machine_get_hosts Running "$@"
|
||||
}
|
||||
|
||||
__docker-machine_get_swarm() {
|
||||
declare -a swarms
|
||||
swarms=(${(f)"$(_call_program commands docker-machine ls -f {{.Swarm}} | awk '{print $1}')"})
|
||||
_describe 'swarm' swarms
|
||||
}
|
||||
|
||||
__docker-machine_hosts_and_files() {
|
||||
_alternative "hosts:host:__docker-machine_hosts_all -qS ':'" 'files:files:_path_files'
|
||||
}
|
||||
|
||||
__docker-machine_filters() {
|
||||
[[ $PREFIX = -* ]] && return 1
|
||||
integer ret=1
|
||||
|
||||
if compset -P '*='; then
|
||||
case "${${words[-1]%=*}#*=}" in
|
||||
(driver)
|
||||
_describe -t driver-filter-opts "driver filter" opts_driver && ret=0
|
||||
;;
|
||||
(swarm)
|
||||
__docker-machine_get_swarm && ret=0
|
||||
;;
|
||||
(state)
|
||||
opts_state=('Running' 'Paused' 'Saved' 'Stopped' 'Stopping' 'Starting' 'Error')
|
||||
_describe -t state-filter-opts "state filter" opts_state && ret=0
|
||||
;;
|
||||
(name)
|
||||
__docker-machine_hosts_all && ret=0
|
||||
;;
|
||||
(label)
|
||||
_message 'label' && ret=0
|
||||
;;
|
||||
*)
|
||||
_message 'value' && ret=0
|
||||
;;
|
||||
esac
|
||||
else
|
||||
opts=('driver' 'swarm' 'state' 'name' 'label')
|
||||
_describe -t filter-opts "filter" opts -qS "=" && ret=0
|
||||
fi
|
||||
return ret
|
||||
}
|
||||
|
||||
__get_swarm_discovery() {
|
||||
declare -a masters services
|
||||
local service
|
||||
services=()
|
||||
masters=($(docker-machine ls -f {{.Swarm}} |grep '(master)' |awk '{print $1}'))
|
||||
for master in $masters; do
|
||||
service=${${${(f)"$(_call_program commands docker-machine inspect -f '{{.HostOptions.SwarmOptions.Discovery}}:{{.Name}}' $master)"}/:/\\:}}
|
||||
services=($services $service)
|
||||
done
|
||||
_describe -t services "swarm service" services && ret=0
|
||||
return ret
|
||||
}
|
||||
|
||||
__get_create_argument() {
|
||||
typeset -g docker_machine_driver
|
||||
if [[ CURRENT -le 2 ]]; then
|
||||
docker_machine_driver="none"
|
||||
elif [[ CURRENT > 2 && $words[CURRENT-2] = '-d' || $words[CURRENT-2] = '--driver' ]]; then
|
||||
docker_machine_driver=$words[CURRENT-1]
|
||||
elif [[ $words[CURRENT-1] =~ '^(-d|--driver)=' ]]; then
|
||||
docker_machine_driver=${${words[CURRENT-1]}/*=/}
|
||||
fi
|
||||
local driver_opt_cmd
|
||||
local -a opts_provider opts_common opts_read_argument
|
||||
opts_read_argument=(
|
||||
": :->argument"
|
||||
)
|
||||
opts_common=(
|
||||
$opts_help \
|
||||
'(--driver -d)'{--driver=,-d=}'[Driver to create machine with]:dirver:->driver-option' \
|
||||
'--engine-install-url=[Custom URL to use for engine installation]:url' \
|
||||
'*--engine-opt=[Specify arbitrary flags to include with the created engine in the form flag=value]:flag' \
|
||||
'*--engine-insecure-registry=[Specify insecure registries to allow with the created engine]:registry' \
|
||||
'*--engine-registry-mirror=[Specify registry mirrors to use]:mirror' \
|
||||
'*--engine-label=[Specify labels for the created engine]:label' \
|
||||
'--engine-storage-driver=[Specify a storage driver to use with the engine]:storage-driver:->storage-driver-option' \
|
||||
'*--engine-env=[Specify environment variables to set in the engine]:environment' \
|
||||
'--swarm[Configure Machine with Swarm]' \
|
||||
'--swarm-image=[Specify Docker image to use for Swarm]:image' \
|
||||
'--swarm-master[Configure Machine to be a Swarm master]' \
|
||||
'--swarm-discovery=[Discovery service to use with Swarm]:service:->swarm-service' \
|
||||
'--swarm-strategy=[Define a default scheduling strategy for Swarm]:strategy:(spread binpack random)' \
|
||||
'*--swarm-opt=[Define arbitrary flags for swarm]:flag' \
|
||||
'*--swarm-join-opt=[Define arbitrary flags for Swarm join]:flag' \
|
||||
'--swarm-host=[ip/socket to listen on for Swarm master]:host' \
|
||||
'--swarm-addr=[addr to advertise for Swarm (default: detect and use the machine IP)]:address' \
|
||||
'--swarm-experimental[Enable Swarm experimental features]' \
|
||||
'*--tls-san=[Support extra SANs for TLS certs]:option'
|
||||
)
|
||||
driver_opt_cmd="docker-machine create -d $docker_machine_driver | grep $docker_machine_driver | sed -e 's/\(--.*\)\ *\[\1[^]]*\]/*\1/g' -e 's/\(\[[^]]*\)/\\\\\\1\\\\/g' -e 's/\".*\"\(.*\)/\1/g' | awk '{printf \"%s[\", \$1; for(i=2;i<=NF;i++) {printf \"%s \", \$i}; print \"]\"}'"
|
||||
if [[ $docker_machine_driver != "none" ]]; then
|
||||
opts_provider=(${(f)"$(_call_program commands $driver_opt_cmd)"})
|
||||
_arguments \
|
||||
$opts_provider \
|
||||
$opts_read_argument \
|
||||
$opts_common && ret=0
|
||||
else
|
||||
_arguments $opts_common && ret=0
|
||||
fi
|
||||
case $state in
|
||||
(driver-option)
|
||||
_describe -t driver-option "driver" opts_driver && ret=0
|
||||
;;
|
||||
(storage-driver-option)
|
||||
_describe -t storage-driver-option "storage driver" opts_storage_driver && ret=0
|
||||
;;
|
||||
(swarm-service)
|
||||
__get_swarm_discovery && ret=0
|
||||
;;
|
||||
(argument)
|
||||
ret=0
|
||||
;;
|
||||
esac
|
||||
return ret
|
||||
}
|
||||
|
||||
|
||||
__docker-machine_subcommand() {
|
||||
local -a opts_help
|
||||
opts_help=("(- :)--help[Print usage]")
|
||||
local -a opts_only_host opts_driver opts_storage_driver opts_state
|
||||
opts_only_host=(
|
||||
"$opts_help"
|
||||
"*:host:__docker-machine_hosts_all"
|
||||
)
|
||||
opts_driver=('amazonec2' 'azure' 'digitalocean' 'exoscale' 'generic' 'google' 'hyperv' 'none' 'openstack' 'rackspace' 'softlayer' 'virtualbox' 'vmwarefusion' 'vmwarevcloudair' 'vmwarevsphere')
|
||||
opts_storage_driver=('overlay' 'aufs' 'btrfs' 'devicemapper' 'vfs' 'zfs')
|
||||
integer ret=1
|
||||
|
||||
case "$words[1]" in
|
||||
(active)
|
||||
_arguments \
|
||||
$opts_help \
|
||||
'(--timeout -t)'{--timeout=,-t=}'[Timeout in seconds, default to 10s]:seconds' && ret=0
|
||||
;;
|
||||
(config)
|
||||
_arguments \
|
||||
$opts_help \
|
||||
'--swarm[Display the Swarm config instead of the Docker daemon]' \
|
||||
"*:host:__docker-machine_hosts_all" && ret=0
|
||||
;;
|
||||
(create)
|
||||
__get_create_argument
|
||||
;;
|
||||
(env)
|
||||
_arguments \
|
||||
$opts_help \
|
||||
'--swarm[Display the Swarm config instead of the Docker daemon]' \
|
||||
'--shell=[Force environment to be configured for a specified shell: \[fish, cmd, powershell\], default is auto-detect]:shell' \
|
||||
'(--unset -u)'{--unset,-u}'[Unset variables instead of setting them]' \
|
||||
'--no-proxy[Add machine IP to NO_PROXY environment variable]' \
|
||||
'*:host:__docker-machine_hosts_running' && ret=0
|
||||
;;
|
||||
(help)
|
||||
_arguments ':subcommand:__docker-machine_commands' && ret=0
|
||||
;;
|
||||
(inspect)
|
||||
_arguments \
|
||||
$opts_help \
|
||||
'(--format -f)'{--format=,-f=}'[Format the output using the given go template]:template' \
|
||||
'*:host:__docker-machine_hosts_all' && ret=0
|
||||
;;
|
||||
(ip)
|
||||
_arguments \
|
||||
$opts_help \
|
||||
'*:host:__docker-machine_hosts_running' && ret=0
|
||||
;;
|
||||
(kill)
|
||||
_arguments \
|
||||
$opts_help \
|
||||
'*:host:__docker-machine_hosts_with_state' && ret=0
|
||||
;;
|
||||
(ls)
|
||||
_arguments \
|
||||
$opts_help \
|
||||
'(--quiet -q)'{--quiet,-q}'[Enable quiet mode]' \
|
||||
'*--filter=[Filter output based on conditions provided]:filter:->filter-options' \
|
||||
'(--timeout -t)'{--timeout=,-t=}'[Timeout in seconds, default to 10s]:seconds' \
|
||||
'(--format -f)'{--format=,-f=}'[Pretty-print machines using a Go template]:template' && ret=0
|
||||
case $state in
|
||||
(filter-options)
|
||||
__docker-machine_filters && ret=0
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
(provision)
|
||||
_arguments $opts_only_host && ret=0
|
||||
;;
|
||||
(regenerate-certs)
|
||||
_arguments \
|
||||
$opts_help \
|
||||
'(--force -f)'{--force,-f}'[Force rebuild and do not prompt]' \
|
||||
'*:host:__docker-machine_hosts_all' && ret=0
|
||||
;;
|
||||
(restart)
|
||||
_arguments \
|
||||
$opts_help \
|
||||
'*:host:__docker-machine_hosts_with_state' && ret=0
|
||||
;;
|
||||
(rm)
|
||||
_arguments \
|
||||
$opts_help \
|
||||
'(--force -f)'{--force,-f}'[Remove local configuration even if machine cannot be removed, also implies an automatic yes (`-y`)]' \
|
||||
'-y[Assumes automatic yes to proceed with remove, without prompting further user confirmation]' \
|
||||
'*:host:__docker-machine_hosts_with_state' && ret=0
|
||||
;;
|
||||
(scp)
|
||||
_arguments \
|
||||
$opts_help \
|
||||
'(--recursive -r)'{--recursive,-r}'[Copy files recursively (required to copy directories))]' \
|
||||
'*:files:__docker-machine_hosts_and_files' && ret=0
|
||||
;;
|
||||
(ssh)
|
||||
_arguments \
|
||||
$opts_help \
|
||||
'*:host:__docker-machine_hosts_running' && ret=0
|
||||
;;
|
||||
(start)
|
||||
_arguments \
|
||||
$opts_help \
|
||||
'*:host:__docker-machine_hosts_with_state' && ret=0
|
||||
;;
|
||||
(status)
|
||||
_arguments $opts_only_host && ret=0
|
||||
;;
|
||||
(stop)
|
||||
_arguments \
|
||||
$opts_help \
|
||||
'*:host:__docker-machine_hosts_with_state' && ret=0
|
||||
;;
|
||||
(upgrade)
|
||||
_arguments $opts_only_host && ret=0
|
||||
;;
|
||||
(url)
|
||||
_arguments \
|
||||
$opts_help \
|
||||
'*:host:__docker-machine_hosts_running' && ret=0
|
||||
;;
|
||||
esac
|
||||
|
||||
return ret
|
||||
}
|
||||
|
||||
|
||||
__docker-machine_commands() {
|
||||
local cache_policy
|
||||
|
||||
zstyle -s ":completion:${curcontext}:" cache-policy cache_policy
|
||||
if [[ -z "$cache_policy" ]]; then
|
||||
zstyle ":completion:${curcontext}:" cache-policy __docker-machine_caching_policy
|
||||
fi
|
||||
|
||||
if ( [[ ${+_docker_machine_subcommands} -eq 0 ]] || _cache_invalid docker_machine_subcommands) \
|
||||
&& ! _retrieve_cache docker_machine_subcommands;
|
||||
then
|
||||
local -a lines
|
||||
lines=(${(f)"$(_call_program commands docker-machine 2>&1)"})
|
||||
_docker_machine_subcommands=(${${${lines[$((${lines[(i)Commands:]} + 1)),${lines[(I) *]}]}## #}/$'\t'##/:})
|
||||
(( $#_docker_machine_subcommands > 0 )) && _store_cache docker_machine_subcommands _docker_machine_subcommands
|
||||
fi
|
||||
_describe -t docker-machine-commands "docker-machine command" _docker_machine_subcommands
|
||||
}
|
||||
|
||||
__docker-machine_caching_policy() {
|
||||
oldp=( "$1"(Nmh+1) )
|
||||
(( $#oldp ))
|
||||
}
|
||||
|
||||
_docker-machine() {
|
||||
if [[ $service != docker-machine ]]; then
|
||||
_call_function - _$service
|
||||
return
|
||||
fi
|
||||
|
||||
local curcontext="$curcontext" state line
|
||||
integer ret=1
|
||||
typeset -A opt_args
|
||||
|
||||
_arguments -C \
|
||||
"(- :)"{-h,--help}"[Show help]" \
|
||||
"(-D --debug)"{-D,--debug}"[Enable debug mode]" \
|
||||
'(-s --storage-path)'{-s,--storage-path}'[Configures storage path]:file:_files' \
|
||||
'--tls-ca-cert[CA to verify remotes against]:file:_files' \
|
||||
'--tls-ca-key[Private key to generate certificates]:file:_files' \
|
||||
'--tls-client-cert[Client cert to use for TLS]:file:_files' \
|
||||
'--tls-client-key[Private key used in client TLS auth]:file:_files' \
|
||||
'--github-api-token[Token to use for requests to the GitHub API]' \
|
||||
'--native-ssh[Use the native (Go-based) SSH implementation.]' \
|
||||
'--bugsnag-api-token[Bugsnag API token for crash reporting]' \
|
||||
'(- :)'{-v,--version}'[Print the version]' \
|
||||
"(-): :->command" \
|
||||
"(-)*:: :->option-or-argument" && ret=0
|
||||
|
||||
case $state in
|
||||
(command)
|
||||
__docker-machine_commands && ret=0
|
||||
;;
|
||||
(option-or-argument)
|
||||
curcontext=${curcontext%:*:*}:docker-machine-$words[1]:
|
||||
__docker-machine_subcommand && ret=0
|
||||
ret=0
|
||||
;;
|
||||
esac
|
||||
|
||||
return ret
|
||||
}
|
||||
|
||||
_docker-machine "$@"
|
||||
|
|
@ -1,33 +0,0 @@
|
|||
DEFAULT_MACHINE="default"
|
||||
|
||||
docker-up() {
|
||||
if [ -z "$1" ]
|
||||
then
|
||||
docker-machine start "${DEFAULT_MACHINE}"
|
||||
eval $(docker-machine env "${DEFAULT_MACHINE}")
|
||||
else
|
||||
docker-machine start $1
|
||||
eval $(docker-machine env $1)
|
||||
fi
|
||||
echo $DOCKER_HOST
|
||||
}
|
||||
docker-stop() {
|
||||
if [ -z "$1" ]
|
||||
then
|
||||
docker-machine stop "${DEFAULT_MACHINE}"
|
||||
else
|
||||
docker-machine stop $1
|
||||
fi
|
||||
}
|
||||
docker-switch() {
|
||||
eval $(docker-machine env $1)
|
||||
echo $DOCKER_HOST
|
||||
}
|
||||
docker-vm() {
|
||||
if [ -z "$1" ]
|
||||
then
|
||||
docker-machine create -d virtualbox --virtualbox-disk-size 20000 --virtualbox-memory 4096 --virtualbox-cpu-count 2 "${DEFAULT_MACHINE}"
|
||||
else
|
||||
docker-machine create -d virtualbox --virtualbox-disk-size 20000 --virtualbox-memory 4096 --virtualbox-cpu-count 2 $1
|
||||
fi
|
||||
}
|
||||
|
|
@ -39,6 +39,10 @@ following setting. See https://github.com/ohmyzsh/ohmyzsh/issues/11789 for more
|
|||
zstyle ':omz:plugins:docker' legacy-completion yes
|
||||
```
|
||||
|
||||
### For Podman's Docker wrapper users
|
||||
|
||||
If you use Podman's Docker wrapper, you need to enable legacy completion. See above section.
|
||||
|
||||
## Aliases
|
||||
|
||||
| Alias | Command | Description |
|
||||
|
|
@ -51,6 +55,7 @@ zstyle ':omz:plugins:docker' legacy-completion yes
|
|||
| dii | `docker image inspect` | Display detailed information on one or more images |
|
||||
| dils | `docker image ls` | List docker images |
|
||||
| dipu | `docker image push` | Push an image or repository to a remote registry |
|
||||
| dipru | `docker image prune -a` | Remove all images not referenced by any container |
|
||||
| dirm | `docker image rm` | Remove one or more images |
|
||||
| dit | `docker image tag` | Add a name and tag to a particular image |
|
||||
| dlo | `docker container logs` | Fetch the logs of a docker container |
|
||||
|
|
@ -61,6 +66,8 @@ zstyle ':omz:plugins:docker' legacy-completion yes
|
|||
| dnls | `docker network ls` | List all networks the engine daemon knows about, including those spanning multiple hosts |
|
||||
| dnrm | `docker network rm` | Remove one or more networks |
|
||||
| dpo | `docker container port` | List port mappings or a specific mapping for the container |
|
||||
| dps | `docker ps` | List all the running docker containers |
|
||||
| dpsa | `docker ps -a` | List all running and stopped containers |
|
||||
| dpu | `docker pull` | Pull an image or a repository from a registry |
|
||||
| dr | `docker container run` | Create a new container and start it using the specified command |
|
||||
| drit | `docker container run -it` | Create a new container and start it in an interactive shell |
|
||||
|
|
@ -70,6 +77,7 @@ zstyle ':omz:plugins:docker' legacy-completion yes
|
|||
| drs | `docker container restart` | Restart one or more containers |
|
||||
| dsta | `docker stop $(docker ps -q)` | Stop all running containers |
|
||||
| dstp | `docker container stop` | Stop one or more running containers |
|
||||
| dsts | `docker stats` | Display real-time streaming statistics for containers |
|
||||
| dtop | `docker top` | Display the running processes of a container |
|
||||
| dvi | `docker volume inspect` | Display detailed information about one or more volumes |
|
||||
| dvls | `docker volume ls` | List all the volumes known to docker |
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue