mrrl-zsh_config

Default ZSH configuration for mrrl
git clone https://ccx.te2000.cz/git/mrrl-zsh_config
Log | Files | Refs

commit c73505cc47870bd09e8e204d98ac5976e0d4cb52
Author: ccx <ccx@te2000.cz>
Date:   Mon, 26 Feb 2024 22:16:16 +0000

initial setup

Diffstat:
Aetc/zlogin | 1+
Aetc/zshenv | 50++++++++++++++++++++++++++++++++++++++++++++++++++
Aetc/zshrc | 1+
Azsh-functions/site_rc | 25+++++++++++++++++++++++++
4 files changed, 77 insertions(+), 0 deletions(-)

diff --git a/etc/zlogin b/etc/zlogin @@ -0,0 +1 @@ +(($site_rcs_enable)) && site_rc zlogin diff --git a/etc/zshenv b/etc/zshenv @@ -0,0 +1,50 @@ +() { + # If $ZDOTDIR is not set and none of .zshenv, .zprofile, .zshrc, .zlogin exist + # in $HOME, read ZSH startup files from $XDG_CONFIG_HOME/zsh/ instead of $HOME. + # The point is to promote XDG-based location, but don't break existing setups. + [[ -n "${ZDOTDIR-}" ]] && return + setopt localoptions extendedglob nullglob + local -a _xdgrcs _homercs + _homercs=( "$HOME"/.z(shenv|profile|shrc|login) ) + if (( $#_homercs )); then + [[ -o interactive ]] || return + _xdgrcs=( ${XDG_CONFIG_HOME:-$HOME/.config}/zsh/.z(shenv|profile|shrc|login) ) + if (( $#_xdgrcs )); then + local _c=${XDG_CONFIG_HOME:-$HOME/.config}/zsh + printf '%s\n' >&2 \ + "Warning: Found Zsh startup files both in ~/ and $_c" \ + " the latter will be ignored (tip: move $_homercs to $_c/)." + fi + else + ZDOTDIR=${XDG_CONFIG_HOME:-$HOME/.config}/zsh + fpath=( $ZDOTDIR/functions $fpath ) + fi +} + +() { + [[ -o rcs ]] || return + + (($+site_rc_blacklist)) || typeset -ga site_rc_blacklist + + if ! (($+site_rcs_enable)); then + if ! [[ -o GLOBAL_RCS ]]; then + site_rcs_enable=0 + elif [[ -f ${ZDOTDIR:-$HOME}/.zsh_site_rcs ]]; then + site_rcs_enable=1 + autoload -Uz site_rc + source ${ZDOTDIR:-$HOME}/.zsh_site_rcs + else + local -a site_rcs_dotfiles + site_rcs_dotfiles=( ${ZDOTDIR:-$HOME}/.z(profile|login|sh(rc|env))(N) ) + if (($#site_rcs_dotfiles)); then + site_rcs_enable=0 + else + site_rcs_enable=1 + autoload -Uz site_rc + fi + fi + fi + + (($site_rcs_enable)) && site_rc zshenv +} +# vim: ft=zsh noet ts=4 sts=4 sw=4 diff --git a/etc/zshrc b/etc/zshrc @@ -0,0 +1 @@ +(($site_rcs_enable)) && site_rc zshrc diff --git a/zsh-functions/site_rc b/zsh-functions/site_rc @@ -0,0 +1,25 @@ +local ppath='' name func black skip +local -a match mbegin mend rc_functions func_files + +func_files=( $^fpath/site_${~1}_*(N) ) + +for func in $func_files ; do + if ! [[ -r "$func" ]]; then + print -r >&2 - "$func is not readable" + continue + fi + autoload -Uz $func:t + rc_functions+=$func:t +done + +for func in ${(o)rc_functions}; do + skip=0 + for black in $site_rc_blacklist; do + if [[ $func == $~black ]]; then + skip=1 + break + fi + done + (($skip)) || $func +done +# vim: ft=zsh noet ts=4 sts=4 sw=4