Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

48 lines (42 sloc) 1.139 kb
#!/bin/sh
# Sets up PATHs for the shell session that sources this file.
ROOT=$HOME/app
# update cache of PATHs
find_paths() {
find -L $ROOT -type d -name "$@" |
fgrep -v "/lib/" |
sort -u | tr '\n' ':' | sed 's/:$//'
}
cache=$HOME/.pathrc.cache
test ! -s $cache -o $ROOT -nt $cache -o $0 -nt $cache && cat > $cache <<EOF
export PATHRC_PATH=\
$HOME/bin:\
$(
echo '.pathrc: calculating $PATH ...' >&2
find_paths bin
):\
/usr/bin/vendor_perl:\
/usr/local/sbin:\
/usr/sbin:\
/sbin:\
/usr/local/bin:\
/usr/bin:\
/bin
export PATHRC_MANPATH=$(
echo '.pathrc: calculating $MANPATH ...' >&2
find_paths man
)
EOF
# remove previous application
test -n "$PATHRC_MANPATH" && MANPATH=$(echo "$MANPATH" | sed "s|$PATHRC_MANPATH:||g")
test -n "$PATHRC_PATH" && PATH=$(echo "$PATH" | sed "s|$PATHRC_PATH:||g")
# apply new PATHs from cache
. $cache
export PATH=$PATHRC_PATH:$PATH
export MANPATH=$PATHRC_MANPATH:$MANPATH
# remove duplicated entries
if uniq-path-env; then
export PATH=$(uniq-path-env "$PATH")
# NOTE: the trailing colon makes man(1) fall back to system man/ directories
export MANPATH=$(uniq-path-env "$MANPATH"):
fi
Jump to Line
Something went wrong with that request. Please try again.