Skip to content

sindresorhus/shell-env

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Sep 13, 2021
f0d93c5 · Sep 13, 2021

History

41 Commits
Aug 24, 2021
Dec 15, 2017
Jun 14, 2018
Dec 15, 2017
Dec 15, 2017
Aug 24, 2021
Aug 24, 2021
Aug 24, 2021
Dec 19, 2020
Sep 13, 2021
Aug 24, 2021
Aug 24, 2021

Repository files navigation

shell-env

Get environment variables from the shell

Especially useful for Electron apps as GUI apps on macOS doesn't inherit the environment variables defined in your dotfiles (.bash_profile/.zshrc/etc).

Install

$ npm install shell-env

Usage

import {shellEnv} from 'shell-env';

console.log(await shellEnv());
//=> {TERM_PROGRAM: 'Apple_Terminal', SHELL: '/bin/zsh', ...}

console.log(await shellEnv('/bin/bash'));
//=> {TERM_PROGRAM: 'iTerm.app', SHELL: '/bin/zsh', ...}

API

Note that for Bash, it reads .bash_profile, but not .bashrc.

shellEnv(shell?)

Return a promise for the environment variables.

shellEnvSync(shell?)

Returns the environment variables.

shell

Type: string
Default: User default shell

Shell to read the environment variables from.

Related

  • 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

Maintainers