How to change shell prompt in Midnight Commander

Bash allows users to do very advanced things when defining shell prompt, including colours and propagation of information into xterm title. Unfortunately, when you want to use mc (Midnight Commander) in conjunction with bash prompts, you may find, that not all advanced escape sequences are handled by mc properly. To overcome this issue you can have a special prompt just for mc. To achieve that, consider the following shell sniplet:

  1.     if ps $PPID |grep mc; then
  2.         PS1="[\u@\h:\w]\$ "
  3.     else
  4.         PS1="${TITLEBAR}\
  5. $BLUE[$RED\$(date +%H%M)$BLUE]\
  6. $BLUE[$LIGHT_RED\u@\h:\w$BLUE]\
  7. $WHITE\$$NO_COLOUR "
  8.     fi

The resulting prompt will look something like this:

  1. [andre@host:/a/b/c/project/subproject]$ |

3 Comments

I think the better idea is to

I think the better idea is to create (or modify) this file ~/.local/share/mc/bashrc.
This file will be used as a sub-shell rc-file.

Add new comment

Subscribe to Comments for "How to change shell prompt in Midnight Commander"