summaryrefslogtreecommitdiffstats
path: root/dot_config/zsh/aliasrc
blob: c3e724ded03e0b5730d9e5d70c21d71431280ebf (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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#!/bin/sh

# Use neovim for vim if present.
[ -x "$(command -v nvim)" ] && alias vim="nvim" vimdiff="nvim -d"

# If code-insiders exists and code does not, use code-insiders.
[ -x "$(command -v code-insiders)" ] && [ ! -x "$(command -v code)" ] && alias code="code-insiders"

# if batcat exists and bat does not, use batcat.
[ -x "$(command -v batcat)" ] && [ ! -x "$(command -v bat)" ] && alias bat="batcat"

# If fdfind exists and fd does not, use fdfind.
[ -x "$(command -v fdfind)" ] && [ ! -x "$(command -v fd)" ] && alias fd="fdfind"

# Use $XINITRC variable if file exists.
[ -f "$XINITRC" ] && alias startx='startx "$XINITRC"'

# sudo not required for some system commands
for x in mount umount sv emerge apt pacman updatedb su; do
  # shellcheck disable=SC2139
  alias $x="sudo $x"
done

if command -v doas >/dev/null 2>&1; then
  alias sudo='doas'
else
#    alias sudo='sudo -E'
fi

# Verbosity and settings that you pretty much just always are going to want.
alias \
  cp="cp -iv" \
  mv="mv -iv" \
  rm="rm -vI" \
  bc="bc -ql" \
  mkdir="mkdir -pv" \
  yt="yt-dlp --add-metadata -i" \
  yta="yt -x -f bestaudio/best" \
  ffmpeg="ffmpeg -hide_banner" \
  df="df -h" \
  du="dust -r" \
  free="free -m" \
  gdb='gdb -q -nh -x "$XDG_CONFIG_HOME/gdb/init"' \
  wget='wget --hsts-file="$XDG_DATA_HOME/wget-hsts"'

# Colorize commands when possible.
alias \
  ls="eza -aF --group-directories-first" \
  ll="eza -alg --group-directories-first" \
  lt='eza -aTF --group-directories-first' \
  lr='eza -aRF' \
  grep="rg --color=auto --hyperlink-format=file://{wslprefix}{path}" \
  diff="delta" \
  cat='bat --paging=never --style=plain'

# These common commands are just too long! Abbreviate them.
alias \
  ka="killall" \
  g="git" \
  trem="transmission-remote" \
  YT="youtube-viewer" \
  sdn="sudo shutdown -h now" \
  e="\$EDITOR" \
  v="\$EDITOR" \
  em="sudo emerge" \
  p="sudo pacman" \
  xi="sudo xbps-install" \
  xr="sudo xbps-remove -R" \
  xq="xbps-query" \
  z="zathura"

alias adb='HOME="$XDG_DATA_HOME"/android adb'

# Use the SSH kitten when possible. (but not already in SSH)
if [ "$TERM" = "xterm-kitty" ] && [ -z "$SSH_TTY" ]; then
  alias sshs='sshs -t "kitten ssh \"{{{name}}}\""'
fi