« get me outta code hell

.zshrc - dotfiles - Miscellaneous configuration files of my personal use
about summary refs log tree commit diff
path: root/.zshrc
blob: 0b12d52debfa54c1f4b7e581a83e9a6c07a82163 (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
# ~nebula/.zshrc, 2023 edition


# //// per-device configuration ///////////////////////////////////////////// #

# Per-device configuration is kept here in dotfiles.git too, but it won't be
# activated just by linking .zshrc. You also need to link ~/.device_pre and
# ~/.device_post to the relevant per-device files under `device`.

# All exports in pre-config are prefixed with `DEVICE_`, and are used to toggle
# features or identify installations in .zshrc or other scripts which are part
# of dotfiles.git.

device_preconfig() {
  source ~/.device_pre
}

# The post-config file is intended to run commands that are so specialized to
# the relevant device that it wouldn't make sense to include as a toggleable
# feature in the main .zshrc.

device_postconfig() {
  source ~/.device_post
}

device_preconfig


# //// zsh configuration //////////////////////////////////////////////////// #

export HISTFILE="$HOME/.zsh_history"
export SAVEHIST=1000
export HISTSIZE=2000

autoload -Uz select-word-style
select-word-style bash

if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
  autoload -U colors && colors
  PS1=$'\e[0;32;1m%n\e[0;32m@\e[32;1m%m \e[34m%1~ \e[0m%# '
  PROMPT="%F{green}%B%n%b@%B%m %F{blue}%1~%b%f %# "
else
  PS1=$'%n@%m %1~ %# '
fi

path+=("$HOME/bin")


# //// third party configuration //////////////////////////////////////////// #

# -- GPG --

if [[ -v DEVICE_HAS_GPG ]]; then
  export GPG_TTY=$(tty)
fi

# -- Homebrew --

if [[ -v DEVICE_HAS_HOMEBREW ]]; then
  eval "$("$DEVICE_HOMEBREW_INSTALLATION"/bin/brew shellenv)"

  if [[ -z DEVICE_HAS_PYENV ]]; then
    # https://github.com/pyenv/pyenv#homebrew-in-macos
    alias brew='env PATH="${PATH//$(pyenv root)\/shims:/}" brew'
  fi

  if [[ -s "$DEVICE_HOMEBREW_INSTALLATION/opt/util-linux" ]]; then
    path=("$DEVICE_HOMEBREW_INSTALLATION/opt/util-linux/bin" ${(@)path})
    path=("$DEVICE_HOMEBREW_INSTALLATION/opt/util-linux/sbin" ${(@)path})
  fi
fi

# -- Node Version Manager --

if [[ -v DEVICE_HAS_NVM ]]; then
  export NVM_DIR="$DEVICE_NVM_INSTALLATION"
  [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
  [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"
fi

# -- Python --

if [[ -v DEVICE_HAS_PYTHON_3 ]]; then
  path+=("$DEVICE_PYTHON_3_INSTALLATION/bin")
fi

# -- Python (pyenv) --

if [[ -z DEVICE_HAS_PYENV ]]; then
  eval "$(pyenv init -)"
fi

# -- Sublime Text --

if [[ -v DEVICE_HAS_SUBLIME_TEXT ]]; then
  path+=("$DEVICE_SUBLIME_TEXT_INSTALLATION)/Contents/SharedSupport/bin")
fi


export PATH


# //// per-device configuration ///////////////////////////////////////////// #

device_postconfig