Skip to content

Instantly share code, notes, and snippets.

@doyousketch2
Created September 5, 2019 02:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save doyousketch2/dc235583e02f6dc9df5197e0ed2458b9 to your computer and use it in GitHub Desktop.
Save doyousketch2/dc235583e02f6dc9df5197e0ed2458b9 to your computer and use it in GitHub Desktop.
Run your Lua / Love2D scripts within gEdit -- F5
#! /bin/dash
# [Gedit Tool]
# Name=Run Lua / Love2D
# Languages=lua
# Shortcut=F5
# Input=nothing
# Output=output-panel
# Applicability=local
# Save-files=document
## place in ~/.config/gedit/tools/
## usually only name my Love2D scripts "main.lua" so this method works well.
## other Lua scripts will execute w/ your system Lua instead.
looking_for_lua=true
if [ -e main.lua ] ; then ## try current dir
looking_for_lua=false
love .
else if [ -e ../main.lua ] ; then ## try parent dir
looking_for_lua=false
love ../.
else if [ -e ../../main.lua ] ; then ## try grandparent dir
looking_for_lua=false
love ../../.
else if [ -e ../../../main.lua ] ; then ## one more for good measure
looking_for_lua=false
love ../../../.
fi
fi
fi
fi
## haven't found a Love2D script, try running it in Lua instead
if [ $looking_for_lua ] ; then
lua $GEDIT_CURRENT_DOCUMENT_PATH
fi
## You can nest the "main.lua" search further than 4 deep if you really need to,
## but this seems to suit my purpose. I wouldn't want it traversing
## nonstop up the filesystem hunting for something that doesn't exist.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment