From e59bdd931e6fa3d4e0c9b7a5d97ca559f894a391 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Wed, 28 Dec 2011 22:57:48 +0000 Subject: [PATCH] search for kakrc next to the kak executable instead of in the current directory --- src/main.cc | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/main.cc b/src/main.cc index 11a317d22..1501b78c2 100644 --- a/src/main.cc +++ b/src/main.cc @@ -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) {