From 8833894671f8d2e802bdd96d303599e4390f648d Mon Sep 17 00:00:00 2001 From: Danielle McLean Date: Thu, 20 Oct 2016 11:49:13 +1100 Subject: [PATCH] Reliably set up environment to be inherited by non-login shells, including FPATH --- config/zsh/all/env | 5 +++++ config/zsh/login/fpath | 4 +++- config/zsh/login/path | 6 +++--- 3 files changed, 11 insertions(+), 4 deletions(-) create mode 100644 config/zsh/all/env diff --git a/config/zsh/all/env b/config/zsh/all/env new file mode 100644 index 0000000..eb9ccf2 --- /dev/null +++ b/config/zsh/all/env @@ -0,0 +1,5 @@ +#! zsh +# We can't inherit the uniqueness flag -U through the environment, so it must +# be established in every Zsh to guarantee these parameters actually contain +# only unique values. +typeset -U cdpath fpath mailpath manpath path pythonpath diff --git a/config/zsh/login/fpath b/config/zsh/login/fpath index 6fd6bbd..6d4a6c2 100644 --- a/config/zsh/login/fpath +++ b/config/zsh/login/fpath @@ -1,5 +1,7 @@ #! zsh fpath=($ZDOTDIR/functions $fpath) -# filter out duplicates, nonexistent directories, and . (the current directory) fpath=(${(u)^fpath:#.}(N)) +# FPATH isn't exported by default like PATH is - to inherit the setting in +# non-login shells, we need to export it ourselves. +typeset -x FPATH diff --git a/config/zsh/login/path b/config/zsh/login/path index f92409a..0bfad87 100644 --- a/config/zsh/login/path +++ b/config/zsh/login/path @@ -1,7 +1,6 @@ #! zsh - path=(/usr/local/bin $path) -if whence brew >/dev/null; then +if (( $+commands[brew] )); then path=( /usr/local/opt/coreutils/libexec/gnubin /usr/local/sbin @@ -13,5 +12,6 @@ fi path=(/usr/local/texlive/20*/bin/universal-*(N) $path) path=(~/bin ~/.bin ~/.local/bin $path) -# filter out duplicates, nonexistent directories, and . (the current directory) +# Filter out nonexistent directories, . (the current directory), and duplicate +# paths - there should be no duplicates because of -U but just to be sure. ;) path=(${(u)^path:#.}(N))