Edgar Gonzàlez i Pellicer, 2010-2016
triqui is a tool for bash which simplifies the management of environment
variables associated to software installed in non-standard locations (e.g.,
in user directories instead of system-wide ones).
It is based on the notion of modules, which can be individually loaded and unloaded, as well as depend on others. Reference counting ensures dependencies are loaded automatically and unloaded when it is safe to do so.
-
Download the
triqui.bashfile and place it in the~/.triquifolder. -
Append the following to the
~/.bash_profile,~/.bash_loginor~/.bashrcfile, as needed.source ~/.triqui/triqui.bash -
Add
.trifiles to the~/.triquifolder for each module.
Each .tri file in the ~/.triqui folder specifies one module.
Their format is line-based, with each line specifying one directive. Empty
lines, and those starting with a # sign are ignored. So do those that contain
an unknown directive, although after generating a warning.
The values of directives are subject to shell expansion.
-
<name> = <value>Exports the environment variable
<name>with<value>as its expansion. Since values are subject to shell expansion, the<name>can be used (as${NAME}) in other directives. -
ACLOCAL <path>Appends
<path>to theACLOCAL_PATHvariable, allowingaclocalto search for.m4files there. -
ALIAS <name> = <value>Adds
<name>as an alias with<value>as its expansion. -
BIN <path>Appends
<path>to thePATHvariable, enabling it for program search. -
-BIN <path>Equivalent to
BIN, but it prepends<path>toPATH. -
INCLUDE <path>Appends
-I<path>to theCPPFLAGSvariable, allowingcppto search for#includefiles there. -
INFO <path>Appends
<path>to theINFOPATHvariable, allowinginfoto search for.infofiles there. -
LIB <path>Appends
-L<path>to theLDFLAGSvariable and<path>to theLD_LIBRARY_PATHone, respectively allowingldto search for libraries there and those same libraries to be dynamically loaded when programs start. -
-LIB <path>Equivalent to
LIB, but it prepends<path>to the variables. -
MAN <path>Appends
<path>to theMANPATHvariable, allowingmanto search for pages there. -
PERL5 <path>Appends
<path>to thePERL5LIBvariable, allowingperlto search for.pmmodules there. -
PKG-CONFIG <path>Appends
<path>to thePKG_CONFIG_PATHvariable, allowingpkg-configto search for.pcfiles there. -
USE <module>Expresses a dependency on another
<module>.
-
triqui lsList all available modules in the
~/.triquifolder. -
triqui loadedList all currently loaded modules.
-
triqui info <module>Displays information about
<module>. In particular, prints the different directives in a readable way.Note this is intended for human consumption. For automated processing, the raw
.trifile is probably more convenient. -
triqui load <module>Loads
<module>. This applies the changes to the different environment variables as determined by the directives in the.trifile.If the module depends on another one through a
USEdirective, the latter's reference count will be increased. If this was the first reference to the module, it will also be automatically loaded. -
triqui unload <module>Unload
<module>. This undoes the changes to the variables that were done bytriqui load.Note that this happens in a best-effort manner: the old values of the variables are not preserved when module loading happens, and instead they are reconstructed based on their current ones.
If the module depends on another one though a
USEdirective, the latter's reference count will be decreased. If this was the last reference to the module, it will also be automatically unloaded. -
triqui clearUnload all currently loaded modules.
If the ~/.triqui/autoload file exists, it is interpreted as containing one
module name per line. These modules are automatically loaded when
triqui.bash is sourced.