V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
hongfeiyu
V2EX  ›  程序员

zsh 的一个问题

  •  
  •   hongfeiyu · 2016-02-20 17:07:40 +08:00 · 1775 次点击
    这是一个创建于 2996 天前的主题,其中的信息可能已经有所发展或是发生改变。

    设置"%(!.%{%F{yellow}%}.)$USER@%m"里的(!.%{%F{yellow}%}.)
    是什么意思啊
    ???

    第 1 条附言  ·  2016-02-20 18:53:04 +08:00
    这么多次点击居然一个回复都没有
    难道我问的这个太偏了吗 2333333
    类似于 Bash 的 PS1 设置
    而 zsh 是这样的 _(:з」∠)_
    neoblackcap
        1
    neoblackcap  
       2016-02-20 23:06:54 +08:00
    感觉是一个字符串格式化的意思,应该是以某种格式,加字体颜色为黄色输出的意思。
    hongfeiyu
        2
    hongfeiyu  
    OP
       2016-02-20 23:49:43 +08:00
    @neoblackcap 我猜是如果是 root 用户的话就显示闪电的标志。。。
    wittyfox
        3
    wittyfox  
       2016-02-21 00:10:15 +08:00 via Android
    来自官方 Manual 的解释

    %(x.true-text.false-text)

    Specifies a ternary expression. The character following the x is arbitrary; the same character is used to separate the text for the ‘ true ’ result from that for the ‘ false ’ result. This separator may not appear in the true-text, except as part of a %-escape sequence. A ‘)’ may appear in the false-text as ‘%)’. true-text and false-text may both contain arbitrarily-nested escape sequences, including further ternary expressions.

    The left parenthesis may be preceded or followed by a positive integer n, which defaults to zero. A negative integer will be multiplied by -1, except as noted below for ‘ l ’. The test character x may be any of the following:

    !
    True if the shell is running with privileges.

    意思就是说,如果是 root 就用黄色。
    hongfeiyu
        4
    hongfeiyu  
    OP
       2016-02-21 00:21:22 +08:00
    @wittyfox O(∩_∩)O 谢谢,可以结贴了
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2514 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 14:45 · PVG 22:45 · LAX 07:45 · JFK 10:45
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.