From: sev Date: Sat, 23 Mar 2024 11:36:42 +0000 (-0500) Subject: zshrc: update PATH generation X-Git-Url: https://git.sev.monster/~sev/dotfiles.git/commitdiff_plain/e7e78648a11c6a494c27bd4c68fbbb37d0e0ed9d?hp=390f6e6794cd2b91450cc2731c2e403062e9e650 zshrc: update PATH generation --- diff --git a/etc/zsh/.zshenv b/etc/zsh/.zshenv index f43343b..c63c390 100644 --- a/etc/zsh/.zshenv +++ b/etc/zsh/.zshenv @@ -51,19 +51,24 @@ function _sev_zcleanup { } function _sev_setpath { - # NOTE: we utilize the fact that unique arrays keep the first occurrence and - # remove any further occurences to capture elements from the old PATH - # that we did not anticipate and shift them to the front, since they are - # probably important to the system - # NOTE: tied arrays path and fpath already exist - typeset -gU path fpath # add as many generic paths as possible to keep the order we want - # NOTE: /usr/{local,pkg,games} are unix/bsdisms - # XXX: PREFIX not validated, non-posix but Termux uses it, maybe others + # NOTE: tied arrays path and fpath already exist, but are not unique (-U); + # we utilize the fact that unique arrays keep the first occurrence + # and remove any further occurences to check for elements from the + # old PATH that we did not anticipate and shift them to the front, + # since they are probably important to the system + typeset -gU path fpath + local -a syspath=("$path[@]") + # NOTE: /usr/{pkg,games} are unix/bsdisms + # NOTE: some systems (esp. research machines) may have multiple versions of + # packages installed in /opt/[pkg]/[ver]/bin or other dirs, managed + # with something like Environment Modules. this code does not account + # for this type of usage and will add all valid paths. any undesired + # paths can be removed using .zshenv.local. + # XXX: PREFIX not validated, non-POSIX but Termux uses it, maybe others # XXX: XDG specifies ~/.local/bin as the only user-writable dir for # executables, but we specify more; technically this is against spec - local -a syspath=("$path[@]") - path=({{${_sev_home:-~},~}{/.local,},{$PREFIX,}{,/usr{,/local,/pkg},/opt,/opt/*{/*,}}}/{s,}bin(N) + path=({{${_sev_home:-~},~}{/.local,},{$PREFIX,}{,/usr{,/local,/pkg},/opt{,/*{/*,}}}}/{s,}bin(N) {$PREFIX,}/usr/{X11R{7,6}/bin,games} # emulate Arch Linux flatpak-bindir.sh for use on other systems {${XDG_DATA_HOME:-~/.local/share},{$PREFIX,}/var/lib}/flatpak/exports/bin) @@ -92,6 +97,7 @@ function _sev_setpath { } # FPATH is not exported by default export FPATH + # un-unique system arrays for consistency typeset +U path fpath }