Get environment variables from the shell
Especially useful for Electron/NW.js apps as GUI apps on macOS doesn't inherit the environment variables defined in your dotfiles (.bashrc/.bash_profile/.zshrc/etc).
$ npm install shell-env
const shellEnv = require('shell-env');
console.log(shellEnv.sync());
//=> {TERM_PROGRAM: 'Apple_Terminal', SHELL: '/bin/zsh', ...}
console.log(shellEnv.sync('/bin/bash'));
//=> {TERM_PROGRAM: 'iTerm.app', SHELL: '/bin/zsh', ...}
Return a promise for the environment variables.
Returns the environment variables.
Type: string
Default: User default shell
Shell to read the environment variables from.
- shell-path - Get the $PATH from the shell
- fix-path - Fix the $PATH on macOS when run from a GUI app
- shell-history - Get the command history of the user's shell
MIT