Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ryooooooga/zabrze
zsh abbreviation expansion plugin
https://github.com/ryooooooga/zabrze
zle-widgets zsh zsh-plugin zsh-plugins
Last synced: 11 days ago
JSON representation
zsh abbreviation expansion plugin
- Host: GitHub
- URL: https://github.com/ryooooooga/zabrze
- Owner: Ryooooooga
- License: mit
- Created: 2021-08-14T08:38:22.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2024-10-12T14:04:32.000Z (25 days ago)
- Last Synced: 2024-10-13T02:16:14.980Z (24 days ago)
- Topics: zle-widgets, zsh, zsh-plugin, zsh-plugins
- Language: Rust
- Homepage:
- Size: 174 KB
- Stars: 33
- Watchers: 4
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# zabrze
[![](https://github.com/Ryooooooga/zabrze/actions/workflows/build.yml/badge.svg)](https://github.com/Ryooooooga/zabrze/actions/workflows/build.yml)
[![](https://badgen.net/crates/v/zabrze)](https://crates.io/crates/zabrze)ZSH abbreviation expansion plugin
## Usage
### Simple abbreviation
```yaml
# ~/.config/zabrze/config.yaml
abbrevs:
- name: git
abbr: g
snippet: git- name: awk '{print $1}'
abbr: '.1'
snippet: awk '{print $1}'
``````zsh
$ eval "$(zabrze init --bind-keys)"
```then
```zsh
$ g
# ↓ expanded
$ git$ cat a.txt | .1
# ↓ expanded and executed
$ cat a.txt | awk '{print $1}'
```### Global abbreviation
```yaml
abbrevs:
- name: '>/dev/null 2>&1'
abbr: 'null'
snippets: '>/dev/null 2>&1'
global: true
``````zsh
$ echo a null
# ↓ expanded
$ echo a >/dev/null 2>&1
```### Global abbreviation with context
```yaml
abbrevs:
- name: git commit
abbr: c
snippet: commit
global: true
context: '^git\s'
- name: git commit -m
abbr: cm
snippet: commit -m '{}'
cursor: "{}" # optional; defaults to "{}"
global: true
context: '^git\s'- name: branch name
abbr: B
snippet: $(git symbolic-ref --short HEAD)
evaluate: true
global: true
context: '^git\s'
``````zsh
$ git c
# ↓ expanded
$ git commit$ git cm
# ↓ expanded and move into quotes
$ git commit -m '|'$ git push -d origin B
# ↓ expanded and executed
$ git push -d origin main
```### Conditional abbreviation
```yaml
abbrevs:
- name: chrome
abbr: chrome
snippet: open -a 'Google Chrome'
if: '[[ "$OSTYPE" =~ darwin ]]' # only available in macOS- name: trash
abbr: rm
snippet: trash
if: (( ${+commands[trash]} )) # available if trash is installed- name: rm -r
abbr: rm
snippet: rm -r # fallback
```### Suffix alias
```yaml
abbrevs:
- name: python3 *.py
abbr-pattern: \.py$
snippet: python3 $abbr
evaluate: true
``````zsh
$ ./a.py
# ↓ expanded and executed
$ python3 ./a.py
```## Installation
### From prebuilt binary
You can download a binary release [here](https://github.com/Ryooooooga/zabrze/releases).
### zinit
```zsh
zinit blockf light-mode as"program" from"gh-r" for \
atload'eval "$(zabrze init --bind-keys)"' \
Ryooooooga/zabrze
```### Cargo
```zsh
$ cargo install zabrze
```### Homebrew
```zsh
$ brew install ryooooooga/tap/zabrze
```## Alternatives
- [zsh-abbrev-alias](https://github.com/momo-lab/zsh-abbrev-alias)
- [zeno.zsh](https://github.com/yuki-yano/zeno.zsh)