Package: envprobe
EnvprobeEnvprobe(envprobe) is a shell hook tool that helps you manage your environment variables on a per-shell basis easily.
There is no need for clunkyexportsequences or manualsource-ing of who-knows-where hand-written script files.Envprobe was originally conceived as the tool betweenshellmodulesanddirenv, but with added features such as saving your configuration on the fly.Thefull documentationis available onRead the Docs.InstallationDependenciesDownloadHookQuick user guideManaging environment variablesSaved snapshotsType-safe accessConfiguring variable handlingObtaining variable type descriptionsInstallationDependenciesEnvprobe is supplied as a no-tools-needed Python package.
The only things you need to have installed on the system are one of our supported POSIX-compliant shells and Python3.Supported shells are reasonably modern versions of Bash and Zsh.Officially supported configurationsThese are the configurations that theCIis running tests on:Operating systemRequired dependenciesShells supportedUbuntu 18.04 LTS (Bionic Beaver)Python ≥ 3.6Bash (≥ 4.4), Zsh (≥ 5.4)Ubuntu 20.04 LTS (Focal Fossa)Python ≥ 3.8Bash (≥ 5.0), Zsh (≥ 5.8)DownloadYou can download Envprobe's official releases fromPyPI.pip install envprobeFrom GitHubYou can also download Envprobe from the GitHub repository, either viagitor in a tarball form.
Download the project anywhere you please, and extract the archive.
In this example, we'll use~/envprobeas the location.git clone http://github.com/whisperity/envprobe.git ~/envprobe \
    --origin upstream --single-branch --branch master --depth 1ormkdir ~/envprobe
wget http://github.com/whisperity/envprobe/tarball/master -O envprobe.tar.gz
tar xzf envprobe.tar.gz --strip-components=1 -C ~/envprobe/HookEnvprobe applies the changes to your environment variable every time a prompt is generated in your shell.
For this to work, a hook must be set up in each shell you're using.The easiest way to do this is to add the hook script at the end of the configuration file for your respective shell.:warning: Note!If you are using other custom shell extensions, it iswell-advisedfor the best experience to load Envprobelast.ShellConfiguration file (usually)Code to addBash~/.bashrceval "$(envprobe config hook bash $$)";Zsh (stock)~/.zshrceval "$(envprobe config hook zsh $$)";Zsh (Oh My Zsh)~/.oh-my-zsh/custom/zzzzzz_envprobe.zsh(new file!)eval "$(envprobe config hook zsh $$)";Quick user guideIf Envprobe is successfullyinstalled and hooked, theep/envprobeandepc/envprobe-configconveniencefunctionswill be defined in the current shell.
If you see something like below, the tool is good to go.$ ep
usage: envprobe [-h] ...The following guide will show the usage of Envprobe through a few practical examples.For a complete overview on the commands available and their usage, you can always callep -h(orep get -h, etc. for each subcommand) to get a quick help.
Thecomplete documentationfor the user-facing commands is available behind the link.Managing environment variablesFor easy access, the environment variable managing commands are also offered as shortcuts.CommandShortcutUsageget VARIABLE?VARIABLE, or simplyVARIABLEPrint the value ofVARIABLE.set VARIABLE VALUE!VARIABLE,VARIABLE=VALUESetsVARIABLEtoVALUE.undefine VARIABLE^VARIABLEUndefineVARIABLE.add VARIABLE VALUE+VARIABLE VALUE(front),VARIABLE+ VALUE(back)Add aVALUEto an array.remove VARIABLE VALUE-VARIABLE VALUERemoveVALUEfrom an array.$ ep get USER
USER=root

$ ep USER
USER=root

$ ep PATH
PATH=/usr/local/bin:/usr/bin:/sbin:/bin

$ echo $SOME_VARIABLE
# No result, variable is not defined.
$ ep SOME_VARIABLE=MyValue
$ echo $SOME_VARIABLE
MyValue

$ ep ^SOME_VARIABLE
$ echo $SOME_VARIABLE
# No result.



$ fancy
fancy: command not found!

$ ep +PATH /opt/fancy/bin
$ fancy
Fancy tool works!

$ ep PATH
PATH=/opt/fancy/bin:/usr/local/bin:/usr/bin:/sbin:/bin

$ pwd
/root

$ ep -PATH /opt/fancy/bin
$ ep PATH+ .
$ ep PATH
PATH=/usr/local/bin:/usr/bin:/sbin:/bin:/root

$ ep +PATH ..
PATH=/:/usr/local/bin:/usr/bin:/sbin:/bin:/rootSaved snapshotsFor easy access, some of the snapshot management commands are also offered as shortcuts.CommandShortcutUsagediff [var1 var2...]% [var1 var2...]Show the difference between the current environment and the last saved one (optionally only for the variables named).save [--patch] SNAPSHOT [var1 var2...]}SNAPSHOT [-p] [var1 var2...]Save the changes (optionally of only the variables named) to the snapshot namedSNAPSHOT. If-pis given, ask for confirmation of each individual change.load [--patch] SNAPSHOT [var1 var2...]{SNAPSHOT [-p] [var1 var2...]Load the changes (optionally to only the variables names) from the snapshot namedSNAPSHOT. If-pis given, ask for confirmation of each individual change.listList the saved snapshots' names.delete SNAPSHOTDelete the snapshot namedSNAPSHOT.$ ep %
# (No output, initially the environment hasn't been changed yet.)

$ ep PATH
PATH=/usr/local/bin:/usr/bin/:/sbin:/bin

$ ep SOME_VARIABLE=foo
$ ep +PATH /tmp
$ ep -PATH /sbin
$ ep PATH+ /home/user/bin

$ ep %
(+) Added:       SOME_VARIABLE
        defined value: foo

(!) Changed:     PATH
        added:         /tmp
        added:         /home/user/bin
        removed:       /sbin

$ ep } mypath PATH
For variable 'PATH' the element '/tmp' was added.
For variable 'PATH' the element '/home/user/bin' was added.
For variable 'PATH' the element '/sbin' was removed.

$ ep } other_vars -p
New variable 'SOME_VARIABLE' with value 'foo'.
Save this change? (y/N) _



$ ep list
mypath
other_vars

$ ep delete mypath
$ ep list
other_var



$ ep load custompaths
For variable 'PATH' the element '/srv/custom/bin' will be added.

$ ep PATH
PATH=/srv/custom/bin:/tmp:/home/user/bin

$ ep { foobar -n
New variable 'FOO' will be created with value 'bar'.

$ ep FOO
FOO is not defined

$ ep { foobar -p
New variable 'FOO' will be created with value 'bar'.
Load and apply this change? (y/N) _Saved snapshotsEnvprobe offers type safety when accessing environment variables, such as prohibiting assigning a textual value to a_PIDvariable.
The type of a variable is decided based on several heuristics by default, and can beconfigured by the user.$ echo $SSH_AGENT_PID
12345

$ export SSH_AGENT_PID="invalid-value"
# The above example works, even though a "_PID" variable should only
# contain numbers.

$ ep SSH_AGENT_PID=98765
$ ep SSH_AGENT_PID="foo"
[ERROR] Failed to execute: could not convert string to number.

$ ep SSH_AGENT_PID
SSH_AGENT_PID=98765Configuring variable handlingTheenvprobe-config(orepc) command contains various subcommands that can be used to configure Envprobe's behaviour.For a complete overview on the commands available and their usage, you can always callepc -h(orepc track -h, etc. for each subcommand) to get a quick help.
Thecomplete documentationfor the user-facing commands is available behind the link.CommandUsagehook ...Generate theShell hookthat allows Envprobe to interface with the environment.set VARIABLE ...Set additional information, such as adescription, for a variable.track VARIABLEConfigure whether changes to aVARIABLEshould be managed insaved snapshots.descriptions updateDownload thevariable descriptionsto use locally.Obtaining variable type descriptionsEnvprobe is managed with a sister project, theEnvprobe Variable Descriptions Knowledge Basewhich contains a curated list of environment variable descriptions and types.
This database is used together with other heuristics to provide type-safe access to variables.
The description of a variable, when queried, may come from a local copy of this database too.Read more about this feature.To initially download, or subsequently update, the description database, execute:epc descriptions update