Skip to content

Commit

Permalink
docs: add smart tab switch tip (#188)
Browse files Browse the repository at this point in the history
Co-authored-by: 三咲雅 · Misaki Masa <[email protected]>
  • Loading branch information
hankertrix and sxyazi authored Dec 27, 2024
1 parent 1784bae commit dde6d9f
Showing 1 changed file with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion docs/tips.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ return {
}
```

Then bind it for <kbd>t</kbd> key, in your `keymap.toml`:
Then bind it to the <kbd>t</kbd> key, in your `keymap.toml`:

```toml
[[manager.prepend_keymap]]
Expand All @@ -121,6 +121,31 @@ run = "plugin smart-tab"
desc = "Create a tab and enter the hovered directory"
```

## Smart switch: create tab if the tab being switched to does not exist {#smart-switch}

Save these lines as `~/.config/yazi/plugins/smart-switch.yazi/init.lua`:

```lua
--- @sync entry
local function entry(_, args)
for _ = #cx.tabs, args[1] do
ya.manager_emit("tab_create", { current = true })
end
ya.manager_emit("tab_switch", { args[1] })
end

return { entry = entry }
```

Then bind it to the <kbd>2</kbd> key, in your `keymap.toml`:

```toml
[[manager.prepend_keymap]]
on = "2"
run = "plugin smart-switch --args=1"
desc = "Switch or create tab 2"
```

## Folder-specific rules {#folder-rules}

You can subscribe to directory change events through the [`cd` event provided by DDS](/docs/dds#cd), and then do any action you want, such as setting different sorting methods for specific directories.
Expand Down

0 comments on commit dde6d9f

Please sign in to comment.