在鱼壳中将命令拆分为多行

Lyn*_*ell 6 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
Run Code Online (Sandbox Code Playgroud)

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

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

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

小智 6

我在 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
Run Code Online (Sandbox Code Playgroud)

其中 ~/bin 在 PATH 上设置,而 ~/.config/fish/functions 未设置,则输出: ~/bin

我将上面的内容附加到我的鱼配置中,然后像这样运行它:〜/.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