-
Notifications
You must be signed in to change notification settings - Fork 0
/
aliases
203 lines (165 loc) · 5.43 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
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
# Allow aliases to be with sudo
alias sudo="sudo "
# Generic
alias zshrc='$EDITOR ~/.zshrc'
alias r!='source ~/.zshrc'
alias zmv='noglob zmv -W'
alias watch='watch '
alias ssh='TERM=xterm-color ssh'
# Edit dotfiles
alias dot.='code ~/.dotfiles'
# Use 256-color mode in tmux
alias tmux='tmux -2'
# Directories
alias ..='cd ..'
alias ...='cd ../..'
alias ....='cd ../../..'
alias .....='cd ../../../..'
# Detect which `ls` flavor is in use
if ls --color > /dev/null 2>&1; then # GNU `ls`
alias ls='ls --color'
else # OS X `ls`
alias ls='ls -G'
fi
# List all files and directories colorized in columns
alias l='ls -CF'
#Lis all files and directories including hidden in colums
alias la='ls -A'
# List all files colorized in long format, including dot files
alias ll='ls -laF'
# List only directories
alias lsd='ls -l -d */'
# List all by date
alias lrt='ls -lrt'
# List hidden files
alias l.='ls -d .* '
# Add an "alert" alias for long running commands.
# Use like so: sleep 10; alert
alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"'
# Look for directories and files
alias fd='find . -type d -iname'
alias ff='find . -type f -iname'
# Use colordiff if possible
type -P colodiff &>/dev/null && alias diff="colordiff"
# Colorize the grep command output for ease of use (good for log files)
alias grep='grep --color=auto'
alias egrep='egrep --color=auto'
alias fgrep='fgrep --color=auto'
# Find process by name
alias got='ps awx | egrep'
# Intuitive map function
# For example, to list all directories that contain a certain file:
# find . -name .gitattributes | map dirname
alias map="xargs -n1"
# Stop after sending count ECHO_REQUEST packets
alias ping='ping -c 5'
# Do not wait interval 1 second, go fast
alias fastping='ping -c 100 -s.2'
# Create directories on demand
alias mkdir='mkdir -pv'
# This one saved by butt so many times
alias wget='wget -c'
#Show open ports
alias ports='netstat -tulanp'
# git
alias gs='git st'
alias g='git l'
alias gstash='git stash save --include-untracked'
alias go='git checkout'
alias gc='git commit -S'
alias gca='git commit --amend -S'
alias gcad='git commit --amend -S --date=now'
alias gr='git remote -v'
alias gru='git remote update'
alias gpum='git pull upstream master'
alias gd='git diff -w'
alias gdc='git diff -w --cached'
alias gbd='git branch -D'
alias gbdr='f() { git branch -D $1 && git push origin :$1; }; f'
# Docker
alias dl="docker ps -l -q"
alias dps="docker ps"
alias dpa="docker ps -a"
alias di="docker images"
alias dstopall='docker stop $(docker ps -a -q)'
alias drmall='docker rm $(docker ps -a -q)'
alias drmiall='docker rmi $(docker images -q)'
alias dcup='docker compose up'
alias dcdown='docker compose down'
alias dclogs='docker compose logs'
alias dcb='docker compose build'
alias dcrm='docker compose rm'
alias dcps='docker compose ps'
alias dcstop='docker compose stop'
alias dcrestart='docker compose restart'
# Kubernetes
alias k='kubectl'
alias kenv='kubens'
alias kdp='kubectl describe pod'
alias kl='kubectl logs -f'
alias kgp='kubectl get pods -o wide'
# Terraform
alias tf='terraform'
alias tfmt='terraform fmt'
alias tfv='terraform validate'
alias tfp='terraform plan'
alias tfa='terraform apply'
alias tfd='terraform destroy'
# Export .env variables as environment variables
alias exportenv='export $(grep -v "^#" .env | xargs)'
alias unsetenv='unset $(grep -v "^#" .env | sed -E "s/(.*)=.*/\1/" | xargs)'
# Shortcuts
alias d='cd'
alias h='history'
alias j='jobs -l'
alias i='ipython'
alias path='echo -e ${PATH//:/\\n}'
alias now='date +"%T"'
alias nowdate='date +"%d-%m-%Y"'
alias t="tmux"
# For most of the cases Hub is a nice tool to use
if type hub &> /dev/null; then
eval "$(hub alias -s)"
fi
alias g='git'
#Editors
alias v='vim'
alias vimnoplugin='vim -u NONE'
# URL-encode strings
alias urlencode='python -c "import sys, urllib as ul; print ul.quote_plus(sys.argv[1]);"'
# Use bat instead of cat
alias cat="bat"
# IP addresses
alias ip="dig +short myip.opendns.com @resolver1.opendns.com"
alias ips="ifconfig -a | grep -o 'inet6\? \(addr:\)\?\s\?\(\(\([0-9]\+\.\)\{3\}[0-9]\+\)\|[a-fA-F0-9:]\+\)' | awk '{ sub(/inet6? (addr:)? ?/, \"\"); print }'"
# Show active network interfaces
alias ifactive="ifconfig | pcregrep -M -o '^[^\t:]+:([^\n]|\n\t)*status: active'"
# Copy my public key to the pasteboard
alias pubkey="more ~/.ssh/id_rsa.pub | pbcopy | printf '=> Public key copied to pasteboard.\n'"
# macos specific aliases
if [ "$(uname)" = "Darwin" ]; then
# brew aliases
alias bup='brew update'
alias bout='brew outdated'
alias bin='brew install'
alias brm='brew uninstall'
alias bls='brew list'
alias bsr='brew search'
alias binf='brew info'
alias bdr='brew doctor'
alias cask='brew cask'
# Recursively delete `.DS_Store` files
alias cleanup="find . -type f -name '*.DS_Store' -ls -delete"
# Empty the trash, the main HDD and on all mounted volumes,
# and clear Apple’s system logs to improve shell startup speed.
alias emptytrash="sudo rm -frv /Volumes/*/.Trashes; \
sudo rm -frv ~/.Trash; \
sudo rm -frv /private/var/log/asl/*.asl; \
sqlite3 ~/Library/Preferences/com.apple.LaunchServices.QuarantineEventsV* 'delete from LSQuarantineEvent'"
alias localip="ipconfig getifaddr en0"
# start firefox from terminal hassle free
alias firefox='open -a firefox'
alias o='open'
fi
# TODO Linux
# alias o="xdg-open"