Compare commits

...
Author SHA1 Message Date
Calion 44a5decbc4 docs(thefuck): put the plugins line in a code block (#13272)
Added copybox for plugin code
2026-11-27 19:23:33 -08:00
Abdullah Ahmed 90f9fbc532 feat(terraform): add terraform-docs completion (#14185)
Generate completions from the installed terraform-docs CLI in the background and preserve a valid cache when generation fails or returns no output.

Fixes #12138

AI-assisted with OpenAI Codex.
2026-11-27 19:01:52 -08:00
Tien Nguyen Minh 801782e8a6 fix(spectrum): fall back to a loop on zsh older than 5.0.6 (#14278) 2026-11-27 18:54:18 -08:00
Markus Hofbauer e7a67d2e80 ci: add alias collision check (#10859)
* first draft alias collision

* add collision check to github actions

* run python unit tests in CI

* update actions to latest major version

* rename test to tests

* improve error message

* print all collisions found before failing

* disable failing of collision checker temporarily

* fix CI

* refactor to pytest

* add filter for known collisions

* read known collisions from file

* removed resolved collision

* remove known collisions

* better use checkout

* explicitly use master

* fix plugin path

* move tool to .github workflows

* review comments

* pin actions
2026-11-27 18:34:48 -08:00
Jans Rautenbach 4ec1d17074 feat(kubectl): add kcgetns alias to show the current namespace (#13215)
* rebase and review changes

* full command in readme

* space
2026-11-27 18:33:03 -08:00
180909 71679f351d feat(golang): add goge alias for go generate (#11528)
* feat(golang): add `goge` alias for `go generate`

* feat(golang):update  sequence
2026-11-27 18:32:08 -08:00
Sri Harsha Ponukumati 5c7cd91615 fix(uninstall): prompt before restoring pre-OMZ zshrc backup (#13849)
Fixes #13156
Fixes #13328
2026-11-27 18:30:43 -08:00
Jakub Boukal 5873e1cfec docs(python): add PYTHON_AUTO_VRUN to settings (#14233) 2026-11-27 16:20:27 -08:00
alexanderxc 03ba23c9f6 chore(brew): use bu instead of bubo in bubu (#14229) 2026-11-27 16:19:51 -08:00
PerryLink 597dff9477 fix(extract): untar .tar.Z and .taz archives (#14223) 2026-11-27 16:19:46 -08:00
Marco Trevisan 80ec81e340 feat(clipboard): add OSC 52 fallback (#14251)
OSC 52 makes the terminal emulator set the clipboard of the machine the
user is connected from, which is the only way to copy to it when running
over SSH or inside a container with no access to the local display
server.

Use it when no other clipboard tool is available, or when
ZSH_CLIPBOARD_OSC52 is set to "always"; set it to "never" to disable the
fallback. OSC 52 is write-only in practice, so clippaste keeps failing
unless a real clipboard tool is available.

Closes #13459
2026-11-27 16:19:24 -08:00
Sam Thomas 22c883efa4 fix(dotenv): bypass aliases when checking .env syntax (#14179) 2026-11-27 15:33:11 -08:00
Sam Thomas da85047297 fix(updater): bypass aliases when calling zsh in update check (#14178) 2026-11-27 15:33:06 -08:00
Jay Pokale 113f9b2475 fix(cli): remove adjacent plugins in omz plugin disable (#14303) 2026-11-27 15:19:41 -08:00
Martin Darmüntzel 507561c236 fix(macos): set shuffle with Music's shuffle property in music shuffle (#13365) 2026-11-27 14:58:20 -08:00
Hobeom Jeon d419792761 feat(conda): add environment completion for cna and cnrn (#13632) 2026-11-27 14:54:10 -08:00
Hobeom Jeon 90e5779f1f feat(zellij): add zellij plugin (#13624) 2026-11-27 14:54:06 -08:00
gbaian10 1dc43bfe53 fix(pre-commit): use autoupdate for prek (#14295)
Closes #14294
2026-11-27 14:46:13 -08:00
Rasmus Skovgaard Lauritsen 387dfe0bfb feat(fizzy): add completion plugin (#14297) 2026-11-27 14:46:09 -08:00
Sanjay Doppalapudi 32726ad0a5 fix(extract): unpack .tar.lzma archives (#14298) 2026-11-27 14:46:04 -08:00
Hegui Dai 2cd4cc21fc feat(jj): add jjgpb alias for jj git push --bookmark (#14302) 2026-11-27 14:45:52 -08:00
37 changed files with 776 additions and 51 deletions

No files matched your search

@@ -0,0 +1,2 @@
# default known collisions file
known_collisions.json
@@ -0,0 +1,170 @@
"""Check for alias collisions within the codebase"""
from argparse import ArgumentDefaultsHelpFormatter, ArgumentParser
from pathlib import Path
from dataclasses import dataclass
import itertools
import re
import json
import sys
ERROR_MESSAGE_TEMPLATE = (
"Alias `%s` defined in `%s` already exists as alias `%s` in `%s`."
)
KNOWN_COLLISIONS_PATH = Path(__file__).resolve().parent / "known_collisions.json"
def dir_path(path_string: str) -> Path:
if Path(path_string).is_dir():
return Path(path_string)
else:
raise NotADirectoryError(path_string)
def parse_arguments():
parser = ArgumentParser(
description=__doc__,
formatter_class=ArgumentDefaultsHelpFormatter,
)
parser.add_argument(
"folder",
type=dir_path,
help="Folder to check",
)
group = parser.add_mutually_exclusive_group(required=True)
group.add_argument(
"--known-collisions",
type=Path,
default=None,
help="Json-serialized list of known collision to compare to",
)
group.add_argument(
"--known-collisions-output-path",
type=Path,
default=KNOWN_COLLISIONS_PATH,
help="Output path for a json-serialized list of known collisions",
)
return parser.parse_args()
@dataclass(frozen=True)
class Alias:
alias: str
value: str
module: Path
def to_dict(self) -> dict:
return {
"alias": self.alias,
"value": self.value,
"module": str(self.module),
}
@dataclass(frozen=True)
class Collision:
existing_alias: Alias
new_alias: Alias
def is_new_collision(self, known_collision_aliases: list[str]) -> bool:
return self.new_alias.alias not in known_collision_aliases
@classmethod
def from_dict(cls, collision_dict: dict) -> "Collision":
return cls(
Alias(**collision_dict["existing_alias"]),
Alias(**collision_dict["new_alias"]),
)
def to_dict(self) -> dict:
return {
"existing_alias": self.existing_alias.to_dict(),
"new_alias": self.new_alias.to_dict(),
}
def find_aliases_in_file(file: Path) -> list[Alias]:
matches = re.findall(
r"^[ \t]*alias (?:-[gs] )?([^ =]+)=['\"]?(.*?)['\"]?$",
file.read_text(),
re.MULTILINE,
)
return [Alias(match[0], match[1], file) for match in matches]
def load_known_collisions(collision_file: Path) -> list[Collision]:
collision_list = json.loads(collision_file.read_text())
return [Collision.from_dict(collision_dict) for collision_dict in collision_list]
def find_all_aliases(path: Path) -> list:
aliases = [find_aliases_in_file(file) for file in path.rglob("*.zsh")]
return list(itertools.chain(*aliases))
def check_for_duplicates(aliases: list[Alias]) -> list[Collision]:
elements = {}
collisions = []
for alias in aliases:
if alias.alias in elements:
existing = elements[alias.alias]
collisions.append(Collision(existing, alias))
else:
elements[alias.alias] = alias
return collisions
def print_collisions(collisions: dict[Alias, Alias]) -> None:
if collisions:
print(f"Found {len(collisions)} alias collisions:\n")
for collision in collisions:
print(
ERROR_MESSAGE_TEMPLATE
% (
f"{collision.new_alias.alias}={collision.new_alias.value}",
collision.new_alias.module.name,
f"{collision.existing_alias.alias}={collision.existing_alias.value}",
collision.existing_alias.module.name,
)
)
print("\nConsider renaming your aliases.")
else:
print("Found no collisions")
def check_for_new_collisions(
known_collisions: Path, collisions: list[Collision]
) -> list[Collision]:
known_collisions = load_known_collisions(known_collisions)
known_collision_aliases = [
collision.new_alias.alias for collision in known_collisions
]
return [
collision
for collision in collisions
if collision.is_new_collision(known_collision_aliases)
]
def main() -> int:
"""main"""
args = parse_arguments()
aliases = find_all_aliases(args.folder)
collisions = check_for_duplicates(aliases)
if args.known_collisions is not None:
new_collisions = check_for_new_collisions(args.known_collisions, collisions)
print_collisions(new_collisions)
return -1 if new_collisions else 0
args.known_collisions_output_path.write_text(
json.dumps([collision.to_dict() for collision in collisions])
)
return 0
if __name__ == "__main__":
sys.exit(main())
@@ -0,0 +1,2 @@
pyfakefs
pytest
@@ -0,0 +1,166 @@
from pathlib import Path
from pyfakefs.fake_filesystem import FakeFilesystem
import pytest
from check_alias_collision import (
dir_path,
find_all_aliases,
find_aliases_in_file,
check_for_duplicates,
Alias,
Collision,
load_known_collisions,
)
THREE_ALIASES = """
alias g='git'
alias ga='git add'
alias gaa='git add --all'
"""
CONDITIONAL_ALIAS = """
is-at-least 2.8 "$git_version" \
&& alias gfa='git fetch --all --prune --jobs=10' \
|| alias gfa='git fetch --all --prune'
"""
ONE_KNOWN_COLLISION = """
[
{
"existing_alias": {
"alias": "gcd",
"value": "git checkout $(git_develop_branch)",
"module": "plugins/git/git.plugin.zsh"
},
"new_alias": {
"alias": "gcd",
"value": "git checkout $(git config gitflow.branch.develop)",
"module": "plugins/git-flow/git-flow.plugin.zsh"
}
}
]
"""
def test_dir_path__is_dir__input_path(fs: FakeFilesystem) -> None:
fs.create_dir("test")
assert Path("test") == dir_path("test")
def test_dir_path__is_file__raise_not_a_directory_error(fs: FakeFilesystem) -> None:
fs.create_file("test")
with pytest.raises(NotADirectoryError):
dir_path("test")
def test_dir_path__does_not_exist__raise_not_a_directory_error(
fs: FakeFilesystem,
) -> None:
with pytest.raises(NotADirectoryError):
dir_path("test")
def test_find_all_aliases__empty_folder_should_return_empty_list(
fs: FakeFilesystem,
) -> None:
fs.create_dir("test")
result = find_all_aliases(Path("test"))
assert [] == result
def test_find_aliases_in_file__empty_text_should_return_empty_list(
fs: FakeFilesystem,
) -> None:
fs.create_file("empty.zsh")
result = find_aliases_in_file(Path("empty.zsh"))
assert [] == result
def test_find_aliases_in_file__one_alias_should_find_one(fs: FakeFilesystem) -> None:
fs.create_file("one.zsh", contents="alias g='git'")
result = find_aliases_in_file(Path("one.zsh"))
assert [Alias("g", "git", Path("one.zsh"))] == result
def test_find_aliases_in_file__three_aliases_should_find_three(
fs: FakeFilesystem,
) -> None:
fs.create_file("three.zsh", contents=THREE_ALIASES)
result = find_aliases_in_file(Path("three.zsh"))
assert [
Alias("g", "git", Path("three.zsh")),
Alias("ga", "git add", Path("three.zsh")),
Alias("gaa", "git add --all", Path("three.zsh")),
] == result
def test_find_aliases_in_file__one_conditional_alias_should_find_none(
fs: FakeFilesystem,
) -> None:
fs.create_file("conditional.zsh", contents=CONDITIONAL_ALIAS)
result = find_aliases_in_file(Path("conditional.zsh"))
assert [] == result
def test_check_for_duplicates__no_duplicates_should_return_empty_dict() -> None:
result = check_for_duplicates(
[
Alias("g", "git", Path("git.zsh")),
Alias("ga", "git add", Path("git.zsh")),
Alias("gaa", "git add --all", Path("git.zsh")),
]
)
assert result == []
def test_check_for_duplicates__duplicates_should_have_one_collision() -> None:
result = check_for_duplicates(
[
Alias("gc", "git commit", Path("git.zsh")),
Alias("gc", "git clone", Path("git.zsh")),
]
)
assert result == [
Collision(
Alias("gc", "git commit", Path("git.zsh")),
Alias("gc", "git clone", Path("git.zsh")),
)
]
def test_is_new_collision__new_alias_not_in_known_collisions__should_return_true() -> (
None
):
known_collisions = ["gc", "gd"]
new_alias = Alias("ga", "git add", Path("git.zsh"))
collision = Collision(Alias("gd", "git diff", Path("git.zsh")), new_alias)
assert collision.is_new_collision(known_collisions) is True
def test_is_new_collision__new_alias_in_known_collisions__should_return_false() -> None:
known_collisions = ["gc", "gd", "ga"]
new_alias = Alias("ga", "git add", Path("git.zsh"))
collision = Collision(Alias("gd", "git diff", Path("git.zsh")), new_alias)
assert collision.is_new_collision(known_collisions) is False
def test_load_known_collisions__empty_file__should_return_empty_list(
fs: FakeFilesystem,
) -> None:
empty_list = Path("empty.json")
fs.create_file(empty_list, contents="[]")
result = load_known_collisions(empty_list)
assert [] == result
def test_load_known_collisions__one_collision__should_return_one_collision(
fs: FakeFilesystem,
) -> None:
known_collisions_file = Path("known_collisions.json")
fs.create_file(known_collisions_file, contents=ONE_KNOWN_COLLISION)
result = load_known_collisions(known_collisions_file)
assert 1 == len(result)
assert "gcd" == result[0].existing_alias.alias
+28
View File
@@ -41,3 +41,31 @@ jobs:
./themes/*.zsh-theme; do
zsh -n "$file" || return 1
done
collisions:
name: Check alias collisions
runs-on: ubuntu-latest
steps:
- name: Set up git repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Set up Python
uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
with:
python-version: '3.14'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r .github/workflows/alias_collision/requirements.txt
- name: Run unit tests
run: |
cd .github/workflows/alias_collision/
python -m pytest
- name: Checkout target branch
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
path: ohmyzsh-target-branch
ref: master
- name: Check for alias collisions on target branch
run: python .github/workflows/alias_collision/check_alias_collision.py ohmyzsh-target-branch/plugins --known-collisions-output-path known_alias_collisions.json
- name: Compare known collisions to new collisions on source branch
run: python .github/workflows/alias_collision/check_alias_collision.py plugins --known-collisions known_alias_collisions.json
+14 -8
View File
@@ -295,17 +295,23 @@ function _omz::plugin::disable {
fi
# Remove plugins substitution awk script
# A match consumes the whitespace around the plugin, so adjacent plugins
# can't match in the same pass: repeat until the line stops changing.
local awk_subst_plugins="\
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
do {
prev = \$0
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(/[ \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})\)/, \")\") # with BOL and closing parenthesis
gsub(/\((${(j:|:)dis_plugins})$/, \"(\") # with opening parenthesis and EOL
gsub(/\((${(j:|:)dis_plugins})[ \t]+/, \"(\") # with parenthesis before and spaces after
gsub(/[ \t]+(${(j:|:)dis_plugins})\)/, \")\") # with spaces before or parenthesis after
gsub(/\((${(j:|:)dis_plugins})\)/, \"()\") # with only parentheses
gsub(/^(${(j:|:)dis_plugins})\)/, \")\") # with BOL and closing parenthesis
gsub(/\((${(j:|:)dis_plugins})$/, \"(\") # with opening parenthesis and EOL
} while (\$0 != prev)
"
# Disable plugins awk script
+27
View File
@@ -16,6 +16,10 @@
# - doitclient (for SSH) http://www.chiark.greenend.org.uk/~sgtatham/doit/
# - win32yank (Windows)
# - tmux (if $TMUX is set)
# - OSC 52 (when no clipboard tool is available, e.g. over SSH or in a container)
#
# Set ZSH_CLIPBOARD_OSC52 to "always" to copy through OSC 52 even if a
# clipboard tool is available, or to "never" to disable the fallback.
#
# Defines two functions, clipcopy and clippaste, based on the detected platform.
##
@@ -48,6 +52,22 @@
# # Paste to a file
# clippaste > file.txt
#
function _has_osc52_clipboard() {
[[ -n "${TTY:-}" ]] && [[ -w "${TTY}" ]] && (( ${+commands[base64]} ))
}
function _clipcopy_osc52() {
emulate -L zsh
local content
content=$(cat "${1:-/dev/stdin}" | base64 | tr -d '\n') || return 1
print -rn -- $'\e]52;c;'"${content}"$'\e\\' > /dev/tty
}
function _clippaste_osc52() {
print 'clippaste: OSC 52 is write-only and no other clipboard tool was found' >&2
return 1
}
function detect-clipboard() {
emulate -L zsh
@@ -87,6 +107,9 @@ function detect-clipboard() {
elif [ -n "${TMUX:-}" ] && (( ${+commands[tmux]} )); then
function clipcopy() { tmux load-buffer -w "${1:--}"; }
function clippaste() { tmux save-buffer -; }
elif [[ "${ZSH_CLIPBOARD_OSC52:-}" != never ]] && _has_osc52_clipboard; then
function clipcopy() { _clipcopy_osc52 "$@"; }
function clippaste() { _clippaste_osc52; }
else
function _retry_clipboard_detection_or_fail() {
local clipcmd="${1}"; shift
@@ -101,6 +124,10 @@ function detect-clipboard() {
function clippaste() { _retry_clipboard_detection_or_fail clippaste "$@"; }
return 1
fi
if [[ "${ZSH_CLIPBOARD_OSC52:-}" == always ]] && _has_osc52_clipboard; then
function clipcopy() { _clipcopy_osc52 "$@"; }
fi
}
function clipcopy clippaste {
+11
View File
@@ -2,6 +2,8 @@
# P.C. Shyamshankar <sykora@lucentbeing.com>
# Copied from https://github.com/sykora/etc/blob/master/zsh/functions/spectrum/
autoload -Uz is-at-least
typeset -AHg FX FG BG
FX=(
@@ -18,7 +20,16 @@ FX=(
() {
setopt localoptions noksharrays
local -a codes fg bg
local code
codes=({000..255})
# ${a:^b} array zipping needs zsh 5.0.6
if ! is-at-least 5.0.6; then
for code in $codes; do
FG[$code]="%{"$'\e'"[38;5;${code}m%}"
BG[$code]="%{"$'\e'"[48;5;${code}m%}"
done
return
fi
fg=( "%{"$'\e'"[38;5;"${^codes}"m%}" )
bg=( "%{"$'\e'"[48;5;"${^codes}"m%}" )
FG=( ${codes:^fg} )
+43 -8
View File
@@ -7,16 +7,20 @@ run_awk() {
(( ! 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
do {
prev = \$0
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(/[ \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})\)/, \")\") # with BOL and closing parenthesis
gsub(/\((${(j:|:)dis_plugins})$/, \"(\") # with opening parenthesis and EOL
gsub(/\((${(j:|:)dis_plugins})[ \t]+/, \"(\") # with parenthesis before and spaces after
gsub(/[ \t]+(${(j:|:)dis_plugins})\)/, \")\") # with spaces before or parenthesis after
gsub(/\((${(j:|:)dis_plugins})\)/, \"()\") # with only parentheses
gsub(/^(${(j:|:)dis_plugins})\)/, \")\") # with BOL and closing parenthesis
gsub(/\((${(j:|:)dis_plugins})$/, \"(\") # with opening parenthesis and EOL
} while (\$0 != prev)
"
# Disable plugins awk script
local awk_script="
@@ -167,3 +171,34 @@ z)" \
"plugins=(
git
)"
run_awk_and_test \
"it should delete two adjacent plugins among others in oneline format" \
"docker kubectl" \
"plugins=(git docker kubectl npm)" \
"plugins=(git npm)"
run_awk_and_test \
"it should delete three adjacent plugins among others in oneline format" \
"docker kubectl aws" \
"plugins=(git docker kubectl aws npm)" \
"plugins=(git npm)"
run_awk_and_test \
"it should delete every plugin of a long oneline list" \
"git docker kubectl aws npm z" \
"plugins=(git docker kubectl aws npm z)" \
"plugins=()"
run_awk_and_test \
"it should delete adjacent plugins sharing a line in multiline format" \
"docker kubectl aws" \
"plugins=(
git
docker kubectl aws
npm
)" \
"plugins=(
git
npm
)"
+1 -1
View File
@@ -59,7 +59,7 @@ ensures the `bdr` alias runs without warnings.
| `bsra` | `bsr --all` | Run all stopped services. |
| `bu` | `brew update` | Update brew and all installed formulae. |
| `bubo` | `brew update && brew outdated` | Update Homebrew data, then list outdated formulae and casks. |
| `bubu` | `bubo && bup` | Do the last two operations above. |
| `bubu` | `bu && bup` | Update Homebrew data, then upgrade outdated, unpinned brews. |
| `bugbc` | `brew upgrade --greedy && brew cleanup` | Upgrade outdated formulae and casks (greedy), then run cleanup. |
| `bup` | `brew upgrade` | Upgrade outdated, unpinned brews. |
| `buz` | `brew uninstall --zap` | Remove all files associated with a cask. |
+1 -1
View File
@@ -75,7 +75,7 @@ alias bsr='brew services run'
alias bsra='bsr --all'
alias bu='brew update'
alias bubo='brew update && brew outdated'
alias bubu='bubo && bup'
alias bubu='bu && bup'
alias bubug='bubo && bugbc'
alias bugbc='brew upgrade --greedy && brew cleanup'
alias bup='brew upgrade'
+11 -3
View File
@@ -1,6 +1,6 @@
# conda plugin
The conda plugin provides [aliases](#aliases) for `conda`, usually installed via [anaconda](https://www.anaconda.com/) or [miniconda](https://docs.conda.io/en/latest/miniconda.html).
The conda plugin provides [aliases](#aliases) and [completion](#completion) for `conda`, usually installed via [anaconda](https://www.anaconda.com/) or [miniconda](https://docs.conda.io/en/latest/miniconda.html).
To use it, add `conda` to the plugins array in your zshrc file:
@@ -28,10 +28,18 @@ plugins=(... conda)
| `cnle` | `conda list --export` | Export the list of installed packages in the current environment |
| `cnles` | `conda list --explicit > spec-file.txt` | Export the list of installed packages in the current environment to a spec file |
| `cnr` | `conda remove` | Remove given package |
| `cnrn` | `conda remove -y -all -n` | Remove all packages in the specified environment |
| `cnrp` | `conda remove -y -all -p` | Remove all packages in the specified prefix |
| `cnrn` | `conda remove -y --all -n` | Remove all packages in the specified environment |
| `cnrp` | `conda remove -y --all -p` | Remove all packages in the specified prefix |
| `cnry` | `conda remove -y` | Remove given package without confirmation |
| `cnsr` | `conda search` | Search conda repositories for package |
| `cnu` | `conda update` | Update conda package manager |
| `cnua` | `conda update --all` | Update all installed packages |
| `cnuc` | `conda update conda` | Update conda package manager |
## Completion
Tab completion is available for the following commands, using the environment list conda keeps in
`~/.conda/environments.txt`:
- `cna`: completes environment names for `conda activate`
- `cnrn`: completes environment names for `conda remove -y --all -n`
+21 -2
View File
@@ -1,4 +1,7 @@
alias cna='conda activate'
unalias cna cnrn 2>/dev/null
cna() { conda activate "$@"; }
cnrn() { conda remove -y --all -n "$@"; }
alias cnab='conda activate base'
alias cncf='conda env create -f'
alias cncn='conda create -y -n'
@@ -14,10 +17,26 @@ alias cnl='conda list'
alias cnle='conda list --export'
alias cnles='conda list --explicit > spec-file.txt'
alias cnr='conda remove'
alias cnrn='conda remove -y --all -n'
alias cnrp='conda remove -y --all -p'
alias cnry='conda remove -y'
alias cnsr='conda search'
alias cnu='conda update'
alias cnua='conda update --all'
alias cnuc='conda update conda'
_omz_conda_envs() {
emulate -L zsh -o extended_glob
local envs_file="$HOME/.conda/environments.txt"
[[ -r "$envs_file" ]] || return 1
# Each line is an env prefix; named envs live under <dir>/envs/<name>.
# The root prefix (base) and envs created with -p have no name and are skipped.
local -aU envs
envs=(${(f)"$(<$envs_file)"})
envs=(${${(M)envs:#*/envs/[^/]##}:t})
(( ${#envs} )) && compadd -Q -a envs
}
if (( $+functions[compdef] )); then
compdef _omz_conda_envs cna cnrn
fi
+2 -2
View File
@@ -263,9 +263,9 @@ _dotenv_check_syntax() {
local filename="$1"
if (( $# == 2 )); then
printf '%s' "$2" | zsh -fn /dev/stdin
printf '%s' "$2" | command zsh -fn /dev/stdin
else
zsh -fn -- "$filename"
command zsh -fn -- "$filename"
fi || {
echo "dotenv: error when sourcing '$filename' file" >&2
return 1
+3
View File
@@ -45,9 +45,12 @@ plugins=(... extract)
| `tar.lrz` | Tarball with lrzip compression |
| `tar.lz` | Tarball with lzip compression |
| `tar.lz4` | Tarball with lz4 compression |
| `tar.lzma` | Tarball with lzma compression |
| `tar.xz` | Tarball with lzma2 compression |
| `tar.zma` | Tarball with lzma compression |
| `tar.zst` | Tarball with zstd compression |
| `tar.Z` | Tarball with compress (LZW) compression |
| `taz` | Tarball with compress (LZW) compression |
| `tbz` | Tarball with bzip compression |
| `tbz2` | Tarball with bzip2 compression |
| `tgz` | Tarball with gzip compression |
+1
View File
@@ -31,6 +31,7 @@ local -a exts=(
tar.lrz
tar.lz
tar.lz4
tar.lzma
tar.xz
tar.zma
tar.zst
+6 -1
View File
@@ -88,7 +88,7 @@ EOF
tar --xz --help &> /dev/null \
&& tar --xz -xvf "$full_path" \
|| xzcat "$full_path" | tar xvf - } ;;
(*.tar.zma|*.tlz)
(*.tar.lzma|*.tar.zma|*.tlz)
tar --lzma --help &> /dev/null \
&& tar --lzma -xvf "$full_path" \
|| lzcat "$full_path" | tar xvf - ;;
@@ -97,6 +97,11 @@ EOF
&& tar --zstd -xvf "$full_path" \
|| zstdcat "$full_path" | tar xvf - ;;
(*.tar) tar xvf "$full_path" ;;
# `tar cf - dir | compress > dir.tar.Z`: the plain `.Z` arm below only decompresses the
# stream back to `dir.tar`, so the combined form has to untar it in one step. `.taz` is the
# historic name for the same file, next to `.tgz`/`.tbz`/`.tlz`/`.txz`/`.tzst`. Matching is
# on the lowercased name, so `.tar.Z` lands here too.
(*.tar.z|*.taz) uncompress -c "$full_path" | tar xvf - ;;
(*.tar.lz) (( $+commands[lzip] )) && tar xvf "$full_path" ;;
(*.tar.lz4) lz4 -c -d "$full_path" | tar xvf - ;;
(*.tar.lrz) (( $+commands[lrzuntar] )) && lrzuntar "$full_path" ;;
+5 -1
View File
@@ -167,7 +167,11 @@ check_deb_multiple() {
printf '\037\235\220\150\312\260\141\363\106\001' \
> "$test_dir/fixture.Z"
for extension in lzma Z; do
cp "$test_dir/plain" "$test_dir/sample.txt"
tar -cf "$test_dir/fixture.tar" -C "$test_dir" sample.txt
lzma -c "$test_dir/fixture.tar" > "$test_dir/fixture.tar.lzma"
for extension in lzma Z tar.lzma; do
for mode in default target remove; do
check_extract "$extension" "$mode"
done
+18
View File
@@ -0,0 +1,18 @@
# Fizzy CLI plugin
This plugin adds completion for the [Fizzy CLI (fizzy)](https://github.com/basecamp/fizzy-cli).
To use it, add `fizzy` to the plugins array in your zshrc file:
```zsh
plugins=(... fizzy)
```
This plugin does not add any aliases.
## Cache
This plugin caches the completion script and automatically updates it when the
plugin is loaded, which is usually when you start a new terminal emulator.
The cache is stored at `$ZSH_CACHE_DIR/completions/_fizzy`.
+24
View File
@@ -0,0 +1,24 @@
# Autocompletion for the Fizzy CLI (fizzy).
if (( ! $+commands[fizzy] )); then
return
fi
# If the completion isn't registered yet, autoload it and bind it to `fizzy`.
# Otherwise, compinit will have already done that from the cache.
if [[ -z ${_comps[fizzy]-} ]]; then
typeset -g -A _comps
autoload -Uz _fizzy
_comps[fizzy]=_fizzy
fi
zmodload -F zsh/files b:zf_mv || return
() {
local cache_file="$ZSH_CACHE_DIR/completions/_fizzy"
local temp_file
temp_file=$(mktemp "$ZSH_CACHE_DIR/completions/._fizzy.XXXXXXXX") || return
if command fizzy completion zsh >| "$temp_file" && [[ -s "$temp_file" ]] &&
zf_mv -f -- "$temp_file" "$cache_file"; then
return
fi
rm -f -- "$temp_file"
} &|
+2
View File
@@ -22,6 +22,7 @@ plugins=(... golang)
| gofx | `go fix` | Update packages to use a new API |
| gog | `go get` | Downloads packages and then installs them to $GOPATH |
| goga | `go get ./...` | Installs all dependencies in current directory, recursively |
| goge | `go generate` | Generate Go files by processing source |
| goi | `go install` | Compiles and installs packages to $GOPATH |
| gol | `go list` | Lists Go packages |
| gom | `go mod` | Access to operations on modules |
@@ -54,3 +55,4 @@ changes your prompt to:
```
~/go/project$ ▋ 1.22.3
```
+1
View File
@@ -19,6 +19,7 @@ alias gofa='go fmt ./...'
alias gofx='go fix'
alias gog='go get'
alias goga='go get ./...'
alias goge='go generate'
alias goi='go install'
alias gol='go list'
alias gom='go mod'
+1
View File
@@ -44,6 +44,7 @@ plugins=(... jj)
| jjgi | `jj git init` |
| jjgp | `jj git push` |
| jjgpa | `jj git push --all` |
| jjgpb | `jj git push --bookmark` |
| jjgpd | `jj git push --deleted` |
| jjgpt | `jj git push --tracked` |
| jjgrl | `jj git remote list` |
+1
View File
@@ -70,6 +70,7 @@ alias jjgfa='jj git fetch --all-remotes'
alias jjgi='jj git init'
alias jjgp='jj git push'
alias jjgpa='jj git push --all'
alias jjgpb='jj git push --bookmark'
alias jjgpd='jj git push --deleted'
alias jjgpt='jj git push --tracked'
alias jjgrl='jj git remote list'
+1
View File
@@ -60,6 +60,7 @@ plugins=(... kubectl)
| | | **Namespace management** |
| kgns | `kubectl get namespaces` | List the current namespaces in a cluster |
| kcn | `kubectl config set-context --current --namespace` | Change current namespace |
| kcgetns | `kubectl config view --minify -o jsonpath={.contexts[0].context.namespace}` | Get the current context's namespace |
| kens | `kubectl edit namespace` | Edit namespace resource from the default editor |
| kdns | `kubectl describe namespace` | Describe namespace resource in detail |
| kdelns | `kubectl delete namespace` | Delete the namespace. WARNING! This deletes everything in the namespace |
+2 -1
View File
@@ -31,7 +31,7 @@ alias kapk='kubectl apply -k'
# Drop into an interactive terminal on a container
alias keti='kubectl exec -t -i'
# Manage configuration quickly to switch contexts between local, dev ad staging.
# Manage configuration quickly to switch contexts between local, dev and staging.
alias kcuc='kubectl config use-context'
alias kcsc='kubectl config set-context'
alias kcdc='kubectl config delete-context'
@@ -83,6 +83,7 @@ alias kens='kubectl edit namespace'
alias kdns='kubectl describe namespace'
alias kdelns='kubectl delete namespace'
alias kcn='kubectl config set-context --current --namespace'
alias kcgetns="kubectl config view --minify -o 'jsonpath={.contexts[0].context.namespace}'"
# ConfigMap management
alias kgcm='kubectl get configmaps'
+15 -12
View File
@@ -72,11 +72,6 @@ EOF
return 0
;;
shuf|shuff|shuffle)
# The shuffle property of current playlist can't be changed in iTunes 12,
# so this workaround uses AppleScript to simulate user input instead.
# Defaults to toggling when no options are given.
# The toggle option depends on the shuffle button being visible in the Now playing area.
# On and off use the menu bar items.
local state=$1
if [[ -n "$state" && "$state" != (on|off|toggle) ]]; then
@@ -85,16 +80,24 @@ EOF
fi
case "$state" in
on|off)
# Inspired by: https://stackoverflow.com/a/14675583
osascript >/dev/null 2>&1 <<EOF
tell application "System Events" to perform action "AXPress" of (menu item "${state}" of menu "Shuffle" of menu item "Shuffle" of menu "Controls" of menu bar item "Controls" of menu bar 1 of application process "iTunes" )
EOF
# Inspired by: https://stackoverflow.com/a/43942013/2396771
on)
osascript -e "tell application \"$APP_NAME\" to set shuffle enabled to true";
return 0
;;
off)
osascript -e "tell application \"$APP_NAME\" to set shuffle enabled to false";
return 0
;;
toggle|*)
osascript >/dev/null 2>&1 <<EOF
tell application "System Events" to perform action "AXPress" of (button 2 of process "iTunes"'s window "iTunes"'s scroll area 1)
osascript 2>/dev/null <<EOF
tell application "$APP_NAME"
if shuffle enabled then
set shuffle enabled to false
else
set shuffle enabled to true
end
end tell
EOF
return 0
;;
+1 -1
View File
@@ -15,7 +15,7 @@ plugins=(... pre-commit)
| Alias | Command | Description |
| ----- | ------------------------------------------------------ | --------------------------------------------- |
| prc | `prek` or `pre-commit` | The pre-commit command |
| prcau | `prek auto-update` or `pre-commit autoupdate` | Update hooks automatically |
| prcau | `prek autoupdate` or `pre-commit autoupdate` | Update hooks automatically |
| prcr | `prek run` or `pre-commit run` | The pre-commit run command |
| prcra | `prek run --all-files` or `pre-commit run --all-files` | Run pre-commit hooks on all files |
| prcrf | `prek run --files` or `pre-commit run --files` | Run pre-commit hooks on a given list of files |
+1 -3
View File
@@ -1,15 +1,13 @@
# Aliases for pre-commit (uses prek if available, else pre-commit)
if command -v prek &> /dev/null; then
_prc_cmd='prek'
_prc_autoupdate='auto-update'
else
_prc_cmd='pre-commit'
_prc_autoupdate='autoupdate'
fi
alias prc="$_prc_cmd"
alias prcau="$_prc_cmd $_prc_autoupdate"
alias prcau="$_prc_cmd autoupdate"
alias prcr="$_prc_cmd run"
alias prcra="$_prc_cmd run --all-files"
+9
View File
@@ -46,6 +46,7 @@ You can set these variables in your `.zshrc` file, before Oh My Zsh is sourced.
For example:
```sh
PYTHON_AUTO_VRUN=true
PYTHON_VENV_NAME=".venv"
PYTHON_VENV_NAMES=($PYTHON_VENV_NAME venv)
...
@@ -54,6 +55,14 @@ source "$ZSH/oh-my-zsh.sh"
```
## `$PYTHON_AUTO_VRUN`
**Default**: `false`.
Enable automatic activation of virtual environments when entering a directory containing
`<venv-name>/bin/activate`, and automatically deactivate it when navigating out of it.
Set to `true` to enable this feature.
## `$PYTHON_VENV_NAME`
**Default**: `venv`.
+8
View File
@@ -12,6 +12,14 @@ plugins=(... terraform)
## Requirements
- [Terraform](https://terraform.io/)
- [terraform-docs](https://terraform-docs.io/) (optional, for completion)
## terraform-docs completion
If `terraform-docs` is installed, this plugin also enables its completion.
The completion script is generated from the installed version and cached in
`$ZSH_CACHE_DIR/completions/_terraform-docs`. It is refreshed in the background
each time the plugin loads, so completion stays in sync with the installed CLI.
## Aliases
+20
View File
@@ -39,3 +39,23 @@ alias tfsh='terraform show'
alias tfw='terraform workspace'
alias tfwl='terraform workspace list'
alias tfws='terraform workspace select'
if (( $+commands[terraform-docs] )); then
# If the completion file doesn't exist yet, compinit hasn't registered it.
if [[ ! -f "$ZSH_CACHE_DIR/completions/_terraform-docs" ]]; then
typeset -g -A _comps
autoload -Uz _terraform-docs
_comps[terraform-docs]=_terraform-docs
fi
zmodload -F zsh/files b:zf_mv
() {
local completions
completions=$(command terraform-docs completion zsh) || return
[[ -n "$completions" ]] || return
local TMPPREFIX="$ZSH_CACHE_DIR/completions/._terraform-docs"
zf_mv -f -- =(print -r -- "$completions") \
"$ZSH_CACHE_DIR/completions/_terraform-docs"
} &|
fi
+2
View File
@@ -4,7 +4,9 @@
To use it, add thefuck to the plugins array of your zshrc file:
```zsh
plugins=(... thefuck)
```
## Usage
Press `ESC` twice to correct previous console command.
+43
View File
@@ -0,0 +1,43 @@
# zellij
This plugin provides aliases, functions, and completions for [zellij](https://zellij.dev/),
the terminal workspace (multiplexer). To use it, add `zellij` to the plugins array in your
zshrc file.
```zsh
plugins=(... zellij)
```
## Aliases
| Alias | Command | Description |
| ------ | ---------------------------- | --------------------------- |
| `zj` | `zellij` | Zellij command |
| `zjl` | `zellij list-sessions` | List sessions |
| `zjs` | `zellij -s` | Start a named session |
| `zjda` | `zellij delete-all-sessions` | Delete all sessions |
| `zjka` | `zellij kill-all-sessions` | Kill all sessions |
| `zjr` | `zellij run` | Run a command in a pane |
| `zjad` | `zellij action detach` | Detach from current session |
## Functions
| Function | Command | Description |
| -------- | -------------------------------- | -------------------------------- |
| `zja` | `zellij attach` | Attach to a session |
| `zjd` | `zellij delete-session` | Delete a session (exited only) |
| `zjdf` | `zellij delete-session --force` | Force-delete any session |
| `zjk` | `zellij kill-session` | Kill a session |
| `zjas` | `zellij action switch-session` | Switch to a session |
| `zjrf` | `zellij run --floating --` | Run a command in a floating pane |
| `zje` | `zellij edit` | Edit a file in a pane |
## Completions
This plugin caches the zellij completion script. On first load the cache is generated
synchronously; subsequent updates (when the `zellij` binary is newer than the cache) happen in
the background. The cache is written to a temporary file and moved into place, so a
partially written file is never loaded.
Session-aware completions are provided for `zja`, `zjdf` and `zjas` (all sessions), `zjk`
(running sessions) and `zjd` (exited sessions).
+77
View File
@@ -0,0 +1,77 @@
if (( ! $+commands[zellij] )); then
return
fi
# Aliases
alias zj='zellij'
alias zjl='zellij list-sessions'
alias zjs='zellij -s'
alias zjda='zellij delete-all-sessions'
alias zjka='zellij kill-all-sessions'
alias zjr='zellij run'
alias zjad='zellij action detach'
# Functions (with session-aware completion)
function zja { command zellij attach "$@"; }
function zjd { command zellij delete-session "$@"; }
function zjdf { command zellij delete-session --force "$@"; }
function zjk { command zellij kill-session "$@"; }
function zjas { command zellij action switch-session "$@"; }
# Convenience functions
function zjrf { command zellij run --floating -- "$@"; }
function zje { command zellij edit "$@"; }
# Completion cache: generate synchronously on first load, regenerate in the
# background when the zellij binary is newer than the cache. Write to a temp
# file in the same directory and rename it, so a partial file is never loaded.
_omz_zellij_gen_completion() {
local TMPPREFIX="$ZSH_CACHE_DIR/completions/._zellij"
zf_mv -f -- =( command zellij setup --generate-completion zsh 2>/dev/null ) "$ZSH_CACHE_DIR/completions/_zellij"
}
zmodload -F zsh/files b:zf_mv
if [[ ! -s "$ZSH_CACHE_DIR/completions/_zellij" ]]; then
_omz_zellij_gen_completion
elif [[ $commands[zellij] -nt "$ZSH_CACHE_DIR/completions/_zellij" ]]; then
_omz_zellij_gen_completion &|
fi
_omz_zellij_ls_raw() {
command zellij list-sessions --no-formatting 2>/dev/null || command zellij list-sessions 2>/dev/null
}
_omz_zellij_session_names() {
# Use --short if available (zellij >= 0.44), fall back to sed parsing
command zellij list-sessions --short --no-formatting 2>/dev/null \
|| _omz_zellij_ls_raw | LC_ALL=C sed -nE 's/^([^[:space:]]+).*/\1/p'
}
_omz_zellij_all_sessions() {
emulate -L zsh
local -a sessions
sessions=(${(f)"$(_omz_zellij_session_names)"})
(( ${#sessions} )) && compadd -Q -a sessions
}
_omz_zellij_running_sessions() {
emulate -L zsh
local -a sessions
sessions=(${(f)"$(_omz_zellij_ls_raw | LC_ALL=C sed -nE '/\(EXITED/!s/^([^[:space:]]+).*/\1/p')"})
(( ${#sessions} )) && compadd -Q -a sessions
}
_omz_zellij_exited_sessions() {
emulate -L zsh
local -a sessions
sessions=(${(f)"$(_omz_zellij_ls_raw | LC_ALL=C sed -nE '/\(EXITED/s/^([^[:space:]]+).*/\1/p')"})
(( ${#sessions} )) && compadd -Q -a sessions
}
if (( $+functions[compdef] )); then
autoload -Uz _zellij
compdef _zellij zellij
compdef _omz_zellij_all_sessions zja zjdf zjas
compdef _omz_zellij_running_sessions zjk
compdef _omz_zellij_exited_sessions zjd
fi
+2 -2
View File
@@ -160,13 +160,13 @@ function update_ohmyzsh() {
fi
if [[ "$update_mode" != background-alpha ]] \
&& LANG= ZSH="$ZSH" zsh -f "$ZSH/tools/upgrade.sh" -i -v $verbose_mode -c $cooldown_days; then
&& LANG= ZSH="$ZSH" command zsh -f "$ZSH/tools/upgrade.sh" -i -v $verbose_mode -c $cooldown_days; then
update_last_updated_file
return $?
fi
local exit_status error
if error=$(LANG= ZSH="$ZSH" zsh -f "$ZSH/tools/upgrade.sh" -i -v silent -c $cooldown_days 2>&1); then
if error=$(LANG= ZSH="$ZSH" command zsh -f "$ZSH/tools/upgrade.sh" -i -v silent -c $cooldown_days 2>&1); then
update_last_updated_file 0 "Update successful"
else
exit_status=$?
+34 -5
View File
@@ -23,18 +23,47 @@ fi
if [ -e ~/.zshrc ]; then
ZSHRC_SAVE=~/.zshrc.omz-uninstalled-$(date +%Y-%m-%d_%H-%M-%S)
echo "Found ~/.zshrc -- Renaming to ${ZSHRC_SAVE}"
echo "Found ~/.zshrc -- Saving your current config to ${ZSHRC_SAVE}"
echo " (this file contains your current zsh configuration)"
mv ~/.zshrc "${ZSHRC_SAVE}"
fi
echo "Looking for original zsh config..."
ZSHRC_ORIG=~/.zshrc.pre-oh-my-zsh
if [ -e "$ZSHRC_ORIG" ]; then
echo "Found $ZSHRC_ORIG -- Restoring to ~/.zshrc"
mv "$ZSHRC_ORIG" ~/.zshrc
echo "Your original zsh config was restored."
ZSHRC_ORIG_DATE=$(date -r "$ZSHRC_ORIG" "+%Y-%m-%d" 2>/dev/null || date -d "@$(stat -c %Y "$ZSHRC_ORIG" 2>/dev/null)" "+%Y-%m-%d" 2>/dev/null || echo "unknown date")
echo "Found $ZSHRC_ORIG (last modified: ${ZSHRC_ORIG_DATE})"
echo "This is the zsh config that existed before Oh My Zsh was installed."
printf "Restore it as ~/.zshrc? [y/N] "
read -r restore_confirmation
if [ "$restore_confirmation" = y ] || [ "$restore_confirmation" = Y ]; then
mv "$ZSHRC_ORIG" ~/.zshrc
echo "Your original zsh config was restored to ~/.zshrc."
if [ -n "$ZSHRC_SAVE" ]; then
echo "Your Oh My Zsh config is saved at ${ZSHRC_SAVE} if you need it."
fi
else
echo "Skipping restore."
if [ -n "$ZSHRC_SAVE" ]; then
mv "${ZSHRC_SAVE}" ~/.zshrc
echo "Your current zsh config has been kept at ~/.zshrc."
echo "Your pre-OMZ backup is still at ${ZSHRC_ORIG} if you need it."
fi
fi
else
echo "No original zsh config found"
echo "No original zsh config found."
if [ -n "$ZSHRC_SAVE" ]; then
mv "${ZSHRC_SAVE}" ~/.zshrc
echo "Your current zsh config has been kept at ~/.zshrc."
fi
fi
# Warn if the active .zshrc still sources oh-my-zsh
if [ -f ~/.zshrc ] && command grep -q 'source.*oh-my-zsh\.sh' ~/.zshrc 2>/dev/null; then
echo ""
echo "Note: ~/.zshrc still contains a line sourcing oh-my-zsh.sh."
echo "Since oh-my-zsh has been removed, that line will cause an error"
echo "on every new shell. You may want to remove or comment it out."
fi
echo "Thanks for trying out Oh My Zsh. It's been uninstalled."