Compare commits
2 Commits
main
...
custom_key
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e45dffc27a | ||
|
|
0e772b951b |
@@ -23,10 +23,10 @@ ya pack -a dedukun/bookmarks
|
|||||||
|
|
||||||
## Import/Export bookmarks
|
## Import/Export bookmarks
|
||||||
|
|
||||||
This plugin uses [Yazi's DDS](https://yazi-rs.github.io/docs/dds/) for bookmark persistence, as such,
|
This plugin uses [Yazi's DDS](https://yazi-rs.github.io/docs/dds/) for bookmark persistence, as such,
|
||||||
the bookmarks are saved in DDS's state file (`~/.local/state/yazi/.dds` on Linux and `C:\Users\USERNAME\AppData\Roaming\yazi\state\.dds` on Windows)
|
the bookmarks are saved in DDS's state file (`~/.local/state/yazi/.dds` on Linux and `C:\Users\USERNAME\AppData\Roaming\yazi\state\.dds` on Windows)
|
||||||
|
|
||||||
***NOTE:*** This system may be used by other plugins that you have installed, so this file might have more data than just the bookmarks.
|
**_NOTE:_** This system may be used by other plugins that you have installed, so this file might have more data than just the bookmarks.
|
||||||
|
|
||||||
## Configuration
|
## Configuration
|
||||||
|
|
||||||
@@ -62,7 +62,7 @@ The following are the default configurations:
|
|||||||
```lua
|
```lua
|
||||||
-- ~/.config/yazi/init.lua
|
-- ~/.config/yazi/init.lua
|
||||||
require("bookmarks"):setup({
|
require("bookmarks"):setup({
|
||||||
last_directory = { enable = false, persist = false },
|
last_directory = { enable = false, persist = false, key= "'" },
|
||||||
persist = "none",
|
persist = "none",
|
||||||
desc_format = "full",
|
desc_format = "full",
|
||||||
file_pick_mode = "hover",
|
file_pick_mode = "hover",
|
||||||
@@ -85,6 +85,8 @@ the last directory.
|
|||||||
|
|
||||||
There's also the option to enable persistence to this automatic bookmark.
|
There's also the option to enable persistence to this automatic bookmark.
|
||||||
|
|
||||||
|
It's also possible to change the trigger key.
|
||||||
|
|
||||||
### `persist`
|
### `persist`
|
||||||
|
|
||||||
When enabled the bookmarks will persist, i.e. if you close and reopen Yazi they will still be
|
When enabled the bookmarks will persist, i.e. if you close and reopen Yazi they will still be
|
||||||
|
|||||||
26
main.lua
26
main.lua
@@ -92,7 +92,10 @@ end)
|
|||||||
|
|
||||||
local _save_last_directory = ya.sync(function(state, persist)
|
local _save_last_directory = ya.sync(function(state, persist)
|
||||||
if persist then
|
if persist then
|
||||||
ps.sub_remote("@bookmarks-lastdir", function(body) state.curr_dir = body end)
|
ps.sub_remote("@bookmarks-lastdir", function(body)
|
||||||
|
state.curr_dir = body
|
||||||
|
state.curr_dir.on = state.last_directory_key
|
||||||
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
ps.sub("cd", function()
|
ps.sub("cd", function()
|
||||||
@@ -104,7 +107,7 @@ local _save_last_directory = ya.sync(function(state, persist)
|
|||||||
end
|
end
|
||||||
|
|
||||||
state.curr_dir = {
|
state.curr_dir = {
|
||||||
on = "'",
|
on = state.last_directory_key,
|
||||||
desc = _generate_description(file),
|
desc = _generate_description(file),
|
||||||
path = tostring(file.url),
|
path = tostring(file.url),
|
||||||
is_parent = file.is_parent,
|
is_parent = file.is_parent,
|
||||||
@@ -216,6 +219,14 @@ local delete_all_bookmarks = ya.sync(function(state)
|
|||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
local jump_to_last = ya.sync(function(state)
|
||||||
|
if state.last_dir.is_parent then
|
||||||
|
ya.manager_emit("cd", { state.last_dir.is_parent })
|
||||||
|
else
|
||||||
|
ya.manager_emit("reveal", { state.last_dir.is_parent })
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
entry = function(_, job)
|
entry = function(_, job)
|
||||||
local action = job.args[1]
|
local action = job.args[1]
|
||||||
@@ -229,10 +240,10 @@ return {
|
|||||||
save_bookmark(key)
|
save_bookmark(key)
|
||||||
end
|
end
|
||||||
return
|
return
|
||||||
end
|
elseif action == "delete_all" then
|
||||||
|
|
||||||
if action == "delete_all" then
|
|
||||||
return delete_all_bookmarks()
|
return delete_all_bookmarks()
|
||||||
|
elseif action == "jump_last" then
|
||||||
|
return jump_to_last()
|
||||||
end
|
end
|
||||||
|
|
||||||
local bookmarks = all_bookmarks(action == "jump")
|
local bookmarks = all_bookmarks(action == "jump")
|
||||||
@@ -258,6 +269,11 @@ return {
|
|||||||
|
|
||||||
if type(args.last_directory) == "table" then
|
if type(args.last_directory) == "table" then
|
||||||
if args.last_directory.enable then
|
if args.last_directory.enable then
|
||||||
|
state.last_directory_key = "'"
|
||||||
|
if type(args.last_directory.key) == "string" then
|
||||||
|
state.last_directory_key = args.last_directory.key
|
||||||
|
end
|
||||||
|
|
||||||
_save_last_directory(args.last_directory.persist)
|
_save_last_directory(args.last_directory.persist)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user