forked from matschaffer/profile
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinit
40 lines (32 loc) · 814 Bytes
/
init
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
load_conf() {
local conf
for conf in "$1"/*.conf; do
[ -d "${conf}" ] && load_conf "${conf}"
[ -f "${conf}" ] && source "${conf}"
done
return 0
}
conf_support() {
cd `dirname ${BASH_ARGV[0]}`
echo "`pwd`/$1"
cd - > /dev/null
}
is_home_dir() {
cd "$1"
full_path=`pwd`
cd - > /dev/null
[ "$full_path" = "$HOME" ]
}
PROFILE_INIT=`readlink ${BASH_ARGV[0]}`
PROFILE_CORE=`dirname ${PROFILE_INIT}`
PROFILE_CUSTOM="${PROFILE_CORE}/.."
PLATFORM=`uname`
ORIGINAL_PWD=`pwd`
cd "${HOME}"
load_conf "${PROFILE_CORE}" 2>> ~/.bashiniterrors
load_conf "${PROFILE_CORE}/${PLATFORM}" 2>> ~/.bashiniterrors
if ! is_home_dir "${PROFILE_CUSTOM}"; then
load_conf "${PROFILE_CUSTOM}" 2>> ~/.bashiniterrors
load_conf "${PROFILE_CUSTOM}/${PLATFORM}" 2>> ~/.bashiniterrors
fi
cd "${ORIGINAL_PWD}"