Skip to content

Commit

Permalink
docs: add Switch & create tab in Tips
Browse files Browse the repository at this point in the history
  • Loading branch information
AnirudhG07 committed Dec 17, 2024
1 parent 54b622d commit d9a5cf9
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion docs/tips.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 <kbd>2</kbd> 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.
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit d9a5cf9

Please sign in to comment.