process-env prints the 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.
process-env can output specific or all environment variables of a process. The default environment variables are:
DBUS_SESSION_BUS_ADDRESS
DISPLAY
SSH_AUTH_SOCK
WAYLAND_DISPLAY
XDG_RUNTIME_DIR
You will need Go 1.22.
go install dbohdan.com/process-env@master
process-env is known to work on:
- FreeBSD 14
- Linux
- Windows 10
It is known to not work on:
- macOS
- NetBSD
- OpenBSD
process-env [options] (pid|process-name) [var-name ...]
Specifying one or more variable names overrides the default list.
- -a, --all — output all environment variables
- -f, --fish — output fish shell commands
- -j, --json — output JSON
- -p, --posix — output POSIX shell commands (default)
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
MIT.
See the file LICENSE
.