【问题标题】:Remove timestamp from each line in zsh shell从 zsh shell 中的每一行中删除时间戳
【发布时间】:2018-08-16 01:54:02
【问题描述】:

我正在尝试使用 ZSH 从我的终端 (macOS) 中删除当前时间戳。我正在使用 oh-my-zsh,并且配置了“纯”主题。

时间戳出现在每行最右边的括号中,我不知道如何删除它。

示例: Timestamps are highlighted in red on the right.

更新:终端输出示例,我想从每一行中删除[17:29:47]等。

❯ cd ~                                                                         [17:29:47]

~
❯ ls                                                                           [17:29:49]
Applications Documents    Library      Music        Projects
Desktop      Downloads    Movies       Pictures     Public

~
❯ ls -l                                                                        [17:29:51]
total 0
drwx------@  4 gage  staff   128 Mar  4 22:27 Applications
drwx------@  4 gage  staff   128 Mar  7 15:39 Desktop

任何帮助将不胜感激,谢谢!

【问题讨论】:

标签: macos shell unix zsh oh-my-zsh


【解决方案1】:

通过在我的 .zshrc 文件末尾添加 unset RPROMPT 来取消设置 RPROMPT。

【讨论】:

  • 这对我来说似乎没有任何区别
【解决方案2】:

我能够删除主题中显示✔  123  10:46:22的整个右侧部分

打开zshrc

open ~/.zshrc

将以下行粘贴到文件末尾。这隐藏了正确的部分 POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=()

谢谢!

【讨论】:

  • 这对我有用。
【解决方案3】:

进入 /Users/your_username/.p10k.zsh 文件并搜索 RIGHT_PROMT_ELEMENTS 并在其下注释时间和状态。

typeset -g POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=(
    # status                  # exit code of the last command ( commented)
    command_execution_time  # duration of the last command
    background_jobs         # presence of background jobs
    direnv                  # direnv status (https://direnv.net/)
    asdf                    # asdf version manager (https://github.com/asdf-vm/asdf)
    virtualenv              # python virtual environment (https://docs.python.org/3/library/venv.html)
    anaconda 
  # time                    # current time
    # ip                    # ip address and ba

【讨论】:

    【解决方案4】:

    试试这些命令。他们应该希望摆脱时间戳。

    setopt noextendedhistory
    setopt nosharehistory
    

    您也可以将它们放入您的 .zshrc 文件中。

    【讨论】:

    • 这似乎没有什么不同。不幸的是,我仍然很难过。
    猜你喜欢
    • 1970-01-01
    • 2017-02-25
    • 1970-01-01
    • 2014-07-22
    • 1970-01-01
    • 1970-01-01
    • 2018-05-04
    • 2018-06-27
    • 1970-01-01
    相关资源
    最近更新 更多