blob: 2d292eaa909a3f0d797166b031d0533eef212ae4 (
plain) (
blame)
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
|
# utils.zsh
# Replacements for coreutils, color and reasonable defaults for common tools, etc.
function has () {
command -v "$@" &> /dev/null
}
# cat
has bat && alias cat='bat --plain --paging=never'
# should consider another alias for --show-all (and --number on base cat) but it's not a good default
# diff
alias diff='diff --color'
# grep
grep_opts="--color=auto --exclude-dir=.git"
alias grep="grep $grep_opts"
alias egrep="egrep $grep_opts"
alias fgrep="fgrep $grep_opts"
unset grep_opts
# ls
if has eza; then
alias ls='eza'
alias ll='eza --long --header --all'
elif ls --almost-all &> /dev/null; then
alias ls='ls --color=auto'
alias ll='ls -l --almost-all --no-group --human-readable --color=auto'
else
# bsd/mac ls
alias ls='ls -G'
alias ll='ls -hoAG'
fi
# tree
has tree && alias tree='tree -C'
# mkdir
alias mkdir='mkdir -p'
# dd
alias dd="dd status=progress oflag=direct,sync"
## df
if df --exclude-type=tmpfs &> /dev/null; then
alias df="df -TH --exclude-type=tmpfs --exclude-type=devtmpfs --exclude-type=squashfs --exclude-type=udev"
else
# bsd/mac df
alias df="df -YH -T noautofs,devfs,tmpfs,squashfs"
fi
# gpg
has gpg2 && alias gpg='gpg2'
# cygwin-specific
if [[ "$OSTYPE" == 'cygwin' ]]; then
alias sudo='cygstart --action=runas'
fi
unfunction has
|