aboutsummaryrefslogtreecommitdiffstats
path: root/.lush
diff options
context:
space:
mode:
Diffstat (limited to '.lush')
-rw-r--r--.lush/scripts/example.lua21
1 files changed, 19 insertions, 2 deletions
diff --git a/.lush/scripts/example.lua b/.lush/scripts/example.lua
index 0357276..279ad5e 100644
--- a/.lush/scripts/example.lua
+++ b/.lush/scripts/example.lua
@@ -15,10 +15,27 @@ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
]]
+-- This file is a demo of all of the commands Lunar Shell has in its Lua API
-- the Lua file itself is the executable unit so all code is run line by line
--- the print function can be used to write to the console
+-- All Lua specific tools still work here too. Functions, loops, conditionals,
+-- tables, Lua's standard library, etc are all available to integrate with Lunar Shell
+
print("Welcome to Lunar Shell scripting")
-- exec can be used to run any command line prompt
-exec('echo "hello world"\n')
+-- this method is much more native than using os.execute and is the recommended function
+-- it also returns a boolean on if the command executed successfully
+if lush.exec('echo "hello world"\n') then
+ print("echo worked properly")
+end
+
+-- getcwd returns the current working directory
+local cwd = lush.getcwd()
+print(cwd)
+
+-- exec also supports piping
+-- this comment will get grepped since it says hello
+lush.exec("cd " .. os.getenv("HOME") .. "/.lush/scripts")
+lush.exec('cat "example.lua" | grep "hello" | sort | uniq')
+lush.exec("cd " .. cwd)
ss='insertions'>+18 2024-09-11spelling error in readme demoGravatar BanceDev 1-0/+0 2024-09-11updated readme with visualsGravatar BanceDev 2-0/+4 2024-09-11fixed off-by-one error with prompt wrappingGravatar BanceDev 1-11/+89 2024-09-10added tab to accept inline autocompleteGravatar BanceDev 1-9/+85 2024-09-10basic current directory suggestionsGravatar BanceDev 1-9/+146 2024-09-10made it so that lua args properly reset between commandsGravatar BanceDev 1-0/+4 2024-09-10removed demo image to cleanupGravatar Lance Borden 2-4/+1 2024-09-10higher quality image for readmeGravatar BanceDev 1-0/+0 2024-09-10added better demo to readmeGravatar BanceDev 2-0/+10 2024-09-10added handling for when prompt gets longer than terminal widthGravatar BanceDev 1-0/+36 2024-09-10added support for multiline promptsGravatar BanceDev 1-4/+35 2024-09-10lua api functions for getting terminal width and heightGravatar BanceDev 4-0/+46 2024-09-09added coloring to help commandGravatar BanceDev 1-2/+2 2024-09-09add aliasing to init.luaGravatar BanceDev 9-14/+258 2024-09-09bugfix to inline backspace and delete on multiline bufferGravatar BanceDev 1-7/+23 2024-09-09fixed line wrapping when deleting inlineGravatar BanceDev 1-0/+8 2024-09-09updated gitignoreGravatar BanceDev 2-1/+2 2024-09-09fixed wrapping bug due to not using updated prompt_lengthGravatar BanceDev 1-3/+6 2024-09-09added stripping of escape sequences from prompt size to allow for coloringGravatar BanceDev 1-5/+26 2024-09-09added support for init.lua for configuring shellGravatar BanceDev 8-38/+180 2024-09-09docs: update pathGravatar Christopher Lane 1-1/+1 Updated the path to the example script and fixed a typo in the readme 2024-09-08added getenv and putenv to Lua APIGravatar BanceDev 2-5/+33 fixed bug where terminal closed upon encountering Lua error 2024-09-08added lua api functions for indexing historyGravatar BanceDev 2-0/+35 2024-09-08added support for cli args for lua scriptsGravatar BanceDev 4-3/+28 2024-09-07added --version flagGravatar BanceDev 1-1/+9 2024-09-07fixed error in install.sh instructionsGravatar BanceDev 1-1/+1 2024-09-07fixed bug with cursor alignment when adding text within the bufferGravatar BanceDev 1-1/+11 2024-09-06added API guide to readmeGravatar BanceDev 1-1/+5 2024-09-06Update README.mdGravatar Lance Borden 1-1/+1 2024-09-06better readmeGravatar BanceDev 2-2/+14