Skip to content

Commit

Permalink
subshell: support user prompt in fallback precmd emulation
Browse files Browse the repository at this point in the history
Signed-off-by: Yury V. Zaytsev <[email protected]>
  • Loading branch information
d3m3t3r authored and zyv committed Jan 15, 2025
1 parent 0c9a190 commit f609f6c
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions src/subshell/common.c
Original file line number Diff line number Diff line change
Expand Up @@ -1151,20 +1151,23 @@ init_subshell_precmd (char *precmd, size_t buff_size)
* "PRECMD=precmd; "
* "PS1='$($PRECMD)$ '\n",
*/
/* *INDENT-OFF* */
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() { "
"if [ ! \"${PWD##$HOME}\" ]; then "
"MC_PWD=\"~\"; "
"else "
"[ \"${PWD##$HOME/}\" = \"$PWD\" ] && MC_PWD=\"$PWD\" || MC_PWD=\"~/${PWD##$HOME/}\"; "
"fi; "
"echo \"$USER@$(hostname -s):$MC_PWD\"; "
"pwd>&%d; "
"kill -STOP $$; "
" if [ ! \"${PWD##$HOME}\" ]; then "
" MC_PWD=\"~\"; "
" else "
" [ \"${PWD##$HOME/}\" = \"$PWD\" ] && MC_PWD=\"$PWD\" || MC_PWD=\"~/${PWD##$HOME/}\"; "
" fi; "
" echo \"${MC_PS1_SAVED:-$USER@$(hostname -s):$MC_PWD\\$ }\"; "
" pwd>&%d; "
" kill -STOP $$; "
"}; "
"PRECMD=precmd; "
"PS1='$($PRECMD)$ '\n";
"PS1='$($PRECMD)'\n";
/* *INDENT-ON* */

switch (mc_global.shell->type)
{
Expand Down

0 comments on commit f609f6c

Please sign in to comment.