Skip to content

Set environment variables from a process — use desktop environment variables in remote sessions

License

Notifications You must be signed in to change notification settings

dbohdan/process-env

Repository files navigation

process-env

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

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:

  • macOS
  • NetBSD
  • OpenBSD

Usage

process-env [options] (pid|process-name) [var-name ...]

Specifying one or more variable names overrides the default list.

Options:

  • -a, --all — output all environment variables
  • -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.

About

Set environment variables from a process — use desktop environment variables in remote sessions

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published