From e44944425298d8d690f916fffeb98a865c9838da Mon Sep 17 00:00:00 2001 From: Fernando Schauenburg Date: Sun, 15 Apr 2018 20:03:11 +0200 Subject: [PATCH] [bash] make nested shells visible on prompt The $ or # now gets repeated as many times as levels of shell nesting we have. --- bashrc | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/bashrc b/bashrc index 19e77f1..c22d791 100644 --- a/bashrc +++ b/bashrc @@ -158,14 +158,23 @@ do_solarize_shell() { fi # Customize the prompt - if [ $(id -u) -eq 0 ]; then - __c="1;31" # orange user name for root - elif [ -n "$SSH_CLIENT" ]; then - __c="0;33" # yellow user name when connected via SSH + if [[ -n "$TMUX" ]]; then + LVL=$(($SHLVL - 2)) else - __c="0;36" # default user name color is cyan + LVL=$SHLVL fi - export PS1="[\[\033[${__c}m\]\u@\h \[\033[0;34m\]\w\[\033[0m\]]\n\$ " + if [ $EUID -eq 0 ]; then + PROMPT=$(printf '#%.0s' $(seq 1 $LVL)) + COLOR="1;31" # orange user name for root + else + PROMPT=$(printf '\$%.0s' $(seq 1 $LVL)) + if [ -n "$SSH_CLIENT" ]; then + COLOR="0;33" # yellow user name when connected via SSH + else + COLOR="0;36" # default user name color is cyan + fi + fi + export PS1="[\[\033[${COLOR}m\]\u@\h \[\033[0;34m\]\w\[\033[0m\]]\n$PROMPT " export PS2=". " # Customize colors for `ls` command