diff --git a/bins/inbreeding/watch.nu b/bins/inbreeding/watch.nu index 69a5bdef6f5548565e6b9071346fb71aa3ce8a1d..6115192b75f2f3a31588c180639f7cf39ab214f3 100644 --- a/bins/inbreeding/watch.nu +++ b/bins/inbreeding/watch.nu @@ -1,20 +1,30 @@ use consts.nu CACHE use path.nu [ "remove-cache-prefix" ] +def pretty-hash []: [ string -> string ] { + str substring 0..7 +} + export def main [] { watch $CACHE { |op, path, new_path| if $op != "Create" { return } + let path = $path | remove-cache-prefix + let now = date now | format date "%Y-%m-%d %H:%M:%S" - let p = $path | remove-cache-prefix | parse "{seed}/{exp}/{id}" | into record + let p = $path | parse "{seed}/{exp}/{id}" | into record if $p == {} { - let p = $path | remove-cache-prefix | parse "{seed}/{exp}" | into record - return $"($p.seed | str substring 0..7) ($p.exp) at ($now)" + let p = $path | parse "{seed}/{exp}" | into record + if $p == {} { + return $path + } + + return $"($p.seed | pretty-hash) ($p.exp) at ($now)" } - $"($p.seed | str substring 0..7) ($p.exp) ($p.id | str substring 0..7) at ($now)" + $"($p.seed | pretty-hash) ($p.exp) ($p.id | pretty-hash) at ($now)" } }