Skip to content

Commit 123cd4e

Browse files
committed
docs: add Switch & create tab in Tips
1 parent 54b622d commit 123cd4e

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

docs/tips.md

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,30 @@ run = "plugin smart-tab"
121121
desc = "Create a tab and enter the hovered directory"
122122
```
123123

124+
## Switch & create tabs: {#switch-create-tab}
125+
126+
Save these lines as `~/.config/yazi/plugins/switch-create-tab.yazi/init.lua`:
127+
128+
```lua
129+
local function entry(_, args)
130+
for _ = #cx.tabs, args[1] do
131+
ya.manager_emit("tab_create", { current = true })
132+
end
133+
ya.manager_emit("tab_switch", { args[1] })
134+
end
135+
136+
return { entry = entry }
137+
```
138+
139+
Then bind it for <kbd>2</kbd> key or any number key, in your `keymap.toml`:
140+
141+
```toml
142+
[[manager.prepend_keymap]]
143+
on = [ "2" ]
144+
run = "plugin --sync switch-create-tab --args=1"
145+
desc = "Create a new tab using the current path and switch to it"
146+
```
147+
124148
## Folder-specific rules {#folder-rules}
125149

126150
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.
@@ -226,7 +250,6 @@ run = '''
226250
shell 'gh browse $(git ls-files $0) --branch=$(git branch --show-current)'
227251
'''
228252
desc = "Browse hovered file on Github."
229-
'''
230253
```
231254

232255
Browse hovered file/directory inside Git repository using [gh](https://cli.github.com/manual/gh_browse) on Github.

0 commit comments

Comments
 (0)