My bash configuration includes the functions use
and unuse
;
the definitions of these are in use.sh.
These functions adjust several environment variables to let my current shell use programs and libraries installed in a different prefix. If I've installed a package from source with something like:
./configure --prefix=$HOME/pkg/foomatic && make install
then I just need to say:
use foomatic
and my environment will be adjusted so that I can run that piece of software and compile other programs against it. Similarly,
unuse foomatic
will remove the extra settings from the environment. It's possible to
use
several packages at once. This is very handy for testing out new
versions of packages during development — and for ad-hoc
compilation from source in a mostly-packaged environment.
(Updated in December 2015, inspired by
this Chris Siebenmann article:
use
and unuse
now support variables like PYTHONPATH
, which have a
default value if they aren't set, and need that default value to be
explicitly included in the path if they are set.)