runit-user-services/import-env.zsh
2023-09-04 10:04:08 +02:00

11 lines
273 B
Bash

import-env() {
for source_name in $@; do
SOURCE_PID=$(pgrep $source_name | head -n 1)
if [[ -n $SOURCE_PID ]]; then break; fi
done
if [[ -z $SOURCE_PID ]]; then return 1; fi
SOURCE_ENV=("${(@ps:\000:)$(</proc/${SOURCE_PID}/environ)}")
export ${SOURCE_ENV[@]:#}
}