-
Notifications
You must be signed in to change notification settings - Fork 7
/
aliases.sh
executable file
·439 lines (375 loc) · 8.4 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
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
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
#
# magic cross-platform "open" command
#
# if [ "$OSTYPE" == "cygwin" ]; then
# alias open='cygstart'
# elif [ -f /usr/bin/xdg-open ]; then
# alias open='xdg-open "$@" 2>/dev/null'
# elif [ -f /usr/bin/exo-open ]; then
# alias open='exo-open "$@" 2>/dev/null'
# elif [ -f /usr/bin/gnome-open ]; then
# alias open='gnome-open "$@" 2>/dev/null'
# fi
# alias open='xdg-open "$@" 2>/dev/null'
alias reload="exec bash"
alias aaa='bl 5'
alias aaaa=aaa
alias aaaaa=aaa
alias aa=aaa
function we_have() {
which "$@" > /dev/null 2>&1
}
function alias_all_as_sudo() {
for var in "$@"
do
alias $var="sudoifnotroot $var"
done
}
## if CLICOLOR doesn't work, this can hard-wire color-ls
if [ "$TERM" != "dumb" ]; then
#export LS_OPTIONS='--color=auto'
if we_have dircolors
then
eval `dircolors -b`
fi
alias ls="ls --color=auto"
fi
## aliases
alias ll='l'
alias la='l -a'
alias lt='d -lt'
alias lh='ls -lh'
alias lts='d -ls'
alias da='d -a'
if we_have exa
then
alias ls='exa'
alias l='exa -ag --long --header'
function t() {
exa --long --header --tree --color=always --ignore-glob=__pycache__ "$@" | less -SRXFi
}
else
alias l='ls -al'
function t() {
tree -Ca $* | less -SRXFi
}
fi
# function fd() {
# query="$@"
# $(which fd) --color=always "$query" | less -RS "+/$query"
#}
#if which fd > /dev/null; then
# alias f='fd -IH'
#fi
# cd
alias up='cd ..'
alias back='cd "$OLDPWD"'
alias cd..='cd ..'
alias ..='cd ..'
alias ...='cd ../..'
alias ....='cd ../../..'
alias .....='cd ../../../..'
alias ......='cd ../../../../..'
alias .......='cd ../../../../../..'
# alias +='pushd .'
# alias -- -='popd'
mkcd() {
if [ ! -d "$@" ]; then
mkdir -p "$@"
fi
cd "$@"
}
pushpath() {
if [ "$1" == "" ]; then
dir="$PWD"
else
dir="`readlink -m "$1"`"
fi
export PATH="$dir":$PATH
echo "'$dir' added to path."
}
# filesystem
alias mv="mv -v"
alias mv-backup='mv --backup=numbered'
alias cp="cp -v"
alias rm='trsh'
alias r='ren'
alias rehash='hash -r'
alias cx='chmod +x'
alias c-x='chmod -x'
alias cls='clear'
alias wh='which'
# text
if ! we_have nano && we_have pico; then
alias nano="pico -w"
else
alias nano="nano -w"
fi
alias n=nano
alias s.='s .'
alias c.='c .'
alias egrep='egrep --color=auto'
alias fgrep='fgrep --color=auto'
alias grep='grep --color=auto'
alias rcat='tac'
rgrep() {
expression=$1
shift
rcat "$@" | grep -Ei $expression
}
pager='less -RSFXi'
if we_have rg
then
rg() {
`which rg` --pretty "$@" | $pager
}
#alias ag="rg"
fi
if we_have ag
then
alias ag="ag --smart-case --pager '$pager'"
else
alias ag="ack --pager '$pager'"
fi
alias less='less -X -F -i'
alias diff='diff -u --color'
alias vimless='vim -u ~/.vimrc.less -'
alias vless=vimless
if we_have scc; then
alias cloc='scc'
fi
# media
alias o="open"
alias o.="open ."
alias a="audacious"
alias ae="a -e"
alias a2="a"
alias ch="chromium"
alias qute="qutebrowser"
alias mixer="pulsemixer"
alias yd='youtube-dl --xattrs --no-mtime'
if we_have ueberzug; then
alias ytf='ytfzf -t --detach'
else
alias ytf='ytfzf --detach'
fi
# net
alias_all_as_sudo iptables netctl ufw dhcpcd nethogs
alias ssh='ssh -2'
alias scpfast='scp -c arcfour128'
alias sshfast='ssh -c arcfour128'
alias mosh='msh'
alias whois='whois -H'
alias geoip='geoiplookup'
alias geoip6='geoiplookup6'
alias iptraf='sudoifnotroot iptraf-ng'
alias ip6='ip -6'
# disks
alias_all_as_sudo fdisk blkid
alias fatrace="sudoifnotroot fatrace | grep -v xfce4-terminal"
alias md='mdadm'
alias df='df -h'
alias df.='df .'
alias screen='screen -U'
alias e.='e .'
best_of() {
best=$( which $* 2> /dev/null | head -n 1 )
if [ "$best" != "" ]; then
basename $best
fi
}
alias best_dd="$(best_of dd_rescue dcfldd ddrescue dd)" # find the best dd
dd() {
if (( $# == 0 )); then
best_dd --help |& less
else
best_dd "$@"
fi
}
# if we_have dd_rescue; then
# alias dd='dd_rescue'
# elif we_have dcfldd; then
# alias dd='dcfldd'
# elif we_have ddrescue; then
# alias dd='ddrescue'
# fi
alias um='unmount'
alias lsmnt='findmnt'
alias lsblk='lsblk -o MODEL,SIZE,TYPE,NAME,MOUNTPOINT,LABEL,FSTYPE'
alias disks='lsblk'
# system
alias_all_as_sudo sysdig swapped perf
alias dmesg='dmesg -T --color=always|less -S -R +\>'
alias dmesg-tail='\dmesg -T --color -w'
alias dstat-wide='dstat -tcyifd'
#alias off='sudoifnotroot shutdown -h now || sudoifnotroot systemctl poweroff'
#alias reboot='sudoifnotroot shutdown -r now || sudoifnotroot systemctl reboot'
#alias reboot='sudoifnotroot systemctl reboot'
alias sus='ssu'
# systemd
# alias_all_as_sudo systemctl journalctl
alias jc='journalctl'
alias jt='journalctl -f'
alias sys='systemctl'
alias j='journalctl'
alias iu='i --user'
alias suspend='systemctl suspend -i'
# misc
alias dict='dictless'
alias wh="$(which w 2> /dev/null)"
alias w='wict'
alias chrome='google-chrome'
alias dmenu="dmenu -l 50"
alias resett="tput reset"
alias xmem='xrestop'
alias flash='crutziplayer'
alias rdp='xfreerdp'
alias gource='gource --user-image-dir ~/.cache/gravatars'
alias psx='pcsxr'
alias detach='bg; disown'; alias det=detach
alias dpkg='sudoifnotroot dpkg'
alias record-desktop="simplescreenrecorder"
alias b='chromium'
alias columns='cols'
# archives
alias ax="aunpack"
alias ac="apack"
alias al="als"
# git
alias gs="git status"
alias gd="git diff"
alias ga="git add"
alias glu="gl -u"
alias gch="git checkout"
# alias g[[="git stash"
# alias g]]="git stash pop"
# alias g[]="git stash list; git stash show"
alias g+="git add"
alias gr="git remote -v"
alias gf="git fetch --all -v --prune"
alias fetch="gf"
alias whose-line-is-it-anyway="git blame"
# functions
functions() {
declare -f | less
}
# alias gc="git clone"
gc() {
# Cloning into 'reponame'...
if $(which gc) "$@"; then
cd "$(\ls -tr | tail -n1)"
else
echo "clone failed"
fi
}
aur() {
if [ ! -d ~/aur ]; then mkdir ~/aur; fi
cd ~/aur
if [ -d "$@" ]; then
echo "* $@ already downloaded. updating..."
cd "$@"
git pull
else
aur-get "$@"
if [ -d "$@" ]; then
cd "$@"
c PKGBUILD
else
echo "something went wrong?"
fi
fi
}
kill-bg-jobs() {
jobs=`jobs -ps`
if [ "$jobs" == "" ]; then
echo "Couldn't find any running background jobs"
else
echo "killing jobs: $jobs"
kill -9 $jobs
fi
}
alias gcs="gc --depth=1"
# scripting languagey things
alias be="bundle exec"
alias rock='luarocks'
alias gi='gem install'
alias rb='ruby'
alias py=python
alias py2=python2
alias py3=python3
alias pip='python -m pip'
alias pip2='python2 -m pip'
alias pip3='python3 -m pip'
alias pi='pip install --user'
alias pi2='pip2 install --user'
alias pi3='pip3 install --user'
alias piu='pip uninstall'
alias ipy=ipython
alias ipy3=ipython3
alias ipy2=ipython2
alias ni='npm install'
gem-cd() {
local gem_dir
if gem_dir="`gem-dir $@`"; then
cd "$gem_dir"
fi
}
pip-cd() {
for dir in `\ls -1rd ~/.local/lib/python*/site-packages/` `\ls -1rd /usr/lib/python*/site-packages/`; do
if [ -d $dir/$1 ]; then
cd $dir/$1
break
fi
done
}
alias pycd=pip-cd
# # 64/32bit specific aliases
# case `uname -m` in
# x86_64)
# ;;
# *)
# ;;
# esac
# Things with literal arguments!
#alias math='noglob math'
#alias gfv='noglob gfv'
# upm
alias u=upm
alias uu='upm update'
alias up='upm upgrade'
alias ui='upm install'
alias ur='upm remove'
alias uf='upm files'
alias ul='upm list'
alias us='upm search'
# arch
alias pacman='sudoifnotroot /usr/bin/pacman'
# alias pacs='\pacman -Ss' # search for package
alias pacf='\pacman -Ql|grep' # which package contains this file?
alias pacq='\pacman -Q|grep' # find a package
alias pacg='\pacman -Qg' # show groups
alias pacu='pacman -Syu' # update packages
alias pacd='pacman -Syuw' # only download updates (no install)
alias pacr='pacman -Rs --' # remove package (and unneeded dependencies)
alias pacrf='pacman -Rc' # remove package (and force removal of dependencies)
alias pacpurge='pacman -Rns' # purge a package and all config files
alias pacuproot='pacman -Rsc' # remove package, dependencies, and dependants
alias abs='sudoifnotroot abs'
# alias pkgfile='sudoifnotroot pkgfile -r'
if we_have yaourt; then
alias y='yaourt'
else
alias y='aurs'
fi
# npm
# alias ni="sudoifnotroot npm install -g"
# alias nl="npm list -g --color=always |& less -S"
#
# Usage:
# faketty <command> <args>
#
# (Almost works... There's just a newline issue)
#
#function faketty { script -qfc "$(printf "%q " "$@")"; }
shiftpath() { [ -d "$1" ] && PATH="${PATH}${PATH:+:}${1}"; }
alias psh=pwsh