• 请不要在回答技术问题时复制粘贴 AI 生成的内容
hongfeiyu
V2EX  ›  程序员

zsh 的一个问题

  •  
  •   hongfeiyu · Feb 20, 2016 · 2321 views
    This topic created in 3733 days ago, the information mentioned may be changed or developed.

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

    Supplement 1  ·  Feb 20, 2016
    这么多次点击居然一个回复都没有
    难道我问的这个太偏了吗 2333333
    类似于 Bash 的 PS1 设置
    而 zsh 是这样的 _(:з」∠)_
    neoblackcap
        1
    neoblackcap  
       Feb 20, 2016
    感觉是一个字符串格式化的意思,应该是以某种格式,加字体颜色为黄色输出的意思。
    hongfeiyu
        2
    hongfeiyu  
    OP
       Feb 20, 2016
    @neoblackcap 我猜是如果是 root 用户的话就显示闪电的标志。。。
    wittyfox
        3
    wittyfox  
       Feb 21, 2016 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
       Feb 21, 2016
    @wittyfox O(∩_∩)O 谢谢,可以结贴了
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   3777 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 31ms · UTC 04:56 · PVG 12:56 · LAX 21:56 · JFK 00:56
    ♥ Do have faith in what you're doing.