从 zsh shell 中的每一行中删除时间戳

Remove timestamp from each line in zsh shell

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

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

示例: 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

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

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

setopt noextendedhistory
setopt nosharehistory

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

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

转到 /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

我能够删除主题中显示 ✔  123  10:46:22

的整个右侧部分

打开 zshrc

open ~/.zshrc

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

谢谢!