mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2026-02-06 02:51:32 +01:00
Merge branch 'master' into tf-plugin-add-workspace-aliases
This commit is contained in:
commit
d3e67b05c9
182 changed files with 2867 additions and 1297 deletions
|
|
@ -6,3 +6,6 @@ insert_final_newline = true
|
||||||
charset = utf-8
|
charset = utf-8
|
||||||
indent_size = 2
|
indent_size = 2
|
||||||
indent_style = space
|
indent_style = space
|
||||||
|
|
||||||
|
[*.py]
|
||||||
|
indent_size = 4
|
||||||
|
|
|
||||||
5
.github/CODEOWNERS
vendored
5
.github/CODEOWNERS
vendored
|
|
@ -1,13 +1,14 @@
|
||||||
# Plugin owners
|
# Plugin owners
|
||||||
plugins/archlinux/ @ratijas
|
plugins/archlinux/ @ratijas
|
||||||
|
plugins/dbt/ @msempere
|
||||||
|
plugins/eza/ @pepoluan
|
||||||
plugins/genpass/ @atoponce
|
plugins/genpass/ @atoponce
|
||||||
plugins/git-lfs/ @hellovietduc
|
plugins/git-lfs/ @hellovietduc
|
||||||
plugins/gitfast/ @felipec
|
plugins/gitfast/ @felipec
|
||||||
plugins/react-native @esthor
|
plugins/react-native @esthor
|
||||||
plugins/sdk/ @rgoldberg
|
plugins/sdk/ @rgoldberg
|
||||||
plugins/shell-proxy/ @septs
|
plugins/shell-proxy/ @septs
|
||||||
|
plugins/starship/ @axieax
|
||||||
plugins/universalarchive/ @Konfekt
|
plugins/universalarchive/ @Konfekt
|
||||||
plugins/wp-cli/ @joshmedeski
|
plugins/wp-cli/ @joshmedeski
|
||||||
plugins/zoxide/ @ajeetdsouza
|
plugins/zoxide/ @ajeetdsouza
|
||||||
plugins/starship/ @axieax
|
|
||||||
plugins/dbt/ @msempere
|
|
||||||
|
|
|
||||||
12
.github/dependabot.yml
vendored
Normal file
12
.github/dependabot.yml
vendored
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
version: 2
|
||||||
|
updates:
|
||||||
|
- package-ecosystem: github-actions
|
||||||
|
directory: /
|
||||||
|
schedule:
|
||||||
|
interval: "weekly"
|
||||||
|
day: "sunday"
|
||||||
|
- package-ecosystem: "pip"
|
||||||
|
directory: "/.github/workflows/dependencies"
|
||||||
|
schedule:
|
||||||
|
interval: "weekly"
|
||||||
|
day: "sunday"
|
||||||
19
.github/dependencies.yml
vendored
19
.github/dependencies.yml
vendored
|
|
@ -2,7 +2,7 @@ dependencies:
|
||||||
plugins/gitfast:
|
plugins/gitfast:
|
||||||
repo: felipec/git-completion
|
repo: felipec/git-completion
|
||||||
branch: master
|
branch: master
|
||||||
version: tag:v2.0
|
version: tag:v2.1
|
||||||
postcopy: |
|
postcopy: |
|
||||||
set -e
|
set -e
|
||||||
rm -rf git-completion.plugin.zsh Makefile README.adoc t tools
|
rm -rf git-completion.plugin.zsh Makefile README.adoc t tools
|
||||||
|
|
@ -21,7 +21,7 @@ dependencies:
|
||||||
plugins/history-substring-search:
|
plugins/history-substring-search:
|
||||||
repo: zsh-users/zsh-history-substring-search
|
repo: zsh-users/zsh-history-substring-search
|
||||||
branch: master
|
branch: master
|
||||||
version: 8dd05bfcc12b0cd1ee9ea64be725b3d9f713cf64
|
version: 87ce96b1862928d84b1afe7c173316614b30e301
|
||||||
precopy: |
|
precopy: |
|
||||||
set -e
|
set -e
|
||||||
rm -f zsh-history-substring-search.plugin.zsh
|
rm -f zsh-history-substring-search.plugin.zsh
|
||||||
|
|
@ -29,3 +29,18 @@ dependencies:
|
||||||
postcopy: |
|
postcopy: |
|
||||||
set -e
|
set -e
|
||||||
test -e dependencies/OMZ-README.md && cat dependencies/OMZ-README.md >> README.md
|
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
|
||||||
|
plugins/wd:
|
||||||
|
repo: mfaerevaag/wd
|
||||||
|
branch: master
|
||||||
|
version: tag:v0.7.0
|
||||||
|
precopy: |
|
||||||
|
set -e
|
||||||
|
rm -r test
|
||||||
|
rm install.sh tty.gif wd.1
|
||||||
|
|
|
||||||
11
.github/workflows/dependencies.yml
vendored
11
.github/workflows/dependencies.yml
vendored
|
|
@ -1,8 +1,8 @@
|
||||||
name: Update dependencies
|
name: Update dependencies
|
||||||
on:
|
on:
|
||||||
workflow_dispatch: {}
|
workflow_dispatch: {}
|
||||||
# schedule:
|
schedule:
|
||||||
# - cron: '34 3 * * */8'
|
- cron: "0 6 * * 0"
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
check:
|
check:
|
||||||
|
|
@ -12,12 +12,19 @@ jobs:
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
- name: Authenticate as @ohmyzsh
|
- name: Authenticate as @ohmyzsh
|
||||||
id: generate_token
|
id: generate_token
|
||||||
uses: ohmyzsh/github-app-token@v2
|
uses: ohmyzsh/github-app-token@v2
|
||||||
with:
|
with:
|
||||||
app_id: ${{ secrets.OHMYZSH_APP_ID }}
|
app_id: ${{ secrets.OHMYZSH_APP_ID }}
|
||||||
private_key: ${{ secrets.OHMYZSH_APP_PRIVATE_KEY }}
|
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
|
- name: Process dependencies
|
||||||
env:
|
env:
|
||||||
GH_TOKEN: ${{ steps.generate_token.outputs.token }}
|
GH_TOKEN: ${{ steps.generate_token.outputs.token }}
|
||||||
|
|
|
||||||
|
|
@ -1,2 +1,7 @@
|
||||||
PyYAML~=6.0.1
|
certifi==2024.2.2
|
||||||
requests~=2.31.0
|
charset-normalizer==3.3.2
|
||||||
|
idna==3.7
|
||||||
|
PyYAML==6.0.1
|
||||||
|
requests==2.31.0
|
||||||
|
semver==3.0.2
|
||||||
|
urllib3==2.2.1
|
||||||
|
|
|
||||||
810
.github/workflows/dependencies/updater.py
vendored
810
.github/workflows/dependencies/updater.py
vendored
|
|
@ -1,11 +1,16 @@
|
||||||
|
import json
|
||||||
import os
|
import os
|
||||||
|
import re
|
||||||
|
import shutil
|
||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
import requests
|
import timeit
|
||||||
import shutil
|
|
||||||
import yaml
|
|
||||||
from copy import deepcopy
|
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
|
# Get TMP_DIR variable from environment
|
||||||
TMP_DIR = os.path.join(os.environ.get("TMP_DIR", "/tmp"), "ohmyzsh")
|
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 flag
|
||||||
DRY_RUN = os.environ.get("DRY_RUN", "0") == "1"
|
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:
|
class CodeTimer:
|
||||||
def __init__(self, name=None):
|
def __init__(self, name=None):
|
||||||
self.name = " '" + name + "'" if name else ''
|
self.name = " '" + name + "'" if name else ""
|
||||||
|
|
||||||
def __enter__(self):
|
def __enter__(self):
|
||||||
self.start = timeit.default_timer()
|
self.start = timeit.default_timer()
|
||||||
|
|
||||||
def __exit__(self, exc_type, exc_value, traceback):
|
def __exit__(self, exc_type, exc_value, traceback):
|
||||||
self.took = (timeit.default_timer() - self.start) * 1000.0
|
self.took = (timeit.default_timer() - self.start) * 1000.0
|
||||||
print('Code block' + self.name + ' took: ' + str(self.took) + ' ms')
|
print("Code block" + self.name + " took: " + str(self.took) + " ms")
|
||||||
|
|
||||||
|
|
||||||
### YAML representation
|
### YAML representation
|
||||||
def str_presenter(dumper, data):
|
def str_presenter(dumper, data):
|
||||||
"""
|
"""
|
||||||
Configures yaml for dumping multiline strings
|
Configures yaml for dumping multiline strings
|
||||||
Ref: https://stackoverflow.com/a/33300001
|
Ref: https://stackoverflow.com/a/33300001
|
||||||
"""
|
"""
|
||||||
if len(data.splitlines()) > 1: # check for multiline string
|
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, style="|")
|
||||||
return dumper.represent_scalar('tag:yaml.org,2002:str', data)
|
return dumper.represent_scalar("tag:yaml.org,2002:str", data)
|
||||||
|
|
||||||
|
|
||||||
yaml.add_representer(str, str_presenter)
|
yaml.add_representer(str, str_presenter)
|
||||||
yaml.representer.SafeRepresenter.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
|
# Types
|
||||||
class DependencyDict(TypedDict):
|
class DependencyDict(TypedDict):
|
||||||
repo: str
|
repo: str
|
||||||
branch: str
|
branch: str
|
||||||
version: str
|
version: str
|
||||||
precopy: Optional[str]
|
precopy: NotRequired[str]
|
||||||
postcopy: Optional[str]
|
postcopy: NotRequired[str]
|
||||||
|
|
||||||
|
|
||||||
class DependencyYAML(TypedDict):
|
class DependencyYAML(TypedDict):
|
||||||
dependencies: dict[str, DependencyDict]
|
dependencies: dict[str, DependencyDict]
|
||||||
|
|
||||||
class UpdateStatus(TypedDict):
|
|
||||||
has_updates: bool
|
class UpdateStatusFalse(TypedDict):
|
||||||
version: Optional[str]
|
has_updates: Literal[False]
|
||||||
compare_url: Optional[str]
|
|
||||||
head_ref: Optional[str]
|
|
||||||
head_url: Optional[str]
|
class UpdateStatusTrue(TypedDict):
|
||||||
|
has_updates: Literal[True]
|
||||||
|
version: str
|
||||||
|
compare_url: str
|
||||||
|
head_ref: str
|
||||||
|
head_url: str
|
||||||
|
|
||||||
|
|
||||||
class CommandRunner:
|
class CommandRunner:
|
||||||
class Exception(Exception):
|
class Exception(Exception):
|
||||||
def __init__(self, message, returncode, stage, stdout, stderr):
|
def __init__(self, message, returncode, stage, stdout, stderr):
|
||||||
super().__init__(message)
|
super().__init__(message)
|
||||||
self.returncode = returncode
|
self.returncode = returncode
|
||||||
self.stage = stage
|
self.stage = stage
|
||||||
self.stdout = stdout
|
self.stdout = stdout
|
||||||
self.stderr = stderr
|
self.stderr = stderr
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def run_or_fail(command: list[str], stage: str, *args, **kwargs):
|
def run_or_fail(command: list[str], stage: str, *args, **kwargs):
|
||||||
if DRY_RUN and command[0] == "gh":
|
if DRY_RUN and command[0] == "gh":
|
||||||
command.insert(0, "echo")
|
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:
|
if result.returncode != 0:
|
||||||
raise CommandRunner.Exception(
|
raise CommandRunner.Exception(
|
||||||
f"{stage} command failed with exit code {result.returncode}", returncode=result.returncode,
|
f"{stage} command failed with exit code {result.returncode}",
|
||||||
stage=stage,
|
returncode=result.returncode,
|
||||||
stdout=result.stdout.decode("utf-8"),
|
stage=stage,
|
||||||
stderr=result.stderr.decode("utf-8")
|
stdout=result.stdout.decode("utf-8"),
|
||||||
)
|
stderr=result.stderr.decode("utf-8"),
|
||||||
|
)
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
||||||
class DependencyStore:
|
class DependencyStore:
|
||||||
store: DependencyYAML = {
|
store: DependencyYAML = {"dependencies": {}}
|
||||||
"dependencies": {}
|
|
||||||
}
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def set(data: DependencyYAML):
|
def set(data: DependencyYAML):
|
||||||
DependencyStore.store = data
|
DependencyStore.store = data
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def update_dependency_version(path: str, version: str) -> DependencyYAML:
|
def update_dependency_version(path: str, version: str) -> DependencyYAML:
|
||||||
with CodeTimer(f"store deepcopy: {path}"):
|
with CodeTimer(f"store deepcopy: {path}"):
|
||||||
store_copy = deepcopy(DependencyStore.store)
|
store_copy = deepcopy(DependencyStore.store)
|
||||||
|
|
||||||
dependency = store_copy["dependencies"].get(path, {})
|
dependency = store_copy["dependencies"].get(path)
|
||||||
dependency["version"] = version
|
if dependency is None:
|
||||||
store_copy["dependencies"][path] = dependency
|
raise ValueError(f"Dependency {path} {version} not found")
|
||||||
|
dependency["version"] = version
|
||||||
|
store_copy["dependencies"][path] = dependency
|
||||||
|
|
||||||
return store_copy
|
return store_copy
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def write_store(file: str, data: DependencyYAML):
|
def write_store(file: str, data: DependencyYAML):
|
||||||
with open(file, "w") as yaml_file:
|
with open(file, "w") as yaml_file:
|
||||||
yaml.safe_dump(data, yaml_file, sort_keys=False)
|
yaml.safe_dump(data, yaml_file, sort_keys=False)
|
||||||
|
|
||||||
|
|
||||||
class Dependency:
|
class Dependency:
|
||||||
def __init__(self, path: str, values: DependencyDict):
|
def __init__(self, path: str, values: DependencyDict):
|
||||||
self.path = path
|
self.path = path
|
||||||
self.values = values
|
self.values = values
|
||||||
|
|
||||||
self.name: str = ""
|
self.name: str = ""
|
||||||
self.desc: str = ""
|
self.desc: str = ""
|
||||||
self.kind: str = ""
|
self.kind: str = ""
|
||||||
|
|
||||||
match path.split("/"):
|
match path.split("/"):
|
||||||
case ["plugins", name]:
|
case ["plugins", name]:
|
||||||
self.name = name
|
self.name = name
|
||||||
self.kind = "plugin"
|
self.kind = "plugin"
|
||||||
self.desc = f"{name} plugin"
|
self.desc = f"{name} plugin"
|
||||||
case ["themes", name]:
|
case ["themes", name]:
|
||||||
self.name = name.replace(".zsh-theme", "")
|
self.name = name.replace(".zsh-theme", "")
|
||||||
self.kind = "theme"
|
self.kind = "theme"
|
||||||
self.desc = f"{self.name} theme"
|
self.desc = f"{self.name} theme"
|
||||||
case _:
|
case _:
|
||||||
self.name = self.desc = path
|
self.name = self.desc = path
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
output: str = ""
|
output: str = ""
|
||||||
for key in DependencyDict.__dict__['__annotations__'].keys():
|
for key in DependencyDict.__dict__["__annotations__"].keys():
|
||||||
if key not in self.values:
|
if key not in self.values:
|
||||||
output += f"{key}: None\n"
|
output += f"{key}: None\n"
|
||||||
continue
|
continue
|
||||||
|
|
||||||
value = self.values[key]
|
value = self.values[key]
|
||||||
if "\n" not in value:
|
if "\n" not in value:
|
||||||
output += f"{key}: {value}\n"
|
output += f"{key}: {value}\n"
|
||||||
else:
|
else:
|
||||||
output += f"{key}:\n "
|
output += f"{key}:\n "
|
||||||
output += value.replace("\n", "\n ", value.count("\n") - 1)
|
output += value.replace("\n", "\n ", value.count("\n") - 1)
|
||||||
return output
|
return output
|
||||||
|
|
||||||
def update_or_notify(self):
|
def update_or_notify(self):
|
||||||
# Print dependency settings
|
# Print dependency settings
|
||||||
print(f"Processing {self.desc}...", file=sys.stderr)
|
print(f"Processing {self.desc}...", file=sys.stderr)
|
||||||
print(self, file=sys.stderr)
|
print(self, file=sys.stderr)
|
||||||
|
|
||||||
# Check for updates
|
# Check for updates
|
||||||
repo = self.values["repo"]
|
repo = self.values["repo"]
|
||||||
remote_branch = self.values["branch"]
|
remote_branch = self.values["branch"]
|
||||||
version = self.values["version"]
|
version = self.values["version"]
|
||||||
is_tag = version.startswith("tag:")
|
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
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# Create new branch
|
with CodeTimer(f"update check: {repo}"):
|
||||||
branch = Git.create_branch(self.path, new_version)
|
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
|
if status["has_updates"] is True:
|
||||||
self.__update_yaml(f"tag:{new_version}" if is_tag else status["version"])
|
short_sha = status["head_ref"][:8]
|
||||||
|
new_version = status["version"] if is_tag else short_sha
|
||||||
|
|
||||||
# Update dependency files
|
try:
|
||||||
self.__apply_upstream_changes()
|
branch_name = f"update/{self.path}/{new_version}"
|
||||||
|
|
||||||
# Add all changes and commit
|
# Create new branch
|
||||||
Git.add_and_commit(self.name, short_sha)
|
branch = Git.checkout_or_create_branch(branch_name)
|
||||||
|
|
||||||
# Push changes to remote
|
# Update dependencies.yml file
|
||||||
Git.push(branch)
|
self.__update_yaml(
|
||||||
|
f"tag:{new_version}" if is_tag else status["version"]
|
||||||
|
)
|
||||||
|
|
||||||
# Create GitHub PR
|
# Update dependency files
|
||||||
GitHub.create_pr(
|
self.__apply_upstream_changes()
|
||||||
branch,
|
|
||||||
f"feat({self.name}): update to version {new_version}",
|
# Add all changes and commit
|
||||||
f"""## Description
|
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']}).
|
Update for **{self.desc}**: update to version [{new_version}]({status['head_url']}).
|
||||||
Check out the [list of changes]({status['compare_url']}).
|
Check out the [list of changes]({status['compare_url']}).
|
||||||
"""
|
""",
|
||||||
)
|
)
|
||||||
|
|
||||||
# Clean up repository
|
# Clean up repository
|
||||||
Git.clean_repo()
|
Git.clean_repo()
|
||||||
except (CommandRunner.Exception, shutil.Error) as e:
|
except (CommandRunner.Exception, shutil.Error) as e:
|
||||||
# Handle exception on automatic update
|
# Handle exception on automatic update
|
||||||
match type(e):
|
match type(e):
|
||||||
case CommandRunner.Exception:
|
case CommandRunner.Exception:
|
||||||
# Print error message
|
# Print error message
|
||||||
print(f"Error running {e.stage} command: {e.returncode}", file=sys.stderr)
|
print(
|
||||||
print(e.stderr, file=sys.stderr)
|
f"Error running {e.stage} command: {e.returncode}", # pyright: ignore[reportAttributeAccessIssue]
|
||||||
case shutil.Error:
|
file=sys.stderr,
|
||||||
print(f"Error copying files: {e}", 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:
|
try:
|
||||||
Git.clean_repo()
|
Git.clean_repo()
|
||||||
except CommandRunner.Exception as e:
|
except CommandRunner.Exception as e:
|
||||||
print(f"Error reverting repository to clean state: {e}", file=sys.stderr)
|
print(
|
||||||
sys.exit(1)
|
f"Error reverting repository to clean state: {e}",
|
||||||
|
file=sys.stderr,
|
||||||
|
)
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
# Create a GitHub issue to notify maintainer
|
# Create a GitHub issue to notify maintainer
|
||||||
title = f"{self.path}: update to {new_version}"
|
title = f"{self.path}: update to {new_version}"
|
||||||
body = (
|
body = f"""## Description
|
||||||
f"""## Description
|
|
||||||
|
|
||||||
There is a new version of `{self.name}` {self.kind} available.
|
There is a new version of `{self.name}` {self.kind} available.
|
||||||
|
|
||||||
New version: [{new_version}]({status['head_url']})
|
New version: [{new_version}]({status['head_url']})
|
||||||
Check out the [list of changes]({status['compare_url']}).
|
Check out the [list of changes]({status['compare_url']}).
|
||||||
"""
|
"""
|
||||||
)
|
|
||||||
|
|
||||||
print(f"Creating GitHub issue", file=sys.stderr)
|
print("Creating GitHub issue", file=sys.stderr)
|
||||||
print(f"{title}\n\n{body}", file=sys.stderr)
|
print(f"{title}\n\n{body}", file=sys.stderr)
|
||||||
GitHub.create_issue(title, body)
|
GitHub.create_issue(title, body)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(e, file=sys.stderr)
|
print(e, file=sys.stderr)
|
||||||
|
|
||||||
def __update_yaml(self, new_version: str) -> None:
|
def __update_yaml(self, new_version: str) -> None:
|
||||||
dep_yaml = DependencyStore.update_dependency_version(self.path, new_version)
|
dep_yaml = DependencyStore.update_dependency_version(self.path, new_version)
|
||||||
DependencyStore.write_store(DEPS_YAML_FILE, dep_yaml)
|
DependencyStore.write_store(DEPS_YAML_FILE, dep_yaml)
|
||||||
|
|
||||||
def __apply_upstream_changes(self) -> None:
|
def __apply_upstream_changes(self) -> None:
|
||||||
# Patterns to ignore in copying files from upstream repo
|
# Patterns to ignore in copying files from upstream repo
|
||||||
GLOBAL_IGNORE = [
|
GLOBAL_IGNORE = [".git", ".github", ".gitignore"]
|
||||||
".git",
|
|
||||||
".github",
|
|
||||||
".gitignore"
|
|
||||||
]
|
|
||||||
|
|
||||||
path = os.path.abspath(self.path)
|
path = os.path.abspath(self.path)
|
||||||
precopy = self.values.get("precopy")
|
precopy = self.values.get("precopy")
|
||||||
postcopy = self.values.get("postcopy")
|
postcopy = self.values.get("postcopy")
|
||||||
|
|
||||||
repo = self.values["repo"]
|
repo = self.values["repo"]
|
||||||
branch = self.values["branch"]
|
branch = self.values["branch"]
|
||||||
remote_url = f"https://github.com/{repo}.git"
|
remote_url = f"https://github.com/{repo}.git"
|
||||||
repo_dir = os.path.join(TMP_DIR, repo)
|
repo_dir = os.path.join(TMP_DIR, repo)
|
||||||
|
|
||||||
# Clone repository
|
# Clone repository
|
||||||
Git.clone(remote_url, branch, repo_dir, reclone=True)
|
Git.clone(remote_url, branch, repo_dir, reclone=True)
|
||||||
|
|
||||||
# Run precopy on tmp repo
|
# Run precopy on tmp repo
|
||||||
if precopy is not None:
|
if precopy is not None:
|
||||||
print("Running precopy script:", end="\n ", file=sys.stderr)
|
print("Running precopy script:", end="\n ", file=sys.stderr)
|
||||||
print(precopy.replace("\n", "\n ", precopy.count("\n") - 1), file=sys.stderr)
|
print(
|
||||||
CommandRunner.run_or_fail(["bash", "-c", precopy], cwd=repo_dir, stage="Precopy")
|
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
|
# Copy files from upstream repo
|
||||||
print(f"Copying files from {repo_dir} to {path}", file=sys.stderr)
|
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))
|
shutil.copytree(
|
||||||
|
repo_dir,
|
||||||
|
path,
|
||||||
|
dirs_exist_ok=True,
|
||||||
|
ignore=shutil.ignore_patterns(*GLOBAL_IGNORE),
|
||||||
|
)
|
||||||
|
|
||||||
# Run postcopy on our repository
|
# Run postcopy on our repository
|
||||||
if postcopy is not None:
|
if postcopy is not None:
|
||||||
print("Running postcopy script:", end="\n ", file=sys.stderr)
|
print("Running postcopy script:", end="\n ", file=sys.stderr)
|
||||||
print(postcopy.replace("\n", "\n ", postcopy.count("\n") - 1), file=sys.stderr)
|
print(
|
||||||
CommandRunner.run_or_fail(["bash", "-c", postcopy], cwd=path, stage="Postcopy")
|
postcopy.replace("\n", "\n ", postcopy.count("\n") - 1),
|
||||||
|
file=sys.stderr,
|
||||||
|
)
|
||||||
|
CommandRunner.run_or_fail(
|
||||||
|
["bash", "-c", postcopy], cwd=path, stage="Postcopy"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class Git:
|
class Git:
|
||||||
default_branch = "master"
|
default_branch = "master"
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def clone(remote_url: str, branch: str, repo_dir: str, reclone=False):
|
def clone(remote_url: str, branch: str, repo_dir: str, reclone=False):
|
||||||
# If repo needs to be fresh
|
# If repo needs to be fresh
|
||||||
if reclone and os.path.exists(repo_dir):
|
if reclone and os.path.exists(repo_dir):
|
||||||
shutil.rmtree(repo_dir)
|
shutil.rmtree(repo_dir)
|
||||||
|
|
||||||
# Clone repo in tmp directory and checkout branch
|
# Clone repo in tmp directory and checkout branch
|
||||||
if not os.path.exists(repo_dir):
|
if not os.path.exists(repo_dir):
|
||||||
print(f"Cloning {remote_url} to {repo_dir} and checking out {branch}", file=sys.stderr)
|
print(
|
||||||
CommandRunner.run_or_fail(["git", "clone", "--depth=1", "-b", branch, remote_url, repo_dir], stage="Clone")
|
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
|
@staticmethod
|
||||||
def create_branch(path: str, version: str):
|
def checkout_or_create_branch(branch_name: str):
|
||||||
# Get current branch name
|
# Get current branch name
|
||||||
result = CommandRunner.run_or_fail(["git", "rev-parse", "--abbrev-ref", "HEAD"], stage="GetDefaultBranch")
|
result = CommandRunner.run_or_fail(
|
||||||
Git.default_branch = result.stdout.decode("utf-8").strip()
|
["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
|
# Create new branch and return created branch name
|
||||||
branch_name = f"update/{path}/{version}"
|
try:
|
||||||
CommandRunner.run_or_fail(["git", "checkout", "-b", branch_name], stage="CreateBranch")
|
# try to checkout already existing branch
|
||||||
return branch_name
|
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
|
@staticmethod
|
||||||
def add_and_commit(scope: str, version: str):
|
def add_and_commit(scope: str, version: str) -> bool:
|
||||||
user_name = os.environ.get("GIT_APP_NAME")
|
"""
|
||||||
user_email = os.environ.get("GIT_APP_EMAIL")
|
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
|
user_name = os.environ.get("GIT_APP_NAME")
|
||||||
CommandRunner.run_or_fail(["git", "add", "-A", "-v"], stage="AddFiles")
|
user_email = os.environ.get("GIT_APP_EMAIL")
|
||||||
|
|
||||||
# Reset environment and git config
|
# Add all files to git staging
|
||||||
clean_env = os.environ.copy()
|
CommandRunner.run_or_fail(["git", "add", "-A", "-v"], stage="AddFiles")
|
||||||
clean_env["LANG"]="C.UTF-8"
|
|
||||||
clean_env["GIT_CONFIG_GLOBAL"]="/dev/null"
|
|
||||||
clean_env["GIT_CONFIG_NOSYSTEM"]="1"
|
|
||||||
|
|
||||||
# Commit with settings above
|
# Reset environment and git config
|
||||||
CommandRunner.run_or_fail([
|
clean_env = os.environ.copy()
|
||||||
"git",
|
clean_env["LANG"] = "C.UTF-8"
|
||||||
"-c", f"user.name={user_name}",
|
clean_env["GIT_CONFIG_GLOBAL"] = "/dev/null"
|
||||||
"-c", f"user.email={user_email}",
|
clean_env["GIT_CONFIG_NOSYSTEM"] = "1"
|
||||||
"commit",
|
|
||||||
"-m", f"feat({scope}): update to {version}"
|
|
||||||
], stage="CreateCommit", env=clean_env)
|
|
||||||
|
|
||||||
@staticmethod
|
# Commit with settings above
|
||||||
def push(branch: str):
|
CommandRunner.run_or_fail(
|
||||||
CommandRunner.run_or_fail(["git", "push", "-u", "origin", branch], stage="PushBranch")
|
[
|
||||||
|
"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
|
@staticmethod
|
||||||
def clean_repo():
|
def push(branch: str):
|
||||||
CommandRunner.run_or_fail(["git", "reset", "--hard", "HEAD"], stage="ResetRepository")
|
CommandRunner.run_or_fail(
|
||||||
CommandRunner.run_or_fail(["git", "checkout", Git.default_branch], stage="CheckoutDefaultBranch")
|
["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:
|
class GitHub:
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def check_newer_tag(repo, current_tag) -> UpdateStatus:
|
def check_newer_tag(repo, current_tag) -> UpdateStatusFalse | UpdateStatusTrue:
|
||||||
# GET /repos/:owner/:repo/git/refs/tags
|
# GET /repos/:owner/:repo/git/refs/tags
|
||||||
url = f"https://api.github.com/repos/{repo}/git/refs/tags"
|
url = f"https://api.github.com/repos/{repo}/git/refs/tags"
|
||||||
|
|
||||||
# Send a GET request to the GitHub API
|
# Send a GET request to the GitHub API
|
||||||
response = requests.get(url)
|
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 the request was successful
|
||||||
if response.status_code == 200:
|
if response.status_code == 200:
|
||||||
# Parse the JSON response
|
# Parse the JSON response
|
||||||
data = response.json()
|
data = response.json()
|
||||||
|
|
||||||
if len(data) == 0:
|
if len(data) == 0:
|
||||||
return {
|
return {
|
||||||
"has_updates": False,
|
"has_updates": False,
|
||||||
}
|
}
|
||||||
|
|
||||||
latest_ref = data[-1]
|
latest_ref = None
|
||||||
latest_tag = latest_ref["ref"].replace("refs/tags/", "")
|
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:
|
# raise if no valid semver tag is found
|
||||||
return {
|
if latest_ref is None or latest_version is None:
|
||||||
"has_updates": False,
|
raise ValueError(f"No tags following semver found in {repo}")
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
# we get the tag since GitHub returns it as plain git ref
|
||||||
"has_updates": True,
|
latest_tag = latest_ref["ref"].replace("refs/tags/", "")
|
||||||
"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()}")
|
|
||||||
|
|
||||||
@staticmethod
|
if latest_version.compare(current_version) <= 0:
|
||||||
def check_updates(repo, branch, version) -> UpdateStatus:
|
return {
|
||||||
# TODO: add support for semver updating (based on tags)
|
"has_updates": False,
|
||||||
# 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}"
|
|
||||||
|
|
||||||
# Send a GET request to the GitHub API
|
return {
|
||||||
response = requests.get(url)
|
"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
|
@staticmethod
|
||||||
if response.status_code == 200:
|
def check_updates(repo, branch, version) -> UpdateStatusFalse | UpdateStatusTrue:
|
||||||
# Parse the JSON response
|
url = f"https://api.github.com/repos/{repo}/compare/{version}...{branch}"
|
||||||
data = response.json()
|
|
||||||
|
|
||||||
# If the base is behind the head, there is a newer version
|
# Send a GET request to the GitHub API
|
||||||
has_updates = data["status"] != "identical"
|
response = requests.get(url)
|
||||||
|
|
||||||
if not has_updates:
|
# If the request was successful
|
||||||
return {
|
if response.status_code == 200:
|
||||||
"has_updates": False,
|
# Parse the JSON response
|
||||||
}
|
data = response.json()
|
||||||
|
|
||||||
return {
|
# If the base is behind the head, there is a newer version
|
||||||
"has_updates": data["status"] != "identical",
|
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
|
if not has_updates:
|
||||||
def create_issue(title: str, body: str) -> None:
|
return {
|
||||||
cmd = [
|
"has_updates": False,
|
||||||
"gh",
|
}
|
||||||
"issue",
|
|
||||||
"create",
|
|
||||||
"-t", title,
|
|
||||||
"-b", body
|
|
||||||
]
|
|
||||||
CommandRunner.run_or_fail(cmd, stage="CreateIssue")
|
|
||||||
|
|
||||||
@staticmethod
|
return {
|
||||||
def create_pr(branch: str, title: str, body: str) -> None:
|
"has_updates": data["status"] != "identical",
|
||||||
cmd = [
|
"version": data["commits"][-1]["sha"],
|
||||||
"gh",
|
"compare_url": data["permalink_url"],
|
||||||
"pr",
|
"head_ref": data["commits"][-1]["sha"],
|
||||||
"create",
|
"head_url": data["commits"][-1]["html_url"],
|
||||||
"-B", Git.default_branch,
|
}
|
||||||
"-H", branch,
|
else:
|
||||||
"-t", title,
|
# If the request was not successful, raise an exception
|
||||||
"-b", body
|
raise Exception(
|
||||||
]
|
f"GitHub API request failed with status code {response.status_code}: {response.json()}"
|
||||||
CommandRunner.run_or_fail(cmd, stage="CreatePullRequest")
|
)
|
||||||
|
|
||||||
|
@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():
|
def main():
|
||||||
# Load the YAML file
|
# Load the YAML file
|
||||||
with open(DEPS_YAML_FILE, "r") as yaml_file:
|
with open(DEPS_YAML_FILE, "r") as yaml_file:
|
||||||
data: DependencyYAML = yaml.safe_load(yaml_file)
|
data: DependencyYAML = yaml.safe_load(yaml_file)
|
||||||
|
|
||||||
if "dependencies" not in data:
|
if "dependencies" not in data:
|
||||||
raise Exception(f"dependencies.yml not properly formatted")
|
raise Exception("dependencies.yml not properly formatted")
|
||||||
|
|
||||||
# Cache YAML version
|
# Cache YAML version
|
||||||
DependencyStore.set(data)
|
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__":
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
||||||
|
|
|
||||||
4
.github/workflows/installer.yml
vendored
4
.github/workflows/installer.yml
vendored
|
|
@ -26,7 +26,7 @@ jobs:
|
||||||
- macos-latest
|
- macos-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Set up git repository
|
- name: Set up git repository
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v4
|
||||||
- name: Install zsh
|
- name: Install zsh
|
||||||
if: runner.os == 'Linux'
|
if: runner.os == 'Linux'
|
||||||
run: sudo apt-get update; sudo apt-get install zsh
|
run: sudo apt-get update; sudo apt-get install zsh
|
||||||
|
|
@ -42,7 +42,7 @@ jobs:
|
||||||
- test
|
- test
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v4
|
||||||
- name: Install Vercel CLI
|
- name: Install Vercel CLI
|
||||||
run: npm install -g vercel
|
run: npm install -g vercel
|
||||||
- name: Setup project and deploy
|
- name: Setup project and deploy
|
||||||
|
|
|
||||||
2
.github/workflows/main.yml
vendored
2
.github/workflows/main.yml
vendored
|
|
@ -24,7 +24,7 @@ jobs:
|
||||||
if: github.repository == 'ohmyzsh/ohmyzsh'
|
if: github.repository == 'ohmyzsh/ohmyzsh'
|
||||||
steps:
|
steps:
|
||||||
- name: Set up git repository
|
- name: Set up git repository
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v4
|
||||||
- name: Install zsh
|
- name: Install zsh
|
||||||
run: sudo apt-get update; sudo apt-get install zsh
|
run: sudo apt-get update; sudo apt-get install zsh
|
||||||
- name: Check syntax
|
- name: Check syntax
|
||||||
|
|
|
||||||
24
README.md
24
README.md
|
|
@ -43,6 +43,7 @@ To learn more, visit [ohmyz.sh](https://ohmyz.sh), follow [@ohmyzsh](https://twi
|
||||||
- [Custom Plugins And Themes](#custom-plugins-and-themes)
|
- [Custom Plugins And Themes](#custom-plugins-and-themes)
|
||||||
- [Enable GNU ls In macOS And freeBSD Systems](#enable-gnu-ls-in-macos-and-freebsd-systems)
|
- [Enable GNU ls In macOS And freeBSD Systems](#enable-gnu-ls-in-macos-and-freebsd-systems)
|
||||||
- [Skip Aliases](#skip-aliases)
|
- [Skip Aliases](#skip-aliases)
|
||||||
|
- [Disable async git prompt](#disable-async-git-prompt)
|
||||||
- [Getting Updates](#getting-updates)
|
- [Getting Updates](#getting-updates)
|
||||||
- [Updates Verbosity](#updates-verbosity)
|
- [Updates Verbosity](#updates-verbosity)
|
||||||
- [Manual Updates](#manual-updates)
|
- [Manual Updates](#manual-updates)
|
||||||
|
|
@ -88,7 +89,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)"` |
|
| **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)"` |
|
| **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 |
|
| Method | Command |
|
||||||
| :-------- | :------------------------------------------------------------------------------------------------ |
|
| :-------- | :------------------------------------------------------------------------------------------------ |
|
||||||
|
|
@ -234,7 +235,7 @@ If you're in China, India, or another country that blocks `raw.githubusercontent
|
||||||
|
|
||||||
#### Installing From A Forked Repository
|
#### 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
|
- `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}`.
|
this variable, the installer will look for a repository at `https://github.com/{owner}/{repository}`.
|
||||||
|
|
@ -308,7 +309,7 @@ If you would like to override the functionality of a plugin distributed with Oh
|
||||||
|
|
||||||
<a name="enable-gnu-ls"></a>
|
<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
|
(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`:
|
sourcing `oh-my-zsh.sh`:
|
||||||
|
|
||||||
|
|
@ -341,7 +342,7 @@ zstyle ':omz:plugins:*' aliases no
|
||||||
zstyle ':omz:plugins:git' 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
|
```sh
|
||||||
# Skip all plugin aliases, except for the git plugin
|
# Skip all plugin aliases, except for the git plugin
|
||||||
|
|
@ -361,6 +362,17 @@ Instead, you can now use the following:
|
||||||
zstyle ':omz:lib:directories' aliases no
|
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
|
||||||
|
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
|
||||||
|
```
|
||||||
|
|
||||||
#### Notice <!-- omit in toc -->
|
#### Notice <!-- omit in toc -->
|
||||||
|
|
||||||
> This feature is currently in a testing phase and it may be subject to change in the future.
|
> This feature is currently in a testing phase and it may be subject to change in the future.
|
||||||
|
|
@ -449,6 +461,10 @@ Oh My Zsh has a vibrant community of happy users and delightful contributors. Wi
|
||||||
|
|
||||||
Thank you so much!
|
Thank you so much!
|
||||||
|
|
||||||
|
<a href="https://github.com/ohmyzsh/ohmyzsh/graphs/contributors">
|
||||||
|
<img src="https://contrib.rocks/image?repo=ohmyzsh/ohmyzsh" width="100%"/>
|
||||||
|
</a>
|
||||||
|
|
||||||
## Follow Us
|
## Follow Us
|
||||||
|
|
||||||
We're on social media:
|
We're on social media:
|
||||||
|
|
|
||||||
144
lib/async_prompt.zsh
Normal file
144
lib/async_prompt.zsh
Normal file
|
|
@ -0,0 +1,144 @@
|
||||||
|
# The async code is taken from
|
||||||
|
# https://github.com/zsh-users/zsh-autosuggestions/blob/master/src/async.zsh
|
||||||
|
# https://github.com/woefe/git-prompt.zsh/blob/master/git-prompt.zsh
|
||||||
|
|
||||||
|
zmodload zsh/system
|
||||||
|
autoload -Uz is-at-least
|
||||||
|
|
||||||
|
# For now, async prompt function handlers are set up like so:
|
||||||
|
# First, define the async function handler and register the handler
|
||||||
|
# with _omz_register_handler:
|
||||||
|
#
|
||||||
|
# function _git_prompt_status_async {
|
||||||
|
# # Do some expensive operation that outputs to stdout
|
||||||
|
# }
|
||||||
|
# _omz_register_handler _git_prompt_status_async
|
||||||
|
#
|
||||||
|
# Then add a stub prompt function in `$PROMPT` or similar prompt variables,
|
||||||
|
# which will show the output of "$_OMZ_ASYNC_OUTPUT[handler_name]":
|
||||||
|
#
|
||||||
|
# function git_prompt_status {
|
||||||
|
# echo -n $_OMZ_ASYNC_OUTPUT[_git_prompt_status_async]
|
||||||
|
# }
|
||||||
|
#
|
||||||
|
# RPROMPT='$(git_prompt_status)'
|
||||||
|
#
|
||||||
|
# This API is subject to change and optimization. Rely on it at your own risk.
|
||||||
|
|
||||||
|
function _omz_register_handler {
|
||||||
|
setopt localoptions noksharrays
|
||||||
|
typeset -ga _omz_async_functions
|
||||||
|
# we want to do nothing if there's no $1 function or we already set it up
|
||||||
|
if [[ -z "$1" ]] || (( ! ${+functions[$1]} )) \
|
||||||
|
|| (( ${_omz_async_functions[(Ie)$1]} )); then
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
_omz_async_functions+=("$1")
|
||||||
|
# let's add the hook to async_request if it's not there yet
|
||||||
|
if (( ! ${precmd_functions[(Ie)_omz_async_request]} )) \
|
||||||
|
&& (( ${+functions[_omz_async_request]})); then
|
||||||
|
autoload -Uz add-zsh-hook
|
||||||
|
add-zsh-hook precmd _omz_async_request
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Set up async handlers and callbacks
|
||||||
|
function _omz_async_request {
|
||||||
|
local -i ret=$?
|
||||||
|
typeset -gA _OMZ_ASYNC_FDS _OMZ_ASYNC_PIDS _OMZ_ASYNC_OUTPUT
|
||||||
|
|
||||||
|
# executor runs a subshell for all async requests based on key
|
||||||
|
local handler
|
||||||
|
for handler in ${_omz_async_functions}; do
|
||||||
|
(( ${+functions[$handler]} )) || continue
|
||||||
|
|
||||||
|
local fd=${_OMZ_ASYNC_FDS[$handler]:--1}
|
||||||
|
local pid=${_OMZ_ASYNC_PIDS[$handler]:--1}
|
||||||
|
|
||||||
|
# If we've got a pending request, cancel it
|
||||||
|
if (( fd != -1 && pid != -1 )) && { true <&$fd } 2>/dev/null; then
|
||||||
|
# Close the file descriptor and remove the handler
|
||||||
|
exec {fd}<&-
|
||||||
|
zle -F $fd
|
||||||
|
|
||||||
|
# Zsh will make a new process group for the child process only if job
|
||||||
|
# control is enabled (MONITOR option)
|
||||||
|
if [[ -o MONITOR ]]; then
|
||||||
|
# Send the signal to the process group to kill any processes that may
|
||||||
|
# have been forked by the async function handler
|
||||||
|
kill -TERM -$pid 2>/dev/null
|
||||||
|
else
|
||||||
|
# Kill just the child process since it wasn't placed in a new process
|
||||||
|
# group. If the async function handler forked any child processes they may
|
||||||
|
# be orphaned and left behind.
|
||||||
|
kill -TERM $pid 2>/dev/null
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Define global variables to store the file descriptor, PID and output
|
||||||
|
_OMZ_ASYNC_FDS[$handler]=-1
|
||||||
|
_OMZ_ASYNC_PIDS[$handler]=-1
|
||||||
|
|
||||||
|
# Fork a process to fetch the git status and open a pipe to read from it
|
||||||
|
exec {fd}< <(
|
||||||
|
# Tell parent process our PID
|
||||||
|
builtin echo ${sysparams[pid]}
|
||||||
|
# Set exit code for the handler if used
|
||||||
|
() { return $ret }
|
||||||
|
# Run the async function handler
|
||||||
|
$handler
|
||||||
|
)
|
||||||
|
|
||||||
|
# Save FD for handler
|
||||||
|
_OMZ_ASYNC_FDS[$handler]=$fd
|
||||||
|
|
||||||
|
# There's a weird bug here where ^C stops working unless we force a fork
|
||||||
|
# See https://github.com/zsh-users/zsh-autosuggestions/issues/364
|
||||||
|
# and https://github.com/zsh-users/zsh-autosuggestions/pull/612
|
||||||
|
is-at-least 5.8 || command true
|
||||||
|
|
||||||
|
# Save the PID from the handler child process
|
||||||
|
read -u $fd "_OMZ_ASYNC_PIDS[$handler]"
|
||||||
|
|
||||||
|
# When the fd is readable, call the response handler
|
||||||
|
zle -F "$fd" _omz_async_callback
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
# Called when new data is ready to be read from the pipe
|
||||||
|
function _omz_async_callback() {
|
||||||
|
emulate -L zsh
|
||||||
|
|
||||||
|
local fd=$1 # First arg will be fd ready for reading
|
||||||
|
local err=$2 # Second arg will be passed in case of error
|
||||||
|
|
||||||
|
if [[ -z "$err" || "$err" == "hup" ]]; then
|
||||||
|
# Get handler name from fd
|
||||||
|
local handler="${(k)_OMZ_ASYNC_FDS[(r)$fd]}"
|
||||||
|
|
||||||
|
# Store old output which is supposed to be already printed
|
||||||
|
local old_output="${_OMZ_ASYNC_OUTPUT[$handler]}"
|
||||||
|
|
||||||
|
# Read output from fd
|
||||||
|
IFS= read -r -u $fd -d '' "_OMZ_ASYNC_OUTPUT[$handler]"
|
||||||
|
|
||||||
|
# Repaint prompt if output has changed
|
||||||
|
if [[ "$old_output" != "${_OMZ_ASYNC_OUTPUT[$handler]}" ]]; then
|
||||||
|
zle .reset-prompt
|
||||||
|
zle -R
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Close the fd
|
||||||
|
exec {fd}<&-
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Always remove the handler
|
||||||
|
zle -F "$fd"
|
||||||
|
|
||||||
|
# Unset global FD variable to prevent closing user created FDs in the precmd hook
|
||||||
|
_OMZ_ASYNC_FDS[$handler]=-1
|
||||||
|
_OMZ_ASYNC_PIDS[$handler]=-1
|
||||||
|
}
|
||||||
|
|
||||||
|
autoload -Uz add-zsh-hook
|
||||||
|
add-zsh-hook precmd _omz_async_request
|
||||||
28
lib/cli.zsh
28
lib/cli.zsh
|
|
@ -241,10 +241,18 @@ function _omz::plugin::disable {
|
||||||
|
|
||||||
# Remove plugins substitution awk script
|
# Remove plugins substitution awk script
|
||||||
local awk_subst_plugins="\
|
local awk_subst_plugins="\
|
||||||
gsub(/[ \t]+(${(j:|:)dis_plugins})/, \"\") # with spaces before
|
gsub(/[ \t]+(${(j:|:)dis_plugins})[ \t]+/, \" \") # with spaces before or after
|
||||||
gsub(/(${(j:|:)dis_plugins})[ \t]+/, \"\") # with spaces after
|
gsub(/[ \t]+(${(j:|:)dis_plugins})$/, \"\") # with spaces before and EOL
|
||||||
gsub(/\((${(j:|:)dis_plugins})\)/, \"\") # without spaces (only plugin)
|
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
|
# Disable plugins awk script
|
||||||
local awk_script="
|
local awk_script="
|
||||||
# if plugins=() is in oneline form, substitute disabled plugins and go to next line
|
# if plugins=() is in oneline form, substitute disabled plugins and go to next line
|
||||||
|
|
@ -448,7 +456,7 @@ function _omz::plugin::load {
|
||||||
if [[ ! -f "$base/_$plugin" && ! -f "$base/$plugin.plugin.zsh" ]]; then
|
if [[ ! -f "$base/_$plugin" && ! -f "$base/$plugin.plugin.zsh" ]]; then
|
||||||
_omz::log warn "'$plugin' is not a valid plugin"
|
_omz::log warn "'$plugin' is not a valid plugin"
|
||||||
continue
|
continue
|
||||||
# It it is a valid plugin, add its directory to $fpath unless it is already there
|
# It is a valid plugin, add its directory to $fpath unless it is already there
|
||||||
elif (( ! ${fpath[(Ie)$base]} )); then
|
elif (( ! ${fpath[(Ie)$base]} )); then
|
||||||
fpath=("$base" $fpath)
|
fpath=("$base" $fpath)
|
||||||
fi
|
fi
|
||||||
|
|
@ -773,7 +781,17 @@ function _omz::theme::use {
|
||||||
}
|
}
|
||||||
|
|
||||||
function _omz::update {
|
function _omz::update {
|
||||||
local last_commit=$(builtin cd -q "$ZSH"; git rev-parse HEAD)
|
# Check if git command is available
|
||||||
|
(( $+commands[git] )) || {
|
||||||
|
_omz::log error "git is not installed. Aborting..."
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
|
local last_commit=$(builtin cd -q "$ZSH"; git rev-parse HEAD 2>/dev/null)
|
||||||
|
[[ $? -eq 0 ]] || {
|
||||||
|
_omz::log error "\`$ZSH\` is not a git directory. Aborting..."
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
# Run update script
|
# Run update script
|
||||||
zstyle -s ':omz:update' verbose verbose_mode || verbose_mode=default
|
zstyle -s ':omz:update' verbose verbose_mode || verbose_mode=default
|
||||||
|
|
|
||||||
|
|
@ -49,7 +49,7 @@ zstyle ':completion:*:*:*:users' ignored-patterns \
|
||||||
adm amanda apache at avahi avahi-autoipd beaglidx bin cacti canna \
|
adm amanda apache at avahi avahi-autoipd beaglidx bin cacti canna \
|
||||||
clamav daemon dbus distcache dnsmasq dovecot fax ftp games gdm \
|
clamav daemon dbus distcache dnsmasq dovecot fax ftp games gdm \
|
||||||
gkrellmd gopher hacluster haldaemon halt hsqldb ident junkbust kdm \
|
gkrellmd gopher hacluster haldaemon halt hsqldb ident junkbust kdm \
|
||||||
ldap lp mail mailman mailnull man messagebus mldonkey mysql nagios \
|
ldap lp mail mailman mailnull man messagebus mldonkey mysql nagios \
|
||||||
named netdump news nfsnobody nobody nscd ntp nut nx obsrun openvpn \
|
named netdump news nfsnobody nobody nscd ntp nut nx obsrun openvpn \
|
||||||
operator pcap polkitd postfix postgres privoxy pulse pvm quagga radvd \
|
operator pcap polkitd postfix postgres privoxy pulse pvm quagga radvd \
|
||||||
rpc rpcuser rpm rtkit scard shutdown squid sshd statd svn sync tftp \
|
rpc rpcuser rpm rtkit scard shutdown squid sshd statd svn sync tftp \
|
||||||
|
|
|
||||||
58
lib/git.zsh
58
lib/git.zsh
|
|
@ -1,3 +1,5 @@
|
||||||
|
autoload -Uz is-at-least
|
||||||
|
|
||||||
# The git prompt's git commands are read-only and should not interfere with
|
# The git prompt's git commands are read-only and should not interfere with
|
||||||
# other processes. This environment variable is equivalent to running with `git
|
# other processes. This environment variable is equivalent to running with `git
|
||||||
# --no-optional-locks`, but falls back gracefully for older versions of git.
|
# --no-optional-locks`, but falls back gracefully for older versions of git.
|
||||||
|
|
@ -9,14 +11,18 @@ function __git_prompt_git() {
|
||||||
GIT_OPTIONAL_LOCKS=0 command git "$@"
|
GIT_OPTIONAL_LOCKS=0 command git "$@"
|
||||||
}
|
}
|
||||||
|
|
||||||
function git_prompt_info() {
|
function _omz_git_prompt_info() {
|
||||||
# If we are on a folder not tracked by git, get out.
|
# If we are on a folder not tracked by git, get out.
|
||||||
# Otherwise, check for hide-info at global and local repository level
|
# Otherwise, check for hide-info at global and local repository level
|
||||||
if ! __git_prompt_git rev-parse --git-dir &> /dev/null \
|
if ! __git_prompt_git rev-parse --git-dir &> /dev/null \
|
||||||
|| [[ "$(__git_prompt_git config --get oh-my-zsh.hide-info 2>/dev/null)" == 1 ]]; then
|
|| [[ "$(__git_prompt_git config --get oh-my-zsh.hide-info 2>/dev/null)" == 1 ]]; then
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Get either:
|
||||||
|
# - the current branch name
|
||||||
|
# - the tag name if we are on a tag
|
||||||
|
# - the short SHA of the current commit
|
||||||
local ref
|
local ref
|
||||||
ref=$(__git_prompt_git symbolic-ref --short HEAD 2> /dev/null) \
|
ref=$(__git_prompt_git symbolic-ref --short HEAD 2> /dev/null) \
|
||||||
|| ref=$(__git_prompt_git describe --tags --exact-match HEAD 2> /dev/null) \
|
|| ref=$(__git_prompt_git describe --tags --exact-match HEAD 2> /dev/null) \
|
||||||
|
|
@ -33,6 +39,52 @@ function git_prompt_info() {
|
||||||
echo "${ZSH_THEME_GIT_PROMPT_PREFIX}${ref:gs/%/%%}${upstream:gs/%/%%}$(parse_git_dirty)${ZSH_THEME_GIT_PROMPT_SUFFIX}"
|
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
|
||||||
|
function git_prompt_info() {
|
||||||
|
if [[ -n "${_OMZ_ASYNC_OUTPUT[_omz_git_prompt_info]}" ]]; then
|
||||||
|
echo -n "${_OMZ_ASYNC_OUTPUT[_omz_git_prompt_info]}"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
function git_prompt_status() {
|
||||||
|
if [[ -n "${_OMZ_ASYNC_OUTPUT[_omz_git_prompt_status]}" ]]; then
|
||||||
|
echo -n "${_OMZ_ASYNC_OUTPUT[_omz_git_prompt_status]}"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Conditionally register the async handler, only if it's needed in $PROMPT
|
||||||
|
# or any of the other prompt variables
|
||||||
|
function _defer_async_git_register() {
|
||||||
|
# Check if git_prompt_info is used in a prompt variable
|
||||||
|
case "${PS1}:${PS2}:${PS3}:${PS4}:${RPROMPT}:${RPS1}:${RPS2}:${RPS3}:${RPS4}" in
|
||||||
|
*(\$\(git_prompt_info\)|\`git_prompt_info\`)*)
|
||||||
|
_omz_register_handler _omz_git_prompt_info
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
case "${PS1}:${PS2}:${PS3}:${PS4}:${RPROMPT}:${RPS1}:${RPS2}:${RPS3}:${RPS4}" in
|
||||||
|
*(\$\(git_prompt_status\)|\`git_prompt_status\`)*)
|
||||||
|
_omz_register_handler _omz_git_prompt_status
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
add-zsh-hook -d precmd _defer_async_git_register
|
||||||
|
unset -f _defer_async_git_register
|
||||||
|
}
|
||||||
|
|
||||||
|
# Register the async handler first. This needs to be done before
|
||||||
|
# the async request prompt is run
|
||||||
|
precmd_functions=(_defer_async_git_register $precmd_functions)
|
||||||
|
else
|
||||||
|
function git_prompt_info() {
|
||||||
|
_omz_git_prompt_info
|
||||||
|
}
|
||||||
|
function git_prompt_status() {
|
||||||
|
_omz_git_prompt_status
|
||||||
|
}
|
||||||
|
fi
|
||||||
|
|
||||||
# Checks if working tree is dirty
|
# Checks if working tree is dirty
|
||||||
function parse_git_dirty() {
|
function parse_git_dirty() {
|
||||||
local STATUS
|
local STATUS
|
||||||
|
|
@ -161,7 +213,7 @@ function git_prompt_long_sha() {
|
||||||
SHA=$(__git_prompt_git rev-parse HEAD 2> /dev/null) && echo "$ZSH_THEME_GIT_PROMPT_SHA_BEFORE$SHA$ZSH_THEME_GIT_PROMPT_SHA_AFTER"
|
SHA=$(__git_prompt_git rev-parse HEAD 2> /dev/null) && echo "$ZSH_THEME_GIT_PROMPT_SHA_BEFORE$SHA$ZSH_THEME_GIT_PROMPT_SHA_AFTER"
|
||||||
}
|
}
|
||||||
|
|
||||||
function git_prompt_status() {
|
function _omz_git_prompt_status() {
|
||||||
[[ "$(__git_prompt_git config --get oh-my-zsh.hide-status 2>/dev/null)" = 1 ]] && return
|
[[ "$(__git_prompt_git config --get oh-my-zsh.hide-status 2>/dev/null)" = 1 ]] && return
|
||||||
|
|
||||||
# Maps a git status prefix to an internal constant
|
# Maps a git status prefix to an internal constant
|
||||||
|
|
|
||||||
|
|
@ -1,19 +1,20 @@
|
||||||
## History wrapper
|
## History wrapper
|
||||||
function omz_history {
|
function omz_history {
|
||||||
local clear list
|
# parse arguments and remove from $@
|
||||||
zparseopts -E c=clear l=list
|
local clear list stamp
|
||||||
|
zparseopts -E -D c=clear l=list f=stamp E=stamp i=stamp t:=stamp
|
||||||
|
|
||||||
if [[ -n "$clear" ]]; then
|
if [[ -n "$clear" ]]; then
|
||||||
# if -c provided, clobber the history file
|
# if -c provided, clobber the history file
|
||||||
echo -n >| "$HISTFILE"
|
echo -n >| "$HISTFILE"
|
||||||
fc -p "$HISTFILE"
|
fc -p "$HISTFILE"
|
||||||
echo >&2 History file deleted.
|
echo >&2 History file deleted.
|
||||||
elif [[ -n "$list" ]]; then
|
elif [[ $# -eq 0 ]]; then
|
||||||
# if -l provided, run as if calling `fc' directly
|
# if no arguments provided, show full history starting from 1
|
||||||
builtin fc "$@"
|
builtin fc $stamp -l 1
|
||||||
else
|
else
|
||||||
# unless a number is provided, show all history events (starting from 1)
|
# otherwise, run `fc -l` with a custom format
|
||||||
[[ ${@[-1]-} = *[0-9]* ]] && builtin fc -l "$@" || builtin fc -l "$@" 1
|
builtin fc $stamp -l "$@"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -32,19 +32,26 @@ if [[ -n "${terminfo[knp]}" ]]; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Start typing + [Up-Arrow] - fuzzy find history forward
|
# Start typing + [Up-Arrow] - fuzzy find history forward
|
||||||
if [[ -n "${terminfo[kcuu1]}" ]]; then
|
autoload -U up-line-or-beginning-search
|
||||||
autoload -U up-line-or-beginning-search
|
zle -N up-line-or-beginning-search
|
||||||
zle -N up-line-or-beginning-search
|
|
||||||
|
|
||||||
|
bindkey -M emacs "^[[A" up-line-or-beginning-search
|
||||||
|
bindkey -M viins "^[[A" up-line-or-beginning-search
|
||||||
|
bindkey -M vicmd "^[[A" up-line-or-beginning-search
|
||||||
|
if [[ -n "${terminfo[kcuu1]}" ]]; then
|
||||||
bindkey -M emacs "${terminfo[kcuu1]}" up-line-or-beginning-search
|
bindkey -M emacs "${terminfo[kcuu1]}" up-line-or-beginning-search
|
||||||
bindkey -M viins "${terminfo[kcuu1]}" up-line-or-beginning-search
|
bindkey -M viins "${terminfo[kcuu1]}" up-line-or-beginning-search
|
||||||
bindkey -M vicmd "${terminfo[kcuu1]}" up-line-or-beginning-search
|
bindkey -M vicmd "${terminfo[kcuu1]}" up-line-or-beginning-search
|
||||||
fi
|
fi
|
||||||
# Start typing + [Down-Arrow] - fuzzy find history backward
|
|
||||||
if [[ -n "${terminfo[kcud1]}" ]]; then
|
|
||||||
autoload -U down-line-or-beginning-search
|
|
||||||
zle -N down-line-or-beginning-search
|
|
||||||
|
|
||||||
|
# Start typing + [Down-Arrow] - fuzzy find history backward
|
||||||
|
autoload -U down-line-or-beginning-search
|
||||||
|
zle -N down-line-or-beginning-search
|
||||||
|
|
||||||
|
bindkey -M emacs "^[[B" down-line-or-beginning-search
|
||||||
|
bindkey -M viins "^[[B" down-line-or-beginning-search
|
||||||
|
bindkey -M vicmd "^[[B" down-line-or-beginning-search
|
||||||
|
if [[ -n "${terminfo[kcud1]}" ]]; then
|
||||||
bindkey -M emacs "${terminfo[kcud1]}" down-line-or-beginning-search
|
bindkey -M emacs "${terminfo[kcud1]}" down-line-or-beginning-search
|
||||||
bindkey -M viins "${terminfo[kcud1]}" down-line-or-beginning-search
|
bindkey -M viins "${terminfo[kcud1]}" down-line-or-beginning-search
|
||||||
bindkey -M vicmd "${terminfo[kcud1]}" down-line-or-beginning-search
|
bindkey -M vicmd "${terminfo[kcud1]}" down-line-or-beginning-search
|
||||||
|
|
|
||||||
|
|
@ -40,5 +40,5 @@ ZSH_THEME_RVM_PROMPT_OPTIONS="i v g"
|
||||||
# use this to enable users to see their ruby version, no matter which
|
# use this to enable users to see their ruby version, no matter which
|
||||||
# version management system they use
|
# version management system they use
|
||||||
function ruby_prompt_info() {
|
function ruby_prompt_info() {
|
||||||
echo $(rvm_prompt_info || rbenv_prompt_info || chruby_prompt_info)
|
echo "$(rvm_prompt_info || rbenv_prompt_info || chruby_prompt_info)"
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ typeset -AHg FX FG BG
|
||||||
FX=(
|
FX=(
|
||||||
reset "%{[00m%}"
|
reset "%{[00m%}"
|
||||||
bold "%{[01m%}" no-bold "%{[22m%}"
|
bold "%{[01m%}" no-bold "%{[22m%}"
|
||||||
|
dim "%{[02m%}" no-dim "%{[22m%}"
|
||||||
italic "%{[03m%}" no-italic "%{[23m%}"
|
italic "%{[03m%}" no-italic "%{[23m%}"
|
||||||
underline "%{[04m%}" no-underline "%{[24m%}"
|
underline "%{[04m%}" no-underline "%{[24m%}"
|
||||||
blink "%{[05m%}" no-blink "%{[25m%}"
|
blink "%{[05m%}" no-blink "%{[25m%}"
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ function title {
|
||||||
: ${2=$1}
|
: ${2=$1}
|
||||||
|
|
||||||
case "$TERM" in
|
case "$TERM" in
|
||||||
cygwin|xterm*|putty*|rxvt*|konsole*|ansi|mlterm*|alacritty|st*|foot*|contour*)
|
cygwin|xterm*|putty*|rxvt*|konsole*|ansi|mlterm*|alacritty*|st*|foot*|contour*)
|
||||||
print -Pn "\e]2;${2:q}\a" # set window name
|
print -Pn "\e]2;${2:q}\a" # set window name
|
||||||
print -Pn "\e]1;${1:q}\a" # set tab name
|
print -Pn "\e]1;${1:q}\a" # set tab name
|
||||||
;;
|
;;
|
||||||
|
|
@ -129,7 +129,7 @@ fi
|
||||||
# Don't define the function if we're in an unsupported terminal
|
# Don't define the function if we're in an unsupported terminal
|
||||||
case "$TERM" in
|
case "$TERM" in
|
||||||
# all of these either process OSC 7 correctly or ignore entirely
|
# all of these either process OSC 7 correctly or ignore entirely
|
||||||
xterm*|putty*|rxvt*|konsole*|mlterm*|alacritty|screen*|tmux*) ;;
|
xterm*|putty*|rxvt*|konsole*|mlterm*|alacritty*|screen*|tmux*) ;;
|
||||||
contour*|foot*) ;;
|
contour*|foot*) ;;
|
||||||
*)
|
*)
|
||||||
# Terminal.app and iTerm2 process OSC 7 correctly
|
# Terminal.app and iTerm2 process OSC 7 correctly
|
||||||
|
|
|
||||||
169
lib/tests/cli.test.zsh
Normal file
169
lib/tests/cli.test.zsh
Normal file
|
|
@ -0,0 +1,169 @@
|
||||||
|
#!/usr/bin/zsh -df
|
||||||
|
|
||||||
|
run_awk() {
|
||||||
|
local -a dis_plugins=(${=1})
|
||||||
|
local input_text="$2"
|
||||||
|
|
||||||
|
(( ! DEBUG )) || set -xv
|
||||||
|
|
||||||
|
local awk_subst_plugins="\
|
||||||
|
gsub(/[ \t]+(${(j:|:)dis_plugins})[ \t]+/, \" \") # with spaces before or after
|
||||||
|
gsub(/[ \t]+(${(j:|:)dis_plugins})$/, \"\") # with spaces before and EOL
|
||||||
|
gsub(/^(${(j:|:)dis_plugins})[ \t]+/, \"\") # with BOL and spaces after
|
||||||
|
|
||||||
|
gsub(/\((${(j:|:)dis_plugins})[ \t]+/, \"(\") # with parenthesis before and spaces after
|
||||||
|
gsub(/[ \t]+(${(j:|:)dis_plugins})\)/, \")\") # with spaces before or parenthesis after
|
||||||
|
gsub(/\((${(j:|:)dis_plugins})\)/, \"()\") # with only parentheses
|
||||||
|
|
||||||
|
gsub(/^(${(j:|:)dis_plugins})\)/, \")\") # with BOL and closing parenthesis
|
||||||
|
gsub(/\((${(j:|:)dis_plugins})$/, \"(\") # with opening parenthesis and EOL
|
||||||
|
"
|
||||||
|
# Disable plugins awk script
|
||||||
|
local awk_script="
|
||||||
|
# if plugins=() is in oneline form, substitute disabled plugins and go to next line
|
||||||
|
/^[ \t]*plugins=\([^#]+\).*\$/ {
|
||||||
|
$awk_subst_plugins
|
||||||
|
print \$0
|
||||||
|
next
|
||||||
|
}
|
||||||
|
|
||||||
|
# if plugins=() is in multiline form, enable multi flag and disable plugins if they're there
|
||||||
|
/^[ \t]*plugins=\(/ {
|
||||||
|
multi=1
|
||||||
|
$awk_subst_plugins
|
||||||
|
print \$0
|
||||||
|
next
|
||||||
|
}
|
||||||
|
|
||||||
|
# if multi flag is enabled and we find a valid closing parenthesis, remove plugins and disable multi flag
|
||||||
|
multi == 1 && /^[^#]*\)/ {
|
||||||
|
multi=0
|
||||||
|
$awk_subst_plugins
|
||||||
|
print \$0
|
||||||
|
next
|
||||||
|
}
|
||||||
|
|
||||||
|
multi == 1 && length(\$0) > 0 {
|
||||||
|
$awk_subst_plugins
|
||||||
|
if (length(\$0) > 0) print \$0
|
||||||
|
next
|
||||||
|
}
|
||||||
|
|
||||||
|
{ print \$0 }
|
||||||
|
"
|
||||||
|
|
||||||
|
command awk "$awk_script" <<< "$input_text"
|
||||||
|
|
||||||
|
(( ! DEBUG )) || set +xv
|
||||||
|
}
|
||||||
|
|
||||||
|
# runs awk against stdin, checks if the resulting file is not empty and then checks if the file has valid zsh syntax
|
||||||
|
run_awk_and_test() {
|
||||||
|
local description="$1"
|
||||||
|
local plugins_to_disable="$2"
|
||||||
|
local input_text="$3"
|
||||||
|
local expected_output="$4"
|
||||||
|
|
||||||
|
local tmpfile==(:)
|
||||||
|
|
||||||
|
{
|
||||||
|
print -u2 "Test: $description"
|
||||||
|
DEBUG=0 run_awk "$plugins_to_disable" "$input_text" >| $tmpfile
|
||||||
|
|
||||||
|
if [[ ! -s "$tmpfile" ]]; then
|
||||||
|
print -u2 "\e[31mError\e[0m: output file empty"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if ! zsh -n $tmpfile; then
|
||||||
|
print -u2 "\e[31mError\e[0m: zsh syntax error"
|
||||||
|
diff -u $tmpfile <(echo "$expected_output")
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if ! diff -u --color=always $tmpfile <(echo "$expected_output"); then
|
||||||
|
if (( DEBUG )); then
|
||||||
|
print -u2 ""
|
||||||
|
DEBUG=1 run_awk "$plugins_to_disable" "$input_text"
|
||||||
|
print -u2 ""
|
||||||
|
fi
|
||||||
|
print -u2 "\e[31mError\e[0m: output file does not match expected output"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
print -u2 "\e[32mSuccess\e[0m"
|
||||||
|
} always {
|
||||||
|
print -u2 ""
|
||||||
|
command rm -f "$tmpfile"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# These tests are for the `omz plugin disable` command
|
||||||
|
run_awk_and_test \
|
||||||
|
"it should delete a single plugin in oneline format" \
|
||||||
|
"git" \
|
||||||
|
"plugins=(git)" \
|
||||||
|
"plugins=()"
|
||||||
|
|
||||||
|
run_awk_and_test \
|
||||||
|
"it should delete a single plugin in multiline format" \
|
||||||
|
"github" \
|
||||||
|
"plugins=(
|
||||||
|
github
|
||||||
|
)" \
|
||||||
|
"plugins=(
|
||||||
|
)"
|
||||||
|
|
||||||
|
run_awk_and_test \
|
||||||
|
"it should delete multiple plugins in oneline format" \
|
||||||
|
"github git z" \
|
||||||
|
"plugins=(github git z)" \
|
||||||
|
"plugins=()"
|
||||||
|
|
||||||
|
run_awk_and_test \
|
||||||
|
"it should delete multiple plugins in multiline format" \
|
||||||
|
"github git z" \
|
||||||
|
"plugins=(
|
||||||
|
github
|
||||||
|
git
|
||||||
|
z
|
||||||
|
)" \
|
||||||
|
"plugins=(
|
||||||
|
)"
|
||||||
|
|
||||||
|
run_awk_and_test \
|
||||||
|
"it should delete a single plugin among multiple in oneline format" \
|
||||||
|
"git" \
|
||||||
|
"plugins=(github git z)" \
|
||||||
|
"plugins=(github z)"
|
||||||
|
|
||||||
|
run_awk_and_test \
|
||||||
|
"it should delete a single plugin among multiple in multiline format" \
|
||||||
|
"git" \
|
||||||
|
"plugins=(
|
||||||
|
github
|
||||||
|
git
|
||||||
|
z
|
||||||
|
)" \
|
||||||
|
"plugins=(
|
||||||
|
github
|
||||||
|
z
|
||||||
|
)"
|
||||||
|
|
||||||
|
run_awk_and_test \
|
||||||
|
"it should delete multiple plugins in mixed format" \
|
||||||
|
"git z" \
|
||||||
|
"plugins=(github
|
||||||
|
git z)" \
|
||||||
|
"plugins=(github
|
||||||
|
)"
|
||||||
|
|
||||||
|
run_awk_and_test \
|
||||||
|
"it should delete multiple plugins in mixed format 2" \
|
||||||
|
"github z" \
|
||||||
|
"plugins=(github
|
||||||
|
git
|
||||||
|
z)" \
|
||||||
|
"plugins=(
|
||||||
|
git
|
||||||
|
)"
|
||||||
|
|
@ -21,7 +21,6 @@ plugins=(... ansible)
|
||||||
| `acon` | command `ansible-console` |
|
| `acon` | command `ansible-console` |
|
||||||
| `ainv` | command `ansible-inventory` |
|
| `ainv` | command `ansible-inventory` |
|
||||||
| `aplaybook` | command `ansible-playbook` |
|
| `aplaybook` | command `ansible-playbook` |
|
||||||
| `ainv` | command `ansible-inventory` |
|
|
||||||
| `adoc` | command `ansible-doc` |
|
| `adoc` | command `ansible-doc` |
|
||||||
| `agal` | command `ansible-galaxy` |
|
| `agal` | command `ansible-galaxy` |
|
||||||
| `apull` | command `ansible-pull` |
|
| `apull` | command `ansible-pull` |
|
||||||
|
|
|
||||||
|
|
@ -179,8 +179,8 @@ fi
|
||||||
# Check Arch Linux PGP Keyring before System Upgrade to prevent failure.
|
# Check Arch Linux PGP Keyring before System Upgrade to prevent failure.
|
||||||
function upgrade() {
|
function upgrade() {
|
||||||
echo ":: Checking Arch Linux PGP Keyring..."
|
echo ":: Checking Arch Linux PGP Keyring..."
|
||||||
local installedver="$(sudo pacman -Qi archlinux-keyring | grep -Po '(?<=Version : ).*')"
|
local installedver="$(LANG= sudo pacman -Qi archlinux-keyring | grep -Po '(?<=Version : ).*')"
|
||||||
local currentver="$(sudo pacman -Si archlinux-keyring | grep -Po '(?<=Version : ).*')"
|
local currentver="$(LANG= sudo pacman -Si archlinux-keyring | grep -Po '(?<=Version : ).*')"
|
||||||
if [ $installedver != $currentver ]; then
|
if [ $installedver != $currentver ]; then
|
||||||
echo " Arch Linux PGP Keyring is out of date."
|
echo " Arch Linux PGP Keyring is out of date."
|
||||||
echo " Updating before full system upgrade."
|
echo " Updating before full system upgrade."
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,9 @@ autojump_paths=(
|
||||||
/opt/local/etc/profile.d/autojump.sh # macOS with MacPorts
|
/opt/local/etc/profile.d/autojump.sh # macOS with MacPorts
|
||||||
/usr/local/etc/profile.d/autojump.sh # macOS with Homebrew (default)
|
/usr/local/etc/profile.d/autojump.sh # macOS with Homebrew (default)
|
||||||
/opt/homebrew/etc/profile.d/autojump.sh # macOS with Homebrew (default on M1 macs)
|
/opt/homebrew/etc/profile.d/autojump.sh # macOS with Homebrew (default on M1 macs)
|
||||||
|
/opt/pkg/share/autojump/autojump.zsh # macOS with pkgsrc
|
||||||
/etc/profiles/per-user/$USER/etc/profile.d/autojump.sh # macOS Nix, Home Manager and flakes
|
/etc/profiles/per-user/$USER/etc/profile.d/autojump.sh # macOS Nix, Home Manager and flakes
|
||||||
|
/nix/var/nix/gcroots/current-system/sw/share/zsh/site-functions/autojump.zsh # macOS Nix, nix-darwin
|
||||||
)
|
)
|
||||||
|
|
||||||
for file in $autojump_paths; do
|
for file in $autojump_paths; do
|
||||||
|
|
|
||||||
|
|
@ -47,6 +47,11 @@ plugins=(... aws)
|
||||||
Some themes might overwrite the value of RPROMPT instead of appending to it, so they'll need to be fixed to
|
Some themes might overwrite the value of RPROMPT instead of appending to it, so they'll need to be fixed to
|
||||||
see the AWS profile/region prompt.
|
see the AWS profile/region prompt.
|
||||||
|
|
||||||
|
* Set `AWS_PROFILE_STATE_ENABLED=true` in your zshrc file if you want the aws profile to persist between shell sessions.
|
||||||
|
This option might slow down your shell startup time.
|
||||||
|
By default the state file path is `/tmp/.aws_current_profile`. This means that the state won't survive a reboot or otherwise GC.
|
||||||
|
You can control the state file path using the `AWS_STATE_FILE` environment variable.
|
||||||
|
|
||||||
## Theme
|
## Theme
|
||||||
|
|
||||||
The plugin creates an `aws_prompt_info` function that you can use in your theme, which displays
|
The plugin creates an `aws_prompt_info` function that you can use in your theme, which displays
|
||||||
|
|
|
||||||
|
|
@ -6,10 +6,26 @@ function agr() {
|
||||||
echo $AWS_REGION
|
echo $AWS_REGION
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Update state file if enabled
|
||||||
|
function _aws_update_state() {
|
||||||
|
if [[ "$AWS_PROFILE_STATE_ENABLED" == true ]]; then
|
||||||
|
test -d $(dirname ${AWS_STATE_FILE}) || exit 1
|
||||||
|
echo "${AWS_PROFILE} ${AWS_REGION}" > "${AWS_STATE_FILE}"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
function _aws_clear_state() {
|
||||||
|
if [[ "$AWS_PROFILE_STATE_ENABLED" == true ]]; then
|
||||||
|
test -d $(dirname ${AWS_STATE_FILE}) || exit 1
|
||||||
|
echo -n > "${AWS_STATE_FILE}"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
# AWS profile selection
|
# AWS profile selection
|
||||||
function asp() {
|
function asp() {
|
||||||
if [[ -z "$1" ]]; then
|
if [[ -z "$1" ]]; then
|
||||||
unset AWS_DEFAULT_PROFILE AWS_PROFILE AWS_EB_PROFILE AWS_PROFILE_REGION
|
unset AWS_DEFAULT_PROFILE AWS_PROFILE AWS_EB_PROFILE AWS_PROFILE_REGION
|
||||||
|
_aws_clear_state
|
||||||
echo AWS profile cleared.
|
echo AWS profile cleared.
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
|
@ -28,6 +44,8 @@ function asp() {
|
||||||
|
|
||||||
export AWS_PROFILE_REGION=$(aws configure get region)
|
export AWS_PROFILE_REGION=$(aws configure get region)
|
||||||
|
|
||||||
|
_aws_update_state
|
||||||
|
|
||||||
if [[ "$2" == "login" ]]; then
|
if [[ "$2" == "login" ]]; then
|
||||||
if [[ -n "$3" ]]; then
|
if [[ -n "$3" ]]; then
|
||||||
aws sso login --sso-session $3
|
aws sso login --sso-session $3
|
||||||
|
|
@ -43,6 +61,7 @@ function asp() {
|
||||||
function asr() {
|
function asr() {
|
||||||
if [[ -z "$1" ]]; then
|
if [[ -z "$1" ]]; then
|
||||||
unset AWS_DEFAULT_REGION AWS_REGION
|
unset AWS_DEFAULT_REGION AWS_REGION
|
||||||
|
_aws_update_state
|
||||||
echo AWS region cleared.
|
echo AWS region cleared.
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
|
@ -56,6 +75,7 @@ function asr() {
|
||||||
|
|
||||||
export AWS_REGION=$1
|
export AWS_REGION=$1
|
||||||
export AWS_DEFAULT_REGION=$1
|
export AWS_DEFAULT_REGION=$1
|
||||||
|
_aws_update_state
|
||||||
}
|
}
|
||||||
|
|
||||||
# AWS profile switch
|
# AWS profile switch
|
||||||
|
|
@ -202,8 +222,17 @@ function aws_change_access_key() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function aws_regions() {
|
function aws_regions() {
|
||||||
|
local region
|
||||||
|
if [[ $AWS_DEFAULT_REGION ]];then
|
||||||
|
region="$AWS_DEFAULT_REGION"
|
||||||
|
elif [[ $AWS_REGION ]];then
|
||||||
|
region="$AWS_REGION"
|
||||||
|
else
|
||||||
|
region="us-west-1"
|
||||||
|
fi
|
||||||
|
|
||||||
if [[ $AWS_DEFAULT_PROFILE || $AWS_PROFILE ]];then
|
if [[ $AWS_DEFAULT_PROFILE || $AWS_PROFILE ]];then
|
||||||
aws ec2 describe-regions |grep RegionName | awk -F ':' '{gsub(/"/, "", $2);gsub(/,/, "", $2);gsub(/ /, "", $2); print $2}'
|
aws ec2 describe-regions --region $region |grep RegionName | awk -F ':' '{gsub(/"/, "", $2);gsub(/,/, "", $2);gsub(/ /, "", $2); print $2}'
|
||||||
else
|
else
|
||||||
echo "You must specify a AWS profile."
|
echo "You must specify a AWS profile."
|
||||||
fi
|
fi
|
||||||
|
|
@ -246,6 +275,22 @@ if [[ "$SHOW_AWS_PROMPT" != false && "$RPROMPT" != *'$(aws_prompt_info)'* ]]; th
|
||||||
RPROMPT='$(aws_prompt_info)'"$RPROMPT"
|
RPROMPT='$(aws_prompt_info)'"$RPROMPT"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [[ "$AWS_PROFILE_STATE_ENABLED" == true ]]; then
|
||||||
|
AWS_STATE_FILE="${AWS_STATE_FILE:-/tmp/.aws_current_profile}"
|
||||||
|
test -s "${AWS_STATE_FILE}" || return
|
||||||
|
|
||||||
|
aws_state=($(cat $AWS_STATE_FILE))
|
||||||
|
|
||||||
|
export AWS_DEFAULT_PROFILE="${aws_state[1]}"
|
||||||
|
export AWS_PROFILE="$AWS_DEFAULT_PROFILE"
|
||||||
|
export AWS_EB_PROFILE="$AWS_DEFAULT_PROFILE"
|
||||||
|
|
||||||
|
test -z "${aws_state[2]}" && AWS_REGION=$(aws configure get region)
|
||||||
|
|
||||||
|
export AWS_REGION=${AWS_REGION:-$aws_state[2]}
|
||||||
|
export AWS_DEFAULT_REGION="$AWS_REGION"
|
||||||
|
fi
|
||||||
|
|
||||||
# Load awscli completions
|
# Load awscli completions
|
||||||
|
|
||||||
# AWS CLI v2 comes with its own autocompletion. Check if that is there, otherwise fall back
|
# AWS CLI v2 comes with its own autocompletion. Check if that is there, otherwise fall back
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
# Bazel plugin
|
# Bazel plugin
|
||||||
|
|
||||||
This plugin adds completion for [bazel](https://bazel.build), an open-source build and
|
This plugin adds completion and aliases for [bazel](https://bazel.build), an open-source build and test tool that scalably supports multi-language and multi-platform projects.
|
||||||
test tool that scalably supports multi-language and multi-platform projects.
|
|
||||||
|
|
||||||
To use it, add `bazel` to the plugins array in your zshrc file:
|
To use it, add `bazel` to the plugins array in your zshrc file:
|
||||||
|
|
||||||
|
|
@ -12,3 +11,12 @@ plugins=(... bazel)
|
||||||
The plugin has a copy of [the completion script from the git repository][1].
|
The plugin has a copy of [the completion script from the git repository][1].
|
||||||
|
|
||||||
[1]: https://github.com/bazelbuild/bazel/blob/master/scripts/zsh_completion/_bazel
|
[1]: https://github.com/bazelbuild/bazel/blob/master/scripts/zsh_completion/_bazel
|
||||||
|
|
||||||
|
## Aliases
|
||||||
|
|
||||||
|
| Alias | Command | Description |
|
||||||
|
| ------- | -------------------------------------- | ------------------------------------------------------ |
|
||||||
|
| bzb | `bazel build` | The `bazel build` command |
|
||||||
|
| bzt | `bazel test` | The `bazel test` command |
|
||||||
|
| bzr | `bazel run` | The `bazel run` command |
|
||||||
|
| bzq | `bazel query` | The `bazel query` command |
|
||||||
|
|
|
||||||
5
plugins/bazel/bazel.plugin.zsh
Normal file
5
plugins/bazel/bazel.plugin.zsh
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
# Aliases for bazel
|
||||||
|
alias bzb='bazel build'
|
||||||
|
alias bzt='bazel test'
|
||||||
|
alias bzr='bazel run'
|
||||||
|
alias bzq='bazel query'
|
||||||
|
|
@ -117,7 +117,7 @@ function bgnotify {
|
||||||
local icon="$3"
|
local icon="$3"
|
||||||
if (( ${+commands[terminal-notifier]} )); then # macOS
|
if (( ${+commands[terminal-notifier]} )); then # macOS
|
||||||
local term_id=$(bgnotify_programid)
|
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
|
elif (( ${+commands[growlnotify]} )); then # macOS growl
|
||||||
growlnotify -m "$title" "$message"
|
growlnotify -m "$title" "$message"
|
||||||
elif (( ${+commands[notify-send]} )); then
|
elif (( ${+commands[notify-send]} )); then
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,6 @@ fi
|
||||||
|
|
||||||
alias bcubc='brew upgrade --cask && brew cleanup'
|
alias bcubc='brew upgrade --cask && brew cleanup'
|
||||||
alias bcubo='brew update && brew outdated --cask'
|
alias bcubo='brew update && brew outdated --cask'
|
||||||
alias bcubc='brew upgrade --cask && brew cleanup'
|
|
||||||
alias brewp='brew pin'
|
alias brewp='brew pin'
|
||||||
alias brewsp='brew list --pinned'
|
alias brewsp='brew list --pinned'
|
||||||
alias bubc='brew upgrade && brew cleanup'
|
alias bubc='brew upgrade && brew cleanup'
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
#compdef bundle
|
#compdef bundle bundler
|
||||||
|
|
||||||
local curcontext="$curcontext" state line _gems _opts ret=1
|
local curcontext="$curcontext" state line _gems _opts ret=1
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
# catimg
|
# catimg
|
||||||
|
|
||||||
Plugin for displaying images on the terminal using the the `catimg.sh` script provided by [posva](https://github.com/posva/catimg)
|
Plugin for displaying images on the terminal using the `catimg.sh` script provided by [posva](https://github.com/posva/catimg)
|
||||||
|
|
||||||
To use it, add `catimg` to the plugins array in your zshrc file:
|
To use it, add `catimg` to the plugins array in your zshrc file:
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
# onto the system clipboard
|
# onto the system clipboard
|
||||||
|
|
||||||
copybuffer () {
|
copybuffer () {
|
||||||
if which clipcopy &>/dev/null; then
|
if builtin which clipcopy &>/dev/null; then
|
||||||
printf "%s" "$BUFFER" | clipcopy
|
printf "%s" "$BUFFER" | clipcopy
|
||||||
else
|
else
|
||||||
zle -M "clipcopy not found. Please make sure you have Oh My Zsh installed correctly."
|
zle -M "clipcopy not found. Please make sure you have Oh My Zsh installed correctly."
|
||||||
|
|
|
||||||
|
|
@ -128,7 +128,7 @@ __docker-compose_subcommand() {
|
||||||
'--resolve-image-digests[Pin image tags to digests.]' \
|
'--resolve-image-digests[Pin image tags to digests.]' \
|
||||||
'--services[Print the service names, one per line.]' \
|
'--services[Print the service names, one per line.]' \
|
||||||
'--volumes[Print the volume names, one per line.]' \
|
'--volumes[Print the volume names, one per line.]' \
|
||||||
'--hash[Print the service config hash, one per line. Set "service1,service2" for a list of specified services.]' \ && ret=0
|
'--hash[Print the service config hash, one per line. Set "service1,service2" for a list of specified services.]' && ret=0
|
||||||
;;
|
;;
|
||||||
(create)
|
(create)
|
||||||
_arguments \
|
_arguments \
|
||||||
|
|
|
||||||
|
|
@ -57,6 +57,6 @@ fi
|
||||||
! is-at-least 23.0.0 ${${(s:,:z)"$(command docker --version)"}[3]}; then
|
! is-at-least 23.0.0 ${${(s:,:z)"$(command docker --version)"}[3]}; then
|
||||||
command cp "${0:h}/completions/_docker" "$ZSH_CACHE_DIR/completions/_docker"
|
command cp "${0:h}/completions/_docker" "$ZSH_CACHE_DIR/completions/_docker"
|
||||||
else
|
else
|
||||||
command docker completion zsh >| "$ZSH_CACHE_DIR/completions/_docker"
|
command docker completion zsh | tee "$ZSH_CACHE_DIR/completions/_docker" > /dev/null
|
||||||
fi
|
fi
|
||||||
} &|
|
} &|
|
||||||
|
|
|
||||||
|
|
@ -27,4 +27,4 @@ The plugin uses a custom launcher (which we'll call here `$EMACS_LAUNCHER`) that
|
||||||
| eeval | `$EMACS_LAUNCHER --eval` | Same as `M-x eval` but from outside Emacs |
|
| eeval | `$EMACS_LAUNCHER --eval` | Same as `M-x eval` but from outside Emacs |
|
||||||
| eframe | `emacsclient --alternate-editor="" --create-frame` | Create new X frame |
|
| eframe | `emacsclient --alternate-editor="" --create-frame` | Create new X frame |
|
||||||
| efile | - | Print the path to the file open in the current buffer |
|
| efile | - | Print the path to the file open in the current buffer |
|
||||||
| ecd | - | Print the directory of the file open in the the current buffer |
|
| ecd | - | Print the directory of the file open in the current buffer |
|
||||||
|
|
|
||||||
|
|
@ -60,7 +60,7 @@ function efile {
|
||||||
}
|
}
|
||||||
|
|
||||||
# Write to standard output the directory of the file
|
# Write to standard output the directory of the file
|
||||||
# opened in the the current buffer
|
# opened in the current buffer
|
||||||
function ecd {
|
function ecd {
|
||||||
local file
|
local file
|
||||||
file="$(efile)" || return $?
|
file="$(efile)" || return $?
|
||||||
|
|
|
||||||
|
|
@ -70,7 +70,7 @@ EOF
|
||||||
(*.tar.lz4) lz4 -c -d "$full_path" | tar xvf - ;;
|
(*.tar.lz4) lz4 -c -d "$full_path" | tar xvf - ;;
|
||||||
(*.tar.lrz) (( $+commands[lrzuntar] )) && lrzuntar "$full_path" ;;
|
(*.tar.lrz) (( $+commands[lrzuntar] )) && lrzuntar "$full_path" ;;
|
||||||
(*.gz) (( $+commands[pigz] )) && pigz -cdk "$full_path" > "${file:t:r}" || gunzip -ck "$full_path" > "${file:t:r}" ;;
|
(*.gz) (( $+commands[pigz] )) && pigz -cdk "$full_path" > "${file:t:r}" || gunzip -ck "$full_path" > "${file:t:r}" ;;
|
||||||
(*.bz2) bunzip2 "$full_path" ;;
|
(*.bz2) (( $+commands[pbzip2] )) && pbzip2 -d "$full_path" || bunzip2 "$full_path" ;;
|
||||||
(*.xz) unxz "$full_path" ;;
|
(*.xz) unxz "$full_path" ;;
|
||||||
(*.lrz) (( $+commands[lrunzip] )) && lrunzip "$full_path" ;;
|
(*.lrz) (( $+commands[lrunzip] )) && lrunzip "$full_path" ;;
|
||||||
(*.lz4) lz4 -d "$full_path" ;;
|
(*.lz4) lz4 -d "$full_path" ;;
|
||||||
|
|
@ -80,14 +80,14 @@ EOF
|
||||||
(*.rar) unrar x -ad "$full_path" ;;
|
(*.rar) unrar x -ad "$full_path" ;;
|
||||||
(*.rpm)
|
(*.rpm)
|
||||||
rpm2cpio "$full_path" | cpio --quiet -id ;;
|
rpm2cpio "$full_path" | cpio --quiet -id ;;
|
||||||
(*.7z) 7za x "$full_path" ;;
|
(*.7z | *.7z.[0-9]*) 7za x "$full_path" ;;
|
||||||
(*.deb)
|
(*.deb)
|
||||||
command mkdir -p "control" "data"
|
command mkdir -p "control" "data"
|
||||||
ar vx "$full_path" > /dev/null
|
ar vx "$full_path" > /dev/null
|
||||||
builtin cd -q control; extract ../control.tar.*
|
builtin cd -q control; extract ../control.tar.*
|
||||||
builtin cd -q ../data; extract ../data.tar.*
|
builtin cd -q ../data; extract ../data.tar.*
|
||||||
builtin cd -q ..; command rm *.tar.* debian-binary ;;
|
builtin cd -q ..; command rm *.tar.* debian-binary ;;
|
||||||
(*.zst) unzstd "$full_path" ;;
|
(*.zst) unzstd --stdout "$full_path" > "${file:t:r}" ;;
|
||||||
(*.cab|*.exe) cabextract "$full_path" ;;
|
(*.cab|*.exe) cabextract "$full_path" ;;
|
||||||
(*.cpio|*.obscpio) cpio -idmvF "$full_path" ;;
|
(*.cpio|*.obscpio) cpio -idmvF "$full_path" ;;
|
||||||
(*.zpaq) zpaq x "$full_path" ;;
|
(*.zpaq) zpaq x "$full_path" ;;
|
||||||
|
|
|
||||||
111
plugins/eza/README.md
Normal file
111
plugins/eza/README.md
Normal file
|
|
@ -0,0 +1,111 @@
|
||||||
|
# eza plugin
|
||||||
|
|
||||||
|
This provides aliases that invoke the [`eza`](https://github.com/eza-community/eza) utility rather than `ls`
|
||||||
|
|
||||||
|
To use it add `eza` to the plugins array in your zshrc file:
|
||||||
|
|
||||||
|
```zsh
|
||||||
|
plugins=(... eza)
|
||||||
|
```
|
||||||
|
|
||||||
|
## Configuration
|
||||||
|
|
||||||
|
All configurations are done using the `zstyle` command in the `:omz:plugins:eza` namespace.
|
||||||
|
|
||||||
|
**NOTE:** The configuring needs to be done prior to OMZ loading the plugins. When the plugin is loaded,
|
||||||
|
changing the `zstyle` won't have any effect.
|
||||||
|
|
||||||
|
### `dirs-first`
|
||||||
|
|
||||||
|
```zsh
|
||||||
|
zstyle ':omz:plugins:eza' 'dirs-first' yes|no
|
||||||
|
```
|
||||||
|
|
||||||
|
If `yes`, directories will be grouped first.
|
||||||
|
|
||||||
|
Default: `no`
|
||||||
|
|
||||||
|
### `git-status`
|
||||||
|
|
||||||
|
```zsh
|
||||||
|
zstyle ':omz:plugins:eza' 'git-status' yes|no
|
||||||
|
```
|
||||||
|
|
||||||
|
If `yes`, always add `--git` flag to indicate git status (if tracked / in a git repo).
|
||||||
|
|
||||||
|
Default: `no`
|
||||||
|
|
||||||
|
### `header`
|
||||||
|
|
||||||
|
```zsh
|
||||||
|
zstyle ':omz:plugins:eza' 'header' yes|no
|
||||||
|
```
|
||||||
|
|
||||||
|
If `yes`, always add `-h` flag to add a header row for each column.
|
||||||
|
|
||||||
|
Default: `no`
|
||||||
|
|
||||||
|
### `show-group`
|
||||||
|
|
||||||
|
```zsh
|
||||||
|
zstyle ':omz:plugins:eza' 'show-group' yes|no
|
||||||
|
```
|
||||||
|
|
||||||
|
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
|
||||||
|
zstyle ':omz:plugins:eza' 'size-prefix' (binary|none|si)
|
||||||
|
```
|
||||||
|
|
||||||
|
Choose the prefix to be used in displaying file size:
|
||||||
|
|
||||||
|
- `binary` -- use [binary prefixes](https://en.wikipedia.org/wiki/Binary_prefix) such as "Ki", "Mi", "Gi" and
|
||||||
|
so on
|
||||||
|
- `none` -- don't use any prefix, show size in bytes
|
||||||
|
- `si` (default) -- use [Metric/S.I. prefixes](https://en.wikipedia.org/wiki/Metric_prefix)
|
||||||
|
|
||||||
|
Default: `si`
|
||||||
|
|
||||||
|
### `time-style`
|
||||||
|
|
||||||
|
```zsh
|
||||||
|
zstyle ':omz:plugins:eza' 'time-style' $TIME_STYLE
|
||||||
|
```
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
## Aliases
|
||||||
|
|
||||||
|
**Notes:**
|
||||||
|
|
||||||
|
- Aliases may be modified by Configuration
|
||||||
|
- The term "files" without "only" qualifier means both files & directories
|
||||||
|
|
||||||
|
| Alias | Command | Description |
|
||||||
|
| ------ | ----------------- | -------------------------------------------------------------------------- |
|
||||||
|
| `la` | `eza -la` | List all files (except . and ..) as a long list |
|
||||||
|
| `ldot` | `eza -ld .*` | List dotfiles only (directories shown as entries instead of recursed into) |
|
||||||
|
| `lD` | `eza -lD` | List only directories (excluding dotdirs) as a long list |
|
||||||
|
| `lDD` | `eza -laD` | List only directories (including dotdirs) as a long list |
|
||||||
|
| `ll` | `eza -l` | List files as a long list |
|
||||||
|
| `ls` | `eza` | Plain eza call |
|
||||||
|
| `lsd` | `eza -d` | List specified files with directories as entries, in a grid |
|
||||||
|
| `lsdl` | `eza -dl` | List specified files with directories as entries, in a long list |
|
||||||
|
| `lS` | `eza -l -ssize` | List files as a long list, sorted by size |
|
||||||
|
| `lT` | `eza -l -snewest` | List files as a long list, sorted by date (newest last) |
|
||||||
65
plugins/eza/eza.plugin.zsh
Normal file
65
plugins/eza/eza.plugin.zsh
Normal file
|
|
@ -0,0 +1,65 @@
|
||||||
|
if ! (( $+commands[eza] )); then
|
||||||
|
print "zsh eza plugin: eza not found. Please install eza before using this plugin." >&2
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
typeset -a _EZA_HEAD
|
||||||
|
typeset -a _EZA_TAIL
|
||||||
|
|
||||||
|
function _configure_eza() {
|
||||||
|
local _val
|
||||||
|
# Get the head flags
|
||||||
|
if zstyle -T ':omz:plugins:eza' 'show-group'; then
|
||||||
|
_EZA_HEAD+=("g")
|
||||||
|
fi
|
||||||
|
if zstyle -t ':omz:plugins:eza' 'header'; then
|
||||||
|
_EZA_HEAD+=("h")
|
||||||
|
fi
|
||||||
|
zstyle -s ':omz:plugins:eza' 'size-prefix' _val
|
||||||
|
case "${_val:l}" in
|
||||||
|
binary)
|
||||||
|
_EZA_HEAD+=("b")
|
||||||
|
;;
|
||||||
|
none)
|
||||||
|
_EZA_HEAD+=("B")
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
# Get the tail long-options
|
||||||
|
if zstyle -t ':omz:plugins:eza' 'dirs-first'; then
|
||||||
|
_EZA_TAIL+=("--group-directories-first")
|
||||||
|
fi
|
||||||
|
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
|
||||||
|
}
|
||||||
|
|
||||||
|
_configure_eza
|
||||||
|
|
||||||
|
function _alias_eza() {
|
||||||
|
local _head="${(j::)_EZA_HEAD}$2"
|
||||||
|
local _tail="${(j: :)_EZA_TAIL}"
|
||||||
|
alias "$1"="eza${_head:+ -}${_head}${_tail:+ }${_tail}${3:+ }$3"
|
||||||
|
}
|
||||||
|
|
||||||
|
_alias_eza la la
|
||||||
|
_alias_eza ldot ld ".*"
|
||||||
|
_alias_eza lD lD
|
||||||
|
_alias_eza lDD lDa
|
||||||
|
_alias_eza ll l
|
||||||
|
_alias_eza ls
|
||||||
|
_alias_eza lsd d
|
||||||
|
_alias_eza lsdl dl
|
||||||
|
_alias_eza lS "l -ssize"
|
||||||
|
_alias_eza lT "l -snewest"
|
||||||
|
|
||||||
|
unfunction _alias_eza
|
||||||
|
unfunction _configure_eza
|
||||||
|
unset _EZA_HEAD
|
||||||
|
unset _EZA_TAIL
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
# Author: Adam Strzelecki nanoant.com, modified by Bodo Tasche bitboxer.de
|
# 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 2 and ForkLift 3 by Johan Kaving
|
||||||
# Updated to support ForkLift from Setapp by Paul Rudkin
|
# Updated to support ForkLift from Setapp by Paul Rudkin
|
||||||
|
# Updated to support ForkLift 4 by Michal Szymanski (misiektoja)
|
||||||
#
|
#
|
||||||
# Usage:
|
# Usage:
|
||||||
# fl [<folder>]
|
# fl [<folder>]
|
||||||
|
|
@ -110,6 +111,11 @@ function fl {
|
||||||
tell pop over of list of group of splitter group of splitter group of topWindow
|
tell pop over of list of group of splitter group of splitter group of topWindow
|
||||||
set value of text field 1 to "$PWD"
|
set value of text field 1 to "$PWD"
|
||||||
end tell
|
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
|
else
|
||||||
tell sheet 1 of topWindow
|
tell sheet 1 of topWindow
|
||||||
set value of text field 1 to "$PWD"
|
set value of text field 1 to "$PWD"
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,16 @@
|
||||||
|
function fzf_setup_using_fzf() {
|
||||||
|
(( ${+commands[fzf]} )) || return 1
|
||||||
|
|
||||||
|
# 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)"
|
||||||
|
}
|
||||||
|
|
||||||
function fzf_setup_using_base_dir() {
|
function fzf_setup_using_base_dir() {
|
||||||
local fzf_base fzf_shell fzfdirs dir
|
local fzf_base fzf_shell fzfdirs dir
|
||||||
|
|
||||||
|
|
@ -8,6 +21,7 @@ function fzf_setup_using_base_dir() {
|
||||||
"${HOME}/.fzf"
|
"${HOME}/.fzf"
|
||||||
"${HOME}/.nix-profile/share/fzf"
|
"${HOME}/.nix-profile/share/fzf"
|
||||||
"${XDG_DATA_HOME:-$HOME/.local/share}/fzf"
|
"${XDG_DATA_HOME:-$HOME/.local/share}/fzf"
|
||||||
|
"${MSYSTEM_PREFIX}/share/fzf"
|
||||||
"/usr/local/opt/fzf"
|
"/usr/local/opt/fzf"
|
||||||
"/opt/homebrew/opt/fzf"
|
"/opt/homebrew/opt/fzf"
|
||||||
"/usr/share/fzf"
|
"/usr/share/fzf"
|
||||||
|
|
@ -134,6 +148,27 @@ function fzf_setup_using_opensuse() {
|
||||||
return 0
|
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() {
|
function fzf_setup_using_openbsd() {
|
||||||
# openBSD installs fzf in /usr/local/bin/fzf
|
# openBSD installs fzf in /usr/local/bin/fzf
|
||||||
if [[ "$OSTYPE" != openbsd* ]] || (( ! $+commands[fzf] )); then
|
if [[ "$OSTYPE" != openbsd* ]] || (( ! $+commands[fzf] )); then
|
||||||
|
|
@ -216,9 +251,11 @@ Please add `export FZF_BASE=/path/to/fzf/install/dir` to your .zshrc
|
||||||
EOF
|
EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
fzf_setup_using_openbsd \
|
fzf_setup_using_fzf \
|
||||||
|
|| fzf_setup_using_openbsd \
|
||||||
|| fzf_setup_using_debian \
|
|| fzf_setup_using_debian \
|
||||||
|| fzf_setup_using_opensuse \
|
|| fzf_setup_using_opensuse \
|
||||||
|
|| fzf_setup_using_fedora \
|
||||||
|| fzf_setup_using_cygwin \
|
|| fzf_setup_using_cygwin \
|
||||||
|| fzf_setup_using_macports \
|
|| fzf_setup_using_macports \
|
||||||
|| fzf_setup_using_base_dir \
|
|| fzf_setup_using_base_dir \
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@ if [[ -z "${CLOUDSDK_HOME}" ]]; then
|
||||||
"/usr/local/share/google-cloud-sdk"
|
"/usr/local/share/google-cloud-sdk"
|
||||||
"/usr/local/Caskroom/google-cloud-sdk/latest/google-cloud-sdk"
|
"/usr/local/Caskroom/google-cloud-sdk/latest/google-cloud-sdk"
|
||||||
"/opt/homebrew/Caskroom/google-cloud-sdk/latest/google-cloud-sdk"
|
"/opt/homebrew/Caskroom/google-cloud-sdk/latest/google-cloud-sdk"
|
||||||
|
"/opt/homebrew/share/google-cloud-sdk"
|
||||||
"/usr/share/google-cloud-sdk"
|
"/usr/share/google-cloud-sdk"
|
||||||
"/snap/google-cloud-sdk/current"
|
"/snap/google-cloud-sdk/current"
|
||||||
"/snap/google-cloud-cli/current"
|
"/snap/google-cloud-cli/current"
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,8 @@
|
||||||
# git-commit plugin
|
# git-commit plugin
|
||||||
|
|
||||||
The git-commit plugin adds several [git aliases](https://www.git-scm.com/docs/git-config#Documentation/git-config.txt-alias) for [conventional commit](https://www.conventionalcommits.org/en/v1.0.0/#summary) messages.
|
The git-commit plugin adds several
|
||||||
|
[git aliases](https://www.git-scm.com/docs/git-config#Documentation/git-config.txt-alias) for
|
||||||
|
[conventional commit](https://www.conventionalcommits.org/en/v1.0.0/#summary) messages.
|
||||||
|
|
||||||
To use it, add `git-commit` to the plugins array in your zshrc file:
|
To use it, add `git-commit` to the plugins array in your zshrc file:
|
||||||
|
|
||||||
|
|
@ -11,11 +13,9 @@ plugins=(... git-commit)
|
||||||
## Syntax
|
## Syntax
|
||||||
|
|
||||||
```zsh
|
```zsh
|
||||||
git <type> [(-s, --scope) "<scope>"] "<message>"
|
git <type> [(-s, --scope) "<scope>"] [(-a, --attention)] "<message>"
|
||||||
```
|
```
|
||||||
|
|
||||||
> ⚠️ Single/Double quotes around the scope and message are required
|
|
||||||
|
|
||||||
Where `type` is one of the following:
|
Where `type` is one of the following:
|
||||||
|
|
||||||
- `build`
|
- `build`
|
||||||
|
|
@ -29,14 +29,19 @@ Where `type` is one of the following:
|
||||||
- `rev`
|
- `rev`
|
||||||
- `style`
|
- `style`
|
||||||
- `test`
|
- `test`
|
||||||
|
- `wip`
|
||||||
|
|
||||||
> NOTE: the alias for `revert` type is `rev`, as otherwise it conflicts with the git command of the same name.
|
> NOTE: the alias for `revert` type is `rev`, as otherwise it conflicts with the git command of the same name.
|
||||||
> It will still generate a commit message in the format `revert: <message>`
|
> It will still generate a commit message in the format `revert: <message>`
|
||||||
|
|
||||||
|
> ⚠️ Enabling this plugin will (potentially) overwrite all `alias.<type>` that you manually set. Use with
|
||||||
|
> care!
|
||||||
|
|
||||||
## Examples
|
## Examples
|
||||||
|
|
||||||
| Git alias | Command |
|
| Git alias | Command |
|
||||||
| --------------------------------------------- | ---------------------------------------------------- |
|
| --------------------------------------------- | ---------------------------------------------------- |
|
||||||
| `git style "remove trailing whitespace"` | `git commit -m "style: remove trailing whitespace"` |
|
| `git style "remove trailing whitespace"` | `git commit -m "style: remove trailing whitespace"` |
|
||||||
|
| `git wip "work in progress"` | `git commit -m "work in progress"` |
|
||||||
| `git fix -s "router" "correct redirect link"` | `git commit -m "fix(router): correct redirect link"` |
|
| `git fix -s "router" "correct redirect link"` | `git commit -m "fix(router): correct redirect link"` |
|
||||||
| `git rev -s "api" "rollback v2"` | `git commit -m "revert(api): rollback v2"` |
|
| `git rev -s "api" "rollback v2"` | `git commit -m "revert(api): rollback v2"` |
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,9 @@
|
||||||
|
local _rev="$(git -C $ZSH rev-parse HEAD 2> /dev/null)"
|
||||||
|
if [[ $_rev == $(git config --global --get oh-my-zsh.git-commit-alias 2> /dev/null) ]]; then
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
git config --global oh-my-zsh.git-commit-alias "$_rev"
|
||||||
|
|
||||||
local -a _git_commit_aliases
|
local -a _git_commit_aliases
|
||||||
_git_commit_aliases=(
|
_git_commit_aliases=(
|
||||||
'build'
|
'build'
|
||||||
|
|
@ -11,21 +17,42 @@ _git_commit_aliases=(
|
||||||
'revert'
|
'revert'
|
||||||
'style'
|
'style'
|
||||||
'test'
|
'test'
|
||||||
|
'wip'
|
||||||
)
|
)
|
||||||
|
|
||||||
local alias type
|
local _alias _type
|
||||||
for type in "${_git_commit_aliases[@]}"; do
|
for _type in "${_git_commit_aliases[@]}"; do
|
||||||
# an alias can't be named "revert" because the git command takes precedence
|
# an alias can't be named "revert" because the git command takes precedence
|
||||||
# https://stackoverflow.com/a/3538791
|
# https://stackoverflow.com/a/3538791
|
||||||
case "$type" in
|
case "$_type" in
|
||||||
revert) alias=rev ;;
|
revert) _alias=rev ;;
|
||||||
*) alias=$type ;;
|
*) _alias=$_type ;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
local func='!a() { if [ "$1" = "-s" ] || [ "$1" = "--scope" ]; then local scope="$2"; shift 2; git commit -m "'$type'(${scope}): ${@}"; else git commit -m "'$type': ${@}"; fi }; a'
|
local _func='!a() {
|
||||||
if ! git config --global --get-all alias.${alias} >/dev/null 2>&1; then
|
local _scope _attention _message
|
||||||
git config --global alias.${alias} "$func"
|
while [ $# -ne 0 ]; do
|
||||||
fi
|
case $1 in
|
||||||
|
-s | --scope )
|
||||||
|
if [ -z $2 ]; then
|
||||||
|
echo "Missing scope!"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
_scope="$2"
|
||||||
|
shift 2
|
||||||
|
;;
|
||||||
|
-a | --attention )
|
||||||
|
_attention="!"
|
||||||
|
shift 1
|
||||||
|
;;
|
||||||
|
* )
|
||||||
|
_message="${_message} $1"
|
||||||
|
shift 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
done
|
done
|
||||||
|
git commit -m "'$_type'${_scope:+(${_scope})}${_attention}:${_message}"
|
||||||
|
}; a'
|
||||||
|
|
||||||
unset _git_commit_aliases alias type func
|
git config --global alias.$_alias "$_func"
|
||||||
|
done
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,10 @@ To use it, add `git-prompt` to the plugins array in your zshrc file:
|
||||||
plugins=(... git-prompt)
|
plugins=(... git-prompt)
|
||||||
```
|
```
|
||||||
|
|
||||||
|
You may also need to [customize your theme](https://github.com/ohmyzsh/ohmyzsh/issues/9395#issuecomment-1027130429)
|
||||||
|
to change the way the prompt is built. See the
|
||||||
|
[OMZ wiki on customizing themes](https://github.com/ohmyzsh/ohmyzsh/wiki/Customization#overriding-and-adding-themes).
|
||||||
|
|
||||||
See the [original repository](https://github.com/olivierverdier/zsh-git-prompt).
|
See the [original repository](https://github.com/olivierverdier/zsh-git-prompt).
|
||||||
|
|
||||||
## Requirements
|
## Requirements
|
||||||
|
|
|
||||||
|
|
@ -41,8 +41,8 @@ plugins=(... git)
|
||||||
| `gba` | `git branch --all` |
|
| `gba` | `git branch --all` |
|
||||||
| `gbd` | `git branch --delete` |
|
| `gbd` | `git branch --delete` |
|
||||||
| `gbD` | `git branch --delete --force` |
|
| `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\]" \| cut -c 3- \| 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` |
|
||||||
| `gbm` | `git branch --move` |
|
| `gbm` | `git branch --move` |
|
||||||
| `gbnm` | `git branch --no-merged` |
|
| `gbnm` | `git branch --no-merged` |
|
||||||
| `gbr` | `git branch --remote` |
|
| `gbr` | `git branch --remote` |
|
||||||
|
|
@ -111,6 +111,7 @@ plugins=(... git)
|
||||||
| `gfg` | `git ls-files \| grep` |
|
| `gfg` | `git ls-files \| grep` |
|
||||||
| `gm` | `git merge` |
|
| `gm` | `git merge` |
|
||||||
| `gma` | `git merge --abort` |
|
| `gma` | `git merge --abort` |
|
||||||
|
| `gmc` | `git merge --continue` |
|
||||||
| `gms` | `git merge --squash` |
|
| `gms` | `git merge --squash` |
|
||||||
| `gmom` | `git merge origin/$(git_main_branch)` |
|
| `gmom` | `git merge origin/$(git_main_branch)` |
|
||||||
| `gmum` | `git merge upstream/$(git_main_branch)` |
|
| `gmum` | `git merge upstream/$(git_main_branch)` |
|
||||||
|
|
@ -152,6 +153,7 @@ plugins=(... git)
|
||||||
| `grbd` | `git rebase $(git_develop_branch)` |
|
| `grbd` | `git rebase $(git_develop_branch)` |
|
||||||
| `grbm` | `git rebase $(git_main_branch)` |
|
| `grbm` | `git rebase $(git_main_branch)` |
|
||||||
| `grbom` | `git rebase origin/$(git_main_branch)` |
|
| `grbom` | `git rebase origin/$(git_main_branch)` |
|
||||||
|
| `grf` | `git reflog` |
|
||||||
| `gr` | `git remote` |
|
| `gr` | `git remote` |
|
||||||
| `grv` | `git remote --verbose` |
|
| `grv` | `git remote --verbose` |
|
||||||
| `gra` | `git remote add` |
|
| `gra` | `git remote add` |
|
||||||
|
|
@ -165,6 +167,7 @@ plugins=(... git)
|
||||||
| `grhk` | `git reset --keep` |
|
| `grhk` | `git reset --keep` |
|
||||||
| `grhs` | `git reset --soft` |
|
| `grhs` | `git reset --soft` |
|
||||||
| `gpristine` | `git reset --hard && git clean --force -dfx` |
|
| `gpristine` | `git reset --hard && git clean --force -dfx` |
|
||||||
|
| `gwipe` | `git reset --hard && git clean --force -df` |
|
||||||
| `groh` | `git reset origin/$(git_current_branch) --hard` |
|
| `groh` | `git reset origin/$(git_current_branch) --hard` |
|
||||||
| `grs` | `git restore` |
|
| `grs` | `git restore` |
|
||||||
| `grss` | `git restore --source` |
|
| `grss` | `git restore --source` |
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,7 @@ function git_develop_branch() {
|
||||||
function git_main_branch() {
|
function git_main_branch() {
|
||||||
command git rev-parse --git-dir &>/dev/null || return
|
command git rev-parse --git-dir &>/dev/null || return
|
||||||
local ref
|
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
|
if command git show-ref -q --verify $ref; then
|
||||||
echo ${ref:t}
|
echo ${ref:t}
|
||||||
return 0
|
return 0
|
||||||
|
|
@ -147,8 +147,8 @@ function gbds() {
|
||||||
done
|
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\]" | cut -c 3- | 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 gbm='git branch --move'
|
alias gbm='git branch --move'
|
||||||
alias gbnm='git branch --no-merged'
|
alias gbnm='git branch --no-merged'
|
||||||
alias gbr='git branch --remote'
|
alias gbr='git branch --remote'
|
||||||
|
|
@ -252,6 +252,7 @@ alias gignored='git ls-files -v | grep "^[[:lower:]]"'
|
||||||
alias gfg='git ls-files | grep'
|
alias gfg='git ls-files | grep'
|
||||||
alias gm='git merge'
|
alias gm='git merge'
|
||||||
alias gma='git merge --abort'
|
alias gma='git merge --abort'
|
||||||
|
alias gmc='git merge --continue'
|
||||||
alias gms="git merge --squash"
|
alias gms="git merge --squash"
|
||||||
alias gmom='git merge origin/$(git_main_branch)'
|
alias gmom='git merge origin/$(git_main_branch)'
|
||||||
alias gmum='git merge upstream/$(git_main_branch)'
|
alias gmum='git merge upstream/$(git_main_branch)'
|
||||||
|
|
@ -335,6 +336,7 @@ alias grbs='git rebase --skip'
|
||||||
alias grbd='git rebase $(git_develop_branch)'
|
alias grbd='git rebase $(git_develop_branch)'
|
||||||
alias grbm='git rebase $(git_main_branch)'
|
alias grbm='git rebase $(git_main_branch)'
|
||||||
alias grbom='git rebase origin/$(git_main_branch)'
|
alias grbom='git rebase origin/$(git_main_branch)'
|
||||||
|
alias grf='git reflog'
|
||||||
alias gr='git remote'
|
alias gr='git remote'
|
||||||
alias grv='git remote --verbose'
|
alias grv='git remote --verbose'
|
||||||
alias gra='git remote add'
|
alias gra='git remote add'
|
||||||
|
|
@ -348,6 +350,7 @@ alias grhh='git reset --hard'
|
||||||
alias grhk='git reset --keep'
|
alias grhk='git reset --keep'
|
||||||
alias grhs='git reset --soft'
|
alias grhs='git reset --soft'
|
||||||
alias gpristine='git reset --hard && git clean --force -dfx'
|
alias gpristine='git reset --hard && git clean --force -dfx'
|
||||||
|
alias gwipe='git reset --hard && git clean --force -df'
|
||||||
alias groh='git reset origin/$(git_current_branch) --hard'
|
alias groh='git reset origin/$(git_current_branch) --hard'
|
||||||
alias grs='git restore'
|
alias grs='git restore'
|
||||||
alias grss='git restore --source'
|
alias grss='git restore --source'
|
||||||
|
|
|
||||||
|
|
@ -7,9 +7,3 @@ To use it, add `gitfast` to the plugins array in your zshrc file:
|
||||||
```zsh
|
```zsh
|
||||||
plugins=(... gitfast)
|
plugins=(... gitfast)
|
||||||
```
|
```
|
||||||
|
|
||||||
## Aliases
|
|
||||||
|
|
||||||
An earlier version of the plugin also loaded the git plugin. If you want to keep those
|
|
||||||
aliases enable the [git plugin](https://github.com/ohmyzsh/ohmyzsh/tree/master/plugins/git)
|
|
||||||
as well.
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
# Handle $0 according to the standard:
|
# Handle $0 according to the standard:
|
||||||
# https://zdharma-continuum.github.io/Zsh-100-Commits-Club/Zsh-Plugin-Standard.html
|
# https://zdharma-continuum.github.io/Zsh-100-Commits-Club/Zsh-Plugin-Standard.html
|
||||||
0="${${ZERO:-${0:#$ZSH_ARGZERO}}:-${(%):-%N}}"
|
0="${ZERO:-${${0:#$ZSH_ARGZERO}:-${(%):-%N}}}"
|
||||||
0="${${(M)0:#/*}:-$PWD/$0}"
|
0="${${(M)0:#/*}:-$PWD/$0}"
|
||||||
|
|
||||||
source "${0:A:h}/git-prompt.sh"
|
source "${0:A:h}/git-prompt.sh"
|
||||||
|
|
|
||||||
|
|
@ -1,8 +0,0 @@
|
||||||
#!/bin/sh
|
|
||||||
|
|
||||||
url="https://raw.githubusercontent.com/felipec/git-completion"
|
|
||||||
version="1.3.7"
|
|
||||||
|
|
||||||
curl -s -o _git "${url}/v${version}/git-completion.zsh" &&
|
|
||||||
curl -s -o git-completion.bash "${url}/v${version}/git-completion.bash" &&
|
|
||||||
curl -s -o git-prompt.sh "${url}/v${version}/git-prompt.sh"
|
|
||||||
|
|
@ -25,6 +25,7 @@ plugins=(... golang)
|
||||||
| goi | `go install` | Compiles and installs packages to $GOPATH |
|
| goi | `go install` | Compiles and installs packages to $GOPATH |
|
||||||
| gol | `go list` | Lists Go packages |
|
| gol | `go list` | Lists Go packages |
|
||||||
| gom | `go mod` | Access to operations on modules |
|
| gom | `go mod` | Access to operations on modules |
|
||||||
|
| gomt | `go mod tidy` | Tidies up the go.mod file |
|
||||||
| gopa | `cd $GOPATH` | Takes you to `$GOPATH` |
|
| gopa | `cd $GOPATH` | Takes you to `$GOPATH` |
|
||||||
| gopb | `cd $GOPATH/bin` | Takes you to `$GOPATH/bin` |
|
| gopb | `cd $GOPATH/bin` | Takes you to `$GOPATH/bin` |
|
||||||
| gops | `cd $GOPATH/src` | Takes you to `$GOPATH/src` |
|
| gops | `cd $GOPATH/src` | Takes you to `$GOPATH/src` |
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,7 @@ alias goga='go get ./...'
|
||||||
alias goi='go install'
|
alias goi='go install'
|
||||||
alias gol='go list'
|
alias gol='go list'
|
||||||
alias gom='go mod'
|
alias gom='go mod'
|
||||||
|
alias gomt='go mod tidy'
|
||||||
alias gopa='cd $GOPATH'
|
alias gopa='cd $GOPATH'
|
||||||
alias gopb='cd $GOPATH/bin'
|
alias gopb='cd $GOPATH/bin'
|
||||||
alias gops='cd $GOPATH/src'
|
alias gops='cd $GOPATH/src'
|
||||||
|
|
|
||||||
19
plugins/gradle/LICENSE
Normal file
19
plugins/gradle/LICENSE
Normal file
|
|
@ -0,0 +1,19 @@
|
||||||
|
Copyright (c) 2017 Eric Wendelin
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||||
|
this software and associated documentation files (the "Software"), to deal in
|
||||||
|
the Software without restriction, including without limitation the rights to
|
||||||
|
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||||
|
of the Software, and to permit persons to whom the Software is furnished to do
|
||||||
|
so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
||||||
|
|
@ -1,28 +1,4 @@
|
||||||
#compdef gradle gradlew gw
|
#compdef gradle gradlew gw
|
||||||
# THE LINE ABOVE MUST BE THE FIRST LINE OF THIS FILE IN ORDER FOR COMPLETION TO WORK
|
|
||||||
|
|
||||||
#
|
|
||||||
# Taken from https://github.com/gradle/gradle-completion
|
|
||||||
# Copyright (c) 2017 Eric Wendelin
|
|
||||||
#
|
|
||||||
# Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
||||||
# this software and associated documentation files (the "Software"), to deal in
|
|
||||||
# the Software without restriction, including without limitation the rights to
|
|
||||||
# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
|
||||||
# of the Software, and to permit persons to whom the Software is furnished to do
|
|
||||||
# so, subject to the following conditions:
|
|
||||||
#
|
|
||||||
# The above copyright notice and this permission notice shall be included in all
|
|
||||||
# copies or substantial portions of the Software.
|
|
||||||
#
|
|
||||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
# SOFTWARE.
|
|
||||||
# Terms
|
|
||||||
|
|
||||||
__gradle-set-project-root-dir() {
|
__gradle-set-project-root-dir() {
|
||||||
local dir=`pwd`
|
local dir=`pwd`
|
||||||
|
|
@ -38,7 +14,7 @@ __gradle-set-project-root-dir() {
|
||||||
}
|
}
|
||||||
|
|
||||||
__gradle-init-cache-dir() {
|
__gradle-init-cache-dir() {
|
||||||
cache_dir="$HOME/.gradle/completion"
|
cache_dir="${GRADLE_USER_HOME:-$HOME/.gradle}/completion"
|
||||||
mkdir -p $cache_dir
|
mkdir -p $cache_dir
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -98,7 +74,7 @@ __gradle-generate-script-cache() {
|
||||||
zle -R "Generating Gradle build script cache"
|
zle -R "Generating Gradle build script cache"
|
||||||
# Cache all Gradle scripts
|
# Cache all Gradle scripts
|
||||||
local -a gradle_build_scripts
|
local -a gradle_build_scripts
|
||||||
gradle_build_scripts=( $(find $project_root_dir -type f -name "*.gradle" -o -name "*.gradle.kts" 2>/dev/null | egrep -v "$script_exclude_pattern") )
|
gradle_build_scripts=( $(find $project_root_dir -type f -name "*.gradle" -o -name "*.gradle.kts" 2>/dev/null | grep -E -v "$script_exclude_pattern") )
|
||||||
printf "%s\n" "${gradle_build_scripts[@]}" >| $cache_dir/$cache_name
|
printf "%s\n" "${gradle_build_scripts[@]}" >| $cache_dir/$cache_name
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
@ -125,7 +101,7 @@ __gradle-generate-tasks-cache() {
|
||||||
local gradle_all_tasks="" root_tasks="" subproject_tasks="" output_line
|
local gradle_all_tasks="" root_tasks="" subproject_tasks="" output_line
|
||||||
local -a match
|
local -a match
|
||||||
for output_line in ${(f)"$(printf "%s\n" "${gradle_tasks_output[@]}")"}; do
|
for output_line in ${(f)"$(printf "%s\n" "${gradle_tasks_output[@]}")"}; do
|
||||||
if [[ $output_line =~ ^([[:lower:]][[:alnum:][:punct:]]*)([[:space:]]-[[:space:]]([[:print:]]*))? ]]; then
|
if [[ $output_line =~ ^([[:alpha:]][[:alnum:][:punct:]]*)([[:space:]]-[[:space:]]([[:print:]]*))? ]]; then
|
||||||
local task_name="${match[1]}"
|
local task_name="${match[1]}"
|
||||||
local task_description="${match[3]}"
|
local task_description="${match[3]}"
|
||||||
# Completion for subproject tasks with ':' prefix
|
# Completion for subproject tasks with ':' prefix
|
||||||
|
|
|
||||||
|
|
@ -406,7 +406,7 @@ _history-substring-search-end() {
|
||||||
|
|
||||||
# For debugging purposes:
|
# For debugging purposes:
|
||||||
# zle -R "mn: "$_history_substring_search_match_index" m#: "${#_history_substring_search_matches}
|
# 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
|
# 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
|
# before removing search highlight and exiting. This ensures no highlights
|
||||||
# are left lingering after search is finished.
|
# 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}*}" )
|
region_highlight=( "${(@)region_highlight:#*${highlight_memo}*}" )
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
#compdef http
|
#compdef http https
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
# Copyright (c) 2015 GitHub zsh-users - http://github.com/zsh-users
|
# Copyright (c) 2015 GitHub zsh-users - http://github.com/zsh-users
|
||||||
# All rights reserved.
|
# All rights reserved.
|
||||||
|
|
|
||||||
|
|
@ -202,7 +202,7 @@ _ipfs_subcommand(){
|
||||||
_arguments \
|
_arguments \
|
||||||
'--resolve[Check if the given path can be resolved before publishing. Default: true.]' \
|
'--resolve[Check if the given path can be resolved before publishing. Default: true.]' \
|
||||||
'(-t --lifetime)'{-t,--lifetime}'[Time duration that the record will be valid for. Default: 24h.]' \
|
'(-t --lifetime)'{-t,--lifetime}'[Time duration that the record will be valid for. Default: 24h.]' \
|
||||||
'--allow-offline[When offline, save the IPNS record to the the local datastore without broadcasting to the network instead of simply failing.]' \
|
'--allow-offline[When offline, save the IPNS record to the local datastore without broadcasting to the network instead of simply failing.]' \
|
||||||
'--ttl[Time duration this record should be cached for. Uses the same syntax as the lifetime option. (caution: experimental).]' \
|
'--ttl[Time duration this record should be cached for. Uses the same syntax as the lifetime option. (caution: experimental).]' \
|
||||||
'(-k --key)'{-k,--key}"[Name of the key to be used or a valid PeerID, as listed by 'ipfs key list -l'. Default: self.]" \
|
'(-k --key)'{-k,--key}"[Name of the key to be used or a valid PeerID, as listed by 'ipfs key list -l'. Default: self.]" \
|
||||||
'(-Q --quieter)'{-Q,--quieter}'[Write only final hash.]' \
|
'(-Q --quieter)'{-Q,--quieter}'[Write only final hash.]' \
|
||||||
|
|
|
||||||
|
|
@ -16,18 +16,21 @@ This plugin supplies one command, `jira`, through which all its features are exp
|
||||||
|
|
||||||
## Commands
|
## Commands
|
||||||
|
|
||||||
|
`jira help` or `jira usage` will print the below usage instructions
|
||||||
|
|
||||||
| Command | Description |
|
| Command | Description |
|
||||||
| :------------ | :-------------------------------------------------------- |
|
| :------------ | :-------------------------------------------------------- |
|
||||||
| `jira` | Performs the default action |
|
| `jira` | Performs the default action |
|
||||||
| `jira new` | Opens a new Jira issue dialogue |
|
| `jira new` | Opens a new Jira issue dialogue |
|
||||||
| `jira ABC-123` | Opens an existing issue |
|
| `jira ABC-123` | Opens an existing issue |
|
||||||
| `jira ABC-123 m` | Opens an existing issue for adding a comment |
|
| `jira ABC-123 m` | Opens an existing issue for adding a comment |
|
||||||
| `jira dashboard [rapid_view]` | # opens your JIRA dashboard |
|
| `jira dashboard [rapid_view]` | Opens your JIRA dashboard |
|
||||||
| `jira mine` | Queries for your own issues |
|
| `jira mine` | Queries for your own issues |
|
||||||
| `jira tempo` | Opens your JIRA Tempo |
|
| `jira tempo` | Opens your JIRA Tempo |
|
||||||
| `jira reported [username]` | Queries for issues reported by a user |
|
| `jira reported [username]` | Queries for issues reported by a user |
|
||||||
| `jira assigned [username]` | Queries for issues assigned to a user |
|
| `jira assigned [username]` | Queries for issues assigned to a user |
|
||||||
| `jira branch` | Opens an existing issue matching the current branch name |
|
| `jira branch` | Opens an existing issue matching the current branch name |
|
||||||
|
| `jira help` | Prints usage instructions |
|
||||||
|
|
||||||
|
|
||||||
### Jira Branch usage notes
|
### Jira Branch usage notes
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@ _1st_arguments=(
|
||||||
'assigned:search for issues assigned to a user'
|
'assigned:search for issues assigned to a user'
|
||||||
'branch:open the issue named after the git branch of the current directory'
|
'branch:open the issue named after the git branch of the current directory'
|
||||||
'dumpconfig:display effective jira configuration'
|
'dumpconfig:display effective jira configuration'
|
||||||
|
'help:print usage help to stdout'
|
||||||
)
|
)
|
||||||
|
|
||||||
_arguments -C \
|
_arguments -C \
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,21 @@
|
||||||
#
|
#
|
||||||
# See README.md for details
|
# See README.md for details
|
||||||
|
|
||||||
|
function _jira_usage() {
|
||||||
|
cat <<EOF
|
||||||
|
jira Performs the default action
|
||||||
|
jira new Opens a new Jira issue dialogue
|
||||||
|
jira ABC-123 Opens an existing issue
|
||||||
|
jira ABC-123 m Opens an existing issue for adding a comment
|
||||||
|
jira dashboard [rapid_view] Opens your JIRA dashboard
|
||||||
|
jira mine Queries for your own issues
|
||||||
|
jira tempo Opens your JIRA Tempo
|
||||||
|
jira reported [username] Queries for issues reported by a user
|
||||||
|
jira assigned [username] Queries for issues assigned to a user
|
||||||
|
jira branch Opens an existing issue matching the current branch name
|
||||||
|
EOF
|
||||||
|
}
|
||||||
|
|
||||||
function jira() {
|
function jira() {
|
||||||
emulate -L zsh
|
emulate -L zsh
|
||||||
local action jira_url jira_prefix
|
local action jira_url jira_prefix
|
||||||
|
|
@ -44,6 +59,8 @@ function jira() {
|
||||||
open_command "${jira_url}/secure/CreateIssue!default.jspa"
|
open_command "${jira_url}/secure/CreateIssue!default.jspa"
|
||||||
elif [[ "$action" == "assigned" || "$action" == "reported" ]]; then
|
elif [[ "$action" == "assigned" || "$action" == "reported" ]]; then
|
||||||
_jira_query ${@:-$action}
|
_jira_query ${@:-$action}
|
||||||
|
elif [[ "$action" == "help" || "$action" == "usage" ]]; then
|
||||||
|
_jira_usage
|
||||||
elif [[ "$action" == "mine" ]]; then
|
elif [[ "$action" == "mine" ]]; then
|
||||||
echo "Opening my issues"
|
echo "Opening my issues"
|
||||||
open_command "${jira_url}/issues/?filter=-1"
|
open_command "${jira_url}/issues/?filter=-1"
|
||||||
|
|
|
||||||
|
|
@ -8,8 +8,10 @@
|
||||||
#
|
#
|
||||||
export MARKPATH=$HOME/.marks
|
export MARKPATH=$HOME/.marks
|
||||||
|
|
||||||
|
|
||||||
jump() {
|
jump() {
|
||||||
builtin cd -P "$MARKPATH/$1" 2>/dev/null || {echo "No such mark: $1"; return 1}
|
local markpath="$(readlink $MARKPATH/$1)" || {echo "No such mark: $1"; return 1}
|
||||||
|
builtin cd "$markpath" 2>/dev/null || {echo "Destination does not exist for mark [$1]: $markpath"; return 2}
|
||||||
}
|
}
|
||||||
|
|
||||||
mark() {
|
mark() {
|
||||||
|
|
|
||||||
23
plugins/kitty/README.md
Normal file
23
plugins/kitty/README.md
Normal 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)
|
||||||
16
plugins/kitty/kitty.plugin.zsh
Normal file
16
plugins/kitty/kitty.plugin.zsh
Normal 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
|
||||||
|
|
@ -136,6 +136,7 @@ the following environment variables:
|
||||||
| `KUBE_PS1_SUFFIX` | `)` | Prompt closing character |
|
| `KUBE_PS1_SUFFIX` | `)` | Prompt closing character |
|
||||||
| `KUBE_PS1_CLUSTER_FUNCTION` | No default, must be user supplied | Function to customize how cluster is displayed |
|
| `KUBE_PS1_CLUSTER_FUNCTION` | No default, must be user supplied | Function to customize how cluster is displayed |
|
||||||
| `KUBE_PS1_NAMESPACE_FUNCTION` | No default, must be user supplied | Function to customize how namespace is displayed |
|
| `KUBE_PS1_NAMESPACE_FUNCTION` | No default, must be user supplied | Function to customize how namespace is displayed |
|
||||||
|
| `KUBE_PS1_KUBECONFIG_SYMLINK` | `false` | Treat `KUBECONFIG` and `~/.kube/config` files as symbolic links |
|
||||||
|
|
||||||
For terminals that do not support UTF-8, the symbol will be replaced with the
|
For terminals that do not support UTF-8, the symbol will be replaced with the
|
||||||
string `k8s`.
|
string `k8s`.
|
||||||
|
|
|
||||||
|
|
@ -40,6 +40,7 @@ KUBE_PS1_NS_COLOR="${KUBE_PS1_NS_COLOR-cyan}"
|
||||||
KUBE_PS1_BG_COLOR="${KUBE_PS1_BG_COLOR}"
|
KUBE_PS1_BG_COLOR="${KUBE_PS1_BG_COLOR}"
|
||||||
|
|
||||||
KUBE_PS1_KUBECONFIG_CACHE="${KUBECONFIG}"
|
KUBE_PS1_KUBECONFIG_CACHE="${KUBECONFIG}"
|
||||||
|
KUBE_PS1_KUBECONFIG_SYMLINK="${KUBE_PS1_KUBECONFIG_SYMLINK:-false}"
|
||||||
KUBE_PS1_DISABLE_PATH="${HOME}/.kube/kube-ps1/disabled"
|
KUBE_PS1_DISABLE_PATH="${HOME}/.kube/kube-ps1/disabled"
|
||||||
KUBE_PS1_LAST_TIME=0
|
KUBE_PS1_LAST_TIME=0
|
||||||
KUBE_PS1_CLUSTER_FUNCTION="${KUBE_PS1_CLUSTER_FUNCTION}"
|
KUBE_PS1_CLUSTER_FUNCTION="${KUBE_PS1_CLUSTER_FUNCTION}"
|
||||||
|
|
@ -190,14 +191,26 @@ _kube_ps1_file_newer_than() {
|
||||||
local file=$1
|
local file=$1
|
||||||
local check_time=$2
|
local check_time=$2
|
||||||
|
|
||||||
if [[ "${KUBE_PS1_SHELL}" == "zsh" ]]; then
|
if [[ "${KUBE_PS1_KUBECONFIG_SYMLINK}" == "true" ]]; then
|
||||||
mtime=$(zstat +mtime "${file}")
|
if [[ "${KUBE_PS1_SHELL}" == "zsh" ]]; then
|
||||||
elif stat -c "%s" /dev/null &> /dev/null; then
|
mtime=$(zstat -L +mtime "${file}")
|
||||||
# GNU stat
|
elif stat -c "%s" /dev/null &> /dev/null; then
|
||||||
mtime=$(stat -L -c %Y "${file}")
|
# GNU stat
|
||||||
|
mtime=$(stat -c %Y "${file}")
|
||||||
|
else
|
||||||
|
# BSD stat
|
||||||
|
mtime=$(stat -f %m "$file")
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
# BSD stat
|
if [[ "${KUBE_PS1_SHELL}" == "zsh" ]]; then
|
||||||
mtime=$(stat -L -f %m "$file")
|
mtime=$(zstat +mtime "${file}")
|
||||||
|
elif stat -c "%s" /dev/null &> /dev/null; then
|
||||||
|
# GNU stat
|
||||||
|
mtime=$(stat -L -c %Y "${file}")
|
||||||
|
else
|
||||||
|
# BSD stat
|
||||||
|
mtime=$(stat -L -f %m "$file")
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
[[ "${mtime}" -gt "${check_time}" ]]
|
[[ "${mtime}" -gt "${check_time}" ]]
|
||||||
|
|
|
||||||
|
|
@ -180,13 +180,11 @@ alias kej='kubectl edit job'
|
||||||
alias kdj='kubectl describe job'
|
alias kdj='kubectl describe job'
|
||||||
alias kdelj='kubectl delete job'
|
alias kdelj='kubectl delete job'
|
||||||
|
|
||||||
# Only run if the user actually has kubectl installed
|
function kj() { kubectl "$@" -o json | jq; }
|
||||||
if (( ${+_comps[kubectl]} )); then
|
function kjx() { kubectl "$@" -o json | fx; }
|
||||||
function kj() { kubectl "$@" -o json | jq; }
|
function ky() { kubectl "$@" -o yaml | yh; }
|
||||||
function kjx() { kubectl "$@" -o json | fx; }
|
if (( ${+functions[compdef]} )); then
|
||||||
function ky() { kubectl "$@" -o yaml | yh; }
|
compdef _kubectl kj
|
||||||
|
compdef _kubectl kjx
|
||||||
compdef kj=kubectl
|
compdef _kubectl ky
|
||||||
compdef kjx=kubectl
|
|
||||||
compdef ky=kubectl
|
|
||||||
fi
|
fi
|
||||||
|
|
|
||||||
|
|
@ -17,9 +17,9 @@ One can rename default context name for better readability.
|
||||||
|
|
||||||
_Example_. Add to **.zshrc**:
|
_Example_. Add to **.zshrc**:
|
||||||
```
|
```
|
||||||
kubectx_mapping[minikube]="mini"
|
kubectx_mapping["minikube"]="mini"
|
||||||
kubectx_mapping[context_name_from_kubeconfig]="$emoji[wolf_face]"
|
kubectx_mapping["context_name_from_kubeconfig"]="$emoji[wolf_face]"
|
||||||
kubectx_mapping[production_cluster]="%{$fg[yellow]%}prod!%{$reset_color%}"
|
kubectx_mapping["production_cluster"]="%{$fg[yellow]%}prod!%{$reset_color%}"
|
||||||
```
|
```
|
||||||
|
|
||||||

|

|
||||||
|
|
|
||||||
|
|
@ -9,5 +9,5 @@ function kubectx_prompt_info() {
|
||||||
|
|
||||||
# use value in associative array if it exists
|
# use value in associative array if it exists
|
||||||
# otherwise fall back to the context name
|
# otherwise fall back to the context name
|
||||||
echo "${kubectx_mapping[$current_ctx]:-${current_ctx:gs/%/%%}}"
|
echo "${kubectx_mapping[\"$current_ctx\"]:-${current_ctx:gs/%/%%}}"
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,7 @@ plugins=(... laravel)
|
||||||
|:-:|:-:|
|
|:-:|:-:|
|
||||||
| `artisan` | `php artisan` |
|
| `artisan` | `php artisan` |
|
||||||
| `pas` | `php artisan serve` |
|
| `pas` | `php artisan serve` |
|
||||||
|
| `pats` | `php artisan test` |
|
||||||
|
|
||||||
## Database
|
## Database
|
||||||
|
|
||||||
|
|
@ -35,6 +36,10 @@ plugins=(... laravel)
|
||||||
| `pamj` | `php artisan make:job` |
|
| `pamj` | `php artisan make:job` |
|
||||||
| `paml` | `php artisan make:listener` |
|
| `paml` | `php artisan make:listener` |
|
||||||
| `pamn` | `php artisan make:notification` |
|
| `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
|
## Clears
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ alias bob='php artisan bob::build'
|
||||||
|
|
||||||
# Development
|
# Development
|
||||||
alias pas='php artisan serve'
|
alias pas='php artisan serve'
|
||||||
|
alias pats='php artisan test'
|
||||||
|
|
||||||
# Database
|
# Database
|
||||||
alias pam='php artisan migrate'
|
alias pam='php artisan migrate'
|
||||||
|
|
@ -24,6 +25,10 @@ alias pamj='php artisan make:job'
|
||||||
alias paml='php artisan make:listener'
|
alias paml='php artisan make:listener'
|
||||||
alias pamn='php artisan make:notification'
|
alias pamn='php artisan make:notification'
|
||||||
alias pampp='php artisan make:provider'
|
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
|
# Clears
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,11 @@ To start using it, add the `macos` plugin to your plugins array in `~/.zshrc`:
|
||||||
plugins=(... macos)
|
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
|
## Commands
|
||||||
|
|
||||||
|
|
@ -17,7 +21,7 @@ Original author: [Sorin Ionescu](https://github.com/sorin-ionescu)
|
||||||
| `tab` | Open the current directory in a new tab |
|
| `tab` | Open the current directory in a new tab |
|
||||||
| `split_tab` | Split the current terminal tab horizontally |
|
| `split_tab` | Split the current terminal tab horizontally |
|
||||||
| `vsplit_tab` | Split the current terminal tab vertically |
|
| `vsplit_tab` | Split the current terminal tab vertically |
|
||||||
| `ofd` | Open the current directory in a Finder window |
|
| `ofd` | Open passed directories (or $PWD by default) in Finder |
|
||||||
| `pfd` | Return the path of the frontmost Finder window |
|
| `pfd` | Return the path of the frontmost Finder window |
|
||||||
| `pfs` | Return the current Finder selection |
|
| `pfs` | Return the current Finder selection |
|
||||||
| `cdf` | `cd` to the current Finder directory |
|
| `cdf` | `cd` to the current Finder directory |
|
||||||
|
|
@ -37,7 +41,9 @@ Original author: [Sorin Ionescu](https://github.com/sorin-ionescu)
|
||||||
|
|
||||||
## Acknowledgements
|
## 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)
|
[shpotify](https://github.com/hnarayanan/shpotify)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,15 @@
|
||||||
0="${${ZERO:-${0:#$ZSH_ARGZERO}}:-${(%):-%N}}"
|
0="${${ZERO:-${0:#$ZSH_ARGZERO}}:-${(%):-%N}}"
|
||||||
0="${${(M)0:#/*}:-$PWD/$0}"
|
0="${${(M)0:#/*}:-$PWD/$0}"
|
||||||
|
|
||||||
# Open the current directory in a Finder window
|
# Open in Finder the directories passed as arguments, or the current directory if
|
||||||
alias ofd='open_command $PWD'
|
# no directories are passed
|
||||||
|
function ofd {
|
||||||
|
if (( ! $# )); then
|
||||||
|
open_command $PWD
|
||||||
|
else
|
||||||
|
open_command $@
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
# Show/hide hidden files in the Finder
|
# Show/hide hidden files in the Finder
|
||||||
alias showfiles="defaults write com.apple.finder AppleShowAllFiles -bool true && killall Finder"
|
alias showfiles="defaults write com.apple.finder AppleShowAllFiles -bool true && killall Finder"
|
||||||
|
|
@ -72,6 +79,13 @@ EOF
|
||||||
key code 36 #(presses enter)
|
key code 36 #(presses enter)
|
||||||
end tell
|
end tell
|
||||||
EOF
|
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
|
else
|
||||||
echo "$0: unsupported terminal app: $the_app" >&2
|
echo "$0: unsupported terminal app: $the_app" >&2
|
||||||
return 1
|
return 1
|
||||||
|
|
@ -119,6 +133,12 @@ EOF
|
||||||
delay 1
|
delay 1
|
||||||
keystroke "${command} \n"
|
keystroke "${command} \n"
|
||||||
end tell
|
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
|
EOF
|
||||||
else
|
else
|
||||||
echo "$0: unsupported terminal app: $the_app" >&2
|
echo "$0: unsupported terminal app: $the_app" >&2
|
||||||
|
|
@ -168,6 +188,12 @@ EOF
|
||||||
delay 1
|
delay 1
|
||||||
keystroke "${command} \n"
|
keystroke "${command} \n"
|
||||||
end tell
|
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
|
EOF
|
||||||
else
|
else
|
||||||
echo "$0: unsupported terminal app: $the_app" >&2
|
echo "$0: unsupported terminal app: $the_app" >&2
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,9 @@ fi
|
||||||
# Load mise hooks
|
# Load mise hooks
|
||||||
eval "$($__mise activate zsh)"
|
eval "$($__mise activate zsh)"
|
||||||
|
|
||||||
|
# Hook mise into current environment
|
||||||
|
eval "$($__mise hook-env -s zsh)"
|
||||||
|
|
||||||
# If the completion file doesn't exist yet, we need to autoload it and
|
# If the completion file doesn't exist yet, we need to autoload it and
|
||||||
# bind it to `mise`. Otherwise, compinit will have already done that.
|
# bind it to `mise`. Otherwise, compinit will have already done that.
|
||||||
if [[ ! -f "$ZSH_CACHE_DIR/completions/_$__mise" ]]; then
|
if [[ ! -f "$ZSH_CACHE_DIR/completions/_$__mise" ]]; then
|
||||||
|
|
|
||||||
|
|
@ -97,7 +97,7 @@ __run() {
|
||||||
'-address=[(addr) The address of the Nomad server. Overrides the NOMAD_ADDR environment variable if set. Default = http://127.0.0.1:4646]' \
|
'-address=[(addr) The address of the Nomad server. Overrides the NOMAD_ADDR environment variable if set. Default = http://127.0.0.1:4646]' \
|
||||||
'-region=[(region) The region of the Nomad servers to forward commands to. Overrides the NOMAD_REGION environment variable if set. Defaults to the Agent s local region.]' \
|
'-region=[(region) The region of the Nomad servers to forward commands to. Overrides the NOMAD_REGION environment variable if set. Defaults to the Agent s local region.]' \
|
||||||
'-no-color[Disables colored command output.]' \
|
'-no-color[Disables colored command output.]' \
|
||||||
'-check-index[If set, the job is only registered or updated if the the passed job modify index matches the server side version. If a check-index value of zero is passed, the job is only registered if it does not yet exist. If a non-zero value is passed, it ensures that the job is being updated from a known state. The use of this flag is most common in conjunction with plan command.]' \
|
'-check-index[If set, the job is only registered or updated if the passed job modify index matches the server side version. If a check-index value of zero is passed, the job is only registered if it does not yet exist. If a non-zero value is passed, it ensures that the job is being updated from a known state. The use of this flag is most common in conjunction with plan command.]' \
|
||||||
'-detach[Return immediately instead of entering monitor mode. After job submission, the evaluation ID will be printed to the screen, which can be used to examine the evaluation using the eval-status command.]' \
|
'-detach[Return immediately instead of entering monitor mode. After job submission, the evaluation ID will be printed to the screen, which can be used to examine the evaluation using the eval-status command.]' \
|
||||||
'-output[Output the JSON that would be submitted to the HTTP API without submitting the job.]' \
|
'-output[Output the JSON that would be submitted to the HTTP API without submitting the job.]' \
|
||||||
'-verbose[Show full information.]'
|
'-verbose[Show full information.]'
|
||||||
|
|
|
||||||
|
|
@ -26,9 +26,9 @@ These settings should go in your zshrc file, before Oh My Zsh is sourced:
|
||||||
#### Lazy startup
|
#### 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
|
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
|
nvm script only when using it, and will create a function for `node`, `npm`, `npx`, `pnpm`, `yarn`, `corepack`
|
||||||
command(s) specified by `lazy-cmd` option, so when you call either of them, nvm will be loaded and run with
|
and the command(s) specified by `lazy-cmd` option, so when you call either of them, nvm will be loaded and run
|
||||||
default version. To enable it, you can add this snippet to your zshrc, before Oh My Zsh is sourced:
|
with default version. To enable it, you can add this snippet to your zshrc, before Oh My Zsh is sourced:
|
||||||
|
|
||||||
```zsh
|
```zsh
|
||||||
zstyle ':omz:plugins:nvm' lazy yes
|
zstyle ':omz:plugins:nvm' lazy yes
|
||||||
|
|
@ -43,8 +43,7 @@ zstyle ':omz:plugins:nvm' lazy-cmd eslint prettier typescript ...
|
||||||
|
|
||||||
#### `.nvmrc` autoload
|
#### `.nvmrc` autoload
|
||||||
|
|
||||||
Note: _this option cannot be used at the same time as `lazy`. `autoload` will override it and load `nvm` at
|
Note: _if used at the same time as `lazy`, `autoload` will start working only after nvm has been lazy-loaded_
|
||||||
startup._
|
|
||||||
|
|
||||||
If set, the plugin will automatically load a node version when if finds a
|
If set, the plugin will automatically load a node version when if finds a
|
||||||
[`.nvmrc` file](https://github.com/nvm-sh/nvm#nvmrc) in the current working directory indicating which node
|
[`.nvmrc` file](https://github.com/nvm-sh/nvm#nvmrc) in the current working directory indicating which node
|
||||||
|
|
|
||||||
|
|
@ -1,34 +0,0 @@
|
||||||
#compdef nvm
|
|
||||||
#autoload
|
|
||||||
|
|
||||||
[[ -f "$NVM_DIR/nvm.sh" ]] || return 0
|
|
||||||
|
|
||||||
local -a _1st_arguments
|
|
||||||
_1st_arguments=(
|
|
||||||
'help:show help'
|
|
||||||
'--version:print out the latest released version of nvm'
|
|
||||||
'install:download and install a version in <node|iojs|node version number>'
|
|
||||||
'install-latest-npm:download and install the latest npm version'
|
|
||||||
'uninstall:uninstall a version'
|
|
||||||
'use:modify PATH to use <version>. Uses .nvmrc if available'
|
|
||||||
'exec:run <command> on <version>. Uses .nvmrc if available'
|
|
||||||
'run:run `node` on <version> with <args> as arguments. Uses .nvmrc if available'
|
|
||||||
'current:list installed versions'
|
|
||||||
'ls:list installed versions or versions matching a given description'
|
|
||||||
'version:resolve the given description to a single local version'
|
|
||||||
'version-remote:resolve the given description to a single remote version'
|
|
||||||
'ls-remote:list remote versions available for install'
|
|
||||||
'deactivate:undo effects of `nvm` on current shell'
|
|
||||||
'alias:show or set aliases'
|
|
||||||
'unalias:deletes an alias'
|
|
||||||
'reinstall-packages:reinstall global `npm` packages contained in <version> to current version'
|
|
||||||
'unload:unload `nvm` from shell'
|
|
||||||
'which:display path to installed node version. Uses .nvmrc if available'
|
|
||||||
)
|
|
||||||
|
|
||||||
_arguments -C '*:: :->subcmds' && return 0
|
|
||||||
|
|
||||||
if (( CURRENT == 1 )); then
|
|
||||||
_describe -t commands "nvm subcommand" _1st_arguments
|
|
||||||
return
|
|
||||||
fi
|
|
||||||
|
|
@ -1,3 +1,7 @@
|
||||||
|
# Don't try to load nvm if command already available
|
||||||
|
# Note: nvm is a function so we need to use `which`
|
||||||
|
which nvm &>/dev/null && return
|
||||||
|
|
||||||
# See https://github.com/nvm-sh/nvm#installation-and-update
|
# See https://github.com/nvm-sh/nvm#installation-and-update
|
||||||
if [[ -z "$NVM_DIR" ]]; then
|
if [[ -z "$NVM_DIR" ]]; then
|
||||||
if [[ -d "$HOME/.nvm" ]]; then
|
if [[ -d "$HOME/.nvm" ]]; then
|
||||||
|
|
@ -12,57 +16,49 @@ if [[ -z "$NVM_DIR" ]]; then
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Don't try to load nvm if command already available
|
|
||||||
# Note: nvm is a function so we need to use `which`
|
|
||||||
which nvm &>/dev/null && return
|
|
||||||
|
|
||||||
if [[ -z "$NVM_DIR" ]] || [[ ! -f "$NVM_DIR/nvm.sh" ]]; then
|
if [[ -z "$NVM_DIR" ]] || [[ ! -f "$NVM_DIR/nvm.sh" ]]; then
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if zstyle -t ':omz:plugins:nvm' lazy && \
|
function _omz_load_nvm_completion {
|
||||||
! zstyle -t ':omz:plugins:nvm' autoload; then
|
local _nvm_completion
|
||||||
# Call nvm when first using nvm, node, npm, pnpm, yarn or other commands in lazy-cmd
|
# Load nvm bash completion
|
||||||
zstyle -a ':omz:plugins:nvm' lazy-cmd nvm_lazy_cmd
|
for _nvm_completion in "$NVM_DIR/bash_completion" "$NVM_HOMEBREW/etc/bash_completion.d/nvm"; do
|
||||||
nvm_lazy_cmd=(nvm node npm npx pnpm yarn $nvm_lazy_cmd) # default values
|
if [[ -f "$_nvm_completion" ]]; then
|
||||||
eval "
|
# Load bashcompinit
|
||||||
function $nvm_lazy_cmd {
|
autoload -U +X bashcompinit && bashcompinit
|
||||||
for func in $nvm_lazy_cmd; do
|
# Bypass compinit call in nvm bash completion script. See:
|
||||||
if (( \$+functions[\$func] )); then
|
# https://github.com/nvm-sh/nvm/blob/4436638/bash_completion#L86-L93
|
||||||
unfunction \$func
|
ZSH_VERSION= source "$_nvm_completion"
|
||||||
fi
|
break
|
||||||
done
|
fi
|
||||||
# Load nvm if it exists in \$NVM_DIR
|
done
|
||||||
[[ -f \"\$NVM_DIR/nvm.sh\" ]] && source \"\$NVM_DIR/nvm.sh\"
|
unfunction _omz_load_nvm_completion
|
||||||
\"\$0\" \"\$@\"
|
}
|
||||||
}
|
|
||||||
"
|
|
||||||
unset nvm_lazy_cmd
|
|
||||||
else
|
|
||||||
source "$NVM_DIR/nvm.sh"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Autoload nvm when finding a .nvmrc file in the current directory
|
function _omz_setup_autoload {
|
||||||
# Adapted from: https://github.com/nvm-sh/nvm#zsh
|
if ! zstyle -t ':omz:plugins:nvm' autoload; then
|
||||||
if zstyle -t ':omz:plugins:nvm' autoload; then
|
unfunction _omz_setup_autoload
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Autoload nvm when finding a .nvmrc file in the current directory
|
||||||
|
# Adapted from: https://github.com/nvm-sh/nvm#zsh
|
||||||
function load-nvmrc {
|
function load-nvmrc {
|
||||||
local node_version="$(nvm version)"
|
|
||||||
local nvmrc_path="$(nvm_find_nvmrc)"
|
local nvmrc_path="$(nvm_find_nvmrc)"
|
||||||
local nvm_silent=""
|
local nvm_silent=""
|
||||||
zstyle -t ':omz:plugins:nvm' silent-autoload && nvm_silent="--silent"
|
zstyle -t ':omz:plugins:nvm' silent-autoload && nvm_silent="--silent"
|
||||||
|
|
||||||
if [[ -n "$nvmrc_path" ]]; then
|
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
|
if [[ "$nvmrc_node_version" = "N/A" ]]; then
|
||||||
nvm install
|
nvm install
|
||||||
elif [[ "$nvmrc_node_version" != "$node_version" ]]; then
|
elif [[ "$nvmrc_node_version" != "$(nvm version)" ]]; then
|
||||||
nvm use $nvm_silent
|
nvm use $nvm_silent
|
||||||
fi
|
fi
|
||||||
elif [[ "$node_version" != "$(nvm version default)" ]]; then
|
elif [[ -n "$(PWD=$OLDPWD nvm_find_nvmrc)" ]] && [[ "$(nvm version)" != "$(nvm version default)" ]]; then
|
||||||
if [[ -z $nvm_silent ]]; then
|
[[ -z $nvm_silent ]] && echo "Reverting to nvm default version"
|
||||||
echo "Reverting to nvm default version"
|
|
||||||
fi
|
|
||||||
|
|
||||||
nvm use default $nvm_silent
|
nvm use default $nvm_silent
|
||||||
fi
|
fi
|
||||||
|
|
@ -72,18 +68,30 @@ if zstyle -t ':omz:plugins:nvm' autoload; then
|
||||||
add-zsh-hook chpwd load-nvmrc
|
add-zsh-hook chpwd load-nvmrc
|
||||||
|
|
||||||
load-nvmrc
|
load-nvmrc
|
||||||
|
unfunction _omz_setup_autoload
|
||||||
|
}
|
||||||
|
|
||||||
|
if zstyle -t ':omz:plugins:nvm' lazy; then
|
||||||
|
# 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 corepack $nvm_lazy_cmd) # default values
|
||||||
|
eval "
|
||||||
|
function $nvm_lazy_cmd {
|
||||||
|
for func in $nvm_lazy_cmd; do
|
||||||
|
if (( \$+functions[\$func] )); then
|
||||||
|
unfunction \$func
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
# Load nvm if it exists in \$NVM_DIR
|
||||||
|
[[ -f \"\$NVM_DIR/nvm.sh\" ]] && source \"\$NVM_DIR/nvm.sh\"
|
||||||
|
_omz_load_nvm_completion
|
||||||
|
_omz_setup_autoload
|
||||||
|
\"\$0\" \"\$@\"
|
||||||
|
}
|
||||||
|
"
|
||||||
|
unset nvm_lazy_cmd
|
||||||
|
else
|
||||||
|
source "$NVM_DIR/nvm.sh"
|
||||||
|
_omz_load_nvm_completion
|
||||||
|
_omz_setup_autoload
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Load nvm bash completion
|
|
||||||
for nvm_completion in "$NVM_DIR/bash_completion" "$NVM_HOMEBREW/etc/bash_completion.d/nvm"; do
|
|
||||||
if [[ -f "$nvm_completion" ]]; then
|
|
||||||
# Load bashcompinit
|
|
||||||
autoload -U +X bashcompinit && bashcompinit
|
|
||||||
# Bypass compinit call in nvm bash completion script. See:
|
|
||||||
# https://github.com/nvm-sh/nvm/blob/4436638/bash_completion#L86-L93
|
|
||||||
ZSH_VERSION= source "$nvm_completion"
|
|
||||||
break
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
unset NVM_HOMEBREW nvm_completion
|
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,8 @@
|
||||||
|
|
||||||
_pass () {
|
_pass () {
|
||||||
local cmd
|
local cmd
|
||||||
|
local rootcontext
|
||||||
|
rootcontext=$curcontext
|
||||||
if (( CURRENT > 2)); then
|
if (( CURRENT > 2)); then
|
||||||
cmd=${words[2]}
|
cmd=${words[2]}
|
||||||
# Set the context for the subcommand.
|
# Set the context for the subcommand.
|
||||||
|
|
@ -123,8 +125,9 @@ _pass_cmd_show () {
|
||||||
_pass_complete_entries_helper () {
|
_pass_complete_entries_helper () {
|
||||||
local IFS=$'\n'
|
local IFS=$'\n'
|
||||||
local prefix
|
local prefix
|
||||||
zstyle -s ":completion:${curcontext}:" prefix prefix || prefix="${PASSWORD_STORE_DIR:-$HOME/.password-store}"
|
zstyle -s ":completion:${rootcontext}:" prefix prefix ||
|
||||||
_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):-""}
|
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 () {
|
_pass_complete_entries_with_subdirs () {
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@
|
||||||
#-------------------------------------------------------------------------------
|
#-------------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
# The idea/inspiration for a per directory history is from Stewart MacArthur[1]
|
# The idea/inspiration for a per directory history is from Stewart MacArthur[1]
|
||||||
# and Dieter[2], the implementation idea is from Bart Schaefer on the the zsh
|
# and Dieter[2], the implementation idea is from Bart Schaefer on the zsh
|
||||||
# mailing list[3]. The implementation is by Jim Hester in September 2012.
|
# mailing list[3]. The implementation is by Jim Hester in September 2012.
|
||||||
#
|
#
|
||||||
# [1]: http://www.compbiome.com/2010/07/bash-per-directory-bash-history.html
|
# [1]: http://www.compbiome.com/2010/07/bash-per-directory-bash-history.html
|
||||||
|
|
|
||||||
|
|
@ -1,27 +1,27 @@
|
||||||
# Automatic poetry environment activation/deactivation
|
|
||||||
_togglePoetryShell() {
|
_togglePoetryShell() {
|
||||||
# deactivate environment if pyproject.toml doesn't exist and not in a subdir
|
# Determine if currently in a Poetry-managed directory
|
||||||
if [[ ! -f "$PWD/pyproject.toml" ]] ; then
|
local in_poetry_dir=0
|
||||||
if [[ "$poetry_active" == 1 ]]; then
|
if [[ -f "$PWD/pyproject.toml" ]] && grep -q 'tool.poetry' "$PWD/pyproject.toml"; then
|
||||||
if [[ "$PWD" != "$poetry_dir"* ]]; then
|
in_poetry_dir=1
|
||||||
export poetry_active=0
|
|
||||||
deactivate
|
|
||||||
return
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# activate the environment if pyproject.toml exists
|
# Deactivate the current environment if moving out of a Poetry directory or into a different Poetry directory
|
||||||
if [[ "$poetry_active" != 1 ]]; then
|
if [[ $poetry_active -eq 1 ]] && { [[ $in_poetry_dir -eq 0 ]] && [[ "$PWD" != "$poetry_dir"* ]]; }; then
|
||||||
if [[ -f "$PWD/pyproject.toml" ]]; then
|
export poetry_active=0
|
||||||
if grep -q 'tool.poetry' "$PWD/pyproject.toml"; then
|
unset poetry_dir
|
||||||
export poetry_active=1
|
deactivate
|
||||||
export poetry_dir="$PWD"
|
fi
|
||||||
source "$(poetry env info --path)/bin/activate"
|
|
||||||
fi
|
# Activate the environment if in a Poetry directory and no environment is currently active
|
||||||
|
if [[ $in_poetry_dir -eq 1 ]] && [[ $poetry_active -ne 1 ]]; then
|
||||||
|
venv_dir=$(poetry env info --path 2>/dev/null)
|
||||||
|
if [[ -n "$venv_dir" ]]; then
|
||||||
|
export poetry_active=1
|
||||||
|
export poetry_dir="$PWD"
|
||||||
|
source "${venv_dir}/bin/activate"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
autoload -U add-zsh-hook
|
autoload -U add-zsh-hook
|
||||||
add-zsh-hook chpwd _togglePoetryShell
|
add-zsh-hook chpwd _togglePoetryShell
|
||||||
_togglePoetryShell
|
_togglePoetryShell # Initial call to check the current directory at shell startup
|
||||||
|
|
|
||||||
9
plugins/procs/README.md
Normal file
9
plugins/procs/README.md
Normal 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)
|
||||||
|
```
|
||||||
13
plugins/procs/procs.plugin.zsh
Normal file
13
plugins/procs/procs.plugin.zsh
Normal 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" &|
|
||||||
|
|
@ -10,7 +10,7 @@ To use it, add `pyenv` to the plugins array in your zshrc file:
|
||||||
plugins=(... pyenv)
|
plugins=(... pyenv)
|
||||||
```
|
```
|
||||||
|
|
||||||
If you receive a `Found pyenv, but it is badly configured.` error on startup, you may need to ensure that `pyenv` is initialized before the oh-my-zsh pyenv plugin is loaded. This can be achived by adding the following earlier in the `.zshrc` file than the `plugins=(...)` line:
|
If you receive a `Found pyenv, but it is badly configured.` error on startup, you may need to ensure that `pyenv` is initialized before the oh-my-zsh pyenv plugin is loaded. This can be achieved by adding the following earlier in the `.zshrc` file than the `plugins=(...)` line:
|
||||||
|
|
||||||
```zsh
|
```zsh
|
||||||
export PYENV_ROOT="$HOME/.pyenv"
|
export PYENV_ROOT="$HOME/.pyenv"
|
||||||
|
|
|
||||||
|
|
@ -22,8 +22,19 @@ plugins=(... python)
|
||||||
|
|
||||||
## Virtual environments
|
## Virtual environments
|
||||||
|
|
||||||
The plugin provides two utilities to manage Python venvs:
|
The plugin provides three utilities to manage Python 3.3+ [venv](https://docs.python.org/3/library/venv.html)
|
||||||
|
virtual environments:
|
||||||
|
|
||||||
- `mkv [name]`: make a new virtual environment called `name` (default: `venv`) in current directory.
|
- `mkv [name]`: make a new virtual environment called `name` (default: if set `$PYTHON_VENV_NAME`, else
|
||||||
|
`venv`) in the current directory.
|
||||||
|
|
||||||
- `vrun [name]`: activate virtual environment called `name` (default: `venv`) in current directory.
|
- `vrun [name]`: Activate the virtual environment called `name` (default: if set `$PYTHON_VENV_NAME`, else
|
||||||
|
`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 (keeps venv activated
|
||||||
|
in subdirectories).
|
||||||
|
- To enable the feature, set `export PYTHON_AUTO_VRUN=true` before sourcing oh-my-zsh.
|
||||||
|
- 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"`
|
||||||
|
|
|
||||||
|
|
@ -51,11 +51,12 @@ alias pyserver="python3 -m http.server"
|
||||||
|
|
||||||
|
|
||||||
## venv utilities
|
## venv utilities
|
||||||
|
: ${PYTHON_VENV_NAME:=venv}
|
||||||
|
|
||||||
# Activate a the python virtual environment specified.
|
# Activate a the python virtual environment specified.
|
||||||
# If none specified, use 'venv'.
|
# If none specified, use $PYTHON_VENV_NAME, else 'venv'.
|
||||||
function vrun() {
|
function vrun() {
|
||||||
local name="${1:-venv}"
|
local name="${1:-$PYTHON_VENV_NAME}"
|
||||||
local venvpath="${name:P}"
|
local venvpath="${name:P}"
|
||||||
|
|
||||||
if [[ ! -d "$venvpath" ]]; then
|
if [[ ! -d "$venvpath" ]]; then
|
||||||
|
|
@ -72,12 +73,35 @@ function vrun() {
|
||||||
echo "Activated virtual environment ${name}"
|
echo "Activated virtual environment ${name}"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Create a new virtual environment, with default name 'venv'.
|
# Create a new virtual environment using the specified name.
|
||||||
|
# If none specfied, use $PYTHON_VENV_NAME
|
||||||
function mkv() {
|
function mkv() {
|
||||||
local name="${1:-venv}"
|
local name="${1:-$PYTHON_VENV_NAME}"
|
||||||
local venvpath="${name:P}"
|
local venvpath="${name:P}"
|
||||||
|
|
||||||
python3 -m venv "${name}" || return
|
python3 -m venv "${name}" || return
|
||||||
echo >&2 "Created venv in '${venvpath}'"
|
echo >&2 "Created venv in '${venvpath}'"
|
||||||
vrun "${name}"
|
vrun "${name}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if [[ "$PYTHON_AUTO_VRUN" == "true" ]]; then
|
||||||
|
# Automatically activate venv when changing dir
|
||||||
|
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
|
||||||
|
auto_vrun
|
||||||
|
fi
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,8 @@ if parsed.scheme not in proxy_protocols:
|
||||||
|
|
||||||
def make_argv():
|
def make_argv():
|
||||||
yield "nc"
|
yield "nc"
|
||||||
if sys.platform == 'linux':
|
if sys.platform in {'linux', 'cygwin'}:
|
||||||
|
# caveats: the built-in netcat of most linux distributions and cygwin support proxy type
|
||||||
# caveats: macOS built-in netcat command not supported proxy-type
|
# caveats: macOS built-in netcat command not supported proxy-type
|
||||||
yield "-X" # --proxy-type
|
yield "-X" # --proxy-type
|
||||||
# Supported protocols are 4 (SOCKS v4), 5 (SOCKS v5) and connect (HTTP proxy).
|
# Supported protocols are 4 (SOCKS v4), 5 (SOCKS v5) and connect (HTTP proxy).
|
||||||
|
|
|
||||||
|
|
@ -90,7 +90,7 @@ use the `ssh-add-args` setting. You can pass multiple arguments separated by spa
|
||||||
zstyle :omz:plugins:ssh-agent ssh-add-args -K -c -a /run/user/1000/ssh-auth
|
zstyle :omz:plugins:ssh-agent ssh-add-args -K -c -a /run/user/1000/ssh-auth
|
||||||
```
|
```
|
||||||
|
|
||||||
These will then be passed the the `ssh-add` call as if written directly. The example
|
These will then be passed the `ssh-add` call as if written directly. The example
|
||||||
above will turn into:
|
above will turn into:
|
||||||
|
|
||||||
```zsh
|
```zsh
|
||||||
|
|
|
||||||
|
|
@ -62,7 +62,7 @@ function _add_identities() {
|
||||||
# if id is an absolute path, make file equal to id
|
# if id is an absolute path, make file equal to id
|
||||||
[[ "$id" = /* ]] && file="$id" || file="$HOME/.ssh/$id"
|
[[ "$id" = /* ]] && file="$id" || file="$HOME/.ssh/$id"
|
||||||
# check for filename match, otherwise try for signature match
|
# check for filename match, otherwise try for signature match
|
||||||
if [[ ${loaded_ids[(I)$file]} -le 0 ]]; then
|
if [[ -f $file && ${loaded_ids[(I)$file]} -le 0 ]]; then
|
||||||
sig="$(ssh-keygen -lf "$file" | awk '{print $2}')"
|
sig="$(ssh-keygen -lf "$file" | awk '{print $2}')"
|
||||||
[[ ${loaded_sigs[(I)$sig]} -le 0 ]] && not_loaded+=("$file")
|
[[ ${loaded_sigs[(I)$sig]} -le 0 ]] && not_loaded+=("$file")
|
||||||
fi
|
fi
|
||||||
|
|
@ -98,8 +98,10 @@ function _add_identities() {
|
||||||
|
|
||||||
# Add a nifty symlink for screen/tmux if agent forwarding is enabled
|
# Add a nifty symlink for screen/tmux if agent forwarding is enabled
|
||||||
if zstyle -t :omz:plugins:ssh-agent agent-forwarding \
|
if zstyle -t :omz:plugins:ssh-agent agent-forwarding \
|
||||||
&& [[ -n "$SSH_AUTH_SOCK" && ! -L "$SSH_AUTH_SOCK" ]]; then
|
&& [[ -n "$SSH_AUTH_SOCK" ]]; then
|
||||||
ln -sf "$SSH_AUTH_SOCK" /tmp/ssh-agent-$USERNAME-screen
|
if [[ ! -L "$SSH_AUTH_SOCK" ]]; then
|
||||||
|
ln -sf "$SSH_AUTH_SOCK" /tmp/ssh-agent-$USERNAME-screen
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
_start_agent
|
_start_agent
|
||||||
fi
|
fi
|
||||||
|
|
|
||||||
53
plugins/ssh/ssh.plugin.zsh
Normal file
53
plugins/ssh/ssh.plugin.zsh
Normal file
|
|
@ -0,0 +1,53 @@
|
||||||
|
############################################################
|
||||||
|
# Take all host sections in .ssh/config and offer them for
|
||||||
|
# completion as hosts (e.g. for ssh, rsync, scp and the like)
|
||||||
|
# Filter out wildcard host sections.
|
||||||
|
_ssh_configfile="$HOME/.ssh/config"
|
||||||
|
if [[ -f "$_ssh_configfile" ]]; then
|
||||||
|
_ssh_hosts=($(
|
||||||
|
egrep '^Host.*' "$_ssh_configfile" |\
|
||||||
|
awk '{for (i=2; i<=NF; i++) print $i}' |\
|
||||||
|
sort |\
|
||||||
|
uniq |\
|
||||||
|
grep -v '^*' |\
|
||||||
|
sed -e 's/\.*\*$//'
|
||||||
|
))
|
||||||
|
zstyle ':completion:*:hosts' hosts $_ssh_hosts
|
||||||
|
unset _ssh_hosts
|
||||||
|
fi
|
||||||
|
unset _ssh_configfile
|
||||||
|
|
||||||
|
############################################################
|
||||||
|
# Remove host key from known hosts based on a host section
|
||||||
|
# name from .ssh/config
|
||||||
|
function ssh_rmhkey {
|
||||||
|
local ssh_configfile="$HOME/.ssh/config"
|
||||||
|
local ssh_host="$1"
|
||||||
|
if [[ -z "$ssh_host" ]]; then return; fi
|
||||||
|
ssh-keygen -R $(grep -A10 "$ssh_host" "$ssh_configfile" | grep -i HostName | head -n 1 | awk '{print $2}')
|
||||||
|
}
|
||||||
|
compctl -k hosts ssh_rmhkey
|
||||||
|
|
||||||
|
############################################################
|
||||||
|
# Load SSH key into agent
|
||||||
|
function ssh_load_key() {
|
||||||
|
local key="$1"
|
||||||
|
if [[ -z "$key" ]]; then return; fi
|
||||||
|
local keyfile="$HOME/.ssh/$key"
|
||||||
|
local keysig=$(ssh-keygen -l -f "$keyfile")
|
||||||
|
if ( ! ssh-add -l | grep -q "$keysig" ); then
|
||||||
|
ssh-add "$keyfile"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
############################################################
|
||||||
|
# Remove SSH key from agent
|
||||||
|
function ssh_unload_key {
|
||||||
|
local key="$1"
|
||||||
|
if [[ -z "$key" ]]; then return; fi
|
||||||
|
local keyfile="$HOME/.ssh/$key"
|
||||||
|
local keysig=$(ssh-keygen -l -f "$keyfile")
|
||||||
|
if ( ssh-add -l | grep -q "$keysig" ); then
|
||||||
|
ssh-add -d "$keyfile"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
# ignore oh-my-zsh theme
|
|
||||||
unset ZSH_THEME
|
|
||||||
|
|
||||||
if (( $+commands[starship] )); then
|
if (( $+commands[starship] )); then
|
||||||
|
# ignore oh-my-zsh theme
|
||||||
|
unset ZSH_THEME
|
||||||
|
|
||||||
eval "$(starship init zsh)"
|
eval "$(starship init zsh)"
|
||||||
else
|
else
|
||||||
echo '[oh-my-zsh] starship not found, please install it from https://starship.rs'
|
echo '[oh-my-zsh] starship not found, please install it from https://starship.rs'
|
||||||
|
|
|
||||||
9
plugins/stripe/README.md
Normal file
9
plugins/stripe/README.md
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
# Stripe
|
||||||
|
|
||||||
|
This plugin provides completion for the [Stripe CLI](https://stripe.com/docs/stripe-cli).
|
||||||
|
|
||||||
|
To use it add stripe to the plugins array in your zshrc file.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
plugins=(... stripe)
|
||||||
|
```
|
||||||
13
plugins/stripe/stripe.plugin.zsh
Normal file
13
plugins/stripe/stripe.plugin.zsh
Normal file
|
|
@ -0,0 +1,13 @@
|
||||||
|
if (( ! $+commands[stripe] )); then
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
# If the completion file doesn't exist yet, we need to autoload it and
|
||||||
|
# bind it to `stripe`. Otherwise, compinit will have already done that.
|
||||||
|
if [[ ! -f "$ZSH_CACHE_DIR/completions/_stripe" ]]; then
|
||||||
|
typeset -g -A _comps
|
||||||
|
autoload -Uz _stripe
|
||||||
|
_comps[stripe]=_stripe
|
||||||
|
fi
|
||||||
|
|
||||||
|
stripe completion --shell zsh --write-to-stdout >| "$ZSH_CACHE_DIR/completions/_stripe" &|
|
||||||
|
|
@ -4,7 +4,7 @@ alias st=subl
|
||||||
alias stt='subl .'
|
alias stt='subl .'
|
||||||
|
|
||||||
# Define sst only if sudo exists
|
# Define sst only if sudo exists
|
||||||
(( $+commands[sudo] )) && alias sst='sudo subl'
|
(( $+commands[sudo] )) && alias sst='sudo -EH subl'
|
||||||
|
|
||||||
alias stp=find_project
|
alias stp=find_project
|
||||||
alias stn=create_project
|
alias stn=create_project
|
||||||
|
|
@ -62,7 +62,7 @@ alias stn=create_project
|
||||||
for _sublime_path in $_sublime_paths; do
|
for _sublime_path in $_sublime_paths; do
|
||||||
if [[ -a $_sublime_path ]]; then
|
if [[ -a $_sublime_path ]]; then
|
||||||
alias subl="'$_sublime_path'"
|
alias subl="'$_sublime_path'"
|
||||||
(( $+commands[sudo] )) && alias sst="sudo '$_sublime_path'"
|
(( $+commands[sudo] )) && alias sst="sudo -EH '$_sublime_path'"
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ plugins=(... terraform)
|
||||||
|
|
||||||
## Aliases
|
## Aliases
|
||||||
|
|
||||||
| Alias | Command |
|
| Alias | Command |
|
||||||
| ------ | ------------------------- |
|
| ------ | ------------------------- |
|
||||||
| `tf` | `terraform` |
|
| `tf` | `terraform` |
|
||||||
| `tfa` | `terraform apply` |
|
| `tfa` | `terraform apply` |
|
||||||
|
|
@ -28,6 +28,7 @@ plugins=(... terraform)
|
||||||
| `tfp` | `terraform plan` |
|
| `tfp` | `terraform plan` |
|
||||||
| `tfv` | `terraform validate` |
|
| `tfv` | `terraform validate` |
|
||||||
| `tfs` | `terraform state` |
|
| `tfs` | `terraform state` |
|
||||||
|
| `tft` | `terraform test` |
|
||||||
| `tfsh` | `terraform show` |
|
| `tfsh` | `terraform show` |
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,411 +1,545 @@
|
||||||
#compdef terraform
|
#compdef terraform
|
||||||
|
compdef _terraform terraform
|
||||||
|
|
||||||
local -a _terraform_cmds opt_args
|
(( ${+functions[_terraform_commands]} )) || _terraform_commands() {
|
||||||
_terraform_cmds=(
|
local -a _terraform_cmds
|
||||||
'apply:Builds or changes infrastructure'
|
_terraform_cmds=(
|
||||||
'console:Interactive console for Terraform interpolations'
|
'apply:Create or update infrastructure'
|
||||||
'destroy:Destroy Terraform-managed infrastructure'
|
'console:Try Terraform expressions at an interactive command prompt'
|
||||||
'fmt:Rewrites config files to canonical format'
|
'destroy:Destroy previously-created infrastructure'
|
||||||
'force-unlock:Manually unlock the terraform state'
|
'fmt:Reformat your configuration in the standard style'
|
||||||
'get:Download and install modules for the configuration'
|
'force-unlock:Release a stuck lock on the current workspace'
|
||||||
'graph:Create a visual graph of Terraform resources'
|
'get:Install or upgrade remote Terraform modules'
|
||||||
'import:Import existing infrastructure into Terraform'
|
'graph:Generate a Graphviz graph of the steps in an operation'
|
||||||
'init:Initialize a Terraform working directory'
|
'import:Associate existing infrastructure with a Terraform resource'
|
||||||
|
'init:Prepare your working directory for other commands'
|
||||||
'login:Obtain and save credentials for a remote host'
|
'login:Obtain and save credentials for a remote host'
|
||||||
'logout:Remove locally-stored credentials for a remote host'
|
'logout:Remove locally-stored credentials for a remote host'
|
||||||
'output:Read an output from a state file'
|
'metadata:Metadata related commands'
|
||||||
'plan:Generate and show an execution plan'
|
'output:Show output values from your root module'
|
||||||
'providers:Prints a tree of the providers used in the configuration'
|
'plan:Show changes required by the current configuration'
|
||||||
'refresh:Update local state file against real resources'
|
'providers:Show the providers required for this configuration'
|
||||||
'show:Inspect Terraform state or plan'
|
'refresh:Update the state to match remote systems'
|
||||||
|
'show:Show the current state or a saved plan'
|
||||||
'state:Advanced state management'
|
'state:Advanced state management'
|
||||||
'taint:Manually mark a resource for recreation'
|
'taint:Mark a resource instance as not fully functional'
|
||||||
'untaint:Manually unmark a resource as tainted'
|
'test:Execute integration tests for Terraform modules'
|
||||||
'validate:Validates the Terraform files'
|
'untaint:Remove the '\''tainted'\'' state from a resource instance'
|
||||||
'version:Prints the Terraform version'
|
'validate:Check whether the configuration is valid'
|
||||||
|
'version:Show the current Terraform version'
|
||||||
'workspace:Workspace management'
|
'workspace:Workspace management'
|
||||||
'0.12upgrade:Rewrites pre-0.12 module source code for v0.12'
|
)
|
||||||
'0.13upgrade:Rewrites pre-0.13 module source code for v0.13'
|
if (( CURRENT == 1 )); then
|
||||||
)
|
_describe -t commands 'terraform commands' _terraform_cmds
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
__012upgrade() {
|
local curcontext="${curcontext}"
|
||||||
|
cmd="${${_terraform_cmds[(r)$words[1]:*]%%:*}}"
|
||||||
|
curcontext="${curcontext%:*:*}:terraform-${cmd}:"
|
||||||
|
|
||||||
|
local __chdir="${opt_args[-chdir]:-.}"
|
||||||
|
|
||||||
|
if (( ${+functions[_terraform_$cmd]} )); then
|
||||||
|
"_terraform_${cmd}"
|
||||||
|
else
|
||||||
|
_message "no more options"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
(( ${+functions[_terraform_apply]} )) || _terraform_apply() {
|
||||||
_arguments \
|
_arguments \
|
||||||
'-yes[Skip the initial introduction messages and interactive confirmation. This can be used to run this command in batch from a script.]' \
|
'-auto-approve[Skip interactive approval of plan before applying.]' \
|
||||||
'-force[ Override the heuristic that attempts to detect if a configuration is already written for v0.12 or later. Some of the transformations made by this command are not idempotent, so re-running against the same module may change the meanings expressions in the module.]'
|
'-backup=[(path) Path to backup the existing state file before modifying. Defaults to the "-state-out" path with ".backup" extension. Set to "-" to disable backup.]:backupfile:_files -W __chdir -g "*.backup"' \
|
||||||
|
'-compact-warnings[If Terraform produces any warnings that are not accompanied by errors, show them in a more compact form that includes only the summary messages.]' \
|
||||||
|
'-destroy[Destroy Terraform-managed infrastructure. The command "terraform destroy" is a convenience alias for this option.]' \
|
||||||
|
'-lock=[(true) Don'\''t hold a state lock during the operation. This is dangerous if others might concurrently run commands against the same workspace.]:lock:(true false)' \
|
||||||
|
'-lock-timeout=[(0s) Duration to retry a state lock.]:lock_timeout:' \
|
||||||
|
'-input=[(true) Ask for input for variables if not directly set.]:input:(true false)' \
|
||||||
|
'-no-color[If specified, output won'\''t contain any color.]' \
|
||||||
|
'-parallelism=[(10) Limit the number of parallel resource operations.]:parallelism:' \
|
||||||
|
'-refresh=[(true) Skip checking for external changes to remote objects while creating the plan. This can potentially make planning faster, but at the expense of possibly planning against a stale record of the remote system state.]:refresh:(true false)' \
|
||||||
|
'*-replace=[(resource) Force replacement of a particular resource instance using its resource address. If applying would'\''ve normally produced an update or no-op action for this instance, Terraform will replace it instead. You can use this option multiple times to replace more than one object.]:resource:__terraform_state_resources' \
|
||||||
|
'-state=[(terraform.tfstate) Path to read and save state (unless state-out is specified).]:statefile:_files -W __chdir -g "*.tfstate"' \
|
||||||
|
'-state-out=[(path) Path to write state to that is different than "-state". This can be used to preserve the old state.]:statefile:_files -W __chdir -g "*.tfstate"' \
|
||||||
|
'*-target=[(resource) Limit the operation to only the given module, resource, or resource instance and all of its dependencies. You can use this option multiple times to include more than one object. This is for exceptional use only.]:target:__terraform_state_resources' \
|
||||||
|
'*-var=[(for=bar) Set a value for one of the input variables in the root module of the configuration. Use this option more than once to set more than one variable.]:var:' \
|
||||||
|
'*-var-file=[(foo) Load variable values from the given file, in addition to the default files terraform.tfvars and *.auto.tfvars. Use this option more than once to include more than one variables file.]:file:_files -W __chdir -g "*.tfvars{,.json}"' \
|
||||||
|
':plan:_files -W __chdir -'
|
||||||
}
|
}
|
||||||
|
|
||||||
__013upgrade() {
|
(( ${+functions[_terraform_console]} )) || _terraform_console() {
|
||||||
_arguments \
|
_arguments \
|
||||||
'-yes[Skip the initial introduction messages and interactive confirmation. This can be used to run this command in batch from a script.]'
|
'-state=[(terraform.tfstate) Legacy option for the local backend only. See the local backend'\''s documentation for more information.]:statefile:_files -W __chdir -g "*.tfstate"' \
|
||||||
|
'-plan[Create a new plan (as if running "terraform plan") and then evaluate expressions against its planned state, instead of evaluating against the current state. You can use this to inspect the effects of configuration changes that haven'\''t been applied yet.]' \
|
||||||
|
'*-var=[(for=bar) Set a variable in the Terraform configuration. This flag can be set multiple times.]:var:' \
|
||||||
|
'*-var-file=[(foo) Set variables in the Terraform configuration from a file. If "terraform.tfvars" or any ".auto.tfvars" files are present, they will be automatically loaded.]:file:_files -W __chdir -g "*.tfvars{,.json}"'
|
||||||
}
|
}
|
||||||
|
|
||||||
__apply() {
|
(( ${+functions[_terraform_destroy]} )) || _terraform_destroy() {
|
||||||
_arguments \
|
|
||||||
'-auto-approve[Skip interactive approval of plan before applying.]' \
|
|
||||||
'-backup=[(path) Path to backup the existing state file before modifying. Defaults to the "-state-out" path with ".backup" extension. Set to "-" to disable backup.]:backupfile:_files -g "*.backup"' \
|
|
||||||
'-compact-warnings[If Terraform produces any warnings that are not accompanied by errors, show them in a more compact form that includes only the summary messages.]' \
|
|
||||||
'-lock=[(true) Lock the state file when locking is supported.]:lock:(true false)' \
|
|
||||||
'-lock-timeout=[(0s) Duration to retry a state lock.]' \
|
|
||||||
'-input=[(true) Ask for input for variables if not directly set.]' \
|
|
||||||
'-no-color[If specified, output will be colorless.]' \
|
|
||||||
'-parallelism=[(10) Limit the number of parallel resource operations.]' \
|
|
||||||
'-refresh=[(true) Update state prior to checking for differences. This has no effect if a plan file is given to apply.]' \
|
|
||||||
'-state=[(terraform.tfstate) Path to read and save state (unless state-out is specified).]:statefile:_files -g "*.tfstate"' \
|
|
||||||
'-state-out=[(path) Path to write state to that is different than "-state". This can be used to preserve the old state.]:statefile:_files -g "*.tfstate"' \
|
|
||||||
'*-target=[(resource) Resource to target. Operation will be limited to this resource and its dependencies. This flag can be used multiple times.]:target:__statelist' \
|
|
||||||
'*-var[("foo=bar") Set a variable in the Terraform configuration. This flag can be set multiple times.]' \
|
|
||||||
'*-var-file=[(foo) Set variables in the Terraform configuration from a file. If "terraform.tfvars" or any ".auto.tfvars" files are present, they will be automatically loaded.]:file:_files -g "*.tfvars{,.json}"'
|
|
||||||
}
|
|
||||||
|
|
||||||
__console() {
|
|
||||||
_arguments \
|
|
||||||
'-state=[(terraform.tfstate) Path to read state.]' \
|
|
||||||
'*-var[("foo=bar") Set a variable in the Terraform configuration. This flag can be set multiple times.]' \
|
|
||||||
'*-var-file=[(foo) Set variables in the Terraform configuration from a file. If "terraform.tfvars" or any ".auto.tfvars" files are present, they will be automatically loaded.]:file:_files -g "*.tfvars{,.json}"'
|
|
||||||
}
|
|
||||||
|
|
||||||
__destroy() {
|
|
||||||
_arguments \
|
|
||||||
'-backup=[(path) Path to backup the existing state file before modifying. Defaults to the "-state-out" path with ".backup" extension. Set to "-" to disable backup.]:backupfile:_files -g "*.backup"' \
|
|
||||||
'-auto-approve[Skip interactive approval before destroying.]' \
|
|
||||||
'-force[Deprecated: same as auto-approve.]' \
|
|
||||||
'-lock=[(true) Lock the state file when locking is supported.]:lock:(true false)' \
|
|
||||||
'-lock-timeout=[(0s) Duration to retry a state lock.]' \
|
|
||||||
'-no-color[If specified, output will contain no color.]' \
|
|
||||||
'-parallelism=[(10) Limit the number of concurrent operations.]' \
|
|
||||||
'-refresh=[(true) Update state prior to checking for differences. This has no effect if a plan file is given to apply.]' \
|
|
||||||
'-state=[(terraform.tfstate) Path to read and save state (unless state-out is specified).]:statefile:_files -g "*.tfstate"' \
|
|
||||||
'-state-out=[(path) Path to write state to that is different than "-state". This can be used to preserve the old state.]:statefile:_files -g "*.tfstate"' \
|
|
||||||
'*-target=[(resource) Resource to target. Operation will be limited to this resource and its dependencies. This flag can be used multiple times.]:target:__statelist' \
|
|
||||||
'*-var[("foo=bar") Set a variable in the Terraform configuration. This flag can be set multiple times.]' \
|
|
||||||
'*-var-file=[(foo) Set variables in the Terraform configuration from a file. If "terraform.tfvars" or any ".auto.tfvars" files are present, they will be automatically loaded.]:file:_files -g "*.tfvars{,.json}"'
|
|
||||||
}
|
|
||||||
|
|
||||||
__fmt() {
|
|
||||||
_arguments \
|
|
||||||
'-list=[(true) List files whose formatting differs (always false if using STDIN)]' \
|
|
||||||
'-write=[(true) Write result to source file instead of STDOUT (always false if using STDIN or -check)]' \
|
|
||||||
'-diff=[(false) Display diffs of formatting changes]' \
|
|
||||||
'-check=[(false) Check if the input is formatted. Exit status will be 0 if all input is properly formatted and non-zero otherwise.]' \
|
|
||||||
'-recursive=[(false) Also process files in subdirectories. By default, only the given directory (or current directory) is processed.]'
|
|
||||||
}
|
|
||||||
|
|
||||||
__force_unlock() {
|
|
||||||
_arguments \
|
|
||||||
"-force[Don't ask for input for unlock confirmation.]"
|
|
||||||
}
|
|
||||||
|
|
||||||
__get() {
|
|
||||||
_arguments \
|
|
||||||
'-update=[(false) If true, modules already downloaded will be checked for updates and updated if necessary.]' \
|
|
||||||
'-no-color[Disable text coloring in the output.]'
|
|
||||||
}
|
|
||||||
|
|
||||||
__graph() {
|
|
||||||
_arguments \
|
|
||||||
'-draw-cycles[Highlight any cycles in the graph with colored edges. This helps when diagnosing cycle errors.]' \
|
|
||||||
'-type=[(plan) Type of graph to output. Can be: plan, plan-destroy, apply, validate, input, refresh.]'
|
|
||||||
}
|
|
||||||
|
|
||||||
__import() {
|
|
||||||
_arguments \
|
|
||||||
'-backup=[(path) Path to backup the existing state file before modifying. Defaults to the "-state-out" path with ".backup" extension. Set to "-" to disable backup.]:backupfile:_files -g "*.backup"' \
|
|
||||||
'-config=[(path) Path to a directory of Terraform configuration files to use to configure the provider. Defaults to pwd. If no config files are present, they must be provided via the input prompts or env vars.]' \
|
|
||||||
'-allow-missing-config[Allow import when no resource configuration block exists.]' \
|
|
||||||
'-input=[(true) Ask for input for variables if not directly set.]' \
|
|
||||||
'-lock=[(true) Lock the state file when locking is supported.]:lock:(true false)' \
|
|
||||||
'-lock-timeout=[(0s) Duration to retry a state lock.]' \
|
|
||||||
'-no-color[If specified, output will contain no color.]' \
|
|
||||||
'-state=[(PATH) Path to the source state file. Defaults to the configured backend, or "terraform.tfstate"]:statefile:_files -g "*.tfstate"' \
|
|
||||||
'-state-out=[(PATH) Path to the destination state file to write to. If this is not specified, the source state file will be used. This can be a new or existing path.]:statefile:_files -g "*.tfstate"' \
|
|
||||||
'*-var[("foo=bar") Set a variable in the Terraform configuration. This flag can be set multiple times. This is only useful with the "-config" flag.]' \
|
|
||||||
'*-var-file=[(foo) Set variables in the Terraform configuration from a file. If "terraform.tfvars" or any ".auto.tfvars" files are present, they will be automatically loaded.]:file:_files -g "*.tfvars{,.json}"'
|
|
||||||
}
|
|
||||||
|
|
||||||
__init() {
|
|
||||||
_arguments \
|
|
||||||
'-backend=[(true) Configure the backend for this configuration.]' \
|
|
||||||
'-backend-config=[This can be either a path to an HCL file with key/value assignments (same format as terraform.tfvars) or a 'key=value' format. This is merged with what is in the configuration file. This can be specified multiple times. The backend type must be in the configuration itself.]' \
|
|
||||||
'-force-copy[Suppress prompts about copying state data. This is equivalent to providing a "yes" to all confirmation prompts.]' \
|
|
||||||
'-from-module=[(SOURCE) Copy the contents of the given module into the target directory before initialization.]' \
|
|
||||||
'-get=[(true) Download any modules for this configuration.]' \
|
|
||||||
'-get-plugins=[(true) Download any missing plugins for this configuration.]' \
|
|
||||||
'-input=[(true) Ask for input if necessary. If false, will error if input was required.]' \
|
|
||||||
'-lock=[(true) Lock the state file when locking is supported.]:lock:(true false)' \
|
|
||||||
'-lock-timeout=[(0s) Duration to retry a state lock.]' \
|
|
||||||
'-no-color[If specified, output will contain no color.]' \
|
|
||||||
'-plugin-dir[Directory containing plugin binaries. This overrides all default search paths for plugins, and prevents the automatic installation of plugins. This flag can be used multiple times.]:plugin_dir:_files -/' \
|
|
||||||
'-reconfigure[Reconfigure the backend, ignoring any saved configuration.]' \
|
|
||||||
'-upgrade=[(false) If installing modules (-get) or plugins (-get-plugins), ignore previously-downloaded objects and install the latest version allowed within configured constraints.]' \
|
|
||||||
'-verify-plugins=[(true) Verify the authenticity and integrity of automatically downloaded plugins.]'
|
|
||||||
}
|
|
||||||
|
|
||||||
__login() {
|
|
||||||
_arguments \
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
__logout() {
|
|
||||||
_arguments \
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
__output() {
|
|
||||||
_arguments \
|
|
||||||
'-state=[(path) Path to the state file to read. Defaults to "terraform.tfstate".]:statefile:_files -g "*.tfstate"' \
|
|
||||||
'-no-color[If specified, output will contain no color.]' \
|
|
||||||
'-json[If specified, machine readable output will be printed in JSON format]'
|
|
||||||
}
|
|
||||||
|
|
||||||
__plan() {
|
|
||||||
_arguments \
|
|
||||||
'-compact-warnings[If Terraform produces any warnings that are not accompanied by errors, show them in a more compact form that includes only the summary messages.]' \
|
|
||||||
'-destroy[If set, a plan will be generated to destroy all resources managed by the given configuration and state.]' \
|
|
||||||
'-detailed-exitcode[() Return detailed exit codes when the command exits. This will change the meaning of exit codes to: 0 - Succeeded, diff is empty (no changes); 1 - Errored, 2 - Succeeded; there is a diff]' \
|
|
||||||
'-input=[(true) Ask for input for variables if not directly set.]' \
|
|
||||||
'-lock=[(true) Lock the state file when locking is supported.]:lock:(true false)' \
|
|
||||||
'-lock-timeout=[(0s) Duration to retry a state lock.]' \
|
|
||||||
'-no-color[() If specified, output will contain no color.]' \
|
|
||||||
'-out=[(path) Write a plan file to the given path. This can be used as input to the "apply" command.]' \
|
|
||||||
'-parallelism=[(10) Limit the number of concurrent operations.]' \
|
|
||||||
'-refresh=[(true) Update state prior to checking for differences.]' \
|
|
||||||
'-state=[(statefile) Path to a Terraform state file to use to look up Terraform-managed resources. By default it will use the state "terraform.tfstate" if it exists.]:statefile:_files -g "*.tfstate"' \
|
|
||||||
'*-target=[(resource) Resource to target. Operation will be limited to this resource and its dependencies. This flag can be used multiple times.]:target:__statelist' \
|
|
||||||
'*-var[("foo=bar") Set a variable in the Terraform configuration. This flag can be set multiple times.]' \
|
|
||||||
'*-var-file=[(foo) Set variables in the Terraform configuration from a file. If "terraform.tfvars" or any ".auto.tfvars" files are present, they will be automatically loaded.]:file:_files -g "*.tfvars{,.json}"'
|
|
||||||
}
|
|
||||||
|
|
||||||
__providers() {
|
|
||||||
local -a __providers_cmds
|
|
||||||
__providers_cmds=(
|
|
||||||
'mirror:Mirrors the provider plugins needed for the current configuration'
|
|
||||||
'schema:Prints the schemas of the providers used in the configuration'
|
|
||||||
)
|
|
||||||
_describe -t providers "providers commands" __providers_cmds
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
__providers_mirror() {
|
|
||||||
_arguments \
|
|
||||||
'-platform=[(os_arch) Choose which target platform to build a mirror for.]' \
|
|
||||||
"*:target_dir:_files -/"
|
|
||||||
}
|
|
||||||
|
|
||||||
__providers_schema() {
|
|
||||||
_arguments \
|
|
||||||
'-json[]' \
|
|
||||||
'::'
|
|
||||||
}
|
|
||||||
|
|
||||||
__refresh() {
|
|
||||||
_arguments \
|
|
||||||
'-backup=[(path) Path to backup the existing state file before modifying. Defaults to the "-state-out" path with ".backup" extension. Set to "-" to disable backup.]::backupfile:_files -g "*.backup"' \
|
|
||||||
'-compact-warnings[If Terraform produces any warnings that are not accompanied by errors, show them in a more compact form that includes only the summary messages.]' \
|
|
||||||
'-input=[(true) Ask for input for variables if not directly set.]' \
|
|
||||||
'-lock=[(true) Lock the state file when locking is supported.]:lock:(true false)' \
|
|
||||||
'-lock-timeout=[(0s) Duration to retry a state lock.]' \
|
|
||||||
'-no-color[If specified, output will not contain any color.]' \
|
|
||||||
'-state=[(path) Path to read and save state (unless state-out is specified). Defaults to "terraform.tfstate".]:statefile:_files -g "*.tfstate"' \
|
|
||||||
'-state-out=[(path) Path to write state to that is different than "-state". This can be used to preserve the old state.]:statefile:_files -g "*.tfstate"' \
|
|
||||||
'*-target=[(resource) A Resource Address to target. Operation will be limited to this resource and its dependencies. This flag can be used multiple times.]:target:__statelist' \
|
|
||||||
'*-var[("foo=bar") Set a variable in the Terraform configuration. This flag can be set multiple times.]' \
|
|
||||||
'*-var-file=[(foo) Set variables in the Terraform configuration from a file. If "terraform.tfvars" or any ".auto.tfvars" files are present, they will be automatically loaded.]:file:_files -g "*.tfvars{,.json}"'
|
|
||||||
}
|
|
||||||
|
|
||||||
__show() {
|
|
||||||
_arguments \
|
|
||||||
'-json[If specified, output the Terraform plan or state in a machine-readable form.]' \
|
|
||||||
'-no-color[If specified, output will not contain any color.]'
|
|
||||||
}
|
|
||||||
|
|
||||||
__state() {
|
|
||||||
local -a __state_cmds
|
|
||||||
__state_cmds=(
|
|
||||||
'list:List resources in the state'
|
|
||||||
'mv:Move an item in the state'
|
|
||||||
'pull:Pull current state and output to stdout'
|
|
||||||
'push:Update remote state from a local state file'
|
|
||||||
'replace-provider:Replace provider for resources in the Terraform state'
|
|
||||||
'rm:Remove instances from the state'
|
|
||||||
'show:Show a resource in the state'
|
|
||||||
)
|
|
||||||
_describe -t state "state commands" __state_cmds
|
|
||||||
}
|
|
||||||
|
|
||||||
__state_list() {
|
|
||||||
_arguments \
|
_arguments \
|
||||||
'-state=[(statefile) Path to a Terraform state file to use to look up Terraform-managed resources. By default, Terraform will consult the state of the currently-selected workspace.]' \
|
'-auto-approve[Skip interactive approval of plan before applying.]' \
|
||||||
'-id=[(id) Filters the results to include only instances whose resource types have an attribute named id whose value equals the given id string.]' \
|
'-backup=[(path) Path to backup the existing state file before modifying. Defaults to the "-state-out" path with ".backup" extension. Set to "-" to disable backup.]:backupfile:_files -W __chdir -g "*.backup"' \
|
||||||
"*:address:__statelist"
|
'-compact-warnings[If Terraform produces any warnings that are not accompanied by errors, show them in a more compact form that includes only the summary messages.]' \
|
||||||
|
'-lock=[(true) Don'\''t hold a state lock during the operation. This is dangerous if others might concurrently run commands against the same workspace.]:lock:(true false)' \
|
||||||
|
'-lock-timeout=[(0s) Duration to retry a state lock.]:lock_timeout:' \
|
||||||
|
'-input=[(true) Ask for input for variables if not directly set.]:input:(true false)' \
|
||||||
|
'-no-color[If specified, output won'\''t contain any color.]' \
|
||||||
|
'-parallelism=[(10) Limit the number of parallel resource operations.]:parallelism:' \
|
||||||
|
'-refresh=[(true) Update state prior to checking for differences. This has no effect if a plan file is given to apply.]:refresh:(true false)' \
|
||||||
|
'-state=[(terraform.tfstate) Path to read and save state (unless state-out is specified).]:statefile:_files -W __chdir -g "*.tfstate"' \
|
||||||
|
'-state-out=[(path) Path to write state to that is different than "-state". This can be used to preserve the old state.]:statefile:_files -W __chdir -g "*.tfstate"' \
|
||||||
|
'*-target=[(resource) Limit the operation to only the given module, resource, or resource instance and all of its dependencies. You can use this option multiple times to include more than one object. This is for exceptional use only.]:target:__terraform_state_resources' \
|
||||||
|
'*-var=[(for=bar) Set a value for one of the input variables in the root module of the configuration. Use this option more than once to set more than one variable.]:var:' \
|
||||||
|
'*-var-file=[(foo) Load variable values from the given file, in addition to the default files terraform.tfvars and *.auto.tfvars. Use this option more than once to include more than one variables file.]:file:_files -W __chdir -g "*.tfvars{,.json}"'
|
||||||
}
|
}
|
||||||
|
|
||||||
__state_mv() {
|
(( ${+functions[_terraform_fmt]} )) || _terraform_fmt() {
|
||||||
_arguments \
|
_arguments \
|
||||||
"-dry-run[If set, prints out what would've been moved but doesn't actually move anything.]" \
|
'-list=[(true) Don'\''t list files whose formatting differs (always disabled if using STDIN)]:list:(true false)' \
|
||||||
'-backup=[(PATH) Path where Terraform should write the backup for the original state. This can"t be disabled. If not set, Terraform will write it to the same path as the statefile with a ".backup" extension.]:backupfile:_files -g "*.backup"' \
|
'-write=[(true) Don'\''t write to source files (always disabled if using STDIN or -check)]:write:(true false)' \
|
||||||
'-backup-out=[(PATH) Path where Terraform should write the backup for the destination state. This can"t be disabled. If not set, Terraform will write it to the same path as the destination state file with a backup extension. This only needs to be specified if -state-out is set to a different path than -state.]:backupfile:_files -g "*.backup"' \
|
'-diff[Display diffs of formatting changes]' \
|
||||||
"-lock=[(true) Lock the state files when locking is supported.]:lock:(true false)" \
|
'-check[Check if the input is formatted. Exit status will be 0 if all input is properly formatted and non-zero otherwise.]' \
|
||||||
"-lock-timeout=[(0s) Duration to retry a state lock.]" \
|
'-no-color[If specified, output won'\''t contain any color.]' \
|
||||||
'-state=[(path) Path to the source state file. Defaults to the configured backend, or "terraform.tfstate"]:statefile:_files -g "*.tfstate"' \
|
'-recursive[Also process files in subdirectories. By default, only the given directory (or current directory) is processed.]' \
|
||||||
'-state-out=[(path) Path to the destination state file to write to. If this isn"t specified, the source state file will be used. This can be a new or existing path.]:statefile:_files -g "*.tfstate"' \
|
'*:targets:_files -W __chdir -'
|
||||||
"::" \
|
|
||||||
":source:__statelist" \
|
|
||||||
":destination: "
|
|
||||||
}
|
}
|
||||||
|
|
||||||
__state_push() {
|
(( ${+functions[_terraform_force-unlock]} )) || _terraform_force-unlock() {
|
||||||
_arguments \
|
_arguments \
|
||||||
"-force[Write the state even if lineages don't match or the remote serial is higher.]" \
|
'-force[Don'\''t ask for input for unlock confirmation.]' \
|
||||||
'-lock=[(true) Lock the state file when locking is supported.]:lock:(true false)' \
|
':lock_id:'
|
||||||
"-lock-timeout=[(0s) Duration to retry a state lock.]" \
|
|
||||||
"::" \
|
|
||||||
":destination:_files"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
__state_replace_provider() {
|
(( ${+functions[_terraform_get]} )) || _terraform_get() {
|
||||||
|
_arguments \
|
||||||
|
'-update[Check already-downloaded modules for available updates and install the newest versions available.]' \
|
||||||
|
'-no-color[Disable text coloring in the output.]' \
|
||||||
|
'-test-directory=[(tests) Set the Terraform test directory, defaults to "tests".]:test_directory:_files -W __chdir -/'
|
||||||
|
}
|
||||||
|
|
||||||
|
(( ${+functions[_terraform_graph]} )) || _terraform_graph() {
|
||||||
|
_arguments \
|
||||||
|
'-draw-cycles[Highlight any cycles in the graph with colored edges. This helps when diagnosing cycle errors. This option is supported only when illustrating a real evaluation graph, selected using the -type=TYPE option.]' \
|
||||||
|
'-module-depth=[(-1) (deprecated) In prior versions of Terraform, specified the depth of modules to show in the output.]:module_depth:' \
|
||||||
|
'-plan=[Render graph using the specified plan file instead of the configuration in the current directory. Implies -type=apply.]:plan:_files -W __chdir -' \
|
||||||
|
'-type=[(plan) Type of operation graph to output. Can be: plan, plan-refresh-only, plan-destroy, or apply. By default Terraform just summarizes the relationships between the resources in your configuration, without any particular operation in mind. Full operation graphs are more detailed but therefore often harder to read.]:type:(plan plan-refresh-only plan-destroy apply)'
|
||||||
|
}
|
||||||
|
|
||||||
|
(( ${+functions[_terraform_import]} )) || _terraform_import() {
|
||||||
|
_arguments \
|
||||||
|
'-backup=[(path) Path to backup the existing state file before modifying. Defaults to the "-state-out" path with ".backup" extension. Set to "-" to disable backup.]:backupfile:_files -W __chdir -g "*.backup"' \
|
||||||
|
'-config=[(path) Path to a directory of Terraform configuration files to use to configure the provider. Defaults to pwd. If no config files are present, they must be provided via the input prompts or env vars.]:config:_files -W __chdir -/' \
|
||||||
|
'-input=[(true) Disable interactive input prompts.]:input:(true false)' \
|
||||||
|
'-lock=[(true) Don'\''t hold a state lock during the operation. This is dangerous if others might concurrently run commands against the same workspace.]:lock:(true false)' \
|
||||||
|
'-lock-timeout=[(0s) Duration to retry a state lock.]:lock_timeout:' \
|
||||||
|
'-no-color[If specified, output will contain no color.]' \
|
||||||
|
'-state=[(PATH) Path to the source state file. Defaults to the configured backend, or "terraform.tfstate"]:statefile:_files -W __chdir -g "*.tfstate"' \
|
||||||
|
'-state-out=[(PATH) Path to the destination state file to write to. If this is not specified, the source state file will be used. This can be a new or existing path.]:statefile:_files -W __chdir -g "*.tfstate"' \
|
||||||
|
'*-var=[(for=bar) Set a variable in the Terraform configuration. This flag can be set multiple times. This is only useful with the "-config" flag.]:var:' \
|
||||||
|
'*-var-file=[(foo) Set variables in the Terraform configuration from a file. If "terraform.tfvars" or any ".auto.tfvars" files are present, they will be automatically loaded.]:file:_files -W __chdir -g "*.tfvars{,.json}"' \
|
||||||
|
':addr:' \
|
||||||
|
':id:'
|
||||||
|
}
|
||||||
|
|
||||||
|
(( ${+functions[_terraform_init]} )) || _terraform_init() {
|
||||||
|
_arguments \
|
||||||
|
'-backend=[(true) Disable backend or Terraform Cloud initialization for this configuration and use what was previously initialized instead.]:backend:(true false)' \
|
||||||
|
'-backend-config=[Configuration to be merged with what is in the configuration file'\''s '\''backend'\'' block. This can be either a path to an HCL file with key/value assignments (same format as terraform.tfvars) or a '\''key=value'\'' format, and can be specified multiple times. The backend type must be in the configuration itself.]:backend_config:_files -W __chdir -' \
|
||||||
|
'-force-copy[Suppress prompts about copying state data. This is equivalent to providing a "yes" to all confirmation prompts.]' \
|
||||||
|
'-from-module=[Copy the contents of the given module into the target directory before initialization.]:from_module:_files -W __chdir -/' \
|
||||||
|
'-get=[(true) Disable downloading modules for this configuration.]:get:(true false)' \
|
||||||
|
'-input=[(true) Disable interactive prompts. Note that some actions may require interactive prompts and will error if input is disabled.]:input:(true false)' \
|
||||||
|
'-lock=[(true) Don'\''t hold a state lock during backend migration. This is dangerous if others might concurrently run commands against the same workspace.]:lock:(true false)' \
|
||||||
|
'-lock-timeout=[(0s) Duration to retry a state lock.]:lock_timeout:' \
|
||||||
|
'-no-color[If specified, output will contain no color.]' \
|
||||||
|
'-plugin-dir[Directory containing plugin binaries. This overrides all default search paths for plugins, and prevents the automatic installation of plugins. This flag can be used multiple times.]:plugin_dir:_files -W __chdir -/' \
|
||||||
|
'-reconfigure[Reconfigure the backend, ignoring any saved configuration.]' \
|
||||||
|
'-migrate-state[Reconfigure a backend, and attempt to migrate any existing state.]' \
|
||||||
|
'-upgrade[Install the latest module and provider versions allowed within configured constraints, overriding the default behavior of selecting exactly the version recorded in the dependency lockfile.]' \
|
||||||
|
'-lockfile=[Set a dependency lockfile mode. Currently only "readonly" is valid.]:lockfile:( readonly )' \
|
||||||
|
'-ignore-remote-version[A rare option used for Terraform Cloud and the remote backend only. Set this to ignore checking that the local and remote Terraform versions use compatible state representations, making an operation proceed even when there is a potential mismatch. See the documentation on configuring Terraform with Terraform Cloud for more information.]' \
|
||||||
|
'-test-directory=[(tests) Set the Terraform test directory, defaults to "tests".]:test_directory:_files -W __chdir -/'
|
||||||
|
}
|
||||||
|
|
||||||
|
(( ${+functions[_terraform_login]} )) || _terraform_login() {
|
||||||
|
_arguments \
|
||||||
|
':hostname:'
|
||||||
|
}
|
||||||
|
|
||||||
|
(( ${+functions[_terraform_logout]} )) || _terraform_logout() {
|
||||||
|
_arguments \
|
||||||
|
':hostname:'
|
||||||
|
}
|
||||||
|
|
||||||
|
(( ${+functions[_terraform_metadata]} )) || _terraform_metadata() {
|
||||||
|
_arguments \
|
||||||
|
'*::terraform metadata command:_terraform_metadata_commands'
|
||||||
|
}
|
||||||
|
|
||||||
|
(( ${+functions[_terraform_metadata_commands]} )) || _terraform_metadata_commands() {
|
||||||
|
local -a _metadata_cmds
|
||||||
|
_metadata_cmds=(
|
||||||
|
'functions:Show signatures and descriptions for the available functions'
|
||||||
|
)
|
||||||
|
if (( CURRENT == 1 )); then
|
||||||
|
_describe -t commands "terraform metadata commands" _metadata_cmds
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
local curcontext="${curcontext}"
|
||||||
|
cmd="${${_metadata_cmds[(r)$words[1]:*]%%:*}}"
|
||||||
|
curcontext="${curcontext%:*:*}:terraform-metadata-${cmd}:"
|
||||||
|
|
||||||
|
if (( ${+functions[_terraform_metadata_$cmd]} )); then
|
||||||
|
"_terraform_metadata_${cmd}"
|
||||||
|
else
|
||||||
|
_message "no more options"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
(( ${+functions[_terraform_metadata_functions]} )) || _terraform_metadata_functions() {
|
||||||
|
_arguments \
|
||||||
|
'-json[]'
|
||||||
|
}
|
||||||
|
|
||||||
|
(( ${+functions[_terraform_output]} )) || _terraform_output() {
|
||||||
|
_arguments \
|
||||||
|
'-state=[(path) Path to the state file to read. Defaults to "terraform.tfstate". Ignored when remote state is used.]:statefile:_files -W __chdir -g "*.tfstate"' \
|
||||||
|
'-no-color[If specified, output will contain no color.]' \
|
||||||
|
'-json[If specified, machine readable output will be printed in JSON format]' \
|
||||||
|
'-raw[For value types that can be automatically converted to a string, will print the raw string directly, rather than a human-oriented representation of the value.]' \
|
||||||
|
':name:'
|
||||||
|
}
|
||||||
|
|
||||||
|
(( ${+functions[_terraform_plan]} )) || _terraform_plan() {
|
||||||
|
_arguments \
|
||||||
|
'-compact-warnings[If Terraform produces any warnings that are not accompanied by errors, show them in a more compact form that includes only the summary messages.]' \
|
||||||
|
'-destroy[Select the "destroy" planning mode, which creates a plan to destroy all objects currently managed by this Terraform configuration instead of the usual behavior.]' \
|
||||||
|
'-detailed-exitcode[Return detailed exit codes when the command exits. This will change the meaning of exit codes to: 0 - Succeeded, diff is empty (no changes); 1 - Errored, 2 - Succeeded; there is a diff]' \
|
||||||
|
'-input=[(true) Ask for input for variables if not directly set.]:input:(true false)' \
|
||||||
|
'-generate-config-out=[(path) (Experimental) If import blocks are present in configuration, instructs Terraform to generate HCL for any imported resources not already present. The configuration is written to a new file at PATH, which must not already exist. Terraform may still attempt to write configuration if the plan errors.]:generate_config_out:' \
|
||||||
|
'-lock=[(true) Don'\''t hold a state lock during the operation. This is dangerous if others might concurrently run commands against the same workspace.]:lock:(true false)' \
|
||||||
|
'-lock-timeout=[(0s) Duration to retry a state lock.]:lock_timeout:' \
|
||||||
|
'-no-color[If specified, output will contain no color.]' \
|
||||||
|
'-out=[(path) Write a plan file to the given path. This can be used as input to the "apply" command.]:out:' \
|
||||||
|
'-parallelism=[(10) Limit the number of concurrent operations.]:parallelism:' \
|
||||||
|
'-refresh=[(true) Skip checking for external changes to remote objects while creating the plan. This can potentially make planning faster, but at the expense of possibly planning against a stale record of the remote system state.]:refresh:(true false)' \
|
||||||
|
'-refresh-only[Select the "refresh only" planning mode, which checks whether remote objects still match the outcome of the most recent Terraform apply but does not propose any actions to undo any changes made outside of Terraform.]' \
|
||||||
|
'*-replace=[(resource) Force replacement of a particular resource instance using its resource address. If the plan would'\''ve normally produced an update or no-op action for this instance, Terraform will plan to replace it instead. You can use this option multiple times to replace more than one object.]:replace:__terraform_state_resources' \
|
||||||
|
'-state=[(statefile) Path to a Terraform state file to use to look up Terraform-managed resources. By default it will use the state "terraform.tfstate" if it exists.]:statefile:_files -W __chdir -g "*.tfstate"' \
|
||||||
|
'*-target=[(resource) Limit the planning operation to only the given module, resource, or resource instance and all of its dependencies. You can use this option multiple times to include more than one object. This is for exceptional use only.]:target:__terraform_state_resources' \
|
||||||
|
'*-var=[(for=bar) Set a value for one of the input variables in the root module of the configuration. Use this option more than once to set more than one variable.]:var:' \
|
||||||
|
'*-var-file=[(foo) Load variable values from the given file, in addition to the default files terraform.tfvars and *.auto.tfvars. Use this option more than once to include more than one variables file.]:file:_files -W __chdir -g "*.tfvars{,.json}"'
|
||||||
|
}
|
||||||
|
|
||||||
|
(( ${+functions[_terraform_providers]} )) || _terraform_providers() {
|
||||||
|
_arguments \
|
||||||
|
'-test-directory=[(path) Set the Terraform test directory, defaults to "tests".]:test_directory:_files -W __chdir -/' \
|
||||||
|
'*::terraform providers command:_terraform_providers_commands'
|
||||||
|
}
|
||||||
|
|
||||||
|
(( ${+functions[_terraform_providers_commands]} )) || _terraform_providers_commands() {
|
||||||
|
local -a _providers_cmds
|
||||||
|
_providers_cmds=(
|
||||||
|
'lock:Write out dependency locks for the configured providers'
|
||||||
|
'mirror:Save local copies of all required provider plugins'
|
||||||
|
'schema:Show schemas for the providers used in the configuration'
|
||||||
|
)
|
||||||
|
if (( CURRENT == 1 )); then
|
||||||
|
_describe -t commands "terraform providers commands" _providers_cmds
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
local curcontext="${curcontext}"
|
||||||
|
cmd="${${_providers_cmds[(r)$words[1]:*]%%:*}}"
|
||||||
|
curcontext="${curcontext%:*:*}:terraform-providers-${cmd}:"
|
||||||
|
|
||||||
|
if (( ${+functions[_terraform_providers_$cmd]} )); then
|
||||||
|
"_terraform_providers_${cmd}"
|
||||||
|
else
|
||||||
|
_message "no more options"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
(( ${+functions[_terraform_providers_lock]} )) || _terraform_providers_lock() {
|
||||||
|
_arguments \
|
||||||
|
'-fs-mirror=[(dir) Consult the given filesystem mirror directory instead of the origin registry for each of the given providers.]:fs_mirror:_files -W __chdir -/' \
|
||||||
|
'-net-mirror=[(url) Consult the given network mirror (given as a base URL) instead of the origin registry for each of the given providers.]:net_mirror:' \
|
||||||
|
'*-platform=[(os_arch) Choose a target platform to request package checksums for.]:platform:' \
|
||||||
|
'*:provider:'
|
||||||
|
}
|
||||||
|
|
||||||
|
(( ${+functions[_terraform_providers_mirror]} )) || _terraform_providers_mirror() {
|
||||||
|
_arguments \
|
||||||
|
'*-platform=[(os_arch) Choose which target platform to build a mirror for.]:platform:' \
|
||||||
|
'::' \
|
||||||
|
':target_dir:_files -W __chdir -/'
|
||||||
|
}
|
||||||
|
|
||||||
|
(( ${+functions[_terraform_providers_schema]} )) || _terraform_providers_schema() {
|
||||||
|
_arguments \
|
||||||
|
'-json[]'
|
||||||
|
}
|
||||||
|
|
||||||
|
(( ${+functions[_terraform_refresh]} )) || _terraform_refresh() {
|
||||||
|
_arguments \
|
||||||
|
'-backup=[(path) Path to backup the existing state file before modifying. Defaults to the "-state-out" path with ".backup" extension. Set to "-" to disable backup.]::backupfile:_files -W __chdir -g "*.backup"' \
|
||||||
|
'-compact-warnings[If Terraform produces any warnings that are not accompanied by errors, show them in a more compact form that includes only the summary messages.]' \
|
||||||
|
'-input=[(true) Ask for input for variables if not directly set.]:input:(true false)' \
|
||||||
|
'-lock=[(true) Don'\''t hold a state lock during the operation. This is dangerous if others might concurrently run commands against the same workspace.]:lock:(true false)' \
|
||||||
|
'-lock-timeout=[(0s) Duration to retry a state lock.]:lock_timeout:' \
|
||||||
|
'-no-color[If specified, output will not contain any color.]' \
|
||||||
|
'-parallelism=[(10) Limit the number of parallel resource operations.]:parallelism:' \
|
||||||
|
'-state=[(path) Path to read and save state (unless state-out is specified). Defaults to "terraform.tfstate".]:statefile:_files -W __chdir -g "*.tfstate"' \
|
||||||
|
'-state-out=[(path) Path to write state to that is different than "-state". This can be used to preserve the old state.]:statefile:_files -W __chdir -g "*.tfstate"' \
|
||||||
|
'*-target=[(resource) A Resource Address to target. Operation will be limited to this resource and its dependencies. This flag can be used multiple times.]:target:__terraform_state_resources' \
|
||||||
|
'*-var=[(for=bar) Set a variable in the Terraform configuration. This flag can be set multiple times.]:var:' \
|
||||||
|
'*-var-file=[(foo) Set variables in the Terraform configuration from a file. If "terraform.tfvars" or any ".auto.tfvars" files are present, they will be automatically loaded.]:file:_files -W __chdir -g "*.tfvars{,.json}"'
|
||||||
|
}
|
||||||
|
|
||||||
|
(( ${+functions[_terraform_show]} )) || _terraform_show() {
|
||||||
|
_arguments \
|
||||||
|
'-json[If specified, output the Terraform plan or state in a machine-readable form.]' \
|
||||||
|
'-no-color[If specified, output will not contain any color.]' \
|
||||||
|
':path:_files -W __chdir -g "*.tfstate"'
|
||||||
|
}
|
||||||
|
|
||||||
|
(( ${+functions[_terraform_state]} )) || _terraform_state() {
|
||||||
|
_arguments \
|
||||||
|
'*::terraform state command:_terraform_state_commands'
|
||||||
|
}
|
||||||
|
|
||||||
|
(( ${+functions[_terraform_state_commands]} )) || _terraform_state_commands() {
|
||||||
|
local -a _state_cmds
|
||||||
|
_state_cmds=(
|
||||||
|
'list:List resources in the state'
|
||||||
|
'mv:Move an item in the state'
|
||||||
|
'pull:Pull current state and output to stdout'
|
||||||
|
'push:Update remote state from a local state file'
|
||||||
|
'replace-provider:Replace provider in the state'
|
||||||
|
'rm:Remove instances from the state'
|
||||||
|
'show:Show a resource in the state'
|
||||||
|
)
|
||||||
|
if (( CURRENT == 1 )); then
|
||||||
|
_describe -t commands "terraform state commands" _state_cmds
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
local curcontext="${curcontext}"
|
||||||
|
cmd="${${_state_cmds[(r)$words[1]:*]%%:*}}"
|
||||||
|
curcontext="${curcontext%:*:*}:terraform-state-${cmd}:"
|
||||||
|
|
||||||
|
if (( ${+functions[_terraform_state_$cmd]} )); then
|
||||||
|
"_terraform_state_${cmd}"
|
||||||
|
else
|
||||||
|
_message "no more options"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
(( ${+functions[_terraform_state_list]} )) || _terraform_state_list() {
|
||||||
|
_arguments \
|
||||||
|
'-state=[(statefile) Path to a Terraform state file to use to look up Terraform-managed resources. By default, Terraform will consult the state of the currently-selected workspace.]:statefile:_files -W __chdir -g "*.tfstate"' \
|
||||||
|
'-id=[(id) Filters the results to include only instances whose resource types have an attribute named id whose value equals the given id string.]:id:' \
|
||||||
|
'*:address:__terraform_state_resources'
|
||||||
|
}
|
||||||
|
|
||||||
|
(( ${+functions[_terraform_state_mv]} )) || _terraform_state_mv() {
|
||||||
|
_arguments \
|
||||||
|
'-dry-run[If set, prints out what would'\''ve been moved but doesn'\''t actually move anything.]' \
|
||||||
|
'-backup=[(PATH) Path where Terraform should write the backup for the original state. This can"t be disabled. If not set, Terraform will write it to the same path as the statefile with a ".backup" extension.]:backupfile:_files -W __chdir -g "*.backup"' \
|
||||||
|
'-backup-out=[(PATH) Path where Terraform should write the backup for the destination state. This can"t be disabled. If not set, Terraform will write it to the same path as the destination state file with a backup extension. This only needs to be specified if -state-out is set to a different path than -state.]:backupfile:_files -W __chdir -g "*.backup"' \
|
||||||
|
'-ignore-remote-version[A rare option used for the remote backend only. See the remote backend documentation for more information.]' \
|
||||||
|
'-lock=[(true) Don'\''t hold a state lock during the operation. This is dangerous if others might concurrently run commands against the same workspace.]:lock:(true false)' \
|
||||||
|
'-lock-timeout=[(0s) Duration to retry a state lock.]:lock_timeout:' \
|
||||||
|
'-state=[(path) Path to the source state file. Defaults to the configured backend, or "terraform.tfstate"]:statefile:_files -W __chdir -g "*.tfstate"' \
|
||||||
|
'-state-out=[(path) Path to the destination state file to write to. If this isn"t specified, the source state file will be used. This can be a new or existing path.]:statefile:_files -W __chdir -g "*.tfstate"' \
|
||||||
|
'::' \
|
||||||
|
':source:__terraform_state_resources' \
|
||||||
|
':destination: '
|
||||||
|
}
|
||||||
|
|
||||||
|
(( ${+functions[_terraform_state_push]} )) || _terraform_state_push() {
|
||||||
|
_arguments \
|
||||||
|
'-force[Write the state even if lineages don'\''t match or the remote serial is higher.]' \
|
||||||
|
'-lock=[(true) Don'\''t hold a state lock during the operation. This is dangerous if others might concurrently run commands against the same workspace.]:lock:(true false)' \
|
||||||
|
'-lock-timeout=[(0s) Duration to retry a state lock.]:lock_timeout:' \
|
||||||
|
'::' \
|
||||||
|
':destination:_files'
|
||||||
|
}
|
||||||
|
|
||||||
|
(( ${+functions[_terraform_state_replace-provider]} )) || _terraform_state_replace-provider() {
|
||||||
_arguments \
|
_arguments \
|
||||||
'-auto-approve[Skip interactive approval.]' \
|
'-auto-approve[Skip interactive approval.]' \
|
||||||
'-backup=[(PATH) Path where Terraform should write the backup for the state file. This can"t be disabled. If not set, Terraform will write it to the same path as the state file with a ".backup" extension.]:backupfile:_files -g "*.backup"' \
|
'-backup=[(PATH) Path where Terraform should write the backup for the state file. This can"t be disabled. If not set, Terraform will write it to the same path as the state file with a ".backup" extension.]:backupfile:_files -W __chdir -g "*.backup"' \
|
||||||
"-lock=[(true) Lock the state files when locking is supported.]:lock:(true false)" \
|
'-lock=[(true) Don'\''t hold a state lock during the operation. This is dangerous if others might concurrently run commands against the same workspace.]:lock:(true false)' \
|
||||||
"-lock-timeout=[(0s) Duration to retry a state lock.]" \
|
'-lock-timeout=[(0s) Duration to retry a state lock.]:lock_timeout:' \
|
||||||
'-state=[(PATH) Path to the source state file. Defaults to the configured backend, or "terraform.tfstate"]:statefile:_files -g "*.tfstate"' \
|
'-state=[(PATH) Path to the source state file. Defaults to the configured backend, or "terraform.tfstate"]:statefile:_files -W __chdir -g "*.tfstate"' \
|
||||||
":from_provider_fqn:" \
|
'::' \
|
||||||
":to_provider_fqn:"
|
':from_provider_fqn:' \
|
||||||
|
':to_provider_fqn:'
|
||||||
}
|
}
|
||||||
|
|
||||||
__state_rm() {
|
(( ${+functions[_terraform_state_rm]} )) || _terraform_state_rm() {
|
||||||
_arguments \
|
_arguments \
|
||||||
"-dry-run[If set, prints out what would've been removed but doesn't actually remove anything.]" \
|
'-dry-run[If set, prints out what would'\''ve been removed but doesn'\''t actually remove anything.]' \
|
||||||
'-backup=[(PATH) Path where Terraform should write the backup for the original state.]::backupfile:_files -g "*.backup"' \
|
'-backup=[(PATH) Path where Terraform should write the backup for the original state.]::backupfile:_files -W __chdir -g "*.backup"' \
|
||||||
"-lock=[(true) Lock the state file when locking is supported.]:lock:(true false)" \
|
'-ignore-remote-version[Continue even if remote and local Terraform versions are incompatible. This may result in an unusable workspace, and should be used with extreme caution.]' \
|
||||||
"-lock-timeout=[(0s) Duration to retry a state lock.]" \
|
'-lock=[(true) Don'\''t hold a state lock during the operation. This is dangerous if others might concurrently run commands against the same workspace.]:lock:(true false)' \
|
||||||
'-state=[(PATH) Path to the state file to update. Defaults to the current workspace state.]:statefile:_files -g "*.tfstate"' \
|
'-lock-timeout=[(0s) Duration to retry a state lock.]:lock_timeout:' \
|
||||||
"*:address:__statelist"
|
'-state=[(PATH) Path to the state file to update. Defaults to the current workspace state.]:statefile:_files -W __chdir -g "*.tfstate"' \
|
||||||
|
'*:address:__terraform_state_resources'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
(( ${+functions[_terraform_state_show]} )) || _terraform_state_show() {
|
||||||
__state_show() {
|
|
||||||
_arguments \
|
_arguments \
|
||||||
'-state=[(statefile) Path to a Terraform state file to use to look up Terraform-managed resources. By default it will use the state "terraform.tfstate" if it exists.]:statefile:_files -g "*.tfstate"' \
|
'-state=[(statefile) Path to a Terraform state file to use to look up Terraform-managed resources. By default it will use the state "terraform.tfstate" if it exists.]:statefile:_files -W __chdir -g "*.tfstate"' \
|
||||||
"*:address:__statelist"
|
"*:address:__terraform_state_resources"
|
||||||
}
|
}
|
||||||
|
|
||||||
__statelist() {
|
(( ${+functions[__terraform_state_resources]} )) || __terraform_state_resources() {
|
||||||
compadd $(terraform state list $opt_args[-state])
|
local resource
|
||||||
|
local -a resources
|
||||||
|
terraform -chdir="${__chdir}" state list -state="${opt_args[-state]}" 2>/dev/null | while read -r resource; do
|
||||||
|
resources+=( "${resource}" )
|
||||||
|
done
|
||||||
|
compadd "${@}" - "${resources[@]}"
|
||||||
}
|
}
|
||||||
|
|
||||||
__taint() {
|
(( ${+functions[_terraform_taint]} )) || _terraform_taint() {
|
||||||
_arguments \
|
_arguments \
|
||||||
'-allow-missing[If specified, the command will succeed (exit code 0) even if the resource is missing.]' \
|
|
||||||
'-backup=[(path) Path to backup the existing state file before modifying. Defaults to the "-state-out" path with ".backup" extension. Set to "-" to disable backup.]:backupfile:_files -g "*.backup"' \
|
|
||||||
'-lock=[(true) Lock the state file when locking is supported.]:lock:(true false)' \
|
|
||||||
'-lock-timeout=[(0s) Duration to retry a state lock.]' \
|
|
||||||
'-module=[(path) The module path where the resource lives. By default this will be root. Child modules can be specified by names. Ex. "consul" or "consul.vpc" (nested modules).]' \
|
|
||||||
'-state=[(path) Path to read and save state (unless state-out is specified). Defaults to "terraform.tfstate".]:statefile:_files -g "*.tfstate"' \
|
|
||||||
'-state-out=[(path) Path to write updated state file. By default, the "-state" path will be used.]:statefile:_files -g "*.tfstate"' \
|
|
||||||
"*:address:__statelist"
|
|
||||||
}
|
|
||||||
|
|
||||||
__untaint() {
|
|
||||||
_arguments \
|
|
||||||
'-allow-missing[If specified, the command will succeed (exit code 0) even if the resource is missing.]' \
|
'-allow-missing[If specified, the command will succeed (exit code 0) even if the resource is missing.]' \
|
||||||
'-backup=[(path) Path to backup the existing state file before modifying. Defaults to the "-state-out" path with ".backup" extension. Set to "-" to disable backup.]:backupfile:_files -g "*.backup"' \
|
'-backup=[(path) Path to backup the existing state file before modifying. Defaults to the "-state-out" path with ".backup" extension. Set to "-" to disable backup.]:backupfile:_files -W __chdir -g "*.backup"' \
|
||||||
'-lock=[(true) Lock the state file when locking is supported.]:lock:(true false)' \
|
'-ignore-remote-version[A rare option used for the remote backend only. See the remote backend documentation for more information.]' \
|
||||||
'-lock-timeout=[(0s) Duration to retry a state lock.]' \
|
'-lock=[(true) Don'\''t hold a state lock during the operation. This is dangerous if others might concurrently run commands against the same workspace.]:lock:(true false)' \
|
||||||
'-module=[(path) The module path where the resource lives. By default this will be root. Child modules can be specified by names. Ex. "consul" or "consul.vpc" (nested modules).]' \
|
'-lock-timeout=[(0s) Duration to retry a state lock.]:lock_timeout:' \
|
||||||
'-state=[(path) Path to read and save state (unless state-out is specified). Defaults to "terraform.tfstate".]:statefile:_files -g "*.tfstate"' \
|
'-state=[(path) Path to read and save state (unless state-out is specified). Defaults to "terraform.tfstate".]:statefile:_files -W __chdir -g "*.tfstate"' \
|
||||||
'-state-out=[(path) Path to write updated state file. By default, the "-state" path will be used.]:statefile:_files -g "*.tfstate"'
|
'-state-out=[(path) Path to write updated state file. By default, the "-state" path will be used.]:statefile:_files -W __chdir -g "*.tfstate"' \
|
||||||
|
'*:address:__terraform_state_resources'
|
||||||
}
|
}
|
||||||
|
|
||||||
__validate() {
|
(( ${+functions[_terraform_test]} )) || _terraform_test() {
|
||||||
_arguments \
|
_arguments \
|
||||||
'-no-color[If specified, output will not contain any color.]' \
|
'-cloud-run=[(source) If specified, Terraform will execute this test run remotely using Terraform Cloud. You must specify the source of a module registered in a private module registry as the argument to this flag. This allows Terraform to associate the cloud run with the correct Terraform Cloud module and organization.]:cloud_run:' \
|
||||||
|
'*-filter=[(testfile) If specified, Terraform will only execute the test files specified by this flag. You can use this option multiple times to execute more than one test file.]:testfile:_files -W __chdir -g "*.tftest.hcl"' \
|
||||||
|
'-json[If specified, machine readable output will be printed in JSON format]' \
|
||||||
|
'-no-color[If specified, machine readable output will be printed in JSON format]' \
|
||||||
|
'-test-directory=[(path) Set the Terraform test directory, defaults to "tests".]:test_directory:_files -W __chdir -/' \
|
||||||
|
'*-var=[(for=bar) Set a value for one of the input variables in the root module of the configuration. Use this option more than once to set more than one variable.]:var:' \
|
||||||
|
'*-var-file=[(foo) Load variable values from the given file, in addition to the default files terraform.tfvars and *.auto.tfvars. Use this option more than once to include more than one variables file.]:file:_files -W __chdir -g "*.tfvars{,.json}"' \
|
||||||
|
'-verbose[Print the plan or state for each test run block as it executes.]' \
|
||||||
|
}
|
||||||
|
|
||||||
|
(( ${+functions[_terraform_untaint]} )) || _terraform_untaint() {
|
||||||
|
_arguments \
|
||||||
|
'-allow-missing[If specified, the command will succeed (exit code 0) even if the resource is missing.]' \
|
||||||
|
'-backup=[(path) Path to backup the existing state file before modifying. Defaults to the "-state-out" path with ".backup" extension. Set to "-" to disable backup.]:backupfile:_files -W __chdir -g "*.backup"' \
|
||||||
|
'-lock=[(true) Don'\''t hold a state lock during the operation. This is dangerous if others might concurrently run commands against the same workspace.]:lock:(true false)' \
|
||||||
|
'-lock-timeout=[(0s) Duration to retry a state lock.]:lock_timeout:' \
|
||||||
|
'-state=[(path) Path to read and save state (unless state-out is specified). Defaults to "terraform.tfstate".]:statefile:_files -W __chdir -g "*.tfstate"' \
|
||||||
|
'-state-out=[(path) Path to write updated state file. By default, the "-state" path will be used.]:statefile:_files -W __chdir -g "*.tfstate"' \
|
||||||
|
':name:__terraform_state_resources'
|
||||||
|
}
|
||||||
|
|
||||||
|
(( ${+functions[_terraform_validate]} )) || _terraform_validate() {
|
||||||
|
_arguments \
|
||||||
'-json[Produce output in a machine-readable JSON format, suitable for use in text editor integrations and other automated systems.]' \
|
'-json[Produce output in a machine-readable JSON format, suitable for use in text editor integrations and other automated systems.]' \
|
||||||
':dir:_files -/'
|
'-no-color[If specified, output will not contain any color.]' \
|
||||||
|
'-no-tests[If specified, Terraform will not validate test files.]' \
|
||||||
|
'-test-directory=[(path) Set the Terraform test directory, defaults to "tests".]:test_directory:_files -W __chdir -/' \
|
||||||
|
':dir:_files -W __chdir -/'
|
||||||
}
|
}
|
||||||
|
|
||||||
__version() {
|
(( ${+functions[_terraform_version]} )) || _terraform_version() {
|
||||||
_arguments \
|
_arguments \
|
||||||
'-json[Output the version information as a JSON object.]'
|
'-json[Output the version information as a JSON object.]' \
|
||||||
|
'::'
|
||||||
}
|
}
|
||||||
|
|
||||||
__workspace() {
|
(( ${+functions[_terraform_workspace]} )) || _terraform_workspace() {
|
||||||
local -a __workspace_cmds
|
_arguments \
|
||||||
__workspace_cmds=(
|
'*::terraform workspace command:_terraform_workspace_commands'
|
||||||
'delete:Delete a workspace'
|
|
||||||
'list:List Workspaces'
|
|
||||||
'new:Create a new workspace'
|
|
||||||
'select:Select a workspace'
|
|
||||||
'show:Show the name of the current workspace'
|
|
||||||
)
|
|
||||||
_describe -t workspace "workspace commands" __workspace_cmds
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_arguments '*:: :->command'
|
(( ${+functions[_terraform_workspace_commands]} )) || _terraform_workspace_commands() {
|
||||||
|
local -a _workspace_cmds
|
||||||
|
_workspace_cmds=(
|
||||||
|
'delete:Delete a workspace'
|
||||||
|
'list:List Workspaces'
|
||||||
|
'new:Create a new workspace'
|
||||||
|
'select:Select a workspace'
|
||||||
|
'show:Show the name of the current workspace'
|
||||||
|
)
|
||||||
|
if (( CURRENT == 1 )); then
|
||||||
|
_describe -t commands "terraform workspace commands" _workspace_cmds
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
if (( CURRENT == 1 )); then
|
local curcontext="${curcontext}"
|
||||||
_describe -t commands "terraform command" _terraform_cmds
|
cmd="${${_workspace_cmds[(r)$words[1]:*]%%:*}}"
|
||||||
return
|
curcontext="${curcontext%:*:*}:terraform-workspace-${cmd}:"
|
||||||
|
|
||||||
|
if (( ${+functions[_terraform_workspace_$cmd]} )); then
|
||||||
|
"_terraform_workspace_${cmd}"
|
||||||
|
else
|
||||||
|
_message "no more options"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
(( ${+functions[_terraform_workspace_delete]} )) || _terraform_workspace_delete() {
|
||||||
|
_arguments \
|
||||||
|
'-force[Remove a workspace even if it is managing resources. Terraform can no longer track or manage the workspace'\''s infrastructure.]' \
|
||||||
|
'-lock=[(true) Don'\''t hold a state lock during the operation. This is dangerous if others might concurrently run commands against the same workspace.]:lock:(true false)' \
|
||||||
|
'-lock-timeout=[(0s) Duration to retry a state lock.]:lock_timeout:' \
|
||||||
|
'::' \
|
||||||
|
':name:__terraform_workspaces'
|
||||||
|
}
|
||||||
|
|
||||||
|
(( ${+functions[_terraform_workspace_list]} )) || _terraform_workspace_list() {
|
||||||
|
_arguments
|
||||||
|
}
|
||||||
|
|
||||||
|
(( ${+functions[_terraform_workspace_new]} )) || _terraform_workspace_new() {
|
||||||
|
_arguments \
|
||||||
|
'-lock=[(true) Don'\''t hold a state lock during the operation. This is dangerous if others might concurrently run commands against the same workspace.]:lock:(true false)' \
|
||||||
|
'-lock-timeout=[(0s) Duration to retry a state lock.]:lock_timeout:' \
|
||||||
|
'-state=[(path) Copy an existing state file into the new workspace.]:statefile:_files -W __chdir -g "*.tfstate"' \
|
||||||
|
'::' \
|
||||||
|
':name:'
|
||||||
|
}
|
||||||
|
|
||||||
|
(( ${+functions[_terraform_workspace_select]} )) || _terraform_workspace_select() {
|
||||||
|
_arguments \
|
||||||
|
'-or-create=[(false) Create the Terraform workspace if it doesn'\''t exist.]:or_create:(true false)' \
|
||||||
|
'::' \
|
||||||
|
':name:__terraform_workspaces'
|
||||||
|
}
|
||||||
|
|
||||||
|
(( ${+functions[_terraform_workspace_show]} )) || _terraform_workspace_show() {
|
||||||
|
_arguments
|
||||||
|
}
|
||||||
|
|
||||||
|
(( ${+functions[__terraform_workspaces]} )) || __terraform_workspaces() {
|
||||||
|
local workspace
|
||||||
|
local -a workspaces
|
||||||
|
terraform -chdir="${__chdir}" workspace list | while read -r workspace; do
|
||||||
|
if [[ -z "${workspace}" ]]; then
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
workspaces+=( "${workspace#[ *] }" )
|
||||||
|
done
|
||||||
|
compadd "${@}" - "${workspaces[@]}"
|
||||||
|
}
|
||||||
|
|
||||||
|
_terraform() {
|
||||||
|
_arguments \
|
||||||
|
'-chdir=[(DIR) Switch to a different working directory before executing the given subcommand.]:chdir:_files -W __chdir -/' \
|
||||||
|
'-help[Show this help output, or the help for a specified subcommand.]' \
|
||||||
|
'-version[An alias for the "version" subcommand.]' \
|
||||||
|
'*::terraform command:_terraform_commands'
|
||||||
|
}
|
||||||
|
|
||||||
|
# don't run the completion function when being source-ed or eval-ed
|
||||||
|
if [ "${funcstack[1]}" = '_terraform' ]; then
|
||||||
|
_terraform
|
||||||
fi
|
fi
|
||||||
|
|
||||||
local -a _command_args
|
|
||||||
case "$words[1]" in
|
|
||||||
0.12upgrade)
|
|
||||||
__012upgrade ;;
|
|
||||||
0.13upgrade)
|
|
||||||
__013upgrade ;;
|
|
||||||
apply)
|
|
||||||
__apply ;;
|
|
||||||
console)
|
|
||||||
__console;;
|
|
||||||
destroy)
|
|
||||||
__destroy ;;
|
|
||||||
fmt)
|
|
||||||
__fmt;;
|
|
||||||
force-unlock)
|
|
||||||
__force_unlock;;
|
|
||||||
get)
|
|
||||||
__get ;;
|
|
||||||
graph)
|
|
||||||
__graph ;;
|
|
||||||
import)
|
|
||||||
__import;;
|
|
||||||
init)
|
|
||||||
__init ;;
|
|
||||||
login)
|
|
||||||
__login ;;
|
|
||||||
logout)
|
|
||||||
__logout ;;
|
|
||||||
output)
|
|
||||||
__output ;;
|
|
||||||
plan)
|
|
||||||
__plan ;;
|
|
||||||
providers)
|
|
||||||
test $CURRENT -lt 3 && __providers
|
|
||||||
[[ $words[2] = "mirror" ]] && __providers_mirror
|
|
||||||
[[ $words[2] = "schema" ]] && __providers_schema
|
|
||||||
;;
|
|
||||||
refresh)
|
|
||||||
__refresh ;;
|
|
||||||
show)
|
|
||||||
__show ;;
|
|
||||||
state)
|
|
||||||
test $CURRENT -lt 3 && __state
|
|
||||||
[[ $words[2] = "list" ]] && __state_list
|
|
||||||
[[ $words[2] = "mv" ]] && __state_mv
|
|
||||||
[[ $words[2] = "push" ]] && __state_push
|
|
||||||
[[ $words[2] = "replace-provider" ]] && __state_replace_provider
|
|
||||||
[[ $words[2] = "rm" ]] && __state_rm
|
|
||||||
[[ $words[2] = "show" ]] && __state_show
|
|
||||||
;;
|
|
||||||
taint)
|
|
||||||
__taint ;;
|
|
||||||
untaint)
|
|
||||||
__untaint ;;
|
|
||||||
validate)
|
|
||||||
__validate ;;
|
|
||||||
version)
|
|
||||||
__version ;;
|
|
||||||
workspace)
|
|
||||||
test $CURRENT -lt 3 && __workspace ;;
|
|
||||||
esac
|
|
||||||
|
|
|
||||||
|
|
@ -26,4 +26,5 @@ alias tfo='terraform output'
|
||||||
alias tfp='terraform plan'
|
alias tfp='terraform plan'
|
||||||
alias tfv='terraform validate'
|
alias tfv='terraform validate'
|
||||||
alias tfs='terraform state'
|
alias tfs='terraform state'
|
||||||
|
alias tft='terraform test'
|
||||||
alias tfsh='terraform show'
|
alias tfsh='terraform show'
|
||||||
|
|
|
||||||
15
plugins/tldr/README.md
Normal file
15
plugins/tldr/README.md
Normal 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 |
|
||||||
19
plugins/tldr/tldr.plugin.zsh
Normal file
19
plugins/tldr/tldr.plugin.zsh
Normal 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
|
||||||
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
# tmux
|
# tmux
|
||||||
|
|
||||||
This plugin provides aliases for [tmux](https://tmux.github.io/), the terminal multiplexer.
|
This plugin provides aliases for [tmux](https://tmux.github.io/), the terminal multiplexer. To use it add
|
||||||
To use it add `tmux` to the plugins array in your zshrc file.
|
`tmux` to the plugins array in your zshrc file.
|
||||||
|
|
||||||
```zsh
|
```zsh
|
||||||
plugins=(... tmux)
|
plugins=(... tmux)
|
||||||
|
|
@ -19,26 +19,28 @@ The plugin also supports the following:
|
||||||
| ---------- | -------------------------- | -------------------------------------------------------- |
|
| ---------- | -------------------------- | -------------------------------------------------------- |
|
||||||
| `ta` | tmux attach -t | Attach new tmux session to already running named session |
|
| `ta` | tmux attach -t | Attach new tmux session to already running named session |
|
||||||
| `tad` | tmux attach -d -t | Detach named tmux session |
|
| `tad` | tmux attach -d -t | Detach named tmux session |
|
||||||
| `ts` | tmux new-session -s | Create a new named tmux session |
|
| `tds` | `_tmux_directory_session` | Creates or attaches to a session for the current path |
|
||||||
| `tl` | tmux list-sessions | Displays a list of running tmux sessions |
|
|
||||||
| `tksv` | tmux kill-server | Terminate all running tmux sessions |
|
|
||||||
| `tkss` | tmux kill-session -t | Terminate named running tmux session |
|
| `tkss` | tmux kill-session -t | Terminate named running tmux session |
|
||||||
|
| `tksv` | tmux kill-server | Terminate all running tmux sessions |
|
||||||
|
| `tl` | tmux list-sessions | Displays a list of running tmux sessions |
|
||||||
| `tmux` | `_zsh_tmux_plugin_run` | Start a new tmux session |
|
| `tmux` | `_zsh_tmux_plugin_run` | Start a new tmux session |
|
||||||
| `tmuxconf` | `$EDITOR $ZSH_TMUX_CONFIG` | Open .tmux.conf file with an editor |
|
| `tmuxconf` | `$EDITOR $ZSH_TMUX_CONFIG` | Open .tmux.conf file with an editor |
|
||||||
| `tds` | `_tmux_directory_session` | Creates or attaches to a session for the current path |
|
| `ts` | tmux new-session -s | Create a new named tmux session |
|
||||||
|
|
||||||
## Configuration Variables
|
## Configuration Variables
|
||||||
|
|
||||||
| Variable | Description |
|
| Variable | Description |
|
||||||
| ----------------------------------- | ------------------------------------------------------------------------------------------- |
|
| ----------------------------------- | ----------------------------------------------------------------------------------------------------------- |
|
||||||
| `ZSH_TMUX_AUTOSTART` | Automatically starts tmux (default: `false`) |
|
| `ZSH_TMUX_AUTOSTART` | Automatically starts tmux (default: `false`) |
|
||||||
| `ZSH_TMUX_AUTOSTART_ONCE` | Autostart only if tmux hasn't been started previously (default: `true`) |
|
| `ZSH_TMUX_AUTOSTART_ONCE` | Autostart only if tmux hasn't been started previously (default: `true`) |
|
||||||
| `ZSH_TMUX_AUTOCONNECT` | Automatically connect to a previous session if it exits (default: `true`) |
|
| `ZSH_TMUX_AUTOCONNECT` | Automatically connect to a previous session if it exits (default: `true`) |
|
||||||
| `ZSH_TMUX_AUTOQUIT` | Automatically closes terminal once tmux exits (default: `ZSH_TMUX_AUTOSTART`) |
|
| `ZSH_TMUX_AUTOQUIT` | Automatically closes terminal once tmux exits (default: `ZSH_TMUX_AUTOSTART`) |
|
||||||
| `ZSH_TMUX_FIXTERM` | Sets `$TERM` to 256-color term or not based on current terminal support |
|
| `ZSH_TMUX_CONFIG` | Set the configuration path (default: `$HOME/.tmux.conf`, `$XDG_CONFIG_HOME/tmux/tmux.conf`) |
|
||||||
| `ZSH_TMUX_ITERM2` | Sets the `-CC` option for iTerm2 tmux integration (default: `false`) |
|
| `ZSH_TMUX_DEFAULT_SESSION_NAME` | Set tmux default session name when autostart is enabled |
|
||||||
| `ZSH_TMUX_FIXTERM_WITHOUT_256COLOR` | `$TERM` to use for non 256-color terminals (default: `screen`) |
|
| `ZSH_TMUX_AUTONAME_SESSION` | Automatically name new sessions based on the basename of `$PWD` (default: `false`) |
|
||||||
| `ZSH_TMUX_FIXTERM_WITH_256COLOR` | `$TERM` to use for 256-color terminals (default: `screen-256color` |
|
| `ZSH_TMUX_DETACHED` | Set the detached mode (default: `false`) |
|
||||||
| `ZSH_TMUX_CONFIG` | Set the configuration path (default: `$HOME/.tmux.conf`, `$XDG_CONFIG_HOME/tmux/tmux.conf`) |
|
| `ZSH_TMUX_FIXTERM` | Sets `$TERM` to 256-color term or not based on current terminal support |
|
||||||
| `ZSH_TMUX_UNICODE` | Set `tmux -u` option to support unicode |
|
| `ZSH_TMUX_FIXTERM_WITHOUT_256COLOR` | `$TERM` to use for non 256-color terminals (default: `tmux` if available, `screen` otherwise) |
|
||||||
| `ZSH_TMUX_DEFAULT_SESSION_NAME` | Set tmux default session name when autostart is enabled |
|
| `ZSH_TMUX_FIXTERM_WITH_256COLOR` | `$TERM` to use for 256-color terminals (default: `tmux-256color` if available, `screen-256color` otherwise) |
|
||||||
|
| `ZSH_TMUX_ITERM2` | Sets the `-CC` option for iTerm2 tmux integration (default: `false`) |
|
||||||
|
| `ZSH_TMUX_UNICODE` | Set `tmux -u` option to support unicode |
|
||||||
|
|
|
||||||
|
|
@ -13,18 +13,30 @@ fi
|
||||||
: ${ZSH_TMUX_AUTOCONNECT:=true}
|
: ${ZSH_TMUX_AUTOCONNECT:=true}
|
||||||
# Automatically close the terminal when tmux exits
|
# Automatically close the terminal when tmux exits
|
||||||
: ${ZSH_TMUX_AUTOQUIT:=$ZSH_TMUX_AUTOSTART}
|
: ${ZSH_TMUX_AUTOQUIT:=$ZSH_TMUX_AUTOSTART}
|
||||||
|
# Automatically name the new session based on the basename of PWD
|
||||||
|
: ${ZSH_TMUX_AUTONAME_SESSION:=false}
|
||||||
# Set term to screen or screen-256color based on current terminal support
|
# Set term to screen or screen-256color based on current terminal support
|
||||||
|
: ${ZSH_TMUX_DETACHED:=false}
|
||||||
|
# Set detached mode
|
||||||
: ${ZSH_TMUX_FIXTERM:=true}
|
: ${ZSH_TMUX_FIXTERM:=true}
|
||||||
# Set '-CC' option for iTerm2 tmux integration
|
# Set '-CC' option for iTerm2 tmux integration
|
||||||
: ${ZSH_TMUX_ITERM2:=false}
|
: ${ZSH_TMUX_ITERM2:=false}
|
||||||
# The TERM to use for non-256 color terminals.
|
# The TERM to use for non-256 color terminals.
|
||||||
# Tmux states this should be screen, but you may need to change it on
|
# Tmux states this should be tmux|screen, but you may need to change it on
|
||||||
# systems without the proper terminfo
|
# systems without the proper terminfo
|
||||||
: ${ZSH_TMUX_FIXTERM_WITHOUT_256COLOR:=screen}
|
if [[ -e /usr/share/terminfo/t/tmux ]]; then
|
||||||
|
: ${ZSH_TMUX_FIXTERM_WITHOUT_256COLOR:=tmux}
|
||||||
|
else
|
||||||
|
: ${ZSH_TMUX_FIXTERM_WITHOUT_256COLOR:=screen}
|
||||||
|
fi
|
||||||
# The TERM to use for 256 color terminals.
|
# The TERM to use for 256 color terminals.
|
||||||
# Tmux states this should be screen-256color, but you may need to change it on
|
# Tmux states this should be (tmux|screen)-256color, but you may need to change it on
|
||||||
# systems without the proper terminfo
|
# systems without the proper terminfo
|
||||||
: ${ZSH_TMUX_FIXTERM_WITH_256COLOR:=screen-256color}
|
if [[ -e /usr/share/terminfo/t/tmux-256color ]]; then
|
||||||
|
: ${ZSH_TMUX_FIXTERM_WITH_256COLOR:=tmux-256color}
|
||||||
|
else
|
||||||
|
: ${ZSH_TMUX_FIXTERM_WITH_256COLOR:=screen-256color}
|
||||||
|
fi
|
||||||
# Set the configuration path
|
# Set the configuration path
|
||||||
if [[ -e $HOME/.tmux.conf ]]; then
|
if [[ -e $HOME/.tmux.conf ]]; then
|
||||||
: ${ZSH_TMUX_CONFIG:=$HOME/.tmux.conf}
|
: ${ZSH_TMUX_CONFIG:=$HOME/.tmux.conf}
|
||||||
|
|
@ -37,14 +49,40 @@ fi
|
||||||
: ${ZSH_TMUX_UNICODE:=false}
|
: ${ZSH_TMUX_UNICODE:=false}
|
||||||
|
|
||||||
# ALIASES
|
# ALIASES
|
||||||
alias ta='tmux attach -t'
|
function _build_tmux_alias {
|
||||||
alias tad='tmux attach -d -t'
|
eval "function $1 {
|
||||||
alias ts='tmux new-session -s'
|
if [[ -z \$1 ]] || [[ \${1:0:1} == '-' ]]; then
|
||||||
alias tl='tmux list-sessions'
|
tmux $2 \"\$@\"
|
||||||
|
else
|
||||||
|
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'
|
alias tksv='tmux kill-server'
|
||||||
alias tkss='tmux kill-session -t'
|
alias tl='tmux list-sessions'
|
||||||
alias tmuxconf='$EDITOR $ZSH_TMUX_CONFIG'
|
alias tmuxconf='$EDITOR $ZSH_TMUX_CONFIG'
|
||||||
|
|
||||||
|
_build_tmux_alias "ta" "attach" "-t"
|
||||||
|
_build_tmux_alias "tad" "attach -d" "-t"
|
||||||
|
_build_tmux_alias "ts" "new-session" "-s"
|
||||||
|
_build_tmux_alias "tkss" "kill-session" "-t"
|
||||||
|
|
||||||
|
unfunction _build_tmux_alias
|
||||||
|
|
||||||
# Determine if the terminal supports 256 colors
|
# Determine if the terminal supports 256 colors
|
||||||
if [[ $terminfo[colors] == 256 ]]; then
|
if [[ $terminfo[colors] == 256 ]]; then
|
||||||
export ZSH_TMUX_TERM=$ZSH_TMUX_FIXTERM_WITH_256COLOR
|
export ZSH_TMUX_TERM=$ZSH_TMUX_FIXTERM_WITH_256COLOR
|
||||||
|
|
@ -77,11 +115,26 @@ function _zsh_tmux_plugin_run() {
|
||||||
[[ "$ZSH_TMUX_ITERM2" == "true" ]] && tmux_cmd+=(-CC)
|
[[ "$ZSH_TMUX_ITERM2" == "true" ]] && tmux_cmd+=(-CC)
|
||||||
[[ "$ZSH_TMUX_UNICODE" == "true" ]] && tmux_cmd+=(-u)
|
[[ "$ZSH_TMUX_UNICODE" == "true" ]] && tmux_cmd+=(-u)
|
||||||
|
|
||||||
# Try to connect to an existing session.
|
local _detached=""
|
||||||
if [[ -n "$ZSH_TMUX_DEFAULT_SESSION_NAME" ]]; then
|
[[ "$ZSH_TMUX_DETACHED" == "true" ]] && _detached="-d"
|
||||||
[[ "$ZSH_TMUX_AUTOCONNECT" == "true" ]] && $tmux_cmd attach -t $ZSH_TMUX_DEFAULT_SESSION_NAME
|
|
||||||
|
local session_name
|
||||||
|
if [[ "$ZSH_TMUX_AUTONAME_SESSION" == "true" ]]; then
|
||||||
|
# Name the session after the basename of the current directory
|
||||||
|
session_name=${PWD##*/}
|
||||||
|
# If the current directory is the home directory, name it 'HOME'
|
||||||
|
[[ "$PWD" == "$HOME" ]] && session_name="HOME"
|
||||||
|
# If the current directory is the root directory, name it 'ROOT'
|
||||||
|
[[ "$PWD" == "/" ]] && session_name="ROOT"
|
||||||
else
|
else
|
||||||
[[ "$ZSH_TMUX_AUTOCONNECT" == "true" ]] && $tmux_cmd attach
|
session_name="$ZSH_TMUX_DEFAULT_SESSION_NAME"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Try to connect to an existing session.
|
||||||
|
if [[ -n "$session_name" ]]; then
|
||||||
|
[[ "$ZSH_TMUX_AUTOCONNECT" == "true" ]] && $tmux_cmd attach $_detached -t "$session_name"
|
||||||
|
else
|
||||||
|
[[ "$ZSH_TMUX_AUTOCONNECT" == "true" ]] && $tmux_cmd attach $_detached
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# If failed, just run tmux, fixing the TERM variable if requested.
|
# If failed, just run tmux, fixing the TERM variable if requested.
|
||||||
|
|
@ -91,8 +144,9 @@ function _zsh_tmux_plugin_run() {
|
||||||
elif [[ -e "$ZSH_TMUX_CONFIG" ]]; then
|
elif [[ -e "$ZSH_TMUX_CONFIG" ]]; then
|
||||||
tmux_cmd+=(-f "$ZSH_TMUX_CONFIG")
|
tmux_cmd+=(-f "$ZSH_TMUX_CONFIG")
|
||||||
fi
|
fi
|
||||||
if [[ -n "$ZSH_TMUX_DEFAULT_SESSION_NAME" ]]; then
|
|
||||||
$tmux_cmd new-session -s $ZSH_TMUX_DEFAULT_SESSION_NAME
|
if [[ -n "$session_name" ]]; then
|
||||||
|
$tmux_cmd new-session -s "$session_name"
|
||||||
else
|
else
|
||||||
$tmux_cmd new-session
|
$tmux_cmd new-session
|
||||||
fi
|
fi
|
||||||
|
|
|
||||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue