summary refs log tree commit diff
path: root/dot_config/zsh/alias.zsh
blob: 1f9f1944f0614e6be4015d910e17f27a8e1e846b (plain)
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
# Alias deprecated youtube-dl to yt-dlp
if which yt-dlp &>/dev/null; then
    alias youtube-dl="yt-dlp"
fi

# Alias to .local/venv programs
# Should probably move to symlinks
if ! which xq &>/dev/null; then
    alias xq="${HOME}/.local/venv/xq/bin/xq"
fi
if ! which black &>/dev/null; then
    alias black="${HOME}/.local/venv/black/bin/black"
fi
if ! which blackd &>/dev/null; then
    alias blackd="${HOME}/.local/venv/black/bin/blackd"
fi

if [[ "$(uname)" == "Darwin" ]] && ! which tac &>/dev/null; then
    alias tac='tail -r'
fi

# Nicer history
alias h='history 1 | tail -r | bat --style=plain --language=zsh'

# Set up ls aliases
if which exa &>/dev/null; then
    alias ls='exa --classify --group-directories-first --git'
    alias tree='exa --classify --group-directories-first --git --tree --git-ignore'
elif which lsd &>/dev/null; then
    alias ls='lsd'
    alias tree='lsd --tree'
elif [[ $(uname) = 'Darwin' ]]; then
    if which gls &>/dev/null; then
        alias ls='gls --color=tty --classify --time-style long-iso --human-readable'
    else
        alias ls='ls -GFh -D "%Y-%m-%d %H:%M"'
    fi
else
    alias ls='ls --color=tty --classify --time-style long-iso --human-readable'
fi
alias l='ls -l'
alias ll='ls -la'

# Coloured + VCS / common unwanted dir grep
_GREP_EXCLUDE='{.bzr,CVS,.git,.hg,.svn,.idea,.tox,venv}'
if which grep &>/dev/null; then
    alias grep="grep --color=auto --exclude-dir=${_GREP_EXCLUDE}"
fi
if which egrep &>/dev/null; then
    alias egrep="egrep --color=auto --exclude-dir=${_GREP_EXCLUDE}"
fi
if which fgrep &>/dev/null; then
    alias fgrep="fgrep --color=auto --exclude-dir=${_GREP_EXCLUDE}"
fi

if which todo.sh &>/dev/null; then
    alias t='todo.sh'
    alias tls='todo.sh ls | head -n 10'
    alias tl='todo.sh ls | less'
fi

# Colorise
if which ip &>/dev/null; then
    alias ip='ip -c'
fi
if which watch &>/dev/null; then
    alias watch='watch --color'
fi

# Arch stuff
if which yay &>/dev/null; then
    alias yay='sudo -u aurbuilder yay'
fi
if which pacman &>/dev/null; then
    alias pacman='pacman --color auto'
fi
if which pactree &>/dev/null; then
    alias pactree='pactree --color'
fi

# Date stuff
alias isodate='date +%Y-%m-%d'
alias isodatetime='date +%Y-%m-%dT%H:%M:%S%z'
alias pdate='date +"%Y-%m-%d %H:%M %z"'

# Force myself to use better things
if which bat &>/dev/null; then
    alias cat='bat'
fi

# Trash instead of rm
if which trash &>/dev/null; then
    alias rm='trash'
fi

# prettyping
if which prettyping &>/dev/null; then
    alias pping='prettyping --nolegend'
fi

# Use open as xdg-open on macOS
if ! which xdg-open &>/dev/null && which open &>/dev/null; then
    alias xdg-open='open'
fi

# shorthand for dumping QR codes in CLI
if which qrencode &>/dev/null; then
    alias qr='qrencode -t UTF8 -o -'
    alias qri='qrencode -t UTF8i -o -'
fi

# Generic dir aliases
alias -g ...='../..'
alias -g ....='../../..'
alias -g .....='../../../..'
alias -g ......='../../../../..'

alias -- -='cd -'
alias 1='cd -1'
alias 2='cd -2'
alias 3='cd -3'
alias 4='cd -4'
alias 5='cd -5'
alias 6='cd -6'
alias 7='cd -7'
alias 8='cd -8'
alias 9='cd -9'

alias dh='dirs -v'