]> git.phdru.name Git - dotfiles.git/commitdiff
bash: Append `$SHLVL` number of `\$` to `$PS1`
authorOleg Broytman <phd@phdru.name>
Sun, 10 May 2020 17:58:04 +0000 (20:58 +0300)
committerOleg Broytman <phd@phdru.name>
Mon, 11 May 2020 17:15:20 +0000 (20:15 +0300)
.shellrc

index fd73f152065c9795cfab10fdfef5686b62d76f2d..5b1e1d3db39e784807906f1446974f0824843281 100644 (file)
--- 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 "