# /etc/bash/bashrc # # This file is sourced by all *interactive* bash shells on startup, # including some apparently interactive shells such as scp and rcp # that can't tolerate any output. So make sure this doesn't display # anything or bad things will happen ! # Test for an interactive shell. There is no need to set anything # past this point for scp and rcp, and it's important to refrain from # outputting anything in those cases. if [[ $- != *i* ]] ; then # Shell is non-interactive. Be done now! return fi # Bash won't get SIGWINCH if another process is in the foreground. # Enable checkwinsize so that bash will check the terminal size when # it regains control. #65623 # http://cnswww.cns.cwru.edu/~chet/bash/FAQ (E11) shopt -s checkwinsize # Enable history appending instead of overwriting. #139609 shopt -s histappend # Change the window title of X terminals case ${TERM} in xterm*|rxvt*|Eterm|aterm|kterm|gnome*|interix) PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME%%.*}:${PWD/$HOME/~}\007"' ;; screen) PROMPT_COMMAND='echo -ne "\033_${USER}@${HOSTNAME%%.*}:${PWD/$HOME/~}\033\\"' ;; esac use_color=false # Set colorful PS1 only on colorful terminals. # dircolors --print-database uses its own built-in database # instead of using /etc/DIR_COLORS. Try to use the external file # first to take advantage of user additions. Use internal bash # globbing instead of external grep binary. safe_term=${TERM//[^[:alnum:]]/?} # sanitize TERM match_lhs="" [[ -f ~/.dir_colors ]] && match_lhs="${match_lhs}$(<~/.dir_colors)" [[ -f /etc/DIR_COLORS ]] && match_lhs="${match_lhs}$(/dev/null \ && match_lhs=$(dircolors --print-database) [[ $'\n'${match_lhs} == *$'\n'"TERM "${safe_term}* ]] && use_color=true if ${use_color} ; then BLACK="\[\033[0;30m\]" RED="\[\033[0;31m\]" GREEN="\[\033[0;32m\]" BROWN="\[\033[0;33m\]" BLUE="\[\033[0;34m\]" PURPLE="\[\033[0;35m\]" CYAN="\[\033[0;36m\]" LIGHT_GRAY="\[\033[0;37m\]" GRAY="\[\033[1;30m\]" LIGHT_RED="\[\033[1;31m\]" LIGHT_GREEN="\[\033[1;32m\]" YELLOW="\[\033[1;33m\]" LIGHT_BLUE="\[\033[1;34m\]" LIGHT_PURPLE="\[\033[1;35m\]" LIGHT_CYAN="\[\033[1;36m\]" WHITE="\[\033[1;37m\]" UNDERLINE="\[\033[4m\]" NO_COLOR="\[\033[0m\]" C_L1=$RED C_L5=$GREEN C_L15=$BROWN C_PROC=$CYAN C_UPTIME=$PURPLE if [[ ${EUID} == 0 ]] ; then C_PRI=$LIGHT_RED C_PARENS=$BROWN else C_PRI=$LIGHT_GREEN C_PARENS=$LIGHT_BLUE fi alias ls='ls --color=auto' alias grep='grep --colour=auto' fi PSHOST=`uname -n` PS1="\n$C_PRI-$C_PARENS[$C_PRI\u$C_PARENS@$C_PRI$PSHOST$C_PARENS]$C_PRI-$C_PARENS[$C_L1\$(cut -d' ' -f1 /proc/loadavg)$C_PARENS/$C_L5\$(cut -d' ' -f2 /proc/loadavg)$C_PARENS/$C_L15\$(cut -d' ' -f3 /proc/loadavg)$C_PARENS]$C_PRI-$C_PARENS$C_PROC\$(free | xargs echo | awk '{print(int(((\$9+\$20-\$13)*100)/(\$19+\$8))\"%\")}')$C_PARENS$C_PRI-$C_PARENS$C_UPTIME\$(U=\$(cut -d'.' -f1 /proc/uptime);echo \$((\$U / 86400))d\$((\$U / 3600 % 24))h\$((\$U / 60 % 60))m)$C_PARENS$C_PRI-$C_PARENS$C_PRI\D{%Y-%m-%d}${C_PARENS}T${C_PRI}\\t$C_PARENS$C_PRI-\n$C_PRI-$C_PARENS[$C_PRI\w$C_PARENS:$C_PRI\\$""$C_PARENS]$C_PRI- $NO_COLOR" # Try to keep environment pollution down, EPA loves us. unset use_color safe_term match_lhs