From: Oleg Broytman Date: Sun, 10 May 2020 17:58:04 +0000 (+0300) Subject: bash: Append `$SHLVL` number of `\$` to `$PS1` X-Git-Url: https://git.phdru.name/?p=dotfiles.git;a=commitdiff_plain;h=1102e6b795191917acd9686e93af3c48b0ed3fc3 bash: Append `$SHLVL` number of `\$` to `$PS1` --- diff --git a/.shellrc b/.shellrc index fd73f15..5b1e1d3 100644 --- a/.shellrc +++ b/.shellrc @@ -58,7 +58,13 @@ case "$HOME" in esac -OPS1="$OPS1\\$" +# Remove trainling \$s +OPS1="`echo $OPS1 | sed 's/[ \\$]\+$//'`" +# Add a trainling space +OPS1="$OPS1 " +# Re-add trainling \$ +for ((i=0; i<$SHLVL; i++)); do OPS1="$OPS1\\$"; done + PS1="$OPS1 "