Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: add new run property #46

Merged
merged 1 commit into from
Mar 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 14 additions & 14 deletions docs/configuration/keymap.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ You can change Yazi's keybindings in your `keymap.toml` file, which consists of
In each layer, there are two attributes: `prepend_keymap` and `append_keymap`.
Prepend inserts before [the default keybindings](https://github.com/sxyazi/yazi/blob/main/yazi-config/preset/keymap.toml), while append inserts after them.

Since Yazi selects the first matching key to execute, prepend always has a higher priority than default, and append always has a lower priority than default:
Since Yazi selects the first matching key to run, prepend always has a higher priority than default, and append always has a lower priority than default:

```toml
[manager]
prepend_keymap = [
{ on = [ "<C-a>" ], exec = 'my-fev-command1', desc = "Just for test!" },
{ on = [ "<C-a>" ], run = 'my-fev-command1', desc = "Just for test!" },
]
append_keymap = [
{ on = [ "<C-b>" ], exec = 'my-fev-command2', desc = "Just for test!" },
{ on = [ "<C-b>" ], run = 'my-fev-command2', desc = "Just for test!" },
]
```

Expand All @@ -38,29 +38,29 @@ Or in another different style:
```toml
[[manager.prepend_keymap]]
on = [ "<C-a>" ]
exec = 'my-fev-command1'
run = 'my-fev-command1'
desc = "Just for test!"

[[manager.prepend_keymap]]
on = [ "<C-b>" ]
exec = 'my-fev-command2'
on = [ "<C-b>" ]
run = 'my-fev-command2'

[[manager.append_keymap]]
on = [ "<C-c>" ]
exec = 'my-fev-command3'
on = [ "<C-c>" ]
run = 'my-fev-command3'
```

But keep in mind that you can only choose one of them, and it cannot be a combination of the two, as TOML language does not allow this:

```toml
[manager]
prepend_keymap = [
{ on = [ "<C-a>" ], exec = 'my-fev-command1', desc = "Just for test!" },
{ on = [ "<C-a>" ], run = 'my-fev-command1', desc = "Just for test!" },
]

[[manager.prepend_keymap]]
on = [ "<C-b>" ]
exec = 'my-fev-command2'
run = 'my-fev-command2'
desc = "Just for test!"
```

Expand All @@ -70,8 +70,8 @@ When you don't need any default and want to fully customize your keybindings, us
[manager]
keymap = [
# This will override all default keybindings, and just keep the two below.
{ on = [ "<C-a>" ], exec = 'my-fev-command1', desc = "Just for test!" },
{ on = [ "<C-b>" ], exec = 'my-fev-command2', desc = "Just for test!" },
{ on = [ "<C-a>" ], run = 'my-fev-command1', desc = "Just for test!" },
{ on = [ "<C-b>" ], run = 'my-fev-command2', desc = "Just for test!" },
]
```

Expand Down Expand Up @@ -267,11 +267,11 @@ Run a shell command.

| Options/Arguments | Description |
| ----------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `[exec]` | Optional, command template to be run. |
| `[run]` | Optional, command template to be run. |
| `--block` | Open in a blocking manner. After setting this, Yazi will hide into a secondary screen and display the program on the main screen until it exits. During this time, it can receive I/O signals, which is useful for interactive programs. |
| `--confirm` | When the template is provided, run it directly, no input UI was shown. |

You can use the following shell variables in `[exec]`:
You can use the following shell variables in `[run]`:

- `$n` (Unix) / `%n` (Windows): The N-th selected file, starting from `1`. e.g. `$2` represents the second selected file.
- `$@` (Unix) / `%*` (Windows): All selected files.
Expand Down
2 changes: 1 addition & 1 deletion docs/configuration/theme.md
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ Icons
## [help]

- on (Style): Key column style.
- exec (Style): Command column style.
- run (Style): Command column style.
- desc (Style): Description column style.
- hovered (Style): Hovered item style.
- footer (Style): Footer style.
Expand Down
22 changes: 11 additions & 11 deletions docs/configuration/yazi.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,17 +143,17 @@ Configure available openers, for example:
```toml
[opener]
archive = [
{ exec = 'unar "$1"', desc = "Extract here" },
{ run = 'unar "$1"', desc = "Extract here" },
]
text = [
{ exec = 'nvim "$@"', block = true },
{ run = 'nvim "$@"', block = true },
]
# ...
```

Available parameters are as follows:

- exec: The command to open the selected files, with the following variables available:
- run: The command to open the selected files, with the following variables available:
- `$n` (Unix) / `%n` (Windows): The N-th selected file, starting from `1`. e.g. `$2` represents the second selected file.
- `$@` (Unix) / `%*` (Windows): All selected files.
- block (Boolean): Open in a blocking manner. After setting this, Yazi will hide into a secondary screen and display the program on the main screen until it exits. During this time, it can receive I/O signals, which is useful for interactive programs.
Expand Down Expand Up @@ -224,19 +224,19 @@ Here are the available options for a single rule:

- `name` (String): Glob expression for matching the file name. Case insensitive by default, add `\s` to the beginning to make it sensitive.
- `mime` (String): Glob expression for matching the mime-type. Case insensitive by default, add `\s` to the beginning to make it sensitive.
- `exec` (String): The name of the Lua plugin to be executed.
- `sync` (Boolean): Whether to execute in the sync context, default is `false`.
- `run` (String): The name of the Lua plugin to be ran.
- `sync` (Boolean): Whether to run in the sync context, default is `false`.

```toml
[plugin]
prepend_previewers = [
# HEIC previewer
{ mime = "image/heic", exec = "heic" },
{ mime = "image/heic", run = "heic" },
]

append_previewers = [
# My fallback previewer
{ name = "*" , exec = "binary" },
{ name = "*" , run = "binary" },
]
```

Expand All @@ -263,16 +263,16 @@ Here are the available options for a single rule:
- `name` (String): Glob expression for matching the file name. Case insensitive by default, add `\s` to the beginning to make it sensitive.
- `mime` (String): Glob expression for matching the mime-type. Case insensitive by default, add `\s` to the beginning to make it sensitive.
- `cond` (String): Conditional expression – Only rules that meet this condition and satisfy either the `name` or `mime` will be applied. For example, `A & B` means A and B, and `A | !B` means A or not B. Here are the available factors:
- `mime`: This file has a mime-type
- `exec` (String): The name of the Lua plugin to be executed
- `multi` (Boolean): Whether to preload multiple files at once
- `mime`: This file has a mime-type.
- `run` (String): The name of the Lua plugin to be ran.
- `multi` (Boolean): Whether to preload multiple files at once.
- `prio` (String): Preload priority, `low`, `normal` or `high`. The default is `normal` if not specified.

```toml
[plugin]
prepend_preloaders = [
# HEIC preloader
{ mime = "image/heic", exec = "heic" },
{ mime = "image/heic", run = "heic" },
]
```

Expand Down
28 changes: 14 additions & 14 deletions docs/tips.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ Add this keybinding to your `keymap.toml`:
```toml
[[manager.prepend_keymap]]
on = [ "<C-s>" ]
exec = 'shell "$SHELL" --block --confirm'
run = 'shell "$SHELL" --block --confirm'
desc = "Open shell here"
```

Expand All @@ -76,7 +76,7 @@ You can change the `<Esc>` of input component from the default `escape` to `clos
```toml
[[input.prepend_keymap]]
on = [ "<Esc>" ]
exec = "close"
run = "close"
desc = "Cancel input"
```

Expand All @@ -100,7 +100,7 @@ Then bind it for `l` key, in your `keymap.toml`:
```toml
[[manager.prepend_keymap]]
on = [ "l" ]
exec = "plugin --sync smart-enter"
run = "plugin --sync smart-enter"
desc = "Enter the child directory, or open the file"
```

Expand All @@ -110,20 +110,20 @@ Original post: https://github.com/sxyazi/yazi/discussions/327

```toml
[[manager.prepend_keymap]]
on = [ "<C-n>" ]
exec = '''
on = [ "<C-n>" ]
run = '''
shell 'dragon -x -i -T "$1"' --confirm
'''
```

## Copy selected files to the system clipboard while yanking

Yazi allows multiple commands to be bound to a single key, so you can set `y` to not only do the `yank` but also execute a shell script:
Yazi allows multiple commands to be bound to a single key, so you can set `y` to not only do the `yank` but also run a shell script:

```toml
[[manager.prepend_keymap]]
on = [ "y" ]
exec = [ "yank", '''
on = [ "y" ]
run = [ "yank", '''
shell --confirm 'echo "$@" | xclip -i -selection clipboard -t text/uri-list'
''' ]
```
Expand All @@ -132,8 +132,8 @@ The above is available on X11, there is also a Wayland version (Thanks [@hurutpa

```toml
[[manager.prepend_keymap]]
on = [ "y" ]
exec = [ "yank", '''
on = [ "y" ]
run = [ "yank", '''
shell --confirm 'for path in "$@"; do echo "file://$path"; done | wl-copy -t text/uri-list'
''' ]
```
Expand All @@ -156,12 +156,12 @@ Then bind it for `k` and `j` key, in your `keymap.toml`:

```toml
[[manager.prepend_keymap]]
on = [ "k" ]
exec = "plugin --sync arrow --args=-1"
on = [ "k" ]
run = "plugin --sync arrow --args=-1"

[[manager.prepend_keymap]]
on = [ "j" ]
exec = "plugin --sync arrow --args=1"
on = [ "j" ]
run = "plugin --sync arrow --args=1"
```

## No status bar
Expand Down