V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
snooprat
V2EX  ›  macOS

Arm 版 brew 无法按 tab 补全命令

  •  
  •   snooprat · 2020-12-26 11:29:48 +08:00 · 3480 次点击
    这是一个创建于 1458 天前的主题,其中的信息可能已经有所发展或是发生改变。

    M1 装上了 Arm 版 brew,一切都很好,唯一有个问题是之前可以按 tab 补全命令的,现在不行了,qit adb 都是正常的,不知道谁有遇到的吗?要如何解决?

    第 1 条附言  ·  2020-12-26 16:40:44 +08:00

    解决了 To make Homebrew’s completions available in zsh, you must get the Homebrew-managed zsh site-functions on your FPATH before initialising zsh’s completion facility. Add the following to your ~/.zshrc file:

    if type brew &>/dev/null; then
      FPATH=$(brew --prefix)/share/zsh/site-functions:$FPATH
    
      autoload -Uz compinit
      compinit
    fi
    

    This must be done before compinit is called. Note that if you are using Oh My Zsh, it will call compinit for you, so this must be done before you call oh-my-zsh.sh.

    7 条回复    2020-12-26 16:37:39 +08:00
    wengych
        1
    wengych  
       2020-12-26 11:57:32 +08:00
    ??

    brew install zsh-completion

    ??
    jfdnet
        2
    jfdnet  
       2020-12-26 12:08:43 +08:00
    补全功能并不是 brew 带来的
    snooprat
        3
    snooprat  
    OP
       2020-12-26 13:14:37 +08:00 via iPhone
    @jfdnet 之前我在 zsh 加 brew 插件是可以的,现在加了也没用
    snooprat
        4
    snooprat  
    OP
       2020-12-26 13:14:53 +08:00 via iPhone
    @wengych 我试试这个
    wengych
        5
    wengych  
       2020-12-26 13:26:22 +08:00 via iPhone
    @snooprat 安装后记得设置 zshrc
    sinxccc
        6
    sinxccc  
       2020-12-26 14:24:19 +08:00
    在你的 .zshrc 里加上

    setopt completealiases
    snooprat
        7
    snooprat  
    OP
       2020-12-26 16:37:39 +08:00
    最后还是在官方文档找到了解决方案,印象里之前没有配置过就能用,现在需要配置一下才生效。

    To make Homebrew’s completions available in zsh, you must get the Homebrew-managed zsh site-functions on your FPATH before initialising zsh’s completion facility. Add the following to your ~/.zshrc file:

    if type brew &>/dev/null; then
    FPATH=$(brew --prefix)/share/zsh/site-functions:$FPATH

    autoload -Uz compinit
    compinit
    fi

    This must be done before compinit is called. Note that if you are using Oh My Zsh, it will call compinit for you, so this must be done before you call oh-my-zsh.sh.
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   1012 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 22ms · UTC 20:24 · PVG 04:24 · LAX 12:24 · JFK 15:24
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.