"Mountain" Prompt

With this prompt, I have placed the less-used information over on the right-hand side of the screen, above the current line. I thought this was a never-used piece of real estate, but as soon as I did it I began to notice that my prompt was overwriting useful information occasionally. I still like and use the prompt.

The prompt code determines whether the hostname or the username is a longer text string, and places the longer one lower down, so we get the slope the prompt was named for. Not the best name I've ever come up with, but at least descriptive.

Code:


#!/bin/bash

#      by Giles - created 5 July 99
#
#   The 'if' statement to determine which element (hostname or username) is 
#   larger seems to significantly slow the prompt.  Can it be moved to
#   where it doesn't occur for every prompt?
#

PROMcur_tty=$(tty | sed -e "s/.*tty\(.*\)/\1/")

function prompt_command {

local usersize=$(echo -n $(whoami)      | wc -c | tr -d " ")
local hostsize=$(echo -n $(hostname -s) | wc -c | tr -d " ")
local ttysize=$(echo  -n $PROMcur_tty   | wc -c | tr -d " ")
local cwdsize=$(echo  -n $PWD           | wc -c | tr -d " ")

local line2=$(echo -n $(whoami))      ; line2size=$usersize
local line3=$(echo -n $(hostname -s)) ; line3size=$hostsize
if [ "$hostsize" -lt "$usersize" ]
then 
   local line2=$(echo -n $(hostname -s)) ; line2size=$hostsize
	local line3=$(echo -n $(whoami))      ; line3size=$usersize
fi

echo -e "\033[4A\
\033[$((${COLUMNS}-$ttysize))C\
\033[1;31m__\
\n\033[$((${COLUMNS}-$ttysize-1))C\
\033[1;31m/\033[1;34m\
$PROMcur_tty\
\n\033[$((${COLUMNS}-${line2size}-1))C\
\033[1;31m/\033[1;34m\
$line2\
\n\033[$((${COLUMNS}-${line3size}-1))C\
\033[1;31m/\033[1;34m\
$line3"
}

PROMPT_COMMAND=prompt_command

function mountain {

local GRAY="\[\033[1;30m\]"
local LIGHT_GRAY="\[\033[0;37m\]"
local WHITE="\[\033[1;37m\]"
local NO_COLOUR="\[\033[0m\]"

local LIGHT_BLUE="\[\033[1;34m\]"
local YELLOW="\[\033[1;33m\]"
local RED="\[\033[1;31m\]"

case $TERM in
    xterm*)
        TITLEBAR='\[\033]0;\u@\h:\w\007\]'
        ;;
    *)
        TITLEBAR=""
        ;;
esac

PS1="$TITLEBAR\
$YELLOW\${PWD}\
\n\
$RED(\!)$LIGHT_BLUE>\
$NO_COLOUR " 

PS2="$LIGHT_BLUE+>$NO_COLOUR "

}


https://gilesorr.org/bashprompt/prompts/mountain.html 
by giles