aboutsummaryrefslogtreecommitdiffstats
path: root/.lush/scripts/example.lua
diff options
context:
space:
mode:
authorGravatar BanceDev 2024-09-08 17:05:31 -0400
committerGravatar BanceDev 2024-09-08 17:05:31 -0400
commitbfa2768e223456fc6d4754dfffa0ada8b88620e9 (patch)
treea4fb83e6a4c481e7e82861bb19b80de308fffb2b /.lush/scripts/example.lua
parentadded support for cli args for lua scripts (diff)
added lua api functions for indexing history
Diffstat (limited to '.lush/scripts/example.lua')
-rw-r--r--.lush/scripts/example.lua7
1 files changed, 7 insertions, 0 deletions
diff --git a/.lush/scripts/example.lua b/.lush/scripts/example.lua
index ffd04c1..53ee6e8 100644
--- a/.lush/scripts/example.lua
+++ b/.lush/scripts/example.lua
@@ -27,6 +27,7 @@ print("Welcome to Lunar Shell scripting")
-- done like so: example.lua arg1 arg2 ...
-- args can be read using the global args tables
if args ~= nil then
+ print("Printing args:")
for i = 1, #args do
print(args[i])
end
@@ -75,3 +76,9 @@ end
if lush.isWriteable("~/.lush/scripts/example.lua") then
print("example.lua is writeable")
end
+
+-- you can fetch the most recently executed command in history
+print("Most recent history: " .. lush.lastHistory())
+
+-- you can also fetch history at a certain index in the past (1 being most recent)
+print("Most recent history indexed: " .. lush.getHistory(1))