bashrc
~/.bashrc
This is my .bashrc
- bashrc
# Andi's .bashrc # setup path export PATH=${HOME}/bin:${HOME}/programs/bin:${PATH} # where's my palm? export PILOTPORT=/dev/ttyUSB1 # be sure to do to all this on interactive shells only if [ "$PS1" ]; then # load system defaults if [ -f /etc/profile ]; then . /etc/profile fi # handy file conversion tools alias dos2unix="perl -pi -e 's/\r\n/\n/;'" alias unix2dos="perl -pi -e 's/\n/\r\n/;'" alias bomstrip="sed -i -s -e '1s/^\xef\xbb\xbf//'" # enable color support of ls and also add handy aliases eval `dircolors -b` alias ls='ls --color=auto' alias ll='ls -l' alias la='ls -A' alias l='ls -la' export GREP_OPTIONS='--color=auto' # color in man pages http://icanhaz.com/colors export LESS_TERMCAP_mb=$'\E[01;31m' export LESS_TERMCAP_md=$'\E[01;31m' export LESS_TERMCAP_me=$'\E[0m' export LESS_TERMCAP_se=$'\E[0m' export LESS_TERMCAP_so=$'\E[01;44;33m' export LESS_TERMCAP_ue=$'\E[0m' export LESS_TERMCAP_us=$'\E[01;32m' # better safe than sorry alias cp='cp -i' alias rm='rm -i' alias mv='mv -i' # cleanup firefox 3 dbs alias ffclean='for f in ~/.mozilla/firefox/*/*.sqlite; do echo $f; sqlite3 $f "VACUUM;"; done' # current git branch for prompt below # http://techblog.floorplanner.com/2008/12/14/working-with-git-branches/ parse_git_branch() { git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\[\1\]/' } # has current branch unrecorded changes? # http://markelikalderon.com/2009/01/16/dirty-prompts/ parse_git_dirty() { git diff --quiet HEAD &>/dev/null [[ $? == 1 ]] && echo "*" } # set a fancy prompt and xterm title shopt -s checkwinsize if [ "$COLORTERM" != "" -o "$TERM" == "xterm" ]; then if [ "$USER" == "root" ]; then PS1='\[\e[0;31m\]\u@\h\[\e[0;35m\]$(parse_git_branch)$(parse_git_dirty)\[\e[0;31m\]:\w\$\[\e[0m\] ' else PS1='\[\e[0;32m\]\u@\h\[\e[0;35m\]$(parse_git_branch)$(parse_git_dirty)\[\e[0;32m\]:\w\$\[\e[0m\] ' fi else PS1='\u@\h:\w\$ ' fi # enable programmable bash completion if [ -f /etc/bash_completion ]; then . /etc/bash_completion fi # ssh keymanager - see http://wiki.splitbrain.org/ssh if [ -e /usr/bin/keychain -a -e ~/.ssh/id_dsa ]; then keychain -q ~/.ssh/id_dsa if [ -e ~/.ssh-agent-${HOSTNAME} ]; then . ~/.ssh-agent-${HOSTNAME} fi if [ -e ~/.keychain/${HOSTNAME}-sh ]; then . ~/.keychain/${HOSTNAME}-sh fi fi # daily temp dir export TD="$HOME/temp/`date +'%Y-%m-%d'`" td(){ td=$TD if [ ! -z "$1" ]; then td="$HOME/temp/`date -d "$1 days" +'%Y-%m-%d'`"; fi mkdir -p $td; cd $td unset td } # set a sane editor if [ -e /usr/bin/vim ]; then export EDITOR=/usr/bin/vim alias vi=/usr/bin/vim fi # print a fortune cookie if which fortune >/dev/null; then if [ "$COLORTERM" != "" -o "$TERM" == "xterm" ]; then echo -en "\033[0;36m" fortune -a -s echo -en "\033[0;37m" else fortune -a -s fi fi fi
Some infos
Besides a nice prompt and some sane defaults this bashrc defines some handy utils as well:
Convert DOS CRLFs to Unix LFs and vice versa:
$> dos2unix <files> $> unix2dos <files>
Strip UTF-8 byte order marks
$> bomstrip <files>
Change into a temp directory named after the todays date (create if nessary):
$> td
Change into yesterday's temp dir:
$> td -1
bashrc.txt · Last modified: 2010/04/28 18:45 by 92.195.193.18