repositories / dotfiles
dotfiles
bugabingas dorkfiles
owned by bugabinga
wezterm/scripts/scope-info.nu
Raw#!/usr/bin/env nu
def cgroup-path [] {
open --raw /proc/self/cgroup
| lines
| parse --regex '^(?P<id>[^:]*):(?P<controllers>[^:]*):(?P<path>.*)$'
| where id == '0'
| get path.0
| str trim --left --char '/'
| $'/sys/fs/cgroup/($in)'
}
def read-cgroup-file [cg: string, name: string] {
let path = ($cg | path join $name)
try { open --raw $path | str trim } catch { $'<missing: ($name)>' }
}
let cg = (cgroup-path)
let sensitive_env_names = (
$env
| transpose name value
| where name =~ '(?i)(KEY|TOKEN|SECRET|PASSWORD)'
| get name
| sort
)
{
pid: $nu.pid
cwd: (pwd)
shell: ($env.SHELL? | default '')
wezterm_pane: ($env.WEZTERM_PANE? | default '')
wezterm_exec_domain: ($env.WEZTERM_EXEC_DOMAIN? | default '')
cgroup: $cg
memory_current: (read-cgroup-file $cg memory.current)
memory_high: (read-cgroup-file $cg memory.high)
memory_max: (read-cgroup-file $cg memory.max)
memory_swap_max: (read-cgroup-file $cg memory.swap.max)
cpu_max: (read-cgroup-file $cg cpu.max)
env_count: ($env | transpose name value | length)
sensitive_env_names: $sensitive_env_names
}