From 26620f1618f74134cdb49c5cc4913ee76430285c Mon Sep 17 00:00:00 2001
From: Sebastian Gniazdowski <sgniazdowski@gmail.com>
Date: Tue, 16 Feb 2021 16:59:53 -0600
Subject: Support for custom .zshrc for Zsh subshell.
---
lib/mcconfig/paths.c | 1 +
src/subshell/common.c | 26 +++++++++++++++++++++++++-
2 files changed, 26 insertions(+), 1 deletion(-)
diff --git a/lib/mcconfig/paths.c b/lib/mcconfig/paths.c
index e111dc7a2..082f8226f 100644
a
|
b
|
static const struct |
81 | 81 | { "ashrc", &mc_data_str, "ashrc" }, |
82 | 82 | { "bashrc", &mc_data_str, "bashrc" }, |
83 | 83 | { "inputrc", &mc_data_str, "inputrc" }, |
| 84 | { ".zshrc", &mc_data_str, ".zshrc" }, |
84 | 85 | { "extfs.d", &mc_data_str, MC_EXTFS_DIR }, |
85 | 86 | { "history", &mc_data_str, MC_HISTORY_FILE }, |
86 | 87 | { "filepos", &mc_data_str, MC_FILEPOS_FILE }, |
diff --git a/src/subshell/common.c b/src/subshell/common.c
index 97cd78117..c7a9f0865 100644
a
|
b
|
init_subshell_child (const char *pty_name) |
359 | 359 | break; |
360 | 360 | |
361 | 361 | /* TODO: Find a way to pass initfile to TCSH, ZSH and FISH */ |
362 | | case SHELL_TCSH: |
363 | 362 | case SHELL_ZSH: |
| 363 | /* Do we have a custom init file ~/.local/share/mc/.zshrc? */ |
| 364 | init_file = mc_config_get_full_path (".zshrc"); |
| 365 | /* Otherwise use standard ~/.zshrc */ |
| 366 | if (!exist_file (init_file)) |
| 367 | MC_PTR_FREE (init_file); |
| 368 | else |
| 369 | { |
| 370 | /* Strip filename to set rcs dir via ZDOTDIR */ |
| 371 | char *tmp = init_file; |
| 372 | init_file = g_path_get_dirname(init_file); |
| 373 | g_free (tmp); |
| 374 | tmp = g_strconcat("ZDOTDIR=", init_file, (char *) NULL); |
| 375 | |
| 376 | /* Set ZDOTDIR to ~/.local/share/mc (if not configured differently) */ |
| 377 | if(putenv(tmp) != 0) |
| 378 | mc_log("ZDOTDIR set for Zsh shell failed"); |
| 379 | else |
| 380 | mc_log("Correctly set ZDOTDIR to: %s", strchr(tmp,'=')); |
| 381 | |
| 382 | /* Release the dir path string */ |
| 383 | g_free(init_file); |
| 384 | } |
| 385 | break; |
| 386 | |
| 387 | case SHELL_TCSH: |
364 | 388 | case SHELL_FISH: |
365 | 389 | break; |
366 | 390 | |