本文介绍了如何将此 zsh 函数转换为鱼壳?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有这个在 zsh 中运行良好的函数,但我想将其转换为鱼壳,但无法正常工作.
I have this function which works great in zsh, but I want to convert it to fish shell and I can't get it working.
function ogf () {
echo "Cloning, your editor will open when clone has completed..."
source <(TARGET_DIRECTORY=~/students EDITOR=$EDITOR clone_git_file -ts "$1")
}
推荐答案
首先,由于fish的语法和zsh不同,所以你还要把clone_git_file
的输出改成source
它.
First of all, since fish's syntax differs from zsh, you also have to change the output of clone_git_file
to source
it.
例如,如果 clone_git_file
类似于:
For example, if clone_git_file
is something like:
#!/bin/bash
echo "FOO=$TARGET_DIRECTORY"
echo "BAR=$2"
你必须把它改成鱼语法.
you have to change it to fish syntax.
#!/bin/bash
echo "set -gx FOO $TARGET_DIRECTORY"
echo "set -gx BAR $2"
现在是 ogf()
函数和鱼的示例代码:
Now here's the ogf()
function, and sample code for 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运行这段代码,输出为:
Running this code with fish, the output is:
FOO is /home/MY_USER/students
BAR is MY_ARGUMENT
这篇关于如何将此 zsh 函数转换为鱼壳?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!