2 ms·
In my (fever) dreams, there's a directory at `/var/share/env` with the rule that regular files are <file name>=<file contents> and all other file types are igno
by duped 2y ago
In my (fever) dreams, there's a directory at `/var/share/env` with the rule that regular files are <file name>=<file contents> and all other file types are ignored. The `env` program can slurp all the files to create the default environment before applying whatever customization are in dotfiles for a shell.
Want to add to path? `echo ':<directory>' >> /var/share/env/PATH` (or `env --add PATH :<directory>`, or something like that).
- evntdrvn 2y agoyou could call it a "Registry"... ;)
- forgotpwd16 2y agoWhy not make your dreams real then? Here's a barebones zsh function. (Bash fails at export part. If remember right, in past, had wanted to set variables from subshell results and used some eval shenanigans.) function my_env() { ENVDIR=${ENVDIR:-/var/share/env} arg="$1" case "$arg" in --add) echo "$3" >> $ENVDIR/"$2" ;; *) ( for f in $ENVDIR/*; do export $(basename $f)="$(< $f | sed -z 's/\n:/:/g')" done [[ -z "$arg" ]] && env || env "$arg" ) ;; esac } (Of course, that's a bad approach but your idea is certainly doable in a good way.)