在Linux上放置zsh​​自动完成脚本的位置?

时间:2014-08-13 15:53:20

标签: linux ubuntu zsh oh-my-zsh zsh-completion

安装cheat (command cheat sheets from the command line)后,我尝试使用provided zsh script启用自动完成功能。但是,我似乎找不到脚本的正确位置。

到目前为止

  • 我获取了cheat.zsh;
  • 将其复制到~/.oh-my-zsh/custom/plugins/cheat/_cheat.zsh;
  • 作弊添加到plugins;
  • 中的~/.zshrc数组中
  • 重装我的外壳。

键入cheat d<TAB>时不会自动完成。

问题

那么在Linux上放置zsh​​自动完成脚本的位置是什么?

2 个答案:

答案 0 :(得分:3)

我通过将cheat.zsh添加到〜/ .oh-my-zsh / plugins目录来实现此功能。 zsh检查FPATH上的自动加载功能,所以请尝试:

echo $FPATH

然后添加到FPATH或将文件移动到路径上的文件夹中。

这实际上可以更好地解释它: https://unix.stackexchange.com/questions/33255/how-to-define-and-load-your-own-shell-function-in-zsh

答案 1 :(得分:0)

让我在这里帮忙。

我正在尝试类似的东西,这就是我能够让它工作的方式。 以下解决方案已在 debian 发行版 [ubuntu]

上通过 oh-my-zsh 验证

问题:

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

enter image description here

解决方案:

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 

enter image description here

问题排查:

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

希望有人会觉得它有用,如果有帮助很高兴