-
Notifications
You must be signed in to change notification settings - Fork 15
/
_bashrc
146 lines (130 loc) · 4.18 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
shopt -s globstar
set +o histexpand
bind '\C-w:backward-kill-word' 2>/dev/null
stty -ixon >/dev/null 2>&1 || true # disable flow control
_PS1() {
local pre= name="$1" len="$2";
[[ "$name" != "${name#$HOME/}" || -z "${name#$HOME}" ]] &&
pre=$pre'~' name="${name#$HOME}" len=$[len-1];
((${#name}>$len)) && name="/...${name:$[${#name}-len+4]}";
echo "$pre$name"
}
PS1='\[\e[1;92m\]\h\[\e[m\]\[\e[1;95m\]$(_PS1 "$PWD" 30)\[\e[m\] '
clearenv() {
local var
while IFS== read -rd '' var _; do
export -n "$var" 2>/dev/null || true
done < <(env -0)
export PATH="/bin:/usr/bin:/sbin:/usr/sbin:/usr/games"
export BROWSER="firefox"
export EDITOR="vim"
export KEYID="5EEB8C8D5069C4E9B94AA852AFD1503A8C8FF42A"
export WINEDEBUG="-all"
export EMAIL="wellons@nullprogram.com"
export REALNAME="Christopher Wellons"
export DISPLAY HOME LANG SHELL TERM XAUTHORITY
export SSH_AGENT_PID SSH_AUTH_SOCK XDG_RUNTIME_DIR XDG_SESSION_TYPE
}
localenv() {
PATH="$HOME/.local/bin:$PATH"
export CPATH="$HOME/.local/include"
export LIBRARY_PATH="$HOME/.local/lib"
export LD_RUN_PATH="$HOME/.local/lib"
export MANPATH="$HOME/.local/share/man:/usr/share/man"
export GOBIN="$HOME/.local/bin"
export GOTOOLCHAIN="local"
export PKG_CONFIG_PATH
PKG_CONFIG_PATH="$HOME/.local/lib/pkgconfig:$HOME/.local/share/pkgconfig"
if [[ "$(uname -m)" == *64* ]]; then
LIBRARY_PATH+=":$HOME/.local/lib64"
LD_LIBRARY_PATH+=":$HOME/.local/lib64"
LD_RUN_PATH+=":$HOME/.local/lib64"
else
LIBRARY_PATH+=":$HOME/.local/lib32"
LD_LIBRARY_PATH+=":$HOME/.local/lib32"
LD_RUN_PATH+=":$HOME/.local/lib32"
fi
}
sanenv() {
local common=abort_on_error=1:halt_on_error=1:allocator_may_return_null=1
ASAN_OPTIONS=$common
ASAN_OPTIONS+=:print_legend=0
ASAN_OPTIONS+=:detect_leaks=0
ASAN_OPTIONS+=:detect_stack_use_after_return=1
UBSAN_OPTIONS=$common
TSAN_OPTIONS=$common
export ASAN_OPTIONS UBSAN_OPTIONS TSAN_OPTIONS
}
if command -v keychain >/dev/null 2>&1; then
eval $(keychain --eval --quiet)
fi
clearenv
export XDG_DESKTOP_DIR="$HOME/trash/"
export XDG_DOCUMENTS_DIR="$HOME/trash/"
export XDG_DOWNLOAD_DIR="$HOME/Downloads"
export XDG_MUSIC_DIR="$HOME/trash/"
export XDG_PICTURES_DIR="$HOME/trash/"
export XDG_PUBLICSHARE_DIR="$HOME/trash/"
export XDG_TEMPLATES_DIR="$HOME/trash/"
export XDG_VIDEOS_DIR="$HOME/trash/"
export XDG_CACHE_HOME="$HOME/trash/"
export XDG_STATE_HOME="$HOME/trash/"
export XDG_DATA_HOME="$HOME/trash/"
export LIBVIRT_DEFAULT_URI=qemu:///system
localenv
sanenv
colorscheme() {
if [[ "$-" == *"i"* ]] && [[ "$TERM" != "dumb" ]]; then
echo -ne '\e]4;0;#2E3436\a' # black
echo -ne '\e]4;1;#CC0000\a' # red
echo -ne '\e]4;2;#4E9A06\a' # green
echo -ne '\e]4;3;#C4A000\a' # yellow
echo -ne '\e]4;4;#3465A4\a' # blue
echo -ne '\e]4;5;#75507B\a' # magenta
echo -ne '\e]4;6;#06989A\a' # cyan
echo -ne '\e]4;7;#BABDB6\a' # white
echo -ne '\e]4;8;#555753\a' # bright black
echo -ne '\e]4;9;#EF2929\a' # bright red
echo -ne '\e]4;10;#8AE234\a' # bright green
echo -ne '\e]4;11;#FCE94F\a' # bright yellow
echo -ne '\e]4;12;#729FCF\a' # bright blue
echo -ne '\e]4;13;#D15CD1\a' # bright magenta
echo -ne '\e]4;14;#34E2E2\a' # bright cyan
echo -ne '\e]4;15;#EEEEEC\a' # bright white
echo -ne '\e]10;#FFFFFF\a' # default foreground
echo -ne '\e]11;#1D1F21\a' # default background
fi
}
colorscheme
title() {
printf "\e]2;%s\a" $1
}
hh() {
if command -v hastyhex >/dev/null 2>&1; then
hastyhex "$@" | less -FRX
else
hexdump -C "$@" | less -FRX
fi
}
loadssh() {
passphrase2pgp -fssh -c5106E713 -uwellons@p2 | ssh-add -
}
httpd() {
python3 -m http.server "${1:-8080}"
}
st() {
if [ $# -lt 1 ]; then
printf 'usage: st HOST [...]\n' >&2
return 1
fi
host="$1"
shift
ssh -t "$host" tmux attach "$@"
}
source ~/.bash_aliases
if [ -e /etc/bash_completion ]; then
source /etc/bash_completion
fi
if [ -f ~/.bash_local ]; then
. ~/.bash_local
fi