nu: rewatch - suppress Ctrl+C error

This commit is contained in:
2026-05-17 17:46:20 +02:00
parent 17ec0a9a34
commit c9266f252d
+10 -6
View File
@@ -16,12 +16,16 @@ def ports [] {
# Repeatedly clears and reruns a closure — nu-native watch replacement
def rewatch [interval: duration, cmd: closure] {
loop {
clear
let dim = $env.config.color_config.hints
print $"(ansi { fg: $dim })(date now | format date '%H:%M:%S')(ansi reset)"
do $cmd | print
sleep $interval
try {
loop {
clear
let dim = $env.config.color_config.hints
print $"(ansi { fg: $dim })(date now | format date '%H:%M:%S')(ansi reset)"
do $cmd | print
sleep $interval
}
} catch {|e|
if ($e.msg !~ "interrupted") { error make { msg: $e.msg } }
}
}