nu: rewatch - suppress Ctrl+C error
This commit is contained in:
@@ -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 } }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user