Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set tab for zsh autocompletion?

I want to set tab for zsh autocomplition plugin. There is related part of config:

# Widgets that accept the entire suggestion
(( ! ${+ZSH_AUTOSUGGEST_ACCEPT_WIDGETS} )) && {
        typeset -ga ZSH_AUTOSUGGEST_ACCEPT_WIDGETS
        ZSH_AUTOSUGGEST_ACCEPT_WIDGETS=(
                forward-char
                end-of-line
                tab-char //my line
                vi-forward-char
                vi-end-of-line
                vi-add-eol
        )
}

What is the convention for char names used? How does tab named?

like image 983
ogbofjnr Avatar asked Nov 28 '19 18:11

ogbofjnr


People also ask

What is find as you type autocomplete in zsh?

Asynchronous find-as-you-type autocompletion. … zsh-autocomplete adds real-time type-ahead autocompletion to Zsh. Find as you type, then press Tab to insert the top completion, Shift Tab to insert the bottom one, or ↓ / PgDn to select another completion.

How do I enable auto-suggestions in zshrc?

The first step is to clone the repository: Next, remove any calls to compinit available in the ZSH config file then finally, navigate to the cloned repository and add the .zsh file to .zshrc using the source command: Once you have successfully installed the tool, you can now see auto-suggestions as you type commands:

How to install Zsh in Linux?

The installation process for zsh is different in different Operating Systems. Checkout the Zsh Installation Guide to install zsh. After you install Zsh, make sure you make it your default shell. Run the following in your terminal to do so. Log out and Log in back to your default shell. Run echo $SHELL and the output /bin/zsh or similar is expected.

How to add multiple items to a zsh file?

Press Ctrl Space in the completion menu or the history menu to insert more than one item. Works out of the box with zero configuration, but also supports zsh-z, zoxide, z.lua , rupa/z.sh, autojump and fasd. Tested to work with Zsh 5.7 or newer. Should theoretically work with Zsh 5.4 or newer, but I'm unable to test that. Then restart your shell.


3 Answers

You will have to put

bindkey '       ' autosuggest-accept

into your .zshrc file. Notice that the space between the apostrophe is one keystroke of the tab-character. This works similarly with every other character or character combination. If you for example wanted to put a combination of the ctrl+space keys to trigger the acception, you'd append

bindkey '^ ' autosuggest-accept

to the file.

Here's a link to the Configuration-file, where this is explained: https://github.com/zsh-users/zsh-autosuggestions#key-bindings

like image 124
t3d08 Avatar answered Oct 19 '22 13:10

t3d08


For all of you that are struggling with the accepted answer, I got it to work doing the following:

bindkey '^I' autosuggest-accept

...where '^I' is tab.

like image 10
dave4jr Avatar answered Oct 19 '22 15:10

dave4jr


this seems to work as expected in your ~/.zshrc:

bindkey '\t' autosuggest-accept

If you want to know more, you can click here

like image 4
weilin wang Avatar answered Oct 19 '22 15:10

weilin wang