{"id":16405579,"url":"https://github.com/danasilver/zsh-history","last_synced_at":"2025-10-26T17:31:34.264Z","repository":{"id":57406683,"uuid":"66171064","full_name":"danasilver/zsh-history","owner":"danasilver","description":"Read and parse your complete zsh history.","archived":false,"fork":false,"pushed_at":"2017-10-14T02:04:04.000Z","size":12,"stargazers_count":7,"open_issues_count":3,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-31T21:52:56.075Z","etag":null,"topics":["zsh"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/danasilver.png","metadata":{"files":{"readme":"README.md","changelog":"history.sh","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-08-20T22:40:21.000Z","updated_at":"2023-12-29T19:45:25.000Z","dependencies_parsed_at":"2022-09-05T07:31:42.995Z","dependency_job_id":null,"html_url":"https://github.com/danasilver/zsh-history","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danasilver%2Fzsh-history","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danasilver%2Fzsh-history/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danasilver%2Fzsh-history/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danasilver%2Fzsh-history/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/danasilver","download_url":"https://codeload.github.com/danasilver/zsh-history/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238375246,"owners_count":19461571,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["zsh"],"created_at":"2024-10-11T06:06:32.950Z","updated_at":"2025-10-26T17:31:33.976Z","avatar_url":"https://github.com/danasilver.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"## zsh history\n\n[![Build Status](https://travis-ci.org/danasilver/zsh-history.svg?branch=master)](https://travis-ci.org/danasilver/zsh-history)\n\nRead and parse your complete zsh history.\n\n```js\nrequire('zsh-history')().then(console.log);\n\n[\n  {\n    time: Date('2016-08-20T20:09:24.000Z'),\n    executionTime: 2,\n    command: 'sleep',\n    arguments: [ '2' ]\n  },\n\n  // many more commands\n]\n```\n\n### API\n\n#### #history([histFile])\n\nParse a [zsh history](http://zsh.sourceforge.net/Guide/zshguide02.html#l16)\nfile, defaulting to `~/.zsh_history`. Pass a path to a different history file\nif that's not where your history lives.\n\nReturns a Promise resolving to an array of commands, or throwing an error if\nthere was an issue parsing the file.\n\n### Input-Output Correspondence\n\n#### zsh History Format\n\n```\n: 1471766804:3;git push origin master\n```\n\n* `1471766804`: The time the command was executed in seconds from the\n  [Unix Epoch](https://en.wikipedia.org/wiki/Unix_time).\n* `3`: The execution time of the command in seconds.\n* `git push origin master`: The full command executed and its arguments.\n\n#### JavaScript Parsed Command\n\nEach command (in the array of commands promised) has four parts:\n\n```js\n{\n  time: Date('2016-08-20T20:09:24.000Z'),\n  executionTime: 2,\n  command: 'sleep',\n  arguments: [ '2' ]\n}\n```\n\n* `time`: An instance of `Date`. The date and time the command was executed with\n  second resolution.\n* `executionTime`: The execution time of the command in seconds.\n* `command`: The command executed. Just the first space-separated word from the\n  full command.\n* `arguments`: An array of arguments passed to the command, split with\n  [argv-split](https://www.npmjs.com/package/argv-split).\n\n### Example\n\nRead the default `zsh-history` and log the result.\n\n```js\nrequire('zsh-history')().then(console.log);\n\n[\n  {\n    time: Date('2016-08-20T20:09:24.000Z'),\n    executionTime: 2,\n    command: 'sleep',\n    arguments: [ '2' ]\n  },\n\n  // many more commands\n]\n```\n\n### Notes on Execution Time\n\nYou might see all `0`s for execution time, even when commands (like `sleep 1`)\ndon't execute instantaneously.\n\nThis likely means you are using the `INC_APPEND_HISTORY` and `SHARE_HISTORY`\noptions, both of which are\n[oh-my-zsh defaults](https://github.com/robbyrussell/oh-my-zsh/blob/83cf8dc16f51babbb0193c5b97e568739c1f40de/lib/history.zsh#L23-L24).\n\nThese options write history to `~/.zsh_history` before the command finishes\nexecuting so it can be immediately shared with other shell instances. A side\neffect is all zero execution times, since zsh has written down the command\nbefore it finishes.\n\nConfusingly, `history` will report non-zero times for commands that took greater\nthan zero seconds in your current shell. zsh maintains an internal history for\nthe current shell, which `history` (aliased to `fc -l 1`) merges with\n`~/.zsh_history`. The internal history contains accurate execution times\nregardless of settings.\n\nTo write execution time to history, the following zsh options must be set:\n\n```zsh\nunsetopt SHARE_HISTORY\nunsetopt APPEND_HISTORY\nunsetopt INC_APPEND_HISTORY\n\nsetopt EXTENDED_HISTORY\nsetopt INC_APPEND_HISTORY_TIME\n```\n\nzsh has much more documentation on its\n[history options](http://zsh.sourceforge.net/Doc/Release/Options.html#History).\n\n#### Share History Without `SHARE_HISTORY`\n\nTo share history between shells with `SHARE_HISTORY` off, you may can to\n`alias history=\"fc -R \u0026\u0026 fc -l 1\"`, which will reload the history file when you\nrun `history`.\n\nRetrieving a session's own history (ex. up arrow) will always work as expected.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanasilver%2Fzsh-history","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdanasilver%2Fzsh-history","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanasilver%2Fzsh-history/lists"}