forked from HiDeoo/dotfiles
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathzsh_aliases
212 lines (164 loc) · 5.16 KB
/
zsh_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
204
205
206
207
208
209
210
211
212
# Expand aliases after sudo instead of only checking the first word of a command for an alias.
alias sudo='sudo '
# Reload Bash.
alias rr='exec zsh'
# Edit zshrc in VSCode.
alias alz='c ~/.zshrc'
alias al='c ~/.zsh_aliases'
# Navigate to the previous directory.
alias -- -='cd -'
alias ..='cd ..'
# Various shortcuts.
alias dl='cd ~/Downloads'
alias dt='cd ~/Desktop'
alias wk='cd ~/Work'
alias si='cd ~/Sites'
alias gi='cd ~/Github'
alias ss='cd ~/Pictures/Screenshots'
#
# Editors
#
alias vim='nvim'
alias c='code'
alias n='nvim'
alias v='nvim'
# Compare two files using VS Code.
alias cdiff='c -n -d'
#
# Miscellaneous
#
# Use GNU grep instead of BSD grep.
alias grep='ggrep'
# PS aliases.
alias psa='ps aux'
alias psg='ps aux | grep -i'
# Use the verbose mode for cp & mv.
alias cp='cp -v'
alias mv='mv -v'
# Override some default commands.
alias cat='bat -p --theme ansi'
alias ping='prettyping'
alias rm='trash'
#
# Services
#
rsmysql='sudo systemctl restart mysqld.service'
# Human readable DF & DU.
alias df='df -h'
alias du='du -h -d 2'
# Clear & list directory.
alias cls='clear; ls'
alias clr='clear'
# LS & grep.
alias lsg='ll | grep -i'
alias lla='ls -lah'
# Add colors to tree.
alias tree='tree -C'
# Add a native rm fallback.
alias rmi='command rm -i'
#
# macOS
#
# Use Homebrew’s Python 3.
alias python='python3'
# Update various parts of the system.
alias update_os='sudo softwareupdate -i -a'
alias update_brew='brew -v update; brew upgrade; brew cleanup --prune=30; brew doctor'
alias update_npm='npmgu'
alias update_yarn='yarn global upgrade --latest'
alias update_prezto='zprezto-update'
alias update_all='update_os; update_brew; update_npm; update_yarn; update_prezto'
# Update npm global packages.
npmgu() {
for package in $(npm -g outdated --parseable --depth=0 | cut -d: -f4)
do
npm -g --force install "$package"
done
}
# Empty trashes on all mounted volumes, the trash of the main disk & Apple's System Logs.
alias empty='sudo \rm -rfv /Volumes/*/.Trashes; sudo \rm -rfv ~/.Trash; sudo \rm -rfv /private/var/log/asl/*.asl'
# Remove quarantine on a specific element.
alias unquarantine='xattr -r -d com.apple.quarantine'
# Approve a specific element from an unidentified developer via the system-wide assessment rule database.
alias approve='spctl --add --label "Approved"'
#
# Internet
#
# Get external IPv4.
alias ip='\dig +short -4 myip.opendns.com @resolver1.opendns.com'
# Alias dig to dog.
alias dig='dog'
# Edit the hosts file.
alias hosts='sudo $EDITOR /etc/hosts'
#
# Dev
#
# URL-encode a string.
alias urlencode='python -c "import sys, urllib.parse as ul; print(ul.quote_plus(sys.argv[1]));"'
# URL-encode a string.
alias urlencode='python -c "import sys, urllib.parse as ul; print(ul.quote_plus(sys.argv[1]));"'
#
# Projects
#
# Dotfiles
alias dotfiles='cd ~/Github/dotfiles-osx'
#
# Git
#
# Navigate automatically to a git cloned directory.
git() {
if [ "$1" = clone ] ; then
command git clone $2
cd $(basename $2 | sed 's/.git$//')
else
command git "$@"
fi
}
alias gpl='git pull --prune'
alias gs='git status'
# Delete git local branches which have already been merged into the current HEAD.
alias gitcleanup='git branch --merged | grep -v "\*" | xargs -n 1 git branch -d'
# Time
alias week='date +%V'
alias clock='date +%T'
#
# Laravel
#
artisan() {
if [ -f bin/artisan ]; then
php bin/artisan "$@"
else
php artisan "$@"
fi
}
alias art='php artisan'
alias serve='artisan serve'
alias tinker='artisan tinker'
alias migrate='php artisan migrate'
# Misc PHP
t() {
if [ -f vendor/bin/phpunit ]; then
vendor/bin/phpunit "$@"
else
phpunit "$@"
fi
}
#
# GIF stuff *_*
# Copy a gif url in my clipboard
# Just in case I need a gif asap.
#
alias fine='echo -n "https://media.giphy.com/media/z9AUvhAEiXOqA/giphy.gif" | pbcopy; echo "Fine gif copied to clipboard"'
alias nope='echo -n "https://media.giphy.com/media/6h4z4b3v6XWxO/giphy.gif" | pbcopy; echo "Nope gif copied to clipboard"'
alias wtf='echo -n "https://media.giphy.com/media/26xBG9lQdU5YTRnJS/giphy.gif" | pbcopy; echo "WTF gif copied to clipboard"'
alias facepalm='echo -n "https://media.giphy.com/media/XsUtdIeJ0MWMo/giphy.gif" | pbcopy; echo "Facepalm gif copied to clipboard"'
alias thumbsup='echo -n "https://media.giphy.com/media/l2YWCz0kmmgdx8feM/giphy.gif" | pbcopy; echo "ThumbsUp gif copied to clipboard"'
alias godno='echo -n "https://media.giphy.com/media/12XMGIWtrHBl5e/giphy.gif" | pbcopy; echo "GODNO gif copied to clipboard"'
alias what='echo -n "https://media.giphy.com/media/fpXxIjftmkk9y/giphy.gif" | pbcopy; echo "WHAT gif copied to clipboard"'
alias please='echo -n "https://media.giphy.com/media/3h2lUwrZKilQKbAK6f/giphy.gif" | pbcopy; echo "PLS gif copied to clipboard"'
alias eheheh='echo -n "https://media.giphy.com/media/9MFsKQ8A6HCN2/giphy.gif" | pbcopy; echo "EHEHEH gif copied to clipboard"'
alias look='echo -n "https://giphy.com/gifs/funny-reaction-cute-E6gUCRWYFqDO8" | pbcopy; echo "LOOK gif copied to clipboard"'
alias shrug="echo '¯\_(ツ)_/¯' | pbcopy; echo 'Shrug copied to clipboard'";
alias fight="echo '(ง'̀-'́)ง' | pbcopy; echo 'Fight copied to clipboard'";
# Clean the clipboard
alias gclean='pbcopy </dev/null; echo "Clipboard cleaned."'