-
Notifications
You must be signed in to change notification settings - Fork 2
/
install
executable file
·57 lines (48 loc) · 1.45 KB
/
install
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
#!/usr/bin/env bash
path-abs() {
cd -P "$(dirname "${1}")" && pwd
}
path-read-link() {
case "$(uname)" in
"Darwin")
readlink -n "${1}"
;;
"Linux")
readlink --canonicalize-existing --no-newline "${1}"
;;
*)
readlink -n "${1}"
;;
esac
}
path-real() {
local SOURCE="${1}"
while [[ -L ${SOURCE} ]]; do
SOURCE="$(path-read-link "${SOURCE}")"
[[ ${SOURCE} != /* ]] && SOURCE="$(path-abs "${SOURCE}")/${SOURCE}"
done
path-abs "${SOURCE}"
}
DIR="$(path-real "${BASH_SOURCE[0]}")"
echo "********************************************************"
echo "**************** Dotfiles Installation ****************"
echo " dotfiles folder: ${DIR}"
if [ ! -f ~/.dotfiles.bash ]; then
echo " creating symlink at home folder"
ln -s "${DIR}/root.bash" ~/.dotfiles.bash
else
echo " syslink exists"
fi
BASH_FILE=~/.bashrc
[[ ! -f ${BASH_FILE} ]] && BASH_FILE=~/.bash_profile
[[ ! -f ${BASH_FILE} ]] && touch "${BASH_FILE}"
echo " bash file to be used: ${BASH_FILE}"
SOURCE_LINE='[[ -r ~/.dotfiles.bash ]] && [[ -f ~/.dotfiles.bash ]] && source ~/.dotfiles.bash'
if grep --fixed-strings --quiet "${SOURCE_LINE}" "${BASH_FILE}"; then
echo " dotfiles sourcing is already included in ${BASH_FILE}"
else
echo " add dotfiles sourcing in ${BASH_FILE}"
echo "${SOURCE_LINE}" >>"${BASH_FILE}"
fi
echo "********************************************************"
echo "********************************************************"