-
Notifications
You must be signed in to change notification settings - Fork 0
/
.bashrc
151 lines (132 loc) · 3.68 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
export BASH_SILENCE_DEPRECATION_WARNING=1
export PS1="\[$(tput bold)$(tput setaf 4)\]\u\[$(tput sgr0)\]@\[$(tput bold)$(tput setaf 5)\]\h\[$(tput sgr0)\] \w> "
source "$(dirname "$BASH_SOURCE")/utils.bash"
realpath () {
if ! pushd "$(dirname "$1")" > /dev/null 2>&1; then
return 1
fi
local link=$(readlink "$(basename "$1")")
while [ "$link" ]; do
popd > /dev/null 2>&1
if ! pushd "$(dirname "$link")" > /dev/null 2>&1; then
return 1
fi
link=$(readlink "$(basename "$1")")
done
echo "$PWD/$(basename "$1")"
popd > /dev/null 2>&1
}
pathadd() {
if [ -d "$1" ] && [[ ":$PATH:" != *":$1:"* ]]; then
PATH="$1${PATH:+":$PATH"}"
fi
}
CONFIG="$(realpath "$BASH_SOURCE")"
BIN="$(realpath ~/install/bin)"
pathadd "$BIN"
pathadd "$CONFIG/rbenv/bin"
pathadd "$CONFIG/pyenv/bin"
pathadd "$HOME/.cargo/bin"
# TODO: set up ack ignore filetypes
function search() {
ack "$*"
}
function searchci() {
ack -i "$*"
}
function files() {
ack -l "$*"
}
function filesci() {
ack -li "$*"
}
function git {
if [[ "$1" == "branch" && "$@" != *"--help"* ]]; then
shift 1
command git br "$@"
else
command git "$@"
fi
}
function emoji {
chars=()
for arg in $@; do
arg=$(echo $arg | tr '[:upper:]' '[:lower:]')
for (( i=0; i<${#arg}; i++ )); do
chars+=("${arg:$i:1}")
done
chars+=("_")
done
str=""
for char in ${chars[@]}; do
case $char in
@) str+='\U1f171\Ufe0f\U2005';; # 🅱️
a) str+='\U1f1e6\U2005';; # 🇦
b) str+='\U1f1e7\U2005';; # 🇧
c) str+='\U1f1e8\U2005';; # 🇨
d) str+='\U1f1e9\U2005';; # 🇩
e) str+='\U1f1ea\U2005';; # 🇪
f) str+='\U1f1eb\U2005';; # 🇫
g) str+='\U1f1ec\U2005';; # 🇬
h) str+='\U1f1ed\U2005';; # 🇭
i) str+='\U1f1ee\U2005';; # 🇮
j) str+='\U1f1ef\U2005';; # 🇯
k) str+='\U1f1f0\U2005';; # 🇰
l) str+='\U1f1f1\U2005';; # 🇱
m) str+='\U1f1f2\U2005';; # 🇲
n) str+='\U1f1f3\U2005';; # 🇳
o) str+='\U1f1f4\U2005';; # 🇴
p) str+='\U1f1f5\U2005';; # 🇵
q) str+='\U1f1f6\U2005';; # 🇶
r) str+='\U1f1f7\U2005';; # 🇷
s) str+='\U1f1f8\U2005';; # 🇸
t) str+='\U1f1f9\U2005';; # 🇹
u) str+='\U1f1fa\U2005';; # 🇺
v) str+='\U1f1fb\U2005';; # 🇻
w) str+='\U1f1fc\U2005';; # 🇼
x) str+='\U1f1fd\U2005';; # 🇽
y) str+='\U1f1fe\U2005';; # 🇾
z) str+='\U1f1ff\U2005';; # 🇿
_) str+='\U2003\U2003';;
0) str+='\U30\Ufe0f\U20e3\U2005';; # 0️⃣
1) str+='\U31\Ufe0f\U20e3\U2005';; # 1️⃣
2) str+='\U32\Ufe0f\U20e3\U2005';; # 2️⃣
3) str+='\U33\Ufe0f\U20e3\U2005';; # 3️⃣
4) str+='\U34\Ufe0f\U20e3\U2005';; # 4️⃣
5) str+='\U35\Ufe0f\U20e3\U2005';; # 5️⃣
6) str+='\U36\Ufe0f\U20e3\U2005';; # 6️⃣
7) str+='\U37\Ufe0f\U20e3\U2005';; # 7️⃣
8) str+='\U38\Ufe0f\U20e3\U2005';; # 8️⃣
9) str+='\U39\Ufe0f\U20e3\U2005';; # 9️⃣
*)
echo "ERROR"
return 1
;;
esac
done
echo -en "$str" | tee >(xclip)
echo
}
alias vi=vim
export EDITOR=`which vim`
if which pyenv > /dev/null; then
export PYENV_ROOT="$CONFIG/pyenv"
eval "$(pyenv init -)"
fi
gvm_init="$HOME/.gvm/scripts/gvm"
if [[ -s "$gvm_init" ]]; then
source "$gvm_init"
fi
# Node Version Manager settings, configured for nvm v0.34.0
export NVM_DIR="$CONFIG/.nvm"
# This loads nvm
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
# This loads nvm bash_completion
[ -s "$HOME/.bash_completion" ] && \. "$HOME/.bash_completion"
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"
for f in "$HOME/.bash_completion.d/*" ; do
[ -s "$f" ] && . "$f"
done
for f in "$CONFIG/.bash_completion.d/*" ; do
[ -s "$f" ] && . "$f"
done