# bashrc # # Copyright (c) 1997 - 2011 Benjamin Schweizer. # # # Abstract # ~~~~~~~~ # bashrc profile for Linux/FreeBSD/OSX/Solaris # # Authors # ~~~~~~~ # Benjamin Schweizer, http://benjamin-schweizer.de/contact # # Changes # ~~~~~~~ # $Log: .bashrc,v $ # Revision 1.19 2011/04/20 19:15:45 gopher # added comments # # Revision 1.18 2011/04/20 19:00:05 gopher # fixed comment # # Revision 1.17 2011/04/20 18:51:13 gopher # fixed emph again # # Revision 1.16 2011/04/20 08:17:18 gopher # more history tweaks # # Revision 1.15 2011/04/18 11:55:55 gopher # fixed emph # # Revision 1.14 2011/04/18 08:59:44 gopher # updated history # # Revision 1.13 2011/04/18 08:59:00 gopher # tools: emph # # Revision 1.12 2011/02/17 08:29:17 gopher # copy # # Revision 1.11 2011/02/10 18:01:36 gopher # fixed shell vars # # Revision 1.10 2011/01/28 10:00:51 gopher # fixed env+shell vars for less # # Revision 1.9 2010/12/14 09:18:03 gopher # fixed term # # Revision 1.8 2010/12/13 16:38:21 gopher # reverted prompt # # Revision 1.7 2010/12/13 13:20:34 gopher # changed prompt # # Revision 1.6 2010/11/23 07:41:32 gopher # fixed term # # Revision 1.5 2010/11/23 07:36:35 gopher # debug # # Revision 1.4 2010/11/22 18:34:16 gopher # fixed locales # # Revision 1.3 2010/11/22 18:26:11 gopher # major cleanups # # Revision 1.2 2010/11/22 17:21:07 gopher # cleanup1 # # Todo # ~~~~ # - we'll see # # setup umask test "$USER" = "root" && umask 0022 || umask 0077 # prepend user local paths test -d ~/bin && PATH=~/bin:"${PATH}" test -d ~/man && MANPATH=~/man:"${MANPATH}" # leave here if this is not an interactive shell test -z "$PS1" && return # optimize termcap: # osx10.4 lacks -256color variants # rhel5 has no screen-256color # solaris10 has no xterm-color # but screen handles -256color variant case "${TERM}" in xterm-256color) tput -Txterm-256color longname > /dev/null 2>&1 || TERM="xterm-color" tput -Txterm-color longname > /dev/null 2>&1 || TERM="xterm" ;; xterm-color) tput -Txterm-color longname > /dev/null 2>&1 || TERM="xterm" ;; xterm) ;; screen-256color) tput -Tscreen-256color longname > /dev/null 2>&1 || TERM="screen" ;; screen) tput -Tscreen-256color longname > /dev/null 2>&1 && TERM="screen-256color" ;; vt100) # sunos: upgrade vt100 to xterm test "`uname -s`" = "SunOS" && TERM="xterm" ;; linux) # pass ;; *) echo "found freaky terminal '$TERM'" ;; esac # check window size on each prompt shopt -s checkwinsize # set window title in xterm/Eterm PROMPT_COMMAND='printf "\e]0;${USER}@${HOSTNAME%%.*}:${PWD/#$HOME/~}\a"' # enable terminal colors case "${TERM}" in xterm*|Eterm|screen*|linux|cons25) # prompt: hash the hostname and give it a color HOSTCOLOR=$(( 1$(hostname | cksum | sed -e "s/[^0-9]//g") % 6 + 31 )) if [ "$USER" = "root" ]; then PS1="\A \[\e[0;31m\]\u\[\e[0m\]@\[\e[${HOSTCOLOR}m\]\h\[\e[0m\]:\w# " else PS1="\A \[\e[0;32m\]\u\[\e[0m\]@\[\e[${HOSTCOLOR}m\]\h\[\e[0m\]:\w\$ " fi PS2="> " PS4="+ " # more colors case "`uname -s`" in Linux) # GNU; not Busybox which dircolors > /dev/null && { eval `dircolors -b` alias ls='ls --color=auto' } alias 'grep'='grep --color' ;; Darwin|FreeBSD) # BSD # from some mac-forums.com posting LSCOLORS='gxfxcxdxbxegedabagacad' CLICOLOR=true alias 'grep'='grep --color' ;; SunOS) alias 'grep'='ggrep --color' esac ;; *) # older and dumb terminals if [ "$USER" = "root" ]; then PS1="\A \u@\h:\w\# " else PS1="\A \u@\h:\w\$ " fi PS2="> " PS4="+ " ;; esac # timestamps in history HISTTIMEFORMAT='%Y-%m-%d %H:%M:%S: ' HISTSIZE=32768 PROMPT_COMMAND="history -a; $PROMPT_COMMAND" # safety checks alias rm='rm -i' alias cp='cp -i' alias mv='mv -i' alias '..'='cd ..' # pager et al stat "`which vim`" > /dev/null 2>&1 && alias vi="vim" stat "`which less`" > /dev/null 2>&1 && export PAGER="less" export LESS='-S' export EDITOR="vi" # ll case "`uname -s`" in Darwin) #alias 'll'='ls -laeo@' alias 'll'='ls -laeo' ;; FreeBSD) alias 'll'='ls -lao' ;; *) alias 'll'='ls -la' ;; esac # locale LANG=POSIX locale -a | grep "en_GB.UTF-8" > /dev/null && LANG="en_GB.UTF-8" # sunos locale -a | grep "en_US.UTF-8" > /dev/null && LANG="en_US.UTF-8" # osx locale -a | grep "en_US.utf8" > /dev/null && LANG="en_US.utf8" # debian LC_ALL=$LANG # tools function emph { # beware of case sensitiveness, this is broken in gnu grep 2.5.1 grep --color -E "|$1" } # last, allow local overwrites test -f ~/.bash_local && source ~/.bash_local # eof.