3 ms·
Fun fact: units can do math too! Try it: units -t '12 * 45 * 11' This can be combined with unit conversion of course: units -t '(8 lbf) / (9.8 m/s^2)
by aftbit 4y ago
Fun fact: units can do math too! Try it:
units -t '12 * 45 * 11'
This can be combined with unit conversion of course:
units -t '(8 lbf) / (9.8 m/s^2)' slug
Be careful using it for temperature conversion. You need to use tempC and tempF functions, not degC and degF units, because of the linear offset from absolute zero.
Correct way (absolute temperature):
units -t 'tempF(71)' tempC
Incorrect way (temperature difference):
units -t '71 degF' degC
I use units a ton, so I have the following in my .zshrc:
# in-terminal calculator: e.g. `calc 60 * 60 * 4`
_calc () {
units -t "$*"
}
alias calc='noglob _calc'
# units convenience, use ( and * without quoting
alias u='noglob units -t'