mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2026-10-20 21:02:08 +08:00
Compare commits
110
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
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 | ||
|
|
83a0ec79ee | ||
|
|
c5852b1101 | ||
|
|
68795c2170 | ||
|
|
f809d46c10 | ||
|
|
0431f1c33d | ||
|
|
a3c88eba72 | ||
|
|
6881f37316 | ||
|
|
1d66682636 | ||
|
|
ce7f8c3224 | ||
|
|
f8e13d714e | ||
|
|
95ba6ae764 | ||
|
|
74965c9609 | ||
|
|
1b2d741f19 | ||
|
|
4ccc63333c | ||
|
|
40bddc3c1a | ||
|
|
8d421b6309 | ||
|
|
7d1b2a25ca | ||
|
|
86ef6555e0 | ||
|
|
32d7277ac3 | ||
|
|
e0d3557e14 | ||
|
|
b6830a53d5 | ||
|
|
fa82d8a3eb | ||
|
|
6421f8e104 | ||
|
|
0b50afdbfd | ||
|
|
157eb033f2 | ||
|
|
e7852049a5 | ||
|
|
7ce781ea37 | ||
|
|
def0f255c5 | ||
|
|
0ee67f0428 | ||
|
|
ec2901b7d0 | ||
|
|
1396cdd674 | ||
|
|
2ea948e05b | ||
|
|
6cd3a0baf6 | ||
|
|
fcf965912c | ||
|
|
c648271b6b | ||
|
|
53f663f3d8 | ||
|
|
e995678ca8 | ||
|
|
aea374f522 | ||
|
|
6553f90c45 | ||
|
|
9bf43f682c | ||
|
|
1b72d609b4 | ||
|
|
3258baa8b4 | ||
|
|
ee78d3aedd | ||
|
|
2b48fa42f9 | ||
|
|
be8da5c771 | ||
|
|
c6e66edee8 | ||
|
|
a1115e6eb8 | ||
|
|
24d629f7f1 | ||
|
|
d6f3106269 | ||
|
|
e6561f578f | ||
|
|
9bb15d681a | ||
|
|
ee2acd0e44 | ||
|
|
d5fa35e453 | ||
|
|
2c911e3f80 | ||
|
|
cd320b5506 | ||
|
|
e8b1cca662 | ||
|
|
8e5f198226 | ||
|
|
391cafc4cf | ||
|
|
3079e2f0b5 | ||
|
|
129de5a05f | ||
|
|
bd77419b2a | ||
|
|
d217d05374 | ||
|
|
c891b750b0 | ||
|
|
6aa16696d5 | ||
|
|
8d10cc9488 | ||
|
|
bf77e350e0 | ||
|
|
07351f99fc | ||
|
|
39334a08e9 | ||
|
|
cba369e090 | ||
|
|
0da7919339 | ||
|
|
992edcc17d | ||
|
|
78cbb3fe5e | ||
|
|
76ac9fcddc | ||
|
|
17bbf5fdac | ||
|
|
704f7d59d8 | ||
|
|
0b235c54de |
@@ -5,6 +5,7 @@ plugins/eza/ @pepoluan
|
|||||||
plugins/genpass/ @atoponce
|
plugins/genpass/ @atoponce
|
||||||
plugins/git-lfs/ @hellovietduc
|
plugins/git-lfs/ @hellovietduc
|
||||||
plugins/gitfast/ @felipec
|
plugins/gitfast/ @felipec
|
||||||
|
plugins/hermes/ @Uhm-why
|
||||||
plugins/kube-ps1/ @mcornella
|
plugins/kube-ps1/ @mcornella
|
||||||
plugins/kubectl/ @mcornella
|
plugins/kubectl/ @mcornella
|
||||||
plugins/kubectx/ @mcornella
|
plugins/kubectx/ @mcornella
|
||||||
|
|||||||
@@ -12,14 +12,14 @@ dependencies:
|
|||||||
plugins/gradle:
|
plugins/gradle:
|
||||||
repo: gradle/gradle-completion
|
repo: gradle/gradle-completion
|
||||||
branch: master
|
branch: master
|
||||||
version: 63578c9bc56134b80766e88957ba0239e6be2343
|
version: 05693a01fcb246bc4e8fc32a8d561dc537aaedf2
|
||||||
precopy: |
|
precopy: |
|
||||||
set -e
|
set -e
|
||||||
find . ! -name _gradle ! -name LICENSE -delete
|
find . ! -name _gradle ! -name LICENSE -delete
|
||||||
plugins/history-substring-search:
|
plugins/history-substring-search:
|
||||||
repo: zsh-users/zsh-history-substring-search
|
repo: zsh-users/zsh-history-substring-search
|
||||||
branch: master
|
branch: master
|
||||||
version: 14c8d2e0ffaee98f2df9850b19944f32546fdea5
|
version: a0bdb0d47dbaba31dba2db7af8c48a5d9c74049a
|
||||||
precopy: |
|
precopy: |
|
||||||
set -e
|
set -e
|
||||||
rm -f zsh-history-substring-search.plugin.zsh
|
rm -f zsh-history-substring-search.plugin.zsh
|
||||||
@@ -30,7 +30,7 @@ dependencies:
|
|||||||
plugins/kube-ps1:
|
plugins/kube-ps1:
|
||||||
repo: jonmosco/kube-ps1
|
repo: jonmosco/kube-ps1
|
||||||
branch: master
|
branch: master
|
||||||
version: 04af46f7fe888ad287abcab6699b9bb10234bc3d
|
version: 7aaaeee5eaa29f920acd850ea63839d9f87b8ac5
|
||||||
precopy: |
|
precopy: |
|
||||||
set -e
|
set -e
|
||||||
find . ! -name kube-ps1.sh ! -name LICENSE ! -name README.md -delete
|
find . ! -name kube-ps1.sh ! -name LICENSE ! -name README.md -delete
|
||||||
@@ -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
|
||||||
@@ -55,3 +55,46 @@ dependencies:
|
|||||||
set -e
|
set -e
|
||||||
test -e _zshz && mv -f _zshz _z
|
test -e _zshz && mv -f _zshz _z
|
||||||
test -e zsh-z.plugin.zsh && mv -f zsh-z.plugin.zsh z.plugin.zsh
|
test -e zsh-z.plugin.zsh && mv -f zsh-z.plugin.zsh z.plugin.zsh
|
||||||
|
plugins/zsh-autosuggestions:
|
||||||
|
repo: zsh-users/zsh-autosuggestions
|
||||||
|
branch: master
|
||||||
|
version: 85919cd1ffa7d2d5412f6d3fe437ebdbeeec4fc5
|
||||||
|
precopy: |
|
||||||
|
set -e
|
||||||
|
test -e README.md && mv -f README.md MANUAL.md
|
||||||
|
sed -i 's|\[INSTALL.md\](INSTALL.md)|[the Oh My Zsh plugin README](README.md)|' MANUAL.md
|
||||||
|
rm -f zsh-autosuggestions.plugin.zsh
|
||||||
|
mv -f zsh-autosuggestions.zsh zsh-autosuggestions.plugin.zsh
|
||||||
|
find . -depth -mindepth 1 \
|
||||||
|
! -path './LICENSE' \
|
||||||
|
! -path './MANUAL.md' \
|
||||||
|
! -path './src' \
|
||||||
|
! -path './src/*' \
|
||||||
|
! -path './zsh-autosuggestions.plugin.zsh' \
|
||||||
|
-delete
|
||||||
|
plugins/zsh-syntax-highlighting:
|
||||||
|
repo: zsh-users/zsh-syntax-highlighting
|
||||||
|
branch: master
|
||||||
|
version: e6683f20e5c38d3e5447f45845d04ddda75d0f23
|
||||||
|
precopy: |
|
||||||
|
set -e
|
||||||
|
version=$(<.version)
|
||||||
|
test -e README.md && mv -f README.md MANUAL.md
|
||||||
|
sed -i 's|\[INSTALL.md\](INSTALL.md)|[the Oh My Zsh plugin README](README.md)|' MANUAL.md
|
||||||
|
rm -f zsh-syntax-highlighting.plugin.zsh
|
||||||
|
mv -f zsh-syntax-highlighting.zsh zsh-syntax-highlighting.plugin.zsh
|
||||||
|
mv -f COPYING.md LICENSE
|
||||||
|
sed -i "s|typeset -g ZSH_HIGHLIGHT_VERSION=.*|typeset -g ZSH_HIGHLIGHT_VERSION=$version|" zsh-syntax-highlighting.plugin.zsh
|
||||||
|
sed -i 's|typeset -g ZSH_HIGHLIGHT_REVISION=.*|typeset -g ZSH_HIGHLIGHT_REVISION=HEAD|' zsh-syntax-highlighting.plugin.zsh
|
||||||
|
find highlighters -type d -name test-data -prune -exec rm -rf {} +
|
||||||
|
find . -depth -mindepth 1 \
|
||||||
|
! -path './LICENSE' \
|
||||||
|
! -path './MANUAL.md' \
|
||||||
|
! -path './docs' \
|
||||||
|
! -path './docs/*' \
|
||||||
|
! -path './highlighters' \
|
||||||
|
! -path './highlighters/*' \
|
||||||
|
! -path './images' \
|
||||||
|
! -path './images/*' \
|
||||||
|
! -path './zsh-syntax-highlighting.plugin.zsh' \
|
||||||
|
-delete
|
||||||
|
|||||||
@@ -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@05e31511f85b41b11d1cf0ef85d0992719546e2c # v2.21.0
|
uses: step-security/harden-runner@ccd8616d44fd3846e67624a50d5aad6d37bf2d25 # v2.22.1
|
||||||
with:
|
with:
|
||||||
egress-policy: audit
|
egress-policy: audit
|
||||||
|
|
||||||
@@ -26,7 +26,7 @@ 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@64ab729a6294000f5aa4a4bc0b73d1f32bc45510 # v3.3.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 }}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
certifi==2026.7.22
|
certifi==2026.7.22
|
||||||
charset-normalizer==3.5.1
|
charset-normalizer==3.5.2
|
||||||
idna==3.19
|
idna==3.20
|
||||||
PyYAML==6.0.3
|
PyYAML==6.0.3
|
||||||
requests==2.34.2
|
requests==2.34.2
|
||||||
semver==3.0.4
|
semver==3.1.0
|
||||||
urllib3==2.7.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@05e31511f85b41b11d1cf0ef85d0992719546e2c # v2.21.0
|
uses: step-security/harden-runner@ccd8616d44fd3846e67624a50d5aad6d37bf2d25 # v2.22.1
|
||||||
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@05e31511f85b41b11d1cf0ef85d0992719546e2c # v2.21.0
|
uses: step-security/harden-runner@ccd8616d44fd3846e67624a50d5aad6d37bf2d25 # v2.22.1
|
||||||
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@05e31511f85b41b11d1cf0ef85d0992719546e2c # v2.21.0
|
uses: step-security/harden-runner@ccd8616d44fd3846e67624a50d5aad6d37bf2d25 # v2.22.1
|
||||||
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@05e31511f85b41b11d1cf0ef85d0992719546e2c # v2.21.0
|
uses: step-security/harden-runner@ccd8616d44fd3846e67624a50d5aad6d37bf2d25 # v2.22.1
|
||||||
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@64ab729a6294000f5aa4a4bc0b73d1f32bc45510 # v3.3.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@05e31511f85b41b11d1cf0ef85d0992719546e2c # v2.21.0
|
uses: step-security/harden-runner@ccd8616d44fd3846e67624a50d5aad6d37bf2d25 # v2.22.1
|
||||||
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@fa7117db83c52d787ae5a89f350999701505d78e # v2.5.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@cdf488f595d80d6e07e03d4674febd5ab45fa938 # v4.37.9
|
uses: github/codeql-action/upload-sarif@6f2ac81f5cd81fe351a197ba0b00d91d03cd2aee # v4.39.0
|
||||||
with:
|
with:
|
||||||
sarif_file: results.sarif
|
sarif_file: results.sarif
|
||||||
|
|||||||
@@ -23,6 +23,14 @@ Twitter), and join us on [Discord](https://discord.gg/ohmyzsh).
|
|||||||
[](https://mstdn.social/@ohmyzsh)
|
[](https://mstdn.social/@ohmyzsh)
|
||||||
[](https://discord.gg/ohmyzsh)
|
[](https://discord.gg/ohmyzsh)
|
||||||
|
|
||||||
|
<a href="https://commitgoods.com/collections/oh-my-zsh?utm_source=github">
|
||||||
|
<picture>
|
||||||
|
<source media="(prefers-color-scheme: dark)" srcset="https://cdn.shopify.com/s/files/1/0101/8752/files/commitgoods-badge-stacked-navy-dark.svg">
|
||||||
|
<img src="https://cdn.shopify.com/s/files/1/0101/8752/files/commitgoods-badge-stacked-navy.svg" height="28" alt="Official merch on commitgoods.com">
|
||||||
|
</picture>
|
||||||
|
</a>
|
||||||
|
|
||||||
|
|
||||||
<details>
|
<details>
|
||||||
<summary>Table of Contents</summary>
|
<summary>Table of Contents</summary>
|
||||||
|
|
||||||
@@ -37,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)
|
||||||
@@ -233,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
|
||||||
@@ -466,6 +502,22 @@ zstyle ':omz:update' frequency 7
|
|||||||
zstyle ':omz:update' frequency 0
|
zstyle ':omz:update' frequency 0
|
||||||
```
|
```
|
||||||
|
|
||||||
|
By default, updates always pull the latest changes. If you'd rather let others kick the tires first
|
||||||
|
before an update reaches your machine, you can set a cooldown (in days). You'll still get everything —
|
||||||
|
just a little later:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
# Only apply updates that are at least 10 days old
|
||||||
|
zstyle ':omz:update' cooldown 10
|
||||||
|
```
|
||||||
|
|
||||||
|
`omz update` honors this setting. If you call `upgrade.sh` directly, pass the same
|
||||||
|
value with `-c`, because that script does not read your `.zshrc`:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
$ZSH/tools/upgrade.sh -c 10
|
||||||
|
```
|
||||||
|
|
||||||
### Updates Verbosity
|
### Updates Verbosity
|
||||||
|
|
||||||
You can also limit the update verbosity with the following settings:
|
You can also limit the update verbosity with the following settings:
|
||||||
|
|||||||
+33
-1
@@ -28,12 +28,25 @@ function _omz {
|
|||||||
'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
|
||||||
@@ -174,6 +187,7 @@ Available commands:
|
|||||||
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 +196,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"}
|
||||||
|
|
||||||
@@ -738,6 +761,9 @@ function _omz::reload {
|
|||||||
|
|
||||||
# Old zsh versions don't have ZSH_ARGZERO
|
# Old zsh versions don't have ZSH_ARGZERO
|
||||||
local zsh="${ZSH_ARGZERO:-${functrace[-1]%:*}}"
|
local zsh="${ZSH_ARGZERO:-${functrace[-1]%:*}}"
|
||||||
|
# ZSH_ARGZERO is how zsh was invoked, not the path to it, so re-resolve
|
||||||
|
# anything that is not absolute via $PATH at exec time (see #13919)
|
||||||
|
[[ "${zsh#-}" != /* ]] && (( $+commands[zsh] )) && zsh="zsh"
|
||||||
# Check whether to run a login shell
|
# Check whether to run a login shell
|
||||||
[[ "$zsh" = -* || -o login ]] && exec -l "${zsh#-}" || exec "$zsh"
|
[[ "$zsh" = -* || -o login ]] && exec -l "${zsh#-}" || exec "$zsh"
|
||||||
}
|
}
|
||||||
@@ -903,8 +929,11 @@ function _omz::update {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# Run update script
|
# Run update script
|
||||||
|
local verbose_mode cooldown_days
|
||||||
zstyle -s ':omz:update' verbose verbose_mode || verbose_mode=default
|
zstyle -s ':omz:update' verbose verbose_mode || verbose_mode=default
|
||||||
ZSH="$ZSH" command zsh -f "$ZSH/tools/upgrade.sh" -i -v $verbose_mode || return $?
|
zstyle -s ':omz:update' cooldown cooldown_days || cooldown_days=0
|
||||||
|
[[ $cooldown_days == <-> ]] || cooldown_days=0
|
||||||
|
ZSH="$ZSH" command zsh -f "$ZSH/tools/upgrade.sh" -i -v $verbose_mode -c $cooldown_days || return $?
|
||||||
|
|
||||||
# Update last updated file
|
# Update last updated file
|
||||||
zmodload zsh/datetime
|
zmodload zsh/datetime
|
||||||
@@ -916,6 +945,9 @@ function _omz::update {
|
|||||||
if [[ "$(builtin cd -q "$ZSH"; git rev-parse HEAD)" != "$last_commit" ]]; then
|
if [[ "$(builtin cd -q "$ZSH"; git rev-parse HEAD)" != "$last_commit" ]]; then
|
||||||
# Old zsh versions don't have ZSH_ARGZERO
|
# Old zsh versions don't have ZSH_ARGZERO
|
||||||
local zsh="${ZSH_ARGZERO:-${functrace[-1]%:*}}"
|
local zsh="${ZSH_ARGZERO:-${functrace[-1]%:*}}"
|
||||||
|
# ZSH_ARGZERO is how zsh was invoked, not the path to it, so re-resolve
|
||||||
|
# anything that is not absolute via $PATH at exec time (see #13919)
|
||||||
|
[[ "${zsh#-}" != /* ]] && (( $+commands[zsh] )) && zsh="zsh"
|
||||||
# Check whether to run a login shell
|
# Check whether to run a login shell
|
||||||
[[ "$zsh" = -* || -o login ]] && exec -l "${zsh#-}" || exec "$zsh"
|
[[ "$zsh" = -* || -o login ]] && exec -l "${zsh#-}" || exec "$zsh"
|
||||||
fi
|
fi
|
||||||
|
|||||||
+2
-1
@@ -178,7 +178,8 @@ function omz_urlencode() {
|
|||||||
setopt norematchpcre
|
setopt norematchpcre
|
||||||
|
|
||||||
local -a opts
|
local -a opts
|
||||||
zparseopts -D -E -a opts r m P
|
# Quote the specs so global aliases (e.g. common-aliases' P) don't expand here
|
||||||
|
zparseopts -D -E -a opts 'r' 'm' 'P'
|
||||||
|
|
||||||
local in_str="$@"
|
local in_str="$@"
|
||||||
local url_str=""
|
local url_str=""
|
||||||
|
|||||||
+21
-10
@@ -12,10 +12,16 @@ function __git_prompt_git() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function _omz_git_prompt_info() {
|
function _omz_git_prompt_info() {
|
||||||
# If we are on a folder not tracked by git, get out.
|
# Get the git dir and the current branch name in one call. Outside a repo
|
||||||
# Otherwise, check for hide-info at global and local repository level
|
# there is no output. On a detached HEAD the branch is "HEAD". On an unborn
|
||||||
if ! __git_prompt_git rev-parse --git-dir &> /dev/null \
|
# branch git exits non-zero after printing the git dir.
|
||||||
|| [[ "$(__git_prompt_git config --get oh-my-zsh.hide-info 2>/dev/null)" == 1 ]]; then
|
local -a info
|
||||||
|
info=("${(@f)$(__git_prompt_git rev-parse --git-dir --abbrev-ref HEAD 2> /dev/null)}")
|
||||||
|
local unborn=$(( $? != 0 ))
|
||||||
|
[[ -n "$info[1]" ]] || return 0
|
||||||
|
|
||||||
|
# Check for hide-info at global and local repository level
|
||||||
|
if [[ "$(__git_prompt_git config --get oh-my-zsh.hide-info 2>/dev/null)" == 1 ]]; then
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -23,11 +29,15 @@ function _omz_git_prompt_info() {
|
|||||||
# - the current branch name
|
# - the current branch name
|
||||||
# - the tag name if we are on a tag
|
# - the tag name if we are on a tag
|
||||||
# - the short SHA of the current commit
|
# - the short SHA of the current commit
|
||||||
local ref
|
# a git dir path may contain newlines, so the branch is the last line
|
||||||
ref=$(__git_prompt_git symbolic-ref --short HEAD 2> /dev/null) \
|
local ref="$info[-1]"
|
||||||
|| ref=$(__git_prompt_git describe --tags --exact-match HEAD 2> /dev/null) \
|
if (( unborn )); then
|
||||||
|| ref=$(__git_prompt_git rev-parse --short HEAD 2> /dev/null) \
|
ref=$(__git_prompt_git symbolic-ref --short HEAD 2> /dev/null) || return 0
|
||||||
|| return 0
|
elif [[ "$ref" == HEAD ]]; then
|
||||||
|
ref=$(__git_prompt_git describe --tags --exact-match HEAD 2> /dev/null) \
|
||||||
|
|| ref=$(__git_prompt_git rev-parse --short HEAD 2> /dev/null) \
|
||||||
|
|| return 0
|
||||||
|
fi
|
||||||
|
|
||||||
# Use global ZSH_THEME_GIT_SHOW_UPSTREAM=1 for including upstream remote info
|
# Use global ZSH_THEME_GIT_SHOW_UPSTREAM=1 for including upstream remote info
|
||||||
local upstream
|
local upstream
|
||||||
@@ -244,7 +254,8 @@ function parse_git_dirty() {
|
|||||||
FLAGS+="--ignore-submodules=${GIT_STATUS_IGNORE_SUBMODULES:-dirty}"
|
FLAGS+="--ignore-submodules=${GIT_STATUS_IGNORE_SUBMODULES:-dirty}"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
STATUS=$(__git_prompt_git status ${FLAGS} 2> /dev/null | tail -n 1)
|
# only non-emptiness matters, so keep one line instead of the whole list
|
||||||
|
__git_prompt_git status ${FLAGS} 2> /dev/null | read -r STATUS
|
||||||
fi
|
fi
|
||||||
if [[ -n $STATUS ]]; then
|
if [[ -n $STATUS ]]; then
|
||||||
echo "$ZSH_THEME_GIT_PROMPT_DIRTY"
|
echo "$ZSH_THEME_GIT_PROMPT_DIRTY"
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ function chruby_prompt_info \
|
|||||||
azure_prompt_info \
|
azure_prompt_info \
|
||||||
tf_prompt_info \
|
tf_prompt_info \
|
||||||
conda_prompt_info \
|
conda_prompt_info \
|
||||||
|
go_prompt_info \
|
||||||
{
|
{
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|||||||
+10
-4
@@ -14,10 +14,16 @@ FX=(
|
|||||||
reverse "%{[07m%}" no-reverse "%{[27m%}"
|
reverse "%{[07m%}" no-reverse "%{[27m%}"
|
||||||
)
|
)
|
||||||
|
|
||||||
for color in {000..255}; do
|
# Build the tables with array operations instead of a 256-iteration loop
|
||||||
FG[$color]="%{[38;5;${color}m%}"
|
() {
|
||||||
BG[$color]="%{[48;5;${color}m%}"
|
setopt localoptions noksharrays
|
||||||
done
|
local -a codes fg bg
|
||||||
|
codes=({000..255})
|
||||||
|
fg=( "%{"$'\e'"[38;5;"${^codes}"m%}" )
|
||||||
|
bg=( "%{"$'\e'"[48;5;"${^codes}"m%}" )
|
||||||
|
FG=( ${codes:^fg} )
|
||||||
|
BG=( ${codes:^bg} )
|
||||||
|
}
|
||||||
|
|
||||||
# Show all 256 colors with color number
|
# Show all 256 colors with color number
|
||||||
function spectrum_ls() {
|
function spectrum_ls() {
|
||||||
|
|||||||
+15
-7
@@ -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,23 +16,32 @@ 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
|
||||||
;;
|
;;
|
||||||
screen*|tmux*)
|
screen*|tmux*)
|
||||||
print -Pn "\ek${1:q}\e\\" # set screen hardstatus
|
print -Pn "\e]2;${2:q}\e\\" # set tmux pane title
|
||||||
|
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
|
||||||
print -Pn "${terminfo[tsl]}$1${terminfo[fsl]}"
|
# Emit the capabilities with echoti so terminfo does its own parameter
|
||||||
|
# substitution: some terminals (vt320) take a column argument, and
|
||||||
|
# running prompt expansion over the capability string mangles it.
|
||||||
|
echoti tsl 0
|
||||||
|
print -Pn "$1"
|
||||||
|
echoti fsl
|
||||||
fi
|
fi
|
||||||
fi
|
;;
|
||||||
|
esac
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,69 +13,92 @@ ZSH_THEME_RUBY_PROMPT_PREFIX="("
|
|||||||
ZSH_THEME_RUBY_PROMPT_SUFFIX=")"
|
ZSH_THEME_RUBY_PROMPT_SUFFIX=")"
|
||||||
|
|
||||||
|
|
||||||
|
# The command probes below fork a process each, and their result doesn't change
|
||||||
|
# from one shell to the next, so they're cached for a day (like lib/grep.zsh).
|
||||||
|
typeset -A __omz_probes
|
||||||
|
__omz_probe_cache="$ZSH_CACHE_DIR/appearance-probes"
|
||||||
|
__omz_probe_cached=("$__omz_probe_cache"(Nm-1))
|
||||||
|
[[ -z "$__omz_probe_cached" ]] || source "$__omz_probe_cache"
|
||||||
|
|
||||||
|
function __omz_test_cmd_args {
|
||||||
|
# Usage: __omz_test_cmd_args cmd args...
|
||||||
|
# Runs `cmd args... /dev/null` and remembers whether it succeeded, so a
|
||||||
|
# command needing two operands passes the first one itself:
|
||||||
|
# e.g. __omz_test_cmd_args gls --color -> gls --color /dev/null
|
||||||
|
# __omz_test_cmd_args diff --color /dev/null -> diff --color /dev/null /dev/null
|
||||||
|
local key="$*"
|
||||||
|
if (( ! ${+__omz_probes[$key]} )); then
|
||||||
|
command "$@" /dev/null &>/dev/null
|
||||||
|
__omz_probes[$key]=$?
|
||||||
|
if [[ -w "$ZSH_CACHE_DIR" ]]; then
|
||||||
|
print -r -- "__omz_probes=(" "${(@qqkv)__omz_probes}" ")" >| "$__omz_probe_cache"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
return $__omz_probes[$key]
|
||||||
|
}
|
||||||
|
|
||||||
# Use diff --color if available
|
# Use diff --color if available
|
||||||
if command diff --color /dev/null{,} &>/dev/null; then
|
if __omz_test_cmd_args diff --color /dev/null; then
|
||||||
function diff {
|
function diff {
|
||||||
command diff --color "$@"
|
command diff --color "$@"
|
||||||
}
|
}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Don't set ls coloring if disabled
|
# Set up ls coloring. Done in a function so the early return below still
|
||||||
[[ "$DISABLE_LS_COLORS" != true ]] || return 0
|
# reaches the cleanup at the end of this file.
|
||||||
|
() {
|
||||||
|
# Don't set ls coloring if disabled
|
||||||
|
[[ "$DISABLE_LS_COLORS" != true ]] || return 0
|
||||||
|
|
||||||
# Default coloring for BSD-based ls
|
# Default coloring for BSD-based ls
|
||||||
export LSCOLORS="Gxfxcxdxbxegedabagacad"
|
export LSCOLORS="Gxfxcxdxbxegedabagacad"
|
||||||
|
|
||||||
# Default coloring for GNU-based ls
|
# Default coloring for GNU-based ls
|
||||||
if [[ -z "$LS_COLORS" ]]; then
|
if [[ -z "$LS_COLORS" ]]; then
|
||||||
# Define LS_COLORS via dircolors if available. Otherwise, set a default
|
# Define LS_COLORS via dircolors if available. Otherwise, set a default
|
||||||
# equivalent to LSCOLORS (generated via https://geoff.greer.fm/lscolors)
|
# equivalent to LSCOLORS (generated via https://geoff.greer.fm/lscolors)
|
||||||
if (( $+commands[dircolors] )); then
|
if (( $+commands[dircolors] )); then
|
||||||
[[ -f "$HOME/.dircolors" ]] \
|
[[ -f "$HOME/.dircolors" ]] \
|
||||||
&& source <(dircolors -b "$HOME/.dircolors") \
|
&& source <(dircolors -b "$HOME/.dircolors") \
|
||||||
|| source <(dircolors -b)
|
|| source <(dircolors -b)
|
||||||
else
|
else
|
||||||
export LS_COLORS="di=1;36:ln=35:so=32:pi=33:ex=31:bd=34;46:cd=34;43:su=30;41:sg=30;46:tw=30;42:ow=30;43"
|
export LS_COLORS="di=1;36:ln=35:so=32:pi=33:ex=31:bd=34;46:cd=34;43:su=30;41:sg=30;46:tw=30;42:ow=30;43"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
|
||||||
|
|
||||||
function test-ls-args {
|
# Find the option for using colors in ls, depending on the version
|
||||||
# Usage: test-ls-args cmd args...
|
case "$OSTYPE" in
|
||||||
# e.g. test-ls-args gls --color
|
netbsd*)
|
||||||
command "$@" /dev/null &>/dev/null
|
# On NetBSD, test if `gls` (GNU ls) is installed (this one supports colors);
|
||||||
|
# otherwise, leave ls as is, because NetBSD's ls doesn't support -G
|
||||||
|
__omz_test_cmd_args gls --color && alias ls='gls --color=tty'
|
||||||
|
;;
|
||||||
|
openbsd*)
|
||||||
|
# On OpenBSD, `gls` (ls from GNU coreutils) and `colorls` (ls from base,
|
||||||
|
# with color and multibyte support) are available from ports.
|
||||||
|
# `colorls` will be installed on purpose and can't be pulled in by installing
|
||||||
|
# coreutils (which might be installed for ), so prefer it to `gls`.
|
||||||
|
__omz_test_cmd_args gls --color && alias ls='gls --color=tty'
|
||||||
|
__omz_test_cmd_args colorls -G && alias ls='colorls -G'
|
||||||
|
;;
|
||||||
|
(darwin|freebsd)*)
|
||||||
|
# This alias works by default just using $LSCOLORS
|
||||||
|
__omz_test_cmd_args ls -G && alias ls='ls -G'
|
||||||
|
# Only use GNU ls if installed and there are user defaults for $LS_COLORS,
|
||||||
|
# as the default coloring scheme is not very pretty
|
||||||
|
zstyle -t ':omz:lib:theme-and-appearance' gnu-ls \
|
||||||
|
&& __omz_test_cmd_args gls --color \
|
||||||
|
&& alias ls='gls --color=tty'
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
if __omz_test_cmd_args ls --color; then
|
||||||
|
alias ls='ls --color=tty'
|
||||||
|
elif __omz_test_cmd_args ls -G; then
|
||||||
|
alias ls='ls -G'
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
# Find the option for using colors in ls, depending on the version
|
unfunction __omz_test_cmd_args
|
||||||
case "$OSTYPE" in
|
unset __omz_probes __omz_probe_cache __omz_probe_cached
|
||||||
netbsd*)
|
|
||||||
# On NetBSD, test if `gls` (GNU ls) is installed (this one supports colors);
|
|
||||||
# otherwise, leave ls as is, because NetBSD's ls doesn't support -G
|
|
||||||
test-ls-args gls --color && alias ls='gls --color=tty'
|
|
||||||
;;
|
|
||||||
openbsd*)
|
|
||||||
# On OpenBSD, `gls` (ls from GNU coreutils) and `colorls` (ls from base,
|
|
||||||
# with color and multibyte support) are available from ports.
|
|
||||||
# `colorls` will be installed on purpose and can't be pulled in by installing
|
|
||||||
# coreutils (which might be installed for ), so prefer it to `gls`.
|
|
||||||
test-ls-args gls --color && alias ls='gls --color=tty'
|
|
||||||
test-ls-args colorls -G && alias ls='colorls -G'
|
|
||||||
;;
|
|
||||||
(darwin|freebsd)*)
|
|
||||||
# This alias works by default just using $LSCOLORS
|
|
||||||
test-ls-args ls -G && alias ls='ls -G'
|
|
||||||
# Only use GNU ls if installed and there are user defaults for $LS_COLORS,
|
|
||||||
# as the default coloring scheme is not very pretty
|
|
||||||
zstyle -t ':omz:lib:theme-and-appearance' gnu-ls \
|
|
||||||
&& test-ls-args gls --color \
|
|
||||||
&& alias ls='gls --color=tty'
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
if test-ls-args ls --color; then
|
|
||||||
alias ls='ls --color=tty'
|
|
||||||
elif test-ls-args ls -G; then
|
|
||||||
alias ls='ls -G'
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
unfunction test-ls-args
|
|
||||||
|
|||||||
+121
-10
@@ -64,7 +64,7 @@ if [[ ! -w "$ZSH_CACHE_DIR" ]]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Create cache and completions dir and add to $fpath
|
# Create cache and completions dir and add to $fpath
|
||||||
mkdir -p "$ZSH_CACHE_DIR/completions"
|
[[ -d "$ZSH_CACHE_DIR/completions" ]] || mkdir -p "$ZSH_CACHE_DIR/completions"
|
||||||
(( ${fpath[(Ie)$ZSH_CACHE_DIR/completions]} )) || fpath=("$ZSH_CACHE_DIR/completions" $fpath)
|
(( ${fpath[(Ie)$ZSH_CACHE_DIR/completions]} )) || fpath=("$ZSH_CACHE_DIR/completions" $fpath)
|
||||||
|
|
||||||
# Check for updates on initial load...
|
# Check for updates on initial load...
|
||||||
@@ -100,7 +100,28 @@ done
|
|||||||
# Figure out the SHORT hostname
|
# Figure out the SHORT hostname
|
||||||
if [[ "$OSTYPE" = darwin* ]]; then
|
if [[ "$OSTYPE" = darwin* ]]; then
|
||||||
# macOS's $HOST changes with dhcp, etc. Use LocalHostName if possible.
|
# macOS's $HOST changes with dhcp, etc. Use LocalHostName if possible.
|
||||||
SHORT_HOST=$(scutil --get LocalHostName 2>/dev/null) || SHORT_HOST="${HOST/.*/}"
|
# scutil costs a fork on every start, so remember its answer for a day
|
||||||
|
# (like lib/grep.zsh) and re-check sooner if $HOST changes.
|
||||||
|
__omz_host_cache="$ZSH_CACHE_DIR/localhostname"
|
||||||
|
__omz_host_cached=("$__omz_host_cache"(Nm-1))
|
||||||
|
__omz_host_key=
|
||||||
|
SHORT_HOST=
|
||||||
|
if [[ -n "$__omz_host_cached" ]]; then
|
||||||
|
if ! { read -r __omz_host_key && read -r SHORT_HOST } < "$__omz_host_cache"; then
|
||||||
|
__omz_host_key=
|
||||||
|
SHORT_HOST=
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
if [[ "$__omz_host_key" != "$HOST" || -z "$SHORT_HOST" ]]; then
|
||||||
|
# only cache what scutil actually answered, so a transient failure
|
||||||
|
# doesn't pin the fallback name for a day
|
||||||
|
if SHORT_HOST=$(scutil --get LocalHostName 2>/dev/null) && [[ -n "$SHORT_HOST" ]]; then
|
||||||
|
[[ ! -w "$ZSH_CACHE_DIR" ]] || print -rl -- "$HOST" "$SHORT_HOST" >| "$__omz_host_cache"
|
||||||
|
else
|
||||||
|
SHORT_HOST="${HOST/.*/}"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
unset __omz_host_cache __omz_host_cached __omz_host_key
|
||||||
else
|
else
|
||||||
SHORT_HOST="${HOST/.*/}"
|
SHORT_HOST="${HOST/.*/}"
|
||||||
fi
|
fi
|
||||||
@@ -110,13 +131,101 @@ if [[ -z "$ZSH_COMPDUMP" ]]; then
|
|||||||
ZSH_COMPDUMP="${ZDOTDIR:-$HOME}/.zcompdump-${SHORT_HOST}-${ZSH_VERSION}"
|
ZSH_COMPDUMP="${ZDOTDIR:-$HOME}/.zcompdump-${SHORT_HOST}-${ZSH_VERSION}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Construct zcompdump OMZ metadata
|
# Resolve the commit $ZSH is checked out at into $REPLY by reading the git
|
||||||
zcompdump_revision="#omz revision: $(builtin cd -q "$ZSH"; git rev-parse HEAD 2>/dev/null)"
|
# directory, so that no git process is forked on every startup.
|
||||||
|
# Handles .git files (worktrees, submodules), worktree common dirs, detached
|
||||||
|
# HEADs and packed refs. Returns 1 if anything is unexpected.
|
||||||
|
_omz_git_head() {
|
||||||
|
local gitdir="$ZSH/.git" common head ref
|
||||||
|
local -a lines
|
||||||
|
REPLY=
|
||||||
|
|
||||||
|
# .git may be a file pointing at the real git dir
|
||||||
|
if [[ -f "$gitdir" ]]; then
|
||||||
|
read -r head 2>/dev/null < "$gitdir" || return 1
|
||||||
|
[[ "$head" = "gitdir: "* ]] || return 1
|
||||||
|
gitdir="${head#gitdir: }"
|
||||||
|
[[ -n "$gitdir" ]] || return 1
|
||||||
|
[[ "$gitdir" = /* ]] || gitdir="$ZSH/$gitdir"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# worktrees keep their refs in the common git dir
|
||||||
|
common="$gitdir"
|
||||||
|
if [[ -f "$gitdir/commondir" ]]; then
|
||||||
|
read -r common 2>/dev/null < "$gitdir/commondir" || return 1
|
||||||
|
[[ "$common" = /* ]] || common="$gitdir/$common"
|
||||||
|
fi
|
||||||
|
|
||||||
|
[[ -r "$gitdir/HEAD" ]] || return 1
|
||||||
|
read -r head 2>/dev/null < "$gitdir/HEAD" || return 1
|
||||||
|
|
||||||
|
if [[ "$head" = ref:\ * ]]; then
|
||||||
|
ref="${head#ref: }"
|
||||||
|
|
||||||
|
# Only use well-formed full ref names as paths. Besides matching Git's ref
|
||||||
|
# rules, this prevents a malformed HEAD from escaping the git directory.
|
||||||
|
[[ "$ref" = refs/?* \
|
||||||
|
&& "$ref" != *..* \
|
||||||
|
&& "$ref" != *//* \
|
||||||
|
&& "$ref" != */ \
|
||||||
|
&& "$ref" != */.* \
|
||||||
|
&& "$ref" != *.lock \
|
||||||
|
&& "$ref" != *.lock/* \
|
||||||
|
&& "$ref" != *. \
|
||||||
|
&& "$ref" != *'@{'* \
|
||||||
|
&& "$ref" != *[[:cntrl:]\ \~\^\:\?\*\[\\]* \
|
||||||
|
]] || return 1
|
||||||
|
|
||||||
|
case "$ref" in
|
||||||
|
# These namespaces are private to each worktree and are never resolved
|
||||||
|
# from the common directory or its packed-refs file.
|
||||||
|
refs/bisect/*|refs/worktree/*|refs/rewritten/*)
|
||||||
|
[[ -r "$gitdir/$ref" ]] || return 1
|
||||||
|
read -r REPLY 2>/dev/null < "$gitdir/$ref" || return 1
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
if [[ -r "$common/$ref" ]]; then
|
||||||
|
read -r REPLY 2>/dev/null < "$common/$ref" || return 1
|
||||||
|
elif [[ -r "$common/packed-refs" ]]; then
|
||||||
|
lines=("${(@f)$(<"$common/packed-refs")}")
|
||||||
|
REPLY="${lines[(r)* ${(b)ref}]%% *}"
|
||||||
|
else
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
else
|
||||||
|
# detached HEAD: the file holds the commit itself
|
||||||
|
REPLY="$head"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# only an object ID is a usable answer: a symbolic ref, a malformed file or
|
||||||
|
# a missed packed entry all fall through to the git fallback instead
|
||||||
|
[[ -n "$REPLY" && -z "${REPLY//[0-9a-f]/}" ]] \
|
||||||
|
&& (( ${#REPLY} == 40 || ${#REPLY} == 64 ))
|
||||||
|
}
|
||||||
|
|
||||||
|
# Construct zcompdump OMZ metadata. The helper reports through $REPLY, so
|
||||||
|
# call it in a scope that keeps that out of the global namespace.
|
||||||
|
() {
|
||||||
|
local REPLY
|
||||||
|
_omz_git_head || REPLY="$(builtin cd -q "$ZSH"; git rev-parse HEAD 2>/dev/null)"
|
||||||
|
typeset -g zcompdump_revision="#omz revision: $REPLY"
|
||||||
|
}
|
||||||
zcompdump_fpath="#omz fpath: $fpath"
|
zcompdump_fpath="#omz fpath: $fpath"
|
||||||
|
unset -f _omz_git_head
|
||||||
|
|
||||||
|
# Check whether the zcompdump file carries the current OMZ metadata lines
|
||||||
|
_omz_compdump_has_metadata() {
|
||||||
|
local -a lines
|
||||||
|
[[ -r "$ZSH_COMPDUMP" ]] || return 1
|
||||||
|
lines=("${(@f)$(<"$ZSH_COMPDUMP")}")
|
||||||
|
(( ${lines[(Ie)$zcompdump_revision]} && ${lines[(Ie)$zcompdump_fpath]} ))
|
||||||
|
}
|
||||||
|
|
||||||
# Delete the zcompdump file if OMZ zcompdump metadata changed
|
# Delete the zcompdump file if OMZ zcompdump metadata changed
|
||||||
if ! command grep -q -Fx "$zcompdump_revision" "$ZSH_COMPDUMP" 2>/dev/null \
|
zcompdump_refresh=0
|
||||||
|| ! command grep -q -Fx "$zcompdump_fpath" "$ZSH_COMPDUMP" 2>/dev/null; then
|
if ! _omz_compdump_has_metadata; then
|
||||||
command rm -f "$ZSH_COMPDUMP"
|
command rm -f "$ZSH_COMPDUMP"
|
||||||
zcompdump_refresh=1
|
zcompdump_refresh=1
|
||||||
fi
|
fi
|
||||||
@@ -134,9 +243,8 @@ else
|
|||||||
compinit -u -d "$ZSH_COMPDUMP"
|
compinit -u -d "$ZSH_COMPDUMP"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Append zcompdump metadata if missing
|
# Append zcompdump metadata if missing (compinit may have regenerated the file)
|
||||||
if (( $zcompdump_refresh )) \
|
if (( zcompdump_refresh )) || ! _omz_compdump_has_metadata; then
|
||||||
|| ! command grep -q -Fx "$zcompdump_revision" "$ZSH_COMPDUMP" 2>/dev/null; then
|
|
||||||
# Use `tee` in case the $ZSH_COMPDUMP filename is invalid, to silence the error
|
# Use `tee` in case the $ZSH_COMPDUMP filename is invalid, to silence the error
|
||||||
# See https://github.com/ohmyzsh/ohmyzsh/commit/dd1a7269#commitcomment-39003489
|
# See https://github.com/ohmyzsh/ohmyzsh/commit/dd1a7269#commitcomment-39003489
|
||||||
tee -a "$ZSH_COMPDUMP" &>/dev/null <<EOF
|
tee -a "$ZSH_COMPDUMP" &>/dev/null <<EOF
|
||||||
@@ -146,9 +254,12 @@ $zcompdump_fpath
|
|||||||
EOF
|
EOF
|
||||||
fi
|
fi
|
||||||
unset zcompdump_revision zcompdump_fpath zcompdump_refresh
|
unset zcompdump_revision zcompdump_fpath zcompdump_refresh
|
||||||
|
unset -f _omz_compdump_has_metadata
|
||||||
|
|
||||||
# zcompile the completion dump file if the .zwc is older or missing.
|
# zcompile the completion dump file if the .zwc is older or missing.
|
||||||
if command mkdir "${ZSH_COMPDUMP}.lock" 2>/dev/null; then
|
# Test that first so the lock directory and zrecompile are skipped when it's fresh.
|
||||||
|
if [[ ! "${ZSH_COMPDUMP}.zwc" -nt "$ZSH_COMPDUMP" ]] \
|
||||||
|
&& command mkdir "${ZSH_COMPDUMP}.lock" 2>/dev/null; then
|
||||||
zrecompile -q -p "$ZSH_COMPDUMP"
|
zrecompile -q -p "$ZSH_COMPDUMP"
|
||||||
command rm -rf "$ZSH_COMPDUMP.zwc.old" "${ZSH_COMPDUMP}.lock"
|
command rm -rf "$ZSH_COMPDUMP.zwc.old" "${ZSH_COMPDUMP}.lock"
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -11,8 +11,8 @@ fi
|
|||||||
|
|
||||||
zmodload -F zsh/files b:zf_mv
|
zmodload -F zsh/files b:zf_mv
|
||||||
() {
|
() {
|
||||||
local TMPPREFIX="$ZSH_CACHE_DIR/completions/_op"
|
local TMPPREFIX="$ZSH_CACHE_DIR/completions/._op"
|
||||||
zf_mv -f -- =( op completion zsh ) "$TMPPREFIX"
|
zf_mv -f -- =( op completion zsh ) "$ZSH_CACHE_DIR/completions/_op"
|
||||||
} &|
|
} &|
|
||||||
|
|
||||||
# Load opswd function
|
# Load opswd function
|
||||||
|
|||||||
@@ -0,0 +1,122 @@
|
|||||||
|
# AppSignal CLI plugin
|
||||||
|
|
||||||
|
This plugin adds aliases, guard rails and completion for the
|
||||||
|
[AppSignal CLI](https://docs.appsignal.com/cli).
|
||||||
|
|
||||||
|
To use it, add `appsignal-cli` to the plugins array in your zshrc file:
|
||||||
|
|
||||||
|
```zsh
|
||||||
|
plugins=(... appsignal-cli)
|
||||||
|
```
|
||||||
|
|
||||||
|
## Requirements
|
||||||
|
|
||||||
|
[AppSignal CLI](https://docs.appsignal.com/cli) 2.1 or newer, installed and on
|
||||||
|
your `PATH`. The plugin does nothing if it is not:
|
||||||
|
|
||||||
|
```zsh
|
||||||
|
brew install appsignal/appsignal-cli/appsignal-cli
|
||||||
|
# or
|
||||||
|
curl -sSL https://github.com/appsignal/appsignal-cli/releases/latest/download/install.sh | sudo sh
|
||||||
|
```
|
||||||
|
|
||||||
|
Most commands need `appsignal-cli auth login` first.
|
||||||
|
|
||||||
|
## Aliases
|
||||||
|
|
||||||
|
| Alias | Command | Description |
|
||||||
|
| :------ | :----------------------------- | :--------------------------------- |
|
||||||
|
| `asig` | `appsignal-cli` | The AppSignal CLI itself |
|
||||||
|
| `aslog` | `appsignal-cli logs tail` | Stream log lines as they arrive |
|
||||||
|
| `asinc` | `appsignal-cli incidents list` | List incidents for an application |
|
||||||
|
|
||||||
|
`aslog` and `asinc` complete like the commands they stand in for, so
|
||||||
|
`aslog --<TAB>` offers the flags of `appsignal-cli logs tail`.
|
||||||
|
|
||||||
|
## Functions
|
||||||
|
|
||||||
|
| Function | Description |
|
||||||
|
| :-------------- | :----------------------------------------------------------------- |
|
||||||
|
| `appsignal-cli` | Wraps the CLI to confirm before irreversible commands. See Settings |
|
||||||
|
|
||||||
|
## Completion
|
||||||
|
|
||||||
|
Every command completes with a description of what it does, at every level, and
|
||||||
|
so do their flags and allowed values: incident states and severities, sort
|
||||||
|
orders, log severities, trigger fields and comparison operators, output formats
|
||||||
|
and skill targets. `samples` and `sample` complete like `traces`, as they do in
|
||||||
|
the CLI itself.
|
||||||
|
|
||||||
|
`--org` completes offline from the `org` key of your project's
|
||||||
|
`.appsignal.toml` and of the global config.
|
||||||
|
|
||||||
|
The AppSignal CLI ships no completion generator of its own, so `_appsignal-cli`
|
||||||
|
is written from its command definitions and kept in this repository. It targets
|
||||||
|
AppSignal CLI 2.1.x.
|
||||||
|
|
||||||
|
## Settings
|
||||||
|
|
||||||
|
Set these with `zstyle` in your zshrc, before Oh My Zsh is sourced.
|
||||||
|
|
||||||
|
### Confirming destructive commands
|
||||||
|
|
||||||
|
```zsh
|
||||||
|
zstyle ':omz:plugins:appsignal-cli' confirm-destructive no
|
||||||
|
```
|
||||||
|
|
||||||
|
By default the plugin asks for confirmation before four operations that the CLI
|
||||||
|
itself performs without a prompt:
|
||||||
|
|
||||||
|
- `appsignal-cli logs metrics delete`
|
||||||
|
- `appsignal-cli logs triggers delete`
|
||||||
|
- `appsignal-cli triggers archive`, which also closes the trigger's alerts and
|
||||||
|
incidents
|
||||||
|
- `appsignal-cli incidents update --state CLOSED` when it names more than one
|
||||||
|
incident, since that flag accepts a comma-separated list
|
||||||
|
|
||||||
|
Nothing else is intercepted, and the prompt is skipped when stdin is not a
|
||||||
|
terminal, so scripts, pipelines and CI are unaffected. Set the style to `no` to
|
||||||
|
turn the prompt off entirely, or run `command appsignal-cli` for a single
|
||||||
|
invocation.
|
||||||
|
|
||||||
|
### Completing applications
|
||||||
|
|
||||||
|
```zsh
|
||||||
|
zstyle ':omz:plugins:appsignal-cli' dynamic-app-completion yes
|
||||||
|
```
|
||||||
|
|
||||||
|
Off by default. When enabled, `--app`, `--app-id` and `--environment` are
|
||||||
|
completed from `appsignal-cli apps list --output json`, showing each
|
||||||
|
application's name and environment next to its ID instead of making you copy
|
||||||
|
IDs by hand. It is opt-in because it runs the CLI and makes a network call when
|
||||||
|
you press <kbd>Tab</kbd>, and because it needs you to be authenticated. Results
|
||||||
|
are cached for five minutes.
|
||||||
|
|
||||||
|
### Disabling the aliases
|
||||||
|
|
||||||
|
This works for every Oh My Zsh plugin:
|
||||||
|
|
||||||
|
```zsh
|
||||||
|
zstyle ':omz:plugins:appsignal-cli' aliases no
|
||||||
|
```
|
||||||
|
|
||||||
|
## Caveats
|
||||||
|
|
||||||
|
- `appsignal-cli` and the AppSignal Ruby gem's `appsignal` command are different
|
||||||
|
tools. The gem's command installs and diagnoses the agent inside your app;
|
||||||
|
this one queries your data. The plugin deliberately leaves `appsignal` alone,
|
||||||
|
so it keeps working in projects that use the gem.
|
||||||
|
- `appsignal-cli` is a shell function here. Run `command appsignal-cli` to reach
|
||||||
|
the binary directly.
|
||||||
|
- Most commands need exactly one of `--app-id` or `--app`. `--environment` only
|
||||||
|
narrows `--app`; it does nothing next to `--app-id`.
|
||||||
|
- `appsignal-cli project init` writes `.appsignal.toml`, and `auth login` then
|
||||||
|
stores OAuth tokens in it. Do not commit that file.
|
||||||
|
- `incidents delete-note`, `auth logout` and the `--clear-*` flags of
|
||||||
|
`logs metrics update` and `logs triggers update` are destructive too, but are
|
||||||
|
not prompted for: each affects a single note, login or field.
|
||||||
|
- `triggers create` and `triggers update` have their own `--format`, for the
|
||||||
|
format of the metric value. Everywhere else `--format` is a synonym for
|
||||||
|
`--output`.
|
||||||
|
- The CLI sends usage telemetry by default. `APPSIGNAL_CLI_TELEMETRY=0` turns it
|
||||||
|
off, and `APPSIGNAL_CLI_DEBUG=1` shows internal errors.
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,108 @@
|
|||||||
|
# AppSignal CLI: completion, aliases and guard rails.
|
||||||
|
# https://docs.appsignal.com/cli
|
||||||
|
|
||||||
|
if (( ! $+commands[appsignal-cli] )); then
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Does this invocation need confirming? Sets REPLY to the reason.
|
||||||
|
#
|
||||||
|
# The command path is collected from the leading bare words. Only the global
|
||||||
|
# flags may precede a subcommand, so the first other flag ends the path: that
|
||||||
|
# way an option value such as `--app "My App"` is never mistaken for one.
|
||||||
|
function _appsignal_cli_is_destructive() {
|
||||||
|
zstyle -T ':omz:plugins:appsignal-cli' confirm-destructive || return 1
|
||||||
|
|
||||||
|
# Nobody to answer: CI and pipelines are unaffected.
|
||||||
|
[[ -t 0 ]] || return 1
|
||||||
|
|
||||||
|
local -a args=("$@") path numbers
|
||||||
|
local arg state=""
|
||||||
|
integer i=1 n=$# path_done=0
|
||||||
|
|
||||||
|
while (( i <= n )); do
|
||||||
|
arg="$args[i]"
|
||||||
|
case "$arg" in
|
||||||
|
--) break ;;
|
||||||
|
--state=*) state="${arg#--state=}"; path_done=1 ;;
|
||||||
|
--state) state="$args[i+1]"; (( i++ )); path_done=1 ;;
|
||||||
|
--number=*) numbers+=(${(s:,:)${arg#--number=}}); path_done=1 ;;
|
||||||
|
# --number takes one or more values, comma-separated or repeated.
|
||||||
|
--number)
|
||||||
|
path_done=1
|
||||||
|
while (( i < n )) && [[ "$args[i+1]" != -* ]]; do
|
||||||
|
(( i++ ))
|
||||||
|
numbers+=(${(s:,:)args[i]})
|
||||||
|
done
|
||||||
|
;;
|
||||||
|
# The output flag is global, so it can appear before the subcommand.
|
||||||
|
-o|--output|--format) (( i++ )) ;;
|
||||||
|
-o*|--output=*|--format=*) ;;
|
||||||
|
-*) path_done=1 ;;
|
||||||
|
*) (( path_done )) || path+=("$arg") ;;
|
||||||
|
esac
|
||||||
|
(( i++ ))
|
||||||
|
done
|
||||||
|
|
||||||
|
case "${(j: :)path[1,3]}" in
|
||||||
|
"logs metrics delete")
|
||||||
|
REPLY="deleting a log-derived metric cannot be undone."
|
||||||
|
return 0
|
||||||
|
;;
|
||||||
|
"logs triggers delete")
|
||||||
|
REPLY="deleting a log-based trigger cannot be undone."
|
||||||
|
return 0
|
||||||
|
;;
|
||||||
|
"triggers archive")
|
||||||
|
REPLY="archiving a trigger also closes its alerts and incidents."
|
||||||
|
return 0
|
||||||
|
;;
|
||||||
|
"incidents update")
|
||||||
|
if [[ "${(U)state}" == CLOSED ]] && (( $#numbers > 1 )); then
|
||||||
|
REPLY="this closes $#numbers incidents at once."
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
|
# Adds a confirmation prompt before irreversible operations. Everything else
|
||||||
|
# passes straight through, so `logs tail` keeps streaming and pipes stay clean.
|
||||||
|
function appsignal-cli() {
|
||||||
|
local REPLY
|
||||||
|
if _appsignal_cli_is_destructive "$@"; then
|
||||||
|
print -u2 -- "appsignal-cli: $REPLY"
|
||||||
|
if ! read -q "?Continue? [y/N] "; then
|
||||||
|
print -u2 -- ""
|
||||||
|
return 130
|
||||||
|
fi
|
||||||
|
print -u2 -- ""
|
||||||
|
fi
|
||||||
|
|
||||||
|
command appsignal-cli "$@"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Complete the aliases like the commands they stand in for.
|
||||||
|
if (( $+functions[compdef] )); then
|
||||||
|
_aslog() {
|
||||||
|
words=(appsignal-cli logs tail ${words[2,-1]})
|
||||||
|
(( CURRENT += 2 ))
|
||||||
|
_appsignal-cli
|
||||||
|
}
|
||||||
|
|
||||||
|
_asinc() {
|
||||||
|
words=(appsignal-cli incidents list ${words[2,-1]})
|
||||||
|
(( CURRENT += 2 ))
|
||||||
|
_appsignal-cli
|
||||||
|
}
|
||||||
|
|
||||||
|
compdef _appsignal-cli asig
|
||||||
|
compdef _aslog aslog
|
||||||
|
compdef _asinc asinc
|
||||||
|
fi
|
||||||
|
|
||||||
|
alias asig='appsignal-cli'
|
||||||
|
alias aslog='appsignal-cli logs tail'
|
||||||
|
alias asinc='appsignal-cli incidents list'
|
||||||
@@ -13,6 +13,6 @@ fi
|
|||||||
# Generate and load arduino-cli completion
|
# Generate and load arduino-cli completion
|
||||||
zmodload -F zsh/files b:zf_mv
|
zmodload -F zsh/files b:zf_mv
|
||||||
() {
|
() {
|
||||||
local TMPPREFIX="$ZSH_CACHE_DIR/completions/_arduino-cli"
|
local TMPPREFIX="$ZSH_CACHE_DIR/completions/._arduino-cli"
|
||||||
zf_mv -f -- =( arduino-cli completion zsh ) "$TMPPREFIX"
|
zf_mv -f -- =( arduino-cli completion zsh ) "$ZSH_CACHE_DIR/completions/_arduino-cli"
|
||||||
} &|
|
} &|
|
||||||
|
|||||||
@@ -13,6 +13,6 @@ fi
|
|||||||
|
|
||||||
zmodload -F zsh/files b:zf_mv
|
zmodload -F zsh/files b:zf_mv
|
||||||
() {
|
() {
|
||||||
local TMPPREFIX="$ZSH_CACHE_DIR/completions/_argocd"
|
local TMPPREFIX="$ZSH_CACHE_DIR/completions/._argocd"
|
||||||
zf_mv -f -- =( argocd completion zsh ) "$TMPPREFIX"
|
zf_mv -f -- =( argocd completion zsh ) "$ZSH_CACHE_DIR/completions/_argocd"
|
||||||
} &|
|
} &|
|
||||||
|
|||||||
@@ -14,6 +14,6 @@ if [[ ! -f "$ZSH_CACHE_DIR/completions/_asdf" ]]; then
|
|||||||
fi
|
fi
|
||||||
zmodload -F zsh/files b:zf_mv
|
zmodload -F zsh/files b:zf_mv
|
||||||
() {
|
() {
|
||||||
local TMPPREFIX="$ZSH_CACHE_DIR/completions/_asdf"
|
local TMPPREFIX="$ZSH_CACHE_DIR/completions/._asdf"
|
||||||
zf_mv -f -- =( asdf completion zsh ) "$TMPPREFIX"
|
zf_mv -f -- =( asdf completion zsh ) "$ZSH_CACHE_DIR/completions/_asdf"
|
||||||
} &|
|
} &|
|
||||||
|
|||||||
@@ -241,7 +241,7 @@ function aws_regions() {
|
|||||||
function aws_profiles() {
|
function aws_profiles() {
|
||||||
aws --no-cli-pager configure list-profiles 2> /dev/null && return
|
aws --no-cli-pager configure list-profiles 2> /dev/null && return
|
||||||
[[ -r "${AWS_CONFIG_FILE:-$HOME/.aws/config}" ]] || return 1
|
[[ -r "${AWS_CONFIG_FILE:-$HOME/.aws/config}" ]] || return 1
|
||||||
grep --color=never -Eo '\[.*\]' "${AWS_CONFIG_FILE:-$HOME/.aws/config}" | sed -E 's/^[[:space:]]*\[(profile)?[[:space:]]*([^[:space:]]+)\][[:space:]]*$/\2/g'
|
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/'
|
||||||
}
|
}
|
||||||
|
|
||||||
function _aws_regions() {
|
function _aws_regions() {
|
||||||
|
|||||||
@@ -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'
|
||||||
|
|||||||
@@ -13,6 +13,6 @@ fi
|
|||||||
# Generate and load buf completion
|
# Generate and load buf completion
|
||||||
zmodload -F zsh/files b:zf_mv
|
zmodload -F zsh/files b:zf_mv
|
||||||
() {
|
() {
|
||||||
local TMPPREFIX="$ZSH_CACHE_DIR/completions/_buf"
|
local TMPPREFIX="$ZSH_CACHE_DIR/completions/._buf"
|
||||||
zf_mv -f -- =( buf completion zsh ) "$TMPPREFIX"
|
zf_mv -f -- =( buf completion zsh ) "$ZSH_CACHE_DIR/completions/_buf"
|
||||||
} &|
|
} &|
|
||||||
|
|||||||
@@ -13,6 +13,6 @@ fi
|
|||||||
|
|
||||||
zmodload -F zsh/files b:zf_mv
|
zmodload -F zsh/files b:zf_mv
|
||||||
() {
|
() {
|
||||||
local TMPPREFIX="$ZSH_CACHE_DIR/completions/_bun"
|
local TMPPREFIX="$ZSH_CACHE_DIR/completions/._bun"
|
||||||
zf_mv -f -- =( SHELL=zsh bun completions ) "$TMPPREFIX"
|
zf_mv -f -- =( SHELL=zsh bun completions ) "$ZSH_CACHE_DIR/completions/_bun"
|
||||||
} &|
|
} &|
|
||||||
|
|||||||
@@ -13,6 +13,6 @@ fi
|
|||||||
|
|
||||||
zmodload -F zsh/files b:zf_mv
|
zmodload -F zsh/files b:zf_mv
|
||||||
() {
|
() {
|
||||||
local TMPPREFIX="$ZSH_CACHE_DIR/completions/_charm"
|
local TMPPREFIX="$ZSH_CACHE_DIR/completions/._charm"
|
||||||
zf_mv -f -- =( charm completion zsh ) "$TMPPREFIX"
|
zf_mv -f -- =( charm completion zsh ) "$ZSH_CACHE_DIR/completions/_charm"
|
||||||
} &|
|
} &|
|
||||||
|
|||||||
@@ -13,6 +13,6 @@ fi
|
|||||||
|
|
||||||
zmodload -F zsh/files b:zf_mv
|
zmodload -F zsh/files b:zf_mv
|
||||||
() {
|
() {
|
||||||
local TMPPREFIX="$ZSH_CACHE_DIR/completions/_chezmoi"
|
local TMPPREFIX="$ZSH_CACHE_DIR/completions/._chezmoi"
|
||||||
zf_mv -f -- =( chezmoi completion zsh ) "$TMPPREFIX"
|
zf_mv -f -- =( chezmoi completion zsh ) "$ZSH_CACHE_DIR/completions/_chezmoi"
|
||||||
} &|
|
} &|
|
||||||
|
|||||||
@@ -13,6 +13,6 @@ fi
|
|||||||
|
|
||||||
zmodload -F zsh/files b:zf_mv
|
zmodload -F zsh/files b:zf_mv
|
||||||
() {
|
() {
|
||||||
local TMPPREFIX="$ZSH_CACHE_DIR/completions/_codex"
|
local TMPPREFIX="$ZSH_CACHE_DIR/completions/._codex"
|
||||||
zf_mv -f -- =( codex completion zsh < /dev/null 2> /dev/null ) "$TMPPREFIX"
|
zf_mv -f -- =( codex completion zsh < /dev/null 2> /dev/null ) "$ZSH_CACHE_DIR/completions/_codex"
|
||||||
} &|
|
} &|
|
||||||
|
|||||||
@@ -99,18 +99,21 @@ $ find . -type f 2>/dev/null
|
|||||||
## File extension aliases
|
## File extension aliases
|
||||||
|
|
||||||
These are special aliases that are triggered when a file name is passed as the command. For example,
|
These are special aliases that are triggered when a file name is passed as the command. For example,
|
||||||
if the pdf file extension is aliased to `acroread` (a popular Linux pdf reader), when running `file.pdf`
|
if the pdf file extension is aliased to `open_command`, running `file.pdf` opens that file with
|
||||||
that file will be open with `acroread`.
|
whatever application your system uses for PDFs.
|
||||||
|
|
||||||
### Reading Docs
|
### Reading Docs
|
||||||
|
|
||||||
| Alias | Command | Description |
|
These use `open_command`, which picks the right opener for your platform: `open` on macOS,
|
||||||
| ----- | ---------- | ---------------------------------- |
|
`xdg-open` on Linux, `cygstart` on Cygwin.
|
||||||
| pdf | `acroread` | Opens up a document using acroread |
|
|
||||||
| ps | `gv` | Opens up a .ps file using gv |
|
| Alias | Command | Description |
|
||||||
| dvi | `xdvi` | Opens up a .dvi file using xdvi |
|
| ----- | -------------- | ----------------------------------------------- |
|
||||||
| chm | `xchm` | Opens up a .chm file using xchm |
|
| pdf | `open_command` | Opens up a .pdf file in your default viewer |
|
||||||
| djvu | `djview` | Opens up a .djvu file using djview |
|
| ps | `open_command` | Opens up a .ps file in your default viewer |
|
||||||
|
| dvi | `open_command` | Opens up a .dvi file in your default viewer |
|
||||||
|
| chm | `open_command` | Opens up a .chm file in your default viewer |
|
||||||
|
| djvu | `open_command` | Opens up a .djvu file in your default viewer |
|
||||||
|
|
||||||
### Listing files inside a packed file
|
### Listing files inside a packed file
|
||||||
|
|
||||||
|
|||||||
@@ -71,12 +71,9 @@ if is-at-least 4.2.0; then
|
|||||||
_media_fts=(ape avi flv m4a mkv mov mp3 mpeg mpg ogg ogm rm wav webm)
|
_media_fts=(ape avi flv m4a mkv mov mp3 mpeg mpg ogg ogm rm wav webm)
|
||||||
for ft in $_media_fts; do alias -s $ft=mplayer; done
|
for ft in $_media_fts; do alias -s $ft=mplayer; done
|
||||||
|
|
||||||
#read documents
|
# read documents with the platform's default application
|
||||||
alias -s pdf=acroread
|
_doc_fts=(pdf ps dvi chm djvu)
|
||||||
alias -s ps=gv
|
for ft in $_doc_fts; do alias -s $ft=open_command; done
|
||||||
alias -s dvi=xdvi
|
|
||||||
alias -s chm=xchm
|
|
||||||
alias -s djvu=djview
|
|
||||||
|
|
||||||
#list what's inside packed file
|
#list what's inside packed file
|
||||||
alias -s zip="unzip -l"
|
alias -s zip="unzip -l"
|
||||||
|
|||||||
@@ -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 ))
|
||||||
@@ -27,6 +27,6 @@ fi
|
|||||||
|
|
||||||
zmodload -F zsh/files b:zf_mv
|
zmodload -F zsh/files b:zf_mv
|
||||||
() {
|
() {
|
||||||
local TMPPREFIX="$ZSH_CACHE_DIR/completions/_deno"
|
local TMPPREFIX="$ZSH_CACHE_DIR/completions/._deno"
|
||||||
zf_mv -f -- =( deno completions zsh ) "$TMPPREFIX"
|
zf_mv -f -- =( deno completions zsh ) "$ZSH_CACHE_DIR/completions/_deno"
|
||||||
} &|
|
} &|
|
||||||
|
|||||||
@@ -13,25 +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 |
|
||||||
|
| dcstart | `docker-compose start` | Start a container |
|
||||||
|
| dck | `docker-compose kill` | Kills containers |
|
||||||
|
| 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"
|
||||||
@@ -24,5 +26,8 @@ alias dclF="$dccmd logs -f --tail 0"
|
|||||||
alias dcpull="$dccmd pull"
|
alias dcpull="$dccmd pull"
|
||||||
alias dcstart="$dccmd start"
|
alias dcstart="$dccmd start"
|
||||||
alias dck="$dccmd kill"
|
alias dck="$dccmd kill"
|
||||||
|
alias dcv="$dccmd version"
|
||||||
|
alias dcsts="$dccmd stats"
|
||||||
|
alias dci="$dccmd images"
|
||||||
|
|
||||||
unset dccmd
|
unset dccmd
|
||||||
|
|||||||
@@ -48,6 +48,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
|
||||||
@@ -68,7 +73,7 @@ zmodload -F zsh/files b:zf_mv
|
|||||||
! is-at-least 23.0.0 ${${(s:,:z)"$(command docker --version)"}[3]}; then
|
! is-at-least 23.0.0 ${${(s:,:z)"$(command docker --version)"}[3]}; then
|
||||||
command cp "${plugin_dir}/completions/_docker" "$ZSH_CACHE_DIR/completions/_docker"
|
command cp "${plugin_dir}/completions/_docker" "$ZSH_CACHE_DIR/completions/_docker"
|
||||||
else
|
else
|
||||||
local TMPPREFIX="$ZSH_CACHE_DIR/completions/_docker"
|
local TMPPREFIX="$ZSH_CACHE_DIR/completions/._docker"
|
||||||
zf_mv -f -- =( command docker completion zsh ) "$TMPPREFIX"
|
zf_mv -f -- =( command docker completion zsh ) "$ZSH_CACHE_DIR/completions/_docker"
|
||||||
fi
|
fi
|
||||||
} "${0:A:h}" &|
|
} "${0:A:h}" &|
|
||||||
|
|||||||
@@ -16,6 +16,6 @@ fi
|
|||||||
|
|
||||||
zmodload -F zsh/files b:zf_mv
|
zmodload -F zsh/files b:zf_mv
|
||||||
() {
|
() {
|
||||||
local TMPPREFIX="$ZSH_CACHE_DIR/completions/_doctl"
|
local TMPPREFIX="$ZSH_CACHE_DIR/completions/._doctl"
|
||||||
zf_mv -f -- =( doctl completion zsh ) "$TMPPREFIX"
|
zf_mv -f -- =( doctl completion zsh ) "$ZSH_CACHE_DIR/completions/_doctl"
|
||||||
} &|
|
} &|
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
@@ -1,20 +1,40 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
emacsfun() {
|
emacsfun() {
|
||||||
local cmd frames
|
local cmd frames arg tty
|
||||||
|
|
||||||
# Build the Emacs Lisp command to check for suitable frames
|
# Build the Emacs Lisp command to check for suitable frames
|
||||||
# See https://www.gnu.org/software/emacs/manual/html_node/elisp/Frames.html#index-framep
|
# See https://www.gnu.org/software/emacs/manual/html_node/elisp/Frames.html#index-framep
|
||||||
case "$*" in
|
for arg in "$@"; do
|
||||||
*-t*|*--tty*|*-nw*) cmd="(memq 't (mapcar 'framep (frame-list)))" ;; # if != nil, there are tty frames
|
case "$arg" in
|
||||||
*) cmd="(delete 't (mapcar 'framep (frame-list)))" ;; # if != nil, there are graphical terminals (x, w32, ns)
|
-t|--tty|-nw) tty=1; break ;;
|
||||||
esac
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ -n "$tty" ]; then
|
||||||
|
cmd="(memq 't (mapcar 'framep (frame-list)))" # if != nil, there are tty frames
|
||||||
|
else
|
||||||
|
cmd="(delete 't (mapcar 'framep (frame-list)))" # if != nil, there are graphical terminals (x, w32, ns)
|
||||||
|
fi
|
||||||
|
|
||||||
|
# A tty frame needs the client to stay attached, so drop the --no-wait the
|
||||||
|
# `emacs` alias adds. Otherwise emacsclient returns at once and nothing opens.
|
||||||
|
if [ -n "$tty" ]; then
|
||||||
|
for arg do
|
||||||
|
shift
|
||||||
|
case "$arg" in
|
||||||
|
--no-wait) continue ;;
|
||||||
|
esac
|
||||||
|
set -- "$@" "$arg"
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
# Check if there are suitable frames
|
# Check if there are suitable frames
|
||||||
frames="$(emacsclient -a '' -n -e "$cmd" 2>/dev/null |sed 's/.*\x07//g' )"
|
frames="$(emacsclient -a '' -n -e "$cmd" 2>/dev/null |sed 's/.*\x07//g' )"
|
||||||
|
|
||||||
# Only create another X frame if there isn't one present
|
# A bare emacs/e passes only --no-wait, so it still needs --create-frame.
|
||||||
if [ -z "$frames" -o "$frames" = nil ]; then
|
if [ -z "$frames" ] || [ "$frames" = nil ] || [ "$#" -eq 0 ] \
|
||||||
|
|| { [ "$#" -eq 1 ] && [ "$1" = --no-wait ]; }; then
|
||||||
emacsclient --alternate-editor="" --create-frame "$@"
|
emacsclient --alternate-editor="" --create-frame "$@"
|
||||||
return $?
|
return $?
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -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"
|
||||||
|
}
|
||||||
@@ -45,6 +45,36 @@ If `yes`, always add `-h` flag to add a header row for each column.
|
|||||||
|
|
||||||
Default: `no`
|
Default: `no`
|
||||||
|
|
||||||
|
### `links`
|
||||||
|
|
||||||
|
```zsh
|
||||||
|
zstyle ':omz:plugins:eza' 'links' yes|no
|
||||||
|
```
|
||||||
|
|
||||||
|
If `yes`, always add `-H` flag to show hard links for each file.
|
||||||
|
|
||||||
|
Default: `no`
|
||||||
|
|
||||||
|
### `octal`
|
||||||
|
|
||||||
|
```zsh
|
||||||
|
zstyle ':omz:plugins:eza' 'octal' yes|no
|
||||||
|
```
|
||||||
|
|
||||||
|
If `yes`, always add `-o` flag to show file permissions as octal numbers.
|
||||||
|
|
||||||
|
Default: `no`
|
||||||
|
|
||||||
|
### `inodes`
|
||||||
|
|
||||||
|
```zsh
|
||||||
|
zstyle ':omz:plugins:eza' 'inodes' yes|no
|
||||||
|
```
|
||||||
|
|
||||||
|
If `yes`, always add `-i` flag to show the inode for each file.
|
||||||
|
|
||||||
|
Default: `no`
|
||||||
|
|
||||||
### `show-group`
|
### `show-group`
|
||||||
|
|
||||||
```zsh
|
```zsh
|
||||||
|
|||||||
@@ -21,6 +21,15 @@ function _configure_eza() {
|
|||||||
if zstyle -t ':omz:plugins:eza' 'header'; then
|
if zstyle -t ':omz:plugins:eza' 'header'; then
|
||||||
_EZA_HEAD+=("h")
|
_EZA_HEAD+=("h")
|
||||||
fi
|
fi
|
||||||
|
if zstyle -t ':omz:plugins:eza' 'links'; then
|
||||||
|
_EZA_HEAD+=("H")
|
||||||
|
fi
|
||||||
|
if zstyle -t ':omz:plugins:eza' 'octal'; then
|
||||||
|
_EZA_HEAD+=("o")
|
||||||
|
fi
|
||||||
|
if zstyle -t ':omz:plugins:eza' 'inodes'; then
|
||||||
|
_EZA_HEAD+=("i")
|
||||||
|
fi
|
||||||
zstyle -s ':omz:plugins:eza' 'size-prefix' _val
|
zstyle -s ':omz:plugins:eza' 'size-prefix' _val
|
||||||
case "${_val:l}" in
|
case "${_val:l}" in
|
||||||
binary)
|
binary)
|
||||||
|
|||||||
@@ -32,6 +32,6 @@ fi
|
|||||||
|
|
||||||
zmodload -F zsh/files b:zf_mv
|
zmodload -F zsh/files b:zf_mv
|
||||||
() {
|
() {
|
||||||
local TMPPREFIX="$ZSH_CACHE_DIR/completions/_flutter"
|
local TMPPREFIX="$ZSH_CACHE_DIR/completions/._flutter"
|
||||||
zf_mv -f -- =( flutter zsh-completion < /dev/null ) "$TMPPREFIX"
|
zf_mv -f -- =( flutter zsh-completion < /dev/null ) "$ZSH_CACHE_DIR/completions/_flutter"
|
||||||
} &|
|
} &|
|
||||||
|
|||||||
@@ -13,6 +13,6 @@ fi
|
|||||||
|
|
||||||
zmodload -F zsh/files b:zf_mv
|
zmodload -F zsh/files b:zf_mv
|
||||||
() {
|
() {
|
||||||
local TMPPREFIX="$ZSH_CACHE_DIR/completions/_flux"
|
local TMPPREFIX="$ZSH_CACHE_DIR/completions/._flux"
|
||||||
zf_mv -f -- =( flux completion zsh ) "$TMPPREFIX"
|
zf_mv -f -- =( flux completion zsh ) "$ZSH_CACHE_DIR/completions/_flux"
|
||||||
} &|
|
} &|
|
||||||
|
|||||||
@@ -12,8 +12,8 @@ fi
|
|||||||
|
|
||||||
zmodload -F zsh/files b:zf_mv
|
zmodload -F zsh/files b:zf_mv
|
||||||
() {
|
() {
|
||||||
local TMPPREFIX="$ZSH_CACHE_DIR/completions/_fnm"
|
local TMPPREFIX="$ZSH_CACHE_DIR/completions/._fnm"
|
||||||
zf_mv -f -- =( fnm completions --shell=zsh ) "$TMPPREFIX"
|
zf_mv -f -- =( fnm completions --shell=zsh ) "$ZSH_CACHE_DIR/completions/_fnm"
|
||||||
} &|
|
} &|
|
||||||
|
|
||||||
if zstyle -t ':omz:plugins:fnm' autostart; then
|
if zstyle -t ':omz:plugins:fnm' autostart; then
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ function frontend() {
|
|||||||
codepen 'https://codepen.io/search/pens?q='
|
codepen 'https://codepen.io/search/pens?q='
|
||||||
compassdoc 'http://compass-style.org/search?q='
|
compassdoc 'http://compass-style.org/search?q='
|
||||||
cssflow 'http://www.cssflow.com/search?q='
|
cssflow 'http://www.cssflow.com/search?q='
|
||||||
dartlang 'https://api.dartlang.org/apidocs/channels/stable/dartdoc-viewer/dart:'
|
dartlang $(_frontend_fallback 'dart.dev')
|
||||||
emberjs $(_frontend_fallback 'emberjs.com/')
|
emberjs $(_frontend_fallback 'emberjs.com/')
|
||||||
flowtype $(_frontend_fallback 'flow.org/en/docs/')
|
flowtype $(_frontend_fallback 'flow.org/en/docs/')
|
||||||
fontello 'http://fontello.com/#search='
|
fontello 'http://fontello.com/#search='
|
||||||
|
|||||||
@@ -13,6 +13,6 @@ fi
|
|||||||
|
|
||||||
zmodload -F zsh/files b:zf_mv
|
zmodload -F zsh/files b:zf_mv
|
||||||
() {
|
() {
|
||||||
local TMPPREFIX="$ZSH_CACHE_DIR/completions/_gcx"
|
local TMPPREFIX="$ZSH_CACHE_DIR/completions/._gcx"
|
||||||
zf_mv -f -- =( gcx completion zsh ) "$TMPPREFIX"
|
zf_mv -f -- =( gcx completion zsh ) "$ZSH_CACHE_DIR/completions/_gcx"
|
||||||
} &|
|
} &|
|
||||||
|
|||||||
@@ -17,7 +17,4 @@ plugin is loaded, which is usually when you start up a new terminal emulator.
|
|||||||
|
|
||||||
The cache is stored at:
|
The cache is stored at:
|
||||||
|
|
||||||
- `$ZSH/plugins/gh/_gh` completions script
|
- `$ZSH_CACHE_DIR/completions/_gh` completions script
|
||||||
|
|
||||||
- `$ZSH_CACHE_DIR/gh_version` version of GitHub CLI, used to invalidate
|
|
||||||
the cache.
|
|
||||||
|
|||||||
@@ -13,6 +13,6 @@ fi
|
|||||||
|
|
||||||
zmodload -F zsh/files b:zf_mv
|
zmodload -F zsh/files b:zf_mv
|
||||||
() {
|
() {
|
||||||
local TMPPREFIX="$ZSH_CACHE_DIR/completions/_gh"
|
local TMPPREFIX="$ZSH_CACHE_DIR/completions/._gh"
|
||||||
zf_mv -f -- =( gh completion --shell zsh ) "$TMPPREFIX"
|
zf_mv -f -- =( gh completion --shell zsh ) "$ZSH_CACHE_DIR/completions/_gh"
|
||||||
} &|
|
} &|
|
||||||
|
|||||||
@@ -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
|
|
||||||
|
|||||||
@@ -103,10 +103,12 @@ plugins=(... git)
|
|||||||
| `glods` | `git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ad) %C(bold blue)<%an>%Creset' --date=short` |
|
| `glods` | `git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ad) %C(bold blue)<%an>%Creset' --date=short` |
|
||||||
| `glol` | `git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ar) %C(bold blue)<%an>%Creset'` |
|
| `glol` | `git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ar) %C(bold blue)<%an>%Creset'` |
|
||||||
| `glola` | `git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ar) %C(bold blue)<%an>%Creset' --all` |
|
| `glola` | `git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ar) %C(bold blue)<%an>%Creset' --all` |
|
||||||
|
| `glolm` | `git log $(git_main_branch) --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ar) %C(bold blue)<%an>%Creset'` |
|
||||||
| `glols` | `git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ar) %C(bold blue)<%an>%Creset' --stat` |
|
| `glols` | `git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ar) %C(bold blue)<%an>%Creset' --stat` |
|
||||||
| `glo` | `git log --oneline --decorate` |
|
| `glo` | `git log --oneline --decorate` |
|
||||||
| `glog` | `git log --oneline --decorate --graph` |
|
| `glog` | `git log --oneline --decorate --graph` |
|
||||||
| `gloga` | `git log --oneline --decorate --graph --all` |
|
| `gloga` | `git log --oneline --decorate --graph --all` |
|
||||||
|
| `glom` | `git log --oneline --decorate --color $(git_main_branch)..` |
|
||||||
| `glp` | `git log --pretty=<format>` |
|
| `glp` | `git log --pretty=<format>` |
|
||||||
| `glg` | `git log --stat` |
|
| `glg` | `git log --stat` |
|
||||||
| `glgp` | `git log --stat --patch` |
|
| `glgp` | `git log --stat --patch` |
|
||||||
@@ -154,6 +156,8 @@ plugins=(... git)
|
|||||||
| `grba` | `git rebase --abort` |
|
| `grba` | `git rebase --abort` |
|
||||||
| `grbc` | `git rebase --continue` |
|
| `grbc` | `git rebase --continue` |
|
||||||
| `grbi` | `git rebase --interactive` |
|
| `grbi` | `git rebase --interactive` |
|
||||||
|
| `grbmi` | `git rebase $(git_main_branch) --interactive` |
|
||||||
|
| `grbmia` | `git rebase $(git_main_branch) --interactive --autosquash` |
|
||||||
| `grbo` | `git rebase --onto` |
|
| `grbo` | `git rebase --onto` |
|
||||||
| `grbs` | `git rebase --skip` |
|
| `grbs` | `git rebase --skip` |
|
||||||
| `grbd` | `git rebase $(git_develop_branch)` |
|
| `grbd` | `git rebase $(git_develop_branch)` |
|
||||||
@@ -187,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` |
|
||||||
@@ -201,8 +206,10 @@ plugins=(... git)
|
|||||||
| `gst` | `git status` |
|
| `gst` | `git status` |
|
||||||
| `gss` | `git status --short` |
|
| `gss` | `git status --short` |
|
||||||
| `gsb` | `git status --short -b` |
|
| `gsb` | `git status --short -b` |
|
||||||
|
| `gsnut` | `git status --untracked-files=no` |
|
||||||
| `gsi` | `git submodule init` |
|
| `gsi` | `git submodule init` |
|
||||||
| `gsu` | `git submodule update` |
|
| `gsu` | `git submodule update` |
|
||||||
|
| `gsuri` | `git submodule update --recursive --init` |
|
||||||
| `gsd` | `git svn dcommit` |
|
| `gsd` | `git svn dcommit` |
|
||||||
| `git-svn-dcommit-push` | `git svn dcommit && git push github $(git_main_branch):svntrunk` |
|
| `git-svn-dcommit-push` | `git svn dcommit && git push github $(git_main_branch):svntrunk` |
|
||||||
| `gsr` | `git svn rebase` |
|
| `gsr` | `git svn rebase` |
|
||||||
@@ -254,6 +261,7 @@ receive further support.
|
|||||||
| `git_current_user_name` | Returns the `user.name` config value (Lives in `lib/git.zsh`) |
|
| `git_current_user_name` | Returns the `user.name` config value (Lives in `lib/git.zsh`) |
|
||||||
| `git_develop_branch` | Returns the name of the “development” branch: `dev`, `devel`, `development` if they exist, `develop` otherwise |
|
| `git_develop_branch` | Returns the name of the “development” branch: `dev`, `devel`, `development` if they exist, `develop` otherwise |
|
||||||
| `git_main_branch` | Returns the name of the main branch: `main` if it exists, `master` otherwise |
|
| `git_main_branch` | Returns the name of the main branch: `main` if it exists, `master` otherwise |
|
||||||
|
| `gbcopy` | Copies current branch name to clipboard |
|
||||||
| `grename <old> <new>` | Renames branch `<old>` to `<new>`, including on the origin remote |
|
| `grename <old> <new>` | Renames branch `<old>` to `<new>`, including on the origin remote |
|
||||||
| `gbda` | Deletes all merged branches |
|
| `gbda` | Deletes all merged branches |
|
||||||
| `gbds` | Deletes all squash-merged branches (**Note: performance degrades with number of branches**) |
|
| `gbds` | Deletes all squash-merged branches (**Note: performance degrades with number of branches**) |
|
||||||
|
|||||||
+18
-20
@@ -1,25 +1,6 @@
|
|||||||
# Git version checking
|
# Git version checking
|
||||||
autoload -Uz is-at-least
|
autoload -Uz is-at-least
|
||||||
# Running `git version` forks on every startup, so cache the result for a day
|
git_version="${${(As: :)$(git version 2>/dev/null)}[3]}"
|
||||||
# in $ZSH_CACHE_DIR, keyed on the git command path, mtime, and exec path.
|
|
||||||
() {
|
|
||||||
local cache="$ZSH_CACHE_DIR/git-version" key exec_path
|
|
||||||
local -a stat lines
|
|
||||||
zmodload -F zsh/stat b:zstat
|
|
||||||
zstat -A stat +mtime -- "$commands[git]" 2>/dev/null
|
|
||||||
exec_path="$(git --exec-path 2>/dev/null)"
|
|
||||||
key="$commands[git] $stat[1] $exec_path"
|
|
||||||
|
|
||||||
lines=("$cache"(Nm-1))
|
|
||||||
(( $#lines )) && lines=("${(@f)$(<"$cache")}")
|
|
||||||
if [[ "$lines[1]" = "$key" ]]; then
|
|
||||||
git_version="$lines[2]"
|
|
||||||
return
|
|
||||||
fi
|
|
||||||
|
|
||||||
git_version="${${(As: :)$(git version 2>/dev/null)}[3]}"
|
|
||||||
[[ ! -w "$ZSH_CACHE_DIR" ]] || print -rl -- "$key" "$git_version" >| "$cache"
|
|
||||||
}
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Functions Current
|
# Functions Current
|
||||||
@@ -68,6 +49,16 @@ function git_main_branch() {
|
|||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function gbcopy() {
|
||||||
|
command git rev-parse --git-dir &>/dev/null || return
|
||||||
|
|
||||||
|
local branch
|
||||||
|
branch="$(git_current_branch)" || return
|
||||||
|
[[ -n "$branch" ]] || return 1
|
||||||
|
|
||||||
|
print -rn -- "$branch" | clipcopy
|
||||||
|
}
|
||||||
|
|
||||||
function grename() {
|
function grename() {
|
||||||
if [[ -z "$1" || -z "$2" ]]; then
|
if [[ -z "$1" || -z "$2" ]]; then
|
||||||
echo "Usage: $0 old_branch new_branch"
|
echo "Usage: $0 old_branch new_branch"
|
||||||
@@ -258,9 +249,11 @@ alias glod='git log --graph --pretty="%Cred%h%Creset -%C(auto)%d%Creset %s %Cgre
|
|||||||
alias glola='git log --graph --pretty="%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ar) %C(bold blue)<%an>%Creset" --all'
|
alias glola='git log --graph --pretty="%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ar) %C(bold blue)<%an>%Creset" --all'
|
||||||
alias glols='git log --graph --pretty="%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ar) %C(bold blue)<%an>%Creset" --stat'
|
alias glols='git log --graph --pretty="%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ar) %C(bold blue)<%an>%Creset" --stat'
|
||||||
alias glol='git log --graph --pretty="%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ar) %C(bold blue)<%an>%Creset"'
|
alias glol='git log --graph --pretty="%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ar) %C(bold blue)<%an>%Creset"'
|
||||||
|
alias glolm='git log $(git_main_branch) --graph --pretty="%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ar) %C(bold blue)<%an>%Creset"'
|
||||||
alias glo='git log --oneline --decorate'
|
alias glo='git log --oneline --decorate'
|
||||||
alias glog='git log --oneline --decorate --graph'
|
alias glog='git log --oneline --decorate --graph'
|
||||||
alias gloga='git log --oneline --decorate --graph --all'
|
alias gloga='git log --oneline --decorate --graph --all'
|
||||||
|
alias glom='git log --oneline --decorate --color $(git_main_branch)..'
|
||||||
|
|
||||||
# Pretty log messages
|
# Pretty log messages
|
||||||
function _git_log_prettily(){
|
function _git_log_prettily(){
|
||||||
@@ -370,6 +363,8 @@ alias grbd='git rebase $(git_develop_branch)'
|
|||||||
alias grbm='git rebase $(git_main_branch)'
|
alias grbm='git rebase $(git_main_branch)'
|
||||||
alias grbom='git rebase origin/$(git_main_branch)'
|
alias grbom='git rebase origin/$(git_main_branch)'
|
||||||
alias grbum='git rebase upstream/$(git_main_branch)'
|
alias grbum='git rebase upstream/$(git_main_branch)'
|
||||||
|
alias grbmi='git rebase $(git_main_branch) --interactive'
|
||||||
|
alias grbmia='git rebase $(git_main_branch) --interactive --autosquash'
|
||||||
alias grf='git reflog'
|
alias grf='git reflog'
|
||||||
alias gr='git remote'
|
alias gr='git remote'
|
||||||
alias grv='git remote --verbose'
|
alias grv='git remote --verbose'
|
||||||
@@ -397,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'
|
||||||
@@ -412,8 +408,10 @@ alias gsts='git stash show --patch'
|
|||||||
alias gst='git status'
|
alias gst='git status'
|
||||||
alias gss='git status --short'
|
alias gss='git status --short'
|
||||||
alias gsb='git status --short --branch'
|
alias gsb='git status --short --branch'
|
||||||
|
alias gsnut='git status --untracked-files=no'
|
||||||
alias gsi='git submodule init'
|
alias gsi='git submodule init'
|
||||||
alias gsu='git submodule update'
|
alias gsu='git submodule update'
|
||||||
|
alias gsuri='git submodule update --recursive --init'
|
||||||
alias gsd='git svn dcommit'
|
alias gsd='git svn dcommit'
|
||||||
alias git-svn-dcommit-push='git svn dcommit && git push github $(git_main_branch):svntrunk'
|
alias git-svn-dcommit-push='git svn dcommit && git push github $(git_main_branch):svntrunk'
|
||||||
alias gsr='git svn rebase'
|
alias gsr='git svn rebase'
|
||||||
|
|||||||
+34
-36
@@ -1,45 +1,43 @@
|
|||||||
# github plugin
|
# github plugin
|
||||||
|
|
||||||
This plugin supports working with GitHub from the command line. It provides a few things:
|
> [!WARNING]
|
||||||
|
> This plugin is deprecated and will be removed in a future release. It supports
|
||||||
|
> the legacy [`hub`](https://github.com/mislav/hub) CLI, not the current GitHub
|
||||||
|
> CLI. For `gh` completion, use the [`gh` plugin](../gh) instead.
|
||||||
|
|
||||||
* Sets up the `hub` wrapper and completions for the `git` command if you have [`hub`](https://github.com/github/hub) installed.
|
The plugin provides compatibility for existing `hub` users by:
|
||||||
* Completion for the [`github` Ruby gem](https://github.com/defunkt/github-gem).
|
|
||||||
* Convenience functions for working with repos and URLs.
|
|
||||||
|
|
||||||
### Functions
|
- aliasing `git` to `hub` when `hub` is installed;
|
||||||
|
- adding completion for `hub`; and
|
||||||
|
- defining convenience functions for creating repositories.
|
||||||
|
|
||||||
* `empty_gh` - Creates a new empty repo (with a `README.md`) and pushes it to GitHub
|
## Migrating to GitHub CLI
|
||||||
* `new_gh` - Initializes an existing directory as a repo and pushes it to GitHub
|
|
||||||
* `exist_gh` - Takes an existing repo and pushes it to GitHub
|
|
||||||
|
|
||||||
|
Install [GitHub CLI](https://cli.github.com/), replace `github` with `gh` in
|
||||||
## Installation
|
your plugin list, and restart your shell:
|
||||||
|
|
||||||
[Hub](https://github.com/github/hub) needs to be installed if you want to use it. On OS X with Homebrew, this can be done with `brew install hub`. The `hub` completion definition needs to be added to your `$FPATH` before initializing OMZ.
|
|
||||||
|
|
||||||
The [`github` Ruby gem](https://github.com/defunkt/github-gem) needs to be installed if you want to use it.
|
|
||||||
|
|
||||||
### Configuration
|
|
||||||
|
|
||||||
These settings affect `github`'s behavior.
|
|
||||||
|
|
||||||
#### Environment variables
|
|
||||||
|
|
||||||
* `$GITHUB_USER`
|
|
||||||
* `$GITHUB_PASSWORD`
|
|
||||||
|
|
||||||
#### Git configuration options
|
|
||||||
|
|
||||||
* `github.user` - GitHub username for repo operations
|
|
||||||
|
|
||||||
See `man hub` for more details.
|
|
||||||
|
|
||||||
### Homebrew installation note
|
|
||||||
|
|
||||||
If you have installed `hub` using Homebrew, its completions may not be on your `$FPATH` if you are using the system `zsh`. Homebrew installs `zsh` completion definitions to `/usr/local/share/zsh/site-functions`, which will be on `$FPATH` for the Homebrew-installed `zsh`, but not for the system `zsh`. If you want it to work with the system `zsh`, add this to your `~/.zshrc` before it sources `oh-my-zsh.sh`.
|
|
||||||
|
|
||||||
```zsh
|
```zsh
|
||||||
if (( ! ${fpath[(I)/usr/local/share/zsh/site-functions]} )); then
|
plugins=(... gh)
|
||||||
FPATH=/usr/local/share/zsh/site-functions:$FPATH
|
|
||||||
fi
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
The `gh` plugin supplies completion for the installed GitHub CLI. It does not
|
||||||
|
alias `git`, because `gh` is not a Git wrapper.
|
||||||
|
|
||||||
|
The closest replacement for creating a GitHub repository from an existing
|
||||||
|
local repository is:
|
||||||
|
|
||||||
|
```zsh
|
||||||
|
gh repo create --source=. --push
|
||||||
|
```
|
||||||
|
|
||||||
|
## Deprecated functions
|
||||||
|
|
||||||
|
- `empty_gh` - creates a new repository with a `README.md` and pushes it to GitHub
|
||||||
|
- `new_gh` - initializes an existing directory and pushes it to GitHub
|
||||||
|
- `exist_gh` - pushes an existing Git repository to GitHub
|
||||||
|
|
||||||
|
These functions remain available during the deprecation period and require
|
||||||
|
`hub`. They will be removed with the plugin.
|
||||||
|
|
||||||
|
If you continue using `hub`, see its documentation for authentication and
|
||||||
|
configuration details.
|
||||||
|
|||||||
@@ -1,3 +1,6 @@
|
|||||||
|
print -Pru2 -- '%F{yellow}[oh-my-zsh] The %Bgithub%b plugin is deprecated and will be removed in a future release.'
|
||||||
|
print -Pru2 -- 'It supports the legacy %Bhub%b CLI. Use the %Bgh%b plugin for GitHub CLI completion.%f'
|
||||||
|
|
||||||
# Set up hub wrapper for git, if it is available; https://github.com/github/hub
|
# Set up hub wrapper for git, if it is available; https://github.com/github/hub
|
||||||
if (( $+commands[hub] )); then
|
if (( $+commands[hub] )); then
|
||||||
alias git=hub
|
alias git=hub
|
||||||
@@ -26,7 +29,7 @@ empty_gh() { # [NAME_OF_REPO]
|
|||||||
# This function will add all non-hidden files to git.
|
# This function will add all non-hidden files to git.
|
||||||
new_gh() { # [DIRECTORY]
|
new_gh() { # [DIRECTORY]
|
||||||
emulate -L zsh
|
emulate -L zsh
|
||||||
local repo="$1"
|
local repo="${1-.}"
|
||||||
cd "$repo" \
|
cd "$repo" \
|
||||||
|| return
|
|| return
|
||||||
|
|
||||||
@@ -42,7 +45,7 @@ new_gh() { # [DIRECTORY]
|
|||||||
|| return
|
|| return
|
||||||
hub create \
|
hub create \
|
||||||
|| return
|
|| return
|
||||||
git push -u origin master \
|
git push -u origin HEAD \
|
||||||
|| return
|
|| return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -52,18 +55,19 @@ new_gh() { # [DIRECTORY]
|
|||||||
# to your GitHub.
|
# to your GitHub.
|
||||||
exist_gh() { # [DIRECTORY]
|
exist_gh() { # [DIRECTORY]
|
||||||
emulate -L zsh
|
emulate -L zsh
|
||||||
local repo=$1
|
local repo="${1:-.}"
|
||||||
cd "$repo"
|
cd "$repo" \
|
||||||
|
|| return
|
||||||
|
|
||||||
hub create \
|
hub create \
|
||||||
|| return
|
|| return
|
||||||
git push -u origin master
|
git push -u origin HEAD
|
||||||
}
|
}
|
||||||
|
|
||||||
# git.io "GitHub URL"
|
# git.io "GitHub URL"
|
||||||
#
|
#
|
||||||
# Shorten GitHub url, example:
|
# Shorten GitHub url, example:
|
||||||
# https://github.com/nvogel/dotzsh > https://git.io/8nU25w
|
# https://github.com/nvogel/dotzsh > https://git.io/8nU25w
|
||||||
# source: https://github.com/nvogel/dotzsh
|
# source: https://github.com/nvogel/dotzsh
|
||||||
# documentation: https://github.com/blog/985-git-io-github-url-shortener
|
# documentation: https://github.com/blog/985-git-io-github-url-shortener
|
||||||
#
|
#
|
||||||
@@ -74,4 +78,3 @@ git.io() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# End Functions #############################################################
|
# End Functions #############################################################
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,18 @@
|
|||||||
|
# GitLab CLI plugin
|
||||||
|
|
||||||
|
This plugin adds completion for the [GitLab CLI](https://docs.gitlab.com/cli/).
|
||||||
|
|
||||||
|
To use it, add `glab` to the plugins array in your zshrc file:
|
||||||
|
|
||||||
|
```zsh
|
||||||
|
plugins=(... glab)
|
||||||
|
```
|
||||||
|
|
||||||
|
This plugin does not add any aliases.
|
||||||
|
|
||||||
|
## Cache
|
||||||
|
|
||||||
|
This plugin caches the completion script at `$ZSH_CACHE_DIR/completions/_glab`.
|
||||||
|
|
||||||
|
The cache is regenerated in the background whenever the plugin is loaded, which
|
||||||
|
usually happens when you start a new Zsh session.
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
# Autocompletion for the GitLab CLI (glab).
|
||||||
|
if (( ! $+commands[glab] )); then
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
# If the completion file doesn't exist yet, we need to autoload it and
|
||||||
|
# bind it to `glab`. Otherwise, compinit will have already done that.
|
||||||
|
if [[ ! -f "$ZSH_CACHE_DIR/completions/_glab" ]]; then
|
||||||
|
typeset -g -A _comps
|
||||||
|
autoload -Uz _glab
|
||||||
|
_comps[glab]=_glab
|
||||||
|
fi
|
||||||
|
|
||||||
|
zmodload -F zsh/files b:zf_mv
|
||||||
|
() {
|
||||||
|
local TMPPREFIX="$ZSH_CACHE_DIR/completions/._glab"
|
||||||
|
zf_mv -f -- =( glab completion -s zsh ) "$ZSH_CACHE_DIR/completions/_glab"
|
||||||
|
} &|
|
||||||
@@ -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"
|
||||||
|
}
|
||||||
@@ -39,3 +39,18 @@ plugins=(... golang)
|
|||||||
| gov | `go vet` | Vet examines Go source code and reports suspicious constructs |
|
| gov | `go vet` | Vet examines Go source code and reports suspicious constructs |
|
||||||
| gove | `go version` | Prints Go version |
|
| gove | `go version` | Prints Go version |
|
||||||
| gow | `go work` | Work provides access to operations on workspaces |
|
| gow | `go work` | Work provides access to operations on workspaces |
|
||||||
|
|
||||||
|
## Prompt
|
||||||
|
|
||||||
|
This plugin provides the `go_prompt_info` function to add the installed Go
|
||||||
|
version to your prompt.
|
||||||
|
|
||||||
|
For example:
|
||||||
|
```
|
||||||
|
PROMPT="%~$ "
|
||||||
|
RPROMPT='$(go_prompt_info)'
|
||||||
|
```
|
||||||
|
changes your prompt to:
|
||||||
|
```
|
||||||
|
~/go/project$ ▋ 1.22.3
|
||||||
|
```
|
||||||
|
|||||||
+95
-11
@@ -81,6 +81,7 @@ _go() {
|
|||||||
'tool[run specified go tool]'
|
'tool[run specified go tool]'
|
||||||
'version[print Go version]'
|
'version[print Go version]'
|
||||||
'vet[run go tool vet on packages]'
|
'vet[run go tool vet on packages]'
|
||||||
|
'work[workspace maintenance]'
|
||||||
)
|
)
|
||||||
if (( CURRENT == 2 )); then
|
if (( CURRENT == 2 )); then
|
||||||
# explain go commands
|
# explain go commands
|
||||||
@@ -88,19 +89,38 @@ _go() {
|
|||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
build_flags=(
|
build_flags=(
|
||||||
'-a[force reinstallation of packages that are already up to date]'
|
'-C[change to dir before running the command]:directory:_path_files -/'
|
||||||
|
'-a[force rebuilding of packages that are already up-to-date]'
|
||||||
'-n[print the commands but do not run them]'
|
'-n[print the commands but do not run them]'
|
||||||
'-p[number of parallel builds]:number'
|
'-p[number of parallel builds]:number'
|
||||||
'-race[enable data race detection]'
|
'-race[enable data race detection]'
|
||||||
'-x[print the commands]'
|
'-msan[enable interoperation with memory sanitizer]'
|
||||||
|
'-asan[enable interoperation with address sanitizer]'
|
||||||
|
'-cover[enable code coverage instrumentation]'
|
||||||
|
'-covermode[set the mode for coverage analysis]:mode:(set count atomic)'
|
||||||
|
'-coverpkg[apply coverage analysis to matching packages]:pattern'
|
||||||
|
'-v[print the names of packages as they are compiled]'
|
||||||
'-work[print temporary directory name and keep it]'
|
'-work[print temporary directory name and keep it]'
|
||||||
'-ccflags[flags for 5c/6c/8c]:flags'
|
'-x[print the commands]'
|
||||||
'-gcflags[flags for 5g/6g/8g]:flags'
|
'-asmflags[arguments to pass on each go tool asm invocation]:flags'
|
||||||
'-ldflags[flags for 5l/6l/8l]:flags'
|
'-buildmode[build mode to use]:mode:(archive c-archive c-shared default shared exe pie plugin)'
|
||||||
'-gccgoflags[flags for gccgo]:flags'
|
'-buildvcs[stamp binaries with version control information]:mode:(true false auto)'
|
||||||
'-compiler[name of compiler to use]:name'
|
'-compiler[name of compiler to use]:name:(gccgo gc)'
|
||||||
'-installsuffix[suffix to add to package directory]:suffix'
|
'-gccgoflags[arguments to pass on each gccgo compiler/linker invocation]:flags'
|
||||||
|
'-gcflags[arguments to pass on each go tool compile invocation]:flags'
|
||||||
|
'-installsuffix[suffix to use in the package installation directory]:suffix'
|
||||||
|
'-json[emit build output in JSON suitable for automated processing]'
|
||||||
|
'-ldflags[arguments to pass on each go tool link invocation]:flags'
|
||||||
|
'-linkshared[build code that will be linked against shared libraries]'
|
||||||
|
'-mod[module download mode to use]:mode:(readonly vendor mod)'
|
||||||
|
'-modcacherw[leave newly-created directories in the module cache read-write]'
|
||||||
|
'-modfile[read and write an alternate go.mod file]:file:_files -g "*.mod"'
|
||||||
|
'-overlay[read a JSON config file that provides an overlay for build operations]:file:_files -g "*.json"'
|
||||||
|
'-pgo[specify the file path of a profile for profile-guided optimization]:file:_files'
|
||||||
|
'-pkgdir[install and load all packages from dir]:directory:_path_files -/'
|
||||||
'-tags[list of build tags to consider satisfied]:tags'
|
'-tags[list of build tags to consider satisfied]:tags'
|
||||||
|
'-trimpath[remove all file system paths from the resulting executable]'
|
||||||
|
'-toolexec[program to use to invoke toolchain programs]:command'
|
||||||
)
|
)
|
||||||
|
|
||||||
case ${words[2]} in
|
case ${words[2]} in
|
||||||
@@ -125,17 +145,20 @@ _go() {
|
|||||||
;;
|
;;
|
||||||
install)
|
install)
|
||||||
_arguments -s -w : ${build_flags[@]} \
|
_arguments -s -w : ${build_flags[@]} \
|
||||||
"-v[show package names]" \
|
|
||||||
'*:importpaths:__go_packages'
|
'*:importpaths:__go_packages'
|
||||||
;;
|
;;
|
||||||
get)
|
get)
|
||||||
_arguments -s -w : \
|
_arguments -s -w : \
|
||||||
${build_flags[@]}
|
${build_flags[@]} \
|
||||||
|
"-t[consider modules needed to build tests of packages]" \
|
||||||
|
"-u[update modules providing dependencies to newer minor or patch releases]" \
|
||||||
|
"-u=[update modules providing dependencies to patch releases]:mode:(patch)" \
|
||||||
|
"-tool[add a matching tool line to go.mod for each listed package]" \
|
||||||
|
"*:importpaths:__go_packages"
|
||||||
;;
|
;;
|
||||||
build)
|
build)
|
||||||
_arguments -s -w : \
|
_arguments -s -w : \
|
||||||
${build_flags[@]} \
|
${build_flags[@]} \
|
||||||
"-v[show package names]" \
|
|
||||||
"-o[output file]:file:_files" \
|
"-o[output file]:file:_files" \
|
||||||
"*:args:{ _alternative ':importpaths:__go_packages' ':files:_path_files -g \"*.go\"' }"
|
"*:args:{ _alternative ':importpaths:__go_packages' ':files:_path_files -g \"*.go\"' }"
|
||||||
;;
|
;;
|
||||||
@@ -238,6 +261,60 @@ _go() {
|
|||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
;;
|
;;
|
||||||
|
work)
|
||||||
|
local -a work_commands
|
||||||
|
work_commands+=(
|
||||||
|
'edit[edit go.work from tools or scripts]'
|
||||||
|
'init[initialize workspace file]'
|
||||||
|
'sync[sync workspace build list to modules]'
|
||||||
|
'use[add modules to workspace file]'
|
||||||
|
'vendor[make vendored copy of dependencies]'
|
||||||
|
)
|
||||||
|
|
||||||
|
if (( CURRENT == 3 )); then
|
||||||
|
_values 'go work commands' ${work_commands[@]} "help[display help]"
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
case ${words[3]} in
|
||||||
|
help)
|
||||||
|
_values 'go work commands' ${work_commands[@]}
|
||||||
|
;;
|
||||||
|
edit)
|
||||||
|
_arguments -s -w : \
|
||||||
|
"-fmt[reformat the go.work file]" \
|
||||||
|
"-godebug[=key=value add a godebug key=value line]:key=value" \
|
||||||
|
"-dropgodebug[=key drop an existing godebug line]:key" \
|
||||||
|
"-use[=path add a use directive]:directory:_path_files -/" \
|
||||||
|
"-dropuse[=path drop a use directive]:directory:_path_files -/" \
|
||||||
|
"-replace[=old{@v}=new{@v} add a replacement of the given module path and version pair]:name" \
|
||||||
|
"-dropreplace[=old{@v} drop a replacement of the given module path and version pair]:name" \
|
||||||
|
"-go[={version} set the expected Go language version]:number" \
|
||||||
|
"-toolchain[=name set the Go toolchain to use]:name" \
|
||||||
|
"-print[print the final go.work in its text format]" \
|
||||||
|
"-json[print the final go.work file in JSON format]" \
|
||||||
|
"1:go.work file:_files -g 'go.work'"
|
||||||
|
;;
|
||||||
|
init)
|
||||||
|
_arguments -s -w : \
|
||||||
|
"*:module directories:_path_files -/"
|
||||||
|
;;
|
||||||
|
sync)
|
||||||
|
;;
|
||||||
|
use)
|
||||||
|
_arguments -s -w : \
|
||||||
|
"-r[search recursively for modules in the argument directories]" \
|
||||||
|
"*:module directories:_path_files -/"
|
||||||
|
;;
|
||||||
|
vendor)
|
||||||
|
_arguments -s -w : \
|
||||||
|
"-e[attempt to proceed despite errors encountered while loading packages]" \
|
||||||
|
"-v[print the names of vendored modules and packages]" \
|
||||||
|
"-o[create the vendor directory at the given path]:output directory:_path_files -/" \
|
||||||
|
"*:flags"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
;;
|
||||||
help)
|
help)
|
||||||
_values "${commands[@]}" \
|
_values "${commands[@]}" \
|
||||||
'environment[show Go environment variables available]' \
|
'environment[show Go environment variables available]' \
|
||||||
@@ -247,6 +324,13 @@ _go() {
|
|||||||
'testflag[description of testing flags]' \
|
'testflag[description of testing flags]' \
|
||||||
'testfunc[description of testing functions]'
|
'testfunc[description of testing functions]'
|
||||||
;;
|
;;
|
||||||
|
version)
|
||||||
|
_arguments -s -w : \
|
||||||
|
"-m[print module version information]" \
|
||||||
|
"-v[report unrecognized files]" \
|
||||||
|
"-json[print module version information in JSON format]" \
|
||||||
|
"*:file:_files"
|
||||||
|
;;
|
||||||
run)
|
run)
|
||||||
_arguments -s -w : \
|
_arguments -s -w : \
|
||||||
${build_flags[@]} \
|
${build_flags[@]} \
|
||||||
|
|||||||
@@ -36,3 +36,12 @@ alias gotofx='go tool fix'
|
|||||||
alias gov='go vet'
|
alias gov='go vet'
|
||||||
alias gove='go version'
|
alias gove='go version'
|
||||||
alias gow='go work'
|
alias gow='go work'
|
||||||
|
|
||||||
|
## prompt
|
||||||
|
function go_prompt_info() {
|
||||||
|
(( $+commands[go] )) || return
|
||||||
|
local go_prompt
|
||||||
|
go_prompt=$(go version | awk '{ print substr($3, 3) }')
|
||||||
|
[[ -z "${go_prompt}" ]] && return
|
||||||
|
echo "${ZSH_THEME_GO_PROMPT_PREFIX}${go_prompt:gs/%/%%}${ZSH_THEME_GO_PROMPT_SUFFIX}"
|
||||||
|
}
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
+14
-4
@@ -267,6 +267,7 @@ __gradle_subcommand() {
|
|||||||
'-Dorg.gradle.configuration-cache.problems=[Configures how the configuration cache handles problems (fail or warn). Supported values are 'warn', or 'fail' (default).]:org.gradle.configuration cache.problems:(fail warn)' \
|
'-Dorg.gradle.configuration-cache.problems=[Configures how the configuration cache handles problems (fail or warn). Supported values are 'warn', or 'fail' (default).]:org.gradle.configuration cache.problems:(fail warn)' \
|
||||||
'-Dorg.gradle.configuration-cache.read-only=[]' \
|
'-Dorg.gradle.configuration-cache.read-only=[]' \
|
||||||
'-Dorg.gradle.configuration-cache.unsafe.ignore.unsupported-build-events-listeners=[]' \
|
'-Dorg.gradle.configuration-cache.unsafe.ignore.unsupported-build-events-listeners=[]' \
|
||||||
|
'-Dorg.gradle.configuration-cache.unsafe.skip-task-logging-listeners-serialization=[]' \
|
||||||
'-Dorg.gradle.configuration-cache=[Enables the configuration cache. Gradle will try to reuse the build configuration from previous builds.]' \
|
'-Dorg.gradle.configuration-cache=[Enables the configuration cache. Gradle will try to reuse the build configuration from previous builds.]' \
|
||||||
'-Dorg.gradle.configureondemand=[Configures necessary projects only. Gradle will attempt to reduce configuration time for large multi-project builds.]' \
|
'-Dorg.gradle.configureondemand=[Configures necessary projects only. Gradle will attempt to reduce configuration time for large multi-project builds.]' \
|
||||||
'-Dorg.gradle.console.interactive=[]' \
|
'-Dorg.gradle.console.interactive=[]' \
|
||||||
@@ -284,6 +285,9 @@ __gradle_subcommand() {
|
|||||||
'-Dorg.gradle.debug.suspend=[]' \
|
'-Dorg.gradle.debug.suspend=[]' \
|
||||||
'-Dorg.gradle.debug=[]:org.gradle.debug:(true false)' \
|
'-Dorg.gradle.debug=[]:org.gradle.debug:(true false)' \
|
||||||
'-Dorg.gradle.dependency.verification=[Configures the dependency verification mode. Supported values are 'strict', 'lenient', or 'off'.]:org.gradle.dependency.verification:(strict lenient off)' \
|
'-Dorg.gradle.dependency.verification=[Configures the dependency verification mode. Supported values are 'strict', 'lenient', or 'off'.]:org.gradle.dependency.verification:(strict lenient off)' \
|
||||||
|
'-Dorg.gradle.isolated-projects.dangerously-ignore-problems=[]' \
|
||||||
|
'-Dorg.gradle.isolated-projects.diagnostics=[]' \
|
||||||
|
'-Dorg.gradle.isolated-projects=[Enables Isolated Projects. Projects are configured in parallel. Implies `--configuration-cache`.]' \
|
||||||
'-Dorg.gradle.java.home=[]:org.gradle.java.home:_directories' \
|
'-Dorg.gradle.java.home=[]:org.gradle.java.home:_directories' \
|
||||||
'-Dorg.gradle.java.installations.auto-detect=[]' \
|
'-Dorg.gradle.java.installations.auto-detect=[]' \
|
||||||
'-Dorg.gradle.java.installations.auto-download=[]' \
|
'-Dorg.gradle.java.installations.auto-download=[]' \
|
||||||
@@ -293,14 +297,13 @@ __gradle_subcommand() {
|
|||||||
'-Dorg.gradle.jvmargs=[]' \
|
'-Dorg.gradle.jvmargs=[]' \
|
||||||
'-Dorg.gradle.logging.level=[]:org.gradle.logging.level:(quiet warn info debug)' \
|
'-Dorg.gradle.logging.level=[]:org.gradle.logging.level:(quiet warn info debug)' \
|
||||||
'-Dorg.gradle.logging.stacktrace=[]' \
|
'-Dorg.gradle.logging.stacktrace=[]' \
|
||||||
|
'-Dorg.gradle.mirror.maven.settings=[]' \
|
||||||
'-Dorg.gradle.native=[]' \
|
'-Dorg.gradle.native=[]' \
|
||||||
'-Dorg.gradle.parallel=[Builds projects in parallel. Gradle will attempt to determine the optimal number of executor threads to use.]:org.gradle.parallel:(true false)' \
|
'-Dorg.gradle.parallel=[Builds projects in parallel. Gradle will attempt to determine the optimal number of executor threads to use.]:org.gradle.parallel:(true false)' \
|
||||||
'-Dorg.gradle.priority=[Specifies the scheduling priority for the Gradle daemon and all processes launched by it. Supported values are 'normal' (default) or 'low'.]:org.gradle.priority:(normal low)' \
|
'-Dorg.gradle.priority=[Specifies the scheduling priority for the Gradle daemon and all processes launched by it. Supported values are 'normal' (default) or 'low'.]:org.gradle.priority:(normal low)' \
|
||||||
'-Dorg.gradle.problems.report=[Enables the HTML problems report.]' \
|
'-Dorg.gradle.problems.report=[Enables the HTML problems report.]' \
|
||||||
'-Dorg.gradle.projectcachedir=[Specifies the project-specific cache directory. Default is .gradle in the root project directory.]:org.gradle.projectcachedir:_directories' \
|
'-Dorg.gradle.projectcachedir=[Specifies the project-specific cache directory. Default is .gradle in the root project directory.]:org.gradle.projectcachedir:_directories' \
|
||||||
'-Dorg.gradle.tooling.parallel=[]' \
|
'-Dorg.gradle.tooling.parallel=[]' \
|
||||||
'-Dorg.gradle.unsafe.isolated-projects.diagnostics=[]' \
|
|
||||||
'-Dorg.gradle.unsafe.isolated-projects=[]' \
|
|
||||||
'-Dorg.gradle.vfs.verbose=[]' \
|
'-Dorg.gradle.vfs.verbose=[]' \
|
||||||
'-Dorg.gradle.vfs.watch=[Enables file system watching. Reuses file system data for subsequent builds.]:org.gradle.vfs.watch:(true false)' \
|
'-Dorg.gradle.vfs.watch=[Enables file system watching. Reuses file system data for subsequent builds.]:org.gradle.vfs.watch:(true false)' \
|
||||||
'-Dorg.gradle.warning.mode=[Specifies which mode of warnings to generate. Supported values are 'all', 'fail', 'summary' (default), or 'none'.]' \
|
'-Dorg.gradle.warning.mode=[Specifies which mode of warnings to generate. Supported values are 'all', 'fail', 'summary' (default), or 'none'.]' \
|
||||||
@@ -328,12 +331,14 @@ __gradle_subcommand() {
|
|||||||
\*'--include-build[Includes the specified build in the composite.]:include build:_directories' \
|
\*'--include-build[Includes the specified build in the composite.]:include build:_directories' \
|
||||||
(--quiet,-q,--warn,-w,--debug,-d){-i,--info}'[Sets the log level to info.]' \
|
(--quiet,-q,--warn,-w,--debug,-d){-i,--info}'[Sets the log level to info.]' \
|
||||||
\*{-I,--init-script}'[Specifies an initialization script.]:init script:_files -g \*.gradle(|.kts)' \
|
\*{-I,--init-script}'[Specifies an initialization script.]:init script:_files -g \*.gradle(|.kts)' \
|
||||||
|
(--no-isolated-projects)'--isolated-projects[Enables Isolated Projects. Projects are configured in parallel. Implies `--configuration-cache`. (incubating)]' \
|
||||||
'--max-workers[Configures the maximum number of concurrent workers Gradle is allowed to use.]' \
|
'--max-workers[Configures the maximum number of concurrent workers Gradle is allowed to use.]' \
|
||||||
(--build-cache)'--no-build-cache[Disables the Gradle build cache.]' \
|
(--build-cache)'--no-build-cache[Disables the Gradle build cache.]' \
|
||||||
(--configuration-cache)'--no-configuration-cache[Disables the configuration cache.]' \
|
(--configuration-cache)'--no-configuration-cache[Disables the configuration cache.]' \
|
||||||
(--configure-on-demand)'--no-configure-on-demand[Disables the use of configuration on demand. (incubating)]' \
|
(--configure-on-demand)'--no-configure-on-demand[Disables the use of configuration on demand. (incubating)]' \
|
||||||
(--continue)'--no-continue[Stops task execution after a task failure.]' \
|
(--continue)'--no-continue[Stops task execution after a task failure.]' \
|
||||||
(--daemon)'--no-daemon[Runs the build without the Gradle daemon. Useful occasionally if you have configured Gradle to always run with the daemon by default.]' \
|
(--daemon)'--no-daemon[Runs the build without the Gradle daemon. Useful occasionally if you have configured Gradle to always run with the daemon by default.]' \
|
||||||
|
(--isolated-projects)'--no-isolated-projects[Disables Isolated Projects. (incubating)]' \
|
||||||
(--parallel)'--no-parallel[Disables parallel project execution.]' \
|
(--parallel)'--no-parallel[Disables parallel project execution.]' \
|
||||||
(--problems-report)'--no-problems-report[Disables the HTML problems report. (incubating)]' \
|
(--problems-report)'--no-problems-report[Disables the HTML problems report. (incubating)]' \
|
||||||
{-a,--no-rebuild}'[Disables rebuilding of project dependencies.]' \
|
{-a,--no-rebuild}'[Disables rebuilding of project dependencies.]' \
|
||||||
@@ -404,6 +409,7 @@ _gradle() {
|
|||||||
'-Dorg.gradle.configuration-cache.problems=[Configures how the configuration cache handles problems (fail or warn). Supported values are 'warn', or 'fail' (default).]:org.gradle.configuration cache.problems:(fail warn):->argument-expected' \
|
'-Dorg.gradle.configuration-cache.problems=[Configures how the configuration cache handles problems (fail or warn). Supported values are 'warn', or 'fail' (default).]:org.gradle.configuration cache.problems:(fail warn):->argument-expected' \
|
||||||
'-Dorg.gradle.configuration-cache.read-only=[]:->argument-expected' \
|
'-Dorg.gradle.configuration-cache.read-only=[]:->argument-expected' \
|
||||||
'-Dorg.gradle.configuration-cache.unsafe.ignore.unsupported-build-events-listeners=[]:->argument-expected' \
|
'-Dorg.gradle.configuration-cache.unsafe.ignore.unsupported-build-events-listeners=[]:->argument-expected' \
|
||||||
|
'-Dorg.gradle.configuration-cache.unsafe.skip-task-logging-listeners-serialization=[]:->argument-expected' \
|
||||||
'-Dorg.gradle.configuration-cache=[Enables the configuration cache. Gradle will try to reuse the build configuration from previous builds.]:->argument-expected' \
|
'-Dorg.gradle.configuration-cache=[Enables the configuration cache. Gradle will try to reuse the build configuration from previous builds.]:->argument-expected' \
|
||||||
'-Dorg.gradle.configureondemand=[Configures necessary projects only. Gradle will attempt to reduce configuration time for large multi-project builds.]:->argument-expected' \
|
'-Dorg.gradle.configureondemand=[Configures necessary projects only. Gradle will attempt to reduce configuration time for large multi-project builds.]:->argument-expected' \
|
||||||
'-Dorg.gradle.console.interactive=[]:->argument-expected' \
|
'-Dorg.gradle.console.interactive=[]:->argument-expected' \
|
||||||
@@ -421,6 +427,9 @@ _gradle() {
|
|||||||
'-Dorg.gradle.debug.suspend=[]:->argument-expected' \
|
'-Dorg.gradle.debug.suspend=[]:->argument-expected' \
|
||||||
'-Dorg.gradle.debug=[]:org.gradle.debug:(true false):->argument-expected' \
|
'-Dorg.gradle.debug=[]:org.gradle.debug:(true false):->argument-expected' \
|
||||||
'-Dorg.gradle.dependency.verification=[Configures the dependency verification mode. Supported values are 'strict', 'lenient', or 'off'.]:org.gradle.dependency.verification:(strict lenient off):->argument-expected' \
|
'-Dorg.gradle.dependency.verification=[Configures the dependency verification mode. Supported values are 'strict', 'lenient', or 'off'.]:org.gradle.dependency.verification:(strict lenient off):->argument-expected' \
|
||||||
|
'-Dorg.gradle.isolated-projects.dangerously-ignore-problems=[]:->argument-expected' \
|
||||||
|
'-Dorg.gradle.isolated-projects.diagnostics=[]:->argument-expected' \
|
||||||
|
'-Dorg.gradle.isolated-projects=[Enables Isolated Projects. Projects are configured in parallel. Implies `--configuration-cache`.]:->argument-expected' \
|
||||||
'-Dorg.gradle.java.home=[]:org.gradle.java.home:_directories:->argument-expected' \
|
'-Dorg.gradle.java.home=[]:org.gradle.java.home:_directories:->argument-expected' \
|
||||||
'-Dorg.gradle.java.installations.auto-detect=[]:->argument-expected' \
|
'-Dorg.gradle.java.installations.auto-detect=[]:->argument-expected' \
|
||||||
'-Dorg.gradle.java.installations.auto-download=[]:->argument-expected' \
|
'-Dorg.gradle.java.installations.auto-download=[]:->argument-expected' \
|
||||||
@@ -430,14 +439,13 @@ _gradle() {
|
|||||||
'-Dorg.gradle.jvmargs=[]:->argument-expected' \
|
'-Dorg.gradle.jvmargs=[]:->argument-expected' \
|
||||||
'-Dorg.gradle.logging.level=[]:org.gradle.logging.level:(quiet warn info debug):->argument-expected' \
|
'-Dorg.gradle.logging.level=[]:org.gradle.logging.level:(quiet warn info debug):->argument-expected' \
|
||||||
'-Dorg.gradle.logging.stacktrace=[]:->argument-expected' \
|
'-Dorg.gradle.logging.stacktrace=[]:->argument-expected' \
|
||||||
|
'-Dorg.gradle.mirror.maven.settings=[]:->argument-expected' \
|
||||||
'-Dorg.gradle.native=[]:->argument-expected' \
|
'-Dorg.gradle.native=[]:->argument-expected' \
|
||||||
'-Dorg.gradle.parallel=[Builds projects in parallel. Gradle will attempt to determine the optimal number of executor threads to use.]:org.gradle.parallel:(true false):->argument-expected' \
|
'-Dorg.gradle.parallel=[Builds projects in parallel. Gradle will attempt to determine the optimal number of executor threads to use.]:org.gradle.parallel:(true false):->argument-expected' \
|
||||||
'-Dorg.gradle.priority=[Specifies the scheduling priority for the Gradle daemon and all processes launched by it. Supported values are 'normal' (default) or 'low'.]:org.gradle.priority:(normal low):->argument-expected' \
|
'-Dorg.gradle.priority=[Specifies the scheduling priority for the Gradle daemon and all processes launched by it. Supported values are 'normal' (default) or 'low'.]:org.gradle.priority:(normal low):->argument-expected' \
|
||||||
'-Dorg.gradle.problems.report=[Enables the HTML problems report.]:->argument-expected' \
|
'-Dorg.gradle.problems.report=[Enables the HTML problems report.]:->argument-expected' \
|
||||||
'-Dorg.gradle.projectcachedir=[Specifies the project-specific cache directory. Default is .gradle in the root project directory.]:org.gradle.projectcachedir:_directories:->argument-expected' \
|
'-Dorg.gradle.projectcachedir=[Specifies the project-specific cache directory. Default is .gradle in the root project directory.]:org.gradle.projectcachedir:_directories:->argument-expected' \
|
||||||
'-Dorg.gradle.tooling.parallel=[]:->argument-expected' \
|
'-Dorg.gradle.tooling.parallel=[]:->argument-expected' \
|
||||||
'-Dorg.gradle.unsafe.isolated-projects.diagnostics=[]:->argument-expected' \
|
|
||||||
'-Dorg.gradle.unsafe.isolated-projects=[]:->argument-expected' \
|
|
||||||
'-Dorg.gradle.vfs.verbose=[]:->argument-expected' \
|
'-Dorg.gradle.vfs.verbose=[]:->argument-expected' \
|
||||||
'-Dorg.gradle.vfs.watch=[Enables file system watching. Reuses file system data for subsequent builds.]:org.gradle.vfs.watch:(true false):->argument-expected' \
|
'-Dorg.gradle.vfs.watch=[Enables file system watching. Reuses file system data for subsequent builds.]:org.gradle.vfs.watch:(true false):->argument-expected' \
|
||||||
'-Dorg.gradle.warning.mode=[Specifies which mode of warnings to generate. Supported values are 'all', 'fail', 'summary' (default), or 'none'.]:->argument-expected' \
|
'-Dorg.gradle.warning.mode=[Specifies which mode of warnings to generate. Supported values are 'all', 'fail', 'summary' (default), or 'none'.]:->argument-expected' \
|
||||||
@@ -466,12 +474,14 @@ _gradle() {
|
|||||||
\*'--include-build[Includes the specified build in the composite.]:include build:_directories:->argument-expected' \
|
\*'--include-build[Includes the specified build in the composite.]:include build:_directories:->argument-expected' \
|
||||||
(--quiet,-q,--warn,-w,--debug,-d){-i,--info}'[Sets the log level to info.]' \
|
(--quiet,-q,--warn,-w,--debug,-d){-i,--info}'[Sets the log level to info.]' \
|
||||||
\*{-I,--init-script}'[Specifies an initialization script.]:init script:_files -g \*.gradle(|.kts):->argument-expected' \
|
\*{-I,--init-script}'[Specifies an initialization script.]:init script:_files -g \*.gradle(|.kts):->argument-expected' \
|
||||||
|
(--no-isolated-projects)'--isolated-projects[Enables Isolated Projects. Projects are configured in parallel. Implies `--configuration-cache`. (incubating)]' \
|
||||||
'--max-workers[Configures the maximum number of concurrent workers Gradle is allowed to use.]:->argument-expected' \
|
'--max-workers[Configures the maximum number of concurrent workers Gradle is allowed to use.]:->argument-expected' \
|
||||||
(--build-cache)'--no-build-cache[Disables the Gradle build cache.]' \
|
(--build-cache)'--no-build-cache[Disables the Gradle build cache.]' \
|
||||||
(--configuration-cache)'--no-configuration-cache[Disables the configuration cache.]' \
|
(--configuration-cache)'--no-configuration-cache[Disables the configuration cache.]' \
|
||||||
(--configure-on-demand)'--no-configure-on-demand[Disables the use of configuration on demand. (incubating)]' \
|
(--configure-on-demand)'--no-configure-on-demand[Disables the use of configuration on demand. (incubating)]' \
|
||||||
(--continue)'--no-continue[Stops task execution after a task failure.]' \
|
(--continue)'--no-continue[Stops task execution after a task failure.]' \
|
||||||
(--daemon)'--no-daemon[Runs the build without the Gradle daemon. Useful occasionally if you have configured Gradle to always run with the daemon by default.]' \
|
(--daemon)'--no-daemon[Runs the build without the Gradle daemon. Useful occasionally if you have configured Gradle to always run with the daemon by default.]' \
|
||||||
|
(--isolated-projects)'--no-isolated-projects[Disables Isolated Projects. (incubating)]' \
|
||||||
(--parallel)'--no-parallel[Disables parallel project execution.]' \
|
(--parallel)'--no-parallel[Disables parallel project execution.]' \
|
||||||
(--problems-report)'--no-problems-report[Disables the HTML problems report. (incubating)]' \
|
(--problems-report)'--no-problems-report[Disables the HTML problems report. (incubating)]' \
|
||||||
{-a,--no-rebuild}'[Disables rebuilding of project dependencies.]' \
|
{-a,--no-rebuild}'[Disables rebuilding of project dependencies.]' \
|
||||||
|
|||||||
@@ -15,7 +15,6 @@ function gradle-or-gradlew() {
|
|||||||
|
|
||||||
# if gradlew found, run it instead of gradle
|
# if gradlew found, run it instead of gradle
|
||||||
if [[ -f "$project_root/gradlew" ]]; then
|
if [[ -f "$project_root/gradlew" ]]; then
|
||||||
echo "executing gradlew instead of gradle"
|
|
||||||
"$project_root/gradlew" "$@"
|
"$project_root/gradlew" "$@"
|
||||||
else
|
else
|
||||||
command gradle "$@"
|
command gradle "$@"
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ else
|
|||||||
source "$ZSH_CACHE_DIR/completions/_hasura"
|
source "$ZSH_CACHE_DIR/completions/_hasura"
|
||||||
zmodload -F zsh/files b:zf_mv
|
zmodload -F zsh/files b:zf_mv
|
||||||
() {
|
() {
|
||||||
local TMPPREFIX="$ZSH_CACHE_DIR/completions/_hasura"
|
local TMPPREFIX="$ZSH_CACHE_DIR/completions/._hasura"
|
||||||
zf_mv -f -- =( hasura completion zsh ) "$TMPPREFIX"
|
zf_mv -f -- =( hasura completion zsh ) "$ZSH_CACHE_DIR/completions/_hasura"
|
||||||
} &|
|
} &|
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -15,8 +15,8 @@ fi
|
|||||||
|
|
||||||
zmodload -F zsh/files b:zf_mv
|
zmodload -F zsh/files b:zf_mv
|
||||||
() {
|
() {
|
||||||
local TMPPREFIX="$ZSH_CACHE_DIR/completions/_hcloud"
|
local TMPPREFIX="$ZSH_CACHE_DIR/completions/._hcloud"
|
||||||
zf_mv -f -- =( hcloud completion zsh 2> /dev/null ) "$TMPPREFIX"
|
zf_mv -f -- =( hcloud completion zsh 2> /dev/null ) "$ZSH_CACHE_DIR/completions/_hcloud"
|
||||||
} &|
|
} &|
|
||||||
|
|
||||||
# Main alias
|
# Main alias
|
||||||
|
|||||||
@@ -11,8 +11,8 @@ else
|
|||||||
source "$ZSH_CACHE_DIR/completions/_helm"
|
source "$ZSH_CACHE_DIR/completions/_helm"
|
||||||
zmodload -F zsh/files b:zf_mv
|
zmodload -F zsh/files b:zf_mv
|
||||||
() {
|
() {
|
||||||
local TMPPREFIX="$ZSH_CACHE_DIR/completions/_helm"
|
local TMPPREFIX="$ZSH_CACHE_DIR/completions/._helm"
|
||||||
zf_mv -f -- =( helm completion zsh ) "$TMPPREFIX"
|
zf_mv -f -- =( helm completion zsh ) "$ZSH_CACHE_DIR/completions/_helm"
|
||||||
} &|
|
} &|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,163 @@
|
|||||||
|
# herdr plugin
|
||||||
|
|
||||||
|
This plugin adds completion, aliases, an interactive session picker and a prompt
|
||||||
|
function for [herdr](https://herdr.dev), the runtime your
|
||||||
|
coding agents live on. herdr keeps agent terminals running in the background across
|
||||||
|
projects and machines, so you can close your terminal, reconnect later, and pick up
|
||||||
|
where the agents left off.
|
||||||
|
|
||||||
|
To use it, add `herdr` to the plugins array in your zshrc file:
|
||||||
|
|
||||||
|
```zsh
|
||||||
|
plugins=(... herdr)
|
||||||
|
```
|
||||||
|
|
||||||
|
Install herdr first if you have not already:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
curl -fsSL https://herdr.dev/install.sh | sh # or: brew install herdr
|
||||||
|
```
|
||||||
|
|
||||||
|
## Learning herdr from the terminal
|
||||||
|
|
||||||
|
The fastest way to explore herdr is tab completion. Every command group and flag shows a
|
||||||
|
short description, so you can discover what is available without leaving the shell:
|
||||||
|
|
||||||
|
```
|
||||||
|
$ herdr <TAB>
|
||||||
|
agent -- Control and inspect agent panes
|
||||||
|
session -- Manage named persistent sessions
|
||||||
|
workspace -- Manage workspaces over the socket API
|
||||||
|
worktree -- Manage Git worktree-backed workspaces
|
||||||
|
...
|
||||||
|
$ herdr agent <TAB>
|
||||||
|
list -- List agents
|
||||||
|
prompt -- Submit a prompt to an agent
|
||||||
|
start -- Start a supported interactive agent in an existing pane
|
||||||
|
wait -- Wait until an agent reaches one of the requested states
|
||||||
|
...
|
||||||
|
```
|
||||||
|
|
||||||
|
A few other ways to learn as you go:
|
||||||
|
|
||||||
|
- `herdr <group>` with no subcommand prints that group's help, for example `herdr pane`.
|
||||||
|
- `herdr --skill` prints the instructions herdr gives to agents that drive it. It is a
|
||||||
|
good tour of the full command surface.
|
||||||
|
- Most control commands return JSON, so you can pipe them into `jq` in scripts.
|
||||||
|
|
||||||
|
## Common workflows
|
||||||
|
|
||||||
|
### Start and reconnect
|
||||||
|
|
||||||
|
```sh
|
||||||
|
herdr # launch, or attach to the default session
|
||||||
|
herdr --session work # use or create a named session
|
||||||
|
herdr session list # see running and stopped sessions
|
||||||
|
herdr session attach work # reconnect to a named session
|
||||||
|
herdr status # check the local client and running server
|
||||||
|
herdr update # install the latest release
|
||||||
|
```
|
||||||
|
|
||||||
|
### Organize work into workspaces and tabs
|
||||||
|
|
||||||
|
```sh
|
||||||
|
herdr workspace list
|
||||||
|
herdr workspace create --cwd ~/projects/app
|
||||||
|
herdr tab create
|
||||||
|
herdr pane split --direction right
|
||||||
|
herdr worktree create --branch feature/login # open a Git worktree in its own workspace
|
||||||
|
```
|
||||||
|
|
||||||
|
### Run and watch agents
|
||||||
|
|
||||||
|
```sh
|
||||||
|
herdr agent list # what is running, and is it idle, working or blocked
|
||||||
|
herdr agent start reviewer --kind claude --pane w1:p2
|
||||||
|
herdr agent prompt reviewer "review the last commit" --wait
|
||||||
|
herdr agent read reviewer # read the agent's terminal output
|
||||||
|
herdr agent wait reviewer --until idle
|
||||||
|
herdr agent attach reviewer # jump straight into that terminal
|
||||||
|
```
|
||||||
|
|
||||||
|
### Work across machines
|
||||||
|
|
||||||
|
```sh
|
||||||
|
herdr --remote user@build-box # attach through SSH with your local keybindings
|
||||||
|
```
|
||||||
|
|
||||||
|
### Keep the server healthy
|
||||||
|
|
||||||
|
```sh
|
||||||
|
herdr config check # validate config.toml
|
||||||
|
herdr server reload-config # apply config changes without restarting panes
|
||||||
|
herdr server stop
|
||||||
|
herdr channel set preview # switch between stable and preview releases
|
||||||
|
herdr integration status # which agent CLIs have herdr hooks installed
|
||||||
|
```
|
||||||
|
|
||||||
|
See the [CLI reference](https://herdr.dev/docs/cli-reference/) for every command and flag.
|
||||||
|
|
||||||
|
## Aliases
|
||||||
|
|
||||||
|
| Alias | Command |
|
||||||
|
| ------- | ----------------------------- |
|
||||||
|
| `hrdr` | `herdr` |
|
||||||
|
| `hrdrst` | `herdr status` |
|
||||||
|
| `hrdrup` | `herdr update` |
|
||||||
|
| `hrdrsl` | `herdr session list` |
|
||||||
|
| `hrdrsa` | `herdr session attach` |
|
||||||
|
| `hrdrr` | `herdr --remote` |
|
||||||
|
| `hrdral` | `herdr agent list` |
|
||||||
|
| `hrdrwl` | `herdr workspace list` |
|
||||||
|
| `hrdrwc` | `herdr workspace create` |
|
||||||
|
| `hrdrwt` | `herdr worktree create` |
|
||||||
|
| `hrdrps` | `herdr pane split` |
|
||||||
|
| `hrdrrc` | `herdr server reload-config` |
|
||||||
|
|
||||||
|
Tab completion works through the aliases too, so `hrdr agent <TAB>` completes the same
|
||||||
|
way `herdr agent <TAB>` does.
|
||||||
|
|
||||||
|
## Session picker
|
||||||
|
|
||||||
|
`hrdrs` lists your herdr sessions and attaches to the one you pick. It uses
|
||||||
|
[fzf](https://github.com/junegunn/fzf) when it is installed and falls back to a numbered
|
||||||
|
menu otherwise, so it works everywhere.
|
||||||
|
|
||||||
|
```
|
||||||
|
$ hrdrs
|
||||||
|
name status directory
|
||||||
|
1) default running /Users/me/.config/herdr
|
||||||
|
2) work stopped /Users/me/projects/app
|
||||||
|
Attach to session: 2
|
||||||
|
```
|
||||||
|
|
||||||
|
## Prompt
|
||||||
|
|
||||||
|
This plugin provides the `herdr_prompt_info` function to show the current pane ID in
|
||||||
|
your prompt when the shell is running inside herdr. It reads environment variables only,
|
||||||
|
so it adds no cost to prompt rendering.
|
||||||
|
|
||||||
|
For example:
|
||||||
|
```
|
||||||
|
PROMPT="%~$ "
|
||||||
|
RPROMPT='$(herdr_prompt_info)'
|
||||||
|
```
|
||||||
|
changes your prompt inside a herdr pane to:
|
||||||
|
```
|
||||||
|
~/projects/app$ ▋ w1:p4
|
||||||
|
```
|
||||||
|
and shows nothing outside herdr.
|
||||||
|
|
||||||
|
Wrap it with `ZSH_THEME_HERDR_PROMPT_PREFIX` and `ZSH_THEME_HERDR_PROMPT_SUFFIX`, for
|
||||||
|
example:
|
||||||
|
```
|
||||||
|
ZSH_THEME_HERDR_PROMPT_PREFIX="%{$fg[cyan]%}[herdr "
|
||||||
|
ZSH_THEME_HERDR_PROMPT_SUFFIX="]%{$reset_color%}"
|
||||||
|
```
|
||||||
|
|
||||||
|
## 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/_herdr`.
|
||||||
@@ -0,0 +1,68 @@
|
|||||||
|
# Aliases, helpers and completion for herdr (https://herdr.dev), the runtime for coding agents.
|
||||||
|
|
||||||
|
# PROMPT
|
||||||
|
# Defined before the herdr check so themes can reference it on machines without herdr.
|
||||||
|
function herdr_prompt_info {
|
||||||
|
[[ "$HERDR_ENV" == 1 ]] || return
|
||||||
|
echo "${ZSH_THEME_HERDR_PROMPT_PREFIX}${HERDR_PANE_ID:gs/%/%%}${ZSH_THEME_HERDR_PROMPT_SUFFIX}"
|
||||||
|
}
|
||||||
|
|
||||||
|
if (( ! $+commands[herdr] )); then
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
# ALIASES
|
||||||
|
alias hrdr='herdr'
|
||||||
|
alias hrdrst='herdr status'
|
||||||
|
alias hrdrup='herdr update'
|
||||||
|
alias hrdrsl='herdr session list'
|
||||||
|
alias hrdrsa='herdr session attach'
|
||||||
|
alias hrdrr='herdr --remote'
|
||||||
|
alias hrdral='herdr agent list'
|
||||||
|
alias hrdrwl='herdr workspace list'
|
||||||
|
alias hrdrwc='herdr workspace create'
|
||||||
|
alias hrdrwt='herdr worktree create'
|
||||||
|
alias hrdrps='herdr pane split'
|
||||||
|
alias hrdrrc='herdr server reload-config'
|
||||||
|
|
||||||
|
# FUNCTIONS
|
||||||
|
# Pick a session and attach to it, with fzf if available or a numbered menu otherwise.
|
||||||
|
function hrdrs {
|
||||||
|
setopt localoptions extendedglob
|
||||||
|
local -a lines
|
||||||
|
lines=("${(@f)$(herdr session list 2>/dev/null)}")
|
||||||
|
lines=("${(@)lines%%[[:space:]]#[^[:space:]]#}") # drop the socket column
|
||||||
|
if (( $#lines < 2 )); then
|
||||||
|
print "hrdrs: no herdr sessions found" >&2
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
local choice
|
||||||
|
if (( $+commands[fzf] )); then
|
||||||
|
choice=$(print -l -- "${lines[@]}" | fzf --header-lines=1 --prompt='herdr session> ') || return
|
||||||
|
else
|
||||||
|
print -- "${lines[1]}"
|
||||||
|
local PS3="Attach to session: "
|
||||||
|
select choice in "${lines[@]:1}"; do
|
||||||
|
[[ -n "$choice" ]] && break
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
[[ -n "$choice" ]] || return 1
|
||||||
|
|
||||||
|
herdr session attach "${${(z)choice}[1]}"
|
||||||
|
}
|
||||||
|
|
||||||
|
# COMPLETION
|
||||||
|
# If the completion file doesn't exist yet, we need to autoload it and
|
||||||
|
# bind it to `herdr`. Otherwise, compinit will have already done that.
|
||||||
|
if [[ ! -f "$ZSH_CACHE_DIR/completions/_herdr" ]]; then
|
||||||
|
typeset -g -A _comps
|
||||||
|
autoload -Uz _herdr
|
||||||
|
_comps[herdr]=_herdr
|
||||||
|
fi
|
||||||
|
|
||||||
|
zmodload -F zsh/files b:zf_mv
|
||||||
|
() {
|
||||||
|
local TMPPREFIX="$ZSH_CACHE_DIR/completions/._herdr"
|
||||||
|
zf_mv -f -- =( herdr completion zsh < /dev/null 2> /dev/null ) "$ZSH_CACHE_DIR/completions/_herdr"
|
||||||
|
} &|
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
# hermes plugin
|
||||||
|
|
||||||
|
This plugin adds completions for the Hermes AI agent.
|
||||||
|
|
||||||
|
To use it, add `hermes` to the plugin array in your zshrc file:
|
||||||
|
|
||||||
|
```zsh
|
||||||
|
plugins=(... hermes)
|
||||||
|
```
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
```zsh
|
||||||
|
hermes <TAB>
|
||||||
|
```
|
||||||
|
|
||||||
|
## Common Workflows
|
||||||
|
|
||||||
|
```zsh
|
||||||
|
# First time setup/updating overall config
|
||||||
|
hermes setup
|
||||||
|
|
||||||
|
# Starting the tui chat
|
||||||
|
hermes
|
||||||
|
|
||||||
|
# Changing default model
|
||||||
|
hermes model
|
||||||
|
```
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
if (( ! $+commands[hermes] )); then
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ ! -f "$ZSH_CACHE_DIR/completions/_hermes" ]]; then
|
||||||
|
typeset -g -A _comps
|
||||||
|
autoload -Uz _hermes
|
||||||
|
_comps[hermes]=_hermes
|
||||||
|
fi
|
||||||
|
|
||||||
|
zmodload -F zsh/files b:zf_mv
|
||||||
|
() {
|
||||||
|
local TMPPREFIX="$ZSH_CACHE_DIR/completions/._hermes"
|
||||||
|
zf_mv -f -- =( hermes completion zsh < /dev/null 2> /dev/null ) "$ZSH_CACHE_DIR/completions/_hermes"
|
||||||
|
} &|
|
||||||
@@ -20,7 +20,7 @@ Requirements
|
|||||||
Install
|
Install
|
||||||
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
||||||
|
|
||||||
Using the [Homebrew](https://brew.sh) package manager:
|
Using the [Homebrew]( https://brew.sh ) package manager:
|
||||||
|
|
||||||
brew install zsh-history-substring-search
|
brew install zsh-history-substring-search
|
||||||
echo 'source $(brew --prefix)/share/zsh-history-substring-search/zsh-history-substring-search.zsh' >> ~/.zshrc
|
echo 'source $(brew --prefix)/share/zsh-history-substring-search/zsh-history-substring-search.zsh' >> ~/.zshrc
|
||||||
@@ -51,7 +51,7 @@ Using [zplug](https://github.com/zplug/zplug):
|
|||||||
|
|
||||||
1. Add this repo to `~/.zshrc`:
|
1. Add this repo to `~/.zshrc`:
|
||||||
|
|
||||||
zplug "zsh-users/zsh-history-substring-search", as: plugin
|
zplug "zsh-users/zsh-history-substring-search", as:plugin
|
||||||
|
|
||||||
Using [antigen](https://github.com/zsh-users/antigen):
|
Using [antigen](https://github.com/zsh-users/antigen):
|
||||||
|
|
||||||
@@ -75,7 +75,7 @@ Using [Zinit](https://github.com/zdharma-continuum/zinit):
|
|||||||
|
|
||||||
1. Use the `Oh-my-zsh` Zinit snippet in `~/.zshrc`:
|
1. Use the `Oh-my-zsh` Zinit snippet in `~/.zshrc`:
|
||||||
|
|
||||||
zinit snippet OMZ::plugins/git/git.plugin.zsh`
|
zinit snippet OMZ::plugins/git/git.plugin.zsh
|
||||||
|
|
||||||
2. Load the plugin in `~/.zshrc`:
|
2. Load the plugin in `~/.zshrc`:
|
||||||
|
|
||||||
|
|||||||
@@ -295,8 +295,8 @@ _history-substring-search-begin() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
#
|
#
|
||||||
# Escape and join query parts with wildcard character '*' as separator
|
# Escape and join query parts with wildcard character '*' as seperator
|
||||||
# `(j:CHAR:)` join array to string with CHAR as separator
|
# `(j:CHAR:)` join array to string with CHAR as seperator
|
||||||
#
|
#
|
||||||
local search_pattern="${(j:*:)_history_substring_search_query_parts[@]//(#m)[\][()|\\*?#<>~^]/\\$MATCH}*"
|
local search_pattern="${(j:*:)_history_substring_search_query_parts[@]//(#m)[\][()|\\*?#<>~^]/\\$MATCH}*"
|
||||||
|
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ plugins=(... jj)
|
|||||||
| jjopl | `jj op log` |
|
| jjopl | `jj op log` |
|
||||||
| jjor | `jj op restore` |
|
| jjor | `jj op restore` |
|
||||||
| jjrb | `jj rebase` |
|
| jjrb | `jj rebase` |
|
||||||
| jjrbm | `jj rebase -d "trunk()"` |
|
| jjrbm | `jj rebase -o "trunk()"` |
|
||||||
| jjrs | `jj restore` |
|
| jjrs | `jj restore` |
|
||||||
| jjrt | `cd "$(jj root \|\| echo .)"` |
|
| jjrt | `cd "$(jj root \|\| echo .)"` |
|
||||||
| jjs | `jj show` |
|
| jjs | `jj show` |
|
||||||
@@ -120,10 +120,10 @@ that.
|
|||||||
|
|
||||||
### Git async-prompt compatibility
|
### Git async-prompt compatibility
|
||||||
|
|
||||||
If you use a wrapper function that calls `git_prompt_info` (as shown above), it won't work with
|
If you use a wrapper function that calls `git_prompt_info` (as shown above), it won't work with the default
|
||||||
the default git async-prompt mode. This is because async-prompt only registers its background worker
|
git async-prompt mode. This is because async-prompt only registers its background worker when it detects
|
||||||
when it detects `$(git_prompt_info)` literally in your prompt variables. A wrapper like
|
`$(git_prompt_info)` literally in your prompt variables. A wrapper like `$(_my_theme_vcs_info)` won't match,
|
||||||
`$(_my_theme_vcs_info)` won't match, so the async output stays empty.
|
so the async output stays empty.
|
||||||
|
|
||||||
To fix this, add one of the following to your `.zshrc` **before** Oh My Zsh is sourced:
|
To fix this, add one of the following to your `.zshrc` **before** Oh My Zsh is sourced:
|
||||||
|
|
||||||
|
|||||||
@@ -13,8 +13,8 @@ fi
|
|||||||
|
|
||||||
zmodload -F zsh/files b:zf_mv
|
zmodload -F zsh/files b:zf_mv
|
||||||
() {
|
() {
|
||||||
local TMPPREFIX="$ZSH_CACHE_DIR/completions/_jj"
|
local TMPPREFIX="$ZSH_CACHE_DIR/completions/._jj"
|
||||||
zf_mv -f -- =( COMPLETE=zsh jj ) "$TMPPREFIX"
|
zf_mv -f -- =( COMPLETE=zsh jj ) "$ZSH_CACHE_DIR/completions/_jj"
|
||||||
} &|
|
} &|
|
||||||
|
|
||||||
function __jj_prompt_jj() {
|
function __jj_prompt_jj() {
|
||||||
@@ -81,7 +81,7 @@ alias jjop='jj op'
|
|||||||
alias jjopl='jj op log'
|
alias jjopl='jj op log'
|
||||||
alias jjor='jj op restore'
|
alias jjor='jj op restore'
|
||||||
alias jjrb='jj rebase'
|
alias jjrb='jj rebase'
|
||||||
alias jjrbm='jj rebase -d "trunk()"'
|
alias jjrbm='jj rebase -o "trunk()"'
|
||||||
alias jjrs='jj restore'
|
alias jjrs='jj restore'
|
||||||
alias jjrt='cd "$(jj root || echo .)"'
|
alias jjrt='cd "$(jj root || echo .)"'
|
||||||
alias jjs='jj show'
|
alias jjs='jj show'
|
||||||
|
|||||||
@@ -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)
|
||||||
|
|||||||
@@ -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"
|
||||||
|
}
|
||||||
@@ -35,6 +35,7 @@ alias jdlr='juju debug-log --ms --replay'
|
|||||||
alias jcon='juju consume'
|
alias jcon='juju consume'
|
||||||
alias jeb='juju export-bundle'
|
alias jeb='juju export-bundle'
|
||||||
alias jex='juju expose'
|
alias jex='juju expose'
|
||||||
|
alias junex='juju unexpose'
|
||||||
alias jh='juju help'
|
alias jh='juju help'
|
||||||
alias jkc='juju kill-controller -y -t 0'
|
alias jkc='juju kill-controller -y -t 0'
|
||||||
alias jm='juju models'
|
alias jm='juju models'
|
||||||
|
|||||||
@@ -13,6 +13,6 @@ fi
|
|||||||
# the actual completion file will be loaded.
|
# the actual completion file will be loaded.
|
||||||
zmodload -F zsh/files b:zf_mv
|
zmodload -F zsh/files b:zf_mv
|
||||||
() {
|
() {
|
||||||
local TMPPREFIX="$ZSH_CACHE_DIR/completions/_k9s"
|
local TMPPREFIX="$ZSH_CACHE_DIR/completions/._k9s"
|
||||||
zf_mv -f -- =( k9s completion zsh ) "$TMPPREFIX"
|
zf_mv -f -- =( k9s completion zsh ) "$ZSH_CACHE_DIR/completions/_k9s"
|
||||||
} &|
|
} &|
|
||||||
|
|||||||
@@ -13,8 +13,8 @@ fi
|
|||||||
# Generate and load kind completion
|
# Generate and load kind completion
|
||||||
zmodload -F zsh/files b:zf_mv
|
zmodload -F zsh/files b:zf_mv
|
||||||
() {
|
() {
|
||||||
local TMPPREFIX="$ZSH_CACHE_DIR/completions/_kind"
|
local TMPPREFIX="$ZSH_CACHE_DIR/completions/._kind"
|
||||||
zf_mv -f -- =( kind completion zsh ) "$TMPPREFIX"
|
zf_mv -f -- =( kind completion zsh ) "$ZSH_CACHE_DIR/completions/_kind"
|
||||||
} &|
|
} &|
|
||||||
|
|
||||||
# Register aliases
|
# Register aliases
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
# Kubernetes prompt helper for bash/zsh
|
# Kubernetes prompt info for bash, fish, and zsh
|
||||||
# Displays current context and namespace
|
# Displays current context and namespace
|
||||||
|
|
||||||
# Copyright 2026 Jon Mosco
|
# Copyright 2026 Jon Mosco
|
||||||
@@ -39,6 +39,7 @@ KUBE_PS1_HIDE_IF_NOCONTEXT="${KUBE_PS1_HIDE_IF_NOCONTEXT:-false}"
|
|||||||
_KUBE_PS1_KUBECONFIG_CACHE="${KUBECONFIG}"
|
_KUBE_PS1_KUBECONFIG_CACHE="${KUBECONFIG}"
|
||||||
_KUBE_PS1_DISABLE_PATH="${HOME}/.kube/kube-ps1/disabled"
|
_KUBE_PS1_DISABLE_PATH="${HOME}/.kube/kube-ps1/disabled"
|
||||||
_KUBE_PS1_LAST_TIME=0
|
_KUBE_PS1_LAST_TIME=0
|
||||||
|
_KUBE_PS1_HAS_CONTEXT=false
|
||||||
|
|
||||||
# Determine our shell
|
# Determine our shell
|
||||||
_kube_ps1_shell_type() {
|
_kube_ps1_shell_type() {
|
||||||
@@ -121,7 +122,7 @@ _kube_ps1_color_fg() {
|
|||||||
if [[ "${_KUBE_PS1_TPUT_AVAILABLE}" == "true" ]]; then
|
if [[ "${_KUBE_PS1_TPUT_AVAILABLE}" == "true" ]]; then
|
||||||
_KUBE_PS1_FG_CODE="$(tput setaf "${_KUBE_PS1_FG_CODE}")"
|
_KUBE_PS1_FG_CODE="$(tput setaf "${_KUBE_PS1_FG_CODE}")"
|
||||||
elif [[ $_KUBE_PS1_FG_CODE -ge 0 ]] && [[ $_KUBE_PS1_FG_CODE -le 255 ]]; then
|
elif [[ $_KUBE_PS1_FG_CODE -ge 0 ]] && [[ $_KUBE_PS1_FG_CODE -le 255 ]]; then
|
||||||
_KUBE_PS1_FG_CODE="\033[38;5;${_KUBE_PS1_FG_CODE}m"
|
_KUBE_PS1_FG_CODE=$'\033'"[38;5;${_KUBE_PS1_FG_CODE}m"
|
||||||
else
|
else
|
||||||
_KUBE_PS1_FG_CODE="${_KUBE_PS1_DEFAULT_FG}"
|
_KUBE_PS1_FG_CODE="${_KUBE_PS1_DEFAULT_FG}"
|
||||||
fi
|
fi
|
||||||
@@ -154,7 +155,7 @@ _kube_ps1_color_bg() {
|
|||||||
if [[ "${_KUBE_PS1_TPUT_AVAILABLE}" == "true" ]]; then
|
if [[ "${_KUBE_PS1_TPUT_AVAILABLE}" == "true" ]]; then
|
||||||
_KUBE_PS1_BG_CODE="$(tput setab "${_KUBE_PS1_BG_CODE}")"
|
_KUBE_PS1_BG_CODE="$(tput setab "${_KUBE_PS1_BG_CODE}")"
|
||||||
elif [[ $_KUBE_PS1_BG_CODE -ge 0 ]] && [[ $_KUBE_PS1_BG_CODE -le 255 ]]; then
|
elif [[ $_KUBE_PS1_BG_CODE -ge 0 ]] && [[ $_KUBE_PS1_BG_CODE -le 255 ]]; then
|
||||||
_KUBE_PS1_BG_CODE="\033[48;5;${_KUBE_PS1_BG_CODE}m"
|
_KUBE_PS1_BG_CODE=$'\033'"[48;5;${_KUBE_PS1_BG_CODE}m"
|
||||||
else
|
else
|
||||||
_KUBE_PS1_BG_CODE="${_KUBE_PS1_DEFAULT_BG}"
|
_KUBE_PS1_BG_CODE="${_KUBE_PS1_DEFAULT_BG}"
|
||||||
fi
|
fi
|
||||||
@@ -264,15 +265,21 @@ _kube_ps1_prompt_update() {
|
|||||||
[[ "${KUBE_PS1_ENABLED}" == "off" ]] && return $return_code
|
[[ "${KUBE_PS1_ENABLED}" == "off" ]] && return $return_code
|
||||||
|
|
||||||
if ! _kube_ps1_binary_check "${KUBE_PS1_BINARY}"; then
|
if ! _kube_ps1_binary_check "${KUBE_PS1_BINARY}"; then
|
||||||
# No ability to fetch context/namespace; display N/A.
|
# Unable to determine context availability; preserve the existing
|
||||||
|
# BINARY-N/A prompt instead of treating it as no context.
|
||||||
KUBE_PS1_CONTEXT="BINARY-N/A"
|
KUBE_PS1_CONTEXT="BINARY-N/A"
|
||||||
KUBE_PS1_NAMESPACE="N/A"
|
KUBE_PS1_NAMESPACE="N/A"
|
||||||
|
unset _KUBE_PS1_HAS_CONTEXT
|
||||||
|
# Refresh when the binary becomes available again.
|
||||||
|
_KUBE_PS1_LAST_TIME=0
|
||||||
return $return_code
|
return $return_code
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ "${KUBECONFIG}" != "${_KUBE_PS1_KUBECONFIG_CACHE}" ]]; then
|
if [[ "${_KUBE_PS1_LAST_TIME}" == 0 ]] ||
|
||||||
# User changed KUBECONFIG; unconditionally refetch.
|
[[ "${KUBECONFIG}" != "${_KUBE_PS1_KUBECONFIG_CACHE}" ]]; then
|
||||||
_KUBE_PS1_KUBECONFIG_CACHE=${KUBECONFIG}
|
# Fetch initially, even if no config file exists, and whenever the
|
||||||
|
# user changes KUBECONFIG.
|
||||||
|
_KUBE_PS1_KUBECONFIG_CACHE="${KUBECONFIG}"
|
||||||
_kube_ps1_get_context_ns
|
_kube_ps1_get_context_ns
|
||||||
return $return_code
|
return $return_code
|
||||||
fi
|
fi
|
||||||
@@ -300,13 +307,30 @@ _kube_ps1_prompt_update() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_kube_ps1_get_context() {
|
_kube_ps1_get_context() {
|
||||||
if [[ "${KUBE_PS1_CONTEXT_ENABLE}" == true ]]; then
|
local context
|
||||||
KUBE_PS1_CONTEXT="$(${KUBE_PS1_BINARY} config current-context 2>/dev/null)"
|
|
||||||
KUBE_PS1_CONTEXT="${KUBE_PS1_CONTEXT:-N/A}"
|
|
||||||
|
|
||||||
if [[ -n "${KUBE_PS1_CLUSTER_FUNCTION}" ]]; then
|
# Context availability must be detected even when context display is
|
||||||
KUBE_PS1_CONTEXT="$("${KUBE_PS1_CLUSTER_FUNCTION}" "${KUBE_PS1_CONTEXT}")"
|
# disabled but KUBE_PS1_HIDE_IF_NOCONTEXT is enabled.
|
||||||
fi
|
if [[ "${KUBE_PS1_CONTEXT_ENABLE}" != true ]] &&
|
||||||
|
[[ "${KUBE_PS1_HIDE_IF_NOCONTEXT}" != true ]]; then
|
||||||
|
KUBE_PS1_CONTEXT=
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
context="$("${KUBE_PS1_BINARY}" config current-context 2>/dev/null)"
|
||||||
|
|
||||||
|
_KUBE_PS1_HAS_CONTEXT=false
|
||||||
|
[[ -n "${context}" ]] && _KUBE_PS1_HAS_CONTEXT=true
|
||||||
|
|
||||||
|
if [[ "${KUBE_PS1_CONTEXT_ENABLE}" != true ]]; then
|
||||||
|
KUBE_PS1_CONTEXT=
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
KUBE_PS1_CONTEXT="${context:-N/A}"
|
||||||
|
|
||||||
|
if [[ -n "${KUBE_PS1_CLUSTER_FUNCTION}" ]]; then
|
||||||
|
KUBE_PS1_CONTEXT="$("${KUBE_PS1_CLUSTER_FUNCTION}" "${KUBE_PS1_CONTEXT}")"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -325,7 +349,7 @@ _kube_ps1_get_context_ns() {
|
|||||||
# Set the command time
|
# Set the command time
|
||||||
if [[ "${_KUBE_PS1_SHELL}" == "bash" ]]; then
|
if [[ "${_KUBE_PS1_SHELL}" == "bash" ]]; then
|
||||||
if ((BASH_VERSINFO[0] > 4 || (BASH_VERSINFO[0] == 4 && BASH_VERSINFO[1] >= 2))); then
|
if ((BASH_VERSINFO[0] > 4 || (BASH_VERSINFO[0] == 4 && BASH_VERSINFO[1] >= 2))); then
|
||||||
_KUBE_PS1_LAST_TIME=$(printf '%(%s)T')
|
printf -v _KUBE_PS1_LAST_TIME '%(%s)T' -1
|
||||||
else
|
else
|
||||||
_KUBE_PS1_LAST_TIME=$(date +%s)
|
_KUBE_PS1_LAST_TIME=$(date +%s)
|
||||||
fi
|
fi
|
||||||
@@ -407,11 +431,16 @@ kubeoff() {
|
|||||||
# Build our prompt
|
# Build our prompt
|
||||||
kube_ps1() {
|
kube_ps1() {
|
||||||
[[ "${KUBE_PS1_ENABLED}" == "off" ]] && return
|
[[ "${KUBE_PS1_ENABLED}" == "off" ]] && return
|
||||||
|
|
||||||
|
[[ "${KUBE_PS1_HIDE_IF_NOCONTEXT}" == true ]] &&
|
||||||
|
[[ "${_KUBE_PS1_HAS_CONTEXT}" == false ]] && return
|
||||||
|
|
||||||
[[ -z "${KUBE_PS1_CONTEXT}" ]] && [[ "${KUBE_PS1_CONTEXT_ENABLE}" == true ]] && return
|
[[ -z "${KUBE_PS1_CONTEXT}" ]] && [[ "${KUBE_PS1_CONTEXT_ENABLE}" == true ]] && return
|
||||||
[[ "${KUBE_PS1_CONTEXT}" == "N/A" ]] && [[ ${KUBE_PS1_HIDE_IF_NOCONTEXT} == true ]] && return
|
|
||||||
|
|
||||||
local KUBE_PS1
|
local KUBE_PS1
|
||||||
local KUBE_PS1_RESET_COLOR="${_KUBE_PS1_OPEN_ESC}${_KUBE_PS1_DEFAULT_FG}${_KUBE_PS1_CLOSE_ESC}"
|
local KUBE_PS1_RESET_COLOR="${_KUBE_PS1_OPEN_ESC}${_KUBE_PS1_DEFAULT_FG}${_KUBE_PS1_CLOSE_ESC}"
|
||||||
|
local ctx_color="${KUBE_PS1_CTX_COLOR-red}"
|
||||||
|
local ns_color="${KUBE_PS1_NS_COLOR-cyan}"
|
||||||
|
|
||||||
# Background Color
|
# Background Color
|
||||||
[[ -n "${KUBE_PS1_BG_COLOR}" ]] && KUBE_PS1+="$(_kube_ps1_color_bg "${KUBE_PS1_BG_COLOR}")"
|
[[ -n "${KUBE_PS1_BG_COLOR}" ]] && KUBE_PS1+="$(_kube_ps1_color_bg "${KUBE_PS1_BG_COLOR}")"
|
||||||
@@ -432,22 +461,29 @@ kube_ps1() {
|
|||||||
|
|
||||||
# Context
|
# Context
|
||||||
if [[ "${KUBE_PS1_CONTEXT_ENABLE}" == true ]]; then
|
if [[ "${KUBE_PS1_CONTEXT_ENABLE}" == true ]]; then
|
||||||
local ctx_color="${KUBE_PS1_CTX_COLOR:-red}"
|
|
||||||
|
|
||||||
# Allow custom function to override color based on context
|
# Allow custom function to override color based on context
|
||||||
if [[ -n "${KUBE_PS1_CTX_COLOR_FUNCTION}" ]]; then
|
if [[ -n "${KUBE_PS1_CTX_COLOR_FUNCTION}" ]]; then
|
||||||
ctx_color="$("${KUBE_PS1_CTX_COLOR_FUNCTION}" "${KUBE_PS1_CONTEXT}")"
|
ctx_color="$("${KUBE_PS1_CTX_COLOR_FUNCTION}" "${KUBE_PS1_CONTEXT}")"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
KUBE_PS1+="$(_kube_ps1_color_fg "${ctx_color}")${KUBE_PS1_CONTEXT}${KUBE_PS1_RESET_COLOR}"
|
if [[ -n "${ctx_color}" ]]; then
|
||||||
|
KUBE_PS1+="$(_kube_ps1_color_fg "${ctx_color}")${KUBE_PS1_CONTEXT}${KUBE_PS1_RESET_COLOR}"
|
||||||
|
else
|
||||||
|
KUBE_PS1+="${KUBE_PS1_CONTEXT}"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Namespace
|
# Namespace
|
||||||
if [[ "${KUBE_PS1_NS_ENABLE}" == true ]]; then
|
if [[ "${KUBE_PS1_NS_ENABLE}" == true ]]; then
|
||||||
if [[ -n "${KUBE_PS1_DIVIDER}" ]] && [[ "${KUBE_PS1_CONTEXT_ENABLE}" == true ]]; then
|
if [[ -n "${KUBE_PS1_DIVIDER}" && "${KUBE_PS1_CONTEXT_ENABLE}" == true ]]; then
|
||||||
KUBE_PS1+="${KUBE_PS1_DIVIDER}"
|
KUBE_PS1+="${KUBE_PS1_DIVIDER}"
|
||||||
fi
|
fi
|
||||||
KUBE_PS1+="$(_kube_ps1_color_fg "${KUBE_PS1_NS_COLOR:-cyan}")${KUBE_PS1_NAMESPACE}${KUBE_PS1_RESET_COLOR}"
|
|
||||||
|
if [[ -n "${ns_color}" ]]; then
|
||||||
|
KUBE_PS1+="$(_kube_ps1_color_fg "${ns_color}")${KUBE_PS1_NAMESPACE}${KUBE_PS1_RESET_COLOR}"
|
||||||
|
else
|
||||||
|
KUBE_PS1+="${KUBE_PS1_NAMESPACE}"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Suffix
|
# Suffix
|
||||||
@@ -460,5 +496,5 @@ kube_ps1() {
|
|||||||
# Close Background color if defined
|
# Close Background color if defined
|
||||||
[[ -n "${KUBE_PS1_BG_COLOR}" ]] && KUBE_PS1+="${_KUBE_PS1_OPEN_ESC}${_KUBE_PS1_DEFAULT_BG}${_KUBE_PS1_CLOSE_ESC}"
|
[[ -n "${KUBE_PS1_BG_COLOR}" ]] && KUBE_PS1+="${_KUBE_PS1_OPEN_ESC}${_KUBE_PS1_DEFAULT_BG}${_KUBE_PS1_CLOSE_ESC}"
|
||||||
|
|
||||||
echo "${KUBE_PS1}"
|
printf '%s' "${KUBE_PS1}"
|
||||||
}
|
}
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user