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 =
" " /* Useful if the shell supports HISTCONTROL=ignorespace like functionality */
"MC_PS1_SAVED=\"$PS1\"; " /* Save custom PS1 */
"precmd() { "
"if [ ! \"${PWD##$HOME}\" ]; then "
"MC_PWD=\"~\"; "
"else "
"[ \"${PWD##$HOME/}\" = \"$PWD\" ] && MC_PWD=\"$PWD\" || MC_PWD=\"~/${PWD##$HOME/}\"; "
"fi; "
"echo \"$USER@$(hostname -s):$MC_PWD\"; "
"echo \"${MC_PS1_SAVED:-$USER@$(hostname -s):$MC_PWD\\$ }\"; "
"pwd>&%d; "
"kill -STOP $$; "
"}; "
"PRECMD=precmd; "
"PS1='$($PRECMD)$ '\n";
"PS1='$($PRECMD)'\n";
switch (mc_global.shell->type)
{