Last active
December 15, 2015 10:39
-
-
Save losinggeneration/5246813 to your computer and use it in GitHub Desktop.
Lua path setting with ZSH functions. This is another reason why ZSH is awesome: macro shell scripting. This removes the need to duplicate code for each of these functions.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# useful for when you have multiple lua commands for different versions | |
for i in lua lua5.2 lua5.1 luajit; do | |
function $i() | |
{ | |
# Get Lua's version | |
local lua_version=$(command $0 -e "print(string.sub(_VERSION, -3))") | |
# Append to Lua's paths using normal shell variable interpolation | |
LUA_PATH=$(command $0 -e "print(package.path..';$HOME/.luarocks/share/lua/$lua_version/?.lua;$HOME/.luarocks/share/lua/$lua_version/?/init.lua;$HOME/.local/share/lua/$lua_version/?.lua;$HOME/.local/share/lua/$lua_version/?/init.lua')") \ | |
LUA_CPATH=$(command $0 -e "print(package.cpath..';$HOME/.luarocks/lib/lua/$lua_version/?.so;$HOME/.local/lib/lua/$lua_version/?.so')") \ | |
command $0 $* | |
} | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment