zsh报错:_complete:96: bad math expression: operand expected at end of string

现象

为了进入到Application文件夹,输入App后按tab键,想使用zsh的快捷提示功能,结果报错。如图所示:
在这里插入图片描述

排查
1.重新打开iTerm窗口

刚打开命令行时,有一堆提示没有细看,现在重新打开命令行查看提示。

[oh-my-zsh] For safety, we will not load completions from these directories until
[oh-my-zsh] you fix their permissions and ownership and restart zsh.
[oh-my-zsh] See the above list for directories with group or other writability.

[oh-my-zsh] To fix your permissions you can do so by disabling
[oh-my-zsh] the write permission of "group" and "others" and making sure that the
[oh-my-zsh] owner of these directories is either root or your current user.
[oh-my-zsh] The following command may help:
[oh-my-zsh]     compaudit | xargs chmod g-w,o-w

[oh-my-zsh] If the above didn't help or you want to skip the verification of
[oh-my-zsh] insecure directories you can set the variable ZSH_DISABLE_COMPFIX to
[oh-my-zsh] "true" before oh-my-zsh is sourced in your zshrc file.


┌────────────────────────────────────────────────────────┐
│                npm update check failed                 │
│          Try running with sudo or get access           │
│          to the local update config store via          │
│ sudo chown -R $USER:$(id -gn $USER) /Users/jsk/.config │
└────────────────────────────────────────────────────────┘
zsh compinit: insecure directories, run compaudit for list.
Ignore insecure directories and continue [y] or abort compinit [n]?

按提示执行:

sudo chown -R $USER:$(id -gn $USER) /Users/jsk/.config

注意哈,每个人提示的可能不一样。

2.继续重新打开iTerm窗口

窗口提示信息如下:

[oh-my-zsh] Insecure completion-dependent directories detected:
drwxrwxr-x  3 jsk  admin   96  4 22  2020 /usr/local/share/zsh
drwxrwxr-x  6 jsk  admin  192  4 22  2020 /usr/local/share/zsh/site-functions

[oh-my-zsh] For safety, we will not load completions from these directories until
[oh-my-zsh] you fix their permissions and ownership and restart zsh.
[oh-my-zsh] See the above list for directories with group or other writability.

[oh-my-zsh] To fix your permissions you can do so by disabling
[oh-my-zsh] the write permission of "group" and "others" and making sure that the
[oh-my-zsh] owner of these directories is either root or your current user.
   大致意思是:需要确保上面目录的所有者要么是root用户,要么是您当前的用户。
[oh-my-zsh] The following command may help:
[oh-my-zsh]     compaudit | xargs chmod g-w,o-w

[oh-my-zsh] If the above didn't help or you want to skip the verification of
[oh-my-zsh] insecure directories you can set the variable ZSH_DISABLE_COMPFIX to
[oh-my-zsh] "true" before oh-my-zsh is sourced in your zshrc file.

zsh compinit: insecure directories, run compaudit for list.
Ignore insecure directories and continue [y] or abort compinit [n]?
compinit: initialization aborted
complete:13: command not found: compdef

从第一行提示可以看出:检测到不安全的完整依赖目录,/usr/local/share/zsh/usr/local/share/zsh/site-functions。这些目录的所有者要么是root用户,要么是当前的用户。
那就给当前用户重新授权下:

chmod 755 /usr/local/share/zsh
chmod 755 /usr/local/share/zsh/site-functions

chmod是“change mode”的意思,用于改变Linux文件代表不同用户对此文件权限的一串flag。
chmod 755 的含义是所有用户都拥有此文件的读权限和执行权限,只有Owner拥有此文件的写权限。因此我们也可以说chmod 755 的作用等同于 chmod u=rwx,go=rx (其中u代表user,g代表group, o代表others)

3.继续重新打开iTerm窗口

在这里插入图片描述

command+N重新打开一个窗口,可以看到没有错误信息提示了,按Tab键也有目录提示了。

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值