-
Notifications
You must be signed in to change notification settings - Fork 2
/
aliases.sh
144 lines (122 loc) · 3.54 KB
/
aliases.sh
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
#!/bin/bash
# Aliases
alias c="cd ~/Developer"
alias a="cd ~/AppSec"
alias d="cd ~/Desktop"
alias dl="cd ~/Downloads"
alias h="cd ~/"
alias ls="ls -lah"
alias o="open ."
alias v="code ."
alias tree="exa --tree --git-ignore --ignore-glob='.git'"
alias zshconfig="vim ~/.zshrc"
alias zshreload="source ~/.zshrc"
alias speed="networkQuality -v"
alias pip-clean="pip freeze | xargs pip uninstall -y"
alias venv="python -m venv .venv"
alias aliasconfig="vim ~/Developer/dotfiles/aliases.sh"
alias sshconfig="vim ~/.ssh/config"
alias secretsconfig="vim ~/Developer/dotfiles/secrets.sh"
alias hostsconfig="sudo vim /etc/hosts"
# Random
alias server='python -m http.server --bind 0.0.0.0'
alias ports='lsof -nP -iUDP -iTCP'
# System
alias update='sudo softwareupdate --install --all --verbose'
# Git
alias gsync='gpull && gpush'
alias gfetch='git fetch --prune --all'
alias gpull='git pull --rebase origin $(git rev-parse --abbrev-ref HEAD)'
alias gpush='git push origin $(git rev-parse --abbrev-ref HEAD)'
alias gbranches='git branch -a'
function gi() { curl "https://www.toptal.com/developers/gitignore/api/$1"; }
# appsec
function zap() { docker run -t ghcr.io/zaproxy/zaproxy zap-full-scan.py -t "$@"; }
function gobuster() { docker run --name gobuster --rm -v "$HOME/AppSec/wordlists:/wordlists" ghcr.io/oj/gobuster "$@"; }
# Archive / unarchive
function archive() {
tar --zstd -cf "$1.tar.zst" "$@"
}
function archive-ls() {
tar -tvf "$@"
}
function unarchive() {
tar -xvf "$@"
}
function zip-password() {
zip -er "$1.zip" "$1"
}
# Network
function ipinfo() { curl "https://ipinfo.io/$1"; }
# Show all ip addresses
function ips() {
if [[ $(uname) == 'Darwin' ]]; then
interface='en'
else
interface='eth'
fi
for NUMBER in $(seq 0 9); do
ip=$(ifconfig "$interface$NUMBER" 2>/dev/null |
grep -Eo 'inet (addr:)?([0-9]*\.){3}[0-9]*' |
grep -Eo '([0-9]*\.){3}[0-9]*')
if [ -n "$ip" ]; then
echo "Local($interface$NUMBER): $ip"
fi
done
echo "Remote: $(curl -s https://ipinfo.io/ip)"
}
# ssh: expose a local port
function ssh-tunnel-remote-to-local() {
if [[ -z "$1" ]]; then
printf '\nLocal port exposed to remote host\n'
printf '\nUsage:\n'
printf '\tssh-tunnel-local-to-remote <REMOTE_PORT> <LOCAL_PORT> <CONN>\n\n'
return
fi
REMOTE_PORT="$1"
LOCAL_PORT="$2"
CONN="$3"
ssh -nNT -R "$REMOTE_PORT":localhost:"$LOCAL_PORT" "$CONN"
}
# ssh: connect to remote port
function ssh-tunnel-local-to-remote() {
if [[ -z "$1" ]]; then
printf '\nConnect to host, expose host locally\n'
printf '\nUsage:\n'
printf '\tssh-tunnel-local-to-remote <LOCAL_PORT> <REMOTE_HOST> <REMOTE_PORT> <CONN>\n\n'
return
fi
LOCAL_PORT="$1"
REMOTE_HOST="$2"
REMOTE_PORT="$3"
CONN="$4"
ssh -nNT -L "$LOCAL_PORT":"$REMOTE_HOST":"$REMOTE_PORT" "$CONN"
}
# ssh: starts a SOCKS proxy on $LOCAL_PORT
function ssh-proxy() {
if [[ -z "$1" ]]; then
printf '\nUsage:\n\tssh-proxy <LOCAL_PORT> <CONN>\n\n'
return
fi
LOCAL_PORT="$1"
CONN="$2"
ssh -qNC -D "$LOCAL_PORT" "$CONN"
}
function generate-random-password() {
openssl rand -base64 32 | tr -d "=+/" | cut -c1-32
}
zshstats () {
fc -l 1 | \
awk '{CMD[$2]++;count++;}END { for (a in CMD)print CMD[a] " " CMD[a]/count*100 "% " a;}' | \
column -c3 -s " " -t | sort -nr | nl | head -n20
}
qrcode () {
local input="$*"
[ -z "$input" ] && local input="@/dev/stdin"
curl -d "$input" https://qrcode.show
}
qrsvg () {
local input="$*"
[ -z "$input" ] && local input="@/dev/stdin"
curl -d "${input}" https://qrcode.show -H "Accept: image/svg+xml"
}