Skip to content

Commit

Permalink
docs: update tips to the latest
Browse files Browse the repository at this point in the history
  • Loading branch information
sxyazi committed Jan 15, 2024
1 parent e845d77 commit 4d9f637
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 82 deletions.
28 changes: 17 additions & 11 deletions docs/configuration/theme.md
Original file line number Diff line number Diff line change
Expand Up @@ -193,21 +193,27 @@ You can restrict the specific type of files through `is`, noting that it must be
- `sock`: Socket
- `sticky`: File with sticky bit set

## [icons]
## [icon]

Display different icons based on file name rules, noting that the `/` after the name signifies that it must be a directory.
Display icon based on file name rules, noting that the `/` after the name signifies that it's a directory.

```toml
[icons]
"Desktop/" = ""
"*.rs" = ""
# ...

# Default
"*" = ""
"*/" = ""
[icon]

rules = [
{ name = "*.rs" , text = "" },
{ name = "Desktop/", text = "" },
# ...

# Icon with a color
{ name = "*.lua", text = "", fg = "#51a0cf" },

# Default
{ name = "*" , text = "" },
{ name = "*/", text = "" },
]
```

Similarly, `*` and `*/` can be used for fallback matching all files and all directories.
Similarly, `*` and `*/` can be used for fallback matching all files and all directories. You can also use `fg` to set the icon color.

The above rules use icons from [Nerd Fonts](https://www.nerdfonts.com), and they will not display properly if you don't have a Nerd Font installed.
11 changes: 2 additions & 9 deletions docs/faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,16 +99,9 @@ If you don't want to use it and want things to be calm, sure, you can modify the
[status]
separator_open = ""
separator_close = ""
```

and

```toml
[icons]
"Desktop/" = ""
"Documents/" = ""
"Downloads/" = ""
# ...
[icon]
rules = []
```

The above code changed all icons to `""`, and the whole world went quiet, nice!
Expand Down
84 changes: 22 additions & 62 deletions docs/tips.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,63 +13,48 @@ You can implement a full border for Yazi via the UI plugin.

<img src={useBaseUrl("/img/full-border.png")} width="600" />

Copy the preset [`Manager:render` function](https://github.com/sxyazi/yazi/blob/main/yazi-plugin/preset/components/manager.lua) to any place, for example `~/.config/yazi/ui.lua`, then apply the following patch:
Copy the preset [`Manager:render` function](https://github.com/sxyazi/yazi/blob/main/yazi-plugin/preset/components/manager.lua) to your `~/.config/yazi/init.lua`, then apply the following patch:

```diff
@@ -10,16 +10,28 @@ function Manager:render(area)
@@ -10,16 +10,29 @@
})
:split(area)

+ local bar = function(c, x, y)
+ return ui.Bar(
+ ui.Rect { x = math.max(0, x), y = math.max(0, y), w = math.min(1, area.w), h = math.min(1, area.h) },
+ ui.Position.TOP
+ ui.Bar.TOP
+ ):symbol(c)
+ end
+
return utils.flat {
- -- Borders
- ui.Bar(chunks[1], ui.Position.RIGHT):symbol(THEME.manager.border_symbol):style(THEME.manager.border_style),
- ui.Bar(chunks[3], ui.Position.LEFT):symbol(THEME.manager.border_symbol):style(THEME.manager.border_style),
+ ui.Border(area, ui.Position.ALL):type(ui.Border.ROUNDED),
+ ui.Bar(chunks[1], ui.Position.RIGHT),
+ ui.Bar(chunks[3], ui.Position.LEFT),
+
return ya.flat {
-- Borders
- ui.Bar(chunks[1], ui.Bar.RIGHT):symbol(THEME.manager.border_symbol):style(THEME.manager.border_style),
- ui.Bar(chunks[3], ui.Bar.LEFT):symbol(THEME.manager.border_symbol):style(THEME.manager.border_style),
+ ui.Border(area, ui.Border.ALL):type(ui.Border.ROUNDED),
+ ui.Bar(chunks[1], ui.Bar.RIGHT),
+ ui.Bar(chunks[3], ui.Bar.LEFT),

+ bar("┬", chunks[1].right - 1, chunks[1].y),
+ bar("┴", chunks[1].right - 1, chunks[1].bottom - 1),
+ bar("┬", chunks[2].right, chunks[2].y),
+ bar("┴", chunks[2].right, chunks[1].bottom - 1),

+
-- Parent
- Folder:render(chunks[1]:padding(ui.Padding.x(1)), { kind = Folder.PARENT }),
+ Folder:render(chunks[1]:padding(ui.Padding.xy(1)), { kind = Folder.PARENT }),
- Parent:render(chunks[1]:padding(ui.Padding.x(1))),
+ Parent:render(chunks[1]:padding(ui.Padding.xy(1))),
-- Current
- Folder:render(chunks[2], { kind = Folder.CURRENT }),
+ Folder:render(chunks[2]:padding(ui.Padding.y(1)), { kind = Folder.CURRENT }),
- Current:render(chunks[2]),
+ Current:render(chunks[2]:padding(ui.Padding.y(1))),
-- Preview
- ui.Base(chunks[3]:padding(ui.Padding.x(1)), ui.Base.PREVIEW),
+ ui.Base(chunks[3]:padding(ui.Padding.xy(1)), ui.Base.PREVIEW),
- Preview:render(chunks[3]:padding(ui.Padding.x(1))),
+ Preview:render(chunks[3]:padding(ui.Padding.xy(1))),
}
end
```

If you prefer sharp corners for the border, you can remove `:type(ui.Border.ROUNDED)`.

Finally include it and adjust the manager layout offset:

```toml
# yazi.toml
[plugins]
preload = [
"~/.config/yazi/ui.lua"
]

# theme.toml
[manager]
folder_offset = [ 2, 0, 2, 0 ]
preview_offset = [ 2, 1, 2, 1 ]
```

## Dropping to the shell

Add the keybindings to the `[manager]` of `keymap.toml`:
Expand Down Expand Up @@ -125,7 +110,7 @@ Please make sure that `<C-n>` does not conflict with your other keys.

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

Save these lines as a file, for example `~/.config/yazi/ui.lua`:
Add these lines to your `~/.config/yazi/init.lua`:

```lua
function Status:render() return {} end
Expand All @@ -136,27 +121,12 @@ function Manager:render(area)
end
```

Finally include it and adjust the manager layout offset:

```toml
# yazi.toml
[plugins]
preload = [
"~/.config/yazi/ui.lua"
]

# theme.toml
[manager]
folder_offset = [ 1, 0, 0, 0 ]
preview_offset = [ 1, 1, 0, 1 ]
```

## Show symlink in status bar

<img src={useBaseUrl("/img/symlink-in-status.png")} width="600" />

You only need to rewrite the [`Status:name()` method](https://github.com/sxyazi/yazi/blob/main/yazi-plugin/preset/components/status.lua#L39-L46) to achieve this feature,
save this method as a file, and apply the following patch to it:
You can rewrite the [`Status:name()` method](https://github.com/sxyazi/yazi/blob/main/yazi-plugin/preset/components/status.lua) to achieve this feature,
copy this method to your `~/.config/yazi/init.lua`, and apply the following patch:

```diff
@@ -42,7 +42,11 @@ function Status:name()
Expand All @@ -172,21 +142,11 @@ save this method as a file, and apply the following patch to it:
end
```

Finally just include it:

```toml
# yazi.toml
[plugins]
preload = [
"/path/to/your/status-name-function.lua"
]
```

## Show user/group of files in status bar

<img src={useBaseUrl("/img/owner.png")} width="600" />

You only need to rewrite the [`Status:render()` method](https://github.com/sxyazi/yazi/blob/main/yazi-plugin/preset/components/status.lua#L143-L154) to achieve this feature,
You can rewrite the [`Status:render()` method](https://github.com/sxyazi/yazi/blob/main/yazi-plugin/preset/components/status.lua) to achieve this feature,
copy this method to your `~/.config/yazi/init.lua`, and apply the following patch:

```diff
Expand Down

0 comments on commit 4d9f637

Please sign in to comment.