CLI tool to bookmark files and open them in your editor of choice. Inspired by Harpoon
- 📑 Bookmark files (with line and column) per worktree
- ⚡ Open bookmarks in your favorite editor (default: Zed)
- 🛠️ Configurable editor and arguments (JSON config)
- 🖥️ Simple CLI with add, show, and open commands
- 🧩 Zed integration via tasks
This is a small weekend project and I'm fairly new to zig. This repo is a hot mess i guess. For now it does what i need it to do. Hopefully zed gets a more comprehensive extension api that allows to do stuff like this soon. The task approach works but it is not ideal. Launching a task takes aprox 500ms, zigzag does its work in a few ms, so a native extension in zed will most certainly be more responsive.
Download a release from GitHub Releases or build from source:
zig build -Doptimize=ReleaseFast
cp zig-out/bin/zigzag /usr/local/bin/zigzag add <worktreeRootPath> <filePath> --line <line> --col <column>zigzag show <worktreeRootPath>zigzag open <worktreeRootPath> <position> --filePath <filePath> --line <line> --col <column>| Command | Description | Example |
|---|---|---|
add |
Add a bookmark for a file (optionally with line/col) | zigzag add ~/project src/main.zig --line 42 --col 7 |
show |
Show the bookmarks file for a worktree | zigzag show ~/project |
open |
Open a bookmark in your editor. If you provide filePath, line, and col and the file has a bookmark, zigzag will save your current position, so next time you open that file, you return to your last location. |
zigzag open ~/project 0 --filePath src/main.zig --line 42 --col 7 |
When you use the open command and provide a filePath, line, and col, zigzag will:
- Save your current position for that file in the bookmark.
- The next time you open that file with zigzag, you’ll be returned to your last saved location (line and column).
- This makes it easy to jump back to exactly where you left off in any bookmarked file!
Example:
zigzag open ~/project 0 --filePath src/main.zig --line 42 --col 7- This will open
src/main.zigat line 42, column 7 in your editor. - zigzag will remember this position for the next time you open this bookmark.
By default, zigzag uses Zed as the editor.
You can override this by creating a JSON config file at ~/.config/zigzag/config.json:
{
"editor": "code",
"args": "{file_path}:{row}:{column}"
}- editor: The command to launch your editor (must be in your PATH)
- args: Arguments to pass to the editor.
Use
{file_path},{row},{column}as placeholders.
Default config:
{
"editor": "zed",
"args": "{file_path}:{row}:{column}"
}Add these tasks to your .zed/tasks.json for seamless workflow:
[
{
"label": "Show bookmarks",
"command": "zigzag show $ZED_WORKTREE_ROOT"
},
{
"label": "Add bookmark",
"command": "zigzag add",
"args": ["$ZED_WORKTREE_ROOT", "$ZED_RELATIVE_FILE"]
},
{
"label": "Open bookmark 1",
"command": "zigzag open",
"args": [
"$ZED_WORKTREE_ROOT",
"0",
"--filePath $ZED_RELATIVE_FILE",
"--line $ZED_ROW",
"--col $ZED_COLUMN"
]
}
// ...add more for other bookmarks
]Then you can add keymaps for the tasks:
...
"space h e": ["task::Spawn", { "task_name": "Show bookmarks" }],
"space h a": ["task::Spawn", { "task_name": "Add bookmark" }],
"space 1": ["task::Spawn", { "task_name": "Open bookmark 1" }],
...- Bookmarks are stored per worktree for easy project-based navigation.
- Editor command is fully customizable via config.
- Supports any editor that can open files from the command line.
- Tobias Klemp @tobiasklemp
MIT
zigzag — Simple bookmarks per worktree!
