Skip to content

Instantly share code, notes, and snippets.

@dustinblackman
Last active December 26, 2018 19:31
Embed
What would you like to do?
Load env variables from ZSH for Atom
fs = require('fs')
# Import ENV from zsh config.
fs.readFile process.env.HOME+"/.zshrc", "utf8", (err, zshFile) ->
envPaths = []
for l in zshFile.split('\n')
if l.substring(0,11) is 'export PATH'
e = l.split('=').splice(-1)[0]
e = e.replace(':$PATH','').replace(/"/g,'')
if ':' in e
for x in e.split(':')
envPaths.push(x)
else
envPaths.push(e)
else if l.substring(0,6) is 'export'
e = l.replace(/export /g, '').split('=')
process.env[e[0]] = e[1]
process.env.PATH = envPaths.join(':')
console.log('Paths: '+process.env.PATH.toString())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment