aboutsummaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'plugins')
-rw-r--r--plugins/openselected.lua27
1 files changed, 22 insertions, 5 deletions
diff --git a/plugins/openselected.lua b/plugins/openselected.lua
index a1e21a2..af00194 100644
--- a/plugins/openselected.lua
+++ b/plugins/openselected.lua
@@ -2,6 +2,17 @@
local core = require "core"
local command = require "core.command"
local keymap = require "core.keymap"
+local config = require "core.config"
+
+
+config.plugins.openselected = {}
+if PLATFORM == "Windows" then
+ config.plugins.openselected.filemanager = "start"
+elseif PLATFORM == "Mac OS X" then
+ config.plugins.openselected.filemanager = "open"
+else
+ config.plugins.openselected.filemanager = "xdg-open"
+end
command.add("core.docview", {
@@ -13,15 +24,21 @@ command.add("core.docview", {
end
local text = doc:get_text(doc:get_selection())
- core.log("Opening \"%s\"...", text)
- if PLATFORM == "Windows" then
- system.exec("start " .. text)
- else
- system.exec(string.format("xdg-open %q", text))
+ -- trim whitespace from the ends
+ text = text:match( "^%s*(.-)%s*$" )
+
+ -- non-Windows platforms need the text quoted (%q)
+ if PLATFORM ~= "Windows" then
+ text = string.format("%q", text)
end
+
+ core.log("Opening %s...", text)
+
+ system.exec(config.plugins.openselected.filemanager .. " " .. text)
end,
})
keymap.add { ["ctrl+shift+o"] = "open-selected:open-selected" }
+