This commit is contained in:
abc 2024-08-06 11:00:42 +08:00
commit 95a61164a7
112 changed files with 2146 additions and 1995 deletions

View file

@ -6,3 +6,6 @@ insert_final_newline = true
charset = utf-8
indent_size = 2
indent_style = space
[*.py]
indent_size = 4

View file

@ -5,8 +5,10 @@ updates:
schedule:
interval: "weekly"
day: "sunday"
labels: []
- package-ecosystem: "pip"
directory: "/.github/workflows/dependencies"
schedule:
interval: "weekly"
day: "sunday"
labels: []

View file

@ -7,6 +7,32 @@ dependencies:
set -e
rm -rf git-completion.plugin.zsh Makefile README.adoc t tools
test -e git-completion.zsh && mv -f git-completion.zsh _git
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.7.1
precopy: |
set -e
rm -r test
rm install.sh tty.gif wd.1
plugins/z:
branch: master
repo: agkozak/zsh-z
@ -18,21 +44,3 @@ dependencies:
set -e
test -e _zshz && mv -f _zshz _z
test -e zsh-z.plugin.zsh && mv -f zsh-z.plugin.zsh z.plugin.zsh
plugins/history-substring-search:
repo: zsh-users/zsh-history-substring-search
branch: master
version: 8dd05bfcc12b0cd1ee9ea64be725b3d9f713cf64
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/gradle:
repo: gradle/gradle-completion
branch: master
version: 25da917cf5a88f3e58f05be3868a7b2748c8afe6
precopy: |
set -e
find . ! -name _gradle ! -name LICENSE -delete

View file

@ -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 }}

View file

@ -0,0 +1 @@
.venv

View file

@ -1,2 +1,7 @@
PyYAML~=6.0.1
requests~=2.31.0
certifi==2024.7.4
charset-normalizer==3.3.2
idna==3.7
PyYAML==6.0.1
requests==2.32.3
semver==3.0.2
urllib3==2.2.2

View file

@ -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, short_sha)
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()

View file

@ -37,7 +37,7 @@ Once installed, your terminal shell will become the talk of the town _or your mo
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).
[![CI](https://github.com/ohmyzsh/ohmyzsh/workflows/CI/badge.svg)](https://github.com/ohmyzsh/ohmyzsh/actions?query=workflow%3ACI)
[![X (formerly Twitter) Follow](https://img.shields.io/twitter/follow/ohmyzsh?label=%40ohmyzsh&logo=x&style=flat)](https://twitter.com/intent/follow?screen_name=ohmyzsh)
@ -116,7 +116,7 @@ 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 |
| :-------- | :------------------------------------------------------------------------------------------------ |
@ -262,7 +262,7 @@ If you're in China, India, or another country that blocks `raw.githubusercontent
#### 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}`.
@ -336,7 +336,7 @@ If you would like to override the functionality of a plugin distributed with Oh
<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`:
@ -369,7 +369,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
@ -389,17 +389,6 @@ Instead, you can now use the following:
zstyle ':omz:lib:directories' aliases no
```
### Disable async git prompt
Async prompt functions are an experimental feature (included on April 3, 2024) that allows Oh My Zsh to render prompt information
asyncronously. 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
```
#### Notice <!-- omit in toc -->
> This feature is currently in a testing phase and it may be subject to change in the future.
@ -409,6 +398,17 @@ zstyle ':omz:alpha:lib:git' async-prompt no
> 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.
### Disable 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
```
## 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**:
@ -496,7 +496,7 @@ Thank you so much!
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!
@ -513,4 +513,4 @@ Oh My Zsh is released under the [MIT license](LICENSE.txt).
![Planet Argon](https://pa-github-assets.s3.amazonaws.com/PARGON_logo_digital_COL-small.jpg)
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).

View file

@ -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.

View file

@ -241,10 +241,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

View file

@ -160,6 +160,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

View file

@ -39,8 +39,13 @@ function _omz_git_prompt_info() {
echo "${ZSH_THEME_GIT_PROMPT_PREFIX}${ref:gs/%/%%}${upstream:gs/%/%%}$(parse_git_dirty)${ZSH_THEME_GIT_PROMPT_SUFFIX}"
}
# Use async version if setting is enabled or undefined
if zstyle -T ':omz:alpha:lib:git' async-prompt; then
# 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
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]}"

View file

@ -1,14 +1,21 @@
## History wrapper
function omz_history {
# parse arguments and remove from $@
local clear list stamp
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.
print -u2 History file deleted.
elif [[ $# -eq 0 ]]; then
# if no arguments provided, show full history starting from 1
builtin fc $stamp -l 1

View file

@ -20,6 +20,7 @@ function chruby_prompt_info \
jenv_prompt_info \
azure_prompt_info \
tf_prompt_info \
conda_prompt_info \
{
return 1
}

169
lib/tests/cli.test.zsh Normal file
View 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
)"

View file

@ -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

View file

@ -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.

View file

@ -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

View file

@ -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.

View file

@ -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
}

View file

@ -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
```
![image](https://github.com/ohmyzsh/ohmyzsh/assets/19378/39642750-fb10-4f1a-b7f9-f36789eeb01b)
### Options
> In order to clarify, let's say `alias a=abc` has source 'abc' and destination 'a'.

View file

@ -0,0 +1,8 @@
# 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)
```

View 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" &|

View file

@ -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.

View file

@ -58,7 +58,7 @@ if [[ "$OSTYPE" = darwin* ]]; then
fi
echo "%{$fg[$color]%}[${battery_pct}%%]%{$reset_color%}"
else
echo ""
echo "${BATTERY_CHARGING-⚡️}"
fi
}

View file

@ -117,7 +117,7 @@ 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"} &>/dev/null
elif (( ${+commands[growlnotify]} )); then # macOS growl
growlnotify -m "$title" "$message"
elif (( ${+commands[notify-send]} )); then

View file

@ -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

View file

@ -34,16 +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 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() {

View file

@ -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" &|

View file

@ -1,4 +1,4 @@
#compdef bundle
#compdef bundle bundler
local curcontext="$curcontext" state line _gems _opts ret=1

View file

@ -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.

View 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

View 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

View file

@ -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.

View file

@ -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

View file

@ -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"

View file

@ -51,6 +51,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 +62,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 |

View file

@ -6,6 +6,7 @@ alias dib='docker image build'
alias dii='docker image inspect'
alias dils='docker image ls'
alias dipu='docker image push'
alias dipru='docker image prune -a'
alias dirm='docker image rm'
alias dit='docker image tag'
alias dlo='docker container logs'
@ -16,6 +17,8 @@ alias dni='docker network inspect'
alias dnls='docker network ls'
alias dnrm='docker network rm'
alias dpo='docker container port'
alias dps='docker ps'
alias dpsa='docker ps -a'
alias dpu='docker pull'
alias dr='docker container run'
alias drit='docker container run -it'

View file

@ -10,7 +10,7 @@ encodefile64() {
if [[ $# -eq 0 ]]; then
echo "You must provide a filename"
else
base64 -i $1 -o $1.txt
base64 $1 > $1.txt
echo "${1}'s content encoded in base64 and saved as ${1}.txt"
fi
}

View file

@ -80,7 +80,7 @@ EOF
(*.rar) unrar x -ad "$full_path" ;;
(*.rpm)
rpm2cpio "$full_path" | cpio --quiet -id ;;
(*.7z) 7za x "$full_path" ;;
(*.7z | *.7z.[0-9]*) 7za x "$full_path" ;;
(*.deb)
command mkdir -p "control" "data"
ar vx "$full_path" > /dev/null

View file

@ -55,6 +55,16 @@ If `yes` (default), always add `-g` flag to show the group ownership.
Default: `yes`
### `icons`
```zsh
zstyle ':omz:plugins:eza' 'icons' yes|no
```
If `yes`, sets the `--icons` option of `eza`, adding icons for files and folders.
Default: `no`
### `size-prefix`
```zsh
@ -80,6 +90,16 @@ Sets the `--time-style` option of `eza`. (See `man eza` for the options)
Default: Not set, which means the default behavior of `eza` will take place.
### `hyperlink`
```zsh
zstyle ':omz:plugins:eza' 'hyperlink' yes|no
```
If `yes`, always add `--hyperlink` flag to create hyperlink with escape codes.
Default: `no`
## Aliases
**Notes:**

View file

@ -31,10 +31,16 @@ function _configure_eza() {
if zstyle -t ':omz:plugins:eza' 'git-status'; then
_EZA_TAIL+=("--git")
fi
if zstyle -t ':omz:plugins:eza' 'icons'; then
_EZA_TAIL+=("--icons=auto")
fi
zstyle -s ':omz:plugins:eza' 'time-style' _val
if [[ $_val ]]; then
_EZA_TAIL+=("--time-style='$_val'")
fi
if zstyle -t ":omz:plugins:eza" "hyperlink"; then
_EZA_TAIL+=("--hyperlink")
fi
}
_configure_eza

View file

@ -1,9 +0,0 @@
# fd
This plugin adds completion for the file search tool [`fd`](https://github.com/sharkdp/fd), also known as `fd-find`.
To use it, add `fd` to the plugins array in your zshrc file:
```zsh
plugins=(... fd)
```

View file

@ -1,273 +0,0 @@
#compdef fd
##
# zsh completion function for fd
#
# Based on ripgrep completion function.
# Originally based on code from the zsh-users project — see copyright notice
# below.
autoload -U is-at-least
_fd() {
local curcontext="$curcontext" no='!' ret=1
local -a context line state state_descr _arguments_options fd_types fd_args
local -A opt_args
if is-at-least 5.2; then
_arguments_options=( -s -S )
else
_arguments_options=( -s )
fi
fd_types=(
{f,file}'\:"regular files"'
{d,directory}'\:"directories"'
{l,symlink}'\:"symbolic links"'
{e,empty}'\:"empty files or directories"'
{x,executable}'\:"executable (files)"'
{s,socket}'\:"sockets"'
{p,pipe}'\:"named pipes (FIFOs)"'
)
# Do not complete rare options unless either the current prefix
# matches one of those options or the user has the `complete-all`
# style set. Note that this prefix check has to be updated manually to account
# for all of the potential negation options listed below!
if
# (--[bpsu]* => match all options marked with '$no')
[[ $PREFIX$SUFFIX == --[bopsu]* ]] ||
zstyle -t ":complete:$curcontext:*" complete-all
then
no=
fi
# We make heavy use of argument groups here to prevent the option specs from
# growing unwieldy. These aren't supported in zsh <5.4, though, so we'll strip
# them out below if necessary. This makes the exclusions inaccurate on those
# older versions, but oh well — it's not that big a deal
fd_args=(
+ '(hidden)' # hidden files
{-H,--hidden}'[search hidden files/directories]'
+ '(no-ignore-full)' # all ignore files
'(no-ignore-partial)'{-I,--no-ignore}"[don't respect .(git|fd)ignore and global ignore files]"
$no'(no-ignore-partial)*'{-u,--unrestricted}'[alias for --no-ignore, when repeated also alias for --hidden]'
+ no-ignore-partial # some ignore files
"(no-ignore-full --no-ignore-vcs)--no-ignore-vcs[don't respect .gitignore files]"
"!(no-ignore-full --no-global-ignore-file)--no-global-ignore-file[don't respect the global ignore file]"
$no'(no-ignore-full --no-ignore-parent)--no-ignore-parent[]'
+ '(case)' # case-sensitivity
{-s,--case-sensitive}'[perform a case-sensitive search]'
{-i,--ignore-case}'[perform a case-insensitive search]'
+ '(regex-pattern)' # regex-based search pattern
'(no-regex-pattern)--regex[perform a regex-based search (default)]'
+ '(no-regex-pattern)' # non-regex-based search pattern
{-g,--glob}'[perform a glob-based search]'
{-F,--fixed-strings}'[treat pattern as literal string instead of a regex]'
+ '(match-full)' # match against full path
{-p,--full-path}'[match the pattern against the full path instead of the basename]'
+ '(follow)' # follow symlinks
{-L,--follow}'[follow symbolic links to directories]'
+ '(abs-path)' # show absolute paths
'(long-listing)'{-a,--absolute-path}'[show absolute paths instead of relative paths]'
+ '(null-sep)' # use null separator for output
'(long-listing)'{-0,--print0}'[separate search results by the null character]'
+ '(long-listing)' # long-listing output
'(abs-path null-sep max-results exec-cmds)'{-l,--list-details}'[use a long listing format with file metadata]'
+ '(max-results)' # max number of results
'(long-listing exec-cmds)--max-results=[limit number of search results to given count and quit]:count'
'(long-listing exec-cmds)-1[limit to a single search result and quit]'
+ '(fs-errors)' # file-system errors
$no'--show-errors[enable the display of filesystem errors]'
+ '(fs-traversal)' # file-system traversal
$no"--one-file-system[don't descend into directories on other file systems]"
'!--mount'
'!--xdev'
+ dir-depth # directory depth
'(--exact-depth -d --max-depth)'{-d+,--max-depth=}'[set max directory depth to descend when searching]:depth'
'!(--exact-depth -d --max-depth)--maxdepth:depth'
'(--exact-depth --min-depth)--min-depth=[set directory depth to descend before start searching]:depth'
'(--exact-depth -d --max-depth --maxdepth --min-depth)--exact-depth=[only search at the exact given directory depth]:depth'
+ prune # pruning
"--prune[don't traverse into matching directories]"
+ filter-misc # filter search
'*'{-t+,--type=}"[filter search by type]:type:(($fd_types))"
'*'{-e+,--extension=}'[filter search by file extension]:extension'
'*'{-E+,--exclude=}'[exclude files/directories that match the given glob pattern]:glob pattern'
'*'{-S+,--size=}'[limit search by file size]:size limit:->size'
'(-o --owner)'{-o+,--owner=}'[filter by owning user and/or group]:owner and/or group:->owner'
+ ignore-file # extra ignore files
'*--ignore-file=[add a custom, low-precedence ignore-file with .gitignore format]: :_files'
+ '(filter-mtime-newer)' # filter by files modified after than
'--changed-within=[limit search to files/directories modified within the given date/duration]:date or duration'
'!--change-newer-than=:date/duration'
'!--newer=:date/duration'
+ '(filter-mtime-older)' # filter by files modified before than
'--changed-before=[limit search to files/directories modified before the given date/duration]:date or duration'
'!--change-older-than=:date/duration'
'!--older=:date/duration'
+ '(color)' # colorize output
{-c+,--color=}'[declare when to colorize search results]:when to colorize:((
auto\:"show colors if the output goes to an interactive console (default)"
never\:"do not use colorized output"
always\:"always use colorized output"
))'
+ '(threads)'
{-j+,--threads=}'[set the number of threads for searching and executing]:number of threads'
+ '(exec-cmds)' # execute command
'(long-listing max-results)'{-x+,--exec=}'[execute command for each search result]:command: _command_names -e:*\;::program arguments: _normal'
'(long-listing max-results)'{-X+,--exec-batch=}'[execute command for all search results at once]:command: _command_names -e:*\;::program arguments: _normal'
'(long-listing max-results)--batch-size=[max number of args for each -X call]:size'
+ other
'!(--max-buffer-time)--max-buffer-time=[set amount of time to buffer before showing output]:time (ms)'
+ '(about)' # about flags
'(: * -)'{-h,--help}'[display help message]'
'(: * -)'{-v,--version}'[display version information]'
+ path-sep # set path separator for output
$no'(--path-separator)--path-separator=[set the path separator to use when printing file paths]:path separator'
+ search-path
$no'(--base-directory)--base-directory=[change the current working directory to the given path]:directory:_files -/'
$no'(*)*--search-path=[set search path (instead of positional <path> arguments)]:directory:_files -/'
+ strip-cwd-prefix
$no'(strip-cwd-prefix exec-cmds)--strip-cwd-prefix[Strip ./ prefix when output is redirected]'
+ args # positional arguments
'1: :_guard "^-*" pattern'
'(--search-path)*:directory:_files -/'
)
# Strip out argument groups where unsupported (see above)
is-at-least 5.4 ||
fd_args=( ${(@)args:#(#i)(+|[a-z0-9][a-z0-9_-]#|\([a-z0-9][a-z0-9_-]#\))} )
_arguments $_arguments_options : $fd_args && ret=0
case ${state} in
owner)
compset -P '(\\|)\!'
if compset -P '*:'; then
_groups && ret=0
else
if
compset -S ':*' ||
# Do not add the colon suffix when completing "!user<TAB>
# (with a starting double-quote) otherwise pressing tab again
# after the inserted colon "!user:<TAB> will complete history modifiers
[[ $IPREFIX == (\\|\!)* && ($QIPREFIX == \"* && -z $QISUFFIX) ]]
then
_users && ret=0
else
local q
# Since quotes are needed when using the negation prefix !,
# automatically remove the colon suffix also when closing the quote
if [[ $QIPREFIX == [\'\"]* ]]; then
q=${QIPREFIX:0:1}
fi
_users -r ": \t\n\-$q" -S : && ret=0
fi
fi
;;
size)
if compset -P '[-+][0-9]##'; then
local -a suff=(
'B:bytes'
'K:kilobytes (10^3 = 1000 bytes)'
'M:megabytes (10^6 = 1000^2 bytes)'
'G:gigabytes (10^9 = 1000^3 bytes)'
'T:terabytes (10^12 = 1000^4 bytes)'
'Ki:kibibytes ( 2^10 = 1024 bytes)'
'Mi:mebibytes ( 2^20 = 1024^2 bytes)'
'Gi:gigibytes ( 2^30 = 1024^3 bytes)'
'Ti:tebibytes ( 2^40 = 1024^4 bytes)'
)
_describe -t units 'size limit units' suff -V 'units'
elif compset -P '[-+]'; then
_message -e 'size limit number (full format: <+-><number><unit>)'
else
_values 'size limit prefix (full format: <prefix><number><unit>)' \
'\+[file size must be greater or equal to]'\
'-[file size must be less than or equal to]' && ret=0
fi
;;
esac
return ret
}
_fd "$@"
# ------------------------------------------------------------------------------
# Copyright (c) 2011 GitHub zsh-users - http://github.com/zsh-users
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# * Neither the name of the zsh-users nor the
# names of its contributors may be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL ZSH-USERS BE LIABLE FOR ANY
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# ------------------------------------------------------------------------------
# Description
# -----------
#
# Completion script for fd
#
# ------------------------------------------------------------------------------
# Authors
# -------
#
# * smancill (https://github.com/smancill)
#
# ------------------------------------------------------------------------------
# Local Variables:
# mode: shell-script
# coding: utf-8-unix
# indent-tabs-mode: nil
# sh-indentation: 2
# sh-basic-offset: 2
# End:
# vim: ft=zsh sw=2 ts=2 et

View file

@ -2,6 +2,7 @@
# Author: Adam Strzelecki nanoant.com, modified by Bodo Tasche bitboxer.de
# Updated to support ForkLift 2 and ForkLift 3 by Johan Kaving
# Updated to support ForkLift from Setapp by Paul Rudkin
# Updated to support ForkLift 4 by Michal Szymanski (misiektoja)
#
# Usage:
# fl [<folder>]
@ -110,6 +111,11 @@ function fl {
tell pop over of list of group of splitter group of splitter group of topWindow
set value of text field 1 to "$PWD"
end tell
else if forkLiftVersion starts with "4" then
tell pop over of list of group of splitter group of splitter group of topWindow
keystroke "$PWD"
delay 0.1
end tell
else
tell sheet 1 of topWindow
set value of text field 1 to "$PWD"

View file

@ -4,6 +4,8 @@ function fzf_setup_using_fzf() {
# we remove "fzf " prefix, this fixes really old fzf versions behaviour
# see https://github.com/ohmyzsh/ohmyzsh/issues/12387
local fzf_ver=${"$(fzf --version)"#fzf }
autoload -Uz is-at-least
is-at-least 0.48.0 ${${(s: :)fzf_ver}[1]} || return 1
eval "$(fzf --zsh)"
@ -146,6 +148,27 @@ function fzf_setup_using_opensuse() {
return 0
}
function fzf_setup_using_fedora() {
(( $+commands[fzf] )) || return 1
local completions="/usr/share/zsh/site-functions/fzf"
local key_bindings="/usr/share/fzf/shell/key-bindings.zsh"
if [[ ! -f "$completions" || ! -f "$key_bindings" ]]; then
return 1
fi
if [[ -o interactive && "$DISABLE_FZF_AUTO_COMPLETION" != "true" ]]; then
source "$completions" 2>/dev/null
fi
if [[ "$DISABLE_FZF_KEY_BINDINGS" != "true" ]]; then
source "$key_bindings" 2>/dev/null
fi
return 0
}
function fzf_setup_using_openbsd() {
# openBSD installs fzf in /usr/local/bin/fzf
if [[ "$OSTYPE" != openbsd* ]] || (( ! $+commands[fzf] )); then
@ -232,6 +255,7 @@ fzf_setup_using_fzf \
|| fzf_setup_using_openbsd \
|| fzf_setup_using_debian \
|| fzf_setup_using_opensuse \
|| fzf_setup_using_fedora \
|| fzf_setup_using_cygwin \
|| fzf_setup_using_macports \
|| fzf_setup_using_base_dir \

View file

@ -4,4 +4,29 @@ alias gemp="gem push *.gem"
# gemy GEM 0.0.0 = gem yank GEM -v 0.0.0
function gemy {
gem yank $1 -v $2
}
}
# If the completion file doesn't exist yet, we need to autoload it and
# bind it to `gem`. Otherwise, compinit will have already done that.
if [[ ! -f "$ZSH_CACHE_DIR/completions/_gem" ]]; then
typeset -g -A _comps
autoload -Uz _gem
_comps[docker]=_gem
fi
# zsh 5.5 already provides completion for `_gem`. With this we ensure that
# our provided completion (which is not optimal but is enough in most cases)
# is used for older versions
autoload -Uz is-at-least
if is-at-least 5.5; then
return 0
fi
{
# Standarized $0 handling
# https://zdharma-continuum.github.io/Zsh-100-Commits-Club/Zsh-Plugin-Standard.html
0="${${ZERO:-${0:#$ZSH_ARGZERO}}:-${(%):-%N}}"
0="${${(M)0:#/*}:-$PWD/$0}"
command cp -f "${0:h}/completions/_gem" "$ZSH_CACHE_DIR/completions/_gem"
} &|

View file

@ -41,8 +41,8 @@ plugins=(... git)
| `gba` | `git branch --all` |
| `gbd` | `git branch --delete` |
| `gbD` | `git branch --delete --force` |
| `gbgd` | `LANG=C git branch --no-color -vv \| grep ": gone\]" \| awk '"'"'{print $1}'"'"' \| xargs git branch -d` |
| `gbgD` | `LANG=C git branch --no-color -vv \| grep ": gone\]" \| awk '"'"'{print $1}'"'"' \| xargs git branch -D` |
| `gbgd` | `LANG=C git branch --no-color -vv \| grep ": gone\]" \| cut -c 3- \| awk '"'"'{print $1}'"'"' \| xargs git branch -d` |
| `gbgD` | `LANG=C git branch --no-color -vv \| grep ": gone\]" \| cut -c 3- \| awk '"'"'{print $1}'"'"' \| xargs git branch -D` |
| `gbm` | `git branch --move` |
| `gbnm` | `git branch --no-merged` |
| `gbr` | `git branch --remote` |
@ -59,6 +59,7 @@ plugins=(... git)
| `gcpc` | `git cherry-pick --continue` |
| `gclean` | `git clean --interactive -d` |
| `gcl` | `git clone --recurse-submodules` |
| `gclf` | `git clone --recursive --shallow-submodules --filter=blob:none --also-filter-submodules` |
| `gccd` | `git clone --recurse-submodules "$@" && cd "$(basename $\_ .git)"` |
| `gcam` | `git commit --all --message` |
| `gcas` | `git commit --all --signoff` |
@ -88,7 +89,7 @@ plugins=(... git)
| `gdnolock` | `git diff $@ ":(exclude)package-lock.json" ":(exclude)\*.lock"` |
| `gdt` | `git diff-tree --no-commit-id --name-only -r` |
| `gf` | `git fetch` |
| `gfa` | `git fetch --all --prune` |
| `gfa` | `git fetch --all --tags --prune` |
| `gfo` | `git fetch origin` |
| `gg` | `git gui citool` |
| `gga` | `git gui citool --amend` |
@ -111,7 +112,7 @@ plugins=(... git)
| `gfg` | `git ls-files \| grep` |
| `gm` | `git merge` |
| `gma` | `git merge --abort` |
| `gmc` | `git merge --continue` |
| `gmc` | `git merge --continue` |
| `gms` | `git merge --squash` |
| `gmom` | `git merge origin/$(git_main_branch)` |
| `gmum` | `git merge upstream/$(git_main_branch)` |

View file

@ -35,7 +35,7 @@ function git_develop_branch() {
function git_main_branch() {
command git rev-parse --git-dir &>/dev/null || return
local ref
for ref in refs/{heads,remotes/{origin,upstream}}/{main,trunk,mainline,default,master}; do
for ref in refs/{heads,remotes/{origin,upstream}}/{main,trunk,mainline,default,stable,master}; do
if command git show-ref -q --verify $ref; then
echo ${ref:t}
return 0
@ -147,8 +147,8 @@ function gbds() {
done
}
alias gbgd='LANG=C git branch --no-color -vv | grep ": gone\]" | awk '"'"'{print $1}'"'"' | xargs git branch -d'
alias gbgD='LANG=C git branch --no-color -vv | grep ": gone\]" | awk '"'"'{print $1}'"'"' | xargs git branch -D'
alias gbgd='LANG=C git branch --no-color -vv | grep ": gone\]" | cut -c 3- | awk '"'"'{print $1}'"'"' | xargs git branch -d'
alias gbgD='LANG=C git branch --no-color -vv | grep ": gone\]" | cut -c 3- | awk '"'"'{print $1}'"'"' | xargs git branch -D'
alias gbm='git branch --move'
alias gbnm='git branch --no-merged'
alias gbr='git branch --remote'
@ -165,6 +165,7 @@ alias gcpa='git cherry-pick --abort'
alias gcpc='git cherry-pick --continue'
alias gclean='git clean --interactive -d'
alias gcl='git clone --recurse-submodules'
alias gclf='git clone --recursive --shallow-submodules --filter=blob:none --also-filter-submodules'
function gccd() {
setopt localoptions extendedglob
@ -219,8 +220,8 @@ alias gdt='git diff-tree --no-commit-id --name-only -r'
alias gf='git fetch'
# --jobs=<n> was added in git 2.8
is-at-least 2.8 "$git_version" \
&& alias gfa='git fetch --all --prune --jobs=10' \
|| alias gfa='git fetch --all --prune'
&& alias gfa='git fetch --all --tags --prune --jobs=10' \
|| alias gfa='git fetch --all --tags --prune'
alias gfo='git fetch origin'
alias gg='git gui citool'
alias gga='git gui citool --amend'

View file

@ -25,6 +25,7 @@ plugins=(... golang)
| goi | `go install` | Compiles and installs packages to $GOPATH |
| gol | `go list` | Lists Go packages |
| gom | `go mod` | Access to operations on modules |
| gomt | `go mod tidy` | Tidies up the go.mod file |
| gopa | `cd $GOPATH` | Takes you to `$GOPATH` |
| gopb | `cd $GOPATH/bin` | Takes you to `$GOPATH/bin` |
| gops | `cd $GOPATH/src` | Takes you to `$GOPATH/src` |

View file

@ -22,6 +22,7 @@ alias goga='go get ./...'
alias goi='go install'
alias gol='go list'
alias gom='go mod'
alias gomt='go mod tidy'
alias gopa='cd $GOPATH'
alias gopb='cd $GOPATH/bin'
alias gops='cd $GOPATH/src'

View file

@ -57,13 +57,13 @@ Using [antigen](https://github.com/zsh-users/antigen):
1. Add the `antigen bundle` command just before `antigen apply`, like this:
```
```
antigen bundle zsh-users/zsh-history-substring-search
antigen apply
```
2. Then, **after** `antigen apply`, add the key binding configurations, like this:
```
# zsh-history-substring-search configuration
bindkey '^[[A' history-substring-search-up # or '\eOA'
@ -120,7 +120,7 @@ Usage
bindkey "$terminfo[kcuu1]" history-substring-search-up
bindkey "$terminfo[kcud1]" history-substring-search-down
Users have also observed that `[OA` and `[OB` are correct values,
Users have also observed that `[OA` and `[OB` are correct values,
_even if_ these were not the observed values. If you are having trouble
with the observed values, give these a try.

View file

@ -16,4 +16,3 @@ if [[ -n "$terminfo[kcud1]" ]]; then
bindkey -M emacs "$terminfo[kcud1]" history-substring-search-down
bindkey -M viins "$terminfo[kcud1]" history-substring-search-down
fi

View file

@ -406,7 +406,7 @@ _history-substring-search-end() {
# For debugging purposes:
# zle -R "mn: "$_history_substring_search_match_index" m#: "${#_history_substring_search_matches}
# read -k -t 200 && zle -U $REPLY
# read -k -t 200 && zle -U -- "$REPLY"
#
# When this function returns, z-sy-h runs its line-pre-redraw hook. It has no
@ -421,7 +421,7 @@ _history-substring-search-end() {
# before removing search highlight and exiting. This ensures no highlights
# are left lingering after search is finished.
#
read -k -t ${HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_TIMEOUT:-1} && zle -U $REPLY
read -k -t ${HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_TIMEOUT:-1} && zle -U -- "$REPLY"
region_highlight=( "${(@)region_highlight:#*${highlight_memo}*}" )
fi

23
plugins/kitty/README.md Normal file
View file

@ -0,0 +1,23 @@
# Kitty plugin
This plugin adds a few aliases and functions that are useful for users of the [Kitty](https://sw.kovidgoyal.net/kitty/) terminal.
To use it, add _kitty_ to the plugins array of your zshrc file:
```
plugins=(... kitty)
```
## Plugin commands
* `kssh`
Runs a kitten ssh session that ensures your terminfo settings are copied
correctly to the remote hose.
* `kssh-slow`
A slower form of `kssh` that should always work. Use this if `kssh` fails
to set terminfo correctly for you on the remote host.
* `kitty-theme`
Browse and change the theme of your Kitty terminal.
## Contributors
- [Ian Chesal](https://github.com/ianchesal)

View file

@ -0,0 +1,16 @@
#####################################################
# Kitty plugin for oh-my-zsh #
#####################################################
if [[ "$TERM" == 'xterm-kitty' ]]; then
## kssh
# Use this when your terminfo isn't recognized on remote hosts.
# See: https://sw.kovidgoyal.net/kitty/faq/#i-get-errors-about-the-terminal-being-unknown-or-opening-the-terminal-failing-when-sshing-into-a-different-computer
alias kssh="kitty +kitten ssh"
compdef kssh='ssh'
# Use this if kssh fails
alias kssh-slow="infocmp -a xterm-kitty | ssh myserver tic -x -o \~/.terminfo /dev/stdin"
# Change the colour theme
alias kitty-theme="kitty +kitten themes"
fi

View file

@ -180,13 +180,23 @@ alias kej='kubectl edit job'
alias kdj='kubectl describe job'
alias kdelj='kubectl delete job'
# Only run if the user actually has kubectl installed
if (( ${+_comps[kubectl]} )); then
function kj() { kubectl "$@" -o json | jq; }
function kjx() { kubectl "$@" -o json | fx; }
function ky() { kubectl "$@" -o yaml | yh; }
# Utility print functions (json / yaml)
function _build_kubectl_out_alias {
setopt localoptions norcexpandparam
compdef kj=kubectl
compdef kjx=kubectl
compdef ky=kubectl
fi
# alias function
eval "function $1 { $2 }"
# completion function
eval "function _$1 {
words=(kubectl \"\${words[@]:1}\")
_kubectl
}"
compdef _$1 $1
}
_build_kubectl_out_alias "kj" 'kubectl "$@" -o json | jq'
_build_kubectl_out_alias "kjx" 'kubectl "$@" -o json | fx'
_build_kubectl_out_alias "ky" 'kubectl "$@" -o yaml | yh'
unfunction _build_kubectl_out_alias

View file

@ -1,25 +1,55 @@
# kubectx - show active kubectl context
This plugins adds ```kubectx_prompt_info()``` function. It shows name of the
active kubectl context (```kubectl config current-context```).
This plugins adds `kubectx_prompt_info()` function. It shows name of the active
kubectl context (`kubectl config current-context`).
You can use it to customize prompt and know if You are on prod cluster ;)
_Example_. Add to **.zshrc**:
To use this plugin, add `kubectx` to the plugins array in your zshrc file:
```zsh
plugins=(... kubectx)
```
### Usage
Add to **.zshrc**:
```zsh
# right prompt
RPS1='$(kubectx_prompt_info)'
# left prompt
PROMPT="$PROMPT"'$(kubectx_prompt_info)'
```
### custom ctx names
### Custom context names
One can rename default context name for better readability.
You can rename the default context name for better readability or additional formatting.
These values accept [prompt expansion sequences](http://zsh.sourceforge.net/Doc/Release/Prompt-Expansion.html)
such as `%F{color}`, `%f`, `%K{color}`, `%k`, `%B`, `%b`, `%U`, `%u`, `%S`, `%s`, `%{...%}`.
_Example_. Add to **.zshrc**:
**Example**: add this to your .zshrc file:
```zsh
kubectx_mapping[minikube]="mini"
kubectx_mapping[context_name_from_kubeconfig]="$emoji[wolf_face]"
kubectx_mapping[production_cluster]="%{$fg[yellow]%}prod!%{$reset_color%}"
# contexts with spaces
kubectx_mapping[context\ with\ spaces]="%F{red}spaces%f"
# don't use quotes as it will break the prompt
kubectx_mapping["context with spaces"]="%F{red}spaces%f" # ti
```
kubectx_mapping["minikube"]="mini"
kubectx_mapping["context_name_from_kubeconfig"]="$emoji[wolf_face]"
kubectx_mapping["production_cluster"]="%{$fg[yellow]%}prod!%{$reset_color%}"
You can also define the whole mapping array at once:
```zsh
typeset -A kubectx_mapping
kubectx_mapping=(
minikube "mini"
context_name_from_kubeconfig "$emoji[wolf_face]"
production_cluster "%{$fg[yellow]%}prod!%{$reset_color%}"
"context with spaces" "%F{red}spaces%f"
)
```
![staging](stage.png)

View file

@ -7,7 +7,9 @@ function kubectx_prompt_info() {
[[ -n "$current_ctx" ]] || return
# use value in associative array if it exists
# otherwise fall back to the context name
echo "${kubectx_mapping[\"$current_ctx\"]:-${current_ctx:gs/%/%%}}"
# Use value in associative array if it exists, otherwise fall back to the context name
#
# Note: we need to escape the % character in the prompt string when coming directly from
# the context name, as it could contain a % character.
echo "${kubectx_mapping[$current_ctx]:-${current_ctx:gs/%/%%}}"
}

View file

@ -36,6 +36,10 @@ plugins=(... laravel)
| `pamj` | `php artisan make:job` |
| `paml` | `php artisan make:listener` |
| `pamn` | `php artisan make:notification` |
| `pamcl` | `php artisan make:class` |
| `pamen` | `php artisan make:enum` |
| `pami` | `php artisan make:interface` |
| `pamtr` | `php artisan make:trait` |
## Clears

View file

@ -25,6 +25,10 @@ alias pamj='php artisan make:job'
alias paml='php artisan make:listener'
alias pamn='php artisan make:notification'
alias pampp='php artisan make:provider'
alias pamcl='php artisan make:class'
alias pamen='php artisan make:enum'
alias pami='php artisan make:interface'
alias pamtr='php artisan make:trait'
# Clears

View file

@ -8,7 +8,11 @@ To start using it, add the `macos` plugin to your plugins array in `~/.zshrc`:
plugins=(... macos)
```
Original author: [Sorin Ionescu](https://github.com/sorin-ionescu)
## Supported Terminals
- [iTerm](https://iterm.sourceforge.net/)
- [iTerm2](https://iterm2.com/)
- [Hyper](https://hyper.is/)
- [Tabby](https://tabby.sh/)
## Commands
@ -37,7 +41,9 @@ Original author: [Sorin Ionescu](https://github.com/sorin-ionescu)
## Acknowledgements
This application makes use of the following third party scripts:
Original author: [Sorin Ionescu](https://github.com/sorin-ionescu)
This application makes use of the following third-party scripts:
[shpotify](https://github.com/hnarayanan/shpotify)

View file

@ -79,6 +79,13 @@ EOF
key code 36 #(presses enter)
end tell
EOF
elif [[ "$the_app" == 'Tabby' ]]; then
osascript >/dev/null <<EOF
tell application "System Events"
tell process "Tabby" to keystroke "t" using command down
end tell
EOF
else
echo "$0: unsupported terminal app: $the_app" >&2
return 1
@ -126,6 +133,12 @@ EOF
delay 1
keystroke "${command} \n"
end tell
EOF
elif [[ "$the_app" == 'Tabby' ]]; then
osascript >/dev/null <<EOF
tell application "System Events"
tell process "Tabby" to keystroke "D" using command down
end tell
EOF
else
echo "$0: unsupported terminal app: $the_app" >&2
@ -175,6 +188,12 @@ EOF
delay 1
keystroke "${command} \n"
end tell
EOF
elif [[ "$the_app" == 'Tabby' ]]; then
osascript >/dev/null <<EOF
tell application "System Events"
tell process "Tabby" to keystroke "d" using command down
end tell
EOF
else
echo "$0: unsupported terminal app: $the_app" >&2

View file

@ -24,3 +24,4 @@ fi
# Generate and load mise completion
$__mise completion zsh >| "$ZSH_CACHE_DIR/completions/_$__mise" &|
unset __mise

View file

@ -26,9 +26,9 @@ These settings should go in your zshrc file, before Oh My Zsh is sourced:
#### Lazy startup
This option will help you to defer nvm's load until you use it to speed-up your zsh startup. This will source
nvm script only when using it, and will create a function for `node`, `npm`, `npx`, `pnpm`, `yarn`, and the
command(s) specified by `lazy-cmd` option, so when you call either of them, nvm will be loaded and run with
default version. To enable it, you can add this snippet to your zshrc, before Oh My Zsh is sourced:
nvm script only when using it, and will create a function for `node`, `npm`, `npx`, `pnpm`, `yarn`, `corepack`
and the command(s) specified by `lazy-cmd` option, so when you call either of them, nvm will be loaded and run
with default version. To enable it, you can add this snippet to your zshrc, before Oh My Zsh is sourced:
```zsh
zstyle ':omz:plugins:nvm' lazy yes

View file

@ -50,11 +50,11 @@ function _omz_setup_autoload {
zstyle -t ':omz:plugins:nvm' silent-autoload && nvm_silent="--silent"
if [[ -n "$nvmrc_path" ]]; then
local nvmrc_node_version=$(nvm version $(cat "$nvmrc_path" | tr -dc '[:print:]'))
local nvmrc_node_version=$(nvm version $(command cat "$nvmrc_path" | tr -dc '[:print:]'))
if [[ "$nvmrc_node_version" = "N/A" ]]; then
nvm install
elif [[ "$nvmrc_node_version" != "$node_version" ]]; then
elif [[ "$nvmrc_node_version" != "$(nvm version)" ]]; then
nvm use $nvm_silent
fi
elif [[ -n "$(PWD=$OLDPWD nvm_find_nvmrc)" ]] && [[ "$(nvm version)" != "$(nvm version default)" ]]; then
@ -72,9 +72,9 @@ function _omz_setup_autoload {
}
if zstyle -t ':omz:plugins:nvm' lazy; then
# Call nvm when first using nvm, node, npm, pnpm, yarn or other commands in lazy-cmd
# Call nvm when first using nvm, node, npm, pnpm, yarn, corepack or other commands in lazy-cmd
zstyle -a ':omz:plugins:nvm' lazy-cmd nvm_lazy_cmd
nvm_lazy_cmd=(nvm node npm npx pnpm yarn $nvm_lazy_cmd) # default values
nvm_lazy_cmd=(nvm node npm npx pnpm yarn corepack $nvm_lazy_cmd) # default values
eval "
function $nvm_lazy_cmd {
for func in $nvm_lazy_cmd; do

View file

@ -0,0 +1,58 @@
# OpenTofu plugin
Plugin for OpenTofu, a fork of Terraform that is open-source, community-driven, and managed by the Linux Foundation. It adds
completion for `tofu` command, as well as aliases and a prompt function.
To use it, add `opentofu` to the plugins array of your `~/.zshrc` file:
```shell
plugins=(... opentofu)
```
## Requirements
- [OpenTofu](https://opentofu.org/)
## Aliases
| Alias | Command |
| ----- | --------------- |
| `tt` | `tofu` |
| `tta` | `tofu apply` |
| `ttc` | `tofu console` |
| `ttd` | `tofu destroy` |
| `ttf` | `tofu fmt` |
| `tti` | `tofu init` |
| `tto` | `tofu output` |
| `ttp` | `tofu plan` |
| `ttv` | `tofu validate` |
| `tts` | `tofu state` |
| `ttsh`| `tofu show` |
| `ttr` | `tofu refresh` |
| `ttt` | `tofu test` |
| `ttws`| `tofu workspace`|
## Prompt functions
- `tofu_prompt_info`: shows the current workspace when in an OpenTofu project directory.
- `tofu_version_prompt_info`: shows the current version of the `tofu` commmand.
To use them, add them to a `PROMPT` variable in your theme or `.zshrc` file:
```sh
PROMPT='$(tofu_prompt_info)'
RPROMPT='$(tofu_version_prompt_info)'
```
You can also specify the PREFIX and SUFFIX strings for both functions, with the following variables:
```sh
# for tofu_prompt_info
ZSH_THEME_TOFU_PROMPT_PREFIX="%{$fg[white]%}"
ZSH_THEME_TOFU_PROMPT_SUFFIX="%{$reset_color%}"
# for tofu_version_prompt_info
ZSH_THEME_TOFU_VERSION_PROMPT_PREFIX="%{$fg[white]%}"
ZSH_THEME_TOFU_VERSION_PROMPT_SUFFIX="%{$reset_color%}"
```

View file

@ -0,0 +1,43 @@
# set up the tofu completion (compatible for zsh)
autoload -Uz bashcompinit && bashcompinit
complete -C tofu tofu
# tofu workspace prompt function
function tofu_prompt_info() {
# only show the workspace name if we're in an opentofu project
# i.e. if a .terraform directory exists within the hierarchy
local dir="$PWD"
while [[ ! -d "${dir}/.terraform" ]]; do
[[ "$dir" != / ]] || return 0 # stop at the root directory
dir="${dir:h}" # get the parent directory
done
# workspace might be different than the .terraform/environment file
# for example, if set with the TF_WORKSPACE environment variable
local workspace="$(tofu workspace show)"
# make sure to escape % signs in the workspace name to prevent command injection
echo "${ZSH_THEME_TOFU_PROMPT_PREFIX-[}${workspace:gs/%/%%}${ZSH_THEME_TOFU_PROMPT_SUFFIX-]}"
}
# tofu version prompt function
function tofu_version_prompt_info() {
# get the output of `tofu --version` in a single line, and get the second word after splitting by a space
local tofu_version=${${(s: :)$(tofu --version)}[2]}
# make sure to escape % signs in the version string to prevent command injection
echo "${ZSH_THEME_TOFU_VERSION_PROMPT_PREFIX-[}${tofu_version:gs/%/%%}${ZSH_THEME_TOFU_VERSION_PROMPT_SUFFIX-]}"
}
alias tt='tofu'
alias tta='tofu apply'
alias ttc='tofu console'
alias ttd='tofu destroy'
alias ttf='tofu fmt'
alias tti='tofu init'
alias tto='tofu output'
alias ttp='tofu plan'
alias ttv='tofu validate'
alias tts='tofu state'
alias ttsh='tofu show'
alias ttr='tofu refresh'
alias ttt='tofu test'
alias ttws='tofu workspace'

View file

@ -20,6 +20,8 @@
_pass () {
local cmd
local rootcontext
rootcontext=$curcontext
if (( CURRENT > 2)); then
cmd=${words[2]}
# Set the context for the subcommand.
@ -123,8 +125,9 @@ _pass_cmd_show () {
_pass_complete_entries_helper () {
local IFS=$'\n'
local prefix
zstyle -s ":completion:${curcontext}:" prefix prefix || prefix="${PASSWORD_STORE_DIR:-$HOME/.password-store}"
_values -C 'passwords' ${$(find -L "$prefix" \( -name .git -o -name .gpg-id \) -prune -o $@ -print 2>/dev/null | sed -e "s#${prefix}/\{0,1\}##" -e 's#\.gpg##' -e 's#\\#\\\\#g' -e 's#:#\\:#g' | sort):-""}
zstyle -s ":completion:${rootcontext}:" prefix prefix ||
prefix="${PASSWORD_STORE_DIR:-$HOME/.password-store}"
_values -C 'passwords' ${$(find -L "$prefix" \( -name .git -o -name .gpg-id \) -prune -o $@ -print 2>/dev/null | sed -e "s#${prefix}/\{0,1\}##" -e 's#\.gpg##' -e 's#\\#\\\\#g' -e 's#:#\\:#g' | sort):-""}
}
_pass_complete_entries_with_subdirs () {

View file

@ -7,3 +7,36 @@ To use it, add `poetry` to the plugins array in your zshrc file:
```zsh
plugins=(... poetry)
```
## Aliases
| Alias | Command | Description
|:----- |--------------------------------------------------- |:--------------------------------------------------------------------------------------- |
| pad | `poetry add` | Add packages to `pyproject.toml` and install them |
| pbld | `poetry build` | Build the source and wheels archives |
| pch | `poetry check` | Validate the content of the `pyproject.toml` and its consistency with the `poetry.lock` |
| pcmd | `poetry list` | Display all the available Poetry commands |
| pconf | `poetry config --list` | Allow you to edit poetry config settings and repositories |
| pexp | `poetry export --without-hashes > requirements.txt | Export the lock file to `requirements.txt` |
| pin | `poetry init` | Create a `pyproject.toml` interactively |
| pinst | `poetry install` | Read the `pyproject.toml`, resolve the dependencies, and install them |
| plck | `poetry lock` | Lock the dependencies in `pyproject.toml` without installing |
| pnew | `poetry new` | Create a directory structure suitable for most Python projects |
| ppath | `poetry env info --path` | Get the path of the currently activated virtualenv` |
| pplug | `poetry self show plugins` | List all the installed Poetry plugins |
| ppub | `poetry publish` | Publish the builded (`poetry build` command) package to the remote repository |
| prm | `poetry remove` | Remove packages from `pyproject.toml` and uninstall them |
| prun | `poetry run` | Executes the given command inside the projects virtualenv |
| psad | `poetry self add` | Add the Poetry plugin and install dependencies to make it work |
| psh | `poetry shell` | Spawns a shell within the virtual environment. If one doesnt exist, it will be created |
| pshw | `poetry show` | List all the available dependencies |
| pslt | `poetry show --latest` | List lastest version of the dependencies |
| psup | `poetry self update` | Update Poetry to the latest version (default) or to the specified version |
| psync | `poetry install --sync` | Synchronize your environment with the `poetry.lock` |
| ptree | `poetry show --tree` | List the dependencies as tree |
| pup | `poetry update` | Get the latest versions of the dependencies and to update the `poetry.lock` |
| pvinf | `poetry env info` | Get basic information about the currently activated virtualenv |
| pvoff | `poetry config virtualenvs.create false` | Disable automatic virtualenv creation |
| pvrm | `poetry env remove` | Delete existing virtualenvs |
| pvrma | `poetry env remove --all` | Delete all existing virtualenvs |
| pvu | `poetry env use` | Switch between existing virtualenvs |

View file

@ -1,3 +1,31 @@
alias pad='poetry add'
alias pbld='poetry build'
alias pch='poetry check'
alias pcmd='poetry list'
alias pconf='poetry config --list'
alias pexp='poetry export --without-hashes > requirements.txt'
alias pin='poetry init'
alias pinst='poetry install'
alias plck='poetry lock'
alias pnew='poetry new'
alias ppath='poetry env info --path'
alias pplug='poetry self show plugins'
alias ppub='poetry publish'
alias prm='poetry remove'
alias prun='poetry run'
alias psad='poetry self add'
alias psh='poetry shell'
alias pshw='poetry show'
alias pslt='poetry show --latest'
alias psup='poetry self update'
alias psync='poetry install --sync'
alias ptree='poetry show --tree'
alias pup='poetry update'
alias pvinf='poetry env info'
alias pvoff='poetry config virtualenvs.create false'
alias pvrm='poetry env remove'
alias pvu='poetry env use'
# Return immediately if poetry is not found
if (( ! $+commands[poetry] )); then
return

9
plugins/procs/README.md Normal file
View file

@ -0,0 +1,9 @@
# procs
This plugin provides completion for [procs](https://github.com/dalance/procs).
To use it, add `procs` to the plugins array in your zshrc file.
```
plugins=(... procs)
```

View file

@ -0,0 +1,13 @@
if (( ! $+commands[procs] )); then
return
fi
# If the completion file doesn't exist yet, we need to autoload it and
# bind it to `minikube`. Otherwise, compinit will have already done that.
if [[ ! -f "$ZSH_CACHE_DIR/completions/_procs" ]]; then
typeset -g -A _comps
autoload -Uz _procs
_comps[procs]=_procs
fi
procs --gen-completion-out zsh >| "$ZSH_CACHE_DIR/completions/_procs" &|

View file

@ -2,7 +2,7 @@
This plugin looks for [pyenv](https://github.com/pyenv/pyenv), a Simple Python version
management system, and loads it if it's found. It also loads pyenv-virtualenv, a pyenv
plugin to manage virtualenv, if it's found.
plugin to manage virtualenv, if it's found. If a venv is found pyenv won't load.
To use it, add `pyenv` to the plugins array in your zshrc file:

View file

@ -1,3 +1,7 @@
# if there is a virtualenv already loaded pyenv should not be loaded
# see https://github.com/ohmyzsh/ohmyzsh/issues/12589
[[ -n ${VIRTUAL_ENV:-} ]] && return
pyenv_config_warning() {
[[ "$ZSH_PYENV_QUIET" != true ]] || return 0

View file

@ -32,8 +32,9 @@ virtual environments:
`venv`) in the current directory.
- `auto_vrun`: Automatically activate the venv virtual environment when entering a directory containing
`<venv-name>/bin/activate`, and automatically deactivate it when navigating out of it (including
subdirectories!).
`<venv-name>/bin/activate`, and automatically deactivate it when navigating out of it (keeps venv activated
in subdirectories).
- To enable the feature, set `export PYTHON_AUTO_VRUN=true` before sourcing oh-my-zsh.
- The default virtual environment name is `venv`. To use a different name, set
- Plugin activates first virtual environment in lexicographic order whose name begins with `<venv-name>`.
The default virtual environment name is `venv`. To use a different name, set
`export PYTHON_VENV_NAME=<venv-name>`. For example: `export PYTHON_VENV_NAME=".venv"`

View file

@ -44,7 +44,7 @@ function pyuserpaths() {
alias pygrep='grep -nr --include="*.py"'
# Run proper IPython regarding current virtualenv (if any)
alias ipython='python3 -c "import IPython, sys; sys.exit(IPython.start_ipython())"'
alias ipython='python3 -c "import sys; del sys.path[0]; import IPython; sys.exit(IPython.start_ipython())"'
# Share local directory as a HTTP server
alias pyserver="python3 -m http.server"
@ -86,11 +86,20 @@ function mkv() {
if [[ "$PYTHON_AUTO_VRUN" == "true" ]]; then
# Automatically activate venv when changing dir
auto_vrun() {
if [[ -f "${PYTHON_VENV_NAME}/bin/activate" ]]; then
source "${PYTHON_VENV_NAME}/bin/activate" > /dev/null 2>&1
else
(( $+functions[deactivate] )) && deactivate > /dev/null 2>&1
function auto_vrun() {
# deactivate if we're on a different dir than VIRTUAL_ENV states
# we don't deactivate subdirectories!
if (( $+functions[deactivate] )) && [[ $PWD != ${VIRTUAL_ENV:h}* ]]; then
deactivate > /dev/null 2>&1
fi
if [[ $PWD != ${VIRTUAL_ENV:h} ]]; then
for _file in "${PYTHON_VENV_NAME}"*/bin/activate(N.); do
# make sure we're not in a venv already
(( $+functions[deactivate] )) && deactivate > /dev/null 2>&1
source $_file > /dev/null 2>&1
break
done
fi
}
add-zsh-hook chpwd auto_vrun

View file

@ -1,9 +0,0 @@
# ripgrep
This plugin adds completion for the text search tool [`ripgrep`](https://github.com/BurntSushi/ripgrep), also known as `rg`.
To use it, add `ripgrep` to the plugins array in your zshrc file:
```zsh
plugins=(... ripgrep)
```

View file

@ -1,640 +0,0 @@
#compdef rg
##
# zsh completion function for ripgrep
#
# Run ci/test-complete after building to ensure that the options supported by
# this function stay in synch with the `rg` binary.
#
# For convenience, a completion reference guide is included at the bottom of
# this file.
#
# Originally based on code from the zsh-users project — see copyright notice
# below.
_rg() {
local curcontext=$curcontext no='!' descr ret=1
local -a context line state state_descr args tmp suf
local -A opt_args
# ripgrep has many options which negate the effect of a more common one — for
# example, `--no-column` to negate `--column`, and `--messages` to negate
# `--no-messages`. There are so many of these, and they're so infrequently
# used, that some users will probably find it irritating if they're completed
# indiscriminately, so let's not do that unless either the current prefix
# matches one of those negation options or the user has the `complete-all`
# style set. Note that this prefix check has to be updated manually to account
# for all of the potential negation options listed below!
if
# We also want to list all of these options during testing
[[ $_RG_COMPLETE_LIST_ARGS == (1|t*|y*) ]] ||
# (--[imnp]* => --ignore*, --messages, --no-*, --pcre2-unicode)
[[ $PREFIX$SUFFIX == --[imnp]* ]] ||
zstyle -t ":complete:$curcontext:*" complete-all
then
no=
fi
# We make heavy use of argument groups here to prevent the option specs from
# growing unwieldy. These aren't supported in zsh <5.4, though, so we'll strip
# them out below if necessary. This makes the exclusions inaccurate on those
# older versions, but oh well — it's not that big a deal
args=(
+ '(exclusive)' # Misc. fully exclusive options
'(: * -)'{-h,--help}'[display help information]'
'(: * -)'{-V,--version}'[display version information]'
'(: * -)'--pcre2-version'[print the version of PCRE2 used by ripgrep, if available]'
+ '(buffered)' # buffering options
'--line-buffered[force line buffering]'
$no"--no-line-buffered[don't force line buffering]"
'--block-buffered[force block buffering]'
$no"--no-block-buffered[don't force block buffering]"
+ '(case)' # Case-sensitivity options
{-i,--ignore-case}'[search case-insensitively]'
{-s,--case-sensitive}'[search case-sensitively]'
{-S,--smart-case}'[search case-insensitively if pattern is all lowercase]'
+ '(context-a)' # Context (after) options
'(context-c)'{-A+,--after-context=}'[specify lines to show after each match]:number of lines'
+ '(context-b)' # Context (before) options
'(context-c)'{-B+,--before-context=}'[specify lines to show before each match]:number of lines'
+ '(context-c)' # Context (combined) options
'(context-a context-b)'{-C+,--context=}'[specify lines to show before and after each match]:number of lines'
+ '(column)' # Column options
'--column[show column numbers for matches]'
$no"--no-column[don't show column numbers for matches]"
+ '(count)' # Counting options
{-c,--count}'[only show count of matching lines for each file]'
'--count-matches[only show count of individual matches for each file]'
'--include-zero[include files with zero matches in summary]'
+ '(encoding)' # Encoding options
{-E+,--encoding=}'[specify text encoding of files to search]: :_rg_encodings'
$no'--no-encoding[use default text encoding]'
+ '(engine)' # Engine choice options
'--engine=[select which regex engine to use]:when:((
default\:"use default engine"
pcre2\:"identical to --pcre2"
auto\:"identical to --auto-hybrid-regex"
))'
+ file # File-input options
'(1)*'{-f+,--file=}'[specify file containing patterns to search for]: :_files'
+ '(file-match)' # Files with/without match options
'(stats)'{-l,--files-with-matches}'[only show names of files with matches]'
'(stats)--files-without-match[only show names of files without matches]'
+ '(file-name)' # File-name options
{-H,--with-filename}'[show file name for matches]'
{-I,--no-filename}"[don't show file name for matches]"
+ '(file-system)' # File system options
"--one-file-system[don't descend into directories on other file systems]"
$no'--no-one-file-system[descend into directories on other file systems]'
+ '(fixed)' # Fixed-string options
{-F,--fixed-strings}'[treat pattern as literal string instead of regular expression]'
$no"--no-fixed-strings[don't treat pattern as literal string]"
+ '(follow)' # Symlink-following options
{-L,--follow}'[follow symlinks]'
$no"--no-follow[don't follow symlinks]"
+ glob # File-glob options
'*'{-g+,--glob=}'[include/exclude files matching specified glob]:glob'
'*--iglob=[include/exclude files matching specified case-insensitive glob]:glob'
+ '(glob-case-insensitive)' # File-glob case sensitivity options
'--glob-case-insensitive[treat -g/--glob patterns case insensitively]'
$no'--no-glob-case-insensitive[treat -g/--glob patterns case sensitively]'
+ '(heading)' # Heading options
'(pretty-vimgrep)--heading[show matches grouped by file name]'
"(pretty-vimgrep)--no-heading[don't show matches grouped by file name]"
+ '(hidden)' # Hidden-file options
{-.,--hidden}'[search hidden files and directories]'
$no"--no-hidden[don't search hidden files and directories]"
+ '(hybrid)' # hybrid regex options
'--auto-hybrid-regex[dynamically use PCRE2 if necessary]'
$no"--no-auto-hybrid-regex[don't dynamically use PCRE2 if necessary]"
+ '(ignore)' # Ignore-file options
"(--no-ignore-global --no-ignore-parent --no-ignore-vcs --no-ignore-dot)--no-ignore[don't respect ignore files]"
$no'(--ignore-global --ignore-parent --ignore-vcs --ignore-dot)--ignore[respect ignore files]'
+ '(ignore-file-case-insensitive)' # Ignore-file case sensitivity options
'--ignore-file-case-insensitive[process ignore files case insensitively]'
$no'--no-ignore-file-case-insensitive[process ignore files case sensitively]'
+ '(ignore-exclude)' # Local exclude (ignore)-file options
"--no-ignore-exclude[don't respect local exclude (ignore) files]"
$no'--ignore-exclude[respect local exclude (ignore) files]'
+ '(ignore-global)' # Global ignore-file options
"--no-ignore-global[don't respect global ignore files]"
$no'--ignore-global[respect global ignore files]'
+ '(ignore-parent)' # Parent ignore-file options
"--no-ignore-parent[don't respect ignore files in parent directories]"
$no'--ignore-parent[respect ignore files in parent directories]'
+ '(ignore-vcs)' # VCS ignore-file options
"--no-ignore-vcs[don't respect version control ignore files]"
$no'--ignore-vcs[respect version control ignore files]'
+ '(require-git)' # git specific settings
"--no-require-git[don't require git repository to respect gitignore rules]"
$no'--require-git[require git repository to respect gitignore rules]'
+ '(ignore-dot)' # .ignore options
"--no-ignore-dot[don't respect .ignore files]"
$no'--ignore-dot[respect .ignore files]'
+ '(ignore-files)' # custom global ignore file options
"--no-ignore-files[don't respect --ignore-file flags]"
$no'--ignore-files[respect --ignore-file files]'
+ '(json)' # JSON options
'--json[output results in JSON Lines format]'
$no"--no-json[don't output results in JSON Lines format]"
+ '(line-number)' # Line-number options
{-n,--line-number}'[show line numbers for matches]'
{-N,--no-line-number}"[don't show line numbers for matches]"
+ '(line-terminator)' # Line-terminator options
'--crlf[use CRLF as line terminator]'
$no"--no-crlf[don't use CRLF as line terminator]"
'(text)--null-data[use NUL as line terminator]'
+ '(max-columns-preview)' # max column preview options
'--max-columns-preview[show preview for long lines (with -M)]'
$no"--no-max-columns-preview[don't show preview for long lines (with -M)]"
+ '(max-depth)' # Directory-depth options
'--max-depth=[specify max number of directories to descend]:number of directories'
'!--maxdepth=:number of directories'
+ '(messages)' # Error-message options
'(--no-ignore-messages)--no-messages[suppress some error messages]'
$no"--messages[don't suppress error messages affected by --no-messages]"
+ '(messages-ignore)' # Ignore-error message options
"--no-ignore-messages[don't show ignore-file parse error messages]"
$no'--ignore-messages[show ignore-file parse error messages]'
+ '(mmap)' # mmap options
'--mmap[search using memory maps when possible]'
"--no-mmap[don't search using memory maps]"
+ '(multiline)' # Multiline options
{-U,--multiline}'[permit matching across multiple lines]'
$no'(multiline-dotall)--no-multiline[restrict matches to at most one line each]'
+ '(multiline-dotall)' # Multiline DOTALL options
'(--no-multiline)--multiline-dotall[allow "." to match newline (with -U)]'
$no"(--no-multiline)--no-multiline-dotall[don't allow \".\" to match newline (with -U)]"
+ '(only)' # Only-match options
{-o,--only-matching}'[show only matching part of each line]'
+ '(passthru)' # Pass-through options
'(--vimgrep)--passthru[show both matching and non-matching lines]'
'!(--vimgrep)--passthrough'
+ '(pcre2)' # PCRE2 options
{-P,--pcre2}'[enable matching with PCRE2]'
$no'(pcre2-unicode)--no-pcre2[disable matching with PCRE2]'
+ '(pcre2-unicode)' # PCRE2 Unicode options
$no'(--no-pcre2 --no-pcre2-unicode)--pcre2-unicode[enable PCRE2 Unicode mode (with -P)]'
'(--no-pcre2 --pcre2-unicode)--no-pcre2-unicode[disable PCRE2 Unicode mode (with -P)]'
+ '(pre)' # Preprocessing options
'(-z --search-zip)--pre=[specify preprocessor utility]:preprocessor utility:_command_names -e'
$no'--no-pre[disable preprocessor utility]'
+ pre-glob # Preprocessing glob options
'*--pre-glob[include/exclude files for preprocessing with --pre]'
+ '(pretty-vimgrep)' # Pretty/vimgrep display options
'(heading)'{-p,--pretty}'[alias for --color=always --heading -n]'
'(heading passthru)--vimgrep[show results in vim-compatible format]'
+ regexp # Explicit pattern options
'(1 file)*'{-e+,--regexp=}'[specify pattern]:pattern'
+ '(replace)' # Replacement options
{-r+,--replace=}'[specify string used to replace matches]:replace string'
+ '(sort)' # File-sorting options
'(threads)--sort=[sort results in ascending order (disables parallelism)]:sort method:((
none\:"no sorting"
path\:"sort by file path"
modified\:"sort by last modified time"
accessed\:"sort by last accessed time"
created\:"sort by creation time"
))'
'(threads)--sortr=[sort results in descending order (disables parallelism)]:sort method:((
none\:"no sorting"
path\:"sort by file path"
modified\:"sort by last modified time"
accessed\:"sort by last accessed time"
created\:"sort by creation time"
))'
'!(threads)--sort-files[sort results by file path (disables parallelism)]'
+ '(stats)' # Statistics options
'(--files file-match)--stats[show search statistics]'
$no"--no-stats[don't show search statistics]"
+ '(text)' # Binary-search options
{-a,--text}'[search binary files as if they were text]'
"--binary[search binary files, don't print binary data]"
$no"--no-binary[don't search binary files]"
$no"(--null-data)--no-text[don't search binary files as if they were text]"
+ '(threads)' # Thread-count options
'(sort)'{-j+,--threads=}'[specify approximate number of threads to use]:number of threads'
+ '(trim)' # Trim options
'--trim[trim any ASCII whitespace prefix from each line]'
$no"--no-trim[don't trim ASCII whitespace prefix from each line]"
+ type # Type options
'*'{-t+,--type=}'[only search files matching specified type]: :_rg_types'
'*--type-add=[add new glob for specified file type]: :->typespec'
'*--type-clear=[clear globs previously defined for specified file type]: :_rg_types'
# This should actually be exclusive with everything but other type options
'(: *)--type-list[show all supported file types and their associated globs]'
'*'{-T+,--type-not=}"[don't search files matching specified file type]: :_rg_types"
+ '(word-line)' # Whole-word/line match options
{-w,--word-regexp}'[only show matches surrounded by word boundaries]'
{-x,--line-regexp}'[only show matches surrounded by line boundaries]'
+ '(unicode)' # Unicode options
$no'--unicode[enable Unicode mode]'
'--no-unicode[disable Unicode mode]'
+ '(zip)' # Compression options
'(--pre)'{-z,--search-zip}'[search in compressed files]'
$no"--no-search-zip[don't search in compressed files]"
+ misc # Other options — no need to separate these at the moment
'(-b --byte-offset)'{-b,--byte-offset}'[show 0-based byte offset for each matching line]'
'--color=[specify when to use colors in output]:when:((
never\:"never use colors"
auto\:"use colors or not based on stdout, TERM, etc."
always\:"always use colors"
ansi\:"always use ANSI colors (even on Windows)"
))'
'*--colors=[specify color and style settings]: :->colorspec'
'--context-separator=[specify string used to separate non-continuous context lines in output]:separator'
$no"--no-context-separator[don't print context separators]"
'--debug[show debug messages]'
'--field-context-separator[set string to delimit fields in context lines]'
'--field-match-separator[set string to delimit fields in matching lines]'
'--trace[show more verbose debug messages]'
'--dfa-size-limit=[specify upper size limit of generated DFA]:DFA size (bytes)'
"(1 stats)--files[show each file that would be searched (but don't search)]"
'*--ignore-file=[specify additional ignore file]:ignore file:_files'
'(-v --invert-match)'{-v,--invert-match}'[invert matching]'
'(-M --max-columns)'{-M+,--max-columns=}'[specify max length of lines to print]:number of bytes'
'(-m --max-count)'{-m+,--max-count=}'[specify max number of matches per file]:number of matches'
'--max-filesize=[specify size above which files should be ignored]:file size (bytes)'
"--no-config[don't load configuration files]"
'(-0 --null)'{-0,--null}'[print NUL byte after file names]'
'--path-separator=[specify path separator to use when printing file names]:separator'
'(-q --quiet)'{-q,--quiet}'[suppress normal output]'
'--regex-size-limit=[specify upper size limit of compiled regex]:regex size (bytes)'
'*'{-u,--unrestricted}'[reduce level of "smart" searching]'
+ operand # Operands
'(--files --type-list file regexp)1: :_guard "^-*" pattern'
'(--type-list)*: :_files'
)
# This is used with test-complete to verify that there are no options
# listed in the help output that aren't also defined here
[[ $_RG_COMPLETE_LIST_ARGS == (1|t*|y*) ]] && {
print -rl - $args
return 0
}
# Strip out argument groups where unsupported (see above)
[[ $ZSH_VERSION == (4|5.<0-3>)(.*)# ]] &&
args=( ${(@)args:#(#i)(+|[a-z0-9][a-z0-9_-]#|\([a-z0-9][a-z0-9_-]#\))} )
_arguments -C -s -S : $args && ret=0
case $state in
colorspec)
if [[ ${IPREFIX#--*=}$PREFIX == [^:]# ]]; then
suf=( -qS: )
tmp=(
'column:specify coloring for column numbers'
'line:specify coloring for line numbers'
'match:specify coloring for match text'
'path:specify coloring for file names'
)
descr='color/style type'
elif [[ ${IPREFIX#--*=}$PREFIX == (column|line|match|path):[^:]# ]]; then
suf=( -qS: )
tmp=(
'none:clear color/style for type'
'bg:specify background color'
'fg:specify foreground color'
'style:specify text style'
)
descr='color/style attribute'
elif [[ ${IPREFIX#--*=}$PREFIX == [^:]##:(bg|fg):[^:]# ]]; then
tmp=( black blue green red cyan magenta yellow white )
descr='color name or r,g,b'
elif [[ ${IPREFIX#--*=}$PREFIX == [^:]##:style:[^:]# ]]; then
tmp=( {,no}bold {,no}intense {,no}underline )
descr='style name'
else
_message -e colorspec 'no more arguments'
fi
(( $#tmp )) && {
compset -P '*:'
_describe -t colorspec $descr tmp $suf && ret=0
}
;;
typespec)
if compset -P '[^:]##:include:'; then
_sequence -s , _rg_types && ret=0
# @todo This bit in particular could be better, but it's a little
# complex, and attempting to solve it seems to run us up against a crash
# bug — zsh # 40362
elif compset -P '[^:]##:'; then
_message 'glob or include directive' && ret=1
elif [[ ! -prefix *:* ]]; then
_rg_types -qS : && ret=0
fi
;;
esac
return ret
}
# Complete encodings
_rg_encodings() {
local -a expl
local -aU _encodings
# This is impossible to read, but these encodings rarely if ever change, so it
# probably doesn't matter. They are derived from the list given here:
# https://encoding.spec.whatwg.org/#concept-encoding-get
_encodings=(
{{,us-}ascii,arabic,chinese,cyrillic,greek{,8},hebrew,korean}
logical visual mac {,cs}macintosh x-mac-{cyrillic,roman,ukrainian}
866 ibm{819,866} csibm866
big5{,-hkscs} {cn-,cs}big5 x-x-big5
cp{819,866,125{0..8}} x-cp125{0..8}
csiso2022{jp,kr} csiso8859{6,8}{e,i}
csisolatin{{1..6},9} csisolatin{arabic,cyrillic,greek,hebrew}
ecma-{114,118} asmo-708 elot_928 sun_eu_greek
euc-{jp,kr} x-euc-jp cseuckr cseucpkdfmtjapanese
{,x-}gbk csiso58gb231280 gb18030 {,cs}gb2312 gb_2312{,-80} hz-gb-2312
iso-2022-{cn,cn-ext,jp,kr}
iso8859{,-}{{1..11},13,14,15}
iso-8859-{{1..11},{6,8}-{e,i},13,14,15,16} iso_8859-{{1..9},15}
iso_8859-{1,2,6,7}:1987 iso_8859-{3,4,5,8}:1988 iso_8859-9:1989
iso-ir-{58,100,101,109,110,126,127,138,144,148,149,157}
koi{,8,8-r,8-ru,8-u,8_r} cskoi8r
ks_c_5601-{1987,1989} ksc{,_}5691 csksc56011987
latin{1..6} l{{1..6},9}
shift{-,_}jis csshiftjis {,x-}sjis ms_kanji ms932
utf{,-}8 utf-16{,be,le} unicode-1-1-utf-8
windows-{31j,874,949,125{0..8}} dos-874 tis-620 ansi_x3.4-1968
x-user-defined auto none
)
_wanted encodings expl encoding compadd -a "$@" - _encodings
}
# Complete file types
_rg_types() {
local -a expl
local -aU _types
_types=( ${(@)${(f)"$( _call_program types rg --type-list )"}%%:*} )
_wanted types expl 'file type' compadd -a "$@" - _types
}
_rg "$@"
################################################################################
# ZSH COMPLETION REFERENCE
#
# For the convenience of developers who aren't especially familiar with zsh
# completion functions, a brief reference guide follows. This is in no way
# comprehensive; it covers just enough of the basic structure, syntax, and
# conventions to help someone make simple changes like adding new options. For
# more complete documentation regarding zsh completion functions, please see the
# following:
#
# * http://zsh.sourceforge.net/Doc/Release/Completion-System.html
# * https://github.com/zsh-users/zsh/blob/master/Etc/completion-style-guide
#
# OVERVIEW
#
# Most zsh completion functions are defined in terms of `_arguments`, which is a
# shell function that takes a series of argument specifications. The specs for
# `rg` are stored in an array, which is common for more complex functions; the
# elements of the array are passed to `_arguments` on invocation.
#
# ARGUMENT-SPECIFICATION SYNTAX
#
# The following is a contrived example of the argument specs for a simple tool:
#
# '(: * -)'{-h,--help}'[display help information]'
# '(-q -v --quiet --verbose)'{-q,--quiet}'[decrease output verbosity]'
# '!(-q -v --quiet --verbose)--silent'
# '(-q -v --quiet --verbose)'{-v,--verbose}'[increase output verbosity]'
# '--color=[specify when to use colors]:when:(always never auto)'
# '*:example file:_files'
#
# Although there may appear to be six specs here, there are actually nine; we
# use brace expansion to combine specs for options that go by multiple names,
# like `-q` and `--quiet`. This is customary, and ties in with the fact that zsh
# merges completion possibilities together when they have the same description.
#
# The first line defines the option `-h`/`--help`. With most tools, it isn't
# useful to complete anything after `--help` because it effectively overrides
# all others; the `(: * -)` at the beginning of the spec tells zsh not to
# complete any other operands (`:` and `*`) or options (`-`) after this one has
# been used. The `[...]` at the end associates a description with `-h`/`--help`;
# as mentioned, zsh will see the identical descriptions and merge these options
# together when offering completion possibilities.
#
# The next line defines `-q`/`--quiet`. Here we don't want to suppress further
# completions entirely, but we don't want to offer `-q` if `--quiet` has been
# given (since they do the same thing), nor do we want to offer `-v` (since it
# doesn't make sense to be quiet and verbose at the same time). We don't need to
# tell zsh not to offer `--quiet` a second time, since that's the default
# behaviour, but since this line expands to two specs describing `-q` *and*
# `--quiet` we do need to explicitly list all of them here.
#
# The next line defines a hidden option `--silent` — maybe it's a deprecated
# synonym for `--quiet`. The leading `!` indicates that zsh shouldn't offer this
# option during completion. The benefit of providing a spec for an option that
# shouldn't be completed is that, if someone *does* use it, we can correctly
# suppress completion of other options afterwards.
#
# The next line defines `-v`/`--verbose`; this works just like `-q`/`--quiet`.
#
# The next line defines `--color`. In this example, `--color` doesn't have a
# corresponding short option, so we don't need to use brace expansion. Further,
# there are no other options it's exclusive with (just itself), so we don't need
# to define those at the beginning. However, it does take a mandatory argument.
# The `=` at the end of `--color=` indicates that the argument may appear either
# like `--color always` or like `--color=always`; this is how most GNU-style
# command-line tools work. The corresponding short option would normally use `+`
# — for example, `-c+` would allow either `-c always` or `-calways`. For this
# option, the arguments are known ahead of time, so we can simply list them in
# parentheses at the end (`when` is used as the description for the argument).
#
# The last line defines an operand (a non-option argument). In this example, the
# operand can be used any number of times (the leading `*`), and it should be a
# file path, so we tell zsh to call the `_files` function to complete it. The
# `example file` in the middle is the description to use for this operand; we
# could use a space instead to accept the default provided by `_files`.
#
# GROUPING ARGUMENT SPECIFICATIONS
#
# Newer versions of zsh support grouping argument specs together. All specs
# following a `+` and then a group name are considered to be members of the
# named group. Grouping is useful mostly for organisational purposes; it makes
# the relationship between different options more obvious, and makes it easier
# to specify exclusions.
#
# We could rewrite our example above using grouping as follows:
#
# '(: * -)'{-h,--help}'[display help information]'
# '--color=[specify when to use colors]:when:(always never auto)'
# '*:example file:_files'
# + '(verbosity)'
# {-q,--quiet}'[decrease output verbosity]'
# '!--silent'
# {-v,--verbose}'[increase output verbosity]'
#
# Here we take advantage of a useful feature of spec grouping — when the group
# name is surrounded by parentheses, as in `(verbosity)`, it tells zsh that all
# of the options in that group are exclusive with each other. As a result, we
# don't need to manually list out the exclusions at the beginning of each
# option.
#
# Groups can also be referred to by name in other argument specs; for example:
#
# '(xyz)--aaa' '*: :_files'
# + xyz --xxx --yyy --zzz
#
# Here we use the group name `xyz` to tell zsh that `--xxx`, `--yyy`, and
# `--zzz` are not to be completed after `--aaa`. This makes the exclusion list
# much more compact and reusable.
#
# CONVENTIONS
#
# zsh completion functions generally adhere to the following conventions:
#
# * Use two spaces for indentation
# * Combine specs for options with different names using brace expansion
# * In combined specs, list the short option first (as in `{-a,--text}`)
# * Use `+` or `=` as described above for options that take arguments
# * Provide a description for all options, option-arguments, and operands
# * Capitalise/punctuate argument descriptions as phrases, not complete
# sentences — 'display help information', never 'Display help information.'
# (but still capitalise acronyms and proper names)
# * Write argument descriptions as verb phrases — 'display x', 'enable y',
# 'use z'
# * Word descriptions to make it clear when an option expects an argument;
# usually this is done with the word 'specify', as in 'specify x' or
# 'use specified x')
# * Write argument descriptions as tersely as possible — for example, articles
# like 'a' and 'the' should be omitted unless it would be confusing
#
# Other conventions currently used by this function:
#
# * Order argument specs alphabetically by group name, then option name
# * Group options that are directly related, mutually exclusive, or frequently
# referenced by other argument specs
# * Use only characters in the set [a-z0-9_-] in group names
# * Order exclusion lists as follows: short options, long options, groups
# * Use American English in descriptions
# * Use 'don't' in descriptions instead of 'do not'
# * Word descriptions for related options as similarly as possible. For example,
# `--foo[enable foo]` and `--no-foo[disable foo]`, or `--foo[use foo]` and
# `--no-foo[don't use foo]`
# * Word descriptions to make it clear when an option only makes sense with
# another option, usually by adding '(with -x)' to the end
# * Don't quote strings or variables unnecessarily. When quotes are required,
# prefer single-quotes to double-quotes
# * Prefix option specs with `$no` when the option serves only to negate the
# behaviour of another option that must be provided explicitly by the user.
# This prevents rarely used options from cluttering up the completion menu
################################################################################
# ------------------------------------------------------------------------------
# Copyright (c) 2011 GitHub zsh-users - http://github.com/zsh-users
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# * Neither the name of the zsh-users nor the
# names of its contributors may be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL ZSH-USERS BE LIABLE FOR ANY
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# ------------------------------------------------------------------------------
# Description
# -----------
#
# Completion script for ripgrep
#
# ------------------------------------------------------------------------------
# Authors
# -------
#
# * arcizan <ghostrevery@gmail.com>
# * MaskRay <i@maskray.me>
#
# ------------------------------------------------------------------------------
# Local Variables:
# mode: shell-script
# coding: utf-8-unix
# indent-tabs-mode: nil
# sh-indentation: 2
# sh-basic-offset: 2
# End:
# vim: ft=zsh sw=2 ts=2 et

View file

@ -1,2 +0,0 @@
# TODO: 2024-01-03 remove rtx support
echo "[oh-my-zsh] 'rtx' plugin has been renamed to 'mise'"

View file

@ -9,7 +9,8 @@
# https://github.com/zsh-users/zsh/blob/f702e17b14d75aa21bff014168fa9048124db286/Functions/Zle/bracketed-paste-magic#L9-L12
# Load bracketed-paste-magic if zsh version is >= 5.1
if [[ ${ZSH_VERSION:0:3} -ge 5.1 ]]; then
autoload -Uz is-at-least
if is-at-least 5.1; then
set zle_bracketed_paste # Explicitly restore this zsh default
autoload -Uz bracketed-paste-magic
zle -N bracketed-paste bracketed-paste-magic

View file

@ -1,6 +1,10 @@
# if using GNU screen, let the zsh tell screen what the title and hardstatus
# of the tab window should be.
if [[ "$TERM" == screen* ]]; then
# Unset title() function defined in lib/termsupport.zsh to prevent
# overwriting our screen titles
title(){}
if [[ $_GET_PATH == '' ]]; then
_GET_PATH='echo $PWD | sed "s/^\/Users\//~/;s/^\/home\//~/;s/^~$USERNAME/~/"'
fi

View file

@ -56,7 +56,16 @@ shrink_path () {
tilde=1
named=1
fi
zstyle -t ':prompt:shrink_path' last && lastfull=1
local last
zstyle -s ':prompt:shrink_path' last last
case "$last" in
(false|no|off|0) lastfull=0 ;;
(true|yes|on|1) lastfull=1 ;;
(""|*[^0-9]*) lastfull=0 ;;
(*) lastfull=$last ;;
esac
zstyle -t ':prompt:shrink_path' short && short=1
zstyle -t ':prompt:shrink_path' tilde && tilde=1
zstyle -t ':prompt:shrink_path' glob && ellipsis='*'
@ -78,7 +87,7 @@ shrink_path () {
print 'Usage: shrink_path [-f -l -s -t] [directory]'
print ' -f, --fish fish-simulation, like -l -s -t'
print ' -g, --glob Add asterisk to allow globbing of shrunk path (equivalent to -e "*")'
print ' -l, --last Print the last directory''s full name'
print ' -l, --last [#] Print the last n directory''s full name (default 1).'
print ' -s, --short Truncate directory names to the number of characters given by -#. Without'
print ' -s, names are truncated without making them ambiguous.'
print ' -t, --tilde Substitute ~ for the home directory'
@ -93,7 +102,13 @@ shrink_path () {
print ' zstyle :prompt:shrink_path fish yes'
return 0
;;
-l|--last) lastfull=1 ;;
-l|--last)
lastfull=1
if [[ -n "$2" && "$2" != *[^0-9]* ]]; then
shift
lastfull=$1
fi
;;
-s|--short) short=1 ;;
-t|--tilde) tilde=1 ;;
-T|--nameddirs)
@ -148,8 +163,8 @@ shrink_path () {
cd -q /
}
for dir in $tree; {
if (( lastfull && $#tree == 1 )) {
result+="/$tree"
if (( lastfull && $#tree <= lastfull )) {
result+="/${(j:/:)tree[@]}"
break
}
expn=(a b)

View file

@ -1,4 +1,4 @@
# Struoe
# Stripe
This plugin provides completion for the [Stripe CLI](https://stripe.com/docs/stripe-cli).

View file

@ -2,7 +2,7 @@
## Description
This plugin provides a few utilities that make you faster on your daily work with the [Swift Package Manager](https://github.com/apple/swift-package-manager), as well as autocompletion for Swift 5.7.
This plugin provides a few utilities that make you faster on your daily work with the [Swift Package Manager](https://github.com/apple/swift-package-manager), as well as autocompletion for Swift 5.9.
To start using it, add the `swiftpm` plugin to your `plugins` array in `~/.zshrc`:

View file

@ -57,6 +57,8 @@ _swift_run() {
'--config-path[Specify the shared configuration directory path]:config-path:_files -/'
'--security-path[Specify the shared security directory path]:security-path:_files -/'
'--scratch-path[Specify a custom scratch directory path (default .build)]:scratch-path:_files -/'
'--pkg-config-path[Specify alternative path to search for pkg-config `.pc` files. Use the option multiple times to
specify more than one path.]:pkg-config-path:_files -/'
'--enable-dependency-cache[Use a shared cache when fetching dependencies]'
'--disable-dependency-cache[Use a shared cache when fetching dependencies]'
'--enable-build-manifest-caching'
@ -64,13 +66,18 @@ _swift_run() {
'--manifest-cache[Caching mode of Package.swift manifests (shared: shared cache, local: package'"'"'s build directory, none: disabled]:manifest-cache:'
'(--verbose -v)'{--verbose,-v}'[Increase verbosity to include informational output]'
'(--very-verbose --vv)'{--very-verbose,--vv}'[Increase verbosity to include debug output]'
'(--quiet -q)'{--quiet,-q}'[Decrease verbosity to only include error output.]'
'--disable-sandbox[Disable using the sandbox when executing subprocesses]'
'--enable-netrc[Load credentials from a .netrc file]'
'--disable-netrc[Load credentials from a .netrc file]'
'--netrc-file[Specify the .netrc file path.]:netrc-file:_files'
'--netrc[Use netrc file even in cases where other credential stores are preferred]'
'--enable-netrc[Load credentials from a netrc file]'
'--disable-netrc[Load credentials from a netrc file]'
'--netrc-file[Specify the netrc file path]:netrc-file:_files'
'--enable-keychain[Search credentials in macOS keychain]'
'--disable-keychain[Search credentials in macOS keychain]'
'--resolver-fingerprint-checking:resolver-fingerprint-checking:'
'--resolver-signing-entity-checking:resolver-signing-entity-checking:'
'--enable-signature-validation[Validate signature of a signed package release downloaded from registry]'
'--disable-signature-validation[Validate signature of a signed package release downloaded from registry]'
'--enable-prefetching'
'--disable-prefetching'
'(--force-resolved-versions --disable-automatic-resolution --only-use-versions-from-resolved-file)'{--force-resolved-versions,--disable-automatic-resolution,--only-use-versions-from-resolved-file}'[Only use versions from the Package.resolved file and fail resolution if it is out-of-date]'
@ -78,6 +85,7 @@ _swift_run() {
'--disable-scm-to-registry-transformation[disable source control to registry transformation]'
'--use-registry-identity-for-scm[look up source control dependencies in the registry and use their registry identity when possible to help deduplicate across the two origins]'
'--replace-scm-with-registry[look up source control dependencies in the registry and use the registry to retrieve them instead of source control when possible]'
'--default-registry-url[Default registry URL to use, instead of the registries.json configuration file]:default-registry-url:'
'(--configuration -c)'{--configuration,-c}'[Build with configuration]:configuration:(debug release)'
'-Xcc[Pass flag through to all C compiler invocations]:Xcc:'
'-Xswiftc[Pass flag through to all Swift compiler invocations]:Xswiftc:'
@ -86,7 +94,7 @@ _swift_run() {
'--triple:triple:'
'--sdk:sdk:_files -/'
'--toolchain:toolchain:_files -/'
'--sanitize[Turn on runtime checks for erroneous behavior, possible values: address, thread, undefined, scudo]:sanitize:'
'--sanitize[Turn on runtime checks for erroneous behavior, possible values: address, thread, undefined, scudo]:sanitize:(address thread undefined scudo)'
'--auto-index-store[Enable or disable indexing-while-building feature]'
'--enable-index-store[Enable or disable indexing-while-building feature]'
'--disable-index-store[Enable or disable indexing-while-building feature]'
@ -94,8 +102,8 @@ _swift_run() {
'(--jobs -j)'{--jobs,-j}'[The number of jobs to spawn in parallel during the build process]:jobs:'
'--emit-swift-module-separately'
'--use-integrated-swift-driver'
'--explicit-target-dependency-import-check:explicit-target-dependency-import-check:'
'--experimental-explicit-module-build'
'--print-manifest-job-graph[Write the command graph for the build manifest as a graphviz file]'
'--build-system:build-system:(native xcode)'
'--enable-dead-strip[Disable/enable dead code stripping by the linker]'
'--disable-dead-strip[Disable/enable dead code stripping by the linker]'
@ -125,6 +133,8 @@ _swift_build() {
'--config-path[Specify the shared configuration directory path]:config-path:_files -/'
'--security-path[Specify the shared security directory path]:security-path:_files -/'
'--scratch-path[Specify a custom scratch directory path (default .build)]:scratch-path:_files -/'
'--pkg-config-path[Specify alternative path to search for pkg-config `.pc` files. Use the option multiple times to
specify more than one path.]:pkg-config-path:_files -/'
'--enable-dependency-cache[Use a shared cache when fetching dependencies]'
'--disable-dependency-cache[Use a shared cache when fetching dependencies]'
'--enable-build-manifest-caching'
@ -132,13 +142,18 @@ _swift_build() {
'--manifest-cache[Caching mode of Package.swift manifests (shared: shared cache, local: package'"'"'s build directory, none: disabled]:manifest-cache:'
'(--verbose -v)'{--verbose,-v}'[Increase verbosity to include informational output]'
'(--very-verbose --vv)'{--very-verbose,--vv}'[Increase verbosity to include debug output]'
'(--quiet -q)'{--quiet,-q}'[Decrease verbosity to only include error output.]'
'--disable-sandbox[Disable using the sandbox when executing subprocesses]'
'--enable-netrc[Load credentials from a .netrc file]'
'--disable-netrc[Load credentials from a .netrc file]'
'--netrc-file[Specify the .netrc file path.]:netrc-file:_files'
'--netrc[Use netrc file even in cases where other credential stores are preferred]'
'--enable-netrc[Load credentials from a netrc file]'
'--disable-netrc[Load credentials from a netrc file]'
'--netrc-file[Specify the netrc file path]:netrc-file:_files'
'--enable-keychain[Search credentials in macOS keychain]'
'--disable-keychain[Search credentials in macOS keychain]'
'--resolver-fingerprint-checking:resolver-fingerprint-checking:'
'--resolver-signing-entity-checking:resolver-signing-entity-checking:'
'--enable-signature-validation[Validate signature of a signed package release downloaded from registry]'
'--disable-signature-validation[Validate signature of a signed package release downloaded from registry]'
'--enable-prefetching'
'--disable-prefetching'
'(--force-resolved-versions --disable-automatic-resolution --only-use-versions-from-resolved-file)'{--force-resolved-versions,--disable-automatic-resolution,--only-use-versions-from-resolved-file}'[Only use versions from the Package.resolved file and fail resolution if it is out-of-date]'
@ -146,6 +161,7 @@ _swift_build() {
'--disable-scm-to-registry-transformation[disable source control to registry transformation]'
'--use-registry-identity-for-scm[look up source control dependencies in the registry and use their registry identity when possible to help deduplicate across the two origins]'
'--replace-scm-with-registry[look up source control dependencies in the registry and use the registry to retrieve them instead of source control when possible]'
'--default-registry-url[Default registry URL to use, instead of the registries.json configuration file]:default-registry-url:'
'(--configuration -c)'{--configuration,-c}'[Build with configuration]:configuration:(debug release)'
'-Xcc[Pass flag through to all C compiler invocations]:Xcc:'
'-Xswiftc[Pass flag through to all Swift compiler invocations]:Xswiftc:'
@ -154,7 +170,7 @@ _swift_build() {
'--triple:triple:'
'--sdk:sdk:_files -/'
'--toolchain:toolchain:_files -/'
'--sanitize[Turn on runtime checks for erroneous behavior, possible values: address, thread, undefined, scudo]:sanitize:'
'--sanitize[Turn on runtime checks for erroneous behavior, possible values: address, thread, undefined, scudo]:sanitize:(address thread undefined scudo)'
'--auto-index-store[Enable or disable indexing-while-building feature]'
'--enable-index-store[Enable or disable indexing-while-building feature]'
'--disable-index-store[Enable or disable indexing-while-building feature]'
@ -162,8 +178,8 @@ _swift_build() {
'(--jobs -j)'{--jobs,-j}'[The number of jobs to spawn in parallel during the build process]:jobs:'
'--emit-swift-module-separately'
'--use-integrated-swift-driver'
'--explicit-target-dependency-import-check:explicit-target-dependency-import-check:'
'--experimental-explicit-module-build'
'--print-manifest-job-graph[Write the command graph for the build manifest as a graphviz file]'
'--build-system:build-system:(native xcode)'
'--enable-dead-strip[Disable/enable dead code stripping by the linker]'
'--disable-dead-strip[Disable/enable dead code stripping by the linker]'
@ -171,6 +187,7 @@ _swift_build() {
'--no-static-swift-stdlib[Link Swift stdlib statically]'
'--build-tests[Build both source and test targets]'
'--show-bin-path[Print the binary output path]'
'--print-manifest-job-graph[Write the command graph for the build manifest as a graphviz file]'
'--target[Build the specified target]:target:'
'--product[Build the specified product]:product:'
'--version[Show the version.]'
@ -190,6 +207,8 @@ _swift_test() {
'--config-path[Specify the shared configuration directory path]:config-path:_files -/'
'--security-path[Specify the shared security directory path]:security-path:_files -/'
'--scratch-path[Specify a custom scratch directory path (default .build)]:scratch-path:_files -/'
'--pkg-config-path[Specify alternative path to search for pkg-config `.pc` files. Use the option multiple times to
specify more than one path.]:pkg-config-path:_files -/'
'--enable-dependency-cache[Use a shared cache when fetching dependencies]'
'--disable-dependency-cache[Use a shared cache when fetching dependencies]'
'--enable-build-manifest-caching'
@ -197,13 +216,18 @@ _swift_test() {
'--manifest-cache[Caching mode of Package.swift manifests (shared: shared cache, local: package'"'"'s build directory, none: disabled]:manifest-cache:'
'(--verbose -v)'{--verbose,-v}'[Increase verbosity to include informational output]'
'(--very-verbose --vv)'{--very-verbose,--vv}'[Increase verbosity to include debug output]'
'(--quiet -q)'{--quiet,-q}'[Decrease verbosity to only include error output.]'
'--disable-sandbox[Disable using the sandbox when executing subprocesses]'
'--enable-netrc[Load credentials from a .netrc file]'
'--disable-netrc[Load credentials from a .netrc file]'
'--netrc-file[Specify the .netrc file path.]:netrc-file:_files'
'--netrc[Use netrc file even in cases where other credential stores are preferred]'
'--enable-netrc[Load credentials from a netrc file]'
'--disable-netrc[Load credentials from a netrc file]'
'--netrc-file[Specify the netrc file path]:netrc-file:_files'
'--enable-keychain[Search credentials in macOS keychain]'
'--disable-keychain[Search credentials in macOS keychain]'
'--resolver-fingerprint-checking:resolver-fingerprint-checking:'
'--resolver-signing-entity-checking:resolver-signing-entity-checking:'
'--enable-signature-validation[Validate signature of a signed package release downloaded from registry]'
'--disable-signature-validation[Validate signature of a signed package release downloaded from registry]'
'--enable-prefetching'
'--disable-prefetching'
'(--force-resolved-versions --disable-automatic-resolution --only-use-versions-from-resolved-file)'{--force-resolved-versions,--disable-automatic-resolution,--only-use-versions-from-resolved-file}'[Only use versions from the Package.resolved file and fail resolution if it is out-of-date]'
@ -211,6 +235,7 @@ _swift_test() {
'--disable-scm-to-registry-transformation[disable source control to registry transformation]'
'--use-registry-identity-for-scm[look up source control dependencies in the registry and use their registry identity when possible to help deduplicate across the two origins]'
'--replace-scm-with-registry[look up source control dependencies in the registry and use the registry to retrieve them instead of source control when possible]'
'--default-registry-url[Default registry URL to use, instead of the registries.json configuration file]:default-registry-url:'
'(--configuration -c)'{--configuration,-c}'[Build with configuration]:configuration:(debug release)'
'-Xcc[Pass flag through to all C compiler invocations]:Xcc:'
'-Xswiftc[Pass flag through to all Swift compiler invocations]:Xswiftc:'
@ -219,7 +244,7 @@ _swift_test() {
'--triple:triple:'
'--sdk:sdk:_files -/'
'--toolchain:toolchain:_files -/'
'--sanitize[Turn on runtime checks for erroneous behavior, possible values: address, thread, undefined, scudo]:sanitize:'
'--sanitize[Turn on runtime checks for erroneous behavior, possible values: address, thread, undefined, scudo]:sanitize:(address thread undefined scudo)'
'--auto-index-store[Enable or disable indexing-while-building feature]'
'--enable-index-store[Enable or disable indexing-while-building feature]'
'--disable-index-store[Enable or disable indexing-while-building feature]'
@ -227,29 +252,77 @@ _swift_test() {
'(--jobs -j)'{--jobs,-j}'[The number of jobs to spawn in parallel during the build process]:jobs:'
'--emit-swift-module-separately'
'--use-integrated-swift-driver'
'--explicit-target-dependency-import-check:explicit-target-dependency-import-check:'
'--experimental-explicit-module-build'
'--print-manifest-job-graph[Write the command graph for the build manifest as a graphviz file]'
'--build-system:build-system:(native xcode)'
'--enable-dead-strip[Disable/enable dead code stripping by the linker]'
'--disable-dead-strip[Disable/enable dead code stripping by the linker]'
'--static-swift-stdlib[Link Swift stdlib statically]'
'--no-static-swift-stdlib[Link Swift stdlib statically]'
'--skip-build[Skip building the test target]'
'--test-product[Test the specified product.]:test-product:'
'--parallel[Run the tests in parallel.]'
'--num-workers[Number of tests to execute in parallel.]:num-workers:'
'(--list-tests -l)'{--list-tests,-l}'[Lists test methods in specifier format]'
'--show-codecov-path[Print the path of the exported code coverage JSON file]'
'(--show-codecov-path --show-code-coverage-path --show-coverage-path)'{--show-codecov-path,--show-code-coverage-path,--show-coverage-path}'[Print the path of the exported code coverage JSON file]'
'(-s --specifier)'{-s,--specifier}':specifier:'
'--filter[Run test cases matching regular expression, Format: <test-target>.<test-case> or <test-target>.<test-case>/<test>]:filter:'
'--skip[Skip test cases matching regular expression, Example: --skip PerformanceTests]:skip:'
'--xunit-output[Path where the xUnit xml file should be generated.]:xunit-output:_files -/'
'--test-product[Test the specified product.]:test-product:'
'--enable-testable-imports[Enable or disable testable imports. Enabled by default.]'
'--disable-testable-imports[Enable or disable testable imports. Enabled by default.]'
'--enable-code-coverage[Enable code coverage]'
'--disable-code-coverage[Enable code coverage]'
'--version[Show the version.]'
'(-help -h --help)'{-help,-h,--help}'[Show help information.]'
'(-): :->command'
'(-)*:: :->arg'
)
_arguments -w -s -S $args[@] && ret=0
case $state in
(command)
local subcommands
subcommands=(
'list:Lists test methods in specifier format'
'generate-linuxmain:Generate LinuxMain.swift (deprecated)'
)
_describe "subcommand" subcommands
;;
(arg)
case ${words[1]} in
(list)
_swift_test_list
;;
(generate-linuxmain)
_swift_test_generate-linuxmain
;;
esac
;;
esac
return ret
}
_swift_test_list() {
integer ret=1
local -a args
args+=(
'--skip-build[Skip building the test target]'
'--test-product[Test the specified product.]:test-product:'
'--version[Show the version.]'
'(-help -h --help)'{-help,-h,--help}'[Show help information.]'
)
_arguments -w -s -S $args[@] && ret=0
return ret
}
_swift_test_generate-linuxmain() {
integer ret=1
local -a args
args+=(
'--version[Show the version.]'
'(-help -h --help)'{-help,-h,--help}'[Show help information.]'
)
_arguments -w -s -S $args[@] && ret=0
@ -265,6 +338,8 @@ _swift_package() {
'--config-path[Specify the shared configuration directory path]:config-path:_files -/'
'--security-path[Specify the shared security directory path]:security-path:_files -/'
'--scratch-path[Specify a custom scratch directory path (default .build)]:scratch-path:_files -/'
'--pkg-config-path[Specify alternative path to search for pkg-config `.pc` files. Use the option multiple times to
specify more than one path.]:pkg-config-path:_files -/'
'--enable-dependency-cache[Use a shared cache when fetching dependencies]'
'--disable-dependency-cache[Use a shared cache when fetching dependencies]'
'--enable-build-manifest-caching'
@ -272,13 +347,18 @@ _swift_package() {
'--manifest-cache[Caching mode of Package.swift manifests (shared: shared cache, local: package'"'"'s build directory, none: disabled]:manifest-cache:'
'(--verbose -v)'{--verbose,-v}'[Increase verbosity to include informational output]'
'(--very-verbose --vv)'{--very-verbose,--vv}'[Increase verbosity to include debug output]'
'(--quiet -q)'{--quiet,-q}'[Decrease verbosity to only include error output.]'
'--disable-sandbox[Disable using the sandbox when executing subprocesses]'
'--enable-netrc[Load credentials from a .netrc file]'
'--disable-netrc[Load credentials from a .netrc file]'
'--netrc-file[Specify the .netrc file path.]:netrc-file:_files'
'--netrc[Use netrc file even in cases where other credential stores are preferred]'
'--enable-netrc[Load credentials from a netrc file]'
'--disable-netrc[Load credentials from a netrc file]'
'--netrc-file[Specify the netrc file path]:netrc-file:_files'
'--enable-keychain[Search credentials in macOS keychain]'
'--disable-keychain[Search credentials in macOS keychain]'
'--resolver-fingerprint-checking:resolver-fingerprint-checking:'
'--resolver-signing-entity-checking:resolver-signing-entity-checking:'
'--enable-signature-validation[Validate signature of a signed package release downloaded from registry]'
'--disable-signature-validation[Validate signature of a signed package release downloaded from registry]'
'--enable-prefetching'
'--disable-prefetching'
'(--force-resolved-versions --disable-automatic-resolution --only-use-versions-from-resolved-file)'{--force-resolved-versions,--disable-automatic-resolution,--only-use-versions-from-resolved-file}'[Only use versions from the Package.resolved file and fail resolution if it is out-of-date]'
@ -286,6 +366,7 @@ _swift_package() {
'--disable-scm-to-registry-transformation[disable source control to registry transformation]'
'--use-registry-identity-for-scm[look up source control dependencies in the registry and use their registry identity when possible to help deduplicate across the two origins]'
'--replace-scm-with-registry[look up source control dependencies in the registry and use the registry to retrieve them instead of source control when possible]'
'--default-registry-url[Default registry URL to use, instead of the registries.json configuration file]:default-registry-url:'
'(--configuration -c)'{--configuration,-c}'[Build with configuration]:configuration:(debug release)'
'-Xcc[Pass flag through to all C compiler invocations]:Xcc:'
'-Xswiftc[Pass flag through to all Swift compiler invocations]:Xswiftc:'
@ -294,7 +375,7 @@ _swift_package() {
'--triple:triple:'
'--sdk:sdk:_files -/'
'--toolchain:toolchain:_files -/'
'--sanitize[Turn on runtime checks for erroneous behavior, possible values: address, thread, undefined, scudo]:sanitize:'
'--sanitize[Turn on runtime checks for erroneous behavior, possible values: address, thread, undefined, scudo]:sanitize:(address thread undefined scudo)'
'--auto-index-store[Enable or disable indexing-while-building feature]'
'--enable-index-store[Enable or disable indexing-while-building feature]'
'--disable-index-store[Enable or disable indexing-while-building feature]'
@ -302,8 +383,8 @@ _swift_package() {
'(--jobs -j)'{--jobs,-j}'[The number of jobs to spawn in parallel during the build process]:jobs:'
'--emit-swift-module-separately'
'--use-integrated-swift-driver'
'--explicit-target-dependency-import-check:explicit-target-dependency-import-check:'
'--experimental-explicit-module-build'
'--print-manifest-job-graph[Write the command graph for the build manifest as a graphviz file]'
'--build-system:build-system:(native xcode)'
'--enable-dead-strip[Disable/enable dead code stripping by the linker]'
'--disable-dead-strip[Disable/enable dead code stripping by the linker]'
@ -325,25 +406,19 @@ _swift_package() {
'update:Update package dependencies'
'describe:Describe the current package'
'init:Initialize a new package'
'_format:'
'diagnose-api-breaking-changes:Diagnose API-breaking changes to Swift modules in a package'
'experimental-api-diff:Deprecated - use `swift package diagnose-api-breaking-changes` instead'
'dump-symbol-graph:Dump Symbol Graph'
'dump-pif:'
'dump-package:Print parsed Package.swift as JSON'
'edit:Put a package in editable mode'
'unedit:Remove a package from editable mode'
'config:Manipulate configuration of the package'
'resolve:Resolve package dependencies'
'fetch:'
'show-dependencies:Print the resolved dependency graph'
'tools-version:Manipulate tools version of the current package'
'generate-xcodeproj:Generates an Xcode project. This command will be deprecated soon.'
'compute-checksum:Compute the checksum for a binary artifact.'
'archive-source:Create a source archive for the package'
'completion-tool:Completion tool (for shell completions)'
'plugin:Invoke a command plugin or perform other actions on command plugins'
'default-command:'
)
_describe "subcommand" subcommands
;;
@ -367,21 +442,12 @@ _swift_package() {
(init)
_swift_package_init
;;
(_format)
_swift_package__format
;;
(diagnose-api-breaking-changes)
_swift_package_diagnose-api-breaking-changes
;;
(experimental-api-diff)
_swift_package_experimental-api-diff
;;
(dump-symbol-graph)
_swift_package_dump-symbol-graph
;;
(dump-pif)
_swift_package_dump-pif
;;
(dump-package)
_swift_package_dump-package
;;
@ -397,18 +463,12 @@ _swift_package() {
(resolve)
_swift_package_resolve
;;
(fetch)
_swift_package_fetch
;;
(show-dependencies)
_swift_package_show-dependencies
;;
(tools-version)
_swift_package_tools-version
;;
(generate-xcodeproj)
_swift_package_generate-xcodeproj
;;
(compute-checksum)
_swift_package_compute-checksum
;;
@ -421,9 +481,6 @@ _swift_package() {
(plugin)
_swift_package_plugin
;;
(default-command)
_swift_package_default-command
;;
esac
;;
esac
@ -498,7 +555,7 @@ _swift_package_init() {
integer ret=1
local -a args
args+=(
'--type[Package type: empty | library | executable | system-module | manifest]:type:'
'--type[Package type:]:type:'
'--name[Provide custom package name]:name:'
'--version[Show the version.]'
'(-help -h --help)'{-help,-h,--help}'[Show help information.]'
@ -508,19 +565,6 @@ _swift_package_init() {
return ret
}
_swift_package__format() {
integer ret=1
local -a args
args+=(
':swift-format-flags:'
'--version[Show the version.]'
'(-help -h --help)'{-help,-h,--help}'[Show help information.]'
)
_arguments -w -s -S $args[@] && ret=0
return ret
}
_swift_package_diagnose-api-breaking-changes() {
integer ret=1
local -a args
@ -539,19 +583,6 @@ _swift_package_diagnose-api-breaking-changes() {
return ret
}
_swift_package_experimental-api-diff() {
integer ret=1
local -a args
args+=(
':args:'
'--version[Show the version.]'
'(-help -h --help)'{-help,-h,--help}'[Show help information.]'
)
_arguments -w -s -S $args[@] && ret=0
return ret
}
_swift_package_dump-symbol-graph() {
integer ret=1
local -a args
@ -561,19 +592,8 @@ _swift_package_dump-symbol-graph() {
'--minimum-access-level[Include symbols with this access level or more. Possible values: private | fileprivate | internal | public | open]:minimum-access-level:(private fileprivate internal public open)'
'--skip-inherited-docs[Skip emitting doc comments for members inherited through classes or default implementations.]'
'--include-spi-symbols[Add symbols with SPI information to the symbol graph.]'
'--version[Show the version.]'
'(-help -h --help)'{-help,-h,--help}'[Show help information.]'
)
_arguments -w -s -S $args[@] && ret=0
return ret
}
_swift_package_dump-pif() {
integer ret=1
local -a args
args+=(
'--preserve-structure[Preserve the internal structure of PIF]'
'--emit-extension-block-symbols[Emit extension block symbols for extensions to external types or directly associate members and conformances with the extended nominal.]'
'--omit-extension-block-symbols[Emit extension block symbols for extensions to external types or directly associate members and conformances with the extended nominal.]'
'--version[Show the version.]'
'(-help -h --help)'{-help,-h,--help}'[Show help information.]'
)
@ -614,7 +634,7 @@ _swift_package_unedit() {
integer ret=1
local -a args
args+=(
'--force[Unedit the package even if it has uncommitted and unpushed changes]'
'--force[Unedit the package even if it has uncommited and unpushed changes]'
':package-name:'
'--version[Show the version.]'
'(-help -h --help)'{-help,-h,--help}'[Show help information.]'
@ -666,9 +686,8 @@ _swift_package_config_set-mirror() {
integer ret=1
local -a args
args+=(
'--package-url[The package dependency url]:package-url:'
'--original-url[The original url]:original-url:'
'--mirror-url[The mirror url]:mirror-url:'
'--original[The original url or identity]:original:'
'--mirror[The mirror url or identity]:mirror:'
'--version[Show the version.]'
'(-help -h --help)'{-help,-h,--help}'[Show help information.]'
)
@ -681,9 +700,8 @@ _swift_package_config_unset-mirror() {
integer ret=1
local -a args
args+=(
'--package-url[The package dependency url]:package-url:'
'--original-url[The original url]:original-url:'
'--mirror-url[The mirror url]:mirror-url:'
'--original[The original url or identity]:original:'
'--mirror[The mirror url or identity]:mirror:'
'--version[Show the version.]'
'(-help -h --help)'{-help,-h,--help}'[Show help information.]'
)
@ -696,8 +714,7 @@ _swift_package_config_get-mirror() {
integer ret=1
local -a args
args+=(
'--package-url[The package dependency url]:package-url:'
'--original-url[The original url]:original-url:'
'--original[The original url or identity]:original:'
'--version[Show the version.]'
'(-help -h --help)'{-help,-h,--help}'[Show help information.]'
)
@ -722,22 +739,6 @@ _swift_package_resolve() {
return ret
}
_swift_package_fetch() {
integer ret=1
local -a args
args+=(
'--version[The version to resolve at]:version:'
'--branch[The branch to resolve at]:branch:'
'--revision[The revision to resolve at]:revision:'
':package-name:'
'--version[Show the version.]'
'(-help -h --help)'{-help,-h,--help}'[Show help information.]'
)
_arguments -w -s -S $args[@] && ret=0
return ret
}
_swift_package_show-dependencies() {
integer ret=1
local -a args
@ -766,25 +767,6 @@ _swift_package_tools-version() {
return ret
}
_swift_package_generate-xcodeproj() {
integer ret=1
local -a args
args+=(
'--xcconfig-overrides[Path to xcconfig file]:xcconfig-overrides:_files'
'--output[Path where the Xcode project should be generated]:output:_files -/'
'--legacy-scheme-generator[Use the legacy scheme generator]'
'--watch[Watch for changes to the Package manifest to regenerate the Xcode project]'
'--skip-extra-files[Do not add file references for extra files to the generated Xcode project]'
'--enable-code-coverage[Enable code coverage]'
'--disable-code-coverage[Enable code coverage]'
'--version[Show the version.]'
'(-help -h --help)'{-help,-h,--help}'[Show help information.]'
)
_arguments -w -s -S $args[@] && ret=0
return ret
}
_swift_package_compute-checksum() {
integer ret=1
local -a args
@ -831,6 +813,7 @@ _swift_package_plugin() {
'--list[List the available command plugins]'
'--allow-writing-to-package-directory[Allow the plugin to write to the package directory]'
'--allow-writing-to-directory[Allow the plugin to write to an additional directory]:allow-writing-to-directory:'
'--allow-network-connections:allow-network-connections:(none local all docker unixDomainSocket)'
':command:'
':arguments:'
'--version[Show the version.]'
@ -841,21 +824,6 @@ _swift_package_plugin() {
return ret
}
_swift_package_default-command() {
integer ret=1
local -a args
args+=(
'--allow-writing-to-package-directory[Allow the plugin to write to the package directory]'
'--allow-writing-to-directory[Allow the plugin to write to an additional directory]:allow-writing-to-directory:'
':remaining:'
'--version[Show the version.]'
'(-help -h --help)'{-help,-h,--help}'[Show help information.]'
)
_arguments -w -s -S $args[@] && ret=0
return ret
}
_swift_help() {
integer ret=1
local -a args

View file

@ -0,0 +1,9 @@
# Symfony
This plugin provides native completion for [Symfony](https://symfony.com/), but requires at least Symfony 6.2.
To use it add `symfony6` to the plugins array in your zshrc file.
```bash
plugins=(... symfony6)
```

View file

@ -0,0 +1,82 @@
#compdef console
# This file is part of the Symfony package.
#
# (c) Fabien Potencier <fabien@symfony.com>
#
# For the full copyright and license information, please view
# https://symfony.com/doc/current/contributing/code/license.html
#
# zsh completions for console
#
# References:
# - https://github.com/spf13/cobra/blob/master/zsh_completions.go
# - https://github.com/symfony/symfony/blob/5.4/src/Symfony/Component/Console/Resources/completion.bash
#
_sf_console() {
local lastParam flagPrefix requestComp out comp
local -a completions
# The user could have moved the cursor backwards on the command-line.
# We need to trigger completion from the $CURRENT location, so we need
# to truncate the command-line ($words) up to the $CURRENT location.
# (We cannot use $CURSOR as its value does not work when a command is an alias.)
words=("${=words[1,CURRENT]}") lastParam=${words[-1]}
# For zsh, when completing a flag with an = (e.g., console -n=<TAB>)
# completions must be prefixed with the flag
setopt local_options BASH_REMATCH
if [[ "${lastParam}" =~ '-.*=' ]]; then
# We are dealing with a flag with an =
flagPrefix="-P ${BASH_REMATCH}"
fi
# Prepare the command to obtain completions
requestComp="${words[0]} ${words[1]} _complete --no-interaction -szsh -a1 -c$((CURRENT-1))" i=""
for w in ${words[@]}; do
w=$(printf -- '%b' "$w")
# remove quotes from typed values
quote="${w:0:1}"
if [ "$quote" = \' ]; then
w="${w%\'}"
w="${w#\'}"
elif [ "$quote" = \" ]; then
w="${w%\"}"
w="${w#\"}"
fi
# empty values are ignored
if [ ! -z "$w" ]; then
i="${i}-i${w} "
fi
done
# Ensure at least 1 input
if [ "${i}" = "" ]; then
requestComp="${requestComp} -i\" \""
else
requestComp="${requestComp} ${i}"
fi
# Use eval to handle any environment variables and such
out=$(eval ${requestComp} 2>/dev/null)
while IFS='\n' read -r comp; do
if [ -n "$comp" ]; then
# If requested, completions are returned with a description.
# The description is preceded by a TAB character.
# For zsh's _describe, we need to use a : instead of a TAB.
# We first need to escape any : as part of the completion itself.
comp=${comp//:/\\:}
local tab=$(printf '\t')
comp=${comp//$tab/:}
completions+=${comp}
fi
done < <(printf "%s\n" "${out[@]}")
# Let inbuilt _describe handle completions
eval _describe "completions" completions $flagPrefix
return $?
}
compdef _sf_console console

View file

@ -15,20 +15,21 @@ plugins=(... terraform)
## Aliases
| Alias | Command |
| ------ | -------------------- |
| `tf` | `terraform` |
| `tfa` | `terraform apply` |
| `tfc` | `terraform console` |
| `tfd` | `terraform destroy` |
| `tff` | `terraform fmt` |
| `tfi` | `terraform init` |
| `tfo` | `terraform output` |
| `tfp` | `terraform plan` |
| `tfv` | `terraform validate` |
| `tfs` | `terraform state` |
| `tft` | `terraform test` |
| `tfsh` | `terraform show` |
| Alias | Command |
| ------ | ------------------------- |
| `tf` | `terraform` |
| `tfa` | `terraform apply` |
| `tfc` | `terraform console` |
| `tfd` | `terraform destroy` |
| `tff` | `terraform fmt` |
| `tfi` | `terraform init` |
| `tfiu` | `terraform init -upgrade` |
| `tfo` | `terraform output` |
| `tfp` | `terraform plan` |
| `tfv` | `terraform validate` |
| `tfs` | `terraform state` |
| `tft` | `terraform test` |
| `tfsh` | `terraform show` |
## Prompt function

View file

@ -21,6 +21,7 @@ alias tfc='terraform console'
alias tfd='terraform destroy'
alias tff='terraform fmt'
alias tfi='terraform init'
alias tfiu='terraform init -upgrade'
alias tfo='terraform output'
alias tfp='terraform plan'
alias tfv='terraform validate'

View file

@ -23,9 +23,12 @@ __timer_display_timer_precmd() {
local tdiff=$((cmd_end_time - __timer_cmd_start_time))
unset __timer_cmd_start_time
if [[ -z "${TIMER_THRESHOLD}" || ${tdiff} -ge "${TIMER_THRESHOLD}" ]]; then
local last_cmd="${history[$((HISTCMD - 1))]%% *}"
if [[ "$last_cmd" != clear ]]; then
local tdiffstr=$(__timer_format_duration ${tdiff})
local cols=$((COLUMNS - ${#tdiffstr} - 1))
echo -e "\033[1A\033[${cols}C ${tdiffstr}"
fi
fi
fi
}

15
plugins/tldr/README.md Normal file
View file

@ -0,0 +1,15 @@
# tldr plugin
This plugin adds a shortcut to insert tldr before the previous command.
Heavily inspired from [Man plugin](https://github.com/ohmyzsh/ohmyzsh/tree/master/plugins/man).
To use it, add `tldr` to the plugins array in your zshrc file:
```zsh
plugins=(... tldr)
```
# Keyboard Shortcuts
| Shortcut | Description |
|------------------------------------|----------------------------------------------------------------------------|
| <kbd>Esc</kbd> + tldr | add tldr before the previous command to see the tldr page for this command |

View file

@ -0,0 +1,19 @@
tldr-command-line() {
# if there is no command typed, use the last command
[[ -z "$BUFFER" ]] && zle up-history
# if typed command begins with tldr, do nothing
[[ "$BUFFER" = tldr\ * ]] && return
# get command and possible subcommand
# http://zsh.sourceforge.net/Doc/Release/Expansion.html#Parameter-Expansion-Flags
local -a args
args=(${${(Az)BUFFER}[1]} ${${(Az)BUFFER}[2]})
BUFFER="tldr ${args[1]}"
}
zle -N tldr-command-line
# Defined shortcut keys: [Esc]tldr
bindkey "\e"tldr tldr-command-line

View file

@ -50,6 +50,7 @@ fi
# ALIASES
function _build_tmux_alias {
setopt localoptions no_rc_expand_param
eval "function $1 {
if [[ -z \$1 ]] || [[ \${1:0:1} == '-' ]]; then
tmux $2 \"\$@\"
@ -57,6 +58,19 @@ function _build_tmux_alias {
tmux $2 $3 \"\$@\"
fi
}"
local f s
f="_omz_tmux_alias_${1}"
s=(${(z)2})
eval "function ${f}() {
shift words;
words=(tmux ${@:2} \$words);
((CURRENT+=${#s[@]}+1))
_tmux
}"
compdef "$f" "$1"
}
alias tksv='tmux kill-server'

View file

@ -10,7 +10,8 @@ plugins=(... toolbox)
## Prompt function
This plugins adds `toolbox_prompt_info()` function. Using it in your prompt, it will show the toolbox indicator ⬢ (if you are running in a toolbox container), and nothing if not.
This plugins adds `toolbox_prompt_info()` function. Using it in your prompt, it will show the toolbox
indicator ⬢ (if you are running in a toolbox container), and nothing if not.
You can use it by adding `$(toolbox_prompt_info)` to your `PROMPT` or `RPROMPT` variable:
@ -18,9 +19,11 @@ You can use it by adding `$(toolbox_prompt_info)` to your `PROMPT` or `RPROMPT`
RPROMPT='$(toolbox_prompt_info)'
```
In the same way, it adds `toolbox_prompt_name()`, showing the name of the containerized environment.
## Aliases
| Alias | Command | Description |
|-------|----------------------|----------------------------------------|
| tbe | `toolbox enter` | Enters the toolbox environment |
| tbr | `toolbox run` | Run a command in an existing toolbox |
| Alias | Command | Description |
| ----- | --------------- | ------------------------------------ |
| tbe | `toolbox enter` | Enters the toolbox environment |
| tbr | `toolbox run` | Run a command in an existing toolbox |

View file

@ -2,5 +2,15 @@ function toolbox_prompt_info() {
[[ -f /run/.toolboxenv ]] && echo "⬢"
}
function toolbox_prompt_name() {
[[ -f /run/.containerenv ]] || return
# This command reads the /run/.containerenv file line by line and extracts the
# container name from it by looking for the `name="..."` line, and uses -F\" to
# split the line by double quotes. Then all % characters are replaced with %%
# to escape them for the prompt.
awk -F\" '/name/ { gsub(/%/, "%%", $2); print $2 }' /run/.containerenv
}
alias tbe="toolbox enter"
alias tbr="toolbox run"

View file

@ -18,12 +18,12 @@ typeset -g VI_MODE_SET_CURSOR
# if $VI_MODE_SET_CURSOR=true.
#
# See https://vt100.net/docs/vt510-rm/DECSCUSR for cursor styles
typeset -g VI_MODE_CURSOR_NORMAL=2
typeset -g VI_MODE_CURSOR_VISUAL=6
typeset -g VI_MODE_CURSOR_INSERT=6
typeset -g VI_MODE_CURSOR_OPPEND=0
typeset -g VI_MODE_CURSOR_NORMAL=${VI_MODE_CURSOR_NORMAL:=2}
typeset -g VI_MODE_CURSOR_VISUAL=${VI_MODE_CURSOR_VISUAL:=6}
typeset -g VI_MODE_CURSOR_INSERT=${VI_MODE_CURSOR_INSERT:=6}
typeset -g VI_MODE_CURSOR_OPPEND=${VI_MODE_CURSOR_OPPEND:=0}
typeset -g VI_KEYMAP=main
typeset -g VI_KEYMAP=${VI_KEYMAP:=main}
function _vi-mode-set-cursor-shape-for-keymap() {
[[ "$VI_MODE_SET_CURSOR" = true ]] || return
@ -162,9 +162,7 @@ if [[ -z "${VI_MODE_DISABLE_CLIPBOARD:-}" ]]; then
fi
# if mode indicator wasn't setup by theme, define default, we'll leave INSERT_MODE_INDICATOR empty by default
if [[ -z "$MODE_INDICATOR" ]]; then
MODE_INDICATOR='%B%F{red}<%b<<%f'
fi
typeset -g MODE_INDICATOR=${MODE_INDICATOR:='%B%F{red}<%b<<%f'}
function vi_mode_prompt_info() {
echo "${${VI_KEYMAP/vicmd/$MODE_INDICATOR}/(main|viins)/$INSERT_MODE_INDICATOR}"

View file

@ -57,6 +57,24 @@ wd() {
}
```
### [Home Manager](https://github.com/nix-community/home-manager)
Add the following to your `home.nix` then run `home-manager switch`:
```nix
programs.zsh.plugins = [
{
name = "wd";
src = pkgs.fetchFromGitHub {
owner = "mfaerevaag";
repo = "wd";
rev = "v0.5.2";
sha256 = "sha256-4yJ1qhqhNULbQmt6Z9G22gURfDLe30uV1ascbzqgdhg=";
};
}
];
```
### [zplug](https://github.com/zplug/zplug)
```zsh
@ -119,6 +137,14 @@ Also, you may have to force a rebuild of `zcompdump` by running:
rm -f ~/.zcompdump; compinit
```
## Browse
If you want to make use of the `fzf`-powered browse feature to fuzzy search through all your warp points, set up a keybind in your `.zshrc`:
```zsh
bindkey ${FZF_WD_BINDKEY:-'^B'} fuzzy_wd_widget
```
## Usage
* Add warp point to current working directory:
@ -132,6 +158,19 @@ If a warp point with the same name exists, use `wd add foo --force` to overwrite
**Note:** a warp point cannot contain colons, or consist of only spaces and dots.
The first will conflict in how `wd` stores the warp points, and the second will conflict with other features, as below.
* Add warp point to any directory with default name:
```zsh
wd addcd /foo/ bar
```
* Add warp point to any directory with a custom name:
```zsh
wd addcd /foo/
```
You can omit point name to automatically use the current directory's name instead.
* From any directory, warp to `foo` with:
@ -153,7 +192,7 @@ wd ..
wd ...
```
This is a wrapper for the zsh's `dirs` function.
This is a wrapper for the zsh's `dirs` function.
_You might need to add `setopt AUTO_PUSHD` to your `.zshrc` if you are not using [oh-my-zsh](https://github.com/ohmyzsh/ohmyzsh)._
* Remove warp point:

View file

@ -31,6 +31,7 @@ function _wd() {
commands=(
'add:Adds the current working directory to your warp points'
'addcd:Adds a directory to your warp points'
'add!:Overwrites existing warp point'
'export:Export warp points as static named directories'
'rm:Removes the given warp point'
@ -63,6 +64,9 @@ function _wd() {
add)
_message 'Write the name of your warp point' && ret=0
;;
addcd)
_message 'Write the name of your path' && ret=0
;;
show)
_describe -t points "Warp points" warp_points && ret=0
;;

Some files were not shown because too many files have changed in this diff Show more