aboutsummaryrefslogtreecommitdiff
path: root/plugins/openselected.lua
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/openselected.lua')
-rw-r--r--plugins/openselected.lua26
1 files changed, 26 insertions, 0 deletions
diff --git a/plugins/openselected.lua b/plugins/openselected.lua
new file mode 100644
index 0000000..5fadbec
--- /dev/null
+++ b/plugins/openselected.lua
@@ -0,0 +1,26 @@
+local core = require "core"
+local command = require "core.command"
+local keymap = require "core.keymap"
+
+
+command.add("core.docview", {
+ ["open-selected:open-selected"] = function()
+ local doc = core.active_view.doc
+ if not doc:has_selection() then
+ core.error("No text selected")
+ return
+ end
+
+ local text = doc:get_text(doc:get_selection())
+ core.log("Opening \"%s\"...", text)
+
+ if PLATFORM == "Windows" then
+ os.execute(string.format("start explorer %s", text))
+ else
+ os.execute(string.format("xdg-open %q &", text))
+ end
+ end,
+})
+
+
+keymap.add { ["ctrl+shift+o"] = "open-selected:open-selected" }