-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBMain.bash
More file actions
106 lines (90 loc) · 2.41 KB
/
BMain.bash
File metadata and controls
106 lines (90 loc) · 2.41 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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
# BashShellSetup : Main Setup
# File: BashShellSetup/BSetup.bash
# Author: Amit Roy amitrupu@gmail.com
# Date: 05-Sep-2023
# Skip sourcing rest of bashrc when called not interactively,
# i.e. from scp/rsync
case $- in
*i*) ;;
*) return;;
esac
# Skip sourcing from within gdb
if [[ "$SHELL" != *bash$ ]]; then
export SHELL=/bin/bash
fi
if [[ "$(ps -o command= -p $PPID)" == gdb* ]]; then
echo Skipping .basrc from with gdb ...
return
fi
set +x
# Restore initial BASH environment
if [ -z "$PATH" ]; then
export PATH=/bin:/usr/bin:/usr/local/bin:/usr/local/sbin:/usr/sbin:/sbin
fi
if [ -z "$B_ROOT" ]; then
echo Saving initial BASH environment ...
env | grep -vi path > ~/.bss.env
elif [ -r ~/.bss.env ]; then
export $(grep -v ' \|HOST' ~/.bss.env)
export PATH=${PATH}:/bin:/usr/bin:/usr/local/bin:/usr/local/sbin:/usr/sbin:/sbin
fi
if [ -z "$SSH_CONNECTION" ]; then
rm -f ~/.bss.env
fi
if [ -n "$SGE_O_SHELL" ]; then
rm -f ~/.bss.env
fi
# Installation name and message prefix setup
[ -e ~/.bss.root ] && source ~/.bss.root
[ -z "$B_ROOT" ] && B_ROOT=~/BashShellSetup
function BMsgPrefix {
echo Bash Shell Setup
}
# Debug setup
# B_DEBUG=1
[ -r ~/BSS_DEBUG ] && B_DEBUG=1
[ ${B_DEBUG:=0} -gt 0 ] && echo $(BMsgPrefix) : Setting up Bash ...
# General shell setup
shopt -s checkwinsize
shopt -s extglob
# History setups
export HISTCONTROL="erasedups:ignoreboth"
shopt -s histappend
shopt -s cmdhist
# Backspace bindings
stty erase
stty werase
# Readline key binding
bind '"\ep": history-search-backward'
bind '"\en": history-search-forward'
# Directory and file specific settings
# shopt -s nullglob
# shopt -s cdspell
# shopt -s cdable_vars
# shopt -s nocaseglob
# shopt -s nocasematch
# set -o errexit
# Create commands
source $B_ROOT/BCommands.bash
# Setup window title and prompt
export PWD=$(pwd)
btitle '$PWD'
bprompt green '[host,user:history]'
setterm -cursor on
# Source user specifc setups
unset $(env | grep B_TRACKMOD | awk -F = '{ print $1 }')
bsource ~/$USER.start.bash
bsource ~/$USER.bash
bsource ~/start.bss.bash
if compgen -G "$HOME/bss.*.bash" > /dev/null; then
for setupFile in ~/bss.*.bash; do
[ ${B_DEBUG:=0} -gt 0 ] && read -n 1 -p "Source $setupFile? " press
[ ${B_DEBUG:=0} -gt 0 ] && echo
bsource $setupFile
done
fi
bsource ~/$USER.end.bash
# Path optimization
bchpath . # we can not add dot as old value to replace here
boptpath
# END