简体   繁体   English

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

[英]Remove timestamp from each line in zsh shell

I'm trying to remove the current timestamp from my Terminal (macOS) using ZSH.我正在尝试使用 ZSH 从我的终端 (macOS) 中删除当前时间戳。 I am using oh-my-zsh & I have the theme "pure" configured.我正在使用 oh-my-zsh 并且我配置了主题“纯”。

A timestamp appears on the very right of each line in brackets and I cannot figure out how to remove it.时间戳出现在括号中每行的最右侧,我不知道如何删除它。

Example: Timestamps are highlighted in red on the right.示例:时间戳在右侧以红色突出显示。

Update: Terminal output example, I want to remove [17:29:47] etc from each line.更新:终端输出示例,我想从每一行中删除[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

Any help would be greatly appreciated, thank you!任何帮助将不胜感激,谢谢!

通过在我的unset RPROMPT文件末尾添加unset RPROMPTunset RPROMPT来修复。

go to /Users/your_username/ .p10k.zsh file and search for RIGHT_PROMT_ELEMENTS and comment the time and status under it.转到/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

Try these commands.试试这些命令。 They should get rid of the timestamps hopefully.他们应该希望摆脱时间戳。

setopt noextendedhistory
setopt nosharehistory

You can put them in your .zshrc file too.您也可以将它们放在 .zshrc 文件中。

I was able to remove the whole right section in the theme which showed ✔  123  10:46:22我能够删除主题中显示的整个右侧部分✔  123  10:46:22

Open zshrc打开 zshrc

open ~/.zshrc

Paste the following line at the end of the file.将以下行粘贴到文件末尾。 This hides the right section POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=()这隐藏了右侧部分POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=()

Thanks!谢谢!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM