#zsh #zsh-plugin

app zabrze

ZSH abbreviation exapansion plugin

20 releases

0.3.0 Sep 17, 2023
0.2.4 May 19, 2023
0.2.3 Jan 10, 2023
0.2.2 Dec 22, 2022
0.1.3+1 Sep 4, 2021

#70 in Command-line interface

Download history 17/week @ 2023-06-03 22/week @ 2023-06-10 41/week @ 2023-06-17 18/week @ 2023-06-24 50/week @ 2023-07-01 24/week @ 2023-07-08 22/week @ 2023-07-15 62/week @ 2023-07-22 23/week @ 2023-07-29 20/week @ 2023-08-05 19/week @ 2023-08-12 38/week @ 2023-08-19 34/week @ 2023-08-26 15/week @ 2023-09-02 23/week @ 2023-09-09 49/week @ 2023-09-16

124 downloads per month

MIT license

48KB
1K SLoC

zabrze

ZSH abbreviation expansion plugin

Usage

Simple abbreviation

# ~/.config/zabrze/config.yaml
abbrevs:
  - name: git
    abbr: g
    snippet: git

  - name: awk '{print $1}'
    abbr: '.1'
    snippet: awk '{print $1}'
$ eval "$(zabrze init --bind-keys)"

then

$ g<SP>
#  ↓ expanded
$ git

$ cat a.txt | .1<CR>
#  ↓ expanded and executed
$ cat a.txt | awk '{print $1}'

Global abbreviation

abbrevs:
  - name: '>/dev/null 2>&1'
    abbr: 'null'
    snippets: '>/dev/null 2>&1'
    global: true
$ echo a null<SP>
#  ↓ expanded
$ echo a >/dev/null 2>&1

Global abbreviation with context

abbrevs:
  - name: git commit
    abbr: c
    snippet: commit
    global: true
    context: '^git\s'

  - name: branch name
    abbr: B
    snippet: $(git symbolic-ref --short HEAD)
    evaluate: true
    global: true
    context: '^git\s'
$ git c<SP>
#  ↓ expanded
$ git commit

$ git push -d origin B<CR>
#  ↓ expanded and executed
$ git push -d origin main

Conditional abbreviation

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

abbrevs:
  - name: python3 *.py
    abbr-pattern: \.py$
    snippet: python3 $abbr
    evaluate: true
$ ./a.py<CR>
#  ↓ expanded and executed
$ python3 ./a.py

Installation

From prebuilt binary

You can download a binary release here.

zinit

zinit blockf light-mode as"program" from"gh-r" for \
    atload'eval "$(zabrze init --bind-keys)"' \
    Ryooooooga/zabrze

Cargo

$ cargo install zabrze

Homebrew

$ brew install ryooooooga/tap/zabrze

Alternatives

Dependencies

~5–7MB
~132K SLoC