From e7cbf38af74b7841baf350ddcc85699d2295aeb7 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Fri, 19 Jan 2018 10:05:08 +1100 Subject: Introduce a $kak_config env var containing the Kakoune user config dir Makes it easier for users who want to locate their kakrc file, and does not require to go through shell expansion to get it as "${XDG_CONFIG_DIR:-${HOME}/.config}/kak" Fixes #1740 --- src/main.cc | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src') diff --git a/src/main.cc b/src/main.cc index b9f995f6..aff7f9f2 100644 --- a/src/main.cc +++ b/src/main.cc @@ -68,6 +68,14 @@ String runtime_directory() return "/usr/share/kak"; } +String config_directory() +{ + StringView config_home = getenv("XDG_CONFIG_HOME"); + if (config_home.empty()) + return format("{}/.config/kak", getenv("HOME")); + return format("{}/kak", config_home); +} + void register_env_vars() { static const struct { @@ -112,6 +120,10 @@ void register_env_vars() "runtime", false, [](StringView name, const Context& context) { return runtime_directory(); } + }, { + "config", false, + [](StringView name, const Context& context) + { return config_directory(); } }, { "opt_", true, [](StringView name, const Context& context) -- cgit v1.2.3