From d6d0947f637535c4b2156aa8c32534f376e73526 Mon Sep 17 00:00:00 2001 From: Oleg Broytman Date: Fri, 12 Jun 2020 21:39:40 +0300 Subject: [PATCH] bash: Append `$SHLVL` directly to `$OPS1` --- .profile | 6 ++---- .shellrc | 8 +++----- admin/prog/bash_prompt | 6 ++---- 3 files changed, 7 insertions(+), 13 deletions(-) diff --git a/.profile b/.profile index 69491d0..20ba5a1 100644 --- a/.profile +++ b/.profile @@ -175,8 +175,6 @@ if [ -t 0 ] ; then fi if test -n "$BASH_VERSION"; then - . "$ENV" - if [ -r "$HOME"/admin/prog/bash_prompt ]; then . "$HOME"/admin/prog/bash_prompt set_prompts @@ -185,12 +183,12 @@ if [ -t 0 ] ; then OPS1="${debian_chroot:+($debian_chroot)}\u@\h:\W \\$" fi + . "$ENV" + else OPS1="${debian_chroot:+($debian_chroot)}`/usr/bin/whoami`@`/bin/hostname -s` >" fi - export OPS1 - ### biff controls new mail notification #biff n ### mesg controls messages (write/talk) from other users diff --git a/.shellrc b/.shellrc index 6973d7a..bc164f1 100644 --- a/.shellrc +++ b/.shellrc @@ -57,8 +57,6 @@ case "$HOME" in ;; esac -PS1="$OPS1$SHLVL " - if test -n "$BASH_VERSION"; then [ "`type -t ls`" = alias ] && unalias ls [ "`type -t ll`" = alias ] && unalias ll @@ -156,8 +154,6 @@ if test -n "$BASH_VERSION"; then . "$HOME"/admin/prog/bash_prompt fi - PS1="\`cgmem_which_prompt\`$OPS1$SHLVL " - #if type -p pip >/dev/null 2>&1; then # eval "`pip completion --bash`" # rm -rf /tmp/pip_build_"$USER" @@ -184,6 +180,7 @@ elif test -n "$KSH_VERSION" -o -n "$FCEDIT"; then j() { jobs; } fi +PS1="$OPS1" # clear screen and history, logout chlo() { clear; cd; >$HISTFILE; unset HISTFILE; history -c; logout || exit; } @@ -343,7 +340,8 @@ mc() { if test -n "$BASH_VERSION"; then MC_SAVE_OPS1="$OPS1" if [ "`type -t short_curdir`" = function ]; then - OPS1="\u@\${HOSTNAME::5}:\`short_curdir\` \\$" + OPS1="\`cgmem_which_prompt\`\u@\${HOSTNAME::5}:\`short_curdir\` " + OPS1+="\$(prompt_git)\\$\$SHLVL " else OPS1="\u@\h:\W \\$" fi diff --git a/admin/prog/bash_prompt b/admin/prog/bash_prompt index a262e5e..7c6117c 100644 --- a/admin/prog/bash_prompt +++ b/admin/prog/bash_prompt @@ -97,8 +97,6 @@ set_prompts() { OPS1+="${debian_chroot:+($debian_chroot)}" OPS1+="\`cgmem_which_prompt\`\u@\${HOSTNAME::5}:\`short_curdir\` " OPS1+="\$(prompt_git)" - OPS1+="\\$" + OPS1+="\\$\$SHLVL " + export OPS1 } - -#set_prompts -#unset set_prompts -- 2.39.2