nushell monitor

This commit is contained in:
Henrik Bakken
2025-04-12 21:19:34 +02:00
parent 33bf510e7e
commit 166db5705a
2 changed files with 30 additions and 105 deletions
+30
View File
@@ -39,6 +39,36 @@ $env.config = {
}
]
}
# from: https://github.com/nushell/nushell/issues/8166
def monitor [
--duration (-d): duration = 1sec
...args
] {
let args = $args | into string
let cmd = $args | str join ' '
loop {
let last_run = (date now)
let till = $last_run + $duration
let out = nu --config $nu.config-path --env-config $nu.env-path --commands $cmd | complete
if $out.exit_code == 0 {
clear
print $"Running every ($duration) on '(hostname)': `($cmd)`"
print $out.stdout
print $"Last run: ($last_run)"
sleep ($till - (date now))
} else {
print $out.stdout $out.stderr
break
}
}
}
source ~/.oh-my-posh.nu
# argc-completions