Support user prompt in fallback precmd emulation

This commit is contained in:
d3m3t3r 2024-11-26 18:59:24 +00:00
parent dad5c64f6b
commit b4c318d761

View File

@ -1152,18 +1152,19 @@ init_subshell_precmd (char *precmd, size_t buff_size)
*/ */
static const char *precmd_fallback = static const char *precmd_fallback =
" " /* Useful if the shell supports HISTCONTROL=ignorespace like functionality */ " " /* Useful if the shell supports HISTCONTROL=ignorespace like functionality */
"MC_PS1_SAVED=\"$PS1\"; " /* Save custom PS1 */
"precmd() { " "precmd() { "
"if [ ! \"${PWD##$HOME}\" ]; then " "if [ ! \"${PWD##$HOME}\" ]; then "
"MC_PWD=\"~\"; " "MC_PWD=\"~\"; "
"else " "else "
"[ \"${PWD##$HOME/}\" = \"$PWD\" ] && MC_PWD=\"$PWD\" || MC_PWD=\"~/${PWD##$HOME/}\"; " "[ \"${PWD##$HOME/}\" = \"$PWD\" ] && MC_PWD=\"$PWD\" || MC_PWD=\"~/${PWD##$HOME/}\"; "
"fi; " "fi; "
"echo \"$USER@$(hostname -s):$MC_PWD\"; " "echo \"${MC_PS1_SAVED:-$USER@$(hostname -s):$MC_PWD\\$ }\"; "
"pwd>&%d; " "pwd>&%d; "
"kill -STOP $$; " "kill -STOP $$; "
"}; " "}; "
"PRECMD=precmd; " "PRECMD=precmd; "
"PS1='$($PRECMD)$ '\n"; "PS1='$($PRECMD)'\n";
switch (mc_global.shell->type) switch (mc_global.shell->type)
{ {