如何将此 zsh 函数转换为 fish shell?

How do I convert this zsh function to fish shell?

我有这个功能,它在 zsh 中工作得很好,但我想将它转换为 fish shell,但我无法让它工作。

function ogf () {
  echo "Cloning, your editor will open when clone has completed..."
  source <(TARGET_DIRECTORY=~/students EDITOR=$EDITOR clone_git_file -ts "")
}

首先,由于fish的语法与zsh不同,你还得把clone_git_file的输出改成source才行。

例如,如果 clone_git_file 类似于:

#!/bin/bash
echo "FOO=$TARGET_DIRECTORY"
echo "BAR="

您必须将其更改为 fish 语法。

#!/bin/bash
echo "set -gx FOO $TARGET_DIRECTORY"
echo "set -gx BAR "

下面是 ogf() 函数和鱼的示例代码:

function ogf
  echo "Cloning, your editor will open when clone has completed..."
  source (env TARGET_DIRECTORY=~/students EDITOR=$EDITOR clone_git_file -ts $argv[1] | psub)
end

ogf MY_ARGUMENT
echo "FOO is $FOO"
echo "BAR is $BAR"

运行这段代码用fish,输出是:

FOO is /home/MY_USER/students
BAR is MY_ARGUMENT