Skip to content

sindresorhus/shell-path

shell-path

Get the $PATH from the shell

Useful for Electron apps as GUI apps on macOS do not inherit the $PATH defined in your dotfiles (.bashrc/.bash_profile/.zshrc/etc).

Install

npm install shell-path

Usage

When executed from a GUI app on macOS:

import {shellPath} from 'shell-path';

console.log(process.env.PATH);
//=> '/usr/bin'

console.log(await shellPath());
//=> '/usr/local/bin:/usr/bin:...'

console.log(await shellPath({shell: '/bin/bash'}));
//=> '/usr/local/bin:/usr/bin:...'

API

shellPath(options?)

Returns a promise for the $PATH.

shellPathSync(options?)

Returns the $PATH.

options

Type: object

shell

Type: string
Default: User's default shell

The shell to read environment path from.

Related

  • fix-path - Fix the $PATH on macOS when run from a GUI app
  • shell-env - Get environment variables from the shell
  • shell-history - Get the command history of the user's shell

About

Get the $PATH from the shell

Resources

License

Code of conduct

Contributing

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •