• Operand
  • odyssey, u hear?

gram: build

> ./config/nushell/program.nu

Lenses
(coming soon!)


source ./nix.nu
source ./disc.nu

def phx [] { mix phx.server; }
def book [] { nsh livebook livebook start_iex }
def panel [] { firefox 'about:debugging#/runtime/this-firefox' }

def --wrapped ledge [...call] { nsh hledger hledger ...($call) }
def "ledge page" [] { nsh hledger-web hledger-web --allow=edit }

def muse --wrapped [ ...call ] {
  nsh spotify-player $"spotify_player ($call | str join ' ')"; }

def elementary [program: string] {
  nsh $"pantheon.elementary-($program)" $"io.elementary.($program)" }

def pad [name:string] { (padloc $name).0.passcode }
def padloc [ name?: string] {
  let node = "~/padloc.csv" | path expand
  if ($name | is-empty) { hx $node; return }
  cat $node | from csv --flexible -s ',' -q '"' -c '#' --trim all | each {
    let r = values | each { str trim | str replace -r '^"' '' | str replace -r '"$' '' }
    { name: $r.0, domain: $r.1, login: $r.2, passcode: $r.3 }
  } | where domain =~ $name
}

def --wrapped pass [...command: string] {
  nsh go-passbolt-cli $"passbolt ($command | str join ' ')"
}

def ex --wrapped [...call] { nsh exercism exercism ...$call }
def --env "ex up" [lang: string] {
  mkcd ([ ~ base code exercise $lang ] | path join | path expand)
  cd ((ls | sort-by modified).name | path basename | choose) }

def "daily burn" [] {
  firefox 'https://exercism.org/tracks/rust/exercises'
  firefox 'https://sam.gov/search/?page=1&pageSize=100&sort=-modifiedDate&sfm%5BsimpleSearch%5D%5BkeywordRadio%5D=ALL&sfm%5BsimpleSearch%5D%5BkeywordTags%5D%5B0%5D%5Bkey%5D=%22house%20of%20representatives%22&sfm%5BsimpleSearch%5D%5BkeywordTags%5D%5B0%5D%5Bvalue%5D=%22house%20of%20representatives%22&sfm%5Bstatus%5D%5Bis_active%5D=true&sfm%5Bstatus%5D%5Bis_inactive%5D=true&sfm%5BagencyPicker%5D%5B0%5D%5BorgKey%5D=300000003&sfm%5BagencyPicker%5D%5B0%5D%5BorgText%5D=000%20-%20HOUSE%20OF%20REPRESENTATIVES,%20THE&sfm%5BagencyPicker%5D%5B0%5D%5BlevelText%5D=Dept%20%2F%20Ind.%20Agency&sfm%5BagencyPicker%5D%5B0%5D%5Bhighlighted%5D=true'
}

def daily [ place: path, ...labels: string ] { cd $place
  let day = bash -c "date -I"
  let name = [ $day ...($labels) md ] | str join "."
  let node = ([ $place $name ] | path join | path expand)
  ch $node; c ab $node; cap $node
  code c -m $"[daily] [($place)] ($day) - ($labels | str join ".")"
}

def "page share" [] {
  c -C /home/calliope/page kf share
  shell $m.base git -C /root/share/page restore --staged .
  shell $m.base git -C /root/share/page checkout -- .
}

def "mag open" [] { d -b nvme0n1p7; mkcd magnesis
  nsh transmission_4-gtk transmission-gtk }
def "mag super" [] { d -b nvme0n1p7; mkcd magnesis
  nsh transmission_4-gtk sudo -E transmission-gtk }
def mag [mag:string] { d -b nvme0n1p7; mkcd magnesis
  nsh transmission_4 transmission-cli -u 0 -w (pwd) $mag }

def render [glob: string, --shape (-s): string = html] {
  xdg-open ...(glob $glob | each {
    let n = $in | path parse;
    let rend = [ $n.parent render $"($n.stem).($shape)" ] | path join
    let pkg = if ($shape == pdf) {[pandoc texliveSmall]} else {[pandoc]}
    mkdir ([$n.parent render] | path join)
    try { nsh -p ($pkg) pandoc -f $n.extension -t $shape $in -o $rend }
    $rend
}) }

def "ledge page" [] {
  nsh hledger-web hledger-web --allow=edit
}