Search code examples
prompttcshmc

Prompt is different in midnight-commander (mc) subshell


The problem first: The subshell of mc has a different prompt compared to the parent shell and my tcsh environment. All the other settings/variables/aliases are available in mc's subshell, only the prompt is not "passed" correctly it seems. I have no idea why that happens. Man page says:

An  extra  added  feature  of using the subshell is that the prompt displayed by the Midnight Commander is the same prompt that you are currently using in your shell.

Background: I am using mc.4.8.23 which I have installed on my own locally (because no root permission). Did basically those two steps:

./configure --prefix=<absolute path>/eda_tools/mc/mc-4.8.23/install --bindir=<absolute path>/eda_tools/mc/mc-4.8.23/bin --with-screen=ncurses
make install

Rest of mc works fine.

What I have tried so far:

  • putting a test prompt and a test alias into tcshrc within ~/.config/mc & ~/.mc & ~/.local/share/mc. None of those locations seem to be evaluated at mc startup. I can neither see a changed prompt, nor the test alias.
  • Have temporarily changed the prompt within .cshrc to a very simple one. Did not help.
  • changing the prompt on-the-fly within the mc's subshell does temporarily work. So it seems, that the prompt string itself is OK and understood.

Does someone has an idea?


Solution

  • The prompt for tcsh is hard coded in the source file src/subshell/common.c in function init_subshell_precmd. To keep your prompt recompile mc with this patch applied:

    --- src/subshell/common.c.org   2019-06-16 19:49:31.041841616 +0200
    +++ src/subshell/common.c       2020-01-12 14:17:03.928956667 +0100
    @@ -886,7 +886,6 @@
         case SHELL_TCSH:
             g_snprintf (precmd, buff_size,
                         "set echo_style=both; "
    -                    "set prompt='%%n@%%m:%%~%%# '; "
                         "alias precmd 'echo $cwd:q >>%s; kill -STOP $$'\n", tcsh_fi
             break;