]> git.phdru.name Git - dotfiles.git/commitdiff
bash: Make `PS1` shorter and simpler
authorOleg Broytman <phd@phdru.name>
Thu, 14 May 2020 14:16:52 +0000 (17:16 +0300)
committerOleg Broytman <phd@phdru.name>
Thu, 14 May 2020 14:16:52 +0000 (17:16 +0300)
Do not repeat `$$$$`, instead display `$4`.

.profile
.shellrc

index 4e9958e77ef43e744245e8ca4bb17693eb308692..7c29d1686a09e6fb35c77fe857ef8cb97397aee5 100644 (file)
--- a/.profile
+++ b/.profile
@@ -192,7 +192,7 @@ if [ -t 0 ] ; then
          ;;
       esac
 
          ;;
       esac
 
-      OPS1=${OPS1}"${debian_chroot:+($debian_chroot)}\u@\h \W "
+      OPS1=${OPS1}"${debian_chroot:+($debian_chroot)}\u@\h \W \\$"
       . "$ENV"
 
    else
       . "$ENV"
 
    else
index aef34517a6a4f9b6bba036f0479f3a5a5fe47f01..a68887656de63857c2555f706cf45bd7462ce040 100644 (file)
--- a/.shellrc
+++ b/.shellrc
@@ -15,6 +15,8 @@ esac
 # Stop if non-interactive shell
 [ -z "$PS1" ] && return
 
 # Stop if non-interactive shell
 [ -z "$PS1" ] && return
 
+PS1="$OPS1$SHLVL "
+
 if test -n "$BASH_VERSION"; then
    # append to the history file, don't overwrite it
    shopt -s histappend
 if test -n "$BASH_VERSION"; then
    # append to the history file, don't overwrite it
    shopt -s histappend
@@ -58,16 +60,6 @@ case "$HOME" in
 esac
 
 
 esac
 
 
-# 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 "
-
-
 if test -n "$BASH_VERSION"; then
    [ "`type -t ls`" = alias ] && unalias ls
    [ "`type -t ll`" = alias ] && unalias ll
 if test -n "$BASH_VERSION"; then
    [ "`type -t ls`" = alias ] && unalias ls
    [ "`type -t ll`" = alias ] && unalias ll
@@ -344,7 +336,7 @@ include() {
 mc() {
    if test -n "$BASH_VERSION"; then
       MC_SAVE_OPS1="$OPS1"
 mc() {
    if test -n "$BASH_VERSION"; then
       MC_SAVE_OPS1="$OPS1"
-      OPS1="\u@\h \W "
+      OPS1="\u@\h \W \\$"
    fi
 
    if [ -n "$SLOWTERM" ]; then
    fi
 
    if [ -n "$SLOWTERM" ]; then