> ## Documentation Index
> Fetch the complete documentation index at: https://mintlify.com/sxyazi/yazi/llms.txt
> Use this file to discover all available pages before exploring further.

# ya

> CLI utility for interacting with Yazi instances

## Overview

`ya` is a command-line utility for interacting with running Yazi instances. It provides commands for sending actions, publishing messages, subscribing to events, and managing packages.

## Synopsis

```bash theme={null}
ya [OPTIONS] <COMMAND>
```

## Options

<ParamField path="-V, --version" type="boolean" default="false">
  Print version information and exit.

  ```bash theme={null}
  ya --version
  # Output: Ya 0.x.x (commit-hash build-date)
  ```
</ParamField>

## Commands

### emit

Emit a command to be executed by the current instance.

```bash theme={null}
ya emit <NAME> [ARGS]...
```

See [emit command documentation](emit) for details.

### emit-to

Emit a command to be executed by a specific instance.

```bash theme={null}
ya emit-to <RECEIVER> <NAME> [ARGS]...
```

See [emit command documentation](emit) for details.

### pkg

Manage packages (plugins and flavors).

```bash theme={null}
ya pkg <SUBCOMMAND>
```

Available subcommands:

* `add` - Add packages
* `delete` - Delete packages
* `install` - Install all packages
* `list` - List all packages
* `upgrade` - Upgrade packages

See [package command documentation](package) for details.

### pub

Publish a message to the current instance.

```bash theme={null}
ya pub <KIND> [OPTIONS]
```

See [pub-sub documentation](pub-sub) for details.

### pub-to

Publish a message to a specific instance.

```bash theme={null}
ya pub-to <RECEIVER> <KIND> [OPTIONS]
```

See [pub-sub documentation](pub-sub) for details.

### sub

Subscribe to messages from all remote instances.

```bash theme={null}
ya sub <KINDS>
```

See [pub-sub documentation](pub-sub) for details.

## Examples

### Quick Command Execution

```bash theme={null}
# Navigate to parent directory
ya emit leave

# Refresh the file list
ya emit refresh

# Search for files
ya emit search --args="*.txt"
```

### Instance Communication

```bash theme={null}
# Send command to specific instance
ya emit-to 12345 cd --args="/home/user/Downloads"

# Publish message to specific instance
ya pub-to 12345 my-event --str="Hello from another instance"
```

### Package Management

```bash theme={null}
# List installed packages
ya pkg list

# Add a new plugin
ya pkg add yazi-rs/plugins:git

# Upgrade all packages
ya pkg upgrade
```

## Environment Variables

`ya` uses the following environment variables:

* `YAZI_ID` / `YAZI_PID` - Instance ID for the current Yazi instance (set automatically)
* `YA_FORCE_ANSI` - Set to `1` to force ANSI color output

## Exit Codes

* `0` - Success
* `1` - Error occurred (e.g., cannot connect to instance, invalid arguments)

## Communication Protocol

`ya` communicates with Yazi instances using DDS (Data Distribution Service). The instance must be running with a valid client ID for communication to work.

### Finding Instance IDs

When Yazi starts, it sets the `YAZI_ID` environment variable. You can use this in shell commands:

```bash theme={null}
echo $YAZI_ID
```

For sending commands from outside a Yazi shell, you need to know the instance ID (specified via `--client-id` when starting Yazi).

## See Also

* [yazi](yazi) - Main Yazi command
* [emit](emit) - Command emission reference
* [pub-sub](pub-sub) - Pub/sub messaging reference
* [package](package) - Package management reference
