-
Notifications
You must be signed in to change notification settings - Fork 0
/
.bashrc.aliases
162 lines (131 loc) · 3.66 KB
/
.bashrc.aliases
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
if [[ $(uname) == "Darwin" ]]; then
MAC_OS=true
else
MAC_OS=false
fi
shopt -s expand_aliases
# macos specific aliases
if $MAC_OS; then
function remote_cmd() {
export RHOST=$(basename $(gbase))
command "$@"
}
alias rbuild="remote_cmd rbuild"
alias rgpull="remote_cmd rgpull"
alias rmake="time remote_cmd rmake"
alias rrobot="remote_cmd rrobot"
# use homebrew version of vim
alias vim="/usr/local/bin/vim"
function rpush() {
export RHOST=$(basename $(gbase))
command rpush "$@"
command greset
}
function vssh() {
local dev_host=$(basename $(gbase))
ssh "$dev_host" "$@"
}
function tmux_attach() {
vssh -t tmux_attach
}
function f() {
fuck
}
alias bazel="PYENV_VERSION=3.6.5:2.7.15 bazel"
function flame_graph() {
local filename="$1"
"$HOME/Documents/thirdparty/FlameGraph/stackcollapse-perf.pl" "$@" | \
"$HOME/Documents/thirdparty/FlameGraph/flamegraph.pl" - \
> "${filename}.svg"
echo "Created '${filename}.svg'"
}
function flame_diff() {
local filename_a="$1"
local filename_b="$2"
"$HOME/Documents/thirdparty/FlameGraph/difffolded.pl" -n \
<("$HOME/Documents/thirdparty/FlameGraph/stackcollapse-perf.pl" "$filename_a") \
<("$HOME/Documents/thirdparty/FlameGraph/stackcollapse-perf.pl" "$filename_b") | \
"$HOME/Documents/thirdparty/FlameGraph/flamegraph.pl" - \
> "${filename_b}.diff.svg"
"$HOME/Documents/thirdparty/FlameGraph/difffolded.pl" -n \
<("$HOME/Documents/thirdparty/FlameGraph/stackcollapse-perf.pl" "$filename_b") \
<("$HOME/Documents/thirdparty/FlameGraph/stackcollapse-perf.pl" "$filename_a") | \
"$HOME/Documents/thirdparty/FlameGraph/flamegraph.pl" --negate - \
> "${filename_a}.diff.svg"
}
else
# centos dev vm functions
alias yum="sudo yum"
alias dnf="sudo dnf"
alias subscription-manager="sudo subscription-manager"
# iterm tmux integration
function tmux_attach() {
if [[ $TERM_PROGRAM = "iTerm.app" ]]; then
command tmux -CC attach $@
else
command tmux attach $@
fi
}
fi
# aliased commands
alias py="python"
alias develop="cd ~/Documents/workspace"
alias dev="develop"
alias bashrc="source ~/.bashrc"
alias mux="tmux_attach"
ls_args="-Falh"
if [ "$MAC_OS" = true ]; then
ls_args="$ls_args -G"
else
ls_args="$ls_args --color=auto"
fi
alias ls="ls $ls_args"
function vi() {
if type -P vim &>/dev/null ; then
command vim "$@"
else
command vi -p "$@"
fi
}
alias vim="vim -p"
# grep colors
alias grep="grep --color=auto"
function tbm_ssh() {
if [ "$MAC_OS" = true ]; then
local dev_host=$(basename $(gbase))
if [[ $# -eq 1 ]]; then
args="-n $@"
else
args= "$@"
fi
command ssh -t "$dev_host" "tbm ssh $args"
else
command tbm ssh -n "$@"
fi
}
function authorize_testbed() {
"$HOME/Documents/tools/authorize_testbed.py" "$@"
}
function ssh() {
if [ "$MAC_OS" = false ]; then
command ssh "$@"
else
if [[ $# -eq 1 && $@ != *@* ]]; then
command ssh -t "$@" \
"bash -c \
'if [ -d \"$(pwd)\" ]; then
cd \"$(pwd)\"
fi
exec \$SHELL -l'"
else
command ssh "$@"
fi
fi
}
function bazel() {
if type -P bazelisk &>/dev/null; then
command bazelisk "$@"
else
command bazel "$@"
fi
}