-
Notifications
You must be signed in to change notification settings - Fork 0
/
.dotfiles-lib
executable file
·54 lines (43 loc) · 943 Bytes
/
.dotfiles-lib
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
_dot_get_os() {
python3 -mplatform
}
_dot_is_osx() {
_dot_get_os | grep --quiet --ignore-case macos
}
_dot_is_ubuntu() {
_dot_get_os | grep --quiet --ignore-case ubuntu
}
_dot_is_redhat() {
_dot_get_os | grep --quiet --ignore-case redhat
}
_dot_is_centos() {
_dot_get_os | grep --quiet --ignore-case centos
}
_dot_is_linux() {
_dot_get_os | grep --quiet --ignore-case linux
}
_dot_on_path() {
local cmd="${1?cmd is required}"
which $cmd &> /dev/null
}
_dot_prepend_to_path() {
local dir="${1?dir is required}"
if [[ -d $dir ]]; then
export PATH="$dir:$PATH"
fi
}
_dot_clone_or_pull() {
local repo="${1?repo is required}"
local dir="${2?dir is required}"
if [[ ! -d $dir/.git ]]; then
git clone $repo $dir
else
(cd $dir && git pull)
fi
}
_dot_shell() {
basename $(command ps -p $$ -oargs=)
}
_dot_is_zsh() {
[[ $(_dot_shell) == zsh ]]
}