-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbashrc
More file actions
197 lines (156 loc) · 4.52 KB
/
bashrc
File metadata and controls
197 lines (156 loc) · 4.52 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
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
# .bashrc
## Prevent bashrc from being evaluated multiple times.
# _BASHRC should not be exported. If it is, then remove it.
if declare -px _BASHRC &>/dev/null; then
unset _BASHRC
fi
# Early exit if this file has been imported already.
if [[ $_BASHRC -eq 1 ]]; then
return
fi
_BASHRC=1
# Settings for interacive sessions
if [[ $- == *i* ]]; then
#Disable Flow Control
stty ixoff -ixon
stty ixany
ps1_hide() {
PS1="\\$ "
bind 'set show-mode-in-prompt off'
}
ps1_min() {
PS1="\[\e[01;34m\]\\W\[\e[00;37m\]\\$ \[\e[0m\]"
bind 'set show-mode-in-prompt off'
}
ps1_show() {
if declare -f __git_ps1 > /dev/null; then
# PS1: username@hostname:directory[history_number](git_branch)$
PS1="\[\e[00;32m\]\u@\h\[\e[0m\]\[\e[00;37m\]:\[\e[0m\]\[\e[01;34m\]\w\[\e[0m\]\[\e[00;37m\][\\!]\$(__git_ps1 \"(%s)\")\\$ \[\e[0m\]"
else
# PS1: username@hostname:directory[history_number]$
PS1="\[\e[00;32m\]\u@\h\[\e[0m\]\[\e[00;37m\]:\[\e[0m\]\[\e[01;34m\]\w\[\e[0m\]\[\e[00;37m\][\\!]\\$ \[\e[0m\]"
fi
bind 'set show-mode-in-prompt on'
}
ps4_debug() {
export PS4='+(${BASH_SOURCE}:${LINENO}): ${FUNCNAME[0]:+${FUNCNAME[0]}(): }'
}
ps4_no_debug(){
export PS4='+ '
}
ps1_show
ps4_debug
fi
shopt -s nullglob
for rc in "$HOME"/.bashrc.*; do
source $rc
done
shopt -u nullglob
# Enable extended globstar '**'
shopt -s globstar
# Restore multiline commands from history
shopt -s lithist
# update window size
shopt -s checkwinsize
# multiline cmds saved as one in history
shopt -s cmdhist
# Append history, and
# commit previous command to history
shopt -s histappend
# Add history incrementally. Respect pre-existing PROMPT_COMMAND.
if [[ "${PROMPT_COMMAND[*]:-}" != *"history -a"* ]]; then
if [[ "$(declare -p PROMPT_COMMAND 2>/dev/null)" =~ "declare -a" ]]; then
PROMPT_COMMAND+='history -a'
else
PROMPT_COMMAND="history -a${PROMPT_COMMAND:+;$PROMPT_COMMAND}"
fi
fi
# trim path in prompt
export PROMPT_DIRTRIM=2
env_darwin() {
# alias ls='ls -G'
# alias l.='ls -dG .*'
alias l@='/bin/ls -halF -@eO'
}
env_fedora() {
command -v open &>/dev/null || { command -v xdg-open &>/dev/null && alias open='xdg-open' ; } || echo Cannot find 'open' or 'xdg-open'.
{ command -v vimx &>/dev/null && alias vim='vimx' ; } || command -v vim &>/dev/null || echo Cannot find 'vim' or 'vimx'.
export EDITOR=vim
[[ -f /usr/share/git-core/contrib/completion/git-prompt.sh ]] \
&& source /usr/share/git-core/contrib/completion/git-prompt.sh
[[ -f /usr/share/bash-completion/bash_completion ]] \
&& source /usr/share/bash-completion/bash_completion
}
# Aliases
alias ..='cd ..'
alias sl=ls
alias ls='ls --color=auto'
alias l.='ls -d .* --color=auto'
alias ll='ls -halF'
alias l1='ls -1'
alias lu='ls -ltu'
alias mkdir='mkdir -pv'
alias df='df -H'
alias du='du -ch'
alias grep='grep --color=auto'
alias egrep='egrep --color=auto'
alias fgrep='fgrep --color=auto'
alias wget='wget -c'
alias digs='dig +noall +answer +short'
alias g='git'
alias groot='cd $(git rev-parse --show-toplevel)'
## SSL Testing
# Remote - Check Trust Chain
ssl_scerts() {
local tmp
tmp=$(mktemp -d ssl_scerts.XXXXXXXXXX)
openssl s_client -showcerts -connect "$@" </dev/null 2>/dev/null \
| cat
# | awk -v tmp="$tmp/" '/-----BEGIN CERTIFICATE-----/{f=1; x=++i; buf=""} f{buf = buf $0 RS} /-----END CERTIFICATE-----/{print buf > tmp x ".cert"; f=0}'
# for cert in "$tmp"/*.cert; do
# echo
# openssl x509 -in "$cert" -out - -text
# done
# rm -rf "$tmp"
}
ssl_strust() {
openssl s_client -connect $1 </dev/null 2> /dev/null \
| sed -n '/Acceptable/,/Client/p'
}
# Client - Check Trust Chain
ssl_ctrust() {
for cert in "$@"; do
keytool -printcert -v -file "$cert"
done
}
# Client - Cert Signature
ssl_ccert() {
for cert in "$@"; do
echo "$cert"
openssl x509 -inform PEM -in "$cert" -noout -text -issuer -email -purpose
done
}
# OS Corrections
case $OSTYPE in
solaris*) ;;
darwin*) env_darwin;;
linux*)
# Fedora
[[ -f /etc/fedora-release ]] && env_fedora
# Ubuntu
[[ -f /usr/lib/git-core/git-sh-prompt ]] \
&& source /usr/lib/git-core/git-sh-prompt
;;
cygwin*) ;;
bsd*) ;;
*) echo '***** OSTYPE='$OSTYPE '*****' ;;
esac
# Use VIM as editor
export EDITOR=vim
# __timestamp="\[\e[01;32m\][\[\e[00;37m\]"'$(history 1)'"\[\e[01;32m\]]\[\e[0m\]\n"
# export PS0="$__timestamp"
# Python
export PYTHONDONTWRITEBYTECODE=1
# curl - log SSL keyfile for inspecting https traffic
export ENABLE_SSLKEYLOGFILE=1
export SSLKEYLOGFILE="${HOME}/.ssh/tlskey"