summaryrefslogtreecommitdiff
path: root/dotfiles-darwin/zsh/rc
blob: 940fe770f0ec45ea39a01f960c5a33994fe1aaa4 (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
# -*- mode: shell-script -*-

autoload -Uz vault

alias df='df -Ph'
alias pbclear='pbcopy </dev/null'
alias rsync='rsync --exclude=.DS_Store'

if command_exists container; then
  alias co=container
fi

if ! command_exists eza; then
  alias ls='ls -G'
fi

if command_exists gls; then
  alias lsh='gls -Shrs'
else
  alias lsh='ls -Shlr | cut -f5- -w'
fi

if command_exists pstree; then
  alias pstree='pstree -g 3'
fi

if [[ -d /opt/homebrew/share/zsh/site-functions ]]; then
  # Unlike the /usr/local/… path, this path has to be manually added. We
  # append it before the first system-wide ones and after the dotfiles
  # ones.
  fpath[${fpath[(i)/usr/local/share/zsh/site-functions]},0]=/opt/homebrew/share/zsh/site-functions
fi

# Make Homebrew appear right after /usr/local/bin. For some reason,
# Homebrew appears is at the end of the PATH, which is wrong.
if (( path[(i)/usr/local/bin] + 1 != path[(i)/opt/homebrew/bin] )); then
  path[(i)/opt/homebrew/bin]=()
  path[$((path[(i)/usr/local/bin] + 1)),0]=/opt/homebrew/bin
fi

if [[ ${TERM_PROGRAM} != iTerm.app ]]; then
  autoload -Uz vcs_info

  zstyle ':vcs_info:*' enable git
  zstyle ':vcs_info:*' formats '[%b]'

  RPROMPT='${vcs_info_msg_0_}'
  precmd_functions+=(vcs_info)

  setopt PROMPT_SUBST
fi