Skip to content

Commit

Permalink
docs: add a tip for navigating in the parent directory without leavin…
Browse files Browse the repository at this point in the history
…g the CWD
  • Loading branch information
sxyazi committed Mar 20, 2024
1 parent 54c7a56 commit dedc4d9
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
2 changes: 1 addition & 1 deletion docs/plugins/types.md
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ Properties:
- `mode` - The [tab::Mode](#tabmode) of this tab.
- `conf` - The [tab::Config](#tabconfig) of this tab.
- `current` - The current folder within this tab, which is a [folder::Folder](#folderfolder).
- `parent` - The parent folder within this tab, which is a [folder::Folder](#folderfolder).
- `parent` - The parent folder within this tab, which is a [folder::Folder](#folderfolder) if `current` has a parent; otherwise, `nil`.
- `selected` - The selected files within this tab, which is a [tab::Selected](#tabselected).
- `preview` - The [tab::Preview](#tabpreview) within this tab.

Expand Down
32 changes: 32 additions & 0 deletions docs/tips.md
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,38 @@ on = [ "j" ]
run = "plugin --sync arrow --args=1"
```

## Navigation in the parent directory without leaving the CWD

Save these lines as `~/.config/yazi/plugins/parent-arrow.yazi/init.lua`:

```lua
local function entry(_, args)
local parent = cx.active.parent
if not parent then
return
end

local target = parent.files[parent.cursor + 1 + args[1]]
if target then
ya.manager_emit("cd", { tostring(target.url) })
end
end

return { entry = entry }
```

Then bind it for `K` and `J` key, in your `keymap.toml`:

```toml
[[manager.prepend_keymap]]
on = [ "K" ]
run = "plugin --sync parent-arrow --args=-1"

[[manager.prepend_keymap]]
on = [ "J" ]
run = "plugin --sync parent-arrow --args=1"
```

## No status bar

<img src={useBaseUrl("/img/no-status-bar.jpg")} width="600" />
Expand Down

0 comments on commit dedc4d9

Please sign in to comment.