body() { IFS= read -r header printf '%s\n' "$header" "$@" } safedir() { echo "$@ $(pwd)" | md5sum | cut -b-32 } diffWith() { diffCmd=$1 diffFile="/tmp/diffwith-$(safedir $diffCmd).patch" $diffCmd > $diffFile dos2unix -q $diffFile ( gvim -f $diffFile ; rm $diffFile ) & } cov() { src=${1} src=$(realpath ${src:=$(pwd)}) cov=/tmp/cov.$$ all=$cov/all key=$cov/key html=$src/bin/cov/html test -d $src || ( echo "$src not a directory" && return 1 ) echo "Cleaning $src" find $src -name "*.gcda" -type f -delete find $src -name "*.run" -type f -delete echo "Building in ${src}" build $src -d0 variant=coverage echo "Extracting coverage data" mkdir -p $cov lcov -d $src -c -o $all --derive-func-data --no-external -b $src -q lcov --remove $all "*/bin/*" -o $key -q echo "Generating HTML" mkdir -p $html genhtml $key -o $html -s -k -t $src --demangle-cpp --sort --function-coverage -q rm -rf $cov [ "${2}" != "0" ] && xdg-open file://$src/bin/cov/html/index.html } PATH="/usr/lib/ccache/bin:$PATH" CORES=$(grep core\ id /proc/cpuinfo | sort -u | wc -l) export FEATURES="ccache" alias :e="gvim" alias ChuckNorris="sudo" alias l="/bin/ls -lhvF --color" alias grep="/bin/grep -I --color=auto --exclude-dir=CVS --exclude-dir=.git --exclude-dir=.svn --exclude-dir=bin --exclude=tags --exclude-dir=docs/html" alias emerge-state='watch "( ps -fC sandbox ; tail /var/log/emerge.log /var/tmp/portage/*/*/temp/build.log 2> /dev/null )"' title() { echo -ne "\033]0;$@\007" } build() { title "Build in progress" CCACHE_BASEDIR=$(git root) nice -n5 b2 -j$CORES $@ rtn=$? if [ $rtn -eq 0 ]; then title "Build success ${PWD/#$HOME/\~}" else title "Build failed ${PWD/#$HOME/\~}" fi return $rtn } onchange() { $@ while inotifywait -qr . --exclude '/bin/|\.sw.|/target/|/\.git/|\.gcov' -e modify ; do clear printf '\e[3J' $@ done } autobuild() { onchange build $@ } # CVS export CVSROOT=":pserver:danielg@hawking.howden.press.net:/usr/local/src/CVS_SOURCE_TREE" cvsd() { diffWith "cvs diff -wubB $@" } # SVN svnd() { diffWith "svn diff --force --no-diff-deleted -x -b $@" } # Git gitd() { diffWith "git diff --no-prefix --relative -b -M $@" } gitdc() { diffWith "git diff --cached --no-prefix --relative -b -M $@" } gppdmb() { PARENT=${1:-master} git checkout $PARENT && git pull --prune && git delete-merged-branches } createAllBranches() { for branch in $(git branch --all | grep '^\s*remotes' | egrep --invert-match '(:?HEAD|master)$'); do git branch --track "${branch#*/*/}" "$branch"; done } filterAllBranches() { git filter-branch --subdirectory-filter $1 --prune-empty --tag-name-filter cat -d /tmp/$$ -- $(git branch | cut -b 3-) } alias gst='git status' # Hg hgd() { diffWith "hg diff -p -b $@" } # Java PATH=$JAVA_HOME/bin:$PATH export CATALINA_HOME="/usr/share/tomcat-5.5/" if [ -d /usr/share/maven-bin-* ] ; then export M2_HOME=$(ls -d /usr/share/maven-bin-*) fi export NPM_PACKAGES="${HOME}/.npm-packages" export NODE_PATH="$NPM_PACKAGES/lib64/node_modules:$NODE_PATH" export MANPATH="$(manpath):$NPM_PACKAGES/share/man" export PATH="$PATH:$NPM_PACKAGES/bin" if [ "$(awk '$5=="/" {print $1}'