diff options
| author | Maxime Coste <mawww@kakoune.org> | 2018-01-19 10:05:08 +1100 |
|---|---|---|
| committer | Maxime Coste <mawww@kakoune.org> | 2018-01-19 10:05:08 +1100 |
| commit | e7cbf38af74b7841baf350ddcc85699d2295aeb7 (patch) | |
| tree | 6dabfe630a523b9fef6bfdb96743aa2ccfdc19f9 /src | |
| parent | 55621fb4cc9c01972317182dd6a8ed3ced0e1f9e (diff) | |
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
Diffstat (limited to 'src')
| -rw-r--r-- | src/main.cc | 12 |
1 files changed, 12 insertions, 0 deletions
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 { @@ -113,6 +121,10 @@ void register_env_vars() [](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) { return context.options()[name.substr(4_byte)].get_as_string(); } |
