-
-
Notifications
You must be signed in to change notification settings - Fork 8
Linux Bonus Shebangs & Desktop Files
A 'Shebang' is Linux feature in which files in plain text can be executed with a program due to adding a line at the very first line of a file. The presence of the line does not affect the functionality of the plain text file.
Typically with bash or sh scripts, the prefixed shebang is one of the following.
#!/bin/bash
...
#!/bin/sh
...
#!/usr/bin/env bash
...
A typical place to install LuaConsole would be `/opt/local/bin` with libraries residing in `/opt/local/lib` and the liblc*.so residing with the executable. I have not tested the ability to put liblc*.so into `/opt/local/lib` nor `/opt/local/bin` and have it work. Because of the self-contained nature of the program, it's a bit weird installing the program globally. So `jit/*` and `lang/*` have to be remote of the cwd. I have not tested installing said files outside of being in cwd. This will change eventually to allow global installs on linux, sorry.
./usr/local/bin/luaw
./usr/local/bin/liblcluajit.so
./usr/local/lib/libluajit.so
./jit
./lang
./res
Once you get the environment set up how you like, for all future .lua files you produce you can prepend the file with the path to the luaw executable file. It's very easy to do. If you have some common feature that you require, you can also add arguments such as -p to keep the program alive at the end of a script and REPL. It's recommended that you always start this script with a terminal present or you may have it running dead in the background. My favorite feature of this is being able to specify which lua version you require at minimum with the -w switch. Note when doing this, you can only supply ONE argument so it has to be put explicitly as `-wlua-5.4.2`.
some_example.lua
#!/usr/local/bin/luaw -wlua-5.4.2
print('hello world')
Then you can execute it as follows:
./some_example.lua
For users with desktop icons, you can create a desktop file which is the equivalent to softlinks in windows.
luaw.desktop
[Desktop Entry]
Encoding=UTF-8
Version=1.0
Name=LuaConsole
GenericName=Terminal REPL Application
Type=Application
Comment=LuaConsole Luaw REPL
Categories=Development;ConsoleOnly;
Exec=luaw
Icon=/path/to/icon
Path=/opt/local/bin
Terminal=true
NoDisplay=true
MimeType=text/lua
Terminal Commands
desktop-file-validate luaw.desktop
desktop-file-install --dir=~/Desktop luaw.desktop
update-desktop-database ~/Desktop