在fish-shell中将命令拆分为多行
我试图将我的附加路径列表拆分为鱼配置中的多行:
# 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我在 OSX 10.8.5 上使用 Fish 2.0.0,您的示例按我的预期工作(对于我的计算机上存在的路径)。
运行此代码
,其中 ~/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
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