#clock #terminal #cli

app tock

Digital clock for the terminal

7 releases (2 stable)

1.0.1 Oct 13, 2023
0.1.4 Jun 21, 2019

#75 in Command line utilities

Download history 4/week @ 2023-08-09 9/week @ 2023-08-16 9/week @ 2023-08-23 14/week @ 2023-08-30 12/week @ 2023-09-06 9/week @ 2023-09-13 15/week @ 2023-09-20 6/week @ 2023-09-27 5/week @ 2023-10-04 69/week @ 2023-10-11 17/week @ 2023-10-18 16/week @ 2023-10-25 21/week @ 2023-11-01 15/week @ 2023-11-08 21/week @ 2023-11-15 25/week @ 2023-11-22

87 downloads per month

MIT license

633 lines


A digital clock for the terminal, inspired by tty-clock. Unfortunately only works on UNIX systems due to the use of the termios and sigaction related function calls.

Note: emulating all features of tty-clock is not a goal of this project.


  • Efficient bitmap and diff-based drawing
  • Timezone support via the TZ environment variable and tzselect utility
  • Military time and second display toggling
  • Color customization using ANSI, 8-bit, or 24-bit color values
  • Arbitrary date formatting
  • Positioned or centered clock
  • Adjustable display size
  • Synchronization with system clock seconds
  • Minimal syscalls (about one read, write, nanosleep per second)


Screenshot of clock

asciicast of multiple clocks


Currently requires a Rust installation with version >= 1.70.0 (due to the IsTerminal trait, and is only available from either:

  1. crates.io using cargo-install
cargo install tock
  1. Building from source
git clone https://github.com/nwtnni/tock.git
cargo build --release


A digital clock for the terminal.

Usage: tock [OPTIONS]

  -x, --x <X>            Horizontal 0-indexed position of top-left corner [default: 0]
  -y, --y <Y>            Vertical 0-indexed position of top-left corner [default: 0]
  -W, --width <WIDTH>    Font width in characters per tile [default: 2]
  -H, --height <HEIGHT>  Font height in characters per tile [default: 1]
  -s, --second           Display seconds
  -m, --military         Display military (24-hour) time
  -c, --center           Center the clock in the terminal. Overrides manual positioning
  -C, --color <COLOR>    Change the color of the time [default: 2]
  -f, --format <FORMAT>  Change the date format [default: "%F | %Z"]
  -h, --help             Print help (see more with '--help')

Currently compiles with the interactive feature flag set by default, which polls stdin for user input once per second. Available commands with this feature flag set are:

  • q or Q or <ESC>: Exit.
  • s: Toggle second display.
  • m: Toggle military (24H) time.
  • 0..=7: Change to corresponding ANSI color.



~60K SLoC