• Operand
  • # (b)ring mi - belles.

gram:build

> ./config/nushell/day.nu

Lenses
(coming soon!)



def day [] { get modified | format date "%Y-%m-%d" }

def "day global" [] { bash -c 'date -I' }
def "day local" [] { bash -c 'date -Is' }

def clock [] { bash -c 'date -Is'; }
def dura [...command: string] { let cl = (clock); echo ($cl); time ...$command; echo; echo ($cl); clock; }

def year [] { cal --full-year 2024 --week-start monday; }

def "day page" [
  place: path,
  ...labels: string,
] {
  let day = bash -c "date -I"
  let name = [ $day ...($labels) md ] | str join "."
  let node = ([ $place $name ] | path join | path expand)
  let combined = ($labels | str join " ")

  let header = "---\n" ++ ({ composer: ...,
    name: $combined,
    summary: $combined,
    labels: $labels,
  } | to yaml) ++ "---\n\n"

  $header | save --append $node; ch $node
  code c -m $"[daily] [($place)] ($day) - ($labels | str join ".")"
}

def "day group" [] { group-by { day } | transpose | rename day nodes }

# def "day gram" [
#   place?: path,
#   label?: string,
#   --plan (-p),
# ] {
#   let grammar = days group
#   let label = if ($label | is-empty) { $place | path basename } else { $label }
#   let plan = $plan or ($place | is-empty)
#   if ($place | is-empty) { print $grammar } else { $grammar | each {|r|
#     send --plan=($plan) (
#       $r | get nodes | get name) (
#       [ $place $"($r | get day).($label)" ] | path join | path expand)
#   } }
# }

# def "day send" [
#   source: list<string>,
#   aim: path,
#   --plan (-p),
# ] {
#   print $"@-> ($aim)"; print $source; mkdir ($aim | path dirname)
#   if (not $plan) { time rsync -av ...($source) ($aim) }
# }