Skip to main content

Module util

Module util 

Source

Functions§

format_age
Format a duration into a human-readable age string.
format_bytes
Format a byte count into a human-readable string (e.g. “1.5 GB”).
pad_left
Pad a string to a given visible width (left-padded).
pad_right
Pad a string to a given visible width (right-padded).
parse_age
Parse an age string like “30d”, “3m”, “1y” into a chrono TimeDelta.
shorten_path
Shorten a path by replacing the home directory with ~.
truncate
Truncate a string to a max visible width, appending “…” if truncated.
visible_len
Visible length of a string (strips ANSI escape sequences).