-
Notifications
You must be signed in to change notification settings - Fork 1
/
bash
86 lines (68 loc) · 2.2 KB
/
bash
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
#!/bin/bash
tabs 4
alias grp='grep -B 2 -A 2 -n --color'
alias reload='source ~/.bash_profile'
alias ..='cd ..'
alias ...='..;..'
alias cd..='cd ..'
alias home='cd ~'
alias ~='cd ~'
alias cd-='cd -'
alias ,.='cd -'
alias path='echo -e ${PATH//:/\\n}'
# get ip addr
alias ip='curl -s https://deuxhuithuit.com/cdn-cgi/trace | grep ip='
# this function calls top with a command filter (1st arg)
# other parameters are passed down to top
function topp {
pattern=$1
shift 1
top -p $(pgrep -d',' $pattern) $@
}
# http header
alias hh='curl -Is'
# base 64
function 64d {
node -e "console.log(new Buffer(process.argv[1], 'base64').toString())" $@
}
function 64e {
node -e "console.log(new Buffer(process.argv[1]).toString('base64'))" $@
}
# top 10 biggest folders
alias top10='du -a / | sort -n -r | head -10'
# php lint all
alias phplint='for D in **/*.php; do php -l $D; done;'
# php lint dirty files
alias ldp="gs | egrep '[ M]{2}' | awk '/[M ]+(.+)\.php/ { system(\"php -l \" \$2); }'"
alias ldps="ss | grep '^[AM]' | awk '/\.php/ { system(\"php -l \" \$2); }'"
# extension change
function ext {
if [ -z "$1" ]; then
echo "Missing 1st paramter (old ext)"
return 1
elif [ -z "$2" ]; then
echo "Missing 2nd paramter (new ext)"
return 2
fi
find . $3 -name "*.$1" |while read f; do
$4 mv "$f" "${f%.$1}.$2"
done
}
# sed shortcut
alias bs2fs="sed 's/\\\\/\\//g'"
# create empty file
function nef {
BS="$((1024 * $1))";
dd if=/dev/zero of=$2 count=1024 bs=$BS;
}
# add ssh keys, if needed
# from https://unix.stackexchange.com/questions/132791/have-ssh-add-be-quiet-if-key-already-there
function _add_ssh_key() {
ssh-add -l | grep -q `ssh-keygen -lf $1 | awk '{print $2}'` || ssh-add "$1"
}
# jq expression to debug wrangler taills
alias wrangler-errors="jq -r '.outcome as \$o | .event.request.url as \$u | .exceptions[] as \$e | \"\\(\$o) \\(\$e) \\(\$u)\"'";
alias wrangler-all="jq -r '.outcome as \$o | .event.request.url as \$u | \"\\(\$o) \\(\$u) \"'";
alias wrangler-logs="jq -r '.event.request.url as \$u | .logs[] | .message[] as \$m | \"[\\(.timestamp/1000|todate)[\\(.level)] \\(\$m) \\(\$u)\"'";
# fetch Cloudflare CA
alias cfca="curl https://developers.cloudflare.com/ssl/static/origin_ca_rsa_root.pem"