Git Product home page Git Product logo

zeno.zsh's Introduction

logo

zsh fuzzy completion and utility plugin with Deno.

Features

  • Insert snippet and abbrev snippet
  • Completion with fzf
    • Builtin git completion
    • User defined completion
  • ZLE utilities

Demo

Abbrev snippet

zeno

Completion with fzf

zeno

Requirements

Installation

zinit

zinit ice lucid depth"1" blockf
zinit light yuki-yano/zeno.zsh

git clone

$ git clone https://github.com/yuki-yano/zeno.zsh.git
$ echo "source /path/to/dir/zeno.zsh" >> ~/.zshrc

Usage

Abbrev snippet

Require user configuration file

$ gs<Space>

Insert
$ git status --short --branch
$ gs<Enter>

Execute
$ git status --short --branch

Completion

$ git add <Tab>
Git Add Files> ...

Insert snippet

Use zeno-insert-snippet zle

Search history

Use zeno-history-completion zle

Change ghq managed repository

Use zeno-ghq-cd zle

Configuration example

Completion and abbrev snippet

# if defined load the configuration file from there
# export ZENO_HOME=~/.config/zeno

# if disable deno cache command when plugin loaded
# export ZENO_DISABLE_EXECUTE_CACHE_COMMAND=1

# if enable fzf-tmux
# export ZENO_ENABLE_FZF_TMUX=1

# if setting fzf-tmux options
# export ZENO_FZF_TMUX_OPTIONS="-p"

# Experimental: Use UNIX Domain Socket
export ZENO_ENABLE_SOCK=1

# if disable builtin completion
# export ZENO_DISABLE_BUILTIN_COMPLETION=1

# default
export ZENO_GIT_CAT="cat"
# git file preview with color
# export ZENO_GIT_CAT="bat --color=always"

# default
export ZENO_GIT_TREE="tree"
# git folder preview with color
# export ZENO_GIT_TREE="exa --tree"

if [[ -n $ZENO_LOADED ]]; then
  bindkey ' '  zeno-auto-snippet

  # fallback if snippet not matched (default: self-insert)
  # export ZENO_AUTO_SNIPPET_FALLBACK=self-insert

  # if you use zsh's incremental search
  # bindkey -M isearch ' ' self-insert

  bindkey '^m' zeno-auto-snippet-and-accept-line

  bindkey '^i' zeno-completion

  bindkey '^x '  zeno-insert-space
  bindkey '^x^m' accept-line
  bindkey '^x^z' zeno-toggle-auto-snippet

  # fallback if completion not matched
  # (default: fzf-completion if exists; otherwise expand-or-complete)
  # export ZENO_COMPLETION_FALLBACK=expand-or-complete
fi

ZLE widget

if [[ -n $ZENO_LOADED ]]; then
  bindkey '^r'   zeno-history-selection
  bindkey '^x^s' zeno-insert-snippet
  bindkey '^x^f' zeno-ghq-cd
fi

Builtin completion

  • git
    • add
    • diff
    • diff file
    • checkout
    • checkout file
    • switch
    • reset
    • reset file
    • restore
    • fixup and squash commit
    • rebase
    • merge

See: https://github.com/yuki-yano/zeno.zsh/blob/main/src/completion/source/git.ts

User configuration file

The configuration file is searched from the following.

  • $ZENO_HOME/config.yml
  • $XDG_CONFIG_HOME/zeno/config.yml or ~/.config/zeno/config.yml
  • Find .../zeno/config.yml from each in $XDG_CONFIG_DIRS

Example

$ touch ~/.config/zeno/config.yml

and

snippets:
  # snippet and keyword abbrev
  - name: git status
    keyword: gs
    snippet: git status --short --branch

  # snippet with placeholder
  - name: git commit message
    keyword: gcim
    snippet: git commit -m '{{commit_message}}'

  - name: "null"
    keyword: "null"
    snippet: ">/dev/null 2>&1"
    # auto expand condition
    # If not defined, it is only valid at the beginning of a line.
    context:
      # buffer: ''
      lbuffer: '.+\s'
      # rbuffer: ''

  - name: branch
    keyword: B
    snippet: git symbolic-ref --short HEAD
    context:
      lbuffer: '^git\s+checkout\s+'
    evaluate: true # eval snippet


completions:
  # simple sourceCommand, no callback
  - name: kill signal
    patterns:
      - "^kill -s $"
    sourceCommand: "kill -l | tr ' ' '\\n'"
    options:
      --prompt: "'Kill Signal> '"

  # use excludePatterns and callback
  - name: kill pid
    patterns:
      - "^kill( .*)? $"
    excludePatterns:
      # -l, -n or -s is followed by SIGNAL instead of PID
      - " -[lns] $"
    sourceCommand: "LANG=C ps -ef | sed 1d"
    options:
      --multi: true
      --prompt: "'Kill Process> '"
    callback: "awk '{print $2}'"

  # Use null (\0) termination Input / Output
  - name: chdir
    patterns:
      - "^cd $"
    sourceCommand: "find . -path '*/.git' -prune -o -maxdepth 5 -type d -print0"
    options:
      # Added --read0 if null termination is used in `sourceCommand` output.
      --read0: true
      --prompt: "'Chdir> '"
      --preview: "cd {} && ls -a | sed '/^[.]*$/d'"
    callback: "cut -z -c 3-"
    callbackZero: true  # null termination is used in `callback` I/O

FAQ

Q: zsh-syntax-highlighting does not work well.

A: Use fast-syntax-highlighting instead.

Related project

zeno.zsh's People

Contributors

gamoutatsumi avatar kakikubo avatar milly avatar web-flow avatar yuki-yano avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

zeno.zsh's Issues

zsh-syntax-hightlighting と一緒に使うとエラーが出る

便利に使わせていただいています。開発ありがとうございます!
使っていてエラー出力が出ることがあったので、Issueをあげさせてもらいます。

zsh-syntax-hightlighting と一緒に使うとこのようなエラー出力が出ることがあります。

_zsh_highlight:17: bad set of key/value pairs for associative array

おそらくこちらのIssueと同じで optionsという変数名がつかわれている ことが原因かなと思います。

The cause is that zaw creates a variable named options, hiding clashing with the variable of the same name provided by zsh itself via a standard module.

zsh-users/zsh-syntax-highlighting#500 (comment)

deno `--unstable` flag deprecation message interrupts prompt

deno version

❯ deno --version
deno 1.40.0 (release, x86_64-unknown-linux-gnu)
v8 12.1.285.6
typescript 5.3.3

issue

Starting with deno's 1.40.0, if you use the --unstable flag, you will now receive a message informing you that it is deprecated.

https://docs.deno.com/runtime/manual/tools/unstable_flags

How to solve it?

The official documentation announces that it should be replaced with --unstable-*.
I'm not sure what I need as a flag, so I can't create a PR at the moment.

HIST_IGNORE_SPACE オプションに対応させてほしい

zsh の HIST_IGNORE_SPACE (スペースから始まるコマンドラインは履歴に残さない)を有効にして使っています。
しかしコマンドライン行頭に空白文字を入れた状態で snippet 展開すると行頭の空白が削除されてしまいます。
行頭空白を保存したまま展開させられるようにはできませんか?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.