-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdot_alias
299 lines (267 loc) · 8.05 KB
/
dot_alias
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
function gpush() {
git push origin "$(git branch --show-current)" "$@"
}
alias godoc-http="go run golang.org/x/pkgsite/cmd/pkgsite@latest -open"
alias harlequin="harlequin --theme gruvbox-light -a"
alias tzone="tz UTC EST PST8PDT"
alias cronnow="date -u '+%M %H %d %m *'"
alias nz="nix-shell --run zsh"
alias g="git"
alias av="aws-vault exec"
alias nv="nvim -p"
alias k="kubectl"
alias kn="kubectl -n"
alias kd="kubectl describe"
alias kg="kubectl get"
alias warpshell="printf '\eP$f{"hook": "SourcedRcFileForWarp", "value": { "shell": "bash"}}\x9c'"
function frg {
result=`rg --ignore-case --color=always --line-number --no-heading "$@" |
fzf --ansi \
--color 'hl:-1:underline,hl+:-1:underline:reverse' \
--delimiter ':' \
--preview "bat --color=always {1} --theme='Solarized (light)' --highlight-line {2}" \
--preview-window 'up,60%,border-bottom,+{2}+3/3,~3'`
file="${result%%:*}"
linenumber=`echo "${result}" | cut -d: -f2`
if [ ! -z "$file" ]; then
$EDITOR +"${linenumber}" "$file"
fi
}
function wk {
cd "$(walk "$@")"
}
function gpush(){
git push origin "$(git branch --show-current)" "$@"
}
function kn(){
namespace="$1"
shift
object="$1"
shift
if [[ -z "$1" ]] ; then
action="get"
else
action="$1"
shift
fi
if [[ "$action" == "logs" ]] ; then
kubectl -n "$namespace" logs "$@"
else
kubectl -n "$namespace" "$action" "$object" "$@"
fi
}
function k1(){
namespace="$1"
shift
object="$1"
shift
action="$1"
shift
item="$1"
shift
if full=$(kubectl -n "$namespace" get "$object" | awk "/$item/ {print \$1}" | head -1) || [[ -z "$item" ]] ; then
item="$full"
fi
if [[ "$action" == "logs" ]] ; then
kubectl -n "$namespace" logs "$item" "$@"
else
kubectl -n "$namespace" "$action" "$object" "$item" "$@"
fi
}
function klogs(){
ns="$1"
shift
pod_prefix="$1"
shift
if ! pod=$(kubectl -n "$ns" get pods | grep Running | awk "/$pod_prefix/ {print \$1}") || [[ -z "$pod" ]] ; then
echo "error getting pod $pod_prefix" >&2
else
kubectl -n "$ns" logs "$pod" "$@"
fi
}
function klogsf(){
if ! pod=$(kubectl -n "$1" get pods | grep Running | awk "/$2/ {print \$1}") || [[ -z "$pod" ]] ; then
echo "error getting pod $2" >&2
else
kubectl -n "$1" logs -f "$pod"
fi
}
function kpod(){
if ! pod=$(kubectl -n "$1" get pods | awk "/$2/ {print \$1}") || [[ -z "$pod" ]] ; then
echo "error getting pod $2" >&2
else
echo "$pod"
fi
}
alias preview="fzf --preview 'bat --color \"always\" {}'"
function cheat(){ curl "cht.sh/$1" }
function no(){
nvim $(rg --column --line-number --no-heading --ignore-case --follow --fixed-strings --color always "" | fzf --ansi --delimiter ":" --nth 1,4.. | awk -F ':' '/1/ {print $1 " +" $2}')
}
# apt-get install tree
# function tree(){ ls -R "$@" | grep :$ | sed -e 's/:$//' -e 's/[^-][^\/]*\//--/g' -e 's/^/ /' -e 's/-/|/' }
function bucket-owner-folder(){
bucket=$(echo -n "$1" | grep -Po1 '[^\/]+' | head -1)
folder=$(echo -n "$1" | grep -Po '/.*$' | grep -Po '[^/].*$')
for f in $(aws s3 ls s3://"$1" | awk '{print $4}');
do
bucket-owner "$bucket" "$folder$f"
done
}
alias ip-addr="wget http://ipinfo.io/ip -qO -"
alias nv="nvim -p"
function remove-host(){
ssh-keygen -f "/home/greg/.ssh/known_hosts" -R "$1"
}
function ppid () { ps -p ${1:-$$} -o ppid=; }
alias ssh-add-key="ssh-add ~/.ssh/id_rsa"
alias dockerclean="sudo docker ps -a | egrep 'Exit|Created' | awk '{print \$1}' | xargs sudo docker rm"
alias dockercleani="docker images | grep none | awk '{print \$3}' | xargs docker rmi"
function older_images(){
docker images --format '{"repo": {{json .Repository}}, "tag": {{json .Tag}}, "createdAt": {{json .CreatedAt}}}' | jq -sr 'group_by(.repo) | .[] | sort_by(.createdAt) | reverse | .[1] | values | "\(.repo):\(.tag)"'
}
alias sqlite='sqlite3 -header -column'
alias scpresume='rsync --partial --progress --rsh=ssh'
alias grep16='iconv -f UTF-16 -t UTF-8 | grep'
## MAC ##
if [[ `uname` == 'Darwin' ]]; then
alias safari='/Applications/Safari.app/Contents/MacOS/Safari'
alias mtop='top -o rsize'
alias updatedb='/usr/libexec/locate.updatedb'
else
alias pbcopy='xsel --clipboard --input'
alias pbpaste='xsel --clipboard --output'
# alias pbcopy='xclip -selection clipboard'
# alias pbpaste='xclip -selection clipboard -o'
fi
alias diffdirs="diff -ENwbur"
## GIT ##
alias gchanged="g st | egrep 'new|modified' | sed 's/.*://'"
alias gmodified="git status | grep modified: | awk '{print \$2}'"
alias gdeleted="git status | grep deleted: | awk '{print \$3}'"
alias gdiffed="git diff master | grep diff | awk '{print \$3}' | sed 's|a//||'"
alias branches="git branch -a | grep -v 'braid\|tags'"
alias co="git checkout"
alias pull="git pull --rebase"
## IP ##
alias local_ip='ifconfig | grep 192'
alias cD='c ~/Desktop'
# alias e='~/bin/e.rb'
alias g='git'
alias first='print *(.) | xargs head -1' # should make this no directories
alias load='print ${(@)$(</proc/loadavg)[1,3]}'
alias loadn='print -n ${(@)$(</proc/loadavg)[1,3]}'
## GREP ##
alias eg='egrep'
alias gr='grep'
alias grn='grep -n'
alias gri='grep -i'
##########
## ZSH ####
alias s='source ~/.zshrc'
alias :q='exit'
alias xx='exit'
#############
#### CHANGE DIRECTORY #####
alias cdusb='cd `usb`'
alias cd..='cd ..'
alias cd...='cd ../../'
alias cd....='cd ../../../'
alias cd.....='cd ../../../../'
alias c..='c ..'
alias c...='c ../../'
alias c....='c ../../../'
alias c.....='c ../../../../'
#alias killall="kill -9 `ps | grep -v PID | sed 's|^ ||' | sed 's|^ ||' | sed 's|^ ||' | sed 's| .*||' | xargs`"
#### ls with color ####
# enable color support of ls in a server independent way
# make sure this is placed AFTER your path variable has been setup
#case $(uname) in
# Linux)
# current_dir=`pwd`
# this is crazy, just check error status of ls --color
# for dir in `echo $PATH | tr ':' ' '`
# do
# if [[ -e "$dir" ]]
# then
# cd "$dir"
# if [[ -e './ls' ]]
# then
# if [[ -n `./ls --help 2>/dev/null | grep color` ]]
# then
# if [[ -e `which dircolors` ]]
# then
# eval "`dircolors -b`"
# alias ls="$dir/ls --color=auto"
# alias l="$dir/ls --color=auto"
# alias dir="$dir/ls --color=auto --format=vertical"
# alias vdir="$dir/ls --color=auto --format=long"
# break
# else
# alias ls='ls -F'
# alias l='ls -F'
# alias dir="ls --format=vertical"
# alias vdir="ls --format=long"
# break
# fi
# else
# alias ls='ls -F'
# alias l='ls -F'
# alias dir="ls --format=vertical"
# alias vdir="ls --format=long"
# fi
# fi
# fi
# done
# cd $current_dir
#;;
# FreeBSD)
# LS_COLORS="3x5x2x3x1x464301060203"
# alias ls='ls -G'
# export LS_COLORS
# ;;
# OpenBSD|NetBSD|Darwin)
# alias ls='ls -G'
# ;;
# CYGWIN_NT-6.2-WOW64)
# alias ls='ls --color'
#;;
#esac
# options
alias l='ls'
alias l1='ls -1'
alias ll='ls -l'
alias le='ls -l 2>/dev/null'
alias lea='ls -al 2>/dev/null'
alias la='ls -aC'
alias lla='ls -al'
alias lal='ls -al'
alias lt='ls -Crt'
alias lrt='ls -lrt'
alias lr='ls -lr'
function cdf() {
local dir;
while true; do
# exit with ^D
dir="$(exa -a1D | fzf --height 40% --reverse --no-multi --preview 'pwd' --preview-window=up,1,border-none --no-info)"
#dir="$(ls -a1p | grep '/$' | grep -v '^./$' | fzf --height 40% --reverse --no-multi --preview 'pwd' --preview-window=up,1,border-none --no-info)"
if [[ -z "${dir}" ]]; then
break
else
cd "${dir}"
fi
done
}
function cdfr() {
local dir;
while true; do
# exit with ^D
dir="$(exa -a1DR | grep : | cut -d ':' -f 1 | fzf --height 40% --reverse --no-multi --preview 'pwd' --preview-window=up,1,border-none --no-info)"
if [[ -z "${dir}" ]]; then
break
else
cd "${dir}"
fi
done
}
alias pf="fzf --preview='less {}' --bind shift-up:preview-page-up,shift-down:preview-page-down"