diff --git a/docs/tips.md b/docs/tips.md index 7ecfe32a..b9dbe2b1 100644 --- a/docs/tips.md +++ b/docs/tips.md @@ -121,6 +121,30 @@ run = "plugin smart-tab" desc = "Create a tab and enter the hovered directory" ``` +## Switch & create tabs: {#switch-create-tab} + +Save these lines as `~/.config/yazi/plugins/switch-create-tab.yazi/init.lua`: + +```lua +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 for 2 key or any number key, in your `keymap.toml`: + +```toml +[[manager.prepend_keymap]] +on = [ "2" ], +run = "plugin --sync switch-create-tab --args=1" +desc = "Create a new tab using the current path and switch to it" +``` + ## 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. @@ -226,7 +250,6 @@ run = ''' shell 'gh browse $(git ls-files $0) --branch=$(git branch --show-current)' ''' desc = "Browse hovered file on Github." -''' ``` Browse hovered file/directory inside Git repository using [gh](https://cli.github.com/manual/gh_browse) on Github.