Super simple script for running love projects on mac

Showcase your libraries, tools and other projects that help your fellow love users.
User avatar
Johannes
Prole
Posts: 18
Joined: Sat Jun 08, 2013 6:51 pm

Super simple script for running love projects on mac

Post by Johannes »

Probably nothing new, but I made this for my own projects and thought it might be useful for anyone that wants an easy way to test their löve project but doesn't want to have to set up anything fancy, use the terminal, or have to drag+drop the folder onto love.app
run_in_love.zip
Super simple Löve script for mac
(671 Bytes) Downloaded 264 times
All you have to do is drop the 'run_in_love' file in the folder with your main.love and double click it.
You can just copy and paste the file into any Love Project and it will just work. :ultraglee:
MZK7YDv.png
MZK7YDv.png (10.26 KiB) Viewed 665 times
Here's what the script contains:

Code: Select all

#!/bin/sh
/Applications/love.app/Contents/MacOS/love "${0%/*}"
It really couldn't be much simpler :awesome: It just passes the directory that the script is in to the love application (which should be in the applications folder)


Note: If double clicking does not work, you will need to make the 'run_in_love' file executable. You can do this by:
  • 1. Opening a new terminal window
    2. Typing in 'chmod +x ' (including the last space)
    3. Dragging the file into the terminal, which will add its file path, finally pressing enter
User avatar
Jasoco
Inner party member
Posts: 3727
Joined: Mon Jun 22, 2009 9:35 am
Location: Pennsylvania, USA
Contact:

Re: Super simple script for running love projects on mac

Post by Jasoco »

This is how I do it. Except that I name the file with a .command extension which gives it an icon with the Terminal on it. I then attach that .command file to a hotkey I set up via BetterTouchTool (Command+Shift+R) so I can run it on a whim. Saves me sooooo much time.
User avatar
Johannes
Prole
Posts: 18
Joined: Sat Jun 08, 2013 6:51 pm

Re: Super simple script for running love projects on mac

Post by Johannes »

Jasoco wrote:This is how I do it. Except that I name the file with a .command extension which gives it an icon with the Terminal on it. I then attach that .command file to a hotkey I set up via BetterTouchTool (Command+Shift+R) so I can run it on a whim. Saves me sooooo much time.
Ooh, I did not know about .command, that does seem to have some nice benefits like:
- Being able to quick look at the contents (normal shell script will just show 'Exec' icon)
- If permissions are not set it will actually tell the user, and not try to open it in some other application like xcode.

Are there any other benefits to using .command?
User avatar
Lafolie
Inner party member
Posts: 809
Joined: Tue Apr 05, 2011 2:59 pm
Location: SR388
Contact:

Re: Super simple script for running love projects on mac

Post by Lafolie »

Why not use the build system on your text editor? From the editor I use F8 (the Apple keyboard has a play icon on this key), and boom, game. I use a love alias from my .bash_profile, and even outside of the text editor I'm usually cd'd into the project dir if I'm working on it, which means "love ." is all that is needed.
Do you recognise when the world won't stop for you? Or when the days don't care what you've got to do? When the weight's too tough to lift up, what do you? Don't let them choose for you, that's on you.
User avatar
Johannes
Prole
Posts: 18
Joined: Sat Jun 08, 2013 6:51 pm

Re: Super simple script for running love projects on mac

Post by Johannes »

Lafolie wrote:Why not use the build system on your text editor? From the editor I use F8 (the Apple keyboard has a play icon on this key), and boom, game. I use a love alias from my .bash_profile, and even outside of the text editor I'm usually cd'd into the project dir if I'm working on it, which means "love ." is all that is needed.
I already have a build script set up for my editor (Sublime Text 2) and I also have the love alias set up in my bash profile.

I don't tend to use the terminal during my day-to-day work, so I'm not CD'd to my project dir, and just like being able to just quickly double clicking a file and it just working. The point here is utter simplicity and no need to set anything up :)
User avatar
Jasoco
Inner party member
Posts: 3727
Joined: Mon Jun 22, 2009 9:35 am
Location: Pennsylvania, USA
Contact:

Re: Super simple script for running love projects on mac

Post by Jasoco »

Johannes wrote:...I also have the love alias set up in my bash profile.
Just curious how to go about doing this? So I can just type "love" into the Terminal to have it run the binary without having to use its full path. I can't seem to figure that out so my current run script looks like this:

Code: Select all

#!/bin/bash
~/Documents/Coding\ Projects/LÖVE/Löve\ Apps/love.app/Contents/MacOS/love "${0%/*}"
(I keep my Löve apps in a separate folder to keep them from cluttering up my LaunchPad with apps I can't even launch normally anyway.)
User avatar
Dattorz
Citizen
Posts: 66
Joined: Sat Oct 27, 2012 12:32 am
Contact:

Re: Super simple script for running love projects on mac

Post by Dattorz »

I keep a terminal window open to my project directory and just type

Code: Select all

love .
and press Enter. Since it gets added to command history, I can just give the terminal window focus, then press Up and Enter to relaunch.

If you aren't on Linux you'll probably need to manually add love to your $PATH environment variable.

Edit: I'm not a Mac user, but I assume one could do something like this on OS X:

Code: Select all

open love .
User avatar
Jasoco
Inner party member
Posts: 3727
Joined: Mon Jun 22, 2009 9:35 am
Location: Pennsylvania, USA
Contact:

Re: Super simple script for running love projects on mac

Post by Jasoco »

I don't know how to add love to my OS X path. I even tried Googling. Didn't work.
User avatar
Lafolie
Inner party member
Posts: 809
Joined: Tue Apr 05, 2011 2:59 pm
Location: SR388
Contact:

Re: Super simple script for running love projects on mac

Post by Lafolie »

Open up Terminal and type:

Code: Select all

nano ~/.bash_profile
You may want to edit .bash_rc instead, but on 10.6.8 I find that .bash_profile seems to work while others do not.

Anyway, in that file, add the following line:

Code: Select all

alias love='/Applications/love.app/Contents/MacOS/love'
Press Ctrl-X (not Cmd) and then confirm to save.
Do you recognise when the world won't stop for you? Or when the days don't care what you've got to do? When the weight's too tough to lift up, what do you? Don't let them choose for you, that's on you.
User avatar
Dattorz
Citizen
Posts: 66
Joined: Sat Oct 27, 2012 12:32 am
Contact:

Re: Super simple script for running love projects on mac

Post by Dattorz »

Why not just put this in your bash profile?

Code: Select all

export PATH=$PATH:/Applications/love.app/Contents/MacOS
After all, that's what $PATH is for.
Post Reply

Who is online

Users browsing this forum: No registered users and 4 guests