在 zsh 提示中不断更新时钟? [英] Constantly updated clock in zsh prompt?

查看:43
本文介绍了在 zsh 提示中不断更新时钟?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道我可以在 zsh 提示符下执行 date 命令.但是,它显示了时间;要查看当前时间,我必须点击 并获得当前时间的新提示.

有没有办法将 zsh 提示配置为每秒不断更新自身?

解决方案

这在标准 zsh 提示符(或 bash 或其他 shell)中会.... 令人不快.

我建议你最好使用 Gnu Screen.

屏幕可以有一个可以显示时间的状态行.这是一个示例 screenrc 向下滚动到Red Hat Magazine A guide to GNU Screen"以查看示例(我将在此处重现该示例),当屏幕运行时,它将在终端的右下角显示当前时间:

~/.screenrc

<预>硬状态总是最后一行硬状态字符串 '%{= kG}[ %{G}%H %{g}][%= %{=kw}%?%-Lw%?%{r}(%{W}%n*%f%t%?(%u)%?%{r})%{w}%?%+Lw%?%?%= %{g}][%{B}%Y-%m-%d %{W}%c %{g}]'# 默认屏幕屏幕 -t shell1 0屏幕 -t shell2 1

http://www.gnu.org/software/screen/

I know that I can exec a date command in my zsh prompt. However, it shows the old time; to see the current time, I have to hit <return> and get a new prompt with the current time.

Is there a way to configure the zsh prompt to constantly update itself every second?

解决方案

This would be .... unpleasant in a standard zsh prompt (or bash, or other shells).

I suggest you'd be better off using Gnu Screen.

Screen can have a status line which can show the time. Here's an example screenrc scroll down to "Red Hat Magazine A guide to GNU Screen" to see the sample (i'll reproduce that here) which will, when screen is run, show the current time in the lower right corner of the terminal:

~/.screenrc

hardstatus alwayslastline
hardstatus string '%{= kG}[ %{G}%H %{g}][%= %{=kw}%?%-Lw%?%{r}(%{W}%n*%f%t%?(%u)%?%{r})%{w}%?%+Lw%?%?%= %{g}][%{B}%Y-%m-%d %{W}%c %{g}]'

# Default screens
screen -t shell1        0
screen -t shell2        1

http://www.gnu.org/software/screen/

这篇关于在 zsh 提示中不断更新时钟?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆