8

I often use the subshell of mc. So I want the promt of mc-subsell to be different form the primary shell. Say, how can I change the sub-prompt like this:

mc:$Current_dir$

many thanks

mdpc
  • 4,429
  • 9
  • 28
  • 36
lymslive
  • 81
  • 1
  • 2

2 Answers2

4

This page may help you. An excerpt:

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.

What you wanted:

if ps $PPID |grep mc; then
    PS1="mc: \w"
fi
Jakob Weisblat
  • 1,016
  • 1
  • 11
  • 30
  • Thank you, I've got it. and I modified it like this to support color: PS1='\[\033[01;32m\]mc:\[\033[01;34m\]\w\[\033[00m\]\$ ' – lymslive Jan 01 '13 at 02:59
  • If my answer solved your question, you can click the hollow green check mark on the left to accept it. – Jakob Weisblat Jan 01 '13 at 20:21
3

I had faced with the same problem, before I found a recipe: put the following text into the file ~/.local/share/mc/bashrc :

#!/bin/bash

if [ -f $HOME/.bashrc ]; then
        . $HOME/.bashrc
else
        if [ -f /etc/bashrc ]; then
                . /etc/bashrc
        fi
fi

if [ -z "$PS1" ]; then
        PS1="(mc)[\u@\h \W]\$ "
else
        old_PS1=$PS1
        export PS1="(mc)$old_PS1"
fi

or according to your need:

#!/bin/bash

if [ -f $HOME/.bashrc ]; then
        . $HOME/.bashrc
else
        if [ -f /etc/bashrc ]; then
                . /etc/bashrc
        fi
fi

PS1="mc:\$\W\$ "