Macros

Macros can be used to modify raw SNClient values.

Macro Operators

Values can be altered by adding a colon separated suffix.

Supported operators are:

SuffixExampleDescription
:lcWord -> wordmake value lowercase
:uctest -> TESTmake value uppercase
:h1000 -> 1kmake a number more human readably
:duration125 -> 2m 5sconvert amount of seconds into human readable duration
:age1700834034 -> 374subtract value from current unix timestamp to get the age in seconds
:date1700834034 -> 2023-11-24 14:53:54 CETconvert unix timestamp into human readable date (local timezone)
:utc1700834034 -> 2023-11-24 13:53:54 UTCconvert unix timestamp into human readable date (utc timezone)
:fmt=<fmt>123.45 -> 123.5apply format, ex.: $(total | fmt=%.1f) (using GOs fmt.Sprintf)
:s/regexp/replace/C:\ % -> Capply regexp replacement, ex.: $(name | ’s/\W//’ ) (using GOs regexp.Compile)
:asciiC:\ % -> Cremove any none-ascii characters
:trim" test " -> “test”remove leading and trailing whitespace
:chomp" test " -> " test"remove trailing whitespace only

Operators can be put together (spaces are optional):

$(datemacro:date : uc)

This converts $(datemacro) to a human readable date and makes everything uppercase.

You can also use the pipe symbol to use multiple operators in a row, for example:

$(macroname | date | uc)

Use the generic fmt operator to apply any format on numbers, for example:

$(used_pct | fmt=%d)