Giter Club home page Giter Club logo

zsh-autocomplete's Introduction

zsh-autocomplete

zsh-autocomplete adds real-time type-ahead autocompletion to Zsh, plus many more completion features.

file-search

Features

  • Recent dirs completion:

    recent dirs

    • Supports cdr, zsh-z, zoxide, z.lua, rupa/z.sh, autojump and fasd.
  • Automatic incremental history search:

    history lines

  • History menu (โ†‘/PgUp):

    history menu 1 history menu 2
    • Does history search when buffer is non-empty:

      history search 1 history search 2
  • Multi-selection with Alt+Space in completion menu (โ†“/PgDn) and history menu:

    menu select 1 menu select 2
    • Single selection in menus with Enter.
  • Additional context-sensitive completions:

    • Alias expansions

      alias expansions

    • Alternative quoting

      requoted

    • Common substrings

      unambiguous

Key Bindings

Key(s) Action Widget
any Show completions (asynchronously) _list_choices
Tab Insert top completion complete-word
Shift+Tab Insert bottom completion expand-word
Ctrl+Space Show full completion menu list-expand
โ†“ Enter completion menu or move cursor down (in multi-line buffer) down-line-or-select
PgDn Enter completion menu (always) menu-select
โ†‘ Open history menu or move cursor up (in multi-line buffer) up-line-or-search
PgUp Open history menu (always) history-search

Completion Menu

Key(s) Action
โ†‘/โ†“/โ†/โ†’ Change selection
Enter Accept and exit
Alt+Space Multi-select
Ctrl+Space Show full completion menu
PgUp Page up
PgDn Page Down
Alt+B Backward one group (if groups are shown)
Alt+F Forward one group (if groups are shown)
Home Beginning of line
End End of line
Alt+Shift+, Beginning of menu
Alt+Shift+. End of menu
other Accept and exit (then execute the key just typed)

History Menu

Key(s) Action
โ†‘/โ†“ Change selection
Enter Accept and exit
Alt+Space Multi-select
Alt+Shift+, Beginning of menu
Alt+Shift+. End of menu
other Accept and exit (then execute the key just typed)

Requirements

Recommended:

  • Zsh 5.8 or later.

Minimum:

  • Zsh 5.3 or later.

Installation

  1. git clone this repo.
  2. Add to your .zshrc file:
    source path/to/zsh-autocomplete.plugin.zsh

Updating

  1. cd into zsh-autocomplete's directory.
  2. Do git pull.

As a Plugin

zsh-autocomplete should work as a plugin with most frameworks & plugin managers. Please refer to your framework's/plugin manager's documentation for instructions.

Settings

To change your settings, just copy-paste any of the code below to your ~/.zshrc file.

โš ๏ธ Note that while most of these settings use the :autocomplete: namespace, some of them use :completion:. This is because the latter are managed by Zsh's own completion system, whereas the former are unique to zsh-autocomplete.

Show completions in named groups

To categorize completions under informative headers:

zstyle ':completion:*' group-name ''

To group completions only when you press Ctrl+Space:

zstyle ':completion:list-expand:*' group-name ''

Show more/less help text

To show more descriptions:

zstyle ':completion:*' extra-verbose yes

To show fewer descriptions:

zstyle ':completion:*' verbose no

To show more descriptions only when you press Ctrl+Space:

zstyle ':completion:list-expand:*' extra-verbose yes

Disable particular completions

Any of the extra completions added by zsh-autocomplete can be disabled through the completion system's tag-order setting. For example, to disable history words, recent directories and recent files:

zstyle ':completion:*' tag-order '! history-words recent-directories recent-files' '-'

Wait for a minimum amount of input

To suppress autocompletion until a minimum number of characters have been typed:

zstyle ':autocomplete:*' min-input 3

Change the length of the autocompletion list

To change the list length from the default of 10 lines:

zstyle ':autocomplete:*' max-lines 100%

You can set this to a percentage of the available screen space or to a fixed number of lines. Both work.

Customize the autocompletion messages

To change the message shown when the list of completions is too long and gets truncated:

zstyle ':autocomplete:*:too-many-matches' message '(partial list; press Ctrl+Space to expand)'

To change the message shown when no matching completions can be found:

zstyle ':autocomplete:*:no-matches-at-all' message 'No matching completions found.'

Use your own completion config

To disable zsh-autocomplete's pre-packaged config:

zstyle ':autocomplete:*' config off

Change Tab behavior

By default, Tab insert the top completion, Shift+Tab inserts the bottom completion, and โ†“ activates menu selection.

โš ๏ธ Note that, unlike most other settings, changing widget-style at runtime has no effect and changing fzf-completion at runtime will not function correctly. These settings can be changed in your ~/.zshrc file only.

To make Tab first insert any common substring, before inserting full completions:

zstyle ':autocomplete:tab:*' insert-unambiguous yes

To make Tab or Shift+Tab use menu selection:

zstyle ':autocomplete:tab:*' widget-style menu-select

To make Tab and Shift+Tab cycle completions without using menu selection:

zstyle ':autocomplete:tab:*' widget-style menu-complete

To make Tab try Fzf's completion before using Zsh's:

zstyle ':autocomplete:tab:*' fzf-completion yes

widget-style, insert-unambiguous and fzf are mutually compatible and can be used in parallel.

Change other key bindings

Key bindings other than Tab or Shift+Tab can be overridden with the bindkey command, if you do so after sourcing zsh-autocomplete:

source path/to/zsh-autocomplete.plugin.zsh
# zsh-autocomplete defines an associative array `key` that you can use for this.
bindkey $key[Up] up-line-or-history
bindkey $key[Down] down-line-or-history
bindkey $key[ControlSpace] set-mark-command
# The lines above revert the given keys back to Zsh defaults.

Author

ยฉ 2020 Marlon Richert

License

This project is licensed under the MIT License. See the LICENSE file for details.

zsh-autocomplete's People

Contributors

marlonrichert avatar shilik avatar

Watchers

James Cloos avatar

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.