https://github.com/jwodder/elapsed
Show runtime while a command runs
https://github.com/jwodder/elapsed
available-on-crates-io runtime rust time
Last synced: 3 months ago
JSON representation
Show runtime while a command runs
- Host: GitHub
- URL: https://github.com/jwodder/elapsed
- Owner: jwodder
- License: mit
- Created: 2025-10-31T22:45:01.000Z (4 months ago)
- Default Branch: main
- Last Pushed: 2025-12-01T14:48:01.000Z (3 months ago)
- Last Synced: 2025-12-04T03:42:19.804Z (3 months ago)
- Topics: available-on-crates-io, runtime, rust, time
- Language: Rust
- Homepage:
- Size: 146 KB
- Stars: 8
- Watchers: 0
- Forks: 0
- Open Issues: 7
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://www.repostatus.org/#active)
[](https://github.com/jwodder/elapsed/actions/workflows/test.yml)
[](https://codecov.io/gh/jwodder/elapsed)
[](https://www.rust-lang.org)
[](https://opensource.org/licenses/MIT)
[GitHub](https://github.com/jwodder/elapsed) | [crates.io](https://crates.io/crates/elapsed-cmd) | [Issues](https://github.com/jwodder/elapsed/issues) | [Changelog](https://github.com/jwodder/elapsed/blob/main/CHANGELOG.md)
`elapsed` is a simple utility program that runs a given command and, while
it's running, displays & updates the elapsed time below the command's output.

Installation
============
In order to install `elapsed`, you first need to have [Rust and Cargo
installed](https://www.rust-lang.org/tools/install). You can then build the
latest release of `elapsed` and install it in `~/.cargo/bin` by running:
cargo install elapsed-cmd
(Note that the name of the package on crates.io is "elapsed-cmd"; just
"elapsed" was already taken.)
Usage
=====
elapsed [] [ ...]
`elapsed` takes the name of a command to run plus any arguments to that
command. While the command is running, the elapsed time is displayed in a
status line written to standard error below the command's output and updated
once per second. If `elapsed`'s standard error is redirected, the status line
will not be shown.
When the command exits, the status line is erased (unless the `-t`/`--total`
option was given), and `elapsed` exits with the same return code as the
command; if the command was killed by a signal, a message is printed to stderr
(after any `--total` status line), and `elapsed` exits with return code 1
instead.
Options
-------
- `-f `, `--format ` — Use the given format template for
rendering the time in the status line. Templates may contain the following
specifiers & escape sequences:
- `%H` - number of hours as a two-digit number
- `%M` - number of minutes within the hour as a two-digit number
- `%S` - number of seconds within the minute as a two-digit number
- `%s` - total number of seconds
- `%f` - subseconds; defaults to six digits (microseconds) but can also
take a decimal precision (e.g., `%9f` to show nanoseconds)
- `%n` or `\n` - newline
- `%t` or `\t` - tab
- `%e` or `\e` - escape character
- `%%` - percent sign
- `\\` - backslash
The default template is "`Elapsed: %H:%M:%S`."
- `-r `, `--refresh ` — Update the status line after every ``
milliseconds [default: 1000 (once per second)]
- `-t`, `--total` — Leave the total elapsed time behind after the command finishes
- `-T`, `--tty` — Run the command via a pseudo-terminal. This is useful if the
command's behavior (e.g., whether it buffers output or emits ANSI color
sequences) changes depending on whether it's directly connected to a
terminal.
This option is only available on Unix.
- `-S`, `--split-stderr` — When the `--tty` option is given, by default, the
command's stdout and stderr will be merged together into a single stream that
is ultimately printed on `elapsed`'s stdout. If `--split-stderr` is given,
the command's stderr will not be connected to the pseudo-terminal and will
instead be sent to `elapsed`'s stderr so that stdout & stderr can then be
redirected separately.
This option is only available on Unix and only has an effect when `--tty` is
also given.
- `-h`, `--help` — Show command-line usage
- `-V`, `--version` — Show current program version
Restrictions
============
`elapsed` is intended for use with commands with line-oriented output. If it
is used with a command that outputs a large amount of data between newlines or
that manipulates the cursor, you'll have a bad experience.