"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.



#      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" ]
   local line2=$(echo -n $(hostname -s)) ; line2size=$hostsize
	local line3=$(echo -n $(whoami))      ; line3size=$usersize

echo -e "\033[4A\


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




https://gilesorr.com/bashprompt/prompts/mountain.html (2.5Kb)
Last modified 2006-05-18 by giles