Skip to content

Commit

Permalink
feat: show symlink in status bar
Browse files Browse the repository at this point in the history
  • Loading branch information
sxyazi committed Oct 18, 2023
1 parent 963fc4d commit 33de1c3
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
Binary file added static/img/symlink-in-status.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
32 changes: 31 additions & 1 deletion usage/tips.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ Copy the preset [`manager` component](https://github.com/sxyazi/yazi/blob/main/p
end
```

Then include it and adjust the manager layout offset:
Finally include it and adjust the manager layout offset:

```toml
# yazi.toml
Expand All @@ -63,3 +63,33 @@ preload = [
folder_offset = [ 2, 0, 2, 0 ]
preview_offset = [ 2, 1, 2, 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/plugin/preset/components/status.lua#L39-L46) to achieve this feature, save this function as a file, and apply the following patch to it:

```diff
@@ -42,7 +42,11 @@ function Status:name()
return ui.Span("")
end

- return ui.Span(" " .. h.name)
+ local linked = ""
+ if h.link_to ~= nil then
+ linked = " -> " .. tostring(h.link_to)
+ end
+ return ui.Span(" " .. h.name .. linked)
end
```

Finally just include it:

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

0 comments on commit 33de1c3

Please sign in to comment.