12

安装后cheat(命令行中的命令备忘单),我尝试使用提供的 zsh 脚本启用自动完成功能。但是,我似乎没有找到脚本的正确位置。

至今

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

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

问题

那么在Linux上将zsh自动补全脚本放在哪里呢?

4

2 回答 2

17

I got this to work by adding cheat.zsh to the ~/.oh-my-zsh/plugins directory. Zsh checks to autoload functions on FPATH, so try:

echo $FPATH

and then either add to FPATH or move the file into a folder on the path.

This actually does a much better job of explaining it: https://unix.stackexchange.com/questions/33255/how-to-define-and-load-your-own-shell-function-in-zsh

于 2014-08-13T17:18:44.653 回答
4

让我试着在这里帮忙。

我正在尝试类似的东西,这就是我能够让它发挥作用的方式。以下解决方案已oh-my-zsh在 debian 发行版 [ubuntu] 上验证

问题

  > 你的 zsh 没有给出正确的完成建议说 [conda]
  > 这是你输入 # conda 时得到的结果tab

在此处输入图像描述

解决方案

  1. 找到完成脚本

    一个很棒的位置是https://github.com/clarketm/zsh-completions/tree/master/src

  2. 将文件下载到完成文件夹[~/.oh-my-zsh/completions]

    wget https://raw.githubusercontent.com/clarketm/zsh-completions/master/src/_conda ~/.oh-my-zsh/completions
    
  3. 确保完成文件夹列在 $fpath 下

    print -l $fpath
    
    1. 如果它没有列出它应该正常添加 .oh-my-zsh.sh 如果没有在下面附加到 ~/.oh-my-zsh/oh-my-zsh.sh

      # add a function path
      fpath=($ZSH/functions $ZSH/completions $fpath)
      
    2. 源.zshrc

      source ~/.zshrc
      
  4. 执行compinit这将为函数构建~/.zcompdump文件

    compinit
    

在此处输入图像描述

故障排除

  1. 由于冲突,建议可能不会显示尝试以下

    rm -f ~/.zcompdump; compinit
    # we are clearing the function dump stored by zsh, its safe zsh will rebuilt it.
    
  2. 试试源码.zshrc

    source ~/.zshrc
    
  3. 尝试注销并登录

  4. 检查映射~/.zcompdump

    vi ~/.zcompdump
    

    搜索康达

    [/conda]

    你应该看到如下

    'conda' '_conda'

希望有人会觉得它有用,如果是的话很乐意提供帮助

于 2021-02-10T21:32:49.443 回答