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

请教 v 友们 brew search/info 能否支持模糊查找? 谢谢

  •  
  •   notgoda · 2022-01-13 20:50:39 +08:00 · 1408 次点击
    这是一个创建于 826 天前的主题,其中的信息可能已经有所发展或是发生改变。

    我试了 软件名* 显示没有匹配 , 是我姿势不对?

    另外请教想安装 telent, 下面这个提示,是需要先安装 xcode?
    % brew info telnet telnet: stable 63 (bottled) User interface to the TELNET protocol https://opensource.apple.com/ Conflicts with: inetutils (because both install 'telnet' binaries) Not installed From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/telnet.rb License: BSD-4-Clause-UC and APSL-1.0 ==> Requirements Build: Xcode ✘ Required: macOS ✔

    10 条回复    2022-01-18 22:01:12 +08:00
    also24
        1
    also24  
       2022-01-13 20:54:51 +08:00
    根据官方文档,是支持正则的

    https://docs.brew.sh/Manpage#search--s-options-textregex-
    notgoda
        2
    notgoda  
    OP
       2022-01-13 22:26:17 +08:00 via iPhone
    @also24 对呀,但是我 搜索关键词 比如 brew search visual* 显示不匹配。
    also24
        3
    also24  
       2022-01-13 22:38:58 +08:00
    @notgoda #2
    首先,我感觉你的需求可能是直接 brew search visual 就行的



    然后,直觉上你是不是把通配符和正则搞混了?实际想要查的是 brew search /^visual.*/ 吧?
    不过,似乎 zsh 对 * 的解析存在一些问题,建议在 bash 下执行这段

    also24
        4
    also24  
       2022-01-13 22:39:48 +08:00
    另,没有去仔细看 brew 是怎么实现的,似乎对 - 符号有特殊处理,导致搜索结果有点奇怪
    also24
        5
    also24  
       2022-01-13 22:41:38 +08:00   ❤️ 1
    关于 * 的问题的补充,可以通过 setopt no_nomatch 关闭 zsh 对通配符的优先解析,就可以正常执行了
    notgoda
        6
    notgoda  
    OP
       2022-01-13 23:45:41 +08:00 via iPhone
    @also24 谢谢大佬。 请问 brew info 怎么看软件有没有原生支持 ARM ? 现在好像 brew 包里面没有标识出来。
    also24
        7
    also24  
       2022-01-14 00:26:27 +08:00
    @notgoda #6
    可以在网页上查询:
    https://formulae.brew.sh/formula/htop

    也可以使用类似 brew info htop -j | grep arm 的方式查看。

    另外也可以使用 brew unbottled htop 来曲线救国。
    有已打包好的 bottle 的话会显示为 htop: already bottled
    没有的话,会类似于:luajit: ready to bottle


    对于 cask 来说,是否支持 ARM 不归 homebrew 管。
    notgoda
        8
    notgoda  
    OP
       2022-01-14 16:02:37 +08:00 via iPhone
    @also24 谢谢大佬。 如果 l 显示有已打包好的 bottle 的就肯定是支持 arm /Intel 系统架构的吗? 另外比如像下面这个软件如何判断他是否支持 Arm?https://github.com/paradiseduo/tcping
    wengych
        9
    wengych  
       2022-01-14 17:15:12 +08:00
    @also24 这类问题在 zsh 下很多都可以通过加双引号来解决,比如

    ```
    brew search "/^visual.*/"
    ```
    notgoda
        10
    notgoda  
    OP
       2022-01-18 22:01:12 +08:00
    @also24
    @wengych 两位 v 友 请教如何在 zsh 下把 mac 自带的 BSD 命令替换成 gnu 命令? 这是我的步骤 一直不成功, 两位能帮忙看下哪里错了吗? 万分感谢

    我是 zsh 下执行以下脚本 , 用 bash xxx.sh
    #!/usr/bin/env bash
    print_usage() {
    cat <<- EOF
    use gnu tools without prefix "g" on mac, for example, "cat" rather than "gcat"
    EOF
    exit 0
    }
    if [[ $1 =~ -h|--help ]]; then
    print_usage
    fi
    gnu_bin_path=/usr/local/gnubin
    if [[ ! -d $gnu_bin_path ]]; then
    mkdir $gnu_bin_path
    fi
    for i in /usr/local/opt/*/libexec/gnubin/*
    do
    ln -s $i $gnu_bin_path
    done
    echo "finish"


    然后增加 PATH=/usr/local/gnubin/:$PATH
    export PATH

    到.zprofile


    添加这段脚本在~/.zprofile 中:

    join_str() {
    sep="$1"
    shift
    first_word="$1"
    shift
    printf "%s" "$first_word" "${@/#/$sep}"
    }

    manpath=(/usr/local/opt/**/libexec/gnuman/)
    joined_manpath=`join_str : ${manpath[@]}`
    MANPATH=$joined_manpath:$MANPATH
    export MANPATH
    unset manpath
    unset joined_manpath
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2600 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 15:58 · PVG 23:58 · LAX 08:58 · JFK 11:58
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.