LoginSignup
0
0

ターミナル上に時計を表示する

Posted at

やりたいこと

image.png

ターミナル上に時計を表示したいこと(date コマンドではなくリアルタイムで更新される時計がほしいこと)が稀にあります。

Rubyワンライナー

ruby -e 'loop { t = Time.now.strftime("%T"); print "\b" * t.size ; print t;  sleep 0.1}'

"\b" で1文字削除できるので、適当な間隔で削除→時刻を再表示すればよろしい。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0