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

标签 zsh fish

我有这个函数,在 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 "$1")
}

最佳答案

首先,由于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

关于zsh - 如何将此 zsh 函数转换为 Fish shell?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41691787/

相关文章:

zsh - 在带有promptinit的zsh自定义提示符中使用vcs_info

fish - 从 fish shell 中的路径中提取文件夹名称

bash - for循环中的Zsh字符串数组

Macos Catalina 更新后出现错误 : unable to run colorls

ruby-on-rails - RVM 没有在 `fish` 中设置我的 PATH,但应该是

fish - 如何测试一个字符串是否包含 fish shell 中的另一个字符串?

matlab - 在 matlab 中打开 GUIDE 时出错

stdin - 如何从带有 fish shell 的stdin中读取

zsh - : 39: source: not found While installing oh-my-zsh

awk - zsh - 有效地在数组中缓存带引号的字符串