diff options
| -rw-r--r-- | src/lua_api.c | 9 | ||||
| -rw-r--r-- | src/lush.c | 4 |
2 files changed, 8 insertions, 5 deletions
diff --git a/src/lua_api.c b/src/lua_api.c index 77417db..99892c7 100644 --- a/src/lua_api.c +++ b/src/lua_api.c @@ -87,10 +87,13 @@ void lua_load_script(lua_State *L, const char *script, char **args) { void lua_run_init(lua_State *L) { char script_path[64]; - snprintf(script_path, sizeof(script_path), ".lush/%s", "init.lua"); - lua_load_script(L, script_path, NULL); + const char *home_dir = getenv("HOME"); + if (home_dir != NULL) { + snprintf(script_path, sizeof(script_path), "%s/.lush/init.lua", + home_dir); + lua_load_script(L, script_path, NULL); + } } - // -- C funtions -- static int execute_command(lua_State *L, const char *line) { int status = 0; @@ -624,7 +624,6 @@ char *get_suggestions_path(const char *str) { strncpy(result, str, length); result -= 2; result[length + 2] = '\0'; - printf("%s", result); return result; } @@ -664,7 +663,7 @@ static void reprint_buffer(char *buffer, int *last_lines, int *pos, strncpy(suggestion, autocomplete_suggestion, PATH_MAX); } - free(suggestions_path); + // free(suggestions_path); int num_lines = ((strlen(buffer) + prompt_length + 1) / width) + 1; int cursor_pos = (prompt_length + *pos + 1) % width; @@ -724,6 +723,7 @@ static void reprint_buffer(char *buffer, int *last_lines, int *pos, ((strlen(buffer) + strlen(suggestion) + prompt_length + 1) / width) + 1; if (suggested_lines > num_lines) printf("\033[A"); + // cleanup free(prompt); old_buffer_len = strlen(buffer); |
