An open API service indexing awesome lists of open source software.

https://github.com/dnlvgl/stash

A terminal UI for managing shell snippets. Save, search, and execute your frequently used commands.
https://github.com/dnlvgl/stash

bun shell-scripts

Last synced: 5 months ago
JSON representation

A terminal UI for managing shell snippets. Save, search, and execute your frequently used commands.

Awesome Lists containing this project

README

          

# stash

A terminal UI for managing shell snippets. Save, search, and execute your frequently used commands.

![stash screenshot](screenshots/stash-dark-mode.png)

## Features

- Browse and search snippets with fuzzy filtering
- Copy commands to clipboard or execute directly
- Usage tracking (sorts by most used)
- Hand-editable YAML storage
- Minimal, keyboard-driven interface

## Installation

```bash
go install github.com/user/stash@latest
```

Or build from source:

```bash
git clone https://github.com/user/stash
cd stash
go build -o stash .
```

## Usage

Launch the TUI:

```bash
stash
```

Add a snippet from the command line:

```bash
stash add "docker exec -it container bash"
```

This opens the TUI with the command pre-filled so you can add a description and tags.

## Key Bindings

| Key | Action |
|-----|--------|
| `j` / `k` / `↑` / `↓` | Navigate list |
| `Enter` | Copy snippet to clipboard |
| `x` | Execute snippet |
| `a` | Add new snippet |
| `e` | Edit selected snippet |
| `d` | Delete (with confirmation) |
| `/` | Search / filter |
| `Esc` | Clear filter / cancel |
| `?` | Toggle help |
| `q` | Quit |

## Storage

Snippets are stored in `~/.config/stash/snippets.yaml`. The file is human-readable and can be edited directly:

```yaml
snippets:
- command: "docker ps -a"
description: "List all containers"
tags:
- docker
```

Only `command` is required. All other fields are optional and will be auto-populated:

```yaml
snippets:
- command: "git status"
- command: "docker ps"
description: "List running containers"
```

See `snippets.example.yaml` for more examples.

## Testing

Run all tests:

```bash
go test ./... -v
```

Run tests with race detection:

```bash
go test ./... -v -race
```

Run tests for a specific package:

```bash
go test ./internal/storage/... -v
```

### Test Coverage

| Package | What's tested |
|---------|---------------|
| `internal/model` | Snippet creation, defaults, usage tracking, YAML serialization |
| `internal/storage` | Load/save, add/update/delete, bounds checks, round-trips, edge cases |
| `internal/config` | XDG path resolution, directory creation, idempotency |
| `internal/tui` | Mode transitions, list filtering & navigation, form input & submission, detail/confirm/help rendering, key bindings, styles |
| `cmd` | Shell execution, CLI argument validation, subcommand registration |

### CI

A GitHub Actions workflow runs on every push and pull request:

- **Test** — builds the project and runs all tests with `-race`
- **Lint** — checks `gofmt` formatting and `go vet`

## Dependencies

- [Bubble Tea](https://github.com/charmbracelet/bubbletea) - TUI framework
- [Bubbles](https://github.com/charmbracelet/bubbles) - TUI components
- [Lip Gloss](https://github.com/charmbracelet/lipgloss) - Styling
- [Cobra](https://github.com/spf13/cobra) - CLI framework