🚀 Launch Week Day 2:Introducing Custom Tabs for Org Alerts.Learn More →
Socket
Book a DemoInstallSign in
Socket

shell-history

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

shell-history

Get the command history of the user's shell

latest
Source
npmnpm
Version
2.0.1
Version published
Maintainers
1
Created
Source

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.

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

Keywords

shell

FAQs

Package last updated on 02 Nov 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts