【问题标题】:Removing trailing new line after printing on Mac OS X zsh在 Mac OS X zsh 上打印后删除尾随新行
【发布时间】:2013-08-15 08:15:38
【问题描述】:

我正在尝试打印标准输入,但在使用 cat、grep、awk 等(Mac OS X zsh)后出现的尾随新行不显示 不幸的是, echo -n 不起作用,它会打印一些奇怪的字符。

你对这件事有什么想法吗? 谢谢。

【问题讨论】:

    标签: macos shell line trailing


    【解决方案1】:

    来自 man zshoptions:

    PROMPT_SP <D>
                  Attempt  to  preserve  a  partial  line (i.e. a line that did not end
                  with a newline) that would otherwise be covered up by the command prompt
                  due to the PROMPT_CR option.  This works by outputting some
                  cursor-control characters,
                  including a series of spaces, that should make the terminal wrap to the
                  next line when a partial line is present (note that this is only 
                  successful if your terminal has automatic margins, which is typical).
    
                  When a partial line is preserved, by default you will see an inverse+bold
                  character at the end of the partial line:  a "%" for a normal user or a
                  "#" for root.  If set, the shell parameter PROMPT_EOL_MARK can be used
                  to customize how the end of partial lines are shown.
    
                  NOTE: if the PROMPT_CR option is not set, enabling this option will have
                  no effect.  This option is on by default.
    

    将此添加到您的 .zshrc 以更改行为。请注意,这是一项设计功能,而不是错误。

    export PROMPT_EOL_MARK=''

    【讨论】:

      猜你喜欢
      • 2016-11-10
      • 1970-01-01
      • 1970-01-01
      • 2015-02-14
      • 2014-03-04
      • 2021-06-06
      • 1970-01-01
      • 2010-11-28
      • 1970-01-01
      相关资源
      最近更新 更多