zsh完成不区分大小写的_multi_parts函数

Zsh completion case insensitive _multi_parts function

我有一个脚本,它接受类似参数的文件(多部分参数),我正在获取可能的值并将它们放入一个名为 raw 的数组中,然后使用

_multi_parts / "(${raw[@]})" 

自动完成。问题是这是区分大小写的,我怎样才能让它输入 mycommand get fo 并按 Tab 如果 Foo 是其中之一,它将自动完成为 mycommand get Foo/原始的东西。

完整补全在此供参考:

_mycommand() {
  local curcontext="$curcontext" state line

  _arguments "1: :->command" "*: :->label"

  case $state in
  command)
    _arguments "1: :(add get ls rm)"
  ;;
  *) 
    case $words[2] in
      add|get|ls|rm)
        if [ -f ~/.pts ]; then
          IFS=$'\n' read -d '' -r raw <<< "$(mycommand ls)"
          _multi_parts / "(${raw[@]})"
        fi
      ;;
      *)
        _files
      ;;
    esac
  esac
}

_mycommand "$@"

mycommand ls 输出如下名称的路径:

Foo/Bar/x
Foo/Bar/y
Derp/z
Placeholder/z

好的,我明白了:

换行

IFS=$'\n' read -d '' -r raw <<< "$(mycommand ls)"
_multi_parts / "(${raw[@]})"

IFS=$'\n' raw=($(mycommand ls))
_multi_parts -M "m:{[:lower:][:upper:]}={[:upper:][:lower:]}" / raw