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.bash
file and place it in the~/.triqui
folder. -
Append the following to the
~/.bash_profile
,~/.bash_login
or~/.bashrc
file, as needed.source ~/.triqui/triqui.bash
-
Add
.tri
files to the~/.triqui
folder 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_PATH
variable, allowingaclocal
to search for.m4
files there. -
ALIAS <name> = <value>
Adds
<name>
as an alias with<value>
as its expansion. -
BIN <path>
Appends
<path>
to thePATH
variable, enabling it for program search. -
-BIN <path>
Equivalent to
BIN
, but it prepends<path>
toPATH
. -
INCLUDE <path>
Appends
-I<path>
to theCPPFLAGS
variable, allowingcpp
to search for#include
files there. -
INFO <path>
Appends
<path>
to theINFOPATH
variable, allowinginfo
to search for.info
files there. -
LIB <path>
Appends
-L<path>
to theLDFLAGS
variable and<path>
to theLD_LIBRARY_PATH
one, respectively allowingld
to 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 theMANPATH
variable, allowingman
to search for pages there. -
PERL5 <path>
Appends
<path>
to thePERL5LIB
variable, allowingperl
to search for.pm
modules there. -
PKG-CONFIG <path>
Appends
<path>
to thePKG_CONFIG_PATH
variable, allowingpkg-config
to search for.pc
files there. -
USE <module>
Expresses a dependency on another
<module>
.
-
triqui ls
List all available modules in the
~/.triqui
folder. -
triqui loaded
List 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
.tri
file 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.tri
file.If the module depends on another one through a
USE
directive, 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
USE
directive, the latter's reference count will be decreased. If this was the last reference to the module, it will also be automatically unloaded. -
triqui clear
Unload 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.