Metadata-Version: 2.4
Name: shist
Version: 0.1.2
Summary: TUI to pick commands from your shell history and copy them to the clipboard
Author-email: matplo <noksolp@gmail.com>
License-Expression: MIT
Project-URL: Homepage, https://github.com/matplo/shist
Project-URL: Repository, https://github.com/matplo/shist
Project-URL: Issues, https://github.com/matplo/shist/issues
Keywords: shell,history,tui,clipboard,bash,zsh
Classifier: Environment :: Console
Classifier: Environment :: Console :: Curses
Classifier: Intended Audience :: Developers
Classifier: Operating System :: MacOS
Classifier: Operating System :: POSIX
Classifier: Operating System :: POSIX :: Linux
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Utilities
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: textual>=0.60
Requires-Dist: pyperclip>=1.8
Provides-Extra: dev
Requires-Dist: pytest; extra == "dev"
Requires-Dist: pytest-asyncio; extra == "dev"
Dynamic: license-file

# shist

A small TUI for picking commands out of your shell history and copying them
to the clipboard. Targets bash primarily; zsh is supported the same way.

## How it works

- **In bash/zsh, after sourcing the shell integration** (recommended): `shist`
  is a shell function that pipes your shell's own `history` builtin into the
  tool. That's the *live*, in-memory history of the current session,
  including anything you typed that hasn't been flushed to a history file
  yet.
- **Standalone** (no shell integration, or in a shell without a `history`
  builtin): running `shist` directly reads a history file instead —
  `--file PATH`, or `$HISTFILE`, or `~/.bash_history` / `~/.zsh_history`
  depending on `--shell`/`$SHELL`. This can miss very recent commands the
  live shell hasn't written to disk yet.

## Install

```sh
pip install shist
```

Then add the shell integration to your `.bashrc` and/or `.zshrc`:

```sh
eval "$(shist --print-shell-init)"
```

Open a new shell (or `source` your rc file) and run `shist`.

## Using it

There are three panels; `Tab` cycles through them: **search** → **history**
→ **selection** → back to **search**. This keeps typing fully separate from
the single-key list commands — `c`, `d`, `-`, `[`, `]` are always literal
query text while you're in the search panel, and only act as commands once
you've tabbed into history or selection.

**Search** (active on start):
- Type to filter (fuzzy substring match); `Backspace` edits it.
- `↑`/`↓` (`Ctrl+P`/`Ctrl+N`) still browse the history list live;
  `Shift+↑`/`Shift+↓` page through it.
- `Tab` moves to the history panel.

**History panel** (browse & add):
- `↑`/`↓` move the highlight, not wrapping past either end;
  `Shift+↑`/`Shift+↓` move a page at a time.
- `c` adds the highlighted command to the selection, at the end.
- `Tab` moves to the selection panel.

**Selection panel** (the running list of what you've added, in order):
- `↑`/`↓` move the highlight, not wrapping past either end;
  `Shift+↑`/`Shift+↓` move a page at a time.
- `d` or `-` removes the highlighted entry.
- `[` / `]` move the highlighted entry earlier/later.
- `Tab` moves back to search.

**Any panel:**
- `Enter` confirms: copies the selection, newline-joined in order; with
  nothing added, copies just the highlighted history entry.
- `Esc` / `Ctrl+C` cancels without copying anything.

## Known limitations

- A custom `HISTTIMEFORMAT` in bash gets treated as part of the command text
  when reading piped `history` output — not specially parsed out.
- Plain POSIX `sh`/`dash` has no `history` builtin, so there's no live-history
  mode for it; only the standalone/file-fallback mode applies.
