-
-
Notifications
You must be signed in to change notification settings - Fork 136
Open
Open
Copy link
Labels
Description
Decription
Recently I tried to write a plugin for rclone, which able to select rclone remote
from list, mount and go into it. It is more convenient than to create mount-files
for each new remote.
But it didn't work. Pressing Enter on selected entry causes open it
like regular path:
Current selection, as far as I understand, is empty and collected before press.
rclone.lua
local function rclone(info)
local remotes = {}
-- 1. get list of rclone remotes
local job = vifm.startjob {
cmd = "rclone listremotes",
}
local out = job:stdout():read('*all')
for item in string.gmatch(out, "([^,\n]+)") do
table.insert(remotes, item)
end
-- 2. show prompt and get selection
vifm.menus.loadcustom({
title = 'rclone remotes',
items = remotes,
withnavigation = true,
})
local curview = vifm.currview()
local selected = curview:selected()
for item in selected do
print(item)
end
-- 3. mount select
-- 4. cd into it
end
-- this does NOT overwrite pre-existing user command
local added = vifm.cmds.add {
name = "Rclone",
description = "Select and jump into rclone remote",
handler = rclone,
minargs = 0,
maxargs = 0,
}
if not added then
vifm.sb.error("Failed to register :Rclone")
end
return {}At the moment it is not possible to get final selection or wait for Enter
to be pressed on the current selection, or override action. Or it is not documented.
Maybe I have a false idea about what is custom view (very custom view), can it
contain not only files and be used as generic selector like dmenu or fzf? It
would be very useful in terms of writing interactive Lua plugins.