cheat
(命令行中的命令速查表)之后,我尝试使用提供的zsh脚本启用自动补全。然而,我似乎找不到脚本的正确位置。
目前为止
- 获取
cheat.zsh
; - 将其复制到
~/.oh-my-zsh/custom/plugins/cheat/_cheat.zsh
; - 将cheat添加到
plugins
数组中的~/.zshrc
中; - 重新加载shell。
在键入cheat d<TAB>
时,自动补全没有发生。
问题
那么,在Linux上应该将zsh自动补全脚本放在哪里?
cheat
(命令行中的命令速查表)之后,我尝试使用提供的zsh脚本启用自动补全。然而,我似乎找不到脚本的正确位置。
cheat.zsh
;~/.oh-my-zsh/custom/plugins/cheat/_cheat.zsh
;plugins
数组中的~/.zshrc
中;在键入cheat d<TAB>
时,自动补全没有发生。
那么,在Linux上应该将zsh自动补全脚本放在哪里?
我将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
$FPATH
中没有~/.oh-my-zsh/custom/plugins/cheat/
,但我有另一个自定义插件。所以我猜我的source $HOME/.zshrc
不够用。 - Édouard Lopez让我来帮忙。
我曾尝试过类似的事情,这是我如何使其工作的。
以下解决方案已在debian发行版[ubuntu]上使用oh-my-zsh
验证过。
> 您的zsh未能提供正确的完成建议,例如[conda] > 当您键入#conda tab时,会得到以下结果
Find the completion script
one great location is https://github.com/clarketm/zsh-completions/tree/master/src
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
Make sure the completions folder is listed under $fpath
print -l $fpath
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)
source .zshrc
source ~/.zshrc
Execute compinit
this will build ~/.zcompdump
file for the functions
compinit
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.
Try source .zshrc
source ~/.zshrc
Try loggin out and login
Check the mapping in ~/.zcompdump
vi ~/.zcompdump
search for conda
[/conda]
you should see as below
'conda' '_conda'
希望有人会发现这篇文章有用,如果确实有用的话,我很乐意提供帮助。
~/.zcompdump
中。当我将其重命名为下划线时,它就正常工作了。请在其中提到这一点。另外,还有一点需要提到,如果有人没有提供zsh完成脚本,他们可以按照这些步骤进行操作:https://unix.stackexchange.com/a/535646/140177 - undefined