-
Notifications
You must be signed in to change notification settings - Fork 0
/
.bash_common
356 lines (280 loc) · 14 KB
/
.bash_common
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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
# -*- mode: sh -*-
#### ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
## File: $HOME/.bash_common
## Common definitions for both ~/.bash_profile and ~/.bashrc
## Created: 2019-002-16
## Updated: 2020-002-02
## Author: Alisha Awen - [email protected]
## Git Username: harmonicalchemy
## Ref: https://www.gnu.org/software/bash/
## Repo: Github.com:harmonicalchemy/dotfiles.git
## Environment: Linux, BSD, (Qubes 4.0 App VMs) and Mac OS
## (not for hosted VPS or bare metal servers)
##
## This config file is sourced by both $HOME/.bashrc & $HOME/.bash_profile.
## Using a single file to source common configurations across all environments
## represents the best-practice method to get proper definitions defined and
## exported within Interactive, Non-interactive, and Login shell sessions alike.
## Other methods are not recommended and could cause problems. On Stackoverflow,
## I know "a-lot-of-guys" are sourcing $HOME/.bashrc within: $HOME/.bash_profile,
## (and I have done so as well in the past) but experts and the Bash manual all
## warn that this can cause problems with unwanted output to stdout... Doing it
## that way will break the non-interactivity of rsync as well as many other
## things! You will need non-interactive rsync to automate the deployment/updates
## of your websites!
##
## Usage: Symlink this file from your $HOME directory:
##
## $HOME> ln -s $TOOLS/pDotfiles/.bash_common $HOME/.bash_common
##
## 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...
##
## Note2: Adjust: "Top Level Machine Specific Exports:" sections below to fit
## your specific environment. ($HOME is universal by default). If $HOME
## is NOT defined by the system already (can't imagine that on unix)
## then you will have to define $HOME at the top here as well...
##
## Change Log: (descending chronological order)
##
## 2020-002-02 - Alisha Awen - [email protected]
## Refreshed this file from changes made to my private .DOTFILES repo
## Security DueDiligence up to Q1 2020 now...
##
## 2019-006-26 - Alisha Awen Sheppard - [email protected]
## HUGE OVERHAUL for Mac OS mostly... Also 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... Moved a lot of
## stuff in here that was previously part of $HOME/.bashrc into here...
## Now I know why I as experiencing so many shell related problems on
## my old MacBook Pro from many years ago resulting in switching to Zsh. OMG!
#### ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
## To enable/disable DEBUG logging change below to true/false respectively...
## It is on by default... You will probably need that in the beginning. ;-)
## If you need more debug statements elsewhere, use one of these as a template...
export SH_DBG=true
### ~~~~~~~~~~~~~~~~~~~~
## BEGIN: .bash_common Evaluation - Entering File
## DEBUG Print Statements: (Export SH_DBG=true in your shell session to enable)
if [ "$SH_DBG" = true ] ; then
echo "BASH ENV - Entering & Evaluating: \$DOTFILES/.bash_common"
fi
### ~~~~~~~~~~~~~~~~~~~~
## Set architecture flags to X86 64bit (all platforms):
export ARCHFLAGS="-arch x86_64"
### ~~~~~~~~~~~~~~~~~~~~~~~~~~~
## BEGIN: OS Specific Section:
### ~~~~~~~~~~~~~~~~~~~~~~~~~~~
if [[ "$OSTYPE" == "linux-gnu" ]]; then
### ~~~~~~~~~~~~~~~~~~~~
## BEGIN: Linux Specific Configs...
## DEBUG Print Statements: (Export SH_DBG in your shell session to enable)
if [ "$SH_DBG" = true ] ; then
echo "\$DOTFILES/.bash_common - BEGIN: LINUX CASE"
fi
### ~~~~~~~~~~~~~~~~~~~~
###
## Export Linux specific $PATH:
##
## NOTE1: Update the single line Path definitions below, from other lines
## that are sometimes programmatically added to the bottom of other
## shell init files after installing things! Don't let them get all
## tangled up in different places! Keep them all here in one place!
##
## NOTE2: Make sure all /bin directory paths under `/user/local` occur BEFORE
## `/usr/bin` directory paths within the export directive below.
##
## NOTE3: You may need to make adjustments to the default path exports below
## depending on your flavor of unix, and whether you have some of the
## packages/plugins/binaries/libraries installed in a different place.
## But for most cases, the exports already defined below are the default
## paths on Linux and Mac OS. The .rbenv paths assume you installed
## .rbenv and used it to install ruby. (change it if you don't want it)
export PATH="$HOME/.bin:$HOME/.local/bin:$HOME/.rbenv/bin:$HOME/.rbenv/plugins/ruby-build/bin:$GOPATH/bin:/usr/local/bin:/usr/local/sbin:/usr/bin:$PATH"
## Export Linux Manual $PATH:
## TODO: Add this in later...
###
## Qubes Split SSH:
## NOTE: This section is only used for Qubes OS machines that use Qubes App
## Split SSH schemes... If you do that, un-comment the lines in this
## secton...
## Set next line to the ssh key vault you want to use
# SSH_VAULT_VM="vault-ssh"
# if [ "$SSH_VAULT_VM" != "" ]; then
# export SSH_AUTH_SOCK=~user/.SSH_AGENT_$SSH_VAULT_VM
# fi
## Qubes Split GPG tweaks... You may or may not need these depending
## on above... (but I left them enabled since they won't hurt anything)
alias gpg="/usr/bin/gpg2"
alias gpq="qubes-gpg-client"
alias gpw="qubes-gpg-client-wrapper"
export QUBES_GPG_DOMAIN="vault-pgp"
export QUBES_GPG_AUTOACCEPT=86400
### ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
## Top Level Linux Machine Specific Exports:
## (change these to something else if you need to)
### ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
## Define Main GIT Home:
export GIT=$HOME/000-GIT
## Define Main WWW directory
export WWW=$HOME/WWW
### ~~~~~~~~~~~~~~~~~~~~
## END: Linux Specific Configs...
## DEBUG Print Statements: (Export SH_DBG in your shell session to enable)
if [ "$SH_DBG" = true ] ; then
echo "\$DOTFILES/.bash_common - END: LINUX CASE"
fi
### ~~~~~~~~~~~~~~~~~~~~
elif [[ "$OSTYPE" == "darwin"* ]]; then
### ~~~~~~~~~~~~~~~~~~~~
## BEGIN: Mac OS Specific Configs...
## DEBUG Print Statements: (Export SH_DBG in your shell session to enable)
if [ "$SH_DBG" = true ] ; then
echo "\$DOTFILES/.bash_common - BEGIN: MAC-OS CASE"
fi
### ~~~~~~~~~~~~~~~~~~~~
###
## Export Mac OS specific $PATH:
## NOTE1: Update the single line Path definitions below, from other lines
## that are sometimes programmatically added to the bottom of other
## shell init files after installing things! Don't let them get all
## tangled up in different places! Keep them all here in one place!
##
## NOTE2: Make sure all /bin directory paths under `/user/local` occur BEFORE
## `/usr/bin` directory paths within the export directive below. This
## is mostly for the sake of Homebrew on Mac OS...
##
## NOTE3: You may need to make adjustments to the default path exports below
## depending on your flavor of unix, and whether you have some of the
## packages/plugins/binaries/libraries installed in a different place.
## But for most cases, the exports already defined below are the default
## paths on Linux and Mac OS. The .rbenv paths assume you installed
## .rbenv and used it to install ruby. (change it if you don't want it)
##
## Export Mac OS specific $PATH: (This may be different for older versions of Mac OS)
export PATH="$HOME/.bin:$HOME/.local/bin:/usr/local/bin:/opt/local/bin:/opt/local/sbin:/Library/TeX/texbin:/usr/X11/bin:$PATH"
## Export GNU Info Path: (This may be different for older versions of Mac OS)
export INFOPATH="/usr/share/info:$IFOPATH"
## Export Manual Path: (This may be different for older versions of Mac OS)
## export MANPATH="???:$MANPATH"
### ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
## Top Level Mac OS Machine Specific Exports:
## (change these to something else if you need to)
### ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
## Set Default Emacs for programs like cask to use:
export EMACS="/Path/to-your/installed/MacOS/Emacs"
## Define Main GIT Home:
export GIT=$HOME/Documents/GIT
## Define Main WWW directory
export WWW=$HOME/Documents/WWW
## Define Path to Jack2 Repo:
export JACK='/Users/alisha/Documents/001-Harmonic-Alchemy-Productions/Resources/003-Music-Apps/Audio-Loop-Back-Apps/Jack-2/github.src.repo'
###
## Ensure 'gpg-agent' (not ssh-agent) is running when a SSH client needs it.
## NOTE: This assumes you are using a PGP "Auth" [A] subkey instead of the
## standard SSH key with ssh-agent as your local cached SSH key when
## connecting to SSH HOSTS. If you connect with SSH the standard way
## instead, comment out the next two lines...
gpg-connect-agent /bye
export SSH_AUTH_SOCK=$(gpgconf --list-dirs agent-ssh-socket)
### ~~~~~~~~~~~~~~~~~~~~
## END: Mac OS Specific Configs...
## DEBUG Print Statements: (Export SH_DBG in your shell session to enable)
if [ "$SH_DBG" = true ] ; then
echo "\$DOTFILES/.bash_common - END: MAC-OS CASE"
fi
### ~~~~~~~~~~~~~~~~~~~~
fi
### ~~~~~~~~~~~~~~~~~~~~~~~~~
## END: OS Specific Section:
### ~~~~~~~~~~~~~~~~~~~~~~~~~
### ~~~~~~~~~~~~~~~~~~~~
## BEGIN: Generic Platform Independent Exports (all unix flavors):
## DEBUG Print Statements: (Export SH_DBG in your shell session to enable)
if [ "$SH_DBG" = true ] ; then
echo "\$DOTFILES/.bash_common - BEGIN: Final Generic Section"
fi
### ~~~~~~~~~~~~~~~~~~~~
###
## Export your PGP Primary Key Fingerprint for easy input for commands etc.
export SFING="0xFFFFAAAA55550000FFFFAAAA55550000FFFFAAA"
###
## Ensure GnuPG gets the output of the 'tty' command.
export GPG_TTY=$(tty)
###
## Use Python & PIP 3 (this may also be needed by shell scripts)
#alias pip="pip3"
alias python="python3"
###
## Platform Independent Global Directory Definitions:
## Define Global Path to your Development SandBox (DSB)
export DSB=$GIT/dev-sandbox
## Define Global Path to Tools Presets (for tools like .dotfiles) home directory:
export TOOLS=$GIT/tools-presets
## Define Global Path to public .dotfiles (Github:HarmonicAlchemy)
export DF=$TOOLS/dotfiles
## Define Global Path to My-Docs" home Directory:
export MD=$GIT/My-Docs
## Define your www devOps home directory:
export MWMD=$WWW/devOps
## Define Global Path to your "Personal Templates" home Directory:
export PT=$GIT/Personal-templates
### ~~~~~~~~~~~~~~~~~~~~
## Load NVM: (Node.js, NPM) etc...
## NOTE: This assumes you cloned or installed 'creationix/nvm' from Github locally
## in your $HOME environment. The next lines set up that environment for you...
## If you are not using NVM than comment out this section!! You will
## eventually need this for some nice web-apps and tools though!
## DEBUG Print Statements: (Export SH_DBG in your shell session to enable)
if [ "$SH_DBG" = true ] ; then
echo "\$DOTFILES/.bash_common - LOAD: NVM Enviornment & Completions"
fi
### ~~~~~~~~~~~~~~~~~~~~
export NVM_DIR="$HOME/.nvm"
## Load nvm:
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
## Load NVM bash_completion:
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"
### ~~~~~~~~~~~~~~~~~~~~
## Load rbenv Ruby Version Management Tool:
## NOTE: Make sure you have cloned rbenv from Github to $HOME/.rbenv!
## If you decide not to use rbenv comment out this section and remove
## the .rbenv paths from above path export line as well...
## DEBUG Print Statements: (Export SH_DBG in your shell session to enable)
if [ "$SH_DBG" = true ] ; then
echo "\$DOTFILES/.bash_common - LOAD: Ruby Version Management Tool"
fi
#### ~~~~~~~~~~~~~~~~~~~~
if which rbenv > /dev/null; then
eval "$(rbenv init -)";
fi
### ~~~~~~~~~~~~~~~~~~~~
## END: Generic Platform Independent Exports (all unix flavors):
## END: ~/.bash_common - Leaving File...
## DEBUG Print Statements: (Export SH_DBG in your shell session to enable)
if [ "$SH_DBG" = true ] ; then
echo "\$DOTFILES/.bash_common - END: Final Generic Section - Leaving File"
fi
### ~~~~~~~~~~~~~~~~~~~~
#### ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
## END: $HOME/.bash_common
#### ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~