From 1102e6b795191917acd9686e93af3c48b0ed3fc3 Mon Sep 17 00:00:00 2001 From: Oleg Broytman Date: Sun, 10 May 2020 20:58:04 +0300 Subject: [PATCH] bash: Append `$SHLVL` number of `\$` to `$PS1` --- .shellrc | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) 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 " -- 2.39.2