function proml { local BLUE="\[\033[0;34m\]" local RED="\[\033[0;31m\]" local LIGHT_RED="\[\033[1;31m\]" local WHITE="\[\033[1;37m\]" local NO_COLOUR="\[\033[0m\]" case $TERM in xterm*) TITLEBAR='\[\033]0;\u@\h:\w\007\]' ;; *) TITLEBAR="" ;; esac PS1="${TITLEBAR}\ $BLUE[$RED\$(date +%H%M)$BLUE]\ $BLUE[$LIGHT_RED\u@\h:\w$BLUE]\ $WHITE\$$NO_COLOUR " PS2='> ' PS4='+ ' }
Note that this requires a VGA font.
# Created by KrON from windowmaker on IRC # Changed by Spidey 08/06 function elite { PS1="\[\033[31m\]\332\304\[\033[34m\](\[\033[31m\]\u\[\033[34m\]@\[\033[31m\]\h\ \[\033[34m\])\[\033[31m\]-\[\033[34m\](\[\033[31m\]\$(date +%I:%M%P)\ \[\033[34m\]-:-\[\033[31m\]\$(date +%m)\[\033[34m\033[31m\]/\$(date +%d)\ \[\033[34m\])\[\033[31m\]\304-\[\033[34m]\\371\[\033[31m\]-\371\371\ \[\033[34m\]\372\n\[\033[31m\]\300\304\[\033[34m\](\[\033[31m\]\W\[\033[34m\])\ \[\033[31m\]\304\371\[\033[34m\]\372\[\033[00m\]" PS2="> " }
I actually do use this prompt, but it results in noticeable delays in the appearance of the prompt on a single-user PII-400, so I wouldn't recommend using it on a multi-user P-100 or anything ... Look at it for ideas, rather than as a practical prompt.
#!/bin/bash #---------------------------------------------------------------------- # POWER USER PROMPT "pprom2" #---------------------------------------------------------------------- # # Created August 98, Last Modified 9 November 98 by Giles # # Problem: when load is going down, it says "1.35down-.08", get rid # of the negative function prompt_command { # Create TotalMeg variable: sum of visible file sizes in current directory local TotalBytes=0 for Bytes in $(ls -l | grep "^-" | cut -c30-41) do let TotalBytes=$TotalBytes+$Bytes done TotalMeg=$(echo -e "scale=3 \nx=$TotalBytes/1048576\n if (x<1) {print \"0\"} \n print x \nquit" | bc) # This is used to calculate the differential in load values # provided by the "uptime" command. "uptime" gives load # averages at 1, 5, and 15 minute marks. # local one=$(uptime | sed -e "s/.*load average: \(.*\...\), \(.*\...\), \(.*\...\)/\1/" -e "s/ //g") local five=$(uptime | sed -e "s/.*load average: \(.*\...\), \(.*\...\), \(.*\...\).*/\2/" -e "s/ //g") local diff1_5=$(echo -e "scale = scale ($one) \nx=$one - $five\n if (x>0) {print \"up\"} else {print \"down\"}\n print x \nquit \n" | bc) loaddiff="$(echo -n "${one}${diff1_5}")" # Count visible files: let files=$(ls -l | grep "^-" | wc -l | tr -d " ") let hiddenfiles=$(ls -l -d .* | grep "^-" | wc -l | tr -d " ") let executables=$(ls -l | grep ^-..x | wc -l | tr -d " ") let directories=$(ls -l | grep "^d" | wc -l | tr -d " ") let hiddendirectories=$(ls -l -d .* | grep "^d" | wc -l | tr -d " ")-2 let linktemp=$(ls -l | grep "^l" | wc -l | tr -d " ") if [ "$linktemp" -eq "0" ] then links="" else links=" ${linktemp}l" fi unset linktemp let devicetemp=$(ls -l | grep "^[bc]" | wc -l | tr -d " ") if [ "$devicetemp" -eq "0" ] then devices="" else devices=" ${devicetemp}bc" fi unset devicetemp } PROMPT_COMMAND=prompt_command function pprom2 { local BLUE="\[\033[0;34m\]" local LIGHT_GRAY="\[\033[0;37m\]" local LIGHT_GREEN="\[\033[1;32m\]" local LIGHT_BLUE="\[\033[1;34m\]" local LIGHT_CYAN="\[\033[1;36m\]" local YELLOW="\[\033[1;33m\]" local WHITE="\[\033[1;37m\]" local RED="\[\033[0;31m\]" local NO_COLOUR="\[\033[0m\]" case $TERM in xterm*) TITLEBAR='\[\033]0;\u@\h:\w\007\]' ;; *) TITLEBAR="" ;; esac PS1="$TITLEBAR\ $BLUE[$RED\$(date +%H%M)$BLUE]\ $BLUE[$RED\u@\h$BLUE]\ $BLUE[\ $LIGHT_GRAY\${files}.\${hiddenfiles}-\ $LIGHT_GREEN\${executables}x \ $LIGHT_GRAY(\${TotalMeg}Mb) \ $LIGHT_BLUE\${directories}.\ \${hiddendirectories}d\ $LIGHT_CYAN\${links}\ $YELLOW\${devices}\ $BLUE]\ $BLUE[${WHITE}\${loaddiff}$BLUE]\ $BLUE[\ $WHITE\$(ps ax | wc -l | sed -e \"s: ::g\")proc\ $BLUE]\ \n\ $BLUE[$RED\$PWD$BLUE]\ $WHITE\$\ \ $NO_COLOUR " PS2='> ' PS4='+ ' }
A friend complained that he didn't like having a prompt that kept changing size because it had $PWD in it, so I wrote this prompt that adjusts its size to exactly the width of your term, with the working directory on the top line of two.
#!/bin/bash # termwide prompt # by Giles - created 2 November 98 # # The idea here is to have the upper line of this two line prompt # always be the width of your term. Do this by calculating the # width of the text elements, and putting in fill as appropriate # or right-truncating $PWD. # function prompt_command { TERMWIDTH=${COLUMNS} # Calculate the width of the prompt: hostnam=$(echo -n $HOSTNAME | sed -e "s/[\.].*//") # "whoami" and "pwd" include a trailing newline usernam=$(whoami) let usersize=$(echo -n $usernam | wc -c | tr -d " ") newPWD="${PWD}" let pwdsize=$(echo -n ${newPWD} | wc -c | tr -d " ") # Add all the accessories below ... let promptsize=$(echo -n "--(${usernam}@${hostnam})---(${PWD})--" \ | wc -c | tr -d " ") let fillsize=${TERMWIDTH}-${promptsize} fill="" while [ "$fillsize" -gt "0" ] do fill="${fill}-" let fillsize=${fillsize}-1 done if [ "$fillsize" -lt "0" ] then let cut=3-${fillsize} sedvar="" while [ "$cut" -gt "0" ] do sedvar="${sedvar}." let cut=${cut}-1 done newPWD="...$(echo -n $PWD | sed -e "s/\(^${sedvar}\)\(.*\)/\2/")" fi } PROMPT_COMMAND=prompt_command function termwide { 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\]" case $TERM in xterm*) TITLEBAR='\[\033]0;\u@\h:\w\007\]' ;; *) TITLEBAR="" ;; esac PS1="$TITLEBAR\ $YELLOW-$LIGHT_BLUE-(\ $YELLOW\${usernam}$LIGHT_BLUE@$YELLOW\${hostnam}\ ${LIGHT_BLUE})-${YELLOW}-\${fill}${LIGHT_BLUE}-(\ $YELLOW\${newPWD}\ $LIGHT_BLUE)-$YELLOW-\ \n\ $YELLOW-$LIGHT_BLUE-(\ $YELLOW\$(date +%H%M)$LIGHT_BLUE:$YELLOW\$(date \"+%a,%d %b %y\")\ $LIGHT_BLUE:$WHITE\$$LIGHT_BLUE)-\ $YELLOW-\ $NO_COLOUR " PS2="$LIGHT_BLUE-$YELLOW-$YELLOW-$NO_COLOUR " }
This is probably the single most attractive (and useless) prompt I've ever created. Because many X terminal emulators don't implement cursor position save and restore, the alternative when putting a clock in the upper right corner is to anchor the cursor at the bottom of the terminal. This builds on the idea of the "termwide" prompt above, drawing a line up the right side of the screen from the prompt to the clock. A VGA font is required.
Note: There is an odd substitution in here, that may not print properly being translated from SGML to other formats: I had to substitute the screen character for \304 - I would normally have just included the sequence "\304", but it was necessary to make this substitution in this case.
#!/bin/bash # This prompt requires a VGA font. The prompt is anchored at the bottom # of the terminal, fills the width of the terminal, and draws a line up # the right side of the terminal to attach itself to a clock in the upper # right corner of the terminal. function prompt_command { # Calculate the width of the prompt: hostnam=$(echo -n $HOSTNAME | sed -e "s/[\.].*//") # "whoami" and "pwd" include a trailing newline usernam=$(whoami) newPWD="${PWD}" # Add all the accessories below ... let promptsize=$(echo -n "--(${usernam}@${hostnam})---(${PWD})-----" \ | wc -c | tr -d " ") # Figure out how much to add between user@host and PWD (or how much to # remove from PWD) let fillsize=${COLUMNS}-${promptsize} fill="" # Make the filler if prompt isn't as wide as the terminal: while [ "$fillsize" -gt "0" ] do fill="${fill}Ä" # The A with the umlaut over it (it will appear as a long dash if # you're using a VGA font) is \304, but I cut and pasted it in # because Bash will only do one substitution - which in this case is # putting $fill in the prompt. let fillsize=${fillsize}-1 done # Right-truncate PWD if the prompt is going to be wider than the terminal: if [ "$fillsize" -lt "0" ] then let cutt=3-${fillsize} sedvar="" while [ "$cutt" -gt "0" ] do sedvar="${sedvar}." let cutt=${cutt}-1 done newPWD="...$(echo -n $PWD | sed -e "s/\(^${sedvar}\)\(.*\)/\2/")" fi # # Create the clock and the bar that runs up the right side of the term # local LIGHT_BLUE="\033[1;34m" local YELLOW="\033[1;33m" # Position the cursor to print the clock: echo -en "\033[2;$((${COLUMNS}-9))H" echo -en "$LIGHT_BLUE($YELLOW$(date +%H%M)$LIGHT_BLUE)\304$YELLOW\304\304\277" local i=${LINES} echo -en "\033[2;${COLUMNS}H" # Print vertical dashes down the side of the terminal: while [ $i -ge 4 ] do echo -en "\033[$(($i-1));${COLUMNS}H\263" let i=$i-1 done let prompt_line=${LINES}-1 # This is needed because doing \${LINES} inside a Bash mathematical # expression (ie. $(())) doesn't seem to work. } PROMPT_COMMAND=prompt_command function clock3 { local LIGHT_BLUE="\[\033[1;34m\]" local YELLOW="\[\033[1;33m\]" local WHITE="\[\033[1;37m\]" local LIGHT_GRAY="\[\033[0;37m\]" local NO_COLOUR="\[\033[0m\]" case $TERM in xterm*) TITLEBAR='\[\033]0;\u@\h:\w\007\]' ;; *) TITLEBAR="" ;; esac PS1="$TITLEBAR\ \[\033[\${prompt_line};0H\] $YELLOW\332$LIGHT_BLUE\304(\ $YELLOW\${usernam}$LIGHT_BLUE@$YELLOW\${hostnam}\ ${LIGHT_BLUE})\304${YELLOW}\304\${fill}${LIGHT_BLUE}\304(\ $YELLOW\${newPWD}\ $LIGHT_BLUE)\304$YELLOW\304\304\304\331\ \n\ $YELLOW\300$LIGHT_BLUE\304(\ $YELLOW\$(date \"+%a,%d %b %y\")\ $LIGHT_BLUE:$WHITE\$$LIGHT_BLUE)\304\ $YELLOW\304\ $LIGHT_GRAY " PS2="$LIGHT_BLUE\304$YELLOW\304$YELLOW\304$NO_COLOUR " }