Skip to content

Add copy and open-in-editor options to the command log menu#5714

Open
tmwatchanan wants to merge 5 commits into
jesseduffield:masterfrom
tmwatchanan:feature/copy-command-log-git-output
Open

Add copy and open-in-editor options to the command log menu#5714
tmwatchanan wants to merge 5 commits into
jesseduffield:masterfrom
tmwatchanan:feature/copy-command-log-git-output

Conversation

@tmwatchanan

@tmwatchanan tmwatchanan commented Jun 20, 2026

Copy link
Copy Markdown

PR Description

Git hook and push output is easy to read in lazygit's command log but difficult to copy, especially when the output spans multiple lines. Terminal selection is awkward and often picks up neighbouring panels. Related discussion: #3031, including this suggestion to open log output in $EDITOR.

This adds three entries to the command log menu (@):

  1. Copy last git output to clipboard (c)
  2. Copy all git outputs to clipboard (a)
  3. Open command log in editor (o) — writes the full log to a temp file and opens it in the configured editor.

Copy items include the lazygit action, the indented git command(s) above the block, and everything under Git output:. The editor export uses the same underlying log content, without panel chrome or copy-notification lines.

Implementation notes:

  • Parses git output blocks from the command log view buffer; copy boundaries respect real stderr (indented stack traces, multi-line tool errors) rather than treating every two-space line as log noise.
  • Uses CopyToClipboardQuiet so writing to the clipboard is not logged back into the command log stream.
  • Menu items re-evaluate disabled state while the menu is open (e.g. copy/open stay disabled until there is output).
  • Exposes LastGitOutput() and AllGitOutput() on IGuiCommon for custom commands.

Please check if the PR fulfills these requirements

  • Cheatsheets are up-to-date (run go generate ./...)
  • Code has been formatted (see here)
  • Tests have been added/updated (see here for the integration test guide)
  • Text is internationalised (see here)
  • If a new UserConfig entry was added, make sure it can be hot-reloaded (see here)
  • Docs have been updated if necessary
  • You've read through your own file changes for silly mistakes etc

Hook and push output is easy to read in lazygit but hard to reuse
elsewhere. Parse git output blocks from the command log view so copies
match what is shown, include the action and command above each block,
and avoid logging clipboard operations back into the stream.
Hook and linter output often uses leading spaces for stack traces and
continuations. Those lines are visible in the log but were dropped on
copy
because every two-space-prefixed line was treated as lazygit log noise.
…output

A non-indented error line followed by indented context matches the shape
of an action plus command, so copied git output was truncated mid-block.
Only treat the next line as a new log entry when it looks like a lazygit
command rather than any indented text.
@tmwatchanan tmwatchanan force-pushed the feature/copy-command-log-git-output branch from 38bf25b to 799deab Compare June 20, 2026 14:39
Avoids awkward multi-line terminal copy when reusing log content
elsewhere.
Evaluate menu disabled reasons when rendering and invoking so copy items
update while the menu is open. Export actions and git output without
panel
chrome, match copy-notification lines via i18n log templates, and
disable
open-in-editor until there is real log content.
@tmwatchanan tmwatchanan changed the title Copy git output from the command log to the clipboard Add copy and open-in-editor options to the command log menu Jun 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant