aboutsummaryrefslogtreecommitdiff
path: root/shellrc.d/dev
blob: 74d692b397b007f4f9dcab109f965ba4e1238f17 (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
# vim: ft=sh:

if command -v valgrind >/dev/null; then

	alias memcheck="valgrind --error-exitcode=118 --track-fds=yes --leak-check=full --track-origins=yes"
	alias callgrind="valgrind --error-exitcode=118 --tool=callgrind"
	alias massif="valgrind --error-exitcode=118 --tool=massif"
	alias drd="valgrind --error-exitcode=118 --tool=drd"
	alias helgrind="valgrind --error-exitcode=118 --tool=helgrind"
	alias dhat="valgrind --error-exitcode=118 --tool=dhat"

fi

if command -v meson >/dev/null; then

	msetup() {
		set -- "-Doptimization=plain" "$@"
		if [[ -f "build/build.ninja" ]]; then
			[[ $# -eq 0 ]] ||
				meson configure build "$@"
		else
			meson setup "$@" build
		fi
	}

	mbuild() {
		msetup &&
			meson compile -C build "$@"
	}

	mtest() {
		msetup &&
			meson test -C build "$@"
	}

	mcoverage() {
		msetup -Db_coverage=true &&
			meson test -C build "$@" &&
			ninja -C build coverage-html
	}

	mdist() {
		msetup &&
			meson dist -C build --formats xztar,gztar,zip "$@"
	}

	mupdate() {
		meson subprojects update
	}

	mpurge() {
		meson subprojects purge
	}

fi

if command -v bear >/dev/null; then

	bmake() {
		mkdir -p build
		bear --output build/compile_commands.json --append -- make "$@"
	}

	alias mbmake='bmake -j$(($(nproc) * 2)) -l$(nproc)'

fi

glv() {
	GITLAB_TOKEN="$(pass gitlab.com/nvim-token)" nvim -c 'lua require("gitlab").review()'
}

nvim_config() (
	cd ~/.config/nvim && nvim init.vim
)

if command -v nix 2>/dev/null >&2; then
	nrun() {
		nix run . -- "$@"
	}
	nrun_() {
		local package="$1"
		shift
		nix run ".#$package" -- "$@"
	}
fi