mirror of
https://github.com/robbyrussell/oh-my-zsh.git
synced 2026-11-29 11:53:03 +01:00
Compare commits
76
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e6e1a3ed97 | ||
|
|
7140fedbfa | ||
|
|
b5cb2fe952 | ||
|
|
49766a713a | ||
|
|
570bd64a56 | ||
|
|
ad203cc9c4 | ||
|
|
89ec2b437b | ||
|
|
3943d2f880 | ||
|
|
a449ed2c4e | ||
|
|
a32fc1d8ae | ||
|
|
1195c3a15e | ||
|
|
f68e5ec392 | ||
|
|
27506acc8a | ||
|
|
109270911c | ||
|
|
49a6348eac | ||
|
|
2aa7aed78b | ||
|
|
93b87c9c9a | ||
|
|
8a85fa2243 | ||
|
|
6c31a91a3e | ||
|
|
c52efbc756 | ||
|
|
e35c9b4b67 | ||
|
|
87aa1a9b89 | ||
|
|
ca0a63f0ee | ||
|
|
a7f4e49946 | ||
|
|
3ecde00d94 | ||
|
|
902761f897 | ||
|
|
c0140703a5 | ||
|
|
ffe93241cc | ||
|
|
ca82ba6831 | ||
|
|
e957b67eed | ||
|
|
6010fb6260 | ||
|
|
044bcbf82d | ||
|
|
2d03d8ac01 | ||
|
|
f5d571c66d | ||
|
|
cca3bdfbef | ||
|
|
59ff4d042e | ||
|
|
b509b1c6ed | ||
|
|
c483ff288d | ||
|
|
17a2b4c3a5 | ||
|
|
d2b7f557cc | ||
|
|
c61578a8d2 | ||
|
|
2100c630ba | ||
|
|
0eeaa529bb | ||
|
|
f888be4bec | ||
|
|
0650a25040 | ||
|
|
741642d7a9 | ||
|
|
84038f144d | ||
|
|
a208c3a27a | ||
|
|
b056a436fe | ||
|
|
964ddf789b | ||
|
|
fab613bd93 | ||
|
|
1e3960e6f9 | ||
|
|
cbf4a572ef | ||
|
|
55c9071ee7 | ||
|
|
083c339e06 | ||
|
|
417c814e2e | ||
|
|
7d34868725 | ||
|
|
106f9874a2 | ||
|
|
eb29cdb33a | ||
|
|
535aaaf924 | ||
|
|
05c2cb0b2b | ||
|
|
bd9fb5231b | ||
|
|
48feb570f7 | ||
|
|
42a4ccb1b1 | ||
|
|
2d833b453d | ||
|
|
d7aca552b3 | ||
|
|
9f9b28a13d | ||
|
|
361fb5c1ac | ||
|
|
3d9b557be3 | ||
|
|
60c9a7a839 | ||
|
|
d745fbf3bd | ||
|
|
277993de0a | ||
|
|
4d4cfc287e | ||
|
|
92bf53f1ae | ||
|
|
5c4bb4aec5 | ||
|
|
868da9cfd5 |
No files matched your search
@@ -46,7 +46,7 @@ dependencies:
|
|||||||
plugins/z:
|
plugins/z:
|
||||||
branch: master
|
branch: master
|
||||||
repo: agkozak/zsh-z
|
repo: agkozak/zsh-z
|
||||||
version: 102fb78036ed76feedf623907483691777a1d510
|
version: 7f8ff4df11b50a14e3666c7cd212baa399c9b92a
|
||||||
precopy: |
|
precopy: |
|
||||||
set -e
|
set -e
|
||||||
rm -r tests
|
rm -r tests
|
||||||
@@ -75,7 +75,7 @@ dependencies:
|
|||||||
plugins/zsh-syntax-highlighting:
|
plugins/zsh-syntax-highlighting:
|
||||||
repo: zsh-users/zsh-syntax-highlighting
|
repo: zsh-users/zsh-syntax-highlighting
|
||||||
branch: master
|
branch: master
|
||||||
version: 2fc57d63067c18b1100ecdbf684fa5baf49459d1
|
version: e6683f20e5c38d3e5447f45845d04ddda75d0f23
|
||||||
precopy: |
|
precopy: |
|
||||||
set -e
|
set -e
|
||||||
version=$(<.version)
|
version=$(<.version)
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ jobs:
|
|||||||
contents: write # this is needed to push commits and branches
|
contents: write # this is needed to push commits and branches
|
||||||
steps:
|
steps:
|
||||||
- name: Harden the runner (Audit all outbound calls)
|
- name: Harden the runner (Audit all outbound calls)
|
||||||
uses: step-security/harden-runner@e14015d583714f6e62063499dc959a02595150a1 # v2.21.1
|
uses: step-security/harden-runner@aebdcf6156ab6691adf63218240e476564a1ed4c # v2.23.0
|
||||||
with:
|
with:
|
||||||
egress-policy: audit
|
egress-policy: audit
|
||||||
|
|
||||||
@@ -26,12 +26,12 @@ jobs:
|
|||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
- name: Authenticate as @ohmyzsh
|
- name: Authenticate as @ohmyzsh
|
||||||
id: generate-token
|
id: generate-token
|
||||||
uses: actions/create-github-app-token@bcd2ba49218906704ab6c1aa796996da409d3eb1 # v3.2.0
|
uses: actions/create-github-app-token@f418cff399f7aef4c2f0ad47e25ca7a6abbdd6fc # v3.4.0
|
||||||
with:
|
with:
|
||||||
client-id: ${{ secrets.OHMYZSH_CLIENT_ID }}
|
client-id: ${{ secrets.OHMYZSH_CLIENT_ID }}
|
||||||
private-key: ${{ secrets.OHMYZSH_APP_PRIVATE_KEY }}
|
private-key: ${{ secrets.OHMYZSH_APP_PRIVATE_KEY }}
|
||||||
- name: Setup Python
|
- name: Setup Python
|
||||||
uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
|
uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7.1.0
|
||||||
with:
|
with:
|
||||||
python-version: "3.12"
|
python-version: "3.12"
|
||||||
cache: "pip"
|
cache: "pip"
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
certifi==2026.7.22
|
certifi==2026.10.23
|
||||||
charset-normalizer==3.5.1
|
charset-normalizer==3.5.2
|
||||||
idna==3.20
|
idna==3.20
|
||||||
PyYAML==6.0.3
|
PyYAML==6.0.3
|
||||||
requests==2.34.2
|
requests==2.34.2
|
||||||
semver==3.1.0
|
semver==3.1.2
|
||||||
urllib3==2.8.0
|
urllib3==2.8.0
|
||||||
@@ -26,7 +26,7 @@ jobs:
|
|||||||
- macos-latest
|
- macos-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Harden the runner (Audit all outbound calls)
|
- name: Harden the runner (Audit all outbound calls)
|
||||||
uses: step-security/harden-runner@e14015d583714f6e62063499dc959a02595150a1 # v2.21.1
|
uses: step-security/harden-runner@aebdcf6156ab6691adf63218240e476564a1ed4c # v2.23.0
|
||||||
with:
|
with:
|
||||||
egress-policy: audit
|
egress-policy: audit
|
||||||
|
|
||||||
@@ -47,7 +47,7 @@ jobs:
|
|||||||
- test
|
- test
|
||||||
steps:
|
steps:
|
||||||
- name: Harden the runner (Audit all outbound calls)
|
- name: Harden the runner (Audit all outbound calls)
|
||||||
uses: step-security/harden-runner@e14015d583714f6e62063499dc959a02595150a1 # v2.21.1
|
uses: step-security/harden-runner@aebdcf6156ab6691adf63218240e476564a1ed4c # v2.23.0
|
||||||
with:
|
with:
|
||||||
egress-policy: audit
|
egress-policy: audit
|
||||||
|
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ jobs:
|
|||||||
if: github.repository == 'ohmyzsh/ohmyzsh'
|
if: github.repository == 'ohmyzsh/ohmyzsh'
|
||||||
steps:
|
steps:
|
||||||
- name: Harden the runner (Audit all outbound calls)
|
- name: Harden the runner (Audit all outbound calls)
|
||||||
uses: step-security/harden-runner@e14015d583714f6e62063499dc959a02595150a1 # v2.21.1
|
uses: step-security/harden-runner@aebdcf6156ab6691adf63218240e476564a1ed4c # v2.23.0
|
||||||
with:
|
with:
|
||||||
egress-policy: audit
|
egress-policy: audit
|
||||||
|
|
||||||
|
|||||||
@@ -17,12 +17,12 @@ jobs:
|
|||||||
if: github.repository == 'ohmyzsh/ohmyzsh'
|
if: github.repository == 'ohmyzsh/ohmyzsh'
|
||||||
steps:
|
steps:
|
||||||
- name: Harden the runner (Audit all outbound calls)
|
- name: Harden the runner (Audit all outbound calls)
|
||||||
uses: step-security/harden-runner@e14015d583714f6e62063499dc959a02595150a1 # v2.21.1
|
uses: step-security/harden-runner@aebdcf6156ab6691adf63218240e476564a1ed4c # v2.23.0
|
||||||
with:
|
with:
|
||||||
egress-policy: audit
|
egress-policy: audit
|
||||||
- name: Authenticate as @ohmyzsh
|
- name: Authenticate as @ohmyzsh
|
||||||
id: generate-token
|
id: generate-token
|
||||||
uses: actions/create-github-app-token@bcd2ba49218906704ab6c1aa796996da409d3eb1 # v3.2.0
|
uses: actions/create-github-app-token@f418cff399f7aef4c2f0ad47e25ca7a6abbdd6fc # v3.4.0
|
||||||
with:
|
with:
|
||||||
client-id: ${{ secrets.OHMYZSH_CLIENT_ID }}
|
client-id: ${{ secrets.OHMYZSH_CLIENT_ID }}
|
||||||
private-key: ${{ secrets.OHMYZSH_APP_PRIVATE_KEY }}
|
private-key: ${{ secrets.OHMYZSH_APP_PRIVATE_KEY }}
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ jobs:
|
|||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Harden the runner (Audit all outbound calls)
|
- name: Harden the runner (Audit all outbound calls)
|
||||||
uses: step-security/harden-runner@e14015d583714f6e62063499dc959a02595150a1 # v2.21.1
|
uses: step-security/harden-runner@aebdcf6156ab6691adf63218240e476564a1ed4c # v2.23.0
|
||||||
with:
|
with:
|
||||||
egress-policy: audit
|
egress-policy: audit
|
||||||
|
|
||||||
@@ -46,20 +46,20 @@ jobs:
|
|||||||
persist-credentials: false
|
persist-credentials: false
|
||||||
|
|
||||||
- name: "Run analysis"
|
- name: "Run analysis"
|
||||||
uses: ossf/scorecard-action@2d1146689b8cda280b9bc96326124645441f03bc # v2.4.4
|
uses: ossf/scorecard-action@23f22cd43608bae7a1f1fa2603d7314dee9538a5 # v2.6.0
|
||||||
with:
|
with:
|
||||||
results_file: results.sarif
|
results_file: results.sarif
|
||||||
results_format: sarif
|
results_format: sarif
|
||||||
publish_results: true
|
publish_results: true
|
||||||
|
|
||||||
- name: "Upload artifact"
|
- name: "Upload artifact"
|
||||||
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
|
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
|
||||||
with:
|
with:
|
||||||
name: SARIF file
|
name: SARIF file
|
||||||
path: results.sarif
|
path: results.sarif
|
||||||
retention-days: 5
|
retention-days: 5
|
||||||
|
|
||||||
- name: "Upload to code-scanning"
|
- name: "Upload to code-scanning"
|
||||||
uses: github/codeql-action/upload-sarif@2892aa5e19bbd11bc0cff5427e3b750a04d9e3c2 # v4.38.2
|
uses: github/codeql-action/upload-sarif@33d7b85da1a04171e211befe2c739303b9a4c066 # v4.39.3
|
||||||
with:
|
with:
|
||||||
sarif_file: results.sarif
|
sarif_file: results.sarif
|
||||||
@@ -45,6 +45,7 @@ Twitter), and join us on [Discord](https://discord.gg/ohmyzsh).
|
|||||||
- [Using Plugins](#using-plugins)
|
- [Using Plugins](#using-plugins)
|
||||||
- [Themes](#themes)
|
- [Themes](#themes)
|
||||||
- [Selecting A Theme](#selecting-a-theme)
|
- [Selecting A Theme](#selecting-a-theme)
|
||||||
|
- [Shellsavers](#shellsavers)
|
||||||
- [FAQ](#faq)
|
- [FAQ](#faq)
|
||||||
- [Advanced Topics](#advanced-topics)
|
- [Advanced Topics](#advanced-topics)
|
||||||
- [Advanced Installation](#advanced-installation)
|
- [Advanced Installation](#advanced-installation)
|
||||||
@@ -241,6 +242,33 @@ If you only know which themes you don't like, you can add them similarly to an i
|
|||||||
ZSH_THEME_RANDOM_IGNORED=(pygmalion tjkirch_mod)
|
ZSH_THEME_RANDOM_IGNORED=(pygmalion tjkirch_mod)
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Shellsavers
|
||||||
|
|
||||||
|
Give your terminal a little downtime with `omz shellsaver`—our playful name for
|
||||||
|
terminal screensavers. The aquarium is the default; choose another scene to change the mood:
|
||||||
|
|
||||||
|
```zsh
|
||||||
|
omz shellsaver # A quiet aquarium full of sea shells
|
||||||
|
omz shellsaver logo # The updater's rainbow logo, bouncing around
|
||||||
|
omz shellsaver hermit # A slightly lost hermit crab
|
||||||
|
omz shellsaver party # A rainbow stage and a dancing crowd
|
||||||
|
```
|
||||||
|
|
||||||
|
Press any key or Ctrl-C to return to your shell. Screensavers run only when invoked
|
||||||
|
and restore the terminal when they exit. No plugin or configuration change is needed.
|
||||||
|
Use `omz help` to discover the command, and Tab to complete scene names and options.
|
||||||
|
|
||||||
|
```zsh
|
||||||
|
omz shellsaver aquarium --seconds 30 # Stop automatically after 30 seconds
|
||||||
|
omz shellsaver logo --mono # Use the terminal's foreground color
|
||||||
|
omz shellsaver --list # List scenes (aquarium is the default)
|
||||||
|
omz shellsaver --help # Show all scenes and options
|
||||||
|
```
|
||||||
|
|
||||||
|
Requires Zsh 5.8 or newer, `stty`, and an xterm-compatible terminal with alternate-screen
|
||||||
|
support. No additional animation package is required. `NO_COLOR` is respected.
|
||||||
|
A window of at least 49 columns by 18 rows is recommended.
|
||||||
|
|
||||||
### FAQ
|
### FAQ
|
||||||
|
|
||||||
If you have some more questions or issues, you might find a solution in our
|
If you have some more questions or issues, you might find a solution in our
|
||||||
@@ -524,6 +552,20 @@ omz update
|
|||||||
|
|
||||||
Magic! 🎉
|
Magic! 🎉
|
||||||
|
|
||||||
|
## Diagnostics
|
||||||
|
|
||||||
|
If something looks off (glitched characters, completions misbehaving), run:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
omz diagnose
|
||||||
|
```
|
||||||
|
|
||||||
|
It runs a few quick checks and tells you what to fix — for example, it will warn you when
|
||||||
|
your locale is not UTF-8, which is a common cause of duplicated characters at the prompt
|
||||||
|
(see the [FAQ](https://github.com/ohmyzsh/ohmyzsh/wiki/FAQ#i-see-duplicate-typed-characters-after-i-complete-a-command)).
|
||||||
|
|
||||||
|
For a full report suitable for attaching to a bug report, use `omz_diagnostic_dump`.
|
||||||
|
|
||||||
## Uninstalling Oh My Zsh
|
## Uninstalling Oh My Zsh
|
||||||
|
|
||||||
Oh My Zsh isn't for everyone. We'll miss you, but we want to make this an easy breakup.
|
Oh My Zsh isn't for everyone. We'll miss you, but we want to make this an easy breakup.
|
||||||
|
|||||||
+48
@@ -24,16 +24,30 @@ function _omz {
|
|||||||
local -a cmds subcmds
|
local -a cmds subcmds
|
||||||
cmds=(
|
cmds=(
|
||||||
'changelog:Print the changelog'
|
'changelog:Print the changelog'
|
||||||
|
'diagnose:Run configuration diagnostics'
|
||||||
'help:Usage information'
|
'help:Usage information'
|
||||||
'plugin:Manage plugins'
|
'plugin:Manage plugins'
|
||||||
'pr:Manage Oh My Zsh Pull Requests'
|
'pr:Manage Oh My Zsh Pull Requests'
|
||||||
'reload:Reload the current zsh session'
|
'reload:Reload the current zsh session'
|
||||||
|
'shellsaver:Launch a whimsical terminal screensaver'
|
||||||
'shop:Open the Oh My Zsh shop'
|
'shop:Open the Oh My Zsh shop'
|
||||||
'theme:Manage themes'
|
'theme:Manage themes'
|
||||||
'update:Update Oh My Zsh'
|
'update:Update Oh My Zsh'
|
||||||
'version:Show the version'
|
'version:Show the version'
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if [[ "$words[2]" == (screensaver|shellsaver) ]] && (( CURRENT > 2 )); then
|
||||||
|
_arguments \
|
||||||
|
'1:command:' \
|
||||||
|
'2::scene:(aquarium logo hermit party)' \
|
||||||
|
'--list[List available scenes]' \
|
||||||
|
'--mono[Use the default foreground color]' \
|
||||||
|
'--seconds[Exit after a number of seconds]:seconds:' \
|
||||||
|
'--snapshot[Print a plain-text still]::frame:' \
|
||||||
|
'--help[Show Shellsaver help]'
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
if (( CURRENT == 2 )); then
|
if (( CURRENT == 2 )); then
|
||||||
_describe 'command' cmds
|
_describe 'command' cmds
|
||||||
elif (( CURRENT == 3 )); then
|
elif (( CURRENT == 3 )); then
|
||||||
@@ -163,17 +177,42 @@ function _omz::log {
|
|||||||
|
|
||||||
## User-facing commands
|
## User-facing commands
|
||||||
|
|
||||||
|
function _omz::diagnose {
|
||||||
|
# Check the runtime locale: non-UTF-8 charsets are known to cause glitches
|
||||||
|
# such as duplicated characters at the prompt after completions.
|
||||||
|
# https://github.com/ohmyzsh/ohmyzsh/wiki/FAQ#i-see-duplicate-typed-characters-after-i-complete-a-command
|
||||||
|
#
|
||||||
|
# `lib/functions.zsh` loads the zsh/langinfo module at startup, so the
|
||||||
|
# CODESET parameter is already available without any subprocess; only fall
|
||||||
|
# back to `locale charmap` when that module is unavailable (zsh built without it).
|
||||||
|
local codeset="${langinfo[CODESET]:-}"
|
||||||
|
if [[ -z "$codeset" ]] && (( $+commands[locale] )); then
|
||||||
|
codeset="$(locale charmap 2>/dev/null)"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ "${codeset:l}" = (utf-8|utf8) ]]; then
|
||||||
|
_omz::log info "locale charmap is UTF-8"
|
||||||
|
else
|
||||||
|
_omz::log warn "your locale is not UTF-8 (charmap: ${codeset:-unknown})"
|
||||||
|
_omz::log info "non-UTF-8 locales may cause glitches in completions and international characters"
|
||||||
|
_omz::log info "consider setting a UTF-8 locale, e.g.: export LANG=C.UTF-8"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
function _omz::help {
|
function _omz::help {
|
||||||
cat >&2 <<EOF
|
cat >&2 <<EOF
|
||||||
Usage: omz <command> [options]
|
Usage: omz <command> [options]
|
||||||
|
|
||||||
Available commands:
|
Available commands:
|
||||||
|
|
||||||
|
diagnose Run configuration diagnostics
|
||||||
help Print this help message
|
help Print this help message
|
||||||
changelog Print the changelog
|
changelog Print the changelog
|
||||||
plugin <command> Manage plugins
|
plugin <command> Manage plugins
|
||||||
pr <command> Manage Oh My Zsh Pull Requests
|
pr <command> Manage Oh My Zsh Pull Requests
|
||||||
reload Reload the current zsh session
|
reload Reload the current zsh session
|
||||||
|
shellsaver [scene] Launch a Shellsaver (aquarium by default)
|
||||||
shop Open the Oh My Zsh shop
|
shop Open the Oh My Zsh shop
|
||||||
theme <command> Manage themes
|
theme <command> Manage themes
|
||||||
update Update Oh My Zsh
|
update Update Oh My Zsh
|
||||||
@@ -182,6 +221,15 @@ Available commands:
|
|||||||
EOF
|
EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function _omz::shellsaver {
|
||||||
|
command zsh -f "$ZSH/tools/shellsaver.zsh" "$@"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Hidden alias; only shellsaver is advertised in help and command completion.
|
||||||
|
function _omz::screensaver {
|
||||||
|
_omz::shellsaver "$@"
|
||||||
|
}
|
||||||
|
|
||||||
function _omz::changelog {
|
function _omz::changelog {
|
||||||
local version=${1:-HEAD} format=${3:-"--text"}
|
local version=${1:-HEAD} format=${3:-"--text"}
|
||||||
|
|
||||||
|
|||||||
+4
-1
@@ -59,7 +59,10 @@ function detect-clipboard() {
|
|||||||
function clippaste() { cat /dev/clipboard; }
|
function clippaste() { cat /dev/clipboard; }
|
||||||
elif (( $+commands[clip.exe] )) && (( $+commands[powershell.exe] )); then
|
elif (( $+commands[clip.exe] )) && (( $+commands[powershell.exe] )); then
|
||||||
function clipcopy() { cat "${1:-/dev/stdin}" | clip.exe; }
|
function clipcopy() { cat "${1:-/dev/stdin}" | clip.exe; }
|
||||||
function clippaste() { powershell.exe -noprofile -command Get-Clipboard; }
|
function clippaste() {
|
||||||
|
setopt localoptions pipefail
|
||||||
|
powershell.exe -noprofile -command Get-Clipboard | tr -d '\r'
|
||||||
|
}
|
||||||
elif [ -n "${WAYLAND_DISPLAY:-}" ] && (( ${+commands[wl-copy]} )) && (( ${+commands[wl-paste]} )); then
|
elif [ -n "${WAYLAND_DISPLAY:-}" ] && (( ${+commands[wl-copy]} )) && (( ${+commands[wl-paste]} )); then
|
||||||
function clipcopy() { cat "${1:-/dev/stdin}" | wl-copy &>/dev/null &|; }
|
function clipcopy() { cat "${1:-/dev/stdin}" | wl-copy &>/dev/null &|; }
|
||||||
function clippaste() { wl-paste --no-newline; }
|
function clippaste() { wl-paste --no-newline; }
|
||||||
|
|||||||
+7
-5
@@ -5,7 +5,6 @@
|
|||||||
# See: http://www.faqs.org/docs/Linux-mini/Xterm-Title.html#ss3.1
|
# See: http://www.faqs.org/docs/Linux-mini/Xterm-Title.html#ss3.1
|
||||||
# Fully supports screen, iterm, and probably most modern xterm and rxvt
|
# Fully supports screen, iterm, and probably most modern xterm and rxvt
|
||||||
# (In screen, only short_tab_title is used)
|
# (In screen, only short_tab_title is used)
|
||||||
# Limited support for Apple Terminal (Terminal can't set window and tab separately)
|
|
||||||
function title {
|
function title {
|
||||||
setopt localoptions nopromptsubst
|
setopt localoptions nopromptsubst
|
||||||
|
|
||||||
@@ -17,7 +16,7 @@ function title {
|
|||||||
: ${2=$1}
|
: ${2=$1}
|
||||||
|
|
||||||
case "$TERM" in
|
case "$TERM" in
|
||||||
cygwin|xterm*|putty*|rxvt*|konsole*|ansi|mlterm*|alacritty*|st*|foot*|contour*|wezterm*)
|
cygwin|xterm*|putty*|rxvt*|konsole*|ansi|mlterm*|alacritty*|st*|foot*|contour*|wezterm*|nsterm*)
|
||||||
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
|
||||||
;;
|
;;
|
||||||
@@ -26,10 +25,12 @@ function title {
|
|||||||
print -Pn "\ek${1:q}\e\\" # set screen hardstatus/tmux window name if `allow-rename` is on
|
print -Pn "\ek${1:q}\e\\" # set screen hardstatus/tmux window name if `allow-rename` is on
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
if [[ "$TERM_PROGRAM" == "iTerm.app" ]]; then
|
case "$TERM_PROGRAM" in
|
||||||
|
"iTerm.app"|"Apple_Terminal")
|
||||||
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
|
||||||
else
|
;;
|
||||||
|
*)
|
||||||
# Try to use terminfo to set the title if the feature is available
|
# Try to use terminfo to set the title if the feature is available
|
||||||
if (( ${+terminfo[fsl]} && ${+terminfo[tsl]} )); then
|
if (( ${+terminfo[fsl]} && ${+terminfo[tsl]} )); then
|
||||||
# Emit the capabilities with echoti so terminfo does its own parameter
|
# Emit the capabilities with echoti so terminfo does its own parameter
|
||||||
@@ -39,7 +40,8 @@ function title {
|
|||||||
print -Pn "$1"
|
print -Pn "$1"
|
||||||
echoti fsl
|
echoti fsl
|
||||||
fi
|
fi
|
||||||
fi
|
;;
|
||||||
|
esac
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
alias-finder() {
|
alias-finder() {
|
||||||
local cmd=" " exact="" longer="" cheaper="" wordEnd="'?$" finder="" filter=""
|
local c="" cmd=" " exact="" longer="" cheaper="" wordEnd="'?$" finder="" filter="" cmdLen=""
|
||||||
|
|
||||||
# build command and options
|
# build command and options
|
||||||
for c in "$@"; do
|
for c in "$@"; do
|
||||||
@@ -19,11 +19,15 @@ alias-finder() {
|
|||||||
zstyle -t ':omz:plugins:alias-finder' cheaper && cheaper=true
|
zstyle -t ':omz:plugins:alias-finder' cheaper && cheaper=true
|
||||||
|
|
||||||
# format cmd for grep
|
# format cmd for grep
|
||||||
## - replace newlines with spaces
|
## - replace newlines and multiple spaces with one space
|
||||||
## - trim both ends
|
## - trim both ends
|
||||||
## - replace multiple spaces with one space
|
|
||||||
## - add escaping character to special characters
|
## - add escaping character to special characters
|
||||||
cmd=$(echo -n "$cmd" | tr '\n' ' ' | xargs | tr -s '[:space:]' | sed 's/[].\|$(){}?+*^[]/\\&/g')
|
setopt localoptions extendedglob
|
||||||
|
cmd=${cmd//[[:space:]]##/ }
|
||||||
|
cmd=${cmd# }
|
||||||
|
cmd=${cmd% }
|
||||||
|
local esc_pattern='(#m)[][.\\|$(){}?+*^]' MATCH MBEGIN MEND
|
||||||
|
cmd=${cmd//${~esc_pattern}/\\$MATCH}
|
||||||
|
|
||||||
if [[ $longer == true ]]; then
|
if [[ $longer == true ]]; then
|
||||||
wordEnd="" # remove wordEnd to find longer aliases
|
wordEnd="" # remove wordEnd to find longer aliases
|
||||||
@@ -35,7 +39,7 @@ alias-finder() {
|
|||||||
|
|
||||||
# make filter to find only shorter results than current cmd
|
# make filter to find only shorter results than current cmd
|
||||||
if [[ $cheaper == true ]]; then
|
if [[ $cheaper == true ]]; then
|
||||||
cmdLen=$(echo -n "$cmd" | wc -c)
|
cmdLen=${#cmd}
|
||||||
if [[ $cmdLen -le 1 ]]; then
|
if [[ $cmdLen -le 1 ]]; then
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -107,6 +107,30 @@ upgrades were available. Use `pacman -Que` instead.
|
|||||||
| pasu | `pacaur -Syua --no-confirm` | Same as `paupg`, but without confirmation |
|
| pasu | `pacaur -Syua --no-confirm` | Same as `paupg`, but without confirmation |
|
||||||
| upgrade[¹](#f1) | `pacaur -Syu` | Sync with repositories before upgrading packages |
|
| upgrade[¹](#f1) | `pacaur -Syu` | Sync with repositories before upgrading packages |
|
||||||
|
|
||||||
|
#### Paru
|
||||||
|
|
||||||
|
| Alias | Command | Description |
|
||||||
|
|---------|--------------------------------|-------------------------------------------------------------------|
|
||||||
|
| puclean | `paru -Sc` | Clean out old and unused caches and packages |
|
||||||
|
| puclr | `paru -Scc` | Remove all files from the cache |
|
||||||
|
| pufiles | `paru -F` | Search the files database for packages that contain a file |
|
||||||
|
| puin | `paru -S` | Install packages from the repositories |
|
||||||
|
| puins | `paru -U` | Install a package from a local file |
|
||||||
|
| puinsd | `paru -S --asdeps` | Install packages as dependencies of another package |
|
||||||
|
| puloc | `paru -Qi` | Display information about a package in the local database |
|
||||||
|
| pulocs | `paru -Qs` | Search for packages in the local database |
|
||||||
|
| pulst | `paru -Qe` | List installed packages including from AUR (tagged as "local") |
|
||||||
|
| pumir | `paru -Syy` | Force refresh of all package lists after updating mirrorlist |
|
||||||
|
| puorph | `paru -Qtd` | List orphaned packages |
|
||||||
|
| pure | `paru -R` | Remove packages, keeping its settings and dependencies |
|
||||||
|
| purem | `paru -Rns` | Remove packages, including its settings and unneeded dependencies |
|
||||||
|
| purep | `paru -Si` | Display information about a package in the repositories |
|
||||||
|
| pureps | `paru -Ss` | Search for packages in the repositories |
|
||||||
|
| puupd | `paru -Sy` | Update and refresh local package, ABS and AUR databases |
|
||||||
|
| puupg | `paru -Syu` | Sync with repositories before upgrading packages |
|
||||||
|
| pusu | `paru -Syu --noconfirm` | Same as `puupg`, but without confirmation |
|
||||||
|
| upgrade[¹](#f1) | `paru -Syu` | Sync with repositories before upgrading packages |
|
||||||
|
|
||||||
#### Trizen
|
#### Trizen
|
||||||
|
|
||||||
| Alias | Command | Description |
|
| Alias | Command | Description |
|
||||||
@@ -163,9 +187,10 @@ whether the package manager is installed, checked in the following order:
|
|||||||
|
|
||||||
1. `yay`
|
1. `yay`
|
||||||
2. `trizen`
|
2. `trizen`
|
||||||
3. `pacaur`
|
3. `paru`
|
||||||
4. `aura`
|
4. `pacaur`
|
||||||
5. `pacman`
|
5. `aura`
|
||||||
|
6. `pacman`
|
||||||
|
|
||||||
## Contributors
|
## Contributors
|
||||||
|
|
||||||
@@ -182,3 +207,4 @@ whether the package manager is installed, checked in the following order:
|
|||||||
- Jeff M. Hubbard - jeffmhubbard@gmail.com
|
- Jeff M. Hubbard - jeffmhubbard@gmail.com
|
||||||
- K. Harishankar(harishnkr) - hari2menon1234@gmail.com
|
- K. Harishankar(harishnkr) - hari2menon1234@gmail.com
|
||||||
- WH-2099 - wh2099@outlook.com
|
- WH-2099 - wh2099@outlook.com
|
||||||
|
- Boris Frenkel - fobos2k@gmail.com
|
||||||
@@ -134,6 +134,27 @@ if (( $+commands[pacaur] )); then
|
|||||||
alias paupd="pacaur -Sy"
|
alias paupd="pacaur -Sy"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if (( $+commands[paru] )); then
|
||||||
|
alias puclean='paru -Sc'
|
||||||
|
alias puclr='paru -Scc'
|
||||||
|
alias pufiles='paru -F'
|
||||||
|
alias puin='paru -S'
|
||||||
|
alias puins='paru -U'
|
||||||
|
alias puinsd='paru -S --asdeps'
|
||||||
|
alias puloc='paru -Qi'
|
||||||
|
alias pulocs='paru -Qs'
|
||||||
|
alias pulst='paru -Qe'
|
||||||
|
alias pumir='paru -Syy'
|
||||||
|
alias puorph='paru -Qtd'
|
||||||
|
alias pure='paru -R'
|
||||||
|
alias purem='paru -Rns'
|
||||||
|
alias purep='paru -Si'
|
||||||
|
alias pureps='paru -Ss'
|
||||||
|
alias puupd='paru -Sy'
|
||||||
|
alias puupg='paru -Syu'
|
||||||
|
alias pusu='paru -Syu --noconfirm'
|
||||||
|
fi
|
||||||
|
|
||||||
if (( $+commands[trizen] )); then
|
if (( $+commands[trizen] )); then
|
||||||
alias trconf='trizen -C'
|
alias trconf='trizen -C'
|
||||||
alias trupg='trizen -Syua'
|
alias trupg='trizen -Syua'
|
||||||
@@ -194,6 +215,8 @@ function upgrade() {
|
|||||||
yay -Su
|
yay -Su
|
||||||
elif (( $+commands[trizen] )); then
|
elif (( $+commands[trizen] )); then
|
||||||
trizen -Su
|
trizen -Su
|
||||||
|
elif (( $+commands[paru] )); then
|
||||||
|
paru -Su
|
||||||
elif (( $+commands[pacaur] )); then
|
elif (( $+commands[pacaur] )); then
|
||||||
pacaur -Su
|
pacaur -Su
|
||||||
elif (( $+commands[aura] )); then
|
elif (( $+commands[aura] )); then
|
||||||
|
|||||||
@@ -35,7 +35,8 @@ plugins=(... aws)
|
|||||||
|
|
||||||
* `aws_change_access_key`: changes the AWS access key of a profile.
|
* `aws_change_access_key`: changes the AWS access key of a profile.
|
||||||
|
|
||||||
* `aws_profiles`: lists the available profiles in the `$AWS_CONFIG_FILE` (default: `~/.aws/config`).
|
* `aws_profiles`: lists the available profiles in the `$AWS_CONFIG_FILE` (default: `~/.aws/config`) and
|
||||||
|
`$AWS_SHARED_CREDENTIALS_FILE` (default: `~/.aws/credentials`).
|
||||||
Used to provide completion for the `asp` function.
|
Used to provide completion for the `asp` function.
|
||||||
|
|
||||||
* `aws_regions`: lists the available regions.
|
* `aws_regions`: lists the available regions.
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ function asp() {
|
|||||||
export AWS_PROFILE=$1
|
export AWS_PROFILE=$1
|
||||||
export AWS_EB_PROFILE=$1
|
export AWS_EB_PROFILE=$1
|
||||||
|
|
||||||
export AWS_PROFILE_REGION=$(aws configure get region)
|
export AWS_PROFILE_REGION=$(_aws_profile_region "$1")
|
||||||
|
|
||||||
_aws_update_state
|
_aws_update_state
|
||||||
|
|
||||||
@@ -239,9 +239,47 @@ function aws_regions() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function aws_profiles() {
|
function aws_profiles() {
|
||||||
aws --no-cli-pager configure list-profiles 2> /dev/null && return
|
emulate -L zsh
|
||||||
[[ -r "${AWS_CONFIG_FILE:-$HOME/.aws/config}" ]] || return 1
|
local config="${AWS_CONFIG_FILE:-$HOME/.aws/config}"
|
||||||
command grep -Eo '^[[:space:]]*\[[[:space:]]*(profile[[:space:]]+)?[^][:space:]]+[[:space:]]*\]' "${AWS_CONFIG_FILE:-$HOME/.aws/config}" | command sed -E 's/^[[:space:]]*\[[[:space:]]*(profile[[:space:]]+)?([^][:space:]]+)[[:space:]]*\]$/\2/'
|
local creds="${AWS_SHARED_CREDENTIALS_FILE:-$HOME/.aws/credentials}"
|
||||||
|
# Read the files directly; the AWS CLI is slow to start
|
||||||
|
if [[ ! -r "$config" && ! -r "$creds" ]]; then
|
||||||
|
aws --no-cli-pager configure list-profiles 2> /dev/null
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
local line words
|
||||||
|
# Only read the section headers, so the credentials never enter the shell
|
||||||
|
for line in "${(@f)$(command grep -h '^[[:space:]]*\[' -- "$config" "$creds" 2> /dev/null)}"; do
|
||||||
|
line=${line#*\[} # drop up to the first [
|
||||||
|
line=${line%\]*} # drop from the last ] (comments, CR)
|
||||||
|
words=(${=line})
|
||||||
|
if (( $#words == 1 )); then
|
||||||
|
print -r -- $words[1] # [default], or [foo] in the credentials file
|
||||||
|
elif (( $#words == 2 )) && [[ $words[1] == profile ]]; then
|
||||||
|
print -r -- $words[2]
|
||||||
|
fi
|
||||||
|
done | command sort -u
|
||||||
|
}
|
||||||
|
|
||||||
|
# Read a profile's region from the config file, falling back to the AWS CLI
|
||||||
|
function _aws_profile_region() {
|
||||||
|
emulate -L zsh
|
||||||
|
local config="${AWS_CONFIG_FILE:-$HOME/.aws/config}" line words in_profile
|
||||||
|
if [[ -r "$config" ]]; then
|
||||||
|
# Only read headers and region lines, so any credentials never enter the shell
|
||||||
|
for line in "${(@f)$(command grep -e '\[' -e region -- "$config" 2> /dev/null)}"; do
|
||||||
|
line=${line%$'\r'}
|
||||||
|
words=(${=line//[\[\]=]/ }) # "[profile foo]" -> (profile foo), "region = x" -> (region x)
|
||||||
|
if [[ ${${=line}[1]} == \[* ]]; then # header, possibly indented
|
||||||
|
in_profile=
|
||||||
|
[[ "$words" == "profile $1" || ( $1 == default && "$words" == default ) ]] && in_profile=1
|
||||||
|
elif [[ -n $in_profile && $words[1] == region ]]; then
|
||||||
|
print -r -- $words[2]
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
aws configure get region
|
||||||
}
|
}
|
||||||
|
|
||||||
function _aws_regions() {
|
function _aws_regions() {
|
||||||
@@ -285,7 +323,7 @@ if [[ "$AWS_PROFILE_STATE_ENABLED" == true ]]; then
|
|||||||
export AWS_PROFILE="$AWS_DEFAULT_PROFILE"
|
export AWS_PROFILE="$AWS_DEFAULT_PROFILE"
|
||||||
export AWS_EB_PROFILE="$AWS_DEFAULT_PROFILE"
|
export AWS_EB_PROFILE="$AWS_DEFAULT_PROFILE"
|
||||||
|
|
||||||
test -z "${aws_state[2]}" && AWS_REGION=$(aws configure get region)
|
test -z "${aws_state[2]}" && AWS_REGION=$(_aws_profile_region "$AWS_PROFILE")
|
||||||
|
|
||||||
export AWS_REGION=${AWS_REGION:-$aws_state[2]}
|
export AWS_REGION=${AWS_REGION:-$aws_state[2]}
|
||||||
export AWS_DEFAULT_REGION="$AWS_REGION"
|
export AWS_DEFAULT_REGION="$AWS_REGION"
|
||||||
|
|||||||
@@ -25,10 +25,10 @@ if [[ "$OSTYPE" = darwin* ]]; then
|
|||||||
echo "$(ioreg -rc AppleSmartBattery | grep -o '"Watts"=[0-9]\+' | head -1 | grep -o '[0-9]\+')W "
|
echo "$(ioreg -rc AppleSmartBattery | grep -o '"Watts"=[0-9]\+' | head -1 | grep -o '[0-9]\+')W "
|
||||||
}
|
}
|
||||||
function battery_is_charging() {
|
function battery_is_charging() {
|
||||||
ioreg -rc AppleSmartBattery | command grep -q '^.*"ExternalConnected"\ =\ Yes'
|
ioreg -rc AppleSmartBattery | command grep -q '^.*"ExternalConnected" = Yes'
|
||||||
}
|
}
|
||||||
function battery_pct() {
|
function battery_pct() {
|
||||||
pmset -g batt | grep -Eo "\d+%" | cut -d% -f1
|
pmset -g batt | grep -Eo "[0-9]+%" | cut -d% -f1
|
||||||
}
|
}
|
||||||
function battery_pct_remaining() {
|
function battery_pct_remaining() {
|
||||||
if battery_is_charging; then
|
if battery_is_charging; then
|
||||||
@@ -39,8 +39,8 @@ if [[ "$OSTYPE" = darwin* ]]; then
|
|||||||
}
|
}
|
||||||
function battery_time_remaining() {
|
function battery_time_remaining() {
|
||||||
local smart_battery_status="$(ioreg -rc "AppleSmartBattery")"
|
local smart_battery_status="$(ioreg -rc "AppleSmartBattery")"
|
||||||
if [[ $(echo $smart_battery_status | command grep -c '^.*"ExternalConnected"\ =\ No') -eq 1 ]]; then
|
if [[ $(echo $smart_battery_status | command grep -c '^.*"ExternalConnected" = No') -eq 1 ]]; then
|
||||||
timeremaining=$(echo $smart_battery_status | command grep '^.*"AvgTimeToEmpty"\ =\ ' | sed -e 's/^.*"AvgTimeToEmpty"\ =\ //')
|
timeremaining=$(echo $smart_battery_status | command grep '^.*"AvgTimeToEmpty" = ' | sed -e 's/^.*"AvgTimeToEmpty" = //')
|
||||||
if [ $timeremaining -gt 720 ]; then
|
if [ $timeremaining -gt 720 ]; then
|
||||||
echo "::"
|
echo "::"
|
||||||
else
|
else
|
||||||
@@ -52,7 +52,7 @@ if [[ "$OSTYPE" = darwin* ]]; then
|
|||||||
}
|
}
|
||||||
function battery_pct_prompt () {
|
function battery_pct_prompt () {
|
||||||
local battery_pct color
|
local battery_pct color
|
||||||
if ioreg -rc AppleSmartBattery | command grep -q '^.*"ExternalConnected"\ =\ No'; then
|
if ioreg -rc AppleSmartBattery | command grep -q '^.*"ExternalConnected" = No'; then
|
||||||
battery_pct=$(battery_pct_remaining)
|
battery_pct=$(battery_pct_remaining)
|
||||||
if [[ $battery_pct -gt 50 ]]; then
|
if [[ $battery_pct -gt 50 ]]; then
|
||||||
color='green'
|
color='green'
|
||||||
|
|||||||
@@ -0,0 +1,16 @@
|
|||||||
|
# Bitwarden plugin
|
||||||
|
|
||||||
|
This plugin adds Zsh completions for whichever Bitwarden CLIs are installed:
|
||||||
|
|
||||||
|
- [Bitwarden CLI (`bw`)](https://bitwarden.com/help/cli/)
|
||||||
|
- [Bitwarden Secrets Manager CLI (`bws`)](https://bitwarden.com/help/secrets-manager-cli/)
|
||||||
|
|
||||||
|
To enable it, add `bitwarden` to the plugins array in your `.zshrc`:
|
||||||
|
|
||||||
|
```zsh
|
||||||
|
plugins=(... bitwarden)
|
||||||
|
```
|
||||||
|
|
||||||
|
Each installed CLI generates and refreshes its own completion cache in the
|
||||||
|
background when the plugin loads. The cache files are
|
||||||
|
`$ZSH_CACHE_DIR/completions/_bw` and `$ZSH_CACHE_DIR/completions/_bws`.
|
||||||
@@ -0,0 +1,45 @@
|
|||||||
|
# Autocompletion for the Bitwarden CLI (bw) and Secrets Manager CLI (bws).
|
||||||
|
() {
|
||||||
|
local cli completion cache_file
|
||||||
|
local -a generator_args
|
||||||
|
for cli in bw bws; do
|
||||||
|
completion="_$cli"
|
||||||
|
cache_file="$ZSH_CACHE_DIR/completions/$completion"
|
||||||
|
|
||||||
|
if (( ! $+commands[$cli] )); then
|
||||||
|
# compinit can register a cached completion after the CLI is removed.
|
||||||
|
if [[ -f "$cache_file" && ${_comps[$cli]-} == "$completion" ]]; then
|
||||||
|
unset "_comps[$cli]"
|
||||||
|
fi
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
|
||||||
|
case "$cli" in
|
||||||
|
bw)
|
||||||
|
generator_args=(completion --shell zsh)
|
||||||
|
# bw emits function definitions. Use ksh-style autoload to run _bw
|
||||||
|
# on the first Tab press as well as loading its helper functions.
|
||||||
|
autoload -Uk "$completion"
|
||||||
|
;;
|
||||||
|
bws)
|
||||||
|
generator_args=(completions zsh)
|
||||||
|
autoload -Uz "$completion"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
# Register the completion if compinit hasn't picked it up yet.
|
||||||
|
if [[ -z ${_comps[$cli]-} ]]; then
|
||||||
|
_comps[$cli]=$completion
|
||||||
|
fi
|
||||||
|
|
||||||
|
() {
|
||||||
|
zmodload -F zsh/files b:zf_mv || return
|
||||||
|
local temp_file
|
||||||
|
temp_file=$(mktemp "${cache_file:h}/.$completion.XXXXXXXX") || return
|
||||||
|
if command "$cli" "$@" >| "$temp_file" && [[ -s "$temp_file" ]] &&
|
||||||
|
zf_mv -f -- "$temp_file" "$cache_file"; then
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
rm -f -- "$temp_file"
|
||||||
|
} "${generator_args[@]}" &|
|
||||||
|
done
|
||||||
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
# Bridgetown plugin
|
# Bridgetown plugin
|
||||||
|
|
||||||
This plugin adds some aliases and autocompletion for common [Bridgetown](https://bridgetownrb.com/) commands.
|
This plugin adds aliases for common [Bridgetown](https://www.bridgetownrb.com/) commands.
|
||||||
|
|
||||||
To use it, add `bridgetown` to the plugins array in your zshrc file:
|
To use it, add `bridgetown` to the plugins array in your zshrc file:
|
||||||
|
|
||||||
@@ -10,17 +10,27 @@ plugins=(... bridgetown)
|
|||||||
|
|
||||||
## Aliases
|
## Aliases
|
||||||
|
|
||||||
| Alias | Command |
|
Most aliases use the project's `bin/bridgetown` executable so the command runs with the Bridgetown version
|
||||||
|-------|----------------------------|
|
locked in its `Gemfile`. The `br` and `brn` aliases use the globally installed executable and can be run
|
||||||
| br | `bridgetown` |
|
outside a Bridgetown project.
|
||||||
| bra | `bin/bridgetown apply` |
|
|
||||||
| brb | `bin/bridgetown build` |
|
| Alias | Command | Description |
|
||||||
| brc | `bin/bridgetown console` |
|
| --------- | ---------------------------- | ---------------------------------------- |
|
||||||
| brclean | `bin/bridgetown clean` |
|
| `br` | `bridgetown` | Run the globally installed CLI |
|
||||||
| brd | `bin/bridgetown deploy` |
|
| `bra` | `bin/bridgetown apply` | Apply an automation |
|
||||||
| brdoc | `bin/bridgetown doctor` |
|
| `brb` | `bin/bridgetown build` | Build the site |
|
||||||
| brh | `bin/bridgetown help` |
|
| `brc` | `bin/bridgetown console` | Open the Bridgetown console |
|
||||||
| brn | `bridgetown new` |
|
| `brclean` | `bin/bridgetown clean` | Remove generated files and caches |
|
||||||
| brp | `bridgetown plugins` |
|
| `brco` | `bin/bridgetown configure` | Apply a bundled configuration |
|
||||||
| brpl | `bridgetown plugins list` |
|
| `brd` | `bin/bridgetown deploy` | Run the project's deployment task |
|
||||||
| brs | `bin/bridgetown start` |
|
| `brdev` | `bin/bridgetown dev` | Start the development server |
|
||||||
|
| `bre` | `bin/bridgetown esbuild` | Manage the esbuild configuration |
|
||||||
|
| `brh` | `bin/bridgetown help` | Show command help |
|
||||||
|
| `brn` | `bridgetown new` | Create a new Bridgetown site |
|
||||||
|
| `brp` | `bin/bridgetown plugins` | Access plugin commands |
|
||||||
|
| `brpl` | `bin/bridgetown plugins list` | List installed plugins |
|
||||||
|
| `brs` | `bin/bridgetown start` | Start the development server |
|
||||||
|
| `brt` | `bin/bridgetown test` | Run the project's test build task |
|
||||||
|
|
||||||
|
`deploy` and `test` are standard tasks from the `Rakefile` generated for a new Bridgetown site. If the project
|
||||||
|
customizes or removes those tasks, the corresponding aliases follow that project behavior.
|
||||||
@@ -3,10 +3,13 @@ alias bra='bin/bridgetown apply'
|
|||||||
alias brb='bin/bridgetown build'
|
alias brb='bin/bridgetown build'
|
||||||
alias brc='bin/bridgetown console'
|
alias brc='bin/bridgetown console'
|
||||||
alias brclean='bin/bridgetown clean'
|
alias brclean='bin/bridgetown clean'
|
||||||
|
alias brco='bin/bridgetown configure'
|
||||||
alias brd='bin/bridgetown deploy'
|
alias brd='bin/bridgetown deploy'
|
||||||
alias brdoc='bin/bridgetown doctor'
|
alias brdev='bin/bridgetown dev'
|
||||||
|
alias bre='bin/bridgetown esbuild'
|
||||||
alias brh='bin/bridgetown help'
|
alias brh='bin/bridgetown help'
|
||||||
alias brn='bridgetown new'
|
alias brn='bridgetown new'
|
||||||
alias brp='bridgetown plugins'
|
alias brp='bin/bridgetown plugins'
|
||||||
alias brpl='bridgetown plugins list'
|
alias brpl='bin/bridgetown plugins list'
|
||||||
alias brs='bin/bridgetown start'
|
alias brs='bin/bridgetown start'
|
||||||
|
alias brt='bin/bridgetown test'
|
||||||
@@ -14,6 +14,6 @@ function copyfile {
|
|||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
clipcopy $1
|
clipcopy $1 || return 1
|
||||||
echo ${(%):-"%B$1%b copied to clipboard."}
|
echo ${(%):-"%B$1%b copied to clipboard."}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,74 @@
|
|||||||
|
#!/usr/bin/env zsh
|
||||||
|
|
||||||
|
emulate -LR zsh
|
||||||
|
|
||||||
|
source "${1:-${0:A:h:h}/copyfile.plugin.zsh}"
|
||||||
|
|
||||||
|
test_dir=$(mktemp -d) || exit 1
|
||||||
|
trap 'command rm -rf -- "$test_dir"' EXIT
|
||||||
|
|
||||||
|
typeset -i clipboard_status=0 failures=0 tests=0
|
||||||
|
typeset output expected_output
|
||||||
|
|
||||||
|
clipcopy() {
|
||||||
|
print -r -- "$#" "$1" >| "$test_dir/call"
|
||||||
|
if (( clipboard_status )); then
|
||||||
|
print -u2 -r -- "clipboard backend failed"
|
||||||
|
return $clipboard_status
|
||||||
|
fi
|
||||||
|
command cat -- "$1" >| "$test_dir/clipboard"
|
||||||
|
}
|
||||||
|
|
||||||
|
check_copyfile() {
|
||||||
|
local description="$1" expected_status="$2" expected_stdout="$3" expected_stderr="$4"
|
||||||
|
shift 4
|
||||||
|
|
||||||
|
output=$(copyfile "$@" 2> "$test_dir/stderr")
|
||||||
|
local actual_status=$?
|
||||||
|
(( tests++ ))
|
||||||
|
|
||||||
|
if [[ $actual_status == $expected_status && $output == "$expected_stdout" && $(<"$test_dir/stderr") == "$expected_stderr" ]]; then
|
||||||
|
print -r -- "PASS: $description"
|
||||||
|
else
|
||||||
|
print -u2 -r -- "FAIL: $description"
|
||||||
|
print -u2 -r -- " status: $actual_status (expected $expected_status)"
|
||||||
|
print -u2 -r -- " stdout: ${(qqq)output} (expected ${(qqq)expected_stdout})"
|
||||||
|
print -u2 -r -- " stderr: $(<"$test_dir/stderr") (expected $expected_stderr)"
|
||||||
|
(( failures++ ))
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
for filename in plain.txt 'file with spaces.txt' 'unicode-ą.txt' empty.txt; do
|
||||||
|
if [[ $filename == empty.txt ]]; then
|
||||||
|
: >| "$test_dir/$filename"
|
||||||
|
else
|
||||||
|
print -r -- "contents of $filename" >| "$test_dir/$filename"
|
||||||
|
fi
|
||||||
|
|
||||||
|
expected_output=${(%):-"%B$test_dir/$filename%b copied to clipboard."}
|
||||||
|
clipboard_status=0
|
||||||
|
check_copyfile "successful copy of $filename" 0 "$expected_output" '' "$test_dir/$filename"
|
||||||
|
|
||||||
|
if [[ $(<"$test_dir/call") != "1 $test_dir/$filename" ]] || ! command cmp -s -- "$test_dir/$filename" "$test_dir/clipboard"; then
|
||||||
|
print -u2 -r -- "FAIL: clipboard received a different argument or contents for $filename"
|
||||||
|
(( failures++ ))
|
||||||
|
fi
|
||||||
|
|
||||||
|
for clipboard_status in 1 42 127; do
|
||||||
|
check_copyfile "clipboard exit $clipboard_status for $filename" 1 '' 'clipboard backend failed' "$test_dir/$filename"
|
||||||
|
done
|
||||||
|
done
|
||||||
|
|
||||||
|
command rm -f -- "$test_dir/call"
|
||||||
|
check_copyfile 'missing argument' 1 'Usage: copyfile <file>' ''
|
||||||
|
check_copyfile 'empty argument' 1 'Usage: copyfile <file>' '' ''
|
||||||
|
check_copyfile 'nonexistent file' 1 "Error: '$test_dir/missing.txt' is not a valid file." '' "$test_dir/missing.txt"
|
||||||
|
check_copyfile 'directory argument' 1 "Error: '$test_dir' is not a valid file." '' "$test_dir"
|
||||||
|
|
||||||
|
if [[ -e "$test_dir/call" ]]; then
|
||||||
|
print -u2 -r -- 'FAIL: invalid input invoked the clipboard backend'
|
||||||
|
(( failures++ ))
|
||||||
|
fi
|
||||||
|
|
||||||
|
print -r -- "$tests tests, $failures failures"
|
||||||
|
(( failures == 0 ))
|
||||||
@@ -52,7 +52,7 @@ function push_future() {
|
|||||||
if [[ $#dirhistory_future -ge $DIRHISTORY_SIZE ]]; then
|
if [[ $#dirhistory_future -ge $DIRHISTORY_SIZE ]]; then
|
||||||
shift dirhistory_future
|
shift dirhistory_future
|
||||||
fi
|
fi
|
||||||
if [[ $#dirhistory_future -eq 0 || $dirhistory_futuret[$#dirhistory_future] != "$1" ]]; then
|
if [[ $#dirhistory_future -eq 0 || $dirhistory_future[$#dirhistory_future] != "$1" ]]; then
|
||||||
dirhistory_future+=($1)
|
dirhistory_future+=($1)
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,28 +13,32 @@ plugins=(... docker-compose)
|
|||||||
|
|
||||||
## Aliases
|
## Aliases
|
||||||
|
|
||||||
| Alias | Command | Description |
|
| Alias | Command | Description |
|
||||||
|-----------|----------------------------------|----------------------------------------------------------------------------------|
|
|-----------|-------------------------------------|----------------------------------------------------------------------------------------------|
|
||||||
| dco | `docker-compose` | Docker-compose main command |
|
| dco | `docker-compose` | Docker-compose main command |
|
||||||
| dcb | `docker-compose build` | Build containers |
|
| dcb | `docker-compose build` | Build containers |
|
||||||
| dcc | `docker-compose config` | Parse, resolve and render compose file in canonical format |
|
| dcc | `docker-compose config` | Parse, resolve and render compose file in canonical format |
|
||||||
| dce | `docker-compose exec` | Execute command inside a container |
|
| dce | `docker-compose exec` | Execute command inside a container |
|
||||||
| dcps | `docker-compose ps` | List containers |
|
| dcps | `docker-compose ps` | List containers |
|
||||||
| dcrestart | `docker-compose restart` | Restart container |
|
| dcrestart | `docker-compose restart` | Restart container |
|
||||||
| dcrm | `docker-compose rm` | Remove container |
|
| dcrm | `docker-compose rm` | Remove container |
|
||||||
| dcr | `docker-compose run` | Run a command in container |
|
| dcr | `docker-compose run` | Run a command in container |
|
||||||
| dcstop | `docker-compose stop` | Stop a container |
|
| dcstop | `docker-compose stop` | Stop a container |
|
||||||
| dcup | `docker-compose up` | Build, (re)create, start, and attach to containers for a service |
|
| dcup | `docker-compose up` | Build, (re)create, start, and attach to containers for a service |
|
||||||
| dcupb | `docker-compose up --build` | Same as `dcup`, but build images before starting containers |
|
| dcupb | `docker-compose up --build` | Same as `dcup`, but build images before starting containers |
|
||||||
| dcupd | `docker-compose up -d` | Same as `dcup`, but starts as daemon |
|
| dcupd | `docker-compose up -d` | Same as `dcup`, but starts as daemon |
|
||||||
| dcupdb | `docker-compose up -d --build` | Same as `dcup`, but build images before starting containers and starts as daemon |
|
| dcupdb | `docker-compose up -d --build` | Same as `dcup`, but build images before starting containers and starts as daemon |
|
||||||
| dcdn | `docker-compose down` | Stop and remove containers |
|
| dcupw | `docker-compose up --watch` | Watch changes in service and rebuild/restart accordingly (see [Use Compose Watch] for usage) |
|
||||||
| dcl | `docker-compose logs` | Show logs of container |
|
| dcupwb | `docker-compose up --watch --build` | Same as `dcupw`, but build images before starting containers |
|
||||||
| dclf | `docker-compose logs -f` | Show logs and follow output |
|
| dcdn | `docker-compose down` | Stop and remove containers |
|
||||||
| dclF | `docker-compose logs -f --tail0` | Just follow recent logs |
|
| dcl | `docker-compose logs` | Show logs of container |
|
||||||
| dcpull | `docker-compose pull` | Pull image of a service |
|
| dclf | `docker-compose logs -f` | Show logs and follow output |
|
||||||
| dcstart | `docker-compose start` | Start a container |
|
| dclF | `docker-compose logs -f --tail0` | Just follow recent logs |
|
||||||
| dck | `docker-compose kill` | Kills containers |
|
| dcpull | `docker-compose pull` | Pull image of a service |
|
||||||
| dcv | `docker-compose version` | Show version information |
|
| dcstart | `docker-compose start` | Start a container |
|
||||||
| dcsts | `docker-compose stats` | Show stats of containers |
|
| dck | `docker-compose kill` | Kills containers |
|
||||||
| dci | `docker-compose images` | List images |
|
| dcv | `docker-compose version` | Show version information |
|
||||||
|
| dcsts | `docker-compose stats` | Show stats of containers |
|
||||||
|
| dci | `docker-compose images` | List images |
|
||||||
|
|
||||||
|
[Use Compose Watch]: https://docs.docker.com/compose/how-tos/file-watch/
|
||||||
@@ -17,6 +17,8 @@ alias dcup="$dccmd up"
|
|||||||
alias dcupb="$dccmd up --build"
|
alias dcupb="$dccmd up --build"
|
||||||
alias dcupd="$dccmd up -d"
|
alias dcupd="$dccmd up -d"
|
||||||
alias dcupdb="$dccmd up -d --build"
|
alias dcupdb="$dccmd up -d --build"
|
||||||
|
alias dcupw="$dccmd up --watch"
|
||||||
|
alias dcupwb="$dccmd up --watch --build"
|
||||||
alias dcdn="$dccmd down"
|
alias dcdn="$dccmd down"
|
||||||
alias dcl="$dccmd logs"
|
alias dcl="$dccmd logs"
|
||||||
alias dclf="$dccmd logs -f"
|
alias dclf="$dccmd logs -f"
|
||||||
|
|||||||
@@ -84,6 +84,7 @@ If you use Podman's Docker wrapper, you need to enable legacy completion. See ab
|
|||||||
| dtop | `docker top` | Display the running processes of a container |
|
| dtop | `docker top` | Display the running processes of a container |
|
||||||
| dvi | `docker volume inspect` | Display detailed information about one or more volumes |
|
| dvi | `docker volume inspect` | Display detailed information about one or more volumes |
|
||||||
| dvls | `docker volume ls` | List all the volumes known to docker |
|
| dvls | `docker volume ls` | List all the volumes known to docker |
|
||||||
|
| dvrm | `docker volume rm` | Remove one or more volumes |
|
||||||
| dvprune | `docker volume prune` | Cleanup dangling volumes |
|
| dvprune | `docker volume prune` | Cleanup dangling volumes |
|
||||||
| dxc | `docker container exec` | Run a new command in a running container |
|
| dxc | `docker container exec` | Run a new command in a running container |
|
||||||
| dxcit | `docker container exec -it` | Run a new command in a running container in an interactive shell |
|
| dxcit | `docker container exec -it` | Run a new command in a running container in an interactive shell |
|
||||||
@@ -35,6 +35,7 @@ alias dsts='docker stats'
|
|||||||
alias dtop='docker top'
|
alias dtop='docker top'
|
||||||
alias dvi='docker volume inspect'
|
alias dvi='docker volume inspect'
|
||||||
alias dvls='docker volume ls'
|
alias dvls='docker volume ls'
|
||||||
|
alias dvrm='docker volume rm'
|
||||||
alias dvprune='docker volume prune'
|
alias dvprune='docker volume prune'
|
||||||
alias dxc='docker container exec'
|
alias dxc='docker container exec'
|
||||||
alias dxcit='docker container exec -it'
|
alias dxcit='docker container exec -it'
|
||||||
@@ -48,6 +49,11 @@ fi
|
|||||||
0="${${ZERO:-${0:#$ZSH_ARGZERO}}:-${(%):-%N}}"
|
0="${${ZERO:-${0:#$ZSH_ARGZERO}}:-${(%):-%N}}"
|
||||||
0="${${(M)0:#/*}:-$PWD/$0}"
|
0="${${(M)0:#/*}:-$PWD/$0}"
|
||||||
|
|
||||||
|
# Make sure the cache directory exists; when the plugin is loaded by a
|
||||||
|
# standalone plugin manager (e.g. antigen) the core is not sourced, so
|
||||||
|
# $ZSH_CACHE_DIR/completions may not have been created yet (#13679).
|
||||||
|
[[ -d "$ZSH_CACHE_DIR/completions" ]] || mkdir -p "$ZSH_CACHE_DIR/completions"
|
||||||
|
|
||||||
# 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 `docker`. Otherwise, compinit will have already done that.
|
# bind it to `docker`. Otherwise, compinit will have already done that.
|
||||||
if [[ ! -f "$ZSH_CACHE_DIR/completions/_docker" ]]; then
|
if [[ ! -f "$ZSH_CACHE_DIR/completions/_docker" ]]; then
|
||||||
|
|||||||
@@ -100,7 +100,7 @@ takes preference, _i.e._ the .env file will never be sourced.
|
|||||||
## Named Pipe (FIFO) Support
|
## Named Pipe (FIFO) Support
|
||||||
|
|
||||||
The plugin supports `.env` files provided as UNIX named pipes (FIFOs) in addition to regular files.
|
The plugin supports `.env` files provided as UNIX named pipes (FIFOs) in addition to regular files.
|
||||||
This is useful when secrets managers like [1Password Environments](https://developer.1password.com/docs/environment/)
|
This is useful when secrets managers like [1Password Environments](https://developer.1password.com/docs/environments/)
|
||||||
mount `.env` files as named pipes to inject secrets on-the-fly without writing them to disk.
|
mount `.env` files as named pipes to inject secrets on-the-fly without writing them to disk.
|
||||||
|
|
||||||
No additional configuration is required — the plugin automatically detects and sources named pipes.
|
No additional configuration is required — the plugin automatically detects and sources named pipes.
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ plugins=(... drush)
|
|||||||
| `drcr` | `drush core-cron` | Run all cron hooks in all active modules for specified site |
|
| `drcr` | `drush core-cron` | Run all cron hooks in all active modules for specified site |
|
||||||
| `drct` | `drush cc theme-registry` | Clear theme-registry cache |
|
| `drct` | `drush cc theme-registry` | Clear theme-registry cache |
|
||||||
| `drcv` | `drush cc views` | Clear views cache _(make sure that the views module is enabled)_ |
|
| `drcv` | `drush cc views` | Clear views cache _(make sure that the views module is enabled)_ |
|
||||||
| `drdmp` | `drush drush sql-dump --ordered-dump --result-file=dumpsql` | Backup database in a new dump.sql file |
|
| `drdmp` | `drush sql-dump --ordered-dump --result-file=dump.sql` | Backup database in a new dump.sql file |
|
||||||
| `drf` | `drush features` | Display features status |
|
| `drf` | `drush features` | Display features status |
|
||||||
| `drfr` | `drush features-revert -y` | Revert a feature module on your site |
|
| `drfr` | `drush features-revert -y` | Revert a feature module on your site |
|
||||||
| `drfra` | `drush features-revert-all` | Revert all enabled feature module on your site |
|
| `drfra` | `drush features-revert-all` | Revert all enabled feature module on your site |
|
||||||
|
|||||||
@@ -35,7 +35,9 @@ alias eeval="$EMACS_PLUGIN_LAUNCHER --eval"
|
|||||||
alias eframe='emacsclient --alternate-editor="" --create-frame'
|
alias eframe='emacsclient --alternate-editor="" --create-frame'
|
||||||
|
|
||||||
# Emacs ANSI Term tracking
|
# Emacs ANSI Term tracking
|
||||||
if [[ -n "$INSIDE_EMACS" ]] && [[ "$INSIDE_EMACS" != "vterm" ]]; then
|
local excluded_terms=(vterm ghostel)
|
||||||
|
local current_term="${INSIDE_EMACS%%,*}"
|
||||||
|
if [[ -n "$INSIDE_EMACS" ]] && (( ! ${excluded_terms[(Ie)$current_term]} )); then
|
||||||
chpwd_emacs() { print -P "\033AnSiTc %d"; }
|
chpwd_emacs() { print -P "\033AnSiTc %d"; }
|
||||||
print -P "\033AnSiTc %d" # Track current working directory
|
print -P "\033AnSiTc %d" # Track current working directory
|
||||||
print -P "\033AnSiTu %n" # Track username
|
print -P "\033AnSiTu %n" # Track username
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ case $state in
|
|||||||
'new' \
|
'new' \
|
||||||
'serve' \
|
'serve' \
|
||||||
'test' \
|
'test' \
|
||||||
'vesion' && ret=0
|
'version' && ret=0
|
||||||
;;
|
;;
|
||||||
addon)
|
addon)
|
||||||
_arguments \
|
_arguments \
|
||||||
|
|||||||
@@ -46,10 +46,10 @@ Encode a file's contents to base64 and save output to text file.
|
|||||||
- From parameter
|
- From parameter
|
||||||
|
|
||||||
```console
|
```console
|
||||||
$ encodefile64 ohmyzsh.icn
|
$ encodefile64 oh-my-zsh
|
||||||
ohmyzsh.icn's content encoded in base64 and saved as ohmyzsh.icn.txt
|
oh-my-zsh's content encoded in base64 and saved as oh-my-zsh.txt
|
||||||
$ ef64 "oh-my-zsh"
|
$ ef64 "oh-my-zsh"
|
||||||
ohmyzsh.icn's content encoded in base64 and saved as ohmyzsh.icn.txt
|
oh-my-zsh's content encoded in base64 and saved as oh-my-zsh.txt
|
||||||
```
|
```
|
||||||
|
|
||||||
### Decoding
|
### Decoding
|
||||||
|
|||||||
@@ -2,24 +2,37 @@ encode64() {
|
|||||||
if [[ $# -eq 0 ]]; then
|
if [[ $# -eq 0 ]]; then
|
||||||
cat | base64
|
cat | base64
|
||||||
else
|
else
|
||||||
printf '%s' $1 | base64
|
printf '%s' "$1" | base64
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
encodefile64() {
|
encodefile64() {
|
||||||
if [[ $# -eq 0 ]]; then
|
if [[ $# -ne 1 || ! -f "$1" || ! -r "$1" ]]; then
|
||||||
echo "You must provide a filename"
|
print -u2 -- 'Usage: encodefile64 <file>'
|
||||||
else
|
return 1
|
||||||
base64 $1 > $1.txt
|
|
||||||
echo "${1}'s content encoded in base64 and saved as ${1}.txt"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
local file="$1" output="${1}.txt" tmp_file
|
||||||
|
[[ $output == /* ]] || output="./$output"
|
||||||
|
|
||||||
|
tmp_file=$(mktemp "${output}.XXXXXX") || return 1
|
||||||
|
if ! base64 < "$file" > "$tmp_file"; then
|
||||||
|
command rm -f "$tmp_file"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
if ! command mv "$tmp_file" "$output"; then
|
||||||
|
command rm -f "$tmp_file"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
print -- "$file's content encoded in base64 and saved as ${file}.txt"
|
||||||
}
|
}
|
||||||
|
|
||||||
decode64() {
|
decode64() {
|
||||||
if [[ $# -eq 0 ]]; then
|
if [[ $# -eq 0 ]]; then
|
||||||
cat | base64 --decode
|
cat | base64 -d
|
||||||
else
|
else
|
||||||
printf '%s' $1 | base64 --decode
|
printf '%s' "$1" | base64 -d
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
alias e64=encode64
|
alias e64=encode64
|
||||||
|
|||||||
@@ -0,0 +1,77 @@
|
|||||||
|
#!/usr/bin/env zsh
|
||||||
|
|
||||||
|
emulate -LR zsh
|
||||||
|
|
||||||
|
source "${1:-${0:A:h:h}/encode64.plugin.zsh}"
|
||||||
|
|
||||||
|
test_dir=$(mktemp -d) || exit 1
|
||||||
|
trap 'command rm -rf -- "$test_dir"' EXIT
|
||||||
|
cd "$test_dir" || exit 1
|
||||||
|
|
||||||
|
typeset -i failures=0 tests=0
|
||||||
|
typeset output expected_output
|
||||||
|
|
||||||
|
check_result() {
|
||||||
|
local description="$1" expected_status="$2" expected_stdout="$3" expected_stderr="$4"
|
||||||
|
shift 4
|
||||||
|
|
||||||
|
output=$("$@" 2> "$test_dir/stderr")
|
||||||
|
local actual_status=$?
|
||||||
|
(( tests++ ))
|
||||||
|
|
||||||
|
if [[ $actual_status == $expected_status && $output == "$expected_stdout" && $(<"$test_dir/stderr") == "$expected_stderr" ]]; then
|
||||||
|
print -r -- "PASS: $description"
|
||||||
|
else
|
||||||
|
print -u2 -r -- "FAIL: $description"
|
||||||
|
print -u2 -r -- " status: $actual_status (expected $expected_status)"
|
||||||
|
print -u2 -r -- " stdout: ${(qqq)output} (expected ${(qqq)expected_stdout})"
|
||||||
|
print -u2 -r -- " stderr: $(<"$test_dir/stderr") (expected $expected_stderr)"
|
||||||
|
(( failures++ ))
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
check_encode_arg() { encode64 'oh-my-zsh'; }
|
||||||
|
check_encode_empty() { encode64 ''; }
|
||||||
|
check_decode_arg() { decode64 'b2gtbXktenNo'; }
|
||||||
|
|
||||||
|
expected_output=$(printf '%s' 'oh-my-zsh' | base64)
|
||||||
|
check_result 'encode argument' 0 "$expected_output" '' check_encode_arg
|
||||||
|
check_result 'encode empty argument' 0 '' '' check_encode_empty
|
||||||
|
check_result 'decode argument' 0 'oh-my-zsh' '' check_decode_arg
|
||||||
|
|
||||||
|
file="$test_dir/file with spaces.txt"
|
||||||
|
print -r -- 'file contents' >| "$file"
|
||||||
|
encodefile64 "$file" > "$test_dir/stdout" 2> "$test_dir/stderr"
|
||||||
|
file_status=$?
|
||||||
|
expected_output=$(base64 < "$file")
|
||||||
|
(( tests++ ))
|
||||||
|
if [[ $file_status == 0 && $(<"${file}.txt") == "$expected_output" && $(<"$test_dir/stdout") == "$file's content encoded in base64 and saved as ${file}.txt" && ! -s "$test_dir/stderr" ]]; then
|
||||||
|
print -r -- 'PASS: encode file with spaces'
|
||||||
|
else
|
||||||
|
print -u2 -r -- 'FAIL: encode file with spaces'
|
||||||
|
(( failures++ ))
|
||||||
|
fi
|
||||||
|
|
||||||
|
check_invalid_file() { encodefile64 ''; }
|
||||||
|
check_result 'empty filename' 1 '' 'Usage: encodefile64 <file>' check_invalid_file
|
||||||
|
if [[ -e .txt ]]; then
|
||||||
|
print -u2 -r -- 'FAIL: empty filename created .txt'
|
||||||
|
(( failures++ ))
|
||||||
|
command rm -f .txt
|
||||||
|
fi
|
||||||
|
|
||||||
|
print -r -- 'preserve existing output' >| "${file}.txt"
|
||||||
|
base64() { return 42; }
|
||||||
|
encodefile64 "$file" > "$test_dir/stdout" 2> "$test_dir/stderr"
|
||||||
|
file_status=$?
|
||||||
|
unset -f base64
|
||||||
|
(( tests++ ))
|
||||||
|
if [[ $file_status != 0 && $(<"${file}.txt") == 'preserve existing output' && ! -s "$test_dir/stdout" ]]; then
|
||||||
|
print -r -- 'PASS: failed encoding preserves existing output'
|
||||||
|
else
|
||||||
|
print -u2 -r -- 'FAIL: failed encoding preserves existing output'
|
||||||
|
(( failures++ ))
|
||||||
|
fi
|
||||||
|
|
||||||
|
print -r -- "$tests tests, $failures failures"
|
||||||
|
(( failures == 0 ))
|
||||||
@@ -101,12 +101,14 @@ 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) (( $+commands[pbzip2] )) && pbzip2 -d "$full_path" || bunzip2 "$full_path" ;;
|
(*.bz2)
|
||||||
|
(( $+commands[pbzip2] )) && pbzip2 -cd "$full_path" > "${file:t:r}" \
|
||||||
|
|| bunzip2 -c "$full_path" > "${file:t:r}" ;;
|
||||||
(*.xz) xzcat "$full_path" > "${file:t:r}" ;;
|
(*.xz) xzcat "$full_path" > "${file:t:r}" ;;
|
||||||
(*.lrz) (( $+commands[lrunzip] )) && lrunzip "$full_path" ;;
|
(*.lrz) (( $+commands[lrunzip] )) && lrunzip "$full_path" ;;
|
||||||
(*.lz4) lz4 -d "$full_path" ;;
|
(*.lz4) lz4 -d "$full_path" ;;
|
||||||
(*.lzma) unlzma "$full_path" ;;
|
(*.lzma) unlzma -c "$full_path" > "${file:t:r}" ;;
|
||||||
(*.z) uncompress "$full_path" ;;
|
(*.z) uncompress -c "$full_path" > "${file:t:r}" ;;
|
||||||
(*.zip|*.war|*.jar|*.ear|*.sublime-package|*.ipa|*.ipsw|*.xpi|*.apk|*.aar|*.whl|*.vsix|*.crx|*.pk3|*.pk4) unzip "$full_path" ;;
|
(*.zip|*.war|*.jar|*.ear|*.sublime-package|*.ipa|*.ipsw|*.xpi|*.apk|*.aar|*.whl|*.vsix|*.crx|*.pk3|*.pk4) unzip "$full_path" ;;
|
||||||
(*.rar)
|
(*.rar)
|
||||||
if (( $+commands[unrar] )); then
|
if (( $+commands[unrar] )); then
|
||||||
@@ -119,7 +121,17 @@ EOF
|
|||||||
fi ;;
|
fi ;;
|
||||||
(*.rpm)
|
(*.rpm)
|
||||||
rpm2cpio "$full_path" | cpio --quiet -id ;;
|
rpm2cpio "$full_path" | cpio --quiet -id ;;
|
||||||
(*.7z | *.7z.[0-9]* | *.pk7) 7za x "$full_path" ;;
|
(*.7z | *.7z.[0-9]* | *.pk7)
|
||||||
|
if (( $+commands[7zz] )); then
|
||||||
|
7zz x "$full_path"
|
||||||
|
elif (( $+commands[7z] )); then
|
||||||
|
7z x "$full_path"
|
||||||
|
elif (( $+commands[7za] )); then
|
||||||
|
7za x "$full_path"
|
||||||
|
else
|
||||||
|
echo "extract: cannot extract 7z files: install 7zz, 7z or 7za" >&2
|
||||||
|
success=1
|
||||||
|
fi ;;
|
||||||
(*.deb)
|
(*.deb)
|
||||||
command mkdir -p "control" "data"
|
command mkdir -p "control" "data"
|
||||||
ar vx "$full_path" > /dev/null
|
ar vx "$full_path" > /dev/null
|
||||||
|
|||||||
@@ -0,0 +1,65 @@
|
|||||||
|
#!/usr/bin/env zsh
|
||||||
|
|
||||||
|
# Run with: zsh -df plugins/extract/tests/extract.test.zsh
|
||||||
|
emulate -L zsh
|
||||||
|
setopt err_return
|
||||||
|
|
||||||
|
for tool in lzma unlzma uncompress; do
|
||||||
|
(( $+commands[$tool] )) || {
|
||||||
|
print -u2 -r -- "These tests require $tool."
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
done
|
||||||
|
|
||||||
|
source "${0:A:h:h}/extract.plugin.zsh"
|
||||||
|
local test_dir=$(mktemp -d) original_dir=$PWD
|
||||||
|
|
||||||
|
check_extract() {
|
||||||
|
local extension=$1 mode=$2
|
||||||
|
local case_dir="$test_dir/$extension-$mode"
|
||||||
|
mkdir -p "$case_dir/source files" "$case_dir/work/target dir"
|
||||||
|
local archive="$case_dir/source files/sample.txt.$extension"
|
||||||
|
cp "$test_dir/fixture.$extension" "$archive"
|
||||||
|
builtin cd "$case_dir/work"
|
||||||
|
|
||||||
|
local output="$PWD/sample.txt"
|
||||||
|
local -a args
|
||||||
|
case "$mode" in
|
||||||
|
target)
|
||||||
|
args=(-t 'target dir')
|
||||||
|
output="$PWD/target dir/sample.txt"
|
||||||
|
;;
|
||||||
|
remove) args=(-r) ;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
# Run the plugin without the test's ERR_RETURN option.
|
||||||
|
() {
|
||||||
|
emulate -L zsh
|
||||||
|
extract "${args[@]}" "$archive"
|
||||||
|
} || return 1
|
||||||
|
cmp "$test_dir/plain" "$output"
|
||||||
|
if [[ $mode == remove ]]; then
|
||||||
|
[[ ! -e $archive ]]
|
||||||
|
else
|
||||||
|
[[ -f $archive ]]
|
||||||
|
fi
|
||||||
|
print -r -- "PASS: $extension ($mode)"
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
print -r -- hello > "$test_dir/plain"
|
||||||
|
lzma -c "$test_dir/plain" > "$test_dir/fixture.lzma"
|
||||||
|
# "hello\n" as a .Z stream, since many systems only ship uncompress.
|
||||||
|
printf '\037\235\220\150\312\260\141\363\106\001' \
|
||||||
|
> "$test_dir/fixture.Z"
|
||||||
|
|
||||||
|
for extension in lzma Z; do
|
||||||
|
for mode in default target remove; do
|
||||||
|
check_extract "$extension" "$mode"
|
||||||
|
done
|
||||||
|
done
|
||||||
|
print 'All extract compressed-file tests passed.'
|
||||||
|
} always {
|
||||||
|
builtin cd "$original_dir"
|
||||||
|
rm -rf -- "$test_dir"
|
||||||
|
}
|
||||||
@@ -7,6 +7,7 @@ if [[ -z "${CLOUDSDK_HOME}" ]]; then
|
|||||||
search_locations=(
|
search_locations=(
|
||||||
"$HOME/google-cloud-sdk"
|
"$HOME/google-cloud-sdk"
|
||||||
"/usr/local/share/google-cloud-sdk"
|
"/usr/local/share/google-cloud-sdk"
|
||||||
|
"/usr/local/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"
|
"/opt/homebrew/share/google-cloud-sdk"
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
# git-commit plugin
|
# git-commit plugin
|
||||||
|
|
||||||
The git-commit plugin adds several
|
The git-commit plugin adds several git subcommands for
|
||||||
[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.
|
[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:
|
||||||
@@ -31,15 +30,13 @@ Where `type` is one of the following:
|
|||||||
- `test`
|
- `test`
|
||||||
- `wip`
|
- `wip`
|
||||||
|
|
||||||
> NOTE: the alias for `revert` type is `rev`, as otherwise it conflicts with the git command of the same name.
|
> NOTE: the subcommand for `revert` type is `rev`, as otherwise it conflicts with the
|
||||||
> It will still generate a commit message in the format `revert: <message>`
|
> git command of the same name. 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 subcommand | 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 wip "work in progress"` | `git commit -m "work in progress"` |
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
./omz_git_commit
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
./omz_git_commit
|
||||||
+1
@@ -0,0 +1 @@
|
|||||||
|
./omz_git_commit
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
./omz_git_commit
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
./omz_git_commit
|
||||||
+1
@@ -0,0 +1 @@
|
|||||||
|
./omz_git_commit
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
./omz_git_commit
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
./omz_git_commit
|
||||||
+1
@@ -0,0 +1 @@
|
|||||||
|
./omz_git_commit
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
./omz_git_commit
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
./omz_git_commit
|
||||||
+1
@@ -0,0 +1 @@
|
|||||||
|
./omz_git_commit
|
||||||
+38
@@ -0,0 +1,38 @@
|
|||||||
|
#!/usr/bin/env zsh
|
||||||
|
|
||||||
|
_omz_git_commit() {
|
||||||
|
0=${(%):-%x}
|
||||||
|
if [[ "$0" != */git-* ]]; then
|
||||||
|
echo >&2 "Expecting command named git-foo. Got '$0'."
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
local _type="${0##*/git-}"
|
||||||
|
# The subcommand is shortened to avoid Git's built-in revert command.
|
||||||
|
if [[ "$_type" == rev ]]; then
|
||||||
|
_type=revert
|
||||||
|
fi
|
||||||
|
local _scope _attention _message
|
||||||
|
while [ $# -ne 0 ]; do
|
||||||
|
case $1 in
|
||||||
|
-s | --scope )
|
||||||
|
if [ -z $2 ]; then
|
||||||
|
echo >&2 "Missing scope!"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
_scope="$2"
|
||||||
|
shift 2
|
||||||
|
;;
|
||||||
|
-a | --attention )
|
||||||
|
_attention="!"
|
||||||
|
shift 1
|
||||||
|
;;
|
||||||
|
* )
|
||||||
|
_message="${_message} $1"
|
||||||
|
shift 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
git commit -m "${_type}${_scope:+(${_scope})}${_attention}:${_message}"
|
||||||
|
}
|
||||||
|
_omz_git_commit "$@"
|
||||||
@@ -1,58 +1,45 @@
|
|||||||
local _rev="$(git -C $ZSH rev-parse HEAD 2> /dev/null)"
|
# Add git-commit commands directory to path
|
||||||
if [[ $_rev == $(git config --global --get oh-my-zsh.git-commit-alias 2> /dev/null) ]]; then
|
0="${${ZERO:-${0:#$ZSH_ARGZERO}}:-${(%):-%N}}"
|
||||||
return
|
0="${${(M)0:#/*}:-$PWD/$0}"
|
||||||
fi
|
path=("${0:a:h}/git-commands" $path)
|
||||||
git config --global oh-my-zsh.git-commit-alias "$_rev"
|
|
||||||
|
|
||||||
local -a _git_commit_aliases
|
# Append completions for custom git commands
|
||||||
_git_commit_aliases=(
|
() {
|
||||||
'build'
|
local -a git_user_commands
|
||||||
'chore'
|
zstyle -a ':completion:*:*:git:*' user-commands 'git_user_commands' \
|
||||||
'ci'
|
|| git_user_commands=()
|
||||||
'docs'
|
git_user_commands+=(
|
||||||
'feat'
|
build:'Commit with a message indicating a build' \
|
||||||
'fix'
|
chore:'Commit with a message indicating a chore' \
|
||||||
'perf'
|
ci:'Commit with a message indicating a CI change' \
|
||||||
'refactor'
|
docs:'Commit with a message indicating an update to the documentation' \
|
||||||
'revert'
|
feat:'Commit with a message indicating a feature' \
|
||||||
'style'
|
fix:'Commit with a message indicating a fix' \
|
||||||
'test'
|
perf:'Commit with a message indicating a performance enhancement' \
|
||||||
'wip'
|
refactor:'Commit with a message indicating a refactor' \
|
||||||
)
|
rev:'Commit with a message indicating a revert' \
|
||||||
|
style:'Commit with a message indicating a style change' \
|
||||||
|
test:'Commit with a message indicating updates to tests' \
|
||||||
|
wip:'Commit with a message indicating a work in progress'
|
||||||
|
)
|
||||||
|
zstyle ':completion:*:*:git:*' user-commands "${git_user_commands[@]}"
|
||||||
|
}
|
||||||
|
|
||||||
local _alias _type
|
# Clean up aliases from the prior implementation of git-commit. Keep this migration
|
||||||
for _type in "${_git_commit_aliases[@]}"; do
|
# for users upgrading from versions that still wrote aliases to .gitconfig.
|
||||||
# an alias can't be named "revert" because the git command takes precedence
|
() {
|
||||||
# https://stackoverflow.com/a/3538791
|
git config --global --get oh-my-zsh.git-commit-alias &> /dev/null || return 0
|
||||||
case "$_type" in
|
local -a old_git_aliases=(
|
||||||
revert) _alias=rev ;;
|
'build' 'chore' 'ci'
|
||||||
*) _alias=$_type ;;
|
'docs' 'feat' 'fix'
|
||||||
esac
|
'perf' 'refactor' 'rev'
|
||||||
|
'style' 'test' 'wip'
|
||||||
local _func='!a() {
|
)
|
||||||
local _scope _attention _message
|
local git_alias
|
||||||
while [ $# -ne 0 ]; do
|
for git_alias in $old_git_aliases; do
|
||||||
case $1 in
|
if [[ "$(git config --global --get alias.$git_alias | tr '\n' ' ')" == "!a() { local _scope _attention _message"* ]]; then
|
||||||
-s | --scope )
|
git config --global --unset alias.$git_alias
|
||||||
if [ -z $2 ]; then
|
|
||||||
echo "Missing scope!"
|
|
||||||
return 1
|
|
||||||
fi
|
fi
|
||||||
_scope="$2"
|
done
|
||||||
shift 2
|
git config --global --unset oh-my-zsh.git-commit-alias
|
||||||
;;
|
}
|
||||||
-a | --attention )
|
|
||||||
_attention="!"
|
|
||||||
shift 1
|
|
||||||
;;
|
|
||||||
* )
|
|
||||||
_message="${_message} $1"
|
|
||||||
shift 1
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
git commit -m "'$_type'${_scope:+(${_scope})}${_attention}:${_message}"
|
|
||||||
}; a'
|
|
||||||
|
|
||||||
git config --global alias.$_alias "$_func"
|
|
||||||
done
|
|
||||||
@@ -191,6 +191,7 @@ plugins=(... git)
|
|||||||
| `grmc` | `git rm --cached` |
|
| `grmc` | `git rm --cached` |
|
||||||
| `gcount` | `git shortlog --summary -n` |
|
| `gcount` | `git shortlog --summary -n` |
|
||||||
| `gsh` | `git show` |
|
| `gsh` | `git show` |
|
||||||
|
| `gshs` | `git show --stat` |
|
||||||
| `gsps` | `git show --pretty=short --show-signature` |
|
| `gsps` | `git show --pretty=short --show-signature` |
|
||||||
| `gstall` | `git stash --all` |
|
| `gstall` | `git stash --all` |
|
||||||
| `gstu` | `git stash --include-untracked` |
|
| `gstu` | `git stash --include-untracked` |
|
||||||
|
|||||||
@@ -392,6 +392,7 @@ alias grm='git rm'
|
|||||||
alias grmc='git rm --cached'
|
alias grmc='git rm --cached'
|
||||||
alias gcount='git shortlog --summary --numbered'
|
alias gcount='git shortlog --summary --numbered'
|
||||||
alias gsh='git show'
|
alias gsh='git show'
|
||||||
|
alias gshs='git show --stat'
|
||||||
alias gsps='git show --pretty=short --show-signature'
|
alias gsps='git show --pretty=short --show-signature'
|
||||||
alias gstall='git stash --all'
|
alias gstall='git stash --all'
|
||||||
alias gstaa='git stash apply'
|
alias gstaa='git stash apply'
|
||||||
|
|||||||
@@ -4,7 +4,11 @@ globalias() {
|
|||||||
# (A) makes it an array even if there's only one element
|
# (A) makes it an array even if there's only one element
|
||||||
local word=${${(Az)LBUFFER}[-1]}
|
local word=${${(Az)LBUFFER}[-1]}
|
||||||
if [[ $GLOBALIAS_FILTER_VALUES[(Ie)$word] -eq 0 ]]; then
|
if [[ $GLOBALIAS_FILTER_VALUES[(Ie)$word] -eq 0 ]]; then
|
||||||
zle _expand_alias
|
# Completion also considers quoted strings and assignment values as aliases.
|
||||||
|
# Only expand when the complete shell word is an alias name.
|
||||||
|
if (( ${+aliases[$word]} || ${+galiases[$word]} )); then
|
||||||
|
zle _expand_alias
|
||||||
|
fi
|
||||||
zle expand-word
|
zle expand-word
|
||||||
fi
|
fi
|
||||||
zle self-insert
|
zle self-insert
|
||||||
|
|||||||
@@ -0,0 +1,81 @@
|
|||||||
|
#!/usr/bin/env zsh
|
||||||
|
|
||||||
|
# Exercise the actual ZLE widgets in an isolated interactive shell.
|
||||||
|
emulate -L zsh
|
||||||
|
setopt err_return
|
||||||
|
zmodload zsh/zpty
|
||||||
|
zmodload zsh/zselect
|
||||||
|
|
||||||
|
local test_dir=$(mktemp -d)
|
||||||
|
export GLOBALIAS_TEST_PLUGIN=${0:A:h:h}/globalias.plugin.zsh
|
||||||
|
export GLOBALIAS_TEST_RESULT=$test_dir/result
|
||||||
|
|
||||||
|
wait_for_marker() {
|
||||||
|
local marker=$1 output received
|
||||||
|
local -i deadline=$(( SECONDS + 5 ))
|
||||||
|
while (( SECONDS < deadline )); do
|
||||||
|
if zpty -r globalias-test output; then
|
||||||
|
received+=$output
|
||||||
|
[[ $received == *$marker* ]] && return 0
|
||||||
|
else
|
||||||
|
zselect -t 1 || true
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
print -u2 -r -- "Timed out waiting for ZLE: $received"
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
|
check_expansion() {
|
||||||
|
local input=$1 expected=$2 actual
|
||||||
|
zpty -w -n globalias-test "$input"$' \x18'
|
||||||
|
wait_for_marker GLOBALIAS_TEST_CAPTURED
|
||||||
|
actual=$(< "$GLOBALIAS_TEST_RESULT")
|
||||||
|
if [[ $actual != "$expected" ]]; then
|
||||||
|
print -u2 -r -- "Input: ${(qqq)input}"
|
||||||
|
print -u2 -r -- "Expected: ${(qqq)expected}; got: ${(qqq)actual}"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
cat > "$test_dir/setup.zsh" <<'SETUP'
|
||||||
|
autoload -Uz compinit
|
||||||
|
compinit -D
|
||||||
|
source "$GLOBALIAS_TEST_PLUGIN"
|
||||||
|
alias 1='cd -1'
|
||||||
|
alias ll='ls -l'
|
||||||
|
alias -g G='| grep'
|
||||||
|
GLOBALIAS_FILTER_VALUES=(ll)
|
||||||
|
_globalias_test_capture() {
|
||||||
|
print -rn -- "$BUFFER" > "$GLOBALIAS_TEST_RESULT"
|
||||||
|
print -r -- $'\nGLOBALIAS_TEST_CAPTURED'
|
||||||
|
BUFFER=
|
||||||
|
zle .accept-line
|
||||||
|
}
|
||||||
|
zle -N _globalias_test_capture
|
||||||
|
bindkey '^X' _globalias_test_capture
|
||||||
|
PS1='GLOBALIAS_TEST_READY> '
|
||||||
|
RPROMPT=
|
||||||
|
SETUP
|
||||||
|
zpty -b globalias-test zsh -dfi
|
||||||
|
zpty -w globalias-test "source ${(q)test_dir}/setup.zsh"
|
||||||
|
wait_for_marker GLOBALIAS_TEST_READY
|
||||||
|
|
||||||
|
check_expansion 'DEBUG=1' 'DEBUG=1 '
|
||||||
|
check_expansion 'DEBUG="1"' 'DEBUG="1" '
|
||||||
|
check_expansion "DEBUG='1'" "DEBUG='1' "
|
||||||
|
check_expansion '1' 'cd -1 '
|
||||||
|
check_expansion '"1"' '"1" '
|
||||||
|
check_expansion "'1'" "'1' "
|
||||||
|
check_expansion '\1' '\1 '
|
||||||
|
check_expansion 'echo G' 'echo | grep '
|
||||||
|
check_expansion 'DEBUG=1 1' 'DEBUG=1 cd -1 '
|
||||||
|
check_expansion 'll' 'll '
|
||||||
|
check_expansion 'echo $((1+2))' 'echo 3 '
|
||||||
|
check_expansion 'echo {a,b}' 'echo a b '
|
||||||
|
check_expansion '' ' '
|
||||||
|
print 'All globalias expansion tests passed.'
|
||||||
|
} always {
|
||||||
|
zpty -d globalias-test 2>/dev/null || true
|
||||||
|
rm -rf -- "$test_dir"
|
||||||
|
}
|
||||||
@@ -5,10 +5,40 @@ Applies some fixes for some common issues encountered with [GPG's gpg-agent](htt
|
|||||||
More specifically, this plugin:
|
More specifically, this plugin:
|
||||||
|
|
||||||
- Updates the `GPG_TTY` environment variable before each shell execution.
|
- Updates the `GPG_TTY` environment variable before each shell execution.
|
||||||
- Updates the `SSH_AUTH_SOCK` environment variable if `enable-ssh-support` is turned on.
|
- Updates the `SSH_AUTH_SOCK` environment variable if `gpg-agent` is your SSH
|
||||||
|
agent. By default the plugin checks whether `enable-ssh-support` is turned
|
||||||
|
on. The [`ssh-support` setting](#settings) lets you say so yourself.
|
||||||
|
|
||||||
To use it, add `gpg-agent` to the plugins array of your zshrc file:
|
To use it, add `gpg-agent` to the plugins array of your zshrc file:
|
||||||
|
|
||||||
```zsh
|
```zsh
|
||||||
plugins=(... gpg-agent)
|
plugins=(... gpg-agent)
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Settings
|
||||||
|
|
||||||
|
Every time a shell starts, the plugin runs `gpgconf --list-options gpg-agent` to
|
||||||
|
find out whether `enable-ssh-support` is turned on. That check can be slow. If
|
||||||
|
you already know the answer, state it with the `ssh-support` style and the
|
||||||
|
plugin skips the check. Set it in your zshrc, before Oh My Zsh is sourced.
|
||||||
|
|
||||||
|
If you don't use `gpg-agent` as your SSH agent:
|
||||||
|
|
||||||
|
```zsh
|
||||||
|
zstyle ':omz:plugins:gpg-agent' ssh-support no
|
||||||
|
```
|
||||||
|
|
||||||
|
The plugin then only sets `GPG_TTY`. It leaves `SSH_AUTH_SOCK` alone, and it
|
||||||
|
doesn't update the agent's tty before each command, which only SSH support
|
||||||
|
needs.
|
||||||
|
|
||||||
|
If you do use `gpg-agent` as your SSH agent:
|
||||||
|
|
||||||
|
```zsh
|
||||||
|
zstyle ':omz:plugins:gpg-agent' ssh-support yes
|
||||||
|
```
|
||||||
|
|
||||||
|
The plugin then sets `SSH_AUTH_SOCK` without checking. `enable-ssh-support`
|
||||||
|
still has to be set in your `gpg-agent.conf` for SSH to work.
|
||||||
|
|
||||||
|
Leave the style unset to keep the automatic check.
|
||||||
@@ -1,5 +1,16 @@
|
|||||||
export GPG_TTY=$TTY
|
export GPG_TTY=$TTY
|
||||||
|
|
||||||
|
# The ssh-support style says whether gpg-agent is used as the ssh agent.
|
||||||
|
# Setting it saves asking gpgconf, which can be slow.
|
||||||
|
zstyle -t ':omz:plugins:gpg-agent' ssh-support
|
||||||
|
_gpg_agent_ssh_support=$? # 0 if yes, 1 if no, 2 if not set
|
||||||
|
|
||||||
|
# Everything below is only needed for ssh support
|
||||||
|
if (( _gpg_agent_ssh_support == 1 )); then
|
||||||
|
unset _gpg_agent_ssh_support
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
# Fix for passphrase prompt on the correct tty
|
# Fix for passphrase prompt on the correct tty
|
||||||
# See https://www.gnupg.org/documentation/manuals/gnupg/Agent-Options.html#option-_002d_002denable_002dssh_002dsupport
|
# See https://www.gnupg.org/documentation/manuals/gnupg/Agent-Options.html#option-_002d_002denable_002dssh_002dsupport
|
||||||
function _gpg-agent_update-tty_preexec {
|
function _gpg-agent_update-tty_preexec {
|
||||||
@@ -9,9 +20,13 @@ autoload -U add-zsh-hook
|
|||||||
add-zsh-hook preexec _gpg-agent_update-tty_preexec
|
add-zsh-hook preexec _gpg-agent_update-tty_preexec
|
||||||
|
|
||||||
# If enable-ssh-support is set, fix ssh agent integration
|
# If enable-ssh-support is set, fix ssh agent integration
|
||||||
if [[ $(gpgconf --list-options gpg-agent 2>/dev/null | awk -F: '$1=="enable-ssh-support" {print $10}') = 1 ]]; then
|
if (( _gpg_agent_ssh_support == 0 )) \
|
||||||
|
|| [[ $(gpgconf --list-options gpg-agent 2>/dev/null \
|
||||||
|
| awk -F: '$1=="enable-ssh-support" {print $10}') = 1 ]]; then
|
||||||
unset SSH_AGENT_PID
|
unset SSH_AGENT_PID
|
||||||
if [[ "${gnupg_SSH_AUTH_SOCK_by:-0}" -ne $$ ]]; then
|
if [[ "${gnupg_SSH_AUTH_SOCK_by:-0}" -ne $$ ]]; then
|
||||||
export SSH_AUTH_SOCK="$(gpgconf --list-dirs agent-ssh-socket)"
|
export SSH_AUTH_SOCK="$(gpgconf --list-dirs agent-ssh-socket)"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
unset _gpg_agent_ssh_support
|
||||||
@@ -112,6 +112,37 @@ plugins=(... hcloud)
|
|||||||
| hcst | `hcloud server-type list` | List all server types |
|
| hcst | `hcloud server-type list` | List all server types |
|
||||||
| hcit | `hcloud image list --type system` | List all system images |
|
| hcit | `hcloud image list --type system` | List all system images |
|
||||||
|
|
||||||
|
## Prompt function
|
||||||
|
|
||||||
|
This plugin provides `hcloud_prompt_info` which can be added to your prompt to display the current Hetzner Cloud context.
|
||||||
|
|
||||||
|
- If `HCLOUD_TOKEN` environment variable is set, it displays `HCLOUD_TOKEN` (indicating direct token usage)
|
||||||
|
- Otherwise, it displays the active context name
|
||||||
|
|
||||||
|
### Usage
|
||||||
|
|
||||||
|
Add `$(hcloud_prompt_info)` to your `PROMPT` or `RPROMPT` in your `.zshrc`:
|
||||||
|
|
||||||
|
```zsh
|
||||||
|
RPROMPT='$(hcloud_prompt_info)'
|
||||||
|
```
|
||||||
|
|
||||||
|
### Theme variables
|
||||||
|
|
||||||
|
| Variable | Default | Description |
|
||||||
|
| :----------------------------- | :-------------- | :----------------------------------------------- |
|
||||||
|
| `ZSH_THEME_HCLOUD_PREFIX` | `<hcloud:` | Prefix before the context name |
|
||||||
|
| `ZSH_THEME_HCLOUD_SUFFIX` | `>` | Suffix after the context name |
|
||||||
|
| `ZSH_THEME_HCLOUD_TOKEN_TEXT` | `HCLOUD_TOKEN` | Text shown when `HCLOUD_TOKEN` env var is set |
|
||||||
|
|
||||||
|
### Example with custom styling
|
||||||
|
|
||||||
|
```zsh
|
||||||
|
ZSH_THEME_HCLOUD_PREFIX="%{$fg[blue]%}hcloud:("
|
||||||
|
ZSH_THEME_HCLOUD_SUFFIX=")%{$reset_color%}"
|
||||||
|
RPROMPT='$(hcloud_prompt_info)'
|
||||||
|
```
|
||||||
|
|
||||||
## Requirements
|
## Requirements
|
||||||
|
|
||||||
This plugin requires the [Hetzner Cloud CLI](https://github.com/hetznercloud/cli) to be installed.
|
This plugin requires the [Hetzner Cloud CLI](https://github.com/hetznercloud/cli) to be installed.
|
||||||
|
|||||||
@@ -131,3 +131,20 @@ alias hcdc='hcloud datacenter list'
|
|||||||
alias hcloc='hcloud location list'
|
alias hcloc='hcloud location list'
|
||||||
alias hcst='hcloud server-type list'
|
alias hcst='hcloud server-type list'
|
||||||
alias hcit='hcloud image list --type system'
|
alias hcit='hcloud image list --type system'
|
||||||
|
|
||||||
|
# Prompt function to display current hcloud context
|
||||||
|
# Usage: add $(hcloud_prompt_info) to your PROMPT or RPROMPT
|
||||||
|
function hcloud_prompt_info() {
|
||||||
|
# Check if HCLOUD_TOKEN is set (overrides context)
|
||||||
|
if [[ -n "$HCLOUD_TOKEN" ]]; then
|
||||||
|
echo "${ZSH_THEME_HCLOUD_PREFIX=<hcloud:}${ZSH_THEME_HCLOUD_TOKEN_TEXT=HCLOUD_TOKEN}${ZSH_THEME_HCLOUD_SUFFIX=>}"
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Get active context
|
||||||
|
local context
|
||||||
|
context=$(hcloud context active 2>/dev/null)
|
||||||
|
[[ -n "$context" ]] || return
|
||||||
|
|
||||||
|
echo "${ZSH_THEME_HCLOUD_PREFIX=<hcloud:}${context}${ZSH_THEME_HCLOUD_SUFFIX=>}"
|
||||||
|
}
|
||||||
@@ -70,7 +70,7 @@ plugins=(... jj)
|
|||||||
|
|
||||||
## Prompt usage
|
## Prompt usage
|
||||||
|
|
||||||
Because `jj` has a very powerful [template syntax](https://martinvonz.github.io/jj/latest/templates/), this
|
Because `jj` has a very powerful [template syntax](https://docs.jj-vcs.dev/latest/templates/), this
|
||||||
plugin only exposes a convenience function `jj_prompt_template` to read information from the current change.
|
plugin only exposes a convenience function `jj_prompt_template` to read information from the current change.
|
||||||
It is basically the same as `jj log --no-graph -r @ -T $1`:
|
It is basically the same as `jj log --no-graph -r @ -T $1`:
|
||||||
|
|
||||||
|
|||||||
@@ -22,14 +22,17 @@ fi
|
|||||||
# Define json tools for each method
|
# Define json tools for each method
|
||||||
case "$JSONTOOLS_METHOD" in
|
case "$JSONTOOLS_METHOD" in
|
||||||
node)
|
node)
|
||||||
# node doesn't make it easy to deal with stdin, so we pass it as an argument with xargs -0
|
# Read stdin directly so input is not limited by command-line argument size.
|
||||||
function pp_json() {
|
function pp_json() {
|
||||||
xargs -0 node -e 'console.log(JSON.stringify(JSON.parse(process.argv[1]), null, 4));'
|
node -e '
|
||||||
|
const input = require("fs").readFileSync(0, "utf8");
|
||||||
|
console.log(JSON.stringify(JSON.parse(input), null, 4));
|
||||||
|
'
|
||||||
}
|
}
|
||||||
function is_json() {
|
function is_json() {
|
||||||
xargs -0 node -e '
|
node -e '
|
||||||
try {
|
try {
|
||||||
json = JSON.parse(process.argv[1]);
|
JSON.parse(require("fs").readFileSync(0, "utf8"));
|
||||||
console.log("true");
|
console.log("true");
|
||||||
process.exit(0);
|
process.exit(0);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
@@ -39,10 +42,14 @@ case "$JSONTOOLS_METHOD" in
|
|||||||
'
|
'
|
||||||
}
|
}
|
||||||
function urlencode_json() {
|
function urlencode_json() {
|
||||||
xargs -0 node -e "console.log(encodeURIComponent(process.argv[1]))"
|
node -e '
|
||||||
|
console.log(encodeURIComponent(require("fs").readFileSync(0, "utf8")));
|
||||||
|
'
|
||||||
}
|
}
|
||||||
function urldecode_json() {
|
function urldecode_json() {
|
||||||
xargs -0 node -e "console.log(decodeURIComponent(process.argv[1]))"
|
node -e '
|
||||||
|
console.log(decodeURIComponent(require("fs").readFileSync(0, "utf8")));
|
||||||
|
'
|
||||||
}
|
}
|
||||||
;;
|
;;
|
||||||
python3)
|
python3)
|
||||||
@@ -79,8 +86,7 @@ print(unquote_plus(sys.stdin.read()))
|
|||||||
function pp_json() {
|
function pp_json() {
|
||||||
ruby -e '
|
ruby -e '
|
||||||
require "json"
|
require "json"
|
||||||
require "yaml"
|
puts JSON.pretty_generate(JSON.parse(STDIN.read), indent: " ")
|
||||||
puts JSON.parse(STDIN.read).to_yaml
|
|
||||||
'
|
'
|
||||||
}
|
}
|
||||||
function is_json() {
|
function is_json() {
|
||||||
|
|||||||
@@ -0,0 +1,54 @@
|
|||||||
|
#!/usr/bin/env zsh
|
||||||
|
|
||||||
|
# Run with: zsh -df plugins/jsontools/tests/jsontools-ruby.test.zsh
|
||||||
|
emulate -L zsh
|
||||||
|
setopt err_return
|
||||||
|
|
||||||
|
(( $+commands[ruby] )) || {
|
||||||
|
print -u2 'These tests require Ruby.'
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
JSONTOOLS_METHOD=ruby
|
||||||
|
source "${0:A:h:h}/jsontools.plugin.zsh"
|
||||||
|
local test_dir=$(mktemp -d)
|
||||||
|
|
||||||
|
check_output() {
|
||||||
|
local tool=$1 description=$2 expected_status=${3:-0}
|
||||||
|
local -i result=0
|
||||||
|
$tool < "$test_dir/input" > "$test_dir/actual" || result=$?
|
||||||
|
if (( result != expected_status )) \
|
||||||
|
|| ! cmp -s "$test_dir/expected" "$test_dir/actual"; then
|
||||||
|
print -u2 -r -- "FAIL: $description ($tool exited $result)"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
print -r -- "PASS: $description"
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
# pp_json prints JSON with the same 4-space indent as the node and python3 methods.
|
||||||
|
print -rn -- '{"value":42}' > "$test_dir/input"
|
||||||
|
printf '{\n "value": 42\n}\n' > "$test_dir/expected"
|
||||||
|
check_output pp_json 'pretty-print a small document'
|
||||||
|
|
||||||
|
print -rn -- '{"list":[1,"two"],"nested":{"a":null,"b":true}}' > "$test_dir/input"
|
||||||
|
printf '{\n "list": [\n 1,\n "two"\n ],\n "nested": {\n "a": null,\n "b": true\n }\n}\n' \
|
||||||
|
> "$test_dir/expected"
|
||||||
|
check_output pp_json 'pretty-print a nested document'
|
||||||
|
|
||||||
|
printf '{"a":1}\n[2]\n' > "$test_dir/input"
|
||||||
|
printf '{\n "a": 1\n}\n[\n 2\n]\n' > "$test_dir/expected"
|
||||||
|
check_output pp_ndjson 'pretty-print NDJSON'
|
||||||
|
|
||||||
|
print -rn -- '{"value":42}' > "$test_dir/input"
|
||||||
|
print -r -- true > "$test_dir/expected"
|
||||||
|
check_output is_json 'validate a document'
|
||||||
|
|
||||||
|
print -rn -- '{invalid}' > "$test_dir/input"
|
||||||
|
print -r -- false > "$test_dir/expected"
|
||||||
|
check_output is_json 'reject invalid JSON' 1
|
||||||
|
|
||||||
|
print 'All jsontools Ruby tests passed.'
|
||||||
|
} always {
|
||||||
|
rm -rf -- "$test_dir"
|
||||||
|
}
|
||||||
@@ -0,0 +1,64 @@
|
|||||||
|
#!/usr/bin/env zsh
|
||||||
|
|
||||||
|
# Run with: zsh -df plugins/jsontools/tests/jsontools.test.zsh
|
||||||
|
emulate -L zsh
|
||||||
|
setopt err_return
|
||||||
|
|
||||||
|
(( $+commands[node] )) || {
|
||||||
|
print -u2 'These tests require Node.js.'
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
JSONTOOLS_METHOD=node
|
||||||
|
source "${0:A:h:h}/jsontools.plugin.zsh"
|
||||||
|
local test_dir=$(mktemp -d)
|
||||||
|
|
||||||
|
check_output() {
|
||||||
|
local tool=$1 description=$2 expected_status=${3:-0}
|
||||||
|
local -i result=0
|
||||||
|
$tool < "$test_dir/input" > "$test_dir/actual" || result=$?
|
||||||
|
if (( result != expected_status )) \
|
||||||
|
|| ! cmp -s "$test_dir/expected" "$test_dir/actual"; then
|
||||||
|
print -u2 -r -- "FAIL: $description ($tool exited $result)"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
print -r -- "PASS: $description"
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
print -rn -- '{"value":42}' > "$test_dir/input"
|
||||||
|
printf '{\n "value": 42\n}\n' > "$test_dir/expected"
|
||||||
|
check_output pp_json 'pretty-print a small document'
|
||||||
|
|
||||||
|
# Larger than the 128 KiB limit for a single command-line argument.
|
||||||
|
local large_value=${(l:262144::x:):-}
|
||||||
|
print -rn -- '{"value":"'"$large_value"'"}' > "$test_dir/input"
|
||||||
|
printf '{\n "value": "%s"\n}\n' "$large_value" > "$test_dir/expected"
|
||||||
|
check_output pp_json 'pretty-print a large document'
|
||||||
|
print -r -- true > "$test_dir/expected"
|
||||||
|
check_output is_json 'validate a large document'
|
||||||
|
|
||||||
|
print -r -- '%7B%22value%22%3A%22'"$large_value"'%22%7D' \
|
||||||
|
> "$test_dir/expected"
|
||||||
|
check_output urlencode_json 'encode a large document'
|
||||||
|
local encoded=$(< "$test_dir/expected")
|
||||||
|
print -rn -- "$encoded" > "$test_dir/input"
|
||||||
|
print -r -- '{"value":"'"$large_value"'"}' > "$test_dir/expected"
|
||||||
|
check_output urldecode_json 'decode a large document'
|
||||||
|
|
||||||
|
# Passed as an argument, node used to parse this as its own option.
|
||||||
|
print -rn -- '--version' > "$test_dir/input"
|
||||||
|
print -r -- '--version' > "$test_dir/expected"
|
||||||
|
check_output urlencode_json 'encode input that starts with --'
|
||||||
|
|
||||||
|
print -rn -- '{invalid}' > "$test_dir/input"
|
||||||
|
print -r -- false > "$test_dir/expected"
|
||||||
|
check_output is_json 'reject invalid JSON' 1
|
||||||
|
|
||||||
|
printf '1\0002' > "$test_dir/input"
|
||||||
|
check_output is_json 'reject input with NUL bytes' 1
|
||||||
|
|
||||||
|
print 'All jsontools Node.js tests passed.'
|
||||||
|
} always {
|
||||||
|
rm -rf -- "$test_dir"
|
||||||
|
}
|
||||||
@@ -6,6 +6,21 @@ This plugin adds aliases and autocompletion for Laravel [Artisan](https://larave
|
|||||||
plugins=(... laravel)
|
plugins=(... laravel)
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Settings
|
||||||
|
|
||||||
|
By default the aliases run `php artisan`. To use a different PHP command, such as
|
||||||
|
`herd php` (which runs the PHP version the [Laravel Herd](https://herd.laravel.com) site
|
||||||
|
is isolated to, instead of Herd's global version) or a specific version like `php8.4`,
|
||||||
|
set this before Oh My Zsh is sourced:
|
||||||
|
|
||||||
|
```zsh
|
||||||
|
zstyle ':omz:plugins:laravel' php 'herd php'
|
||||||
|
```
|
||||||
|
|
||||||
|
`php` in the aliases below is then replaced with that command.
|
||||||
|
|
||||||
|
## Aliases
|
||||||
|
|
||||||
| Alias | Description |
|
| Alias | Description |
|
||||||
|:-:|:-:|
|
|:-:|:-:|
|
||||||
| `artisan` | `php artisan` |
|
| `artisan` | `php artisan` |
|
||||||
|
|||||||
@@ -1,51 +1,56 @@
|
|||||||
#!zsh
|
#!zsh
|
||||||
alias artisan='php artisan'
|
# Command used to run artisan, e.g. `herd php` or `php8.4` (default: `php`)
|
||||||
alias bob='php artisan bob::build'
|
zstyle -s ':omz:plugins:laravel' php _omz_laravel_php || _omz_laravel_php=php
|
||||||
|
|
||||||
|
alias artisan="$_omz_laravel_php artisan"
|
||||||
|
alias bob="$_omz_laravel_php artisan bob::build"
|
||||||
|
|
||||||
# Development
|
# Development
|
||||||
alias pas='php artisan serve'
|
alias pas="$_omz_laravel_php artisan serve"
|
||||||
alias pad='php artisan dev'
|
alias pad="$_omz_laravel_php artisan dev"
|
||||||
alias pats='php artisan test'
|
alias pats="$_omz_laravel_php artisan test"
|
||||||
|
|
||||||
# Database
|
# Database
|
||||||
alias pam='php artisan migrate'
|
alias pam="$_omz_laravel_php artisan migrate"
|
||||||
alias pamf='php artisan migrate:fresh'
|
alias pamf="$_omz_laravel_php artisan migrate:fresh"
|
||||||
alias pamfs='php artisan migrate:fresh --seed'
|
alias pamfs="$_omz_laravel_php artisan migrate:fresh --seed"
|
||||||
alias pamr='php artisan migrate:rollback'
|
alias pamr="$_omz_laravel_php artisan migrate:rollback"
|
||||||
alias pads='php artisan db:seed'
|
alias pads="$_omz_laravel_php artisan db:seed"
|
||||||
alias padw='php artisan db:wipe'
|
alias padw="$_omz_laravel_php artisan db:wipe"
|
||||||
|
|
||||||
# Makers
|
# Makers
|
||||||
alias pamm='php artisan make:model'
|
alias pamm="$_omz_laravel_php artisan make:model"
|
||||||
alias pamc='php artisan make:controller'
|
alias pamc="$_omz_laravel_php artisan make:controller"
|
||||||
alias pams='php artisan make:seeder'
|
alias pams="$_omz_laravel_php artisan make:seeder"
|
||||||
alias pamt='php artisan make:test'
|
alias pamt="$_omz_laravel_php artisan make:test"
|
||||||
alias pamfa='php artisan make:factory'
|
alias pamfa="$_omz_laravel_php artisan make:factory"
|
||||||
alias pamp='php artisan make:policy'
|
alias pamp="$_omz_laravel_php artisan make:policy"
|
||||||
alias pame='php artisan make:event'
|
alias pame="$_omz_laravel_php artisan make:event"
|
||||||
alias pamj='php artisan make:job'
|
alias pamj="$_omz_laravel_php artisan make:job"
|
||||||
alias paml='php artisan make:listener'
|
alias paml="$_omz_laravel_php artisan make:listener"
|
||||||
alias pamn='php artisan make:notification'
|
alias pamn="$_omz_laravel_php artisan make:notification"
|
||||||
alias pampp='php artisan make:provider'
|
alias pampp="$_omz_laravel_php artisan make:provider"
|
||||||
alias pamcl='php artisan make:class'
|
alias pamcl="$_omz_laravel_php artisan make:class"
|
||||||
alias pamen='php artisan make:enum'
|
alias pamen="$_omz_laravel_php artisan make:enum"
|
||||||
alias pami='php artisan make:interface'
|
alias pami="$_omz_laravel_php artisan make:interface"
|
||||||
alias pamtr='php artisan make:trait'
|
alias pamtr="$_omz_laravel_php artisan make:trait"
|
||||||
alias pamv='php artisan make:view'
|
alias pamv="$_omz_laravel_php artisan make:view"
|
||||||
alias pammig='php artisan make:migration'
|
alias pammig="$_omz_laravel_php artisan make:migration"
|
||||||
|
|
||||||
|
|
||||||
# Clears
|
# Clears
|
||||||
alias pacac='php artisan cache:clear'
|
alias pacac="$_omz_laravel_php artisan cache:clear"
|
||||||
alias pacoc='php artisan config:clear'
|
alias pacoc="$_omz_laravel_php artisan config:clear"
|
||||||
alias pavic='php artisan view:clear'
|
alias pavic="$_omz_laravel_php artisan view:clear"
|
||||||
alias paroc='php artisan route:clear'
|
alias paroc="$_omz_laravel_php artisan route:clear"
|
||||||
alias paopc='php artisan optimize:clear'
|
alias paopc="$_omz_laravel_php artisan optimize:clear"
|
||||||
|
|
||||||
# queues
|
# queues
|
||||||
alias paqf='php artisan queue:failed'
|
alias paqf="$_omz_laravel_php artisan queue:failed"
|
||||||
alias paqft='php artisan queue:failed-table'
|
alias paqft="$_omz_laravel_php artisan queue:failed-table"
|
||||||
alias paql='php artisan queue:listen'
|
alias paql="$_omz_laravel_php artisan queue:listen"
|
||||||
alias paqr='php artisan queue:retry'
|
alias paqr="$_omz_laravel_php artisan queue:retry"
|
||||||
alias paqt='php artisan queue:table'
|
alias paqt="$_omz_laravel_php artisan queue:table"
|
||||||
alias paqw='php artisan queue:work'
|
alias paqw="$_omz_laravel_php artisan queue:work"
|
||||||
|
|
||||||
|
unset _omz_laravel_php
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
# logcli plugin
|
||||||
|
|
||||||
|
This plugin adds completion for [Grafana Loki's logcli](https://grafana.com/docs/loki/latest/query/logcli/).
|
||||||
|
|
||||||
|
To use it, add `logcli` to the plugins array in your zshrc file:
|
||||||
|
|
||||||
|
```zsh
|
||||||
|
plugins=(... logcli)
|
||||||
|
```
|
||||||
|
|
||||||
|
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/_logcli`.
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
# Autocompletion for Grafana Loki's CLI (logcli).
|
||||||
|
if (( ! $+commands[logcli] )); then
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
# If the completion file doesn't exist yet, we need to autoload it and
|
||||||
|
# bind it to `logcli`. Otherwise, compinit will have already done that.
|
||||||
|
if [[ ! -f "$ZSH_CACHE_DIR/completions/_logcli" ]]; then
|
||||||
|
typeset -g -A _comps
|
||||||
|
autoload -Uz _logcli
|
||||||
|
_comps[logcli]=_logcli
|
||||||
|
fi
|
||||||
|
|
||||||
|
zmodload -F zsh/files b:zf_mv
|
||||||
|
() {
|
||||||
|
local TMPPREFIX="$ZSH_CACHE_DIR/completions/._logcli"
|
||||||
|
zf_mv -f -- =( logcli --completion-script-zsh ) "$ZSH_CACHE_DIR/completions/_logcli"
|
||||||
|
} &|
|
||||||
@@ -30,6 +30,7 @@ man-command-line() {
|
|||||||
else
|
else
|
||||||
BUFFER="man ${args[1]}"
|
BUFFER="man ${args[1]}"
|
||||||
fi
|
fi
|
||||||
|
zle end-of-line
|
||||||
}
|
}
|
||||||
|
|
||||||
zle -N man-command-line
|
zle -N man-command-line
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
if (( $+commands[mise] )); then
|
if (( $+commands[mise] )); then
|
||||||
_mise_bin=mise
|
_mise_bin=$commands[mise]
|
||||||
elif [[ -x ~/.local/bin/mise ]]; then
|
elif [[ -x ~/.local/bin/mise ]]; then
|
||||||
_mise_bin=~/.local/bin/mise
|
_mise_bin=~/.local/bin/mise
|
||||||
else
|
else
|
||||||
@@ -8,7 +8,6 @@ fi
|
|||||||
|
|
||||||
# Load mise hooks
|
# Load mise hooks
|
||||||
eval "$($_mise_bin activate zsh)"
|
eval "$($_mise_bin activate zsh)"
|
||||||
unset _mise_bin
|
|
||||||
|
|
||||||
# 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.
|
||||||
@@ -18,9 +17,13 @@ if [[ ! -f "$ZSH_CACHE_DIR/completions/_mise" ]]; then
|
|||||||
_comps[mise]=_mise
|
_comps[mise]=_mise
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Generate and load mise completion
|
# Generate completion only when missing/empty or stale relative to the mise binary.
|
||||||
zmodload -F zsh/files b:zf_mv
|
if [[ ! -s "$ZSH_CACHE_DIR/completions/_mise" || "$_mise_bin" -nt "$ZSH_CACHE_DIR/completions/_mise" ]]; then
|
||||||
() {
|
zmodload -F zsh/files b:zf_mv
|
||||||
local TMPPREFIX="$ZSH_CACHE_DIR/completions/._mise"
|
() {
|
||||||
zf_mv -f -- =( mise completion zsh ) "$ZSH_CACHE_DIR/completions/_mise"
|
local TMPPREFIX="$ZSH_CACHE_DIR/completions/._mise"
|
||||||
} &|
|
zf_mv -f -- =( "$_mise_bin" completion zsh ) "$ZSH_CACHE_DIR/completions/_mise"
|
||||||
|
} &|
|
||||||
|
fi
|
||||||
|
|
||||||
|
unset _mise_bin
|
||||||
@@ -30,6 +30,8 @@ if it's found, or the mvn command otherwise.
|
|||||||
| `mvncisto` | `mvn clean install -DskipTests --offline` |
|
| `mvncisto` | `mvn clean install -DskipTests --offline` |
|
||||||
| `mvncom` | `mvn compile` |
|
| `mvncom` | `mvn compile` |
|
||||||
| `mvncp` | `mvn clean package` |
|
| `mvncp` | `mvn clean package` |
|
||||||
|
| `mvncpst` | `mvn clean package -DskipTests` |
|
||||||
|
| `mvncpsto` | `mvn clean package -DskipTests --offline` |
|
||||||
| `mvnct` | `mvn clean test` |
|
| `mvnct` | `mvn clean test` |
|
||||||
| `mvncv` | `mvn clean verify` |
|
| `mvncv` | `mvn clean verify` |
|
||||||
| `mvncvst` | `mvn clean verify -DskipTests` |
|
| `mvncvst` | `mvn clean verify -DskipTests` |
|
||||||
|
|||||||
@@ -59,6 +59,8 @@ alias mvncist='mvn clean install -DskipTests'
|
|||||||
alias mvncisto='mvn clean install -DskipTests --offline'
|
alias mvncisto='mvn clean install -DskipTests --offline'
|
||||||
alias mvncom='mvn compile'
|
alias mvncom='mvn compile'
|
||||||
alias mvncp='mvn clean package'
|
alias mvncp='mvn clean package'
|
||||||
|
alias mvncpst='mvn clean package -DskipTests'
|
||||||
|
alias mvncpsto='mvn clean package -DskipTests --offline'
|
||||||
alias mvnct='mvn clean test'
|
alias mvnct='mvn clean test'
|
||||||
alias mvncv='mvn clean verify'
|
alias mvncv='mvn clean verify'
|
||||||
alias mvncvst='mvn clean verify -DskipTests'
|
alias mvncvst='mvn clean verify -DskipTests'
|
||||||
@@ -347,6 +349,13 @@ function listMavenCompletions {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
compctl -K listMavenCompletions mvn mvnw
|
# Completion, via compsys so that tools built on it (fzf-tab, etc.) can take over.
|
||||||
compctl -K listMavenCompletions mvn-color
|
_mvn() {
|
||||||
compctl -K listMavenCompletions mvn-or-mvnw
|
local -a commands
|
||||||
|
listMavenCompletions
|
||||||
|
# _describe splits entries on `:`, so escape it to keep goals like `dependency:tree`.
|
||||||
|
commands=("${(@)reply//:/\\:}")
|
||||||
|
_describe -t mvn-commands 'mvn command' commands
|
||||||
|
}
|
||||||
|
|
||||||
|
compdef _mvn mvn mvnw mvn-color mvn-or-mvnw
|
||||||
@@ -16,7 +16,7 @@ plugins=(... npm)
|
|||||||
| `npmS` | `npm i -S` | Install and save to dependencies in your package.json |
|
| `npmS` | `npm i -S` | Install and save to dependencies in your package.json |
|
||||||
| `npmD` | `npm i -D` | Install and save to dev-dependencies in your package.json |
|
| `npmD` | `npm i -D` | Install and save to dev-dependencies in your package.json |
|
||||||
| `npmF` | `npm i -f` | Force install from remote registries ignoring local cache |
|
| `npmF` | `npm i -f` | Force install from remote registries ignoring local cache |
|
||||||
| `npmE` | `PATH="$(npm bin)":"$PATH"` | Run command from node_modules folder based on current directory |
|
| `npmE` | `PATH="$(npm root)/.bin":"$PATH"` | Run command from node_modules folder based on current directory |
|
||||||
| `npmO` | `npm outdated` | Check which npm modules are outdated |
|
| `npmO` | `npm outdated` | Check which npm modules are outdated |
|
||||||
| `npmU` | `npm update` | Update all the packages listed to the latest version |
|
| `npmU` | `npm update` | Update all the packages listed to the latest version |
|
||||||
| `npmV` | `npm -v` | Check package versions |
|
| `npmV` | `npm -v` | Check package versions |
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ alias npmF='npm i -f'
|
|||||||
|
|
||||||
# Execute command from node_modules folder based on current directory
|
# Execute command from node_modules folder based on current directory
|
||||||
# i.e npmE gulp
|
# i.e npmE gulp
|
||||||
alias npmE='PATH="$(npm bin)":"$PATH"'
|
alias npmE='PATH="$(npm root)/.bin":"$PATH"'
|
||||||
|
|
||||||
# Check which npm modules are outdated
|
# Check which npm modules are outdated
|
||||||
alias npmO="npm outdated"
|
alias npmO="npm outdated"
|
||||||
|
|||||||
@@ -0,0 +1,111 @@
|
|||||||
|
# opencode plugin
|
||||||
|
|
||||||
|
This plugin adds completion and aliases for the [OpenCode](https://opencode.ai) CLI.
|
||||||
|
Install OpenCode using its [installation instructions](https://opencode.ai/docs/#install),
|
||||||
|
and make sure `opencode` is available on your `$PATH`.
|
||||||
|
|
||||||
|
To enable it, add `opencode` to the plugins array in your `.zshrc`:
|
||||||
|
|
||||||
|
```zsh
|
||||||
|
plugins=(... opencode)
|
||||||
|
```
|
||||||
|
|
||||||
|
## Learning OpenCode from the terminal
|
||||||
|
|
||||||
|
Use tab completion to explore commands and their descriptions without leaving the
|
||||||
|
shell. For example, these are some of the candidates shown by the CLI:
|
||||||
|
|
||||||
|
```text
|
||||||
|
$ opencode <TAB>
|
||||||
|
agent -- manage agents
|
||||||
|
models -- list all available models
|
||||||
|
run -- run opencode with a message
|
||||||
|
session -- manage sessions
|
||||||
|
stats -- show token usage and cost statistics
|
||||||
|
...
|
||||||
|
|
||||||
|
$ opencode session <TAB>
|
||||||
|
delete -- delete a session
|
||||||
|
list -- list sessions
|
||||||
|
|
||||||
|
$ opencode run --<TAB>
|
||||||
|
--agent -- agent to use
|
||||||
|
--continue -- continue the last session
|
||||||
|
--file -- file(s) to attach to message
|
||||||
|
--model -- model to use in the format of provider/model
|
||||||
|
...
|
||||||
|
```
|
||||||
|
|
||||||
|
Completion works through the aliases too. Type a partial command or option and
|
||||||
|
press Tab to finish it:
|
||||||
|
|
||||||
|
```text
|
||||||
|
$ opc session li<TAB>
|
||||||
|
$ opc session list
|
||||||
|
|
||||||
|
$ opcr --att<TAB>
|
||||||
|
$ opcr --attach
|
||||||
|
|
||||||
|
$ opcc --log-l<TAB>
|
||||||
|
$ opcc --log-level
|
||||||
|
```
|
||||||
|
|
||||||
|
Candidates depend on your installed OpenCode version. In OpenCode 1.18.29, the
|
||||||
|
CLI's completion output omits top-level TUI flags such as `--model` and `--fork`,
|
||||||
|
even though those flags work when typed. Use `opencode --help` or
|
||||||
|
`opencode run --help` for the full options, and see the
|
||||||
|
[CLI reference](https://opencode.ai/docs/cli/) for more workflows.
|
||||||
|
|
||||||
|
## Aliases
|
||||||
|
|
||||||
|
| Alias | Command | Description |
|
||||||
|
| ------ | --------------------- | ----------------------------------- |
|
||||||
|
| `opc` | `opencode` | Launch the terminal UI |
|
||||||
|
| `opcc` | `opencode --continue` | Continue the last session |
|
||||||
|
| `opcr` | `opencode run` | Run a prompt without opening the UI |
|
||||||
|
|
||||||
|
To keep completion but skip the aliases, set this in your `.zshrc`, above the line
|
||||||
|
that sources Oh My Zsh:
|
||||||
|
|
||||||
|
```zsh
|
||||||
|
# ~/.zshrc
|
||||||
|
zstyle ':omz:plugins:opencode' aliases no
|
||||||
|
|
||||||
|
plugins=(... opencode)
|
||||||
|
|
||||||
|
source $ZSH/oh-my-zsh.sh
|
||||||
|
```
|
||||||
|
|
||||||
|
## Common workflows
|
||||||
|
|
||||||
|
All aliases accept additional arguments:
|
||||||
|
|
||||||
|
```zsh
|
||||||
|
# Open a project
|
||||||
|
opc ~/projects/my-app
|
||||||
|
|
||||||
|
# Explore a different approach by forking the last session
|
||||||
|
opcc --fork
|
||||||
|
|
||||||
|
# Ask a question without entering the terminal UI
|
||||||
|
opcr "Explain the test setup in this project"
|
||||||
|
|
||||||
|
# Reuse an already running backend to avoid MCP server cold starts
|
||||||
|
opcr --attach http://localhost:4096 "Explain this project's architecture"
|
||||||
|
```
|
||||||
|
|
||||||
|
## Completion
|
||||||
|
|
||||||
|
Completion queries the installed OpenCode CLI on demand for commands and options,
|
||||||
|
including through the aliases above. It falls back to Zsh's default completion when
|
||||||
|
the CLI returns no candidates. No OpenCode process is started at shell startup,
|
||||||
|
and no generated completion cache is needed.
|
||||||
|
|
||||||
|
## Credits
|
||||||
|
|
||||||
|
Based on the OpenCode plugin proposals by
|
||||||
|
[pranavavva](https://github.com/pranavavva) in
|
||||||
|
[#13545](https://github.com/ohmyzsh/ohmyzsh/pull/13545) and
|
||||||
|
[mskadu](https://github.com/mskadu) in
|
||||||
|
[#13794](https://github.com/ohmyzsh/ohmyzsh/pull/13794).
|
||||||
|
The completion adapter is derived from OpenCode's `opencode completion` output.
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
#compdef opencode
|
||||||
|
|
||||||
|
# Adapted from `opencode completion`, using the CLI's live Yargs completions.
|
||||||
|
local -a reply
|
||||||
|
reply=("${(@f)$(COMP_CWORD="$((CURRENT-1))" COMP_LINE="$BUFFER" COMP_POINT="$CURSOR" \
|
||||||
|
command opencode --get-yargs-completions "${words[@]}" < /dev/null 2> /dev/null)}")
|
||||||
|
|
||||||
|
if [[ -n "${reply[1]}" ]]; then
|
||||||
|
_describe 'values' reply
|
||||||
|
else
|
||||||
|
_default
|
||||||
|
fi
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
if (( ! $+commands[opencode] )); then
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
alias opc='opencode'
|
||||||
|
alias opcc='opencode --continue'
|
||||||
|
alias opcr='opencode run'
|
||||||
@@ -28,11 +28,11 @@ plugins=(... poetry)
|
|||||||
| prm | `poetry remove` | Remove packages from `pyproject.toml` and uninstall them |
|
| prm | `poetry remove` | Remove packages from `pyproject.toml` and uninstall them |
|
||||||
| prun | `poetry run` | Executes the given command inside the project’s virtualenv |
|
| prun | `poetry run` | Executes the given command inside the project’s virtualenv |
|
||||||
| psad | `poetry self add` | Add the Poetry plugin and install dependencies to make it work |
|
| psad | `poetry self add` | Add the Poetry plugin and install dependencies to make it work |
|
||||||
| psh | `poetry shell` | Spawns a shell within the virtual environment. If one doesn’t exist, it will be created |
|
| psh | `poetry shell` | Spawns a shell within the virtual environment. With Poetry 2.0+ and no shell plugin, activates it with `poetry env activate` |
|
||||||
| pshw | `poetry show` | List all the available dependencies |
|
| pshw | `poetry show` | List all the available dependencies |
|
||||||
| pslt | `poetry show --latest` | List latest version of the dependencies |
|
| pslt | `poetry show --latest` | List latest version of the dependencies |
|
||||||
| psup | `poetry self update` | Update Poetry to the latest version (default) or to the specified version |
|
| psup | `poetry self update` | Update Poetry to the latest version (default) or to the specified version |
|
||||||
| psync | `poetry install --sync` | Synchronize your environment with the `poetry.lock` |
|
| psync | `poetry sync` | Synchronize your environment with the `poetry.lock` (`poetry install --sync` before Poetry 2.0) |
|
||||||
| ptree | `poetry show --tree` | List the dependencies as tree |
|
| ptree | `poetry show --tree` | List the dependencies as tree |
|
||||||
| pup | `poetry update` | Get the latest versions of the dependencies and to update the `poetry.lock` |
|
| pup | `poetry update` | Get the latest versions of the dependencies and to update the `poetry.lock` |
|
||||||
| pvinf | `poetry env info` | Get basic information about the currently activated virtualenv |
|
| pvinf | `poetry env info` | Get basic information about the currently activated virtualenv |
|
||||||
|
|||||||
@@ -14,11 +14,9 @@ alias ppub='poetry publish'
|
|||||||
alias prm='poetry remove'
|
alias prm='poetry remove'
|
||||||
alias prun='poetry run'
|
alias prun='poetry run'
|
||||||
alias psad='poetry self add'
|
alias psad='poetry self add'
|
||||||
alias psh='poetry shell'
|
|
||||||
alias pshw='poetry show'
|
alias pshw='poetry show'
|
||||||
alias pslt='poetry show --latest'
|
alias pslt='poetry show --latest'
|
||||||
alias psup='poetry self update'
|
alias psup='poetry self update'
|
||||||
alias psync='poetry install --sync'
|
|
||||||
alias ptree='poetry show --tree'
|
alias ptree='poetry show --tree'
|
||||||
alias pup='poetry update'
|
alias pup='poetry update'
|
||||||
alias pvinf='poetry env info'
|
alias pvinf='poetry env info'
|
||||||
@@ -26,6 +24,25 @@ alias pvoff='poetry config virtualenvs.create false'
|
|||||||
alias pvrm='poetry env remove'
|
alias pvrm='poetry env remove'
|
||||||
alias pvu='poetry env use'
|
alias pvu='poetry env use'
|
||||||
|
|
||||||
|
# Poetry 2.0 moved `poetry shell` to the poetry-plugin-shell plugin, so fall
|
||||||
|
# back to activating the virtualenv in the current shell when it's missing.
|
||||||
|
function psh {
|
||||||
|
if poetry shell --help &>/dev/null; then
|
||||||
|
poetry shell "$@"
|
||||||
|
else
|
||||||
|
eval "$(poetry env activate)"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Poetry 2.0 replaced `poetry install --sync` with `poetry sync`.
|
||||||
|
function psync {
|
||||||
|
if poetry sync --help &>/dev/null; then
|
||||||
|
poetry sync "$@"
|
||||||
|
else
|
||||||
|
poetry install --sync "$@"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
# Return immediately if poetry is not found
|
# Return immediately if poetry is not found
|
||||||
if (( ! $+commands[poetry] )); then
|
if (( ! $+commands[poetry] )); then
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
# Pre-commit plugin
|
# Pre-commit plugin
|
||||||
|
|
||||||
This plugin adds aliases for common commands of [pre-commit](https://pre-commit.com/).
|
This plugin adds aliases for common commands of [pre-commit](https://pre-commit.com/).
|
||||||
It also supports [prek](https://github.com/prek/prek) as a drop-in replacement.
|
It also supports [prek](https://github.com/j178/prek) as a drop-in replacement.
|
||||||
If `prek` is available, it will be used; otherwise, `pre-commit` is used as fallback.
|
If `prek` is available, it will be used; otherwise, `pre-commit` is used as fallback.
|
||||||
|
|
||||||
To use this plugin, add it to the plugins array in your zshrc file:
|
To use this plugin, add it to the plugins array in your zshrc file:
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ function pyuserpaths() {
|
|||||||
|
|
||||||
# Get minor release version.
|
# Get minor release version.
|
||||||
# The patch version is variable length, truncate it.
|
# The patch version is variable length, truncate it.
|
||||||
version=${(M)${"$($python -V 2>&1)":7}#[^.]##.[^.]##}
|
version=${(M)${"$($python -V 2>&1)":7}##[^.]##.[^.]##}
|
||||||
|
|
||||||
# Add version specific path, if:
|
# Add version specific path, if:
|
||||||
# - it exists in the filesystem
|
# - it exists in the filesystem
|
||||||
|
|||||||
@@ -3,6 +3,8 @@
|
|||||||
The primary job of this plugin is to provide `rbenv_prompt_info` which can be added to your theme to include Ruby
|
The primary job of this plugin is to provide `rbenv_prompt_info` which can be added to your theme to include Ruby
|
||||||
version and gemset information into your prompt.
|
version and gemset information into your prompt.
|
||||||
|
|
||||||
|
Additionally, this plugin provides completion for the `rbenv` command. See also <https://github.com/rbenv/rbenv/#shell-completions>.
|
||||||
|
|
||||||
Some functionality of this plugin will not work unless you also have the rbenv plugin *gemset* installed.
|
Some functionality of this plugin will not work unless you also have the rbenv plugin *gemset* installed.
|
||||||
https://github.com/jf/rbenv-gemset
|
https://github.com/jf/rbenv-gemset
|
||||||
|
|
||||||
|
|||||||
@@ -24,6 +24,13 @@ if [[ $FOUND_RBENV -ne 1 ]]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ $FOUND_RBENV -eq 1 ]]; then
|
if [[ $FOUND_RBENV -eq 1 ]]; then
|
||||||
|
rbenv_completions="${commands[rbenv]:A:h:h}/completions"
|
||||||
|
if [[ -f "$rbenv_completions/_rbenv" ]]; then
|
||||||
|
fpath+=("$rbenv_completions")
|
||||||
|
autoload -Uz _rbenv
|
||||||
|
compdef _rbenv rbenv
|
||||||
|
fi
|
||||||
|
|
||||||
eval "$(rbenv init --no-rehash - zsh)"
|
eval "$(rbenv init --no-rehash - zsh)"
|
||||||
|
|
||||||
alias rubies="rbenv versions"
|
alias rubies="rbenv versions"
|
||||||
@@ -65,4 +72,4 @@ else
|
|||||||
}
|
}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
unset FOUND_RBENV rbenvdirs dir
|
unset FOUND_RBENV rbenvdirs dir rbenv_completions
|
||||||
@@ -14,9 +14,9 @@ plugins=(... ruby)
|
|||||||
| ------- | -------------------------------------- | ---------------------------------------------------- |
|
| ------- | -------------------------------------- | ---------------------------------------------------- |
|
||||||
| rb | `ruby` | The Ruby command |
|
| rb | `ruby` | The Ruby command |
|
||||||
| sgem | `sudo gem` | Run sudo gem on the system ruby, not the active ruby |
|
| sgem | `sudo gem` | Run sudo gem on the system ruby, not the active ruby |
|
||||||
| rfind | `find . -name "*.rb" \| xargs grep -n` | Find ruby file |
|
| rfind | `find . -name "*.rb" -print0 \| xargs -0 grep -n` | Find ruby file |
|
||||||
| rrun | `ruby -e` | Execute some code: E.g: `rrun "puts 'Hello world!'"` |
|
| rrun | `ruby -e` | Execute some code: E.g: `rrun "puts 'Hello world!'"` |
|
||||||
| rserver | `ruby -e httpd . -p 8080` | Start HTTP Webrick serving local directory/files |
|
| rserver | `ruby -run -e httpd . -p 8080` | Start HTTP Webrick serving local directory/files |
|
||||||
| gein | `gem install` | Install a gem into the local repository |
|
| gein | `gem install` | Install a gem into the local repository |
|
||||||
| geun | `gem uninstall` | Uninstall gems from the local repository |
|
| geun | `gem uninstall` | Uninstall gems from the local repository |
|
||||||
| geli | `gem list` | Display gems installed locally |
|
| geli | `gem list` | Display gems installed locally |
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
alias sgem='sudo gem'
|
alias sgem='sudo gem'
|
||||||
|
|
||||||
# Find ruby file
|
# Find ruby file
|
||||||
alias rfind='find . -name "*.rb" | xargs grep -n'
|
alias rfind='find . -name "*.rb" -print0 | xargs -0 grep -n'
|
||||||
|
|
||||||
# Shorthand Ruby
|
# Shorthand Ruby
|
||||||
alias rb="ruby"
|
alias rb="ruby"
|
||||||
|
|||||||
@@ -0,0 +1,32 @@
|
|||||||
|
#!/usr/bin/env zsh
|
||||||
|
|
||||||
|
emulate -LR zsh
|
||||||
|
|
||||||
|
source "${1:-${0:A:h:h}/ruby.plugin.zsh}"
|
||||||
|
|
||||||
|
test_dir=$(mktemp -d) || exit 1
|
||||||
|
trap 'command rm -rf -- "$test_dir"' EXIT
|
||||||
|
|
||||||
|
typeset -i failures=0 tests=0
|
||||||
|
typeset filename output
|
||||||
|
|
||||||
|
for filename in plain.rb 'file with spaces.rb' "single'quote.rb" 'double"quote.rb' $'line\nbreak.rb' 'unicode-ą.rb'; do
|
||||||
|
print -r -- 'needle' >| "$test_dir/$filename"
|
||||||
|
output=$(cd "$test_dir" && rfind needle 2> "$test_dir/stderr")
|
||||||
|
actual_status=$?
|
||||||
|
(( tests++ ))
|
||||||
|
|
||||||
|
if [[ $actual_status == 0 && $output == '1:needle' && ! -s "$test_dir/stderr" ]]; then
|
||||||
|
print -r -- "PASS: ${(qqq)filename}"
|
||||||
|
else
|
||||||
|
print -u2 -r -- "FAIL: ${(qqq)filename} (status $actual_status)"
|
||||||
|
print -u2 -r -- " stdout: ${(qqq)output}"
|
||||||
|
print -u2 -r -- " stderr: $(<"$test_dir/stderr")"
|
||||||
|
(( failures++ ))
|
||||||
|
fi
|
||||||
|
|
||||||
|
command rm -- "$test_dir/$filename"
|
||||||
|
done
|
||||||
|
|
||||||
|
print -r -- "$tests tests, $failures failures"
|
||||||
|
(( failures == 0 ))
|
||||||
+1
-1
@@ -237,7 +237,7 @@ case "$words[1]" in
|
|||||||
'(-c|--noancestors)'{-c,--noancestors}'[do not include second-generation package ancestors in the scratch org]' \
|
'(-c|--noancestors)'{-c,--noancestors}'[do not include second-generation package ancestors in the scratch org]' \
|
||||||
'(-i|--clientid)'{-i,--clientid}'[connected app consumer key]' \
|
'(-i|--clientid)'{-i,--clientid}'[connected app consumer key]' \
|
||||||
'(-s|--setdefaultusername)'{-s,--setdefaultusername}'[set the created org as the default username]' \
|
'(-s|--setdefaultusername)'{-s,--setdefaultusername}'[set the created org as the default username]' \
|
||||||
'(-a|--setalias)'{-a,--setalias}'[set an alias for for the created scratch org]' \
|
'(-a|--setalias)'{-a,--setalias}'[set an alias for the created scratch org]' \
|
||||||
'(-e|--env)'{-e,--env}'[environment where the scratch org is created: \[sandbox*,virtual,prototype\] (sandbox*,virtual,prototype)]' \
|
'(-e|--env)'{-e,--env}'[environment where the scratch org is created: \[sandbox*,virtual,prototype\] (sandbox*,virtual,prototype)]' \
|
||||||
'(-w|--wait)'{-w,--wait}'[the streaming client socket timeout (in minutes) (default:6, min:2)]' \
|
'(-w|--wait)'{-w,--wait}'[the streaming client socket timeout (in minutes) (default:6, min:2)]' \
|
||||||
'(-d|--durationdays)'{-d,--durationdays}'[duration of the scratch org (in days) (default:7, min:1, max:30)]' \
|
'(-d|--durationdays)'{-d,--durationdays}'[duration of the scratch org (in days) (default:7, min:1, max:30)]' \
|
||||||
|
|||||||
@@ -14,5 +14,5 @@ fi
|
|||||||
zmodload -F zsh/files b:zf_mv
|
zmodload -F zsh/files b:zf_mv
|
||||||
() {
|
() {
|
||||||
local TMPPREFIX="$ZSH_CACHE_DIR/completions/._sops"
|
local TMPPREFIX="$ZSH_CACHE_DIR/completions/._sops"
|
||||||
zf_mv -f -- =( sops completions zsh ) "$ZSH_CACHE_DIR/completions/_sops"
|
zf_mv -f -- =( sops completion zsh ) "$ZSH_CACHE_DIR/completions/_sops"
|
||||||
} &|
|
} &|
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
#!/usr/bin/env zsh
|
||||||
|
|
||||||
|
# Run with: zsh -df plugins/timer/tests/timer.test.zsh
|
||||||
|
emulate -L zsh
|
||||||
|
|
||||||
|
source "${0:A:h:h}/timer.plugin.zsh"
|
||||||
|
|
||||||
|
typeset -i failures=0 tests=0
|
||||||
|
|
||||||
|
check_duration() {
|
||||||
|
local precision=$1 duration=$2 expected=$3
|
||||||
|
local output=$(TIMER_PRECISION=$precision __timer_format_duration $duration)
|
||||||
|
(( tests++ ))
|
||||||
|
|
||||||
|
if [[ $output == "$expected" ]]; then
|
||||||
|
print -r -- "PASS: $duration with precision $precision -> $output"
|
||||||
|
else
|
||||||
|
print -u2 -r -- "FAIL: $duration with precision $precision -> $output (expected $expected)"
|
||||||
|
(( failures++ ))
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
check_duration 1 0.04 /0.0s
|
||||||
|
check_duration 1 3.04 /3.0s
|
||||||
|
check_duration 1 40.0 /40.0s
|
||||||
|
check_duration 1 59.94 /59.9s
|
||||||
|
check_duration 1 59.97 /1m0.0s
|
||||||
|
check_duration 1 61.5 /1m1.5s
|
||||||
|
check_duration 1 73.0 /1m13.0s
|
||||||
|
check_duration 1 119.97 /2m0.0s
|
||||||
|
check_duration 1 3599.99 /60m0.0s
|
||||||
|
check_duration 2 59.996 /1m0.00s
|
||||||
|
check_duration 2 0.02 /0.02s
|
||||||
|
check_duration 0 1.4 /1s
|
||||||
|
check_duration 0 59.6 /1m0s
|
||||||
|
check_duration 0 119.5 /2m0s
|
||||||
|
|
||||||
|
print -r -- "$tests tests, $failures failures"
|
||||||
|
(( failures == 0 ))
|
||||||
@@ -6,8 +6,14 @@ __timer_current_time() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
__timer_format_duration() {
|
__timer_format_duration() {
|
||||||
local mins=$(printf '%.0f' $(($(IFS='.' read int dec <<< "$1"; echo $int) / 60)))
|
local -i precision=${TIMER_PRECISION:-1}
|
||||||
local secs=$(printf "%.${TIMER_PRECISION:-1}f" $(($1 - 60 * mins)))
|
local -i scale=$(( 10 ** precision ))
|
||||||
|
# Round to the displayed precision before splitting off the minutes,
|
||||||
|
# so that e.g. 59.97s is shown as 1m0.0s instead of 60.0s
|
||||||
|
local -i units
|
||||||
|
(( units = $1 * scale + 0.5 ))
|
||||||
|
local -i mins=$(( units / (60 * scale) ))
|
||||||
|
local secs=$(printf "%.${precision}f" $(( (units - 60 * scale * mins) / (scale * 1.0) )))
|
||||||
local duration_str=$(echo "${mins}m${secs}s")
|
local duration_str=$(echo "${mins}m${secs}s")
|
||||||
local format="${TIMER_FORMAT:-/%d}"
|
local format="${TIMER_FORMAT:-/%d}"
|
||||||
echo "${format//\%d/${duration_str#0m}}"
|
echo "${format//\%d/${duration_str#0m}}"
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ tldr-command-line() {
|
|||||||
args=(${${(Az)BUFFER}[1]} ${${(Az)BUFFER}[2]})
|
args=(${${(Az)BUFFER}[1]} ${${(Az)BUFFER}[2]})
|
||||||
|
|
||||||
BUFFER="tldr ${args[1]}"
|
BUFFER="tldr ${args[1]}"
|
||||||
|
zle end-of-line
|
||||||
}
|
}
|
||||||
|
|
||||||
zle -N tldr-command-line
|
zle -N tldr-command-line
|
||||||
|
|||||||
+12
-12
@@ -15,18 +15,18 @@ The plugin also supports the following:
|
|||||||
|
|
||||||
## Aliases
|
## Aliases
|
||||||
|
|
||||||
| Alias | Command | Description |
|
| Alias | Command | Description |
|
||||||
| ---------- | -------------------------- | -------------------------------------------------------- |
|
| ---------- | -------------------------------------- | -------------------------------------------------------- |
|
||||||
| `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 |
|
||||||
| `tds` | `_tmux_directory_session` | Creates or attaches to a session for the current path |
|
| `tds` | `_tmux_directory_session` | Creates or attaches to a session for the current path |
|
||||||
| `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 |
|
| `tksv` | tmux kill-server | Terminate all running tmux sessions |
|
||||||
| `tl` | tmux list-sessions | Displays a list of running tmux sessions |
|
| `tl` | tmux list-sessions | Displays a list of running tmux sessions |
|
||||||
| `to` | tmux new-session -A -s | Create or attach to a named tmux session |
|
| `to` | tmux new-session -A -s | Create or attach to a named tmux session |
|
||||||
| `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` | `${(z)EDITOR:-vim} "$ZSH_TMUX_CONFIG"` | Open .tmux.conf file with an editor. |
|
||||||
| `ts` | tmux new-session -s | Create a new named tmux session |
|
| `ts` | tmux new-session -s | Create a new named tmux session |
|
||||||
|
|
||||||
## Configuration Variables
|
## Configuration Variables
|
||||||
|
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ function _build_tmux_alias {
|
|||||||
|
|
||||||
alias tksv='tmux kill-server'
|
alias tksv='tmux kill-server'
|
||||||
alias tl='tmux list-sessions'
|
alias tl='tmux list-sessions'
|
||||||
alias tmuxconf='$EDITOR $ZSH_TMUX_CONFIG'
|
alias tmuxconf='${(z)EDITOR:-vim} "$ZSH_TMUX_CONFIG"'
|
||||||
|
|
||||||
_build_tmux_alias "ta" "attach" "-t"
|
_build_tmux_alias "ta" "attach" "-t"
|
||||||
_build_tmux_alias "tad" "attach -d" "-t"
|
_build_tmux_alias "tad" "attach -d" "-t"
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ The plugin will generate a default archive filename based on the input:
|
|||||||
|
|
||||||
| Format | Description | Tool Used |
|
| Format | Description | Tool Used |
|
||||||
|:-----------------|:-------------------------------|:-----------------|
|
|:-----------------|:-------------------------------|:-----------------|
|
||||||
| `7z` | 7zip archive | `7z` |
|
| `7z` | 7zip archive | `7zz`,`7z`,`7za` |
|
||||||
| `bz2` | Bzip2-compressed file | `bzip2` |
|
| `bz2` | Bzip2-compressed file | `bzip2` |
|
||||||
| `gz` | Gzip-compressed file | `gzip` |
|
| `gz` | Gzip-compressed file | `gzip` |
|
||||||
| `lzma` | LZMA-compressed file | `lzma` |
|
| `lzma` | LZMA-compressed file | `lzma` |
|
||||||
|
|||||||
@@ -49,7 +49,17 @@ tlz (tar.lzma), txz (tar.xz), tZ (tar.Z), xz, Z, zip, and zst."
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
case "$ext" in
|
case "$ext" in
|
||||||
7z) 7z u "${output}" "${@}" ;;
|
7z)
|
||||||
|
if (( $+commands[7zz] )); then
|
||||||
|
7zz u "${output}" "${@}"
|
||||||
|
elif (( $+commands[7z] )); then
|
||||||
|
7z u "${output}" "${@}"
|
||||||
|
elif (( $+commands[7za] )); then
|
||||||
|
7za u "${output}" "${@}"
|
||||||
|
else
|
||||||
|
echo "ua: cannot create 7z files: install 7zz, 7z or 7za" >&2
|
||||||
|
return 1
|
||||||
|
fi ;;
|
||||||
bz2) bzip2 -vcf "${@}" > "${output}" ;;
|
bz2) bzip2 -vcf "${@}" > "${output}" ;;
|
||||||
gz) gzip -vcf "${@}" > "${output}" ;;
|
gz) gzip -vcf "${@}" > "${output}" ;;
|
||||||
lzma) lzma -vc -T0 "${@}" > "${output}" ;;
|
lzma) lzma -vc -T0 "${@}" > "${output}" ;;
|
||||||
|
|||||||
@@ -15,14 +15,14 @@ plugins=(... uv)
|
|||||||
| :---- | ---------------------------------------------------------------------------------------- | :-------------------------------------------------------------------- |
|
| :---- | ---------------------------------------------------------------------------------------- | :-------------------------------------------------------------------- |
|
||||||
| uva | `uv add` | Add packages to the project |
|
| uva | `uv add` | Add packages to the project |
|
||||||
| uvexp | `uv export --format requirements-txt --no-hashes --output-file requirements.txt --quiet` | Export the lock file to `requirements.txt` |
|
| uvexp | `uv export --format requirements-txt --no-hashes --output-file requirements.txt --quiet` | Export the lock file to `requirements.txt` |
|
||||||
| uvi | `uv init` | Initialize a new project in current workspace and environment. |
|
| uvi | `uv init` | Initialize a new project |
|
||||||
| uvinw | `uv init --no-workspace` | Initialize a new project in a new workspace and environment |
|
| uvinw | `uv init --no-workspace` | Initialize a standalone project without joining a parent workspace |
|
||||||
| uvl | `uv lock` | Lock the dependencies |
|
| uvl | `uv lock` | Lock the dependencies |
|
||||||
| uvlr | `uv lock --refresh` | Rebuild the lock file without upgrading dependencies |
|
| uvlr | `uv lock --refresh` | Rebuild the lock file without upgrading dependencies |
|
||||||
| uvlu | `uv lock --upgrade` | Lock the dependencies to the newest compatible versions |
|
| uvlu | `uv lock --upgrade` | Lock the dependencies to the newest compatible versions |
|
||||||
| uvp | `uv pip` | Manage pip packages |
|
| uvp | `uv pip` | Manage pip packages |
|
||||||
| uvpi | `uv python install` | Install a specific version of python |
|
| uvpi | `uv python install` | Install a specific version of python |
|
||||||
| uvpl | `uv python list` | Lists all python version installed |
|
| uvpl | `uv python list` | List all installed Python versions. |
|
||||||
| uvpp | `uv python pin` | Pin the current project to use a specific Python version |
|
| uvpp | `uv python pin` | Pin the current project to use a specific Python version |
|
||||||
| uvpu | `uv python uninstall` | Remove a specific version of python |
|
| uvpu | `uv python uninstall` | Remove a specific version of python |
|
||||||
| uvpy | `uv python` | Manage Python installs |
|
| uvpy | `uv python` | Manage Python installs |
|
||||||
|
|||||||
@@ -43,7 +43,6 @@ Available search contexts are:
|
|||||||
| `wolframalpha` | `https://wolframalpha.com/input?i=` |
|
| `wolframalpha` | `https://wolframalpha.com/input?i=` |
|
||||||
| `archive` | `https://web.archive.org/web/*/` |
|
| `archive` | `https://web.archive.org/web/*/` |
|
||||||
| `scholar` | `https://scholar.google.com/scholar?q=` |
|
| `scholar` | `https://scholar.google.com/scholar?q=` |
|
||||||
| `ask` | `https://www.ask.com/web?q=` |
|
|
||||||
| `youtube` | `https://www.youtube.com/results?search_query=` |
|
| `youtube` | `https://www.youtube.com/results?search_query=` |
|
||||||
| `deepl` | `https://www.deepl.com/translator#auto/auto/` |
|
| `deepl` | `https://www.deepl.com/translator#auto/auto/` |
|
||||||
| `dockerhub` | `https://hub.docker.com/search?q=` |
|
| `dockerhub` | `https://hub.docker.com/search?q=` |
|
||||||
|
|||||||
@@ -24,7 +24,6 @@ function web_search() {
|
|||||||
wolframalpha "https://www.wolframalpha.com/input/?i="
|
wolframalpha "https://www.wolframalpha.com/input/?i="
|
||||||
archive "https://web.archive.org/web/*/"
|
archive "https://web.archive.org/web/*/"
|
||||||
scholar "https://scholar.google.com/scholar?q="
|
scholar "https://scholar.google.com/scholar?q="
|
||||||
ask "https://www.ask.com/web?q="
|
|
||||||
youtube "https://www.youtube.com/results?search_query="
|
youtube "https://www.youtube.com/results?search_query="
|
||||||
deepl "https://www.deepl.com/translator#auto/auto/"
|
deepl "https://www.deepl.com/translator#auto/auto/"
|
||||||
dockerhub "https://hub.docker.com/search?q="
|
dockerhub "https://hub.docker.com/search?q="
|
||||||
@@ -89,7 +88,6 @@ alias stackoverflow='web_search stackoverflow'
|
|||||||
alias wolframalpha='web_search wolframalpha'
|
alias wolframalpha='web_search wolframalpha'
|
||||||
alias archive='web_search archive'
|
alias archive='web_search archive'
|
||||||
alias scholar='web_search scholar'
|
alias scholar='web_search scholar'
|
||||||
alias ask='web_search ask'
|
|
||||||
alias youtube='web_search youtube'
|
alias youtube='web_search youtube'
|
||||||
alias deepl='web_search deepl'
|
alias deepl='web_search deepl'
|
||||||
alias dockerhub='web_search dockerhub'
|
alias dockerhub='web_search dockerhub'
|
||||||
|
|||||||
+12
-1
@@ -38,6 +38,17 @@ Zsh-z is a drop-in replacement for `rupa/z` and will, by default, use the same d
|
|||||||
|
|
||||||
## News
|
## News
|
||||||
|
|
||||||
|
### v2.0.1 (October 1, 2026)
|
||||||
|
|
||||||
|
- **Database writes now work with `setopt NO_CLOBBER`.** Under `NO_CLOBBER`,
|
||||||
|
every database write could fail with `can't clobber parameter tmpfd containing
|
||||||
|
file descriptor 0`, even when the database already existed. That error no longer
|
||||||
|
occurs ([#81](https://github.com/agkozak/zsh-z/issues/81)).
|
||||||
|
- **Database and lockfile creation now works with `setopt NO_CLOBBER`.** With
|
||||||
|
`NO_CLOBBER` set and `APPEND_CREATE` unset, Zsh-z could not create a missing
|
||||||
|
database or lockfile. It now creates them without changing your shell options or
|
||||||
|
losing existing directory history ([#105](https://github.com/agkozak/zsh-z/issues/105)).
|
||||||
|
|
||||||
### v2.0 (August 14, 2026)
|
### v2.0 (August 14, 2026)
|
||||||
|
|
||||||
Version **2.0** is a major step forward, and these are the changes most worth knowing about:
|
Version **2.0** is a major step forward, and these are the changes most worth knowing about:
|
||||||
@@ -47,7 +58,7 @@ Version **2.0** is a major step forward, and these are the changes most worth kn
|
|||||||
- **Safer, crash-resistant concurrent writes.** Writes are now guarded by a dedicated, stable lockfile using `zsh/system` file locking, with a bounded wait for lock acquisition (the new [`ZSHZ_LOCK_TIMEOUT`](#settings), default `1` second). Write errors are handled gracefully, and locks are always released even if a write is interrupted. On Cygwin and MSYS2 a write is also retried briefly if Windows refuses it: a virus scanner or the search indexer that opens the database in the instant between its being written and its being moved into place makes the move fail, which used to lose that one directory silently. Zsh-z now retries the move briefly.
|
- **Safer, crash-resistant concurrent writes.** Writes are now guarded by a dedicated, stable lockfile using `zsh/system` file locking, with a bounded wait for lock acquisition (the new [`ZSHZ_LOCK_TIMEOUT`](#settings), default `1` second). Write errors are handled gracefully, and locks are always released even if a write is interrupted. On Cygwin and MSYS2 a write is also retried briefly if Windows refuses it: a virus scanner or the search indexer that opens the database in the instant between its being written and its being moved into place makes the move fail, which used to lose that one directory silently. Zsh-z now retries the move briefly.
|
||||||
- **Your database file now has `600` permissions** -- readable and writable only by you -- so that other users on a shared system cannot read your directory history ([#92](https://github.com/agkozak/zsh-z/issues/92)). On Zsh 5+ this uses the in-process `zf_chmod` builtin; on Zsh 4.3.11 it uses a `umask`-in-a-subshell technique that avoids the fork-and-exec of an external `chmod`.
|
- **Your database file now has `600` permissions** -- readable and writable only by you -- so that other users on a shared system cannot read your directory history ([#92](https://github.com/agkozak/zsh-z/issues/92)). On Zsh 5+ this uses the in-process `zf_chmod` builtin; on Zsh 4.3.11 it uses a `umask`-in-a-subshell technique that avoids the fork-and-exec of an external `chmod`.
|
||||||
- **`COMPLETE_ALIASES` works automatically in normal setups.** Tab completion no longer breaks when you have `setopt COMPLETE_ALIASES` enabled. Zsh-z registers the alias automatically on the first Tab press, so the manual `compdef` line that earlier versions required is no longer necessary. [See below](#complete_aliases).
|
- **`COMPLETE_ALIASES` works automatically in normal setups.** Tab completion no longer breaks when you have `setopt COMPLETE_ALIASES` enabled. Zsh-z registers the alias automatically on the first Tab press, so the manual `compdef` line that earlier versions required is no longer necessary. [See below](#complete_aliases).
|
||||||
- **Fixed a `can't clobber parameter tmpfd` error on some Zsh builds.** On certain Zsh builds, every database write could fail with `can't clobber parameter tmpfd containing file descriptor 0`, leaving an error at each new prompt. The file descriptor used for the temporary database file is now held in an unset scalar rather than one seeded with `0`, so the write never trips Zsh's file-descriptor-clobber guard ([#81](https://github.com/agkozak/zsh-z/issues/81)).
|
- **Fixed a `can't clobber parameter tmpfd` error on some Zsh builds.** On certain Zsh builds, every database write could fail with `can't clobber parameter tmpfd containing file descriptor 0`, leaving an error at each new prompt ([#81](https://github.com/agkozak/zsh-z/issues/81)). *Correction:* the error occurs under `setopt NO_CLOBBER`, and the v2.0 change did not fix it there; v2.0.1 does.
|
||||||
- **A misconfigured database file no longer closes your shell -- or nags you at every prompt.** When `ZSHZ_DATA` points at a directory, or names a file without a directory, Zsh-z now reports the problem and returns instead of calling `exit`. The per-prompt `--add` stays quiet about it, so you are told once, when you actually run `z`, rather than at every prompt ([#103](https://github.com/agkozak/zsh-z/issues/103); props @ahjota).
|
- **A misconfigured database file no longer closes your shell -- or nags you at every prompt.** When `ZSHZ_DATA` points at a directory, or names a file without a directory, Zsh-z now reports the problem and returns instead of calling `exit`. The per-prompt `--add` stays quiet about it, so you are told once, when you actually run `z`, rather than at every prompt ([#103](https://github.com/agkozak/zsh-z/issues/103); props @ahjota).
|
||||||
- **`z -x` can now remove the entry for a directory that no longer exists -- and can no longer crash Zsh 4.3.11.** The removal target used to have to exist on disk, so a database entry whose directory had been deleted -- exactly the entry you most want gone -- could not be removed. `z -x /deleted/dir` (and `z -xR`) now canonicalizes the argument without requiring it to exist, resolving symlinks in as much of the path as is still present. The same change fixes a crash on Zsh 4.3.11, where an upstream bug makes `${x:A}` segfault when the top-level component of the path is missing: `z -x /gone/sub` -- or a `ZSHZ_DATA` pointing into a missing top-level directory -- could kill the shell there.
|
- **`z -x` can now remove the entry for a directory that no longer exists -- and can no longer crash Zsh 4.3.11.** The removal target used to have to exist on disk, so a database entry whose directory had been deleted -- exactly the entry you most want gone -- could not be removed. `z -x /deleted/dir` (and `z -xR`) now canonicalizes the argument without requiring it to exist, resolving symlinks in as much of the path as is still present. The same change fixes a crash on Zsh 4.3.11, where an upstream bug makes `${x:A}` segfault when the top-level component of the path is missing: `z -x /gone/sub` -- or a `ZSHZ_DATA` pointing into a missing top-level directory -- could kill the shell there.
|
||||||
- **More robust startup and operation.** A version check on an unsupported Zsh no longer risks exiting your interactive shell.
|
- **More robust startup and operation.** A version check on an unsupported Zsh no longer risks exiting your interactive shell.
|
||||||
|
|||||||
Loaded 100 of 112 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user