This repository has been archived by the owner on Nov 12, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbashrc
199 lines (169 loc) · 6.62 KB
/
bashrc
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
#!/bin/bash
# BASHRC - Bash Settings, Prompt Cust, Config Settings and Sources Additional Files
#
# This script is a component of ConfigCloud
# https://github.com/robertpeteuil/configcloud
#
# Robert Peteuil (c) 2018
#
bashconfigname=".bashrc"
bashconfignum="2.0.12"
bashconfigdate="2018-08-23"
# EXIT IF NOT RUNNING INTERACTIVELY
case $- in
*i*) ;;
*) return;;
esac
###### BAIL IF NOT RUNNING BASH
if [ -z "$BASH_VERSION" ]; then
export PATH
return &> /dev/null || exit
fi
###### SET PROMPT TYPE
# unset prompt_style # typical-style prompt
# prompt_style="GIT" # 2-line prompt, displays info for repo dirs
# prompt_style="DEMO" # prompt for screen-caps, displays string set in $DEMOHOST var
prompt_style="GIT"
# DEMOHOST used and required if prompt_style="DEMO"
DEMOHOST="Host"
###### VARS
OS=$(uname -s)
###### FUNCTIONS
ver_configfiles() {
[[ -n $profilename ]] && echo "${profilename} v${profilenum} - ${profiledate}"
[[ -n $bashconfigname ]] && echo "${bashconfigname} v${bashconfignum} - ${bashconfigdate}"
[[ -n $aliasfilename ]] && echo "${aliasfilename} v${aliasfilenum} - ${aliasfiledate}"
[[ -n $cloudrcname ]] && echo "${cloudrcname} v${cloudrcnum} - ${cloudrcdate}"
return 0
}
sourceIf () {
if [ -e "$1" ]; then
. "$1"
fi
}
pathIf () {
if [ -d "$1" ] && [[ $PATH != *"$1"* ]]; then
PATH="$PATH:$1"
fi
}
###### ADD DIRS TO PATH IF EXIST
pathIf "/usr/local/bin"
pathIf "/usr/local/sbin"
pathIf "$HOME/bin"
pathIf "$HOME/.local/bin"
pathIf "$HOME/scripts"
pathIf "$HOME/pycharm-2017.2.4/bin"
pathIf "/usr/lib/go-1.9/bin"
###### CHECK FOR REBOOT REQUIRED
if [[ "$OS" == "Linux" ]] && [[ -f /var/run/reboot-required ]]; then
echo "*** System restart required ****"
fi
###### BASH CONFIG
# don't put duplicate lines or lines starting with space in the history.
HISTCONTROL=ignoreboth
# append to the history file, don't overwrite it
shopt -s histappend
# for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
HISTSIZE=1000
HISTFILESIZE=2000
# check the window size after each command and, if necessary,
# update the values of LINES and COLUMNS.
shopt -s checkwinsize
# If set, the pattern "**" used in a pathname expansion context will
# match all files and zero or more directories and subdirectories.
shopt -s globstar
# make less more friendly for non-text input files, see lesspipe(1)
#[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"
# SET BASH SCRIPT TRACE PROMPT
export PS4='$LINENO + '
# SET FILE DEFAULT MODE
umask 0002
###### SET PROMPT AND DEFINE COLOR VARS
# DETERMINE COLOR CAPABILITY
if [ -x /usr/bin/tput ] && $(tput setaf 1 &> /dev/null); then
color_enabled=yes
fi
case "$TERM" in
xterm*) color_enabled=yes;;
ansi) color_enabled=yes;;
vt102) color_enabled=yes;;
linux) color_enabled=yes;;
esac
# SET PROMPT ITEMS
ESCON="\["
ESCOFF="\]"
P_TIME="\@"
P_HOSTNAME="\h"
P_USER="\u"
P_DIR="\w"
P_DIR_SM="\W"
P_SYMBOL="\$ "
# SET COLOR VARS
if [ "$color_enabled" = yes ]; then
COLOR_RESET="\033[0m"
BLUE="\033[1;34m"
WHITE="\033[1;37m"
RED="\033[1;31m"
GREEN="\033[0;32m"
YELLOW="\033[0;33m"
CYAN="\033[0;36m"
PBLUE="${ESCON}${BLUE}${ESCOFF}"
PWHITE="${ESCON}${COLOR_RESET}${ESCOFF}"
PGREEN="${ESCON}${GREEN}${ESCOFF}"
PRED="${ESCON}${RED}${ESCOFF}"
PYELLOW="${ESCON}${YELLOW}${ESCOFF}"
PCYAN="${ESCON}${CYAN}${ESCOFF}"
fi
if [[ $TERM == "linux" ]]; then
PWHITE="${ESCON}${WHITE}${ESCOFF}"
fi
###### PROMPT
if [[ $prompt_style == "GIT" ]] && [[ -e "$HOME/.bash-git-prompt/gitprompt.sh" ]]; then
export PROMPT_COMMAND='echo -ne "\033]1;"$(hostname -s)"\007"'
GIT_PROMPT_IGNORE_SUBMODULES=1
GIT_PROMPT_THEME_FILE=~/.bash-git-prompt/custom_config.sh
. "$HOME/.bash-git-prompt/gitprompt.sh"
elif [[ $prompt_style == "DEMO" ]]; then
export PROMPT_COMMAND='echo -ne "\033]1;${DEMOHOST}\007"'
if [ "$(id -u)" -eq 0 ]; then
export PS1="${PRED}${DEMOHOST}${COLOR_RESET}:${PYELLOW}${P_DIR}${COLOR_RESET}${P_SYMBOL}"
else
export PS1="${PGREEN}${DEMOHOST}${COLOR_RESET}:${PCYAN}${P_DIR}${COLOR_RESET}${P_SYMBOL}"
fi
export SUDO_PS1="${PRED}${DEMOHOST}${COLOR_RESET}:${PYELLOW}${P_DIR_SM}${COLOR_RESET}${P_SYMBOL}"
else
export PROMPT_COMMAND='echo -ne "\033]1;"$(hostname -s)"\007"'
if [ "$(id -u)" -eq 0 ]; then
export PS1="${PRED}${P_HOSTNAME}${COLOR_RESET}:${PYELLOW}${P_DIR}${COLOR_RESET}${P_SYMBOL}"
else
export PS1="${PGREEN}${P_HOSTNAME}${COLOR_RESET}:${PCYAN}${P_DIR}${COLOR_RESET}${P_SYMBOL}"
fi
export SUDO_PS1="${PRED}${P_HOSTNAME}${PWHITE}:${PYELLOW}${P_DIR_SM}${COLOR_RESET}${P_SYMBOL}"
fi
# AVOID XTERM-NEW ON DEBIAN
if [[ -f /etc/debian_version ]] ; then
if [[ "$TERM" == "xterm-new" ]]; then
export TERM="xterm"
fi
fi
export GOPATH="${HOME}/go"
if [ -x /usr/bin/dircolors ]; then
test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
fi
if [[ -n "$HUSHLOGIN" ]]; then
export LS_COLORS='rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:mi=00:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arc=01;31:*.arj=01;31:*.taz=01;31:*.lha=01;31:*.lz4=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.tzo=01;31:*.t7z=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.dz=01;31:*.gz=01;31:*.lrz=01;31:*.lz=01;31:*.lzo=01;31:*.xz=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.alz=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.cab=01;31:*.jpg=01;35:*.jpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.webm=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.m4a=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.oga=00;36:*.opus=00;36:*.spx=00;36:*.xspf=00;36:'
fi
if ! shopt -oq posix; then
sourceIf "/usr/share/bash-completion/bash_completion"
sourceIf "/etc/bash_completion"
fi
export PATH
export GCC_COLORS='error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01'
unset color_enabled
GRC=$(which grc 2>/dev/null)
if [ "$TERM" != dumb ] && [ -n "$GRC" ]; then
sourceIf "$HOME/.grc/grc.bashrc"
fi
###### SOURCE FILES
sourceIf "$HOME/.cloudrc"
sourceIf "$HOME/.aliases"