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

发布于 2024-11-01 11:18:24 字数 526 浏览 3 评论 0原文

我试图将我的附加路径列表拆分为鱼配置中的多行:

# 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

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

这可能吗?我似乎找不到任何有关执行此操作的信息。

或者,有没有办法使用列表/数组文字来执行此操作?

I'm trying to split my list of additional paths on to multiple lines in my fish config:

# 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

However, this doesn't seem to work unless all the items are on one line.

Is this possible? I can't seem to find any information on doing this.

Alternatively, is there a way to use a list/array literals to do this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

感性不性感 2024-11-08 11:18:24

我在 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 未设置,输出:
~/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

I'm using fish 2.0.0 on OSX 10.8.5 and your example works as I would expect (for paths that exist on my machine).

Running this code

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

where ~/bin is set on PATH and ~/.config/fish/functions is not, outputs:
~/bin

I appended the above to my fish config and then ran it like this:
. ~/.config/fish/config.fish

Here is a little more info on multiline editing: http://fishshell.com/docs/2.0/index.html#multiline

There are no array literals in fish. You can read more about fish arrays in the docs. http://fishshell.com/docs/2.0/index.html#variables-arrays

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文