Background tasks with Nu
Currently, Nushell doesn't have built-in background task management feature, but you can make it "support" background task with some tools, here are some examples:
- Using a third-party task management tools, like pueue
- Using a terminal multiplexer, like tmux or zellij
Using nu with pueue
The module borrows the power of pueue, it is possible to schedule background tasks to pueue, and manage those tasks (such as viewing logs, killing tasks, or getting the running status of all tasks, creating groups, pausing tasks etc etc)
Unlike terminal multiplexer, you don't need to attach to multiple tmux sessions, and get task status easily.
Here we provide a nushell module to work with pueue easiler.
Here is a setup example to make Nushell "support" background tasks:
- Install pueue
pueued, you can refer to start-the-daemon page for more information.
- Put the task.nu file under
- Add a line to the
- Restart Nushell.
Then you will get some commands to schedule background tasks. (e.g:
Cons: It spawns a new Nushell interpreter to execute every single task, so it doesn't inherit current scope's variables, custom commands, alias definition. It only inherits environment variables whose value can be converted to a string. Therefore, if you want to use custom commands or variables, you have to
def them within the given block.
Using nu with terminal multiplexer
You can choose and install a terminal multiplexer and use it.
It allows you to easily switch between multiple programs in one terminal, detach them (they continue to run in the background) and reconnect them to a different terminal. As a result, it is very flexible and usable.