aboutsummaryrefslogtreecommitdiff
path: root/plugins/openfilelocation.lua
diff options
context:
space:
mode:
authorrxi <rxi@users.noreply.github.com>2020-05-12 21:08:02 +0100
committerrxi <rxi@users.noreply.github.com>2020-05-12 21:08:02 +0100
commit38983228c83dcdf267a06be8b9174e233a082c76 (patch)
tree8bf1a7455c34c6fa1cb4e7a3b1a8043ae6274ad8 /plugins/openfilelocation.lua
parent21c2975b7e0ff3ba69dc0c550f034c1b3a9982f2 (diff)
downloadlite-xl-plugins-38983228c83dcdf267a06be8b9174e233a082c76.tar.gz
lite-xl-plugins-38983228c83dcdf267a06be8b9174e233a082c76.zip
Added `openselected` and `openfilelocation`
Diffstat (limited to 'plugins/openfilelocation.lua')
-rw-r--r--plugins/openfilelocation.lua28
1 files changed, 28 insertions, 0 deletions
diff --git a/plugins/openfilelocation.lua b/plugins/openfilelocation.lua
new file mode 100644
index 0000000..e57b740
--- /dev/null
+++ b/plugins/openfilelocation.lua
@@ -0,0 +1,28 @@
+local core = require "core"
+local command = require "core.command"
+local config = require "core.config"
+
+
+if PLATFORM == "Windows" then
+ config.filemanager = "explorer"
+else
+ config.filemanager = "xdg-open"
+end
+
+
+command.add("core.docview", {
+ ["open-file-location:open-file-location"] = function()
+ local doc = core.active_view.doc
+ if not doc.filename then
+ core.error "Cannot open location of unsaved doc"
+ return
+ end
+ local folder_name = doc.filename:match("^(.-)[^/\\]*$")
+ core.log("Opening \"%s\"", folder_name)
+ if PLATFORM == "Windows" then
+ os.execute(string.format("start %s %s", config.filemanager, folder_name))
+ else
+ os.execute(string.format("%s %q", config.filemanager, folder_name))
+ end
+ end
+})