runit-user-services/import-env.zsh

14 lines
325 B
Bash
Raw Normal View History

2023-08-20 15:21:42 +00:00
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
echo "import-env: No matching process for: $*"
return 1;
fi
2023-08-20 15:21:42 +00:00
SOURCE_ENV=("${(@ps:\000:)$(</proc/${SOURCE_PID}/environ)}")
export ${SOURCE_ENV[@]:#}
}