Genivia / ugrep

NEW ugrep 6.5: a more powerful, ultra fast, user-friendly, compatible grep. Includes a TUI, Google-like Boolean search with AND/OR/NOT, fuzzy search, hexdumps, searches (nested) archives (zip, 7z, tar, pax, cpio), compressed files (gz, Z, bz2, lzma, xz, lz4, zstd, brotli), pdfs, docs, and more
https://ugrep.com
BSD 3-Clause "New" or "Revised" License
2.56k stars 109 forks source link

inquiry on saving the output interactive #379

Closed charulix closed 4 months ago

charulix commented 4 months ago

Question

ug -Q (interactive mode),

  1. Was wondering how do we save the output in colour to clipboard so we can paste it in words/powerpoint with the colours. or is there a html options with the coloured fonts?

^Q quit and output but do not know how to use this if it can output in colour

  1. M-$ [ ] sort by changed Is it possible to run the interactive mode with sort by changes as default. Please help to show if yes.

thank you.

genivia-inc commented 4 months ago

OK, I will try to answer:

  1. right before you quit the TUI, first type ENTER to enter "selection mode" and press A for select All, then quit. This produces the output in your terminal, which can be copy-pasted (more easily than in the TUI.)
  2. "sort by changed by default" can be specified on the command line with ug -Q --sort=changed. If you use this a lot, then perhaps define an alias such as alias uqc='ug -Q --sort-changed'.

Note that the TUI "quit & output" only outputs the selections you've made in "selection mode" with ENTER. Press ENTER to select a line and DEL to unselect.

genivia-inc commented 4 months ago

Note that the TUI output can be redirected to a clipboard tool, like so with xclip on Linux:

$ ug -Q --color=always | xclip -sel clip

On MacOS:

$ ug -Q --color=always | pbcopy

However, this may not preserve colors. Colors are ANSI escape SGR codes.

genivia-inc commented 4 months ago

On the subject of converting terminal output with ANSI escapes to HTML, this ansi2html.sh script mentioned in this article looks useful.

genivia-inc commented 4 months ago

Closing this as answered. I wish there were better tools to pass results to the clipboard, but it is what it is.