-
Notifications
You must be signed in to change notification settings - Fork 26
/
bash.env.sh
executable file
·64 lines (53 loc) · 1.72 KB
/
bash.env.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
# Exit unless we are a login shell
[[ -z "$PS1" ]] && return
export dot_env_path="$( cd -P "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
# Allow custom directory to exist outside of project root.
export dot_env_custom="${dot_env_custom:=${dot_env_path}/custom}"
# Display .env version
if [[ "$SHLVL" == "1" ]]; then
source "$dot_env_path/global/global_colors.sh"
DOT_ENV_VERSION=`cat $dot_env_path/VERSION`
echo_info ".env v$DOT_ENV_VERSION - https://github.com/midwire/bash.env"
fi
# Determine OS
OS=`uname`
if [[ "$OS" != "Darwin" && "$OS" != "Linux" && "$OS" != "SunOS" ]]; then
echo_error "Sorry, bash.env does not support your platform: '$OS'"
return 1
fi
OS_DIR=$dot_env_path/os/$OS
# Check for updates
if [[ "$ENABLE_AUTO_UPDATE" == "true" ]]; then
$dot_env_path/bin/check_for_update.sh
fi
# Make sure globals are sourced before OS specifics
if [[ "$SHLVL" == "1" && "$dot_env_verbose" == "1" ]]; then
echo "Sourcing Global Environment"
fi
. $dot_env_path/global/global.sh
# Source plugins which may be defined in ~/.bashrc, an OS, or Host specific file
. $dot_env_path/plugins/plugins.sh
# Now source OS specifics
if [[ "$SHLVL" == "1" && "$dot_env_verbose" == "1" ]]; then
echo "Sourcing $OS Environment"
fi
for i in $OS_DIR/*.sh ; do
if [ -r "$i" ]; then
. $i
fi
done
# Source Host specifics if there are any for the current host
if [[ ! -z "$HOSTNAME" ]]; then
HOST_DIR=$dot_env_path/host/$HOSTNAME
if [[ "$SHLVL" == "1" && "$dot_env_verbose" == "1" ]]; then
echo "Sourcing '$HOSTNAME' Environment"
fi
for i in $HOST_DIR/*.sh ; do
if [ -r "$i" ]; then
. $i
fi
done
fi
unset i
# Source theme which may be defined in ~/.bashrc, an OS, or Host specific file
. $dot_env_path/themes/load_theme.sh