-
Notifications
You must be signed in to change notification settings - Fork 2
/
.bash_enter
36 lines (30 loc) · 918 Bytes
/
.bash_enter
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
#!/usr/bin/env bash
SOURCE="$0"
if [ "$SOURCE" = "-bash" ]; then
SOURCE="${BASH_SOURCE[0]}"
fi
if [ -n "${DOCKER_DEVBOX_DIR}" ]; then
# shellcheck source=/dev/null
. "$DOCKER_DEVBOX_DIR"/.bash_leave
fi
if [ "$(basename "$SOURCE")" = .bash_enter ]; then
DOCKER_DEVBOX_DIR="$(readlink -f "$SOURCE" | xargs dirname)"
else
DOCKER_DEVBOX_DIR="$PWD"
fi
echo "$(tput setaf 3)Loading environment $(tput sgr0)"
if [ -d "$DOCKER_DEVBOX_DIR"/.bash.lib.d ]; then
for lib_script in "$DOCKER_DEVBOX_DIR"/.bash.lib.d/*; do
# shellcheck source=/dev/null
. "$lib_script"
done
fi
export DOCKER_DEVBOX_DIR
if [ -d "$DOCKER_DEVBOX_DIR"/.bash_enter.d ]; then
for enter_script in "$DOCKER_DEVBOX_DIR"/.bash_enter.d/*; do
echo "$(tput bold)$(tput setaf 6)[.bash_enter.d/$(basename "$enter_script")]$(tput sgr0)$(tput setaf 7)"
# shellcheck source=/dev/null
. "$enter_script"
tput sgr0
done
fi