process-env
process-env prints select environment variables of a process, typically the current user's desktop session, as shell commands to set those variables or as JSON.
This is useful if you want to access an ssh-agent started for your desktop session in a remote session and in similar scenarios.
The default environment variables are as follows:
DBUS_SESSION_BUS_ADDRESS
DISPLAY
SSH_AUTH_SOCK
Installation
You will need Go 1.22.
go install dbohdan.com/process-env@master
Compatibility
process-env is known to work on:
- FreeBSD 14
- Linux
- Windows 10
It is known to not work on:
Usage
process-env [options] (pid|process-name) [var-name ...]
Options:
- -f, --fish — output fish shell commands
- -j, --json — output JSON
- -p, --posix — output POSIX shell commands (default)
Examples
Get the default environment variables from a MATE session process using POSIX syntax:
process-env mate-session
Get only the DISPLAY
environment variable from a KDE Plasma shell process using fish syntax:
process-env -f plasmashell DISPLAY
License
MIT.
See the file LICENSE
.