Skip to content

[Feature request] Add integrated ^watch alternative #8166

Open
@freijon

Description

Related problem

The watch command of the procps utility is quite useful in certain circumstances. I use it a lot to monitor certain command outputs, for example pueue status, package manager installation progress, etc. It would be wonderful if nushell output could be 'watched' in a similar manner, meaning that the standard output updates itself with the output of a command in a provided block.

Describe the solution you'd like

There is already a watch command, so I'll use a fictional command monitor

There should be a command that expects a block and that is able to monitor the output not only of external commands, but also internal ones:

monitor { sys | get mem }

There should be an option to always show colored output.

Describe alternatives you've considered

I've created the following custom command:

def monitor [command: block] {
  let config_path = $nu.config-path
  let env_path = $nu.env-path
  let source_code = (view-source $command | str trim -l -c '{' | str trim -r -c '}')
  ^watch --color -tn 1 $"nu --config ($config_path) --env-config ($env_path) -c '($source_code)'"
}

asciicast
...however, this has a few limitations:

  • Only works on Linux (Unix?) and needs procps to be installed on the system. Wouldn't work on Windows.
  • Doesn't work with colored output like ls

Additional context and details

Also, I think the watch command of the procps utility comes with some useful options, feel free to check them out here.

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions