Nu can be extended using plugins. Plugins behave much like Nu's built-in commands, with the added benefit that they can be added separately from Nu itself.
Nu plugins are executables; Nu launches them as needed and communicates with them over stdin, stdout, and stderr. Nu plugins can use either JSON or MSGPACK as their communication encoding.
Adding a plugin
To add a plugin, call the
register command to tell Nu where to find it. As you do, you'll need to also tell Nushell what encoding the plugin uses.
Please note that the plugin name needs to start with
nu_plugin_, Nu uses the name prefix to detect plugins.
> register ./my_plugins/nu_plugin_cool
> register .\my_plugins\nu_plugin_cool.exe
register is called:
- Nu launches the plugin, and wait for plugin tell Nu which communication encoding it should use
- Nu sends it a "Signature" message over stdin
- The plugin responds via stdout with a message containing its signature (name, description, arguments, flags, and more)
- Nu saves the plugin signature in the file at
$nu.plugin-path, so registration is persisted across multiple launches
Once registered, the plugin is available as part of your set of commands:
> help commands | where is_plugin == true
Nu's main repo contains example plugins that are useful for learning how the plugin protocol works:
The simplest way to debug a plugin is to print to stderr; plugins' standard error streams are redirected through Nu and displayed to the user.
Nu's plugin documentation is a work in progress. If you're unsure about something, the #plugins channel on the Nu Discord is a great place to ask questions!