search for kakrc next to the kak executable instead of in the current directory

This commit is contained in:
Maxime Coste 2011-12-28 22:57:48 +00:00
parent ee7bc9ddc0
commit e59bdd931e

View File

@ -886,7 +886,15 @@ int main(int argc, char* argv[])
try
{
exec_commands_in_file({ "kakrc" }, main_context);
const char* kakrc = "kakrc";
char buffer[2048];
readlink("/proc/self/exe", buffer, 2048 - strlen(kakrc));
char* ptr = strrchr(buffer, '/');
if (ptr)
{
strcpy(ptr+1, kakrc);
exec_commands_in_file({ buffer }, main_context);
}
}
catch (Kakoune::runtime_error& error)
{