blob: 862580cfeee2774c55fcc797cbb20dd1740b5f93 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
|
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 ) &
}
showimage() {
(
local pkg
pkg=$1
pkg="${pkg:=*/*}"
cd /var/tmp/portage/$pkg-*/image || return 1
find . -not -type d -print0 | xargs -0r ls -lvhF --color=auto
du -shc */*
)
}
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 d="cd ~/dev"
alias p="cd ~/dev/portage"
alias ChuckNorris="sudo"
alias l="/bin/ls -NlhvF --color"
alias grep="/bin/grep -I --color=auto --exclude-dir=node_modules --exclude-dir=CVS --exclude-dir=.git --exclude-dir=.svn --exclude-dir=bin --exclude=tags --exclude-dir=docs/html --exclude-dir=target --exclude-dir=.idea --exclude=*.iml"
alias emerge-state='watch "( ps -C sandbox -o stime,cmd ; tail /var/log/emerge.log /var/tmp/portage/*/*/temp/build.log 2> /dev/null )"'
alias df="/bin/df -hT"
title() {
echo -ne "\033]0;$@\007"
}
vg() {
valgrind \
--show-leak-kinds=all \
--suppressions=$HOME/dev/valgrind.suppressions \
--leak-check=full \
--log-file=/var/tmp/vg.log \
$@
}
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 $@
}
autocov() {
onchange cov . 0
}
# 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}' </proc/1/mountinfo)" != "$(awk '$5=="/" {print $1}' </proc/$$/mountinfo)" ]; then
# chroot
if [ -e /etc/redhat-release ]; then
ROOT=$(cat /etc/redhat-release)
elif [ -e /etc/gentoo-release ]; then
ROOT=$(cat /etc/gentoo-release)
else
ROOT="unknown chroot"
fi
PS1='\[\033[01;32m\]$ROOT \[\033[01;34m\]\w \$\[\033[00m\] '
PROMPT_COMMAND='echo -ne "\033]0;${PWD/#$HOME/\~} ($ROOT)\007"'
elif [ -z "$SSH_CONNECTION" ] ; then
# local
PS1='\[\033[01;34m\]\w \$\[\033[00m\] '
PROMPT_COMMAND='echo -ne "\033]0;${PWD/#$HOME/\~}\007"'
else
# ssh
PS1='\[\033[01;32m\]\h \[\033[01;34m\]\w \$\[\033[00m\] '
PROMPT_COMMAND='echo -ne "\033]0;${PWD/#$HOME/\~} ($HOSTNAME)\007"'
fi
PATH=$PATH:~/files/scripts/
export XAUTHORITY=~/.Xauthority
export HISTFILESIZE=15000
export HISTSIZE=${HISTFILESIZE}
export HISTCONTROL=ignoredups:ignorespace
shopt -s histappend
export LESSCHARSET=utf-8
export EDITOR="gvim -f"
shopt -s cdspell
shopt -s checkwinsize
shopt -s no_empty_cmd_completion
[ -x /usr/bin/fuck ] && eval $(thefuck --alias)
if [ -x /usr/bin/hh ] ; then
export HH_CONFIG=hicolor,keywords,rawhistory
export PROMPT_COMMAND="history -a; history -n; ${PROMPT_COMMAND}"
if [[ $- =~ .*i.* ]]; then bind '"\C-r": "\C-a hh -- \C-j"'; fi
fi
|