Skip to content

Commit

Permalink
docs: add shell templates for dds-cd event
Browse files Browse the repository at this point in the history
  • Loading branch information
sxyazi committed Apr 22, 2024
1 parent 074b389 commit 7b3d0d1
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 4 deletions.
2 changes: 1 addition & 1 deletion cspell.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"language":"en","flagWords":[],"words":["linemode","Hyprland","ueberzug","yazi","sxyazi","Discardable","Sixel","downscaling","downscales","keymap","unyank","preloaders","precache","Konsole","Mintty","Ghostty","Zellij","scrolloff","unsub"],"version":"0.2"}
{"flagWords":[],"words":["linemode","Hyprland","ueberzug","yazi","sxyazi","Discardable","Sixel","downscaling","downscales","keymap","unyank","preloaders","precache","Konsole","Mintty","Ghostty","Zellij","scrolloff","unsub","subshell"],"version":"0.2","language":"en"}
39 changes: 36 additions & 3 deletions docs/dds.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ sidebar_position: 7
description: Data Distribution Service
---

import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';

# DDS

:::warning
Expand Down Expand Up @@ -37,8 +40,8 @@ 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 obtain the ID of the current instance through `$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):
Expand Down Expand Up @@ -350,7 +353,37 @@ System reserves kind.

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.
This is useful for synchronizing the CWD of the current Yazi instance when exiting from a subshell:

<Tabs>
<TabItem value="Zsh" label="Zsh" default>

```sh
# Change Yazi's CWD to PWD on subshell exit
if [[ -n YAZI_ID ]]; then
function _yazi_cd() {
ya pub "$YAZI_ID" dds-cd --str "${PWD}"
}
add-zsh-hook zshexit _yazi_cd
fi
```

</TabItem>
<TabItem value="fish" label="Fish">

```sh
# Please raise a PR if you have a fish version
```

</TabItem>
<TabItem value="nushell" label="Nushell">

```sh
# Please raise a PR if you have a nushell version
```

</TabItem>
</Tabs>

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

Expand Down

0 comments on commit 7b3d0d1

Please sign in to comment.