-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.bashrc
More file actions
88 lines (67 loc) · 2.05 KB
/
Copy path.bashrc
File metadata and controls
88 lines (67 loc) · 2.05 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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# .bashrc is executed for non-login shells, e.g. every time a terminal is opened
#
# do not execute
#
[ "${BASH_SOURCE}" == "${0}" ] && exit
#
# guards
#
case $- in
*i*)
# interactive shell (OK)
;;
*)
# stop. non-interactive shell
return
;;
esac
if [ ${#SSH_CONNECTION} -gt 0 ] && [ ${#SSH_TTY} -eq 0 ] && [ ${#STY} -eq 0 ] && [ ${#TMUX} -eq 0 ] && [ ${#VSCODE_GIT_IPC_HANDLE} -eq 0 ]; then
# stop. ssh (scp/sftp), no tty, no screen, no tmux, no vscode
return
fi
if [ ${#PS1} -le 0 ]; then
# stop. no prompt
return
else
# for consistency; override system prompt
export PS1='[\u@\h \w]\$ '
fi
#
# unset prefixed variables (if any)
#
JJT_=(${!JJT_*} ${!jjt_*} ${!_JJT*} ${!_jjt*}) && [[ ${#JJT_[@]} -gt 0 ]] && unset -v "${JJT_[@]}"
#
# source system profile (as needed)
#
[ ${#HOSTNAME} -eq 0 ] && [ -f /etc/profile ] && . /etc/profile
#
# source user profile.d files (if any, before bd)
#
if [ -d ~/etc/profile.d ] && [ -r ~/etc/profile.d ]; then
for _USER_PROFILE_D_SH in ~/etc/profile.d/*.sh; do
if [ -r "${_USER_PROFILE_D_SH}" ]; then
. "${_USER_PROFILE_D_SH}"
fi
done
unset _USER_PROFILE_D_SH
fi
#
# bash.d (0.40+)
#
export BD_DEBUG=0
[ "${USER}" == 'root' ] && [ "${PWD}" != "${HOME}" ] && cd # bd-root
# variables that SHOULD be set before sourcing bd.sh
# if BD_HOME was previously set, use it to set BD_DIR
[ ${#BD_HOME} -gt 0 ] && [ -r "${BD_HOME}/.bd" ] && [ -d "${BD_HOME}/.bd" ] && export BD_DIR="${BD_HOME}/.bd"
# variables that MUST be set before sourcing bd.sh
export BD_DIR="${BD_DIR:-${HOME}/.bd}"
export BD_GIT_URL=${BD_GIT_URL:-"https://github.com/bash-d/bd"}
# if bd.sh is not found, try to automatically install it
if [ ${#BD_DIR} -gt 0 ] && [ ! -r "${BD_DIR}/bd.sh" ]; then
git clone "${BD_GIT_URL}" "${BD_DIR}" &> /dev/null
fi
if [ ${#BD_DIR} -gt 0 ] && [ -r "${BD_DIR}/bd.sh" ]; then
. "${BD_DIR}/bd.sh" ${@}
else
printf "\n${BD_DIR}/bd.sh file not found readable (install git & run 'cd && git clone ${BD_GIT_URL} ${BD_DIR}')\n\n"
fi