TheDocumentation 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.
ps namespace provides a publish/subscribe messaging system for communication between plugins and Yazi components.
Overview
The PubSub system allows plugins to:- Subscribe to events from Yazi (DDS events)
- Publish custom events to other plugins
- Communicate between plugin instances
- React to system events
Subscription
ps.sub(kind, callback)
Subscribe to a local event.
Event kind/name to subscribe to
Callback function to handle events
ps.sub_remote(kind, callback)
Subscribe to a remote event (from other Yazi instances or DDS).
Event kind to subscribe to
Callback function
As of #3638,
ps.sub() can be used directly in init.lua without requiring a plugin.Publishing
ps.pub(kind, value)
Publish an event locally.
Event kind
Event data (must be serializable)
ps.pub_to(receiver, kind, value)
Publish an event to a specific receiver.
Receiver ID
Event kind
Event data
Unsubscription
ps.unsub(kind)
Unsubscribe from a local event.
Event kind to unsubscribe from
True if was subscribed, false otherwise
ps.unsub_remote(kind)
Unsubscribe from a remote event.
Event kind to unsubscribe from
True if was subscribed, false otherwise
DDS Events
Yazi emits various DDS (Data Distribution Service) events that plugins can subscribe to:File Events
UI Events
-
ind-app-title- Customize app title (#3684) -
ind-which-activate- Change which-key behavior (#3608) -
ind-sort- Change sorting in Lua (#3391)
Key Events
System Events
-
relay-notify-push- Customize notification handler (#3642) -
hey- Fires when static messages are restored from persistence (#3725)
Yank Events
@yank- Files yanked (copied/cut)
Examples
Subscribe to Directory Changes
Custom Event Communication
DDS Event Bridge (from preset)
Thedds.lua preset plugin bridges DDS events to Yazi actions:
Clean Up Subscriptions
Best Practices
- Subscribe early - Set up subscriptions in
init.luaor plugin setup function - Handle errors - Wrap callback logic in pcall to prevent crashes
- Unsubscribe - Clean up subscriptions when no longer needed
- Serialize data - Ensure published data is JSON-serializable
- Avoid loops - Be careful not to create event loops (A publishes → B subscribes and publishes → A subscribes…)
See Also
- DDS Documentation - Full DDS event reference
- ya.emit() - Emit custom actions
- Plugin Examples - Preset plugins using PubSub