|
@@ -0,0 +1,34 @@
|
|
|
+use str
|
|
|
+
|
|
|
+var ignore = [
|
|
|
+ _
|
|
|
+ PWD
|
|
|
+ SHLVL
|
|
|
+ PATH
|
|
|
+]
|
|
|
+
|
|
|
+fn apply-env {|env|
|
|
|
+ for var $env {
|
|
|
+ if (eq $var '') {
|
|
|
+ break
|
|
|
+ }
|
|
|
+
|
|
|
+ var key value = (str:split &max=2 "=" $var)
|
|
|
+ if (has-value $ignore $key) {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+
|
|
|
+ put +$key
|
|
|
+ set-env $key $value
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+# helper to set environment from programs that output a bash script to `eval`
|
|
|
+edit:add-var eval-export~ {
|
|
|
+ var script = (slurp)
|
|
|
+ var output = (env -i sh -c $script"\n/usr/bin/env -0")
|
|
|
+
|
|
|
+ var @vars = (str:split "\x00" $output)
|
|
|
+ edit:notify "Applying vars"
|
|
|
+ edit:notify (print (apply-env $vars))
|
|
|
+}
|