-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbashrc-engine
More file actions
67 lines (55 loc) · 2.13 KB
/
Copy pathbashrc-engine
File metadata and controls
67 lines (55 loc) · 2.13 KB
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
# -*- mode: shell-script;coding:utf-8 -*-
# bashrc-engine
if [ -n "${EMACS_BASH_COMPLETE:-}" ] ; then
return
fi
# On MSYS2, /etc/profile is what populates MSYSTEM-aware bits like
# MINGW_PREFIX, ACLOCAL_PATH, MANPATH and the MSYSTEM-correct PATH
# prefix. If we get here without it (e.g. a non-login context that
# still triggers .bashrc) the cache would capture a half-set env.
# On Linux MINGW_PREFIX is unset and /etc/profile is well-behaved.
if [ -z "${MINGW_PREFIX:-}" ] && [ -r /etc/profile ] ; then
. /etc/profile
fi
pjb_bash_source="${BASH_SOURCE[0]:-}"
if [ -z "$pjb_bash_source" ] ; then
pjb_bash_source="$HOME/.bashrc"
fi
while [ -L "$pjb_bash_source" ] ; do
pjb_bash_dir="$(cd "$(dirname "$pjb_bash_source")" && pwd -P)"
pjb_bash_target="$(readlink "$pjb_bash_source")"
if [ -z "$pjb_bash_target" ] ; then
break
fi
pjb_bash_source="$pjb_bash_target"
case "$pjb_bash_source" in
/*) ;;
*) pjb_bash_source="$pjb_bash_dir/$pjb_bash_source" ;;
esac
done
pjb_bash_dir="$(cd "$(dirname "$pjb_bash_source")" && pwd -P)"
if [ ! -r "$pjb_bash_dir/bash/lib/context.bash" ] && [ -r "$HOME/rc/bash/lib/context.bash" ] ; then
pjb_bash_dir="$(cd "$HOME/rc" && pwd -P)"
fi
source "$pjb_bash_dir/bash/lib/context.bash"
source "$PJB_BASH_RC_ROOT/bash/lib/profile-loader.bash"
source "$PJB_BASH_RC_ROOT/bash/lib/env-cache.bash"
pjb_bash_load_profiles
pjb_bash_build_env_cache
pjb_bash_load_env_cache
# Recompose PATH/MANPATH/INFOPATH from bash/path.d/* so the current
# $PWD's project layer (.bash-path walk) is honored. The cache holds
# whatever cwd the cache writer had; this picks up project-local
# augmentations every time a shell starts. Cheap -- a few existence
# checks per layer, no forks for the common case.
if declare -F path_compose >/dev/null 2>&1 ; then
path_compose
fi
if pjb_bash_interactive_p ; then
source "$PJB_BASH_RC_ROOT/bash/interactive/legacy-loader.bash"
fi
unset pjb_bash_dir pjb_bash_source pjb_bash_target
return
# Legacy monolith code lives in bash/legacy/monolith.bash.
# Keep this file as the loader for profiles, cached environment,
# and interactive modules only.