´ÙÀ½ ÀÌÀü Â÷·Ê

9. ¿¹Á¦ ÇÁ·ÒÇÁÆ®µé

9.1 "Lightweight" ÇÁ·ÒÇÁÆ®

function proml {
local BLUE="\[\033[0;34m\]"
local RED="\[\033[0;31m\]"
local LIGHT_RED="\[\033[1;31m\]"
local WHITE="\[\033[1;37m\]"
local LIGHT_GRAY="\[\033[0;37m\]"
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\$$LIGHT_GRAY "
PS2='> '
PS4='+ '
}

9.2 ¹è½¬ÇÁ·ÒÇÁÆ® Å׸¶¿¡¼­ÀÇ 'elite'

ÀÌ ÇÁ·ÒÇÁÆ®´Â VGA ÆùÆ®°¡ ÇÊ¿äÇÏ´Ù´Â Á¡¿¡ À¯ÀÇ ÇϽʽÿÀ.

# 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="> "
}

9.3 "Power User" ÇÁ·ÒÇÁÆ®

Àú´Â ½ÇÁ¦·Î ÀÌ ÇÁ·ÒÇÁÆ®¸¦ »ç¿ëÇÏ°í ÀÖÁö¸¸, PII 400, single-user ½Ã½ºÅÛ¿¡¼­ ÇÁ·ÒÇÁÆ®°¡ ³ªÅ¸³ª´Â µ¥´Â °¨ÁöÇÒ ¼öÀÖÀ» Á¤µµÀÇ Áö¿¬ÀÌ ³ªÅ¸³ª¹Ç·Î, PII 100 ¶Ç´Â ´Ù¸¥ muti-user ½Ã½ºÅÛ¿¡´Â »ç¿ëÇϱ⸦ ±ÇÀåÇÏÁö ¾ÊÀ¾´Ï´Ù. ½ÇÁ¦ÀûÀÎ ÇÁ·ÒÇÁÆ®·Î ¾²±â À§Çؼ­ º¸´Ù´Â, ¾ÆÀ̵ð¾î¸¦ ¾ò±â À§ÇØ Àß »ìÆì º¸½Ã±â ¹Ù¶ø´Ï´Ù.

#!/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
#   - limit the length of the $PWD to 30 chars - right-truncate if 
#   it exceeds that

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\]"

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\$\
\
$LIGHT_GRAY "
PS2='> '
PS4='+ '
}

9.4 Å͹̳ÎÀÇ Æø ÇÁ·ÒÇÁÆ®

ÇÑ Ä£±¸°¡ ºÒÆòÀ» Çߴµ¥, ÇÁ·ÒÇÁÆ® ¾È¿¡ $PWD ¸í·ÉÀÌ À־ °è¼Ó ±æÀÌ°¡ ¹Ù²î´Â ±×·± ÇÁ·ÒÇÁÆ®¸¦ ÁÁ¾Æ ÇÏÁö¾Ê´Â´Ù°í ÇßÀ¾´Ï´Ù. ±×·¡¼­, ¿©·¯ºÐµéÀÇ Å͹̳ÎÀÇ Æø¿¡ ²À ¸Âµµ·Ï ±æÀ̸¦ Á¶Á¤ÇÒ ¼ö ÀÖ´Â ÇÁ·ÒÇÁÆ®¸¦ ÀÛ¼º ÇÏ¿´À¾´Ï´Ù.

#!/bin/bash

#   termwide prompt
#      by Giles - created 2 November 98
#                 last modified 9 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.
#
#   - needs a lot of refinement, but it works
#   - host doesn't need to be figured out every time: that's a 
#     constant
#   - what about username?  could change?
#   - text vars generated by prompt_command can't be locals,
#     because they have to go to PS1.

function prompt_command {

TERMWIDTH=${COLUMNS}

#   Calculate the width of the prompt:

hostnam=$(echo -n $HOSTNAME | sed -e "s/[\.].*//")
let hostsize=$(echo -n $hostnam | wc -c | tr -d " ")
#   "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=((${fillsize})*(-1))+3
    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 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-\
$LIGHT_GRAY " 

PS2="$LIGHT_BLUE-$YELLOW-$YELLOW-$LIGHT_GRAY "
} 

´ÙÀ½ ÀÌÀü Â÷·Ê