-
Notifications
You must be signed in to change notification settings - Fork 1
/
.bash_aliases
319 lines (283 loc) · 10.3 KB
/
.bash_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
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
#!/bin/bash
# **************************************************************************** #
# #
# ::: :::::::: #
# .bash_aliases :+: :+: :+: #
# +:+ +:+ +:+ #
# By: mc </var/spool/mail/mc> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2017/01/26 20:50:04 by mc #+# #+# #
# Updated: 2020/06/03 13:03:19 by mc ### ########.fr #
# #
# **************************************************************************** #
# functions are way better than aliases actually! (actually bis: not really?)
man_emacs() {
emacsclient -t --eval "(progn (man \"$1\") (other-window 1) (delete-other-windows))"
}
sizeof() {
find "${1:-$PWD}" -maxdepth 1 -print0 \
| du -ah -d1 --files0-from - \
| sort -h
}
prev() {
fd --print0 $@ \
| fzf --read0 --preview '{bat --color=always {} || tree -C {}} 2>/dev/null | head -500'
}
vm() {
target=${1:-arch}
sudo systemd-nspawn --boot --ephemeral --directory "/var/lib/machines/$target"
}
# misc aliases
alias l='ls'
alias ll='ls -lh'
alias la='ls -lAh'
alias norm='norminette --CheckForbiddenSourceHeader'
alias normall='norminette --CheckForbiddenSourceHeader **/*.[ch]'
alias gccf='gcc -std=c11 -Wall -Wextra -Werror'
alias now='date "+%y-%m-%d_%H-%M-%S"'
alias ext-ip='curl -s http://ipecho.net/plain; echo;'
alias led='ledger --no-pager --force-color --color -f ~/kraken.ledger --price-db ~/kraken.price-db'
alias pi='ipython --no-confirm-exit --no-banner'
alias py='python3'
alias copy='xsel --clipboard'
alias caml='rlwrap ocaml'
alias cl='rlwrap sbcl --noinform'
alias open='xdg-open'
alias t='sh ~/sh_script/rename_tab.sh' # TODO: write fun instead
alias del='~/sh_script/trash.sh' # TODO: write fun instead
# SQL_ARGS="--prompt=\"$(echo -e '\033[32;01m\\d\033[33;01m@\033[31;01m\\h> \033[0m')\" -uroot -p --silent"
SQL_ARGS="--silent --prompt=\"$(echo -e '\\d@\\h> \033[0m')\" -u genesys -p"
alias sql="mysql $SQL_ARGS"
alias emount="~/sh_script/crypt.sh mount"
alias eumount="~/sh_script/crypt.sh umount"
alias sz="sizeof"
alias lsblk="lsblk -o NAME,LABEL,SIZE,FSAVAIL,FSUSE%,MOUNTPOINT,UUID"
# emacs stuffs
alias e="$EDITOR"
alias em='emacs --no-window-system --no-x-resources --no-splash'
alias v="$VISUAL"
alias se="SUDO_EDITOR=\"emacsclient -t -a emacs\" sudoedit"
alias man='man_emacs'
alias mail='em --eval "(progn (sleep-for 0.1) (gnu))"'
# flash conf edit
alias zconf='e ~/.zshrc'
alias bconf='e ~/.bashrc'
alias aconf='e ~/.bash_aliases && . ~/.bash_aliases'
alias econf='e ~/.emacs.d/init.el'
# git aliases
alias ga='git add -A'
alias gb='PAGER= git branch'
alias gbb='git remote show origin'
alias gcm='git commit -m'
alias gce='git commit'
alias gco='git checkout'
alias gpl='git pull --ff-only'
alias gplo='git pull --ff-only origin'
alias gplom='git pull --ff-only origin master'
alias gp='git push'
alias gpo='git push origin'
alias gpa='git push --all origin' #yolo
alias gpom='git push origin master'
alias gm='git merge --verbose --progress --no-ff'
alias gs='git status'
alias gh='git stash'
alias ghl='PAGER= git stash list --decorate'
alias ghs='git stash show'
alias ghd='git stash show -p'
alias gha='git stash apply'
alias ghm='git stash push -m'
alias ghp='git stash pop'
alias gf="git fetch --verbose --progress --all --prune -j$(nproc 2>/dev/null || echo 1)"
alias gd='git diff'
alias gdc='git diff --cached'
alias gtree='git log --oneline --graph --decorate --branches --remotes --tags --notes'
alias gl='git log --oneline --graph --decorate'
alias gll='git log'
alias gr='git reset'
alias gcl='git clone --recursive'
gpla() {
# git-pull_all-my-branches
remote="$(test $1 && echo $1 || git remote show)"
remote_show="$(git remote show "$remote")"
branches=$(echo "$remote_show" | grep 'out of date' | cut -d' ' -f5)
local_branches=$(echo "$remote_show" \
| grep -B 1000 'Local branches' \
| tail -n +6 \
| head -n -1 \
| cut -d' ' -f5)
push_branches=$(echo "$remote_show" \
| grep -A 1000 'Local refs' \
| tail -n +2 \
| cut -d' ' -f5)
diff=$(diff <(echo "$local_branches") <(echo "$push_branches"))
if test "$diff"; then
diff_branches=$(echo "$diff" | grep -E '^<' | cut -d' ' -f2)
branches=$(echo "$diff_branches
$branches" | sort | uniq)
fi
if test "$branches"; then
current_branch=$(git branch | grep '*' | cut -d' ' -f2)
# git add -A .
# git stash
git fetch --all --prune
echo
for branch in $(echo $branches); do
echo "[$branch] "
git checkout "$branch"
git merge --ff-only "$remote/$branch"
echo
done
git checkout "$current_branch"
# git stash apply # pop?
fi
}
# keep aliases after those
alias sudo='sudo '
alias watch='watch -c -t -n 3 '
# these were kinda hard to write with a function
eval "$(thefuck --alias fok 2> /dev/null)"
alias gdb='gdb -quiet'
alias c='cd'
alias ..='cd ..'
alias ...='cd ../..'
alias ....='cd ../../..'
alias .....='cd ../../../..'
# yes, I'm human
alias du='du -h'
alias df='df -h'
alias free='free -h'
# typo aliases
alias xs='cd'
alias vf='cd'
alias z=e
alias m=ls
alias k=ls
alias ms=ls
alias lq=ls
alias ks=ls
alias sl=ls
alias pyhton=python
alias ipyhton=ipython
alias unmount=umount
alias umout=umount
# enable color support
if [ "$(uname -s)" = "Linux" ]; then
if test -x /usr/bin/dircolors && test -r ~/.dircolors; then
eval "$(dircolors -b ~/.dircolors)"
else
export LS_COLORS="no=00:fi=00:di=01;34:ln=01;36:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:ex=01;31:tw=40;1;41:ow=40;1;41:*.tar=01;31:*.tgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.gz=01;31:*.deb=01;31:*.jpg=01;35:*.gif=01;35:*.bmp=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.mpg=01;37:*.avi=01;37:*.gl=01;37:*.dl=01;37:"
fi
alias ls='ls --color=auto'
else
export LSCOLORS="ExGxcxdxBxexexaBaBacad"
alias ls='ls -G'
fi
alias dir='dir --color=auto'
alias vdir='vdir --color=auto'
alias grep='grep --color=auto'
alias fgrep='fgrep --color=auto'
alias egrep='egrep --color=auto'
alias diff='diff --color=auto'
alias wdiff='dwdiff -c'
alias pacsearch='pacsearch -c'
alias pactree='pactree -c'
alias bb='bb-wrapper --aur --build-dir /tmp/bb-build'
# support colors in less
export LESS=-R
export LESS_TERMCAP_mb=$(printf "\e[1;31m")
export LESS_TERMCAP_md=$(printf "\e[1;31m")
export LESS_TERMCAP_me=$(printf "\e[0m")
export LESS_TERMCAP_se=$(printf "\e[0m")
export LESS_TERMCAP_so=$(printf "\e[1;44;33m")
export LESS_TERMCAP_ue=$(printf "\e[0m")
export LESS_TERMCAP_us=$(printf "\e[1;32m")
# moar colors
if [ "$TERM" != dumb ] && $(hash grc 2>/dev/null); then
alias colourify="grc -es --colour=auto"
if [ $(uname -s) = "Linux" ]; then
alias ll="colourify ls -lh --color=always"
alias la="colourify ls -lAh --color=always"
else
alias ll="ls -lh"
alias la="ls -lAh"
fi
# alias cat="grc -es --colour=on cat"
alias configure='colourify ./configure'
alias du="colourify du -h"
alias df="colourify df -h"
alias free="colourify free -h"
alias sql="colourify mysql $SQL_ARGS"
alias cc="cc -fdiagnostics-color=always"
alias g++="g++ -fdiagnostics-color=always"
alias gcc="gcc -fdiagnostics-color=always"
# bugged, don't use it
# alias make="$(hash colormake 2>/dev/null && echo colormake || echo colourify make)"
alias as="colourify as"
alias blkid="colourify blkid"
alias dig="colourify dig"
alias env="colourify env"
alias getfacl="colourify getfacl"
alias head="colourify head"
alias ifconfig="colourify ifconfig"
alias iostat="colourify iostat"
alias ip="colourify ip"
alias iptables="colourify iptables"
alias journalctl="colourify journalctl"
alias last="colourify last"
alias ld="colourify ld"
alias link="colourify link"
alias lsattr="colourify lsattr"
alias lsblk="colourify lsblk -o NAME,LABEL,SIZE,FSAVAIL,FSUSE%,MOUNTPOINT,UUID"
alias lsmod="colourify lsmod"
alias lspci="colourify lspci"
alias lshw="colourify lshw"
alias mount="colourify mount"
alias netstat="colourify netstat"
alias nmap="colourify nmap"
alias php="colourify php"
alias ping="colourify ping"
alias ps="colourify ps"
alias sar="colourify sar"
alias showmount="colourify showmount"
alias ss="colourify ss"
alias stat="colourify stat"
alias sysctl="colourify sysctl"
alias systemctl="colourify systemctl"
alias tail="colourify tail"
alias tcpdump="colourify tcpdump"
alias traceroute="colourify traceroute"
alias tune2fs="colourify tune2fs"
alias uptime="colourify uptime"
alias vmstat="colourify vmstat"
alias w="colourify w"
alias who="colourify who"
alias lsof="colourify lsof"
alias docker="colourify docker"
alias docker-machine="colourify docker-machine"
alias docker-compose="colourify docker-compose"
colored_sizeof() {
sizeof "$1" | grcat /usr/share/grc/conf.du
}
alias sizeof="colored_sizeof"
# alias diff="colourify diff --color=always" #clash with diff colors
# unused
# alias ant="colourify ant"
# alias cvs="colourify cvs"
# alias esperanto="colourify esperanto"
# alias dnf="colourify dnf"
# alias gas="colourify gas"
# alias gmake="colourify gmake"
# alias irclog="colourify irclog"
# alias ldap="colourify ldap"
# alias log="colourify log"
# alias mtr="colourify mtr"
# alias mvn="colourify mvn"
# alias ping6="colourify ping6"
# alias proftpd="colourify proftpd"
# alias pv="colourify pv"
# alias semanage="colourify semanage"
# alias traceroute6="colourify traceroute6"
# alias ulimit="colourify ulimit" #bjorked
# alias wdiff="colourify wdiff"
fi
unset SQL_ARGS