| 1 | # System-wide .zshrc file for zsh(1), sourced only for interactive shells. |
| 2 | # |
| 3 | # Global order: zshenv, zprofile, zshrc, zlogin |
| 4 | |
| 5 | # If ZSH startup files exist both in $HOME and XDG-based config directory, |
| 6 | # print a warning (but only if running as a login shell). Note that XDG-based |
| 7 | # config directory is used only when no ZSH startup files are found in $HOME |
| 8 | # (see /etc/zsh/zshenv). |
| 9 | if [[ -z "${ZDOTDIR-}" && -o login ]]; then |
| 10 | _xdgdir=${XDG_CONFIG_HOME:-$HOME/.config}/zsh |
| 11 | if _xdgrcs=("$_xdgdir"/.z{shenv,profile,shrc,login}(N)) && (( $#_xdgrcs )); then |
| 12 | _homercs=("$HOME"/.z{shenv,profile,shrc,login}(N:t)) |
| 13 | print "Warning: Found Zsh startup files both in ~/ and ${_xdgdir/$HOME/\~}/, the latter will\n" \ |
| 14 | " be ignored (tip: move $_homercs to ${_xdgdir/$HOME/\~}/)." >&2 |
| 15 | fi |
| 16 | unset _xdgdir _xdgrcs _homercs |
| 17 | fi |
| 18 | |
| 19 | # TIP: If you don't want any plugins to be automatically loaded here, add |
| 20 | # `zsh_plugin_dirs=()` to your $ZDOTDIR/.zshenv. |
| 21 | if (( ! ${+zsh_plugin_dirs} )); then |
| 22 | zsh_plugin_dirs=("${XDG_DATA_HOME:-$HOME/.local/share}/zsh/plugins") |
| 23 | fi |
| 24 | |
| 25 | # TIP: If you want to automatically use all ZSH plugins installed from Alpine |
| 26 | # packages, add `ZSH_LOAD_SYSTEM_PLUGINS=yes` to your $ZDOTDIR/.zshenv. |
| 27 | if [[ "${ZSH_LOAD_SYSTEM_PLUGINS-}" = [1ty]* ]]; then |
| 28 | zsh_plugin_dirs+=('/usr/share/zsh/plugins') |
| 29 | fi |
| 30 | |
| 31 | # Find plugins (per Oh-My-Zsh convention) under $zsh_plugin_dirs (array of |
| 32 | # paths) and add them to $fpath. |
| 33 | _plugins=() |
| 34 | for _dir ($zsh_plugin_dirs); do |
| 35 | for _name ("$_dir"/*(N:t)); do # equivalent of 'basename $i' |
| 36 | if [[ -f "$_dir/$_name/$_name.plugin.zsh" ]]; then |
| 37 | _plugins+=("$_dir/$_name/$_name.plugin.zsh") |
| 38 | fpath=("$_dir/$_name" $fpath) |
| 39 | fi |
| 40 | done |
| 41 | done |
| 42 | |
| 43 | # Source each <name>.zsh script in /etc/zsh/zshrc.d/ which <name> is not |
| 44 | # included in $zshrcd_blacklist. |
| 45 | # |
| 46 | # TIP: If you want to prevent some scripts in /etc/zsh/zshrc.d from being |
| 47 | # loaded, say a.zsh and b.zsh, add `zshrcd_blacklist=(a b)` to your |
| 48 | # $ZDOTDIR/.zshenv ($XDG_CONFIG_HOME/zsh/.zshenv). |
| 49 | zshrcd_blacklist+=() |
| 50 | _scripts=(/etc/zsh/zshrc.d/*.zsh(N:t:r)) # equivalent of 'basename $i .zsh' |
| 51 | for _name (${_scripts:|zshrcd_blacklist}); do # :| is a set difference A \ B |
| 52 | source "/etc/zsh/zshrc.d/$_name.zsh" |
| 53 | done |
| 54 | |
| 55 | # Source all plugins found in $zsh_plugin_dirs. |
| 56 | for _plugin ($_plugins); do |
| 57 | source "$_plugin" |
| 58 | done |
| 59 | |
| 60 | unset _dir _name _plugin _plugins _scripts |
| 61 | unset zsh_plugin_dirs zshrcd_blacklist ZSH_LOAD_SYSTEM_PLUGINS |
| 62 | |
| 63 | # vim: set ft=zsh ts=4: |
| 64 | |