-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.bash_profile
133 lines (120 loc) · 5.9 KB
/
.bash_profile
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
# -*- mode: sh -*-
## ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# File: $HOME/.bash_profile
# Multiplatform Bash Configurations for Non Interactive Shells,
# _AND_ Login (interactive) Shells.
# Created: 2019-002-16
# Modified: 2020-002-02
# Author: Alisha Awen - [email protected]
# Git Username: harmonicalchemy
# Ref: https://www.gnu.org/software/bash/
# Repo: github.com:harmonicalchemy/pDotfiles.git
# Environment: Linux, BSD, (Qubes 4.0 App VMs) and Mac OS
# (not for hosted VPS or bare metal servers)
#
# This config file is only sourced by BASH when your session is non-interactive
# (e.g., shell script invoked, etc.) _OR_ it is a human interactive login
# session, either remotely from another machine or locally, by using something
# like an X11 virtual terminal or web-client which is basically the same thing
# as a remote login, from outside (above) the "shell" layer of the OS. Because
# of this "Born Again Satanic-Hell rule" (lol ;-), I created $HOME/.bash_common
# which is sourced from both $HOME./bashrc & this $HOME/.bash_profile. Using
# your own $HOME/.bash_common is the preferred best-practice method. An
# alternate method that "a-lot-of-guys" (including me in the past) do of
# sourcing $HOME/.bashrc from $HOME/.bash_profile can cause many problems!
# I learned the "hard" way...
#
# Note1: If you have a legacy .profile file in your $HOME directory,
# BASH will source it if it does not find any such .bash_profile in
# there! ".profile" comes from the "wicked-old-days" I remember ;-)
# It's still around only because BASH includes it for backward
# compatibility and that has preserved it due in part on the laziness
# of sysAdmins and partly due to distro maintainers accommodating those
# lazy system Administrators to keep them happy and contented.
# Backwards compatability on a production machine serves no productive
# purpose! The objective is to sail your merchant ship as fast as she
# can go...
#
# Change Log: (descending chronological order)
#
# 2019-006-26 - Alisha Awen Sheppard - [email protected]
# Completely re-wrote this file all over yet again! We can now handle
# BASH INTERACTIVE & NON-INTERACTIVE Shells... Added debug print
# statements... (that will be commented out when not debugging)...
#
# 2019-005-16 - Alisha Awen Sheppard - [email protected]
# This file needed an overhaul after all the troubleshooting over several
# months (both Mac OS and Linux). I cleaned this up and also added some
# settings copied from [vault-[pgp] clone of this file which may fix some
# issues I am having trying to get git-remote-gcrypt to work... The
# structure here is now simpler... I hope I did not break anything!
# I am on [MWM-work] now. I will have to test this on Rodrigo next...
# Still no fix for Emacs environment vars problem... Boot from shell works.
#
# 2019-002-16 - Alisha Awen [email protected]
# Created this new file for Bash shell on any machine... This file needs to
# source $HOME/.bash_common to grab common definitions needed by all shell
# sessions (interactive, non-interactive, and login).
## ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
##
# First Check If INTERACTIVE:
# If
# Shell IS INTERACTIVE: Evaluate $HOME/.bashrc AND exit! We are done here.
# ELSE
# Only Evaluate $HOME/.bash_common...
# That's all folks...
#
# NOTE:
# For NON-INTERACTIVE Shells we need to load our custom ~/.bash_common
# init file, which sets environment variables for bash and bourne...
# For INTERACTIVE Shells BASH evaluates this file but NOT ~/.bashrc
# Therefore for that case, we need to load ~/.bashrc from this file,
# AND NOT load our custom ~/.bash-common file because ~/.bashrc
# loads that file for us....
if [[ $- == *i* ]]; then
#### ~~~~~~~~~~~~~~~~~~~~
## BEGIN: .bash_profile Evaluation - Entering File
# DEBUG Print Statements: (Export SH_DBG in your shell session to enable)
if [ "$SH_DBG" = true ] ; then
echo "BASH ENV AND/OR LOGIN - Entered & Evaluating: \$DOTFILES/.bash_profile"
fi
#### ~~~~~~~~~~~~~~~~~~~~
#### ~~~~~~~~~~~~~~~~~~~~
## BEGIN: Bash Interactive...
if [ "$SH_DBG" = true ] ; then
echo "BASH INTERACTIVE - \$DOTFILES/.bash_profile - Preparing to Evaluate: .bashrc"
fi
#### ~~~~~~~~~~~~~~~~~~~~
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
else
#### ~~~~~~~~~~~~~~~~~~~~
## BEGIN: Bash NON Interactive...
# DEBUG Print Statements: (Export SH_DBG in your shell session to enable)
# This is NON-INTERACTIVE (better print this to a log file rather than console!)
# Also check for NON-INTERACTIVE in .bash_common for same reason...
# if [ "$SH_DBG" = true ] ; then
# echo "BASH NON-INTERACTIVE - \$DOTFILES/.bash_profile - Preparing to Evaluate: .bash_common"
# fi
#### ~~~~~~~~~~~~~~~~~~~~
##
# Evaluate $HOME/.bash_common:
# Common environment elements needed by interactive,
# non-interactive, & login shell sessions alike...
if [ -f ~/.bash_common ]; then
. ~/.bash_common
fi
fi
## This is all for now... I may have to add more to this for Ubuntu VPS droplets.
if [[ $- == *i* ]]; then
#### ~~~~~~~~~~~~~~~~~~~~
## END: $HOME/.bash_profile - Leaving File...
# DEBUG Print Statements: (Export SH_DBG in your shell session to enable)
if [ "$SH_DBG" = true ] ; then
echo "END: \$DOTFILES/.bash_profile - Leaving File"
fi
fi
## ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# END: $HOME/.bash_profile
## ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~