Skip to content

Get the command history of the user's shell

License

Notifications You must be signed in to change notification settings

sindresorhus/shell-history

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Mar 10, 2021
9bd2fd7 · Mar 10, 2021

History

16 Commits
Mar 10, 2021
Mar 10, 2021
Mar 10, 2021
Mar 10, 2021
Mar 10, 2021
Mar 10, 2021
Mar 10, 2021
Mar 10, 2021
Mar 10, 2021
Mar 10, 2021
Mar 10, 2021

Repository files navigation

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