logoalt Hacker News

MyOutfitIsVague06/24/20251 replyview on HN

nushell does that out of the box:

    > history | get 82076
    ╭─────────────────┬──────────────────╮
    │ start_timestamp │ 2025-06-24 16:46 │
    │ command         │ mpc play         │
    │ cwd             │ /home/work       │
    │ duration        │ 1ms              │
    │ exit_status     │ 0                │
    ╰─────────────────┴──────────────────╯
It's really nice, because it doesn't just tell you time between command executions (or rather time between commands finishing), but the actual runtime duration of the command.

Replies

__MatrixMan__06/25/2025

I love nushell. You can also query by friendlier things than index:

     history | where exit_status == 127 | last | get duration
    2sec 410ms
The syntax ends up very clean looking since the data going through the pipes is typed, and the error messages are top notch

      × Types 'duration' and 'int' are not compatible for the '-' operator.
       ╭─[entry #47:1:2]
     1 │ (history | where exit_status == 127 | last | get duration) - 10
       ·  ───┬───                                                   ┬ ─┬
       ·     │                                                      │  ╰── int
       ·     │                                                      ╰── does not operate between 'duration' and 'int'
       ·     ╰── duration
       ╰────
(fingers crossed hn doesn't mangle that...)