Skip to content

Commit

Permalink
docs: a bunch of improvements for DDS docs
Browse files Browse the repository at this point in the history
  • Loading branch information
sxyazi committed Apr 22, 2024
1 parent 8dac63e commit f3930e6
Show file tree
Hide file tree
Showing 3 changed files with 5,788 additions and 4,410 deletions.
52 changes: 52 additions & 0 deletions docs/dds.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,36 @@ It deeply integrates with a publish-subscribe model based on the Lua API.
The DDS has two usage:

- [Plugin API](/docs/plugins/utils#ps): Using Lua-based publish-subscribe model as the carrier for DDS.
- [Command-line tool](#cli): Using `ya` command-line tool as the carrier for DDS.
- [Real-time `stdout` reporting](#stdout-reporting): Using `stdout` as the carrier for DDS.

### Command-line tool {#cli}

You can send a message to the remote instance(s) using `ya pub`, with the two required `receiver` and `kind` arguments consistent with [`ps.pub_to()`](/docs/plugins/utils#ps.pub_to):

```sh
ya pub <receiver> <kind> --str "string body"
ya pub <receiver> <kind> --json '{"key": "json body"}'

# If you're in a Yazi subshell,
# you can obtain the ID of the current instance using `$YAZI_ID`.
ya pub $YAZI_ID dds-cd --str "/root"
```

You can also send a static message to all remote instances using `ya pub-static`, with its `severity` and `kind` arguments consistent with [`ps.pub_static()`](/docs/plugins/utils#ps.pub_static):

```sh
ya pub-static <severity> <kind> --str "string body"
ya pub-static <severity> <kind> --json '{"key": "json body"}'
```

For greater convenience in integrating within the command-line environment, they support two body formats:

- String: a straightforward format, suitable for most scenarios, without the need for additional tools for encoding
- JSON: for advanced needs, support for types and more complex data can be represented through the JSON format

Note that `ya` is a standalone CLI program introduced since Yazi 0.2.5, it might conflict with the shell wrapper you setup before, see [Introduce a standalone CLI program](https://github.com/sxyazi/yazi/issues/914) for details.

### Real-time `stdout` reporting {#stdout-reporting}

You can specify the `--local-events` and `--remote-events` options when starting Yazi:
Expand Down Expand Up @@ -315,3 +343,27 @@ System reserves kind.
### `bye`

System reserves kind.

## Builtin plugin

### `dds.lua`

This plugin provides the `dds-cd` event kind, which accepts a string URL and changes the CWD to that URL when it is received.

This is useful for synchronizing the CWD of the current Yazi instance when exiting from a subshell.

Source code: https://github.com/sxyazi/yazi/blob/main/yazi-plugin/preset/plugins/dds.lua

### `session.lua`

The plugin provides cross-instance yank ability, which means you can yank files in one instance, and then paste them in another instance.

To enable it, add these lines to your `init.lua`:

```lua
require("session"):setup {
sync_yanked = true,
}
```

Source code: https://github.com/sxyazi/yazi/blob/main/yazi-plugin/preset/plugins/session.lua
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,18 @@
"format": "prettier --write ."
},
"dependencies": {
"@docusaurus/core": "3.2.0",
"@docusaurus/preset-classic": "3.2.0",
"@docusaurus/core": "3.2.1",
"@docusaurus/preset-classic": "3.2.1",
"@mdx-js/react": "^3.0.0",
"clsx": "^1.2.1",
"prism-react-renderer": "^2.1.0",
"react": "^18.0.0",
"react-dom": "^18.0.0"
},
"devDependencies": {
"@docusaurus/module-type-aliases": "3.2.0",
"@docusaurus/tsconfig": "3.2.0",
"@docusaurus/types": "3.2.0",
"@docusaurus/module-type-aliases": "3.2.1",
"@docusaurus/tsconfig": "3.2.1",
"@docusaurus/types": "3.2.1",
"prettier": "^3.0.3",
"typescript": "~5.2.2"
},
Expand All @@ -44,5 +44,5 @@
"engines": {
"node": ">=18.0"
},
"packageManager": "pnpm@8.10.1"
"packageManager": "pnpm@9.0.5"
}
Loading

0 comments on commit f3930e6

Please sign in to comment.