Files
projects.yazi/main.lua
Sami Kankaristo fb00b35266 Add ability to load a project by name or "on" key
The "load" action now accepts an argument, which is used to find a
project by name/description or the "on" keyboard key.

This can be used to create a keybinding to load a specific project (here
named "Default"):
```yaml
{ on = [ "P", "P"  ], run = "plugin projects 'load Default'", desc = "Load the 'Default'project"  },
```

It can also be used to start Yazi with a specific project using a
script:
```bash
#!/bin/bash

#
# Open a project in Yazi.
#
# https://yazi-rs.github.io/docs/plugins/utils/#ya.emit
# https://github.com/MasouShizuka/projects.yazi
#

export yaziProject="$1"
shift

if [ -z "$yaziProject" ]; then
    >&2 echo "ERROR: The first argument must be a project"
    exit 64
fi

# Generate random Yazi client ID (DDS / `ya emit` uses `YAZI_ID`)
export YAZI_ID=$RANDOM

# Use Yazi's DDS to run a plugin command after Yazi has started
# (the nested subshell is only to suppress "Done" output for the job)
( (sleep 0.1; ya emit plugin projects "load $yaziProject") &)

# Run Yazi with the generated client ID
yazi --client-id $YAZI_ID "$@"
```
2025-06-17 13:40:01 +03:00

27 KiB