How to execute any code when opening the lua shell? In bash , for example, there is ~/.bashrc .
1 answer
from man lua :
LUA_INIT_5_2 or LUA_INIT, in that order. If the contents is of the form '@filename', then the filename is executed. Otherwise, the statement was executed.
my free translation:
at the very beginning, even before processing the command line, lua checks the contents of the LUA_INIT_5_2 environment variable (for version 5.2) or LUA_INIT, in that order. if the content is of the form
@имя_файла, the file with that name is executed. otherwise, the string is treated as a lua expression and executed.
so on the same ~/.bashrc you can add something like:
export LUA_INIT="@/путь/к/файлу" and this file will be a kind of analogue of the initialization file.
however, it will be executed not only when an interactive mode is called.
- I have this kind of crap in Bashr:
export LUA_INIT="_PROMPT='\27[32m;\27[0m '_PROMPT2='\27[45m \27[0m '"- Egor Skriptunoff - And how to find out, interactive or not? - val
- one@val, probably after analyzing the arguments. - aleksandr barakin