Nominally Patriotic Meathead

    shell-env
    TypeScript icon, indicating that this package has built-in type declarations

    3.0.1 • Public • Published

    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

    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', ...}

    API

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

    shellEnv(shell?)

    Return a promise for the environment variables.

    shellEnv.sync(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

    Install

    npm i shell-env

    DownloadsWeekly Downloads

    10,431

    Version

    3.0.1

    License

    MIT

    Unpacked Size

    5.51 kB

    Total Files

    5

    Last publish

    Collaborators

    • avatar
    • avatar