Ticket #4203: support custom .zshrc.

Custom .zshrc file is  ~/.local/share/mc/.zshrc.

If ZDOTDIR environment variable is not set, set it to ~/.local/share/mc
if a .zshrc is found there. It is the only way to point zsh to an other
rc file than the default.

Thanks Sebastian Gniazdowski <sgniazdowski@gmail.com> for the original
patch.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
Andrew Borodin 2021-02-28 17:56:46 +03:00
parent e50a4d0e25
commit 76847e08fd
6 changed files with 44 additions and 13 deletions

View File

@ -2465,7 +2465,10 @@ and special keyboard maps in ~/.local/share/mc/inputrc (fallback ~/.inputrc).
.B ash/dash
users (BusyBox or Debian) may specify startup commands in ~/.local/share/mc/ashrc (fallback ~/.profile).
.PP
.B tcsh, zsh, fish
.B zsh
users may specify startup commands in ~/.local/share/mc/.zshrc (fallback ~/.zshrc).
.PP
.B tcsh, fish
users cannot specify mc-specific startup commands at present. They have to rely on
shell-specific startup files.
.PP

View File

@ -2801,6 +2801,11 @@ subshell, в файле
.B ~/.local/share/mc/bashrc
и специальную карту раскладки клавиатуры в файле
.BR ~/.local/share/mc/inputrc .
Если вы используете
.BR zsh ,
можно указать команды, которые будут выполняться при запуске
subshell, в файле
.B ~/.local/share/mc/.zshrc .
Пользователи
.B tcsh
могут задать выполняемые при запуске команды в файле

View File

@ -52,6 +52,7 @@
#define MC_EXTFS_DIR "extfs.d"
#define MC_BASHRC_FILE "bashrc"
#define MC_ZSHRC_FILE ".zshrc"
#define MC_CONFIG_FILE "ini"
#define MC_FILEBIND_FILE "mc.ext"
#define MC_FILEPOS_FILE "filepos"

View File

@ -77,6 +77,7 @@ static const struct
{ &mc_data_str, "ashrc" },
{ &mc_data_str, "bashrc" },
{ &mc_data_str, "inputrc" },
{ &mc_data_str, MC_ZSHRC_FILE },
{ &mc_data_str, MC_EXTFS_DIR },
{ &mc_data_str, MC_HISTORY_FILE },
{ &mc_data_str, MC_FILEPOS_FILE },

View File

@ -97,6 +97,7 @@
#include "lib/global.h"
#include "lib/fileloc.h"
#include "lib/unixcompat.h"
#include "lib/tty/tty.h" /* LINES */
#include "lib/tty/key.h" /* XCTRL */
@ -370,9 +371,26 @@ init_subshell_child (const char *pty_name)
break;
/* TODO: Find a way to pass initfile to TCSH, ZSH and FISH */
case SHELL_TCSH:
case SHELL_ZSH:
/* ZDOTDIR environment variable is the only way to point zsh
* to an other rc file than the default. */
/* Don't overwrite $ZDOTDIR */
if (g_getenv ("ZDOTDIR") != NULL)
{
/* Do we have a custom init file ~/.local/share/mc/.zshrc?
* Otherwise use standard ~/.zshrc */
init_file = mc_config_get_full_path (MC_ZSHRC_FILE);
if (exist_file (init_file))
{
/* Set ZDOTDIR to ~/.local/share/mc */
g_setenv ("ZDOTDIR", mc_config_get_data_path (), TRUE);
}
}
break;
/* TODO: Find a way to pass initfile to TCSH and FISH */
case SHELL_TCSH:
case SHELL_FISH:
break;
@ -416,7 +434,6 @@ init_subshell_child (const char *pty_name)
/* Use -g to exclude cmds beginning with space from history
* and -Z to use the line editor on non-interactive term */
execl (mc_global.shell->path, "zsh", "-Z", "-g", (char *) NULL);
break;
case SHELL_ASH_BUSYBOX:

View File

@ -134,37 +134,41 @@ static const struct test_user_config_paths_ds
},
{ /* 14. */
CONF_DATA,
MC_EXTFS_DIR
MC_ZSHRC_FILE
},
{ /* 15. */
CONF_DATA,
MC_HISTORY_FILE
MC_EXTFS_DIR
},
{ /* 16. */
CONF_DATA,
MC_FILEPOS_FILE
MC_HISTORY_FILE
},
{ /* 17. */
CONF_DATA,
EDIT_HOME_CLIP_FILE
MC_FILEPOS_FILE
},
{ /* 18. */
CONF_DATA,
MC_MACRO_FILE
EDIT_HOME_CLIP_FILE
},
{ /* 19. */
CONF_CACHE,
"mc.log"
CONF_DATA,
MC_MACRO_FILE
},
{ /* 20. */
CONF_CACHE,
MC_TREESTORE_FILE
"mc.log"
},
{ /* 21. */
CONF_CACHE,
EDIT_HOME_TEMP_FILE
MC_TREESTORE_FILE
},
{ /* 22. */
CONF_CACHE,
EDIT_HOME_TEMP_FILE
},
{ /* 23. */
CONF_CACHE,
EDIT_HOME_BLOCK_FILE
},