我有这个功能在zsh中工作得很好,但是我想把它转换成鱼壳,我不能让它工作。
function ogf () {
echo "Cloning, your editor will open when clone has completed..."
source <(TARGET_DIRECTORY=~/students EDITOR=$EDITOR clone_git_file -ts "$1")
}
答案 0 :(得分:2)
首先,由于fish的语法与zsh不同,您还必须将clone_git_file
的输出更改为source
。
例如,如果clone_git_file
类似于:
#!/bin/bash
echo "FOO=$TARGET_DIRECTORY"
echo "BAR=$2"
您必须将其更改为fish语法。
#!/bin/bash
echo "set -gx FOO $TARGET_DIRECTORY"
echo "set -gx BAR $2"
现在这里是ogf()
函数,以及fish的示例代码:
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