我刚刚发现了 oh-my-zsh,但我无法让它工作。虽然主题可以完美地工作,但插件却不能。我选择了一些插件,例如。 macports,但我既没有完成端口命令,也没有适当的别名工作。这是我的
~/.zshrc
:
# Path to your oh-my-zsh configuration.
export ZSH=$HOME/.oh-my-zsh
# Set name of the theme to load.
# Look in ~/.oh-my-zsh/themes/
# Optionally, if you set this to "random", it'll load a random theme each
# time that oh-my-zsh is loaded.
export ZSH_THEME="steeef"
# Set to this to use case-sensitive completion
# export CASE_SENSITIVE="true"
# Comment this out to disable weekly auto-update checks
# export DISABLE_AUTO_UPDATE="true"
# Uncomment following line if you want to disable colors in ls
# export DISABLE_LS_COLORS="true"
# Uncomment following line if you want to disable autosetting terminal title.
# export DISABLE_AUTO_TITLE="true"
# Which plugins would you like to load? (plugins can be found in ~/.oh-my-zsh/plugins/*)
# Example format: plugins=(rails git textmate ruby lighthouse)
plugins=(git osx github macports textmate svn)
source $ZSH/oh-my-zsh.sh
# Customize to your needs...
export
PATH=/opt/local/bin:/opt/local/sbin:/usr/local/bin:/usr/local/sbin/:/opt/local/bin:/opt/local/sbin:/usr/local/bin:/usr/local/sbin/:/usr/bin:/bin:/usr/sbin:/sbin:/usr/X11/bin:/usr/local/cuda/bin:/usr/local/cuda/bin:/opt/local/bin:/opt/local/sbin
textmate 和 osx 插件似乎也不起作用。
zsh
抱怨未知命令并停止。 git 和 svn 有一些基本的补全功能,但我不确定它是通过插件完成的还是只是普通的 zsh 补全功能。我需要导出一些东西才能使用这些插件吗?或者如果没有,该怎么做才能解决这个问题?
确保在初始化 zsh 之前定义插件变量:
plugins=(git wd)
export ZSH=/home/<user>/.oh-my-zsh
source $ZSH/oh-my-zsh.sh
我被这个咬了。
发生的事情是您进行了手动安装并且手动安装的说明没有提到您需要自己设置
PATH
。
所以你最终得到了默认的路径。自动设置代码的源代码会复制您当前的路径并将其附加到
.zshrc
,如果您依赖于非标准 PATH
条目(例如,您在 Mac 上运行 Homebrew),这还不够。
所以修复很简单:
启动旧 shell 及其配置文件,然后将
$PATH
的值复制并粘贴到 ~/.zshrc
文件的顶部。
再见!
我刚才也遇到了同样的问题!我的 Archlinux 中安装了一个名为
grml-zsh-config
的软件包。我删除了这个包,oh-my-zsh
主题开始工作。
就我而言,在
~/.zshrc
我有重复的插件变量
plugins=(git)
.
.
.
plugins=(git autojump zsh-syntax-highlighting zsh-autosuggestions)
检查您是否属于这种情况,因为只有您的 git 插件才会被使用。
删除第一个插件变量,它应该可以工作。
我在使用
kubectl
插件时遇到了这个问题。
查看
~/.oh-my-zsh/plugins/kubectl/kubectl.plugin.zsh
的内容,我意识到我的内容与 github 存储库上的内容不同。使用 oh-my-zsh 存储库中的内容手动更新文件有所帮助,插件开始工作。我想我必须更新我的 oh-my-zsh 安装才能获取最新的插件内容,但这对我有用。
就我而言,我忘记将自定义插件名称添加到 .zshrc 文件中:
plugins=(customPluginName)
并重新加载.zshrc:
source ~/.zshrc
确保插件的文件夹位于 ~/.oh-my-zsh/custom/plugins 文件夹中。当你 git clone 插件时,我会建议你在这个目录中。
其次,确保在 ~/.zshrc 文件中使用单个空格而不是逗号分隔插件列表。
.
.
.
plugin = (git zsh-syntax-highlighting)
.
.
.
所以在上面的例子中,添加了两个插件:git 和 zsh-syntax-highlighting。
如果您的
.zshrc
顶部有这个
export ZSH="~/.oh-my-zsh"
尝试将其更改为:
export ZSH="$HOME/.oh-my-zsh"
尝试像这样手动获取插件:
source ~/.oh-my-zsh/custom/plugins/zsh-autosuggestions/zsh-autosuggestions.zsh
完整
.zshrc
示例:
# Which plugins would you like to load? (plugins can be found in ~/.oh-my-zsh/plugins/*)
# Example format: plugins=(rails git textmate ruby lighthouse)
plugins=(zsh-autosuggestions)
source ~/.oh-my-zsh/custom/plugins/zsh-autosuggestions/zsh-autosuggestions.zsh
手动安装自定义插件后,将它们移动到
$ZSH_CUSTOM/plugins/
位置解决了问题。
我也有同样的问题,当我写的时候:
plugins=(git node)
没成功
所以我再次安装了节点并将路径添加到
PATH
export PATH="/opt/homebrew/opt/node@18/bin:$PATH"
确保插件引用的 cli 工具/命令已安装。例如,如果您在未事先安装 kubectl 的情况下包含 kubectl 插件,则会失败