gpt4 book ai didi

fish - 在 fish shell 中将命令拆分为多行

转载 作者:行者123 更新时间:2023-12-01 04:11:45 26 4
gpt4 key购买 nike

我正在尝试将我的附加路径列表拆分为 fish 配置中的多行:

# Path additions
for i in \
~/Library/Haskell/ghc-7.0.2/lib/gtk2hs-buildtools-0.12.0/bin \
~/Library/Haskell/bin \
/Applications/MacVim.app/Contents/MacOS \
/opt/local/bin \
/usr/local/bin \
/usr/local/git/bin \
/Users/lyndon/.gem/ruby/1.8/bin
if not contains $i $PATH
set -x PATH $i $PATH
end
end

但是,除非所有项目都在一行上,否则这似乎不起作用。

这可能吗?我似乎找不到任何关于这样做的信息。

或者,有没有办法使用列表/数组文字来做到这一点?

最佳答案

我在 OSX 10.8.5 上使用 fish 2.0.0,您的示例按我的预期工作(对于我机器上存在的路径)。

运行此代码

# Path additions
for i in \
~/bin \
~/.config/fish/functions
if not contains $i $PATH
echo $i
end
end

其中 ~/bin 设置在 PATH 上,而 ~/.config/fish/functions 不是,输出:
〜/斌

我将上述内容附加到我的 fish 配置中,然后像这样运行它:
. ~/.config/fish/config.fish

以下是有关多行编辑的更多信息: http://fishshell.com/docs/2.0/index.html#multiline

fish 中没有数组文字。您可以在文档中阅读有关 fish 阵列的更多信息。 http://fishshell.com/docs/2.0/index.html#variables-arrays

关于fish - 在 fish shell 中将命令拆分为多行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5664713/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com