Где разместить скрипт автозаполнения zsh в Linux?

После установки cheat (шпаргалки команд из командной строки) я попытался включить автодополнение с помощью предоставил скрипт zsh. Тем не менее, я не могу найти правильное место для скрипта.

Уже

  • я получаю cheat.zsh ;
  • скопируйте его в ~/.oh-my-zsh/custom/plugins/cheat/_cheat.zsh ;
  • добавить чит в массив plugins в моем ~/.zshrc ;
  • перезагрузить мою оболочку.

Автодополнение не происходит при вводе cheat d<TAB>.

Вопрос

Итак, где разместить скрипт автодополнения zsh в Linux?


person Édouard Lopez    schedule 13.08.2014    source источник
comment
попробуйте добавить его в ~/.bash_profile.. например, 'source .oh-my-zsh/custom/plugins/cheat/_cheat.zsh'   -  person Maximin    schedule 13.08.2014
comment
@Maximin: он использует Zsh, а не Bash.   -  person tripleee    schedule 13.08.2014


Ответы (2)


Я заставил это работать, добавив чит.zsh в каталог ~/.oh-my-zsh/plugins. zsh проверяет автозагрузку функций по FPATH, поэтому попробуйте:

echo $FPATH

а затем либо добавить в FPATH, либо переместить файл в папку по пути.

Это на самом деле гораздо лучше объясняет это: zsh">https://unix.stackexchange.com/questions/33255/how-to-define-and-load-your-own-shell-function-in-zsh

person TheGoatMan7    schedule 13.08.2014
comment
У меня нет ~/.oh-my-zsh/custom/plugins/cheat/ в $FPATH, но у меня есть еще один плагин для вырезания. Так что я думаю, что моего source $HOME/.zshrc недостаточно. - person Édouard Lopez; 14.08.2014

Позвольте мне попытаться помочь здесь.

Я пробовал что-то подобное, и вот как я смог заставить его работать. Решение ниже проверено с помощью oh-my-zsh в дистрибутиве Debian [ubuntu]

Проблема:

> Your zsh isnt giving proper completion suggestions say [conda]
> This is what you get when you type in # conda [tab]

введите здесь описание изображения

Решение:

1. Find the completion script
    one great location is https://github.com/clarketm/zsh-completions/tree/master/src 
2. Download the file to completions folder [~/.oh-my-zsh/completions]
    $ wget https://raw.githubusercontent.com/clarketm/zsh-completions/master/src/_conda ~/.oh-my-zsh/completions
3. Make sure the completions folder is listed under $fpath
     $ print -l $fpath
    3.1 What if its not listed
        It should have normaly added with .oh-my-zsh.sh 
        If not append below to ~/.oh-my-zsh/oh-my-zsh.sh
            # add a function path
            fpath=($ZSH/functions $ZSH/completions $fpath)
        3.1.1 source .zshrc
                $ source ~/.zshrc
4. Execute `compinit` this will build ~/.zcompdump file for the functions
    $ compinit 

введите здесь описание изображения

Исправление проблем:

1. Due to conflicts the suggestions might not be shown try the following
    $ rm -f ~/.zcompdump; compinit
    we are clearing the function dump stored by zsh, its safe zsh will rebuilt it.
2. Try source .zshrc
    $ source ~/.zshrc
3. Try loggin out and login
4. Check the mapping in ~/.zcompdump
    $ vi ~/.zcompdump
    search for conda 
        [/conda]
    you should see as below
    'conda' '_conda

Надеюсь, кому-то это будет полезно, если да, рад помочь

person Amod    schedule 10.02.2021