# .bashrc # User specific aliases and functions # Settings in this file are only for interactive shells. # I don't know why bash loads this file for scp etc., # but return if that's the case. [ "$PS1" ] || return # Source global definitions [ -f /etc/bashrc ] && . /etc/bashrc ####################################### # user specific environment ####################################### # for mc, cvs, svn, ... export EDITOR=vim # Use vim to browse man pages. One can use Ctrl-[ and Ctrl-t # to browse and return from referenced man pages. ZZ or q to quit. # Note initially within vim, one can goto the man page for the # word under the cursor by using [section_number]K. # Note we use bash explicitly here to support process substitution # which in turn suppresses the "Vim: Reading from stdin..." warning. export MANPAGER='bash -c "vim -MRn -c \"set ft=man nomod nolist nospell nonu\" \ -c \"nm q :qa!\" -c \"nm G\" -c \"nm gg\"/dev/null 2>&1 || alias realpath='readlink -f' # make and change to a directory md () { mkdir -p "$1" && cd "$1"; } # quick plot of numbers on stdin. Can also pass plot params. # E.G: seq 1000 | sed 's/.*/s(&)/' | bc -l | plot linecolor 2 plot() { { echo 'plot "-"' "$@"; cat; } | gnuplot -persist; } # highlight occurences of expression hili() { e="$1"; shift; grep --col=always -Eih "$e|$" "$@"; } # Ditto, but user pager ('n' to iterate) scan() { e="$1"; shift; less -i -p "*$e" "$@"; } # Make these functions, common in other languages, available in the shell ord() { printf "0x%x\n" "'$1"; } chr() { printf $(printf '\\%03o\\n' "$1"); } ####################################### # Developer stuff ####################################### # Enable gcc colours, available since gcc 4.9.0 export GCC_COLORS=1 # Set the section search order for overlapping names alias man='man -S 2:3:1:4:5:6:7:8' # setup default search path for python modules. # Note we add this to the 'path' in .vimrc so the gf # command will open any .py or .h files etc. in this dir export PYTHONPATH=~/pb.o/libs/ # for developing: http://udrepper.livejournal.com/11429.html export MALLOC_CHECK_=3 # The following can cause performance issues # so ensure unset before performance testing for example # export MALLOC_PERTURB_=$(($RANDOM % 255 + 1)) # Let me have core dumps ulimit -c unlimited # print the corresponding error message strerror() { python -c "\ import os,locale as l; l.setlocale(l.LC_ALL, ''); print os.strerror($1)"; } # show extra info in the prompt in git repos old_git_prompt=/usr/share/doc/git-*/contrib/completion/git-completion.bash new_git_prompt=/usr/share/git-core/contrib/completion/git-prompt.sh git_integration=$new_git_prompt test -e $git_integration || git_integration=$old_git_prompt if test -e $git_integration; then source $git_integration export GIT_PS1_SHOWDIRTYSTATE=1 PS1='\[\e[1m\]\h:\W$(__git_ps1 " (%s)")\$\[\e[0m\] ' fi