shell-history

2.0.0 • Public • Published

shell-history

Get the command history of the user's shell

Install

$ npm install shell-history

Usage

import {shellHistory, shellHistoryPath} from 'shell-history';

console.log(shellHistory());
//=> ['ava', 'echo unicorn', 'node', 'npm test', …]

console.log(shellHistoryPath());
//=> '/Users/sindresorhus/.history'

API

shellHistory()

Get an array of commands.

On Windows, unless the HISTFILE environment variable is set, this will only return commands from the current session.

shellHistoryPath()

Get the path of the file containing the shell history.

On Windows, this will return either the HISTFILE environment variable or undefined.

parseShellHistory(string)

Parse a shell history string into an array of commands.

Related

  • shell-path - Get the $PATH from the shell
  • shell-env - Get environment variables from the shell

Package Sidebar

Install

npm i shell-history

Weekly Downloads

18

Version

2.0.0

License

MIT

Unpacked Size

4.41 kB

Total Files

4

Last publish

Collaborators

  • sindresorhus