Find file
ff9f7fc Apr 26, 2015
@mattfoster @ryanfb
100 lines (86 sloc) 2.5 KB
# Set up path variables
# Note: it doesn't matter if directories in the lists don't exist, as they
# won't be added to the path unless they do.
local pathdirs mandirs funcdirs helpdirs
# Create a list of directories to add to the path
# gnubin contains coreutils without the g prefix
# Query the gem configuration to get the correct path
# XXX: This might cause problems if you alias 'gem' to something else after the path has been setup.
if [[ -x $(which gem) ]]; then
# 's.:.' creates an array by splitting on ':'.
gemdirs=(${(s.:.)"$(gem environment gempath)"})
# The paths above don't end with /bin.
for dir ($gemdirs) { pathdirs=($pathdirs "$dir/bin") }
# Add directories which exist to the path
for dir ($pathdirs) {
if [[ -d $dir ]]; then
path=($dir $path)
# Allow Homebrew/MacPorts man pages and others
# gnuman contains manpages for coreutils without the g prefix
# Add directories which exist to the manpath
for dir ($mandirs) {
if [[ -x $dir ]]; then
manpath=($manpath $dir)
# Add function paths
local binary=$(which zsh)
local install_path=$binary:h:h # Strip bin/zsh to find installation path.
# Add existing function directories to the fpath
for dir ($funcdirs) {
if [[ -x $dir ]]; then
fpath=($fpath $dir)
# Directories for run-help: see 03_help.
for dir ($helpdirs) {
if [[ -x $dir ]]; then
helpdir=($fpath $dir)
typeset -gU path cdpath manpath fpath helpdir
# vim: set syn=zsh: