Skip to content

Repository files navigation

 

wk

⌨️ which-key like menu for zsh

📦 Installation

  1. Download the archive for your platform from the latest release and extract it:

    https://github.com/844196/wk/releases/latest

    tar xzf wk-x86_64-unknown-linux-gnu.tar.gz

    It holds the wk binary, the JSON Schemas for the configuration files, and the license.

  2. Put the binary into your $PATH:

    install -m 755 wk-x86_64-unknown-linux-gnu/wk ~/.local/bin/
  3. Activate in $ZDOTDIR/.zshrc:

    # Bind space as the leader key and comma as the major-leader key.
    # The major-prefix "m" is used for the major menu.
    eval "$(wk init --leader ' ' --major-leader ',' --major-prefix 'm')"
  4. Restart zsh.

Tip

If you want to register only the widgets, change it as follows:

eval "$(wk init)"

⚙️ Configuration

Config

${XDG_CONFIG_HOME:-$HOME/.config}/wk/config.yaml

---
timeout: 60000
symbols:
  prompt: ''
colors:
  prompt: 8
  inputKeys:
    color: 8
    attrs: [dim]
  breadcrumb:
    color: 8
    attrs: [dim]
  lastInputKey:
    color: 6
    attrs: [underline]
  bindingKey: 5
  separator:
    color: 5
    attrs: [dim]
  group: 8
  bindingIcon: 8
  bindingDescription: 8

Point your editor at the schema in the extracted archive to get completion and validation:

# yaml-language-server: $schema=/path/to/wk-x86_64-unknown-linux-gnu/schemas/config.json

Global bindings

${XDG_CONFIG_HOME:-$HOME/.config}/wk/bindings.yaml

---
- key: g
  desc: Git
  type: bindings
  bindings:
    - key: p
      desc: Push/Pull
      type: bindings
      bindings:
        - key: return
          desc: git push
          type: command
          buffer: 'git push origin $(git symbolic-ref --short HEAD)'
          eval: true
        - key: f
          desc: git push -f
          type: command
          buffer: 'git push --force-with-lease --force-if-includes origin $(git symbolic-ref --short HEAD)'
          eval: true
        - key: l
          type: command
          buffer: 'git pull'
          accept: true
- key: y
  desc: Yank
  type: bindings
  bindings:
    - key: .
      desc: Copy $PWD
      type: command
      buffer: ' echo -ne "\e]52;c;$(base64 <(pwd | tee >$TTY | sed -z ''$s/\n$//''))\a"'
      accept: true

Point your editor at the schema in the extracted archive to get completion and validation:

# yaml-language-server: $schema=/path/to/wk-x86_64-unknown-linux-gnu/schemas/bindings.json

A key is the key to press. YAML reads an unquoted digit as a number, and wk reads it back as that digit, so key: 1 and key: '1' both bind the 1 key. Most punctuation needs no quoting either — key: . above is one. YAML's indicator characters do, though: unquoted they are read as null or rejected outright, so write key: '~' and key: ':'.

Local bindings

$PWD/wk.bindings.yaml

---
- key: m
  desc: Major
  type: bindings
  bindings:
    - key: b
      type: command
      buffer: 'npm run build'
      accept: true
    - key: l
      type: command
      buffer: 'npm run lint'
      accept: true
    - key: t
      type: command
      buffer: 'npm run test'
      accept: true

About

⌨️ which-key like menu for zsh

Topics

Resources

Stars

7 stars

Watchers

3 watching

Forks

Releases

Used by

Contributors

Languages