Skip to main content

Overview

The emit and emit-to commands allow you to send commands to running Yazi instances. This enables automation, remote control, and integration with other tools.

emit

Emit a command to be executed by the current Yazi instance.

Synopsis

Arguments

string
required
Name of the command to execute.This should be a valid Yazi command name (e.g., cd, refresh, search, select).
string[]
Arguments to pass to the command.Arguments can include hyphens and are passed directly to the command handler.

Examples

Use Cases

Automation Scripts

Integration with Other Tools

Shell Functions

emit-to

Emit a command to be executed by a specific Yazi instance.

Synopsis

Arguments

number
required
Receiver instance ID.This is the client ID of the target Yazi instance (specified via --client-id when starting Yazi).
string
required
Name of the command to execute.
string[]
Arguments to pass to the command.

Examples

Use Cases

Multi-Instance Orchestration

Remote Control

Build System Integration

Command Serialization

Commands are serialized as JSON arrays with the command name followed by arguments:
Arguments that contain special characters are properly encoded to handle:
  • Unicode characters
  • Spaces and special shell characters
  • Binary data (converted to byte arrays)

Error Handling

Both commands will exit with status code 1 and print an error message if:
  • The target instance is not reachable
  • The instance ID is invalid (for emit-to)
  • The command fails to serialize
  • DDS communication fails
Example error:

Environment Variables

string
Current Yazi instance ID. Set automatically by Yazi.Used by emit to determine the target instance.
string
Alternative to YAZI_ID. Contains the instance process ID.

See Also

  • ya - Main CLI utility
  • pub-sub - Pub/sub messaging for custom events
  • yazi - Start Yazi with specific client ID