@cjser/shell-env
v4.0.3-cjser.2
Published
Get environment variables from the shell
Maintainers
Readme
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-envUsage
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] For Bash, it reads
.bash_profile, but not.bashrc.
[!NOTE] If your default shell is a non-POSIX shell (e.g., Nushell), it will fall back to
/bin/zshor/bin/bash.
[!NOTE] It disables the oh-my-zsh tmux plugin auto-start by setting
ZSH_TMUX_AUTOSTARTEDandZSH_TMUX_AUTOSTART=falseso the shell does not launch tmux while capturing environment variables.
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
cjser
This package is a CommonJS-compatible build generated by cjser for projects that still need require() support. The source version matches the original npm package version, with a cjser prerelease suffix for this generated build.
Original repository: https://github.com/sindresorhus/shell-env
