-
Notifications
You must be signed in to change notification settings - Fork 0
/
.aliases
142 lines (107 loc) · 3.91 KB
/
.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
case $(uname -s) in
Darwin)
alias ls='gls $LS_OPTIONS -hF'
alias ll='gls $LS_OPTIONS -lhF'
alias l='gls $LS_OPTIONS -lAhF'
# Flush Directory Service cache
alias flush="dscacheutil -flushcache"
# Empty the Trash on all mounted volumes and the main HDD
# Also, clear Apple’s System Logs to improve shell startup speed
alias emptytrash="sudo rm -rfv /Volumes/*/.Trashes; sudo rm -rfv ~/.Trash; sudo rm -rfv /private/var/log/asl/*.asl"
# Show/hide hidden files in Finder
alias show-hidden="defaults write com.apple.Finder AppleShowAllFiles -bool true && killall Finder"
alias hide-hidden="defaults write com.apple.Finder AppleShowAllFiles -bool false && killall Finder"
# Hide/show all desktop icons (useful when presenting)
alias hide-desktop="defaults write com.apple.finder CreateDesktop -bool false && killall Finder"
alias show-desktop="defaults write com.apple.finder CreateDesktop -bool true && killall Finder"
# Enable/disable Spotlight
alias spot-off="sudo mdutil -a -i off"
alias spot-on="sudo mdutil -a -i on"
# Stuff I never really use but cannot delete either because of http://xkcd.com/530/
alias stfu="osascript -e 'set volume output muted true'"
alias pumpitup="osascript -e 'set volume 10'"
;;
Linux)
alias ls='ls $LS_OPTIONS -hF'
alias ll='ls $LS_OPTIONS -lhF'
alias l='ls $LS_OPTIONS -lAhF'
alias pbcopy='xsel --clipboard --input'
alias pbpaste='xsel --clipboard --output'
alias open='caja'
;;
esac
export BAT_THEME="Solarized (light)"
export MANPAGER="sh -c 'col -bx | bat -l man -p'"
alias cat='bat'
alias cd..="cd .."
alias c="clear"
alias e="exit"
alias ..="cd .."
alias sqlite="sqlite3"
# Bundler
alias be="bundle exec"
alias bi="bundle install"
alias bl="bundle list"
alias bp="bundle package"
alias bo="bundle open"
alias bu="bundle update"
# Enable tap to click (Trackpad)
alias enable-tap-to-click="defaults write com.apple.driver.AppleBluetoothMultitouch.trackpad Clicking -bool true"
# IP addresses
alias ip="dig +short myip.opendns.com @resolver1.opendns.com"
alias ips="ifconfig -a | perl -nle'/(\d+\.\d+\.\d+\.\d+)/ && print $1'"
# Enhanced WHOIS lookups
alias whois="whois -h whois-servers.net"
# View HTTP traffic
alias sniff="sudo ngrep -d 'en1' -t '^(GET|POST) ' 'tcp and port 80'"
alias httpdump="sudo tcpdump -i en1 -n -s 0 -w - | grep -a -o -E \"Host\: .*|GET \/.*\""
# URL-encode strings
alias urlencode='python -c "import sys, urllib.parse; print(urllib.parse.quote_plus(sys.argv[1]));"'
# One of @janmoesen’s ProTip™s
for method in GET HEAD POST PUT DELETE TRACE OPTIONS; do
alias "$method"="lwp-request -m '$method'"
done
# SSH Aliases
alias ssh-scicombinator="ssh [email protected]"
alias ssh-hocuspokus="ssh [email protected]"
##
## Docker
##
alias docker-compose='docker compose'
alias docker-clean-images='docker rmi $(docker images --filter "dangling=true" -q --no-trunc)'
alias docker-clean-containers='docker rm $(docker ps -qa --no-trunc --filter "status=exited")'
alias docker-rm-all-containers='docker rm -f $(docker ps -a -q)'
alias docker-rm-all-images='docker rmi -f $(docker images -q)'
##
## NeoVim
##
# alias vim='nvim'
##
## Git
##
# GPG sign all commits in current branch
alias git-sign-branch="git rebase --exec 'git commit --amend --no-edit -n -S' -i master"
# Get a pretty git log
alias git-log="git log --decorate --graph --oneline --topo-order"
## YAML helpers
function parse_yaml() {
yq "${1}"
}
function yaml_to_json() {
yq "${1}" -o json
}
function json_to_yaml() {
ruby -ryaml -rjson -e "puts JSON.parse(File.read('${1}')).to_yaml"
}
alias ack='rg'
# kubectl
alias k='kubectl'
alias kx='kubie ctx'
alias kn='kubie ns'
function decode_k8s_cert() {
namespace="${1}"
secret="${2}"
datakey="${3}"
kubectl get secret -n "${namespace}" "${secret}" -o yaml | yq -r ".data.\"${datakey}\"" | base64 -d | openssl x509 -text
}
alias dadjoke='curl -H "Accept: text/plain" https://icanhazdadjoke.com/'