Skip to content

Commit

Permalink
docs: add smart-enter tip
Browse files Browse the repository at this point in the history
  • Loading branch information
sxyazi committed Jan 9, 2024
1 parent b8dbe0e commit eddec26
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
4 changes: 2 additions & 2 deletions docs/faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,11 @@ The decision to separate `enter` and `open` commands was intentional.

Yazi will be adding the ability to treat an archive as a directory in the future, allowing direct operations on the files inside.

An archive is a file, so it's "openable", but it's also "enterable" as a directory; so the user can choose the action they want to perform.
An archive is a file, so it's "openable", but it's also "enterable" as a directory; so the user can choose the action they want to do.

This is true for a actual directory as well - a directory can be entered (in Yazi), or opened (in programs like VSCode or desktop file managers).

If you truly don't need to distinguish between them, the upcoming Yazi plugin system will also assist you. It will allow you to implement the behaviors you want through plugins.
If you truly don't need to distinguish between them, use this [smart-enter tip](/docs/tips.md#smart-enter-enter-for-directory-open-for-file).

## Why is "orphan" set to false by default?

Expand Down
19 changes: 19 additions & 0 deletions docs/tips.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,25 @@ You can change the `<Esc>` of input component from the default `escape` to `clos

To exiting input directly, without entering Vi mode, making it behave like a regular input box.

## Smart enter: `enter` for directory, `open` for file

Save those lines as `~/.config/yazi/plugins/smart-enter.yazi/init.lua`:

```lua
return {
entry = function()
local h = cx.active.current.hovered
ya.manager_emit(h and h.cha.is_dir and "enter" or "open", {})
end,
}
```

Then bind it for `l` key, in your `keymap.toml`:

```toml
{ on = [ "l" ], exec = "plugin --sync smart-enter", desc = "Enter the child directory, or open the file" },
```

## Drag and drop via [`dragon`](https://github.com/mwh/dragon)

Original post: https://github.com/sxyazi/yazi/discussions/327
Expand Down

0 comments on commit eddec26

Please sign in to comment.