-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path.bashrc
More file actions
515 lines (398 loc) · 16.5 KB
/
.bashrc
File metadata and controls
515 lines (398 loc) · 16.5 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
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
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
# Add RVM to PATH for scripting. Make sure this is the last PATH variable change.
export PATH="$PATH:$HOME/.rvm/bin:/Users/decal/homebrew/bin:/Users/decal/homebrew/opt/go/libexec/bin:/Users/decal/.cargo/bin"
#BASHISHDIR="/Users/decal/homebrew/Cellar/bashish/2.2.4/share/bashish" ## line added by bashish
#TTY=`tty 2>/dev/null` && if test "x$BASHISHDIR" != x;then ## line added by bashish
#test "$BASHISH_OLDPATH"||BASHISH_OLDPATH="$PATH" ## line added by bashish
#PATH="$HOME/.bashish/launcher:$BASHISHDIR/lib:$BASHISH_OLDPATH:$GOPATH/bin" ## line added by bashish
#BASHSISH_CP=437 ## line added by bashish
#TEST_TERM="$TERM" _bashish_utfcheck && BASHISH_CP=utf8 ## line added by bashish
#ENV="$HOME/.profile" ## line added by bashish
#export BASHISH_CP BASHISH_OLDPATH TTY ENV ## line added by bashish
#. "$BASHISHDIR/main/prompt/sh/init" ## line added by bashish
#fi ## line added by bashish
export HOMEBREW="${HOME}/homebrew"
export DOTFILES="${HOME}/GIT/decal/dotfiles" WERDLISTS="${HOME}/GIT/decal/werdlists"
export HB="$HOMEBREW" DF="$DOTFILES" WL="$WERDLISTS"
export PDFTK=/usr/local/bin/pdftk
export MOSH_PREDICTION_DISPLAY=adaptive
export HOMEBREW_CASK_OPTS='--require-sha'
export HOMEBREW_PRY=1 HOMEBREW_VERBOSE=1
export HOMEBREW_NO_INSECURE_REDIRECT=1 HOMEBREW_NO_ANALYTICS=1
# ~/.bashrc: executed by bash(1) for non-login shells.
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc) for examples
[ -f ~/.bash_aliases ] && source ~/.bash_aliases
# tail ~/TODO
# If not running interactively, don't do anything
case $- in
*i*) ;;
*) return;;
esac
# Allow ctrl-S for history navigation (with ctrl-R)
stty -ixon
# How often to check for mail (zero means disable)
export MAILCHECK=0
# File to check for new mail when MAILCHECK is greater than zero
# export MAIL=mbox
# MAILPATH is only used when MAIL is unset
# export MAILPATH='/var/mail/bfox?"You have mail":~/shell-mail?"$_ has mail!"'
# Don't put duplicate lines or lines starting with space in the history; see bash(1) for more info
export HISTCONTROL='ignorespace:erasedups:ignoredups' HISTIGNORE='ls:cd:pwd:jobs:exit:date:history*:. *:*
--help:* -h'
# these are export in an attempt to stop script kiddies from avoiding bash history
export HISTSIZE=4096
export HISTFILESIZE=$HISTSIZE
export HISTTIMEFORMAT='%M-%d-%Y %H:%M:%S ' # HISTFILE='~/.bash_history'
export POWERLINE_HIDE_USER_NAME=1 POWERLINE_PATH='short'
export BETTER_EXCEPTIONS=1
# make less more friendly for non-text input files, see lesspipe(1)
[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"
# set variable identifying the chroot you work in (used in the prompt below)
if [ -z "${debian_chroot:-}" ] && [ -r /etc/debian_chroot ]; then
debian_chroot=$(cat /etc/debian_chroot)
fi
# set a fancy prompt (non-color, unless we know we "want" color)
case "$TERM" in
xterm-color|*-256color) color_prompt=yes;;
esac
# uncomment for a colored prompt, if the terminal has the capability; turned
# off by default to not distract the user: the focus in a terminal window
# should be on the output of commands, not on the prompt
force_color_prompt=yes
if [ -n "$force_color_prompt" ]; then
if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
# We have color support; assume it's compliant with Ecma-48
# (ISO/IEC-6429). (Lack of such support is extremely rare, and such
# a case would tend to support setf rather than setaf.)
color_prompt=yes
else
color_prompt=
fi
fi
if [ "$color_prompt" = yes ]; then
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@UFO\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
else
PS1='${debian_chroot:+($debian_chroot)}\u@UFO:\w\$ '
fi
unset color_prompt force_color_prompt
# enable color support of ls and also add handy aliases
if [ -x /usr/bin/dircolors ]; then
test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
alias aout='gcc -O2 -fopenmp -Wall -o $1 $1.c && ./$1'
fi
# colored GCC warnings and errors
export GCC_COLORS='error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01'
# ls colors
export LS_COLORS='no=00:fi=00:di=00;34:ln=01;36:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.gz=01;31:*.bz2=01;31:*.deb=01;31:*.rpm=01;31:*.jar=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:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.avi=01;35:*.fli=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.ogg=01;35:*.mp3=01;35:*.wav=01;35:*.xml=00;31:*.scm=01;32:*.md=01;33:'
# a black
# b red
# c green
# d brown
# e blue
# f magenta
# g cyan
# h light grey
# A bold black, usually shows up as dark grey
# B bold red
# C bold green
# D bold brown, usually shows up as yellow
# E bold blue
# F bold magenta
# G bold cyan
# H bold light grey; looks like bright white
# x default foreground or background
# 1. directory
# 2. symbolic link
# 3. socket
# 4. pipe
# 5. executable
# 6. block special
# 7. character special
# 8. executable with setuid bit set
# 9. executable with setgid bit set
# 10. directory writable to others, with sticky bit
# 11. directory writable to others, without sticky bit
# default: export LSCOLORS="exfxcxdxbxegedabagacad"
export LSCOLORS="xExGxCxDCxEFEDBxDxxCxH"
# for MacOS ls
export CLICOLOR=1 CLICOLOR_FORCE=1
# long file listing column widths: inode, block count, number of links, user name, group name, flags, file size, file name.
export LS_COLWIDTHS=2:2:2:2:2:4:0:8:10:20:20
# truecolor environment variables
export TRUECOLOR=1 MICRO_TRUECOLOR=1
# enable programmable completion features (you don't need to enable
# this, if it's already enabled in /etc/bash.bashrc and /etc/profile
# sources /etc/bash.bashrc).
if ! shopt -oq posix; then
if [ -f /usr/share/bash-completion/bash_completion ]; then
. /usr/share/bash-completion/bash_completion
elif [ -f /etc/bash_completion ]; then
. /etc/bash_completion
fi
fi
umask 0027
# https://stackoverflow.com/questions/1537956/bash-limit-the-number-of-concurrent-jobs
function max_bg_procs {
if [[ $# -eq 0 ]] ; then
echo 'usage: max_bg_procs NUM_PROCS'
echo
echo ' NUM_PROCS wait until background process count (checked by \`jobs -pr\`) is less than this'
echo
echo 'ex. max_bg_procs 30'
return 1
fi
local -i max_number=$((0 + ${1:-0}))
while true; do
local -i current_number=$(jobs -pr | wc -l)
[[ $current_number -lt $max_number ]] && break
sleep 1
done
return 0
}
function cater {
for f in "$*"
do coderay $f
done
return 0
}
# path_prepend, path_append and mkcd are from https://github.com/uberspot/dotfiles
path_prepend() {
if test -d "$1"; then
PATH="$1:$PATH"
fi
}
path_append() {
if test -d "$1"; then
PATH="$PATH:$1"
fi
}
mkcd() {
mkdir -p "$1"
builtin cd "$1"
}
function dmgrm {
if [ ! "$1" ]; then
echo
echo "usage: $0 PATH"
echo
echo ' PATH location of DMG file to remove and re-create with cleared permissions'
echo
echo 'ex. dmgrm "Waterfox 56.2.5 Setup.dmg"'
echo
return 1
fi
[ ! -s "$1" ] && echo "*** $1 does not exist or is already empty!" && return 2
chmod -v a+w -- "$1"
rm -f -- "$1"
touch -- "$1"
chmod -v 0 -- "$1"
ls -lF@ -- "$1"
return $?
}
function psax {
if [ ! "$1" ]; then
/bin/ps ax
else
/bin/ps ax | egrep -i -- "$1"
fi
return $?
}
function psaux {
if [ ! "$1" ]; then
/bin/ps aux
else
/bin/ps aux | egrep -i -- "$1"
fi
return $?
}
function pself {
if [ ! "$1" ]; then
/bin/ps -elf
else
/bin/ps -elf | egrep -i -- "$1"
fi
return $?
}
# Download an individual file from GitHub
function ghfile {
if [ ! "$3" ]
then echo
echo "usage: $0 USER REPO PATH"
echo
echo ' USER user name of account to download file from'
echo ' REPO the repository of the project file is in'
echo ' PATH path to file within given repository'
echo
echo 'ex. ghfile decal werdlists software-strs/README.md'
echo
return 1
fi
wget -k --continue --show-progress -- "https://raw.githubusercontent.com/${1}/${2}/master/${3}"
return $?
}
function compile {
if [ ! "$1" ]
then echo
echo "usage: $0 FILE"
echo
echo ' FILE name of source code file to compile'
echo
echo 'ex. compile hello.c'
echo
return 1
fi
declare aout=`basename $1 .c`
gcc -O2 -fopenmp -Wall -pedantic -o "$aout" "$1"
return $?
}
function header {
coderay $1 | head -n 20
}
function tailer {
coderay $1 | tail -n 20
}
function lesser {
coderay $1 | most
}
function timeout() { perl -e 'alarm shift; exec @ARGV' "$@"; }
## TODO: add this and any other related aliases that need to be made to githose repo
## TODO: move all functions into .bash_functions
function clone {
if [[ $1 =~ .*/.* ]]; then
git clone -v "https://github.com/${1}" 2>/dev/null &
return $?
fi
[ ! "$2" ] && echo 'usage: clone USER REPO1 [REPO2 [...]]' && return 1
local auser="$1"
local -i aretn=0
shift
for r in $*; do
git clone -v "https://github.com/${auser}/${r}" 2>/dev/null &
[ $? -gt 0 ] && aretn+=$?
done
return $aretn
}
function pull {
local -i aretn=0 nargs=$#
[ ! $1 ] && echo 'usage: pull DIR [...]' && return 1
for d in $*; do
cd "$d"
git pull -v 2>/dev/null &
cd "$OLDPWD"
done
for n in `seq 1 $nargs`; do
wait
[ $? -gt 0 ] && aretn+=$?
done
return $aretn
}
function maxnice {
renice -n -20 `pidof $*`
return $?
}
function remirrors {
[ ! "$1" ] && echo "usage: remirrors HOSTDIR" && return 1
local -i aretn=0
for urlstr in $(find $1 -type d -print)
do nice wget --tries=2 -4 -m -np -nc -k -- "https://${urlstr}"
[ $? -gt $aretn ] && aretn+=$?
done
return $aretn
}
function remirror {
[ ! "$1" ] && echo "usage: remirror HOSTDIR" && return 1
local -i aretn=0
for urlstr in `find $1 -type d -print`
do nice wget --tries=2 -4 -m -np -nc -- "http://${urlstr}"
[ $? -gt 0 ] && aretn+=$?
done
return $aretn
}
function pipx {
local -i rc=0
/usr/bin/pip3 $*
[ $? -ne 0 ] && rc=$?
/usr/bin/pip $*
[ $? -ne 0 ] && rc=$?
return $rc
}
# grep through the output of an apt-cache command for parallel programming related items
function apt-cache-para() {
[ ! $1 ] && echo "usage: ${0} apt-cache-para [OPTIONS] COMMAND" && return 1
apt-cache $* | egrep -i '(concur|para|thread|LWP|proc|fiber|event|block|async)'
return $?
}
export CDPATH='.:~:~/GIT/decal:~/GITLAB/decal/:~/repos:~/gists:~/github:~/cmds'
export GOPATH='/opt' GOOS=`uname -s | tr '[A-Z]' '[a-z]'` GOARCH=amd64
export GOROOT="$GOPATH/go"
export LD_LIBRARY_PATH='~/lib:~/local/lib:/usr/local/lib:/opt/lib:/opt/local/lib'
export RUBYLIB='~/GIT/decal/zap-attack/lib:~/GIT/decal/aemscanio/lib:~/GIT/decal/combos_permutedirs/lib:~/GIT/decal/dirverser/lib:~/GIT/decal/percent_encode/lib:~/GIT/decal/filb/lib:'
export EDITOR=/usr/bin/vim PAGER=/usr/bin/less MANPAGER="/usr/bin/less -X" HTMLPAGER='lynx -dump'
export BAT_THEME=OneHalfDark BAT_STYLE=full GREP_OPTIONS="--color=auto"
export GIT_EDITOR="$EDITOR" GIT_PAGER="$PAGER"
export MAKEFLAGS='-j4' MOST_SWITCHES='-sc'
export LANG='en_US' LC_ALL='en_US.UTF-8'
export LESS='-wx2 -frP "?f%f .?ltLine %lt:?pt%pt\%:?btByte %bt:-..."' LESSSECURE=1
# Each history-related variable is exported individually to prevent log evasion
export LESSHISTSIZE=128 LESS_IS_MORE=1
set -o vi
set visible-stats=on colored-stats=on completion-ignore-case=on completion-query-items=256 mark-symlinked-directories=on mark-modified-lines=on
export OPTERR=1 IGNOREEOF=2 FIGNORE='.o:~:.core:.swp:#:-:.dpkg-new' # TMOUT=4
function echo_shopt {
echo shopt -u $(shopt | egrep 'off$' | awk '{print$1}' | tr '\n' ' ')
echo shopt -s $(shopt | egrep 'on$' | awk '{print$1}' | tr '\n' ' ')
return 0
}
if [ `uname -s` != 'Darwin' ]
then shopt -u autocd cdable_vars cdspell checkhash checkjobs compat31 compat32 compat40 compat41 compat42 direxpand dirspell dotglob execfail extdebug failglob globasciiranges gnu_errfmt histverify hostcomplete huponexit lastpipe mailwarn no_empty_cmd_completion nocaseglob nocasematch nullglob restricted_shell shift_verbose xpg_echo
shopt -s checkwinsize cmdhist complete_fullquote expand_aliases extglob extquote force_fignore globstar histappend histreedit interactive_comments lithist login_shell progcomp promptvars sourcepath
else
alias apropos='PAGER=cat MANPAGER=cat apropos'
alias man-k='PAGER=cat MANPAGER=cat man -k'
alias whatis='PAGER=cat MANPAGER=cat whatis'
fi
bind '"\e[A": history-search-backward'
bind '"\e[B": history-search-forward'
# The next line updates PATH for the Google Cloud SDK.
#source '/home/decal/google-cloud-sdk/path.bash.inc' 2>/dev/null
# The next line enables shell command completion for gcloud.
#source '/home/decal/google-cloud-sdk/compleion.bash.inc' 2>/dev/null
# autocompletion
which pandoc; [ $? -eq 0 ] && eval "$(pandoc --bash-completion)"
export PATH="/Users/decal/bin:/usr/lib/go-1.6/bin:${HOME}/homebrew/bin:${HOME}/.linuxbrew/bin:/home/decal/perl5/bin:/home/decal/perl5/perlbrew/bin:$PATH:/sbin:/usr/sbin:/usr/local/sbin:/usr/local/bin"
# Less colors.. makes man pages easier to read!
#export LESS_TERMCAP_mb=$'\E[01;31m' LESS_TERMCAP_md=$'\E[01;31m'
#export LESS_TERMCAP_me=$'\E[0m' LESS_TERMCAP_se=$'\E[0m'
#export LESS_TERMCAP_so=$'\E[01;44;33m' LESS_TERMCAP_ue=$'\E[0m'
#export LESS_TERMCAP_us=$'\E[01;32m'
# Prompt for decision when a test fails, verify integrity of distribution files
# with CHECKSUMS and SIGNATURES, search other mirrors if missing from first
# Refer to `perldoc cpanm` for more information..
export PERL_CPANM_OPT='--cascade-search --prompt --verify'
# Path name shortcuts for WSL
if [ `uname -s` != 'Darwin' ]
then
export PERL_LOCAL_LIB_ROOT="/home/decal/perl5${PERL_LOCAL_LIB_ROOT:+:${PERL_LOCAL_LIB_ROOT}}"
export PERL_MB_OPT='--install_base "/home/decal/perl5"' PERL_MM_OPT='INSTALL_BASE=/home/decal/perl5'
export PERL5LIB="/home/decal/perl5/lib/perl5${PERL5LIB:+:${PERL5LIB}}"
export DECAL='/mnt/c/Users/decal' DESKTOP='/mnt/c/Users/decal/Desktop' DOWNLOADS='/mnt/c/Users/decal/Downloads'
else
export PERL_LOCAL_LIB_ROOT="/Users/decal/perl5${PERL_LOCAL_LIB_ROOT:+:${PERL_LOCAL_LIB_ROOT}}"
export PERL_MB_OPT='--install_base "/Users/decal/perl5"' PERL_MM_OPT='INSTALL_BASE=/Users/decal/perl5'
export PERL5LIB="/Users/decal/perl5/lib/perl5${PERL5LIB:+:${PERL5LIB}}"
export DECAL='/Users/decal' DESKTOP='/Users/decal/Desktop' DOWNLOADS='/Users/decal/Downloads'
fi
###-tns-completion-start-###
if [ -f /Users/decal/.tnsrc ]; then
source /Users/decal/.tnsrc
fi
###-tns-completion-end-###
#if [ -f $(brew --prefix)/opt/mcfly/mcfly.bash ]; then
# . $(brew --prefix)/opt/mcfly/mcfly.bash
#fi
# tabtab source for serverless package
# uninstall by removing these lines or running `tabtab uninstall serverless`
[ -f /Users/decal/homebrew/lib/node_modules/serverless/node_modules/tabtab/.completions/serverless.bash ] && . /Users/decal/homebrew/lib/node_modules/serverless/node_modules/tabtab/.completions/serverless.bash
# tabtab source for sls package
# uninstall by removing these lines or running `tabtab uninstall sls`
[ -f /Users/decal/homebrew/lib/node_modules/serverless/node_modules/tabtab/.completions/sls.bash ] && . /Users/decal/homebrew/lib/node_modules/serverless/node_modules/tabtab/.completions/sls.bash
export PATH=$(echo $PATH | tr ':' '\n' | sort -uR | tr '\n' ':')