Skip to content

Instantly share code, notes, and snippets.

@mniip
Created May 29, 2014 17:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mniip/7242fd613ab5617966e7 to your computer and use it in GitHub Desktop.
Save mniip/7242fd613ab5617966e7 to your computer and use it in GitHub Desktop.
#!/bin/bash
# Ever wanted to spawn a process in X from a VT?
# This little tool spawns a shell whose environment is copied from a specified PID.
# Example: ./copyenv.sh $(pidof mate-session)
# That will launch a shell with $DISPLAY, $XAUTORITY, and others set to appropriate values and thus you'll be able to spawn your process
xargs -0 -a <(cat "/proc/$1/environ";echo -n $SHELL;echo -ne "\0-i") env
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment