11.04.2013 Views

Guida avanzata di scripting Bash - Portale Posta DMI

Guida avanzata di scripting Bash - Portale Posta DMI

Guida avanzata di scripting Bash - Portale Posta DMI

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Appen<strong>di</strong>ce K. Un esempio <strong>di</strong> file .bashrc<br />

function fastprompt()<br />

{<br />

unset PROMPT_COMMAND<br />

case $TERM in<br />

*term | rxvt )<br />

PS1="${HILIT}[\h]$NC \W > \[\033]0;\${TERM} [\u@\h] \w\007\]" ;;<br />

linux )<br />

PS1="${HILIT}[\h]$NC \W > " ;;<br />

*)<br />

PS1="[\h] \W > " ;;<br />

esac<br />

}<br />

function powerprompt()<br />

{<br />

_powerprompt()<br />

{<br />

LOAD=$(uptime|sed -e "s/.*: \([^,]*\).*/\1/" -e "s/ //g")<br />

}<br />

}<br />

PROMPT_COMMAND=_powerprompt<br />

case $TERM in<br />

*term | rxvt )<br />

PS1="${HILIT}[\A \$LOAD]$NC\n[\h \#] \W > \[\033]0;\${TERM} [\u@\h] \w\007\]" ;;<br />

linux )<br />

PS1="${HILIT}[\A - \$LOAD]$NC\n[\h \#] \w > " ;;<br />

* )<br />

PS1="[\A - \$LOAD]\n[\h \#] \w > " ;;<br />

esac<br />

powerprompt # this is the default prompt - might be slow<br />

# If too slow, use fastprompt instead....<br />

#===============================================================<br />

#<br />

# ALIASES AND FUNCTIONS<br />

#<br />

# Arguably, some functions defined here are quite big<br />

# (ie ’lowercase’) but my workstation has 512Meg of RAM, so .....<br />

# If you want to make this file smaller, these functions can<br />

# be converted into scripts.<br />

#<br />

# Many functions were taken (almost) straight from the bash-2.04<br />

# examples.<br />

#<br />

#===============================================================<br />

#-------------------<br />

# Personnal Aliases<br />

#-------------------<br />

796

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!