aboutsummaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorrxi <rxi@users.noreply.github.com>2020-08-28 15:37:40 +0100
committerrxi <rxi@users.noreply.github.com>2020-08-28 15:38:00 +0100
commitea3ad14c17684e438c560fd36bf5e5d7c58a4389 (patch)
tree6bf4a582daa7837afd26fe6e9cc4da06d2e54a4f /plugins
parentc812288925605c649f1c09e386ea7b07fab602e9 (diff)
downloadlite-xl-plugins-ea3ad14c17684e438c560fd36bf5e5d7c58a4389.tar.gz
lite-xl-plugins-ea3ad14c17684e438c560fd36bf5e5d7c58a4389.zip
Added lastproject plugin
Diffstat (limited to 'plugins')
-rw-r--r--plugins/lastproject.lua26
1 files changed, 26 insertions, 0 deletions
diff --git a/plugins/lastproject.lua b/plugins/lastproject.lua
new file mode 100644
index 0000000..09ca507
--- /dev/null
+++ b/plugins/lastproject.lua
@@ -0,0 +1,26 @@
+local core = require "core"
+
+local last_project_filename = EXEDIR .. PATHSEP .. ".lite_last_project"
+
+
+-- load last project path
+local fp = io.open(last_project_filename)
+local project_path
+if fp then
+ project_path = fp:read("*a")
+ fp:close()
+end
+
+
+-- save current project path
+local fp = io.open(last_project_filename, "w")
+fp:write(system.absolute_path ".")
+fp:close()
+
+
+-- restart using last project path if we had no commandline arguments and could
+-- find a last-project file
+if #ARGS == 1 and project_path then
+ system.exec(string.format("%s %q", EXEFILE, project_path))
+ core.quit(true)
+end