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
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
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
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\$ "
If you look in ~/.local/share/mc/ you will find (or can create) a file called bashrc ...This is the bashrc that is used by mc for its subshell.
** You WILL need to quit mc and start it again to pick up changes to this file!
The specific prompt you requested would require this line:
export PS1="mc:\$PWD\$"
But there are plenty of options available, including colour:
BLK="\[\e[0;30m\]"
GRY="\[\e[1;30m\]"
RED="\[\e[0;31m\]"
LRED="\[\e[1;31m\]"
GRN="\[\e[0;32m\]"
LGRN="\[\e[1;32m\]"
BRN="\[\e[0;33m\]"
YEL="\[\e[1;33m\]"
BLU="\[\e[0;34m\]"
LBLU="\[\e[1;34m\]"
MAG="\[\e[0;35m\]"
LMAG="\[\e[1;35m\]"
CYN="\[\e[0;36m\]"
LCYN="\[\e[1;36m\]"
WHT="\[\e[0;37m\]"
BWHT="\[\e[1;37m\]"
OFF="\[\e[m\]"
|user |@ |host |: |path |errorlevel |time |\n |$ |> |
export PS1=${LGRN}"\u"${BRN}"@"${GRN}"\h"${BRN}":"${LBLU}"$PWD"${GRY}" [$?]"${BLU}" \t""\n"${LGRN}"$"${BWHT}">"${OFF}
You may also wish to set PS2 which is the prompt used when you continue a line ...Here is it set to +>:
mc:/home/user/$ echo foo \
+> | sed s/foo/bar/
For completeness: PS3 is used by select ... and PS4 is used during a shell trace (eg. set -x)