-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathinclude.sh
79 lines (63 loc) · 1.45 KB
/
include.sh
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
#!/bin/bash
function qpopd() {
popd > /dev/null
}
function qpushd() {
pushd "$1" > /dev/null
}
function qwhich() {
which "$1" > /dev/null 2>&1
}
function uname_grep() {
uname | grep "$1" > /dev/null 2>&1
}
function get_os() {
if uname_grep 'MINGW' || uname_grep 'MSYS_NT'; then
echo Windows
elif uname_grep 'Darwin'; then
echo macOS
else
echo Linux
fi
}
export _DOTFILES_TOPDIR=
function get_topdir() {
if [[ -n "${_DOTFILES_TOPDIR}" ]]; then
echo "${_DOTFILES_TOPDIR}"
else
qpushd "$(dirname $0)"
echo "$PWD"
qpopd
fi
}
export _DOTFILES_TOPDIR="$(get_topdir)"
function update_submodule () {
local subdir="$1"
qpushd "$(get_topdir)/${subdir}"
git submodule init
git submodule update --depth 1
qpopd
}
function emacs_script() {
emacs --script "$@" 2>&1 | grep -v '^Loading '
}
function byte_compile() {
if [[ -d "$2" ]]; then
rm -f "$2"/*.elc
elif [[ -f "$2" ]]; then
rm -f "${2}c"
else
echo "Warning: unknown type for $2"
fi
emacs_script "$(get_topdir)"/byte-compile-local.el "$@"
}
function set_treesit_dir() {
emacs_script "$(get_topdir)"/get-treesit-dir.el "$@" > \
"$(get_topdir)"/build/.treesit-dir
}
function get_treesit_dir() {
cat "$(get_topdir)"/build/.treesit-dir
}
function install_treesit_grammar() {
emacs_script "$(get_topdir)"/install-treesit-grammar.el "$@"
}