Files
dotfiles/dot_config/nushell/nu_scripts/modules/log/log.nu
Cian Hughes 896af887ca Changed . token to _dot
This change allows the dotfiles to work with chezmoi (e.g: on windows)
and improves grepability with neovim/telescope
2024-11-07 13:52:17 +00:00

25 lines
651 B
Nu

def logtime [msg act] {
let start = (date now)
let result = (do $act)
let period = ((date now) - $start
| into duration --unit ns
| into string
| str replace ' ' '')
echo $'($start | format date '%Y-%m-%d_%H:%M:%S%z')(char tab)($period)(char tab)($msg)(char newline)'
| save -a ~/.cache/nushell/time.log
return $result
}
export def timelog [] {
open ~/.cache/nushell/time.log
| from tsv -n
| rename start duration message
| each {|x|
$x
| update start ($x.start | into datetime -f '%Y-%m-%d_%H:%M:%S%z')
| update duration ($x.duration | into duration)
}
}