Sponsored Content
Skip to content

Add a shortcut to copy the path of a folder/ file. Add a shortcut to copy the content of file. #2

Description

@lovestaco

Add keyboard shortcuts to copy (a) the path of the highlighted entry and
(b) the contents of the highlighted file to the system clipboard, without
leaving peektea.

Motivation

Today the only way to act on an entry is o (open with configured program).
A common workflow is wanting the path or the contents on the clipboard so
you can paste it into a terminal, an editor, a chat, or a command — e.g.
cd <paste>, cat <paste>, or pasting a small config/snippet somewhere.
Right now that means leaving the browser and re-typing or re-navigating.

Proposed behavior

Two new keys, following the vim "yank" mnemonic so they don't collide with
the existing bindings:

Key Action
y copy the absolute path of the highlighted entry (file or directory)
Y copy the contents of the highlighted file

Details:

  • y works on both files and directories.
  • Y on a directory is a no-op (or shows a hint like Y only works on files).
  • Y on a binary file should refuse and show a notice, consistent with how
    the preview panel already shows [binary file].
  • On success, show a brief confirmation in the hint bar, e.g.
    copied path / copied contents (N lines).

Clipboard / platform notes

peektea already routes opens differently per platform (wslview/explorer.exe
on WSL, etc.), so copy should be platform-aware too:

  • macOSpbcopy
  • Linux (Wayland)wl-copy
  • Linux (X11)xclip / xsel
  • WSLclip.exe

Alternatively, a cross-platform Go clipboard library (e.g.
github.com/atotto/clipboard) could cover most cases, with a graceful
fallback + hint when no clipboard provider is found.

Open questions

  • Should Y cap large files the way preview caps at 500 lines, or copy the
    full file regardless of size?
  • For WSL, should y copy the Linux path or the Windows path (via wslpath),
    given opens already convert to Windows paths?
  • Add these keys to the README Keys table and the -h help output.

Acceptance criteria

  • y copies the absolute path of the highlighted file or directory.
  • Y copies the contents of the highlighted file.
  • Binary files and directories are handled gracefully for Y.
  • A confirmation/error is shown in the hint bar.
  • Works on macOS, Linux (X11 + Wayland), and WSL.
  • README Keys table and peektea -h updated.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions