-1

I tried

bundle --help >> temp.txt

and

bundle --help | tee temp.txt

(note bundle --help is just an example, any command could take its place)

What I hoped to see:

BUNDLE(1)                                                            BUNDLE(1)

NAME
       bundle - Ruby Dependency Management

SYNOPSIS
       bundle COMMAND [--no-color] [--verbose] [ARGS]

DESCRIPTION
       Bundler manages an application´s dependencies through its entire life
       across many machines systematically and repeatably.

       See the bundler website https://bundler.io for information on getting
       started, and Gemfile(5) for more information on the Gemfile format.

What the text file looks like:

BUNDLE(1)                                                            BUNDLE(1)

N^HNA^HAM^HME^HE
       b^Hbu^Hun^Hnd^Hdl^Hle^He - Ruby Dependency Management

S^HSY^HYN^HNO^HOP^HPS^HSI^HIS^HS
       b^Hbu^Hun^Hnd^Hdl^Hle^He COMMAND [--no-color] [--verbose] [ARGS]

D^HDE^HES^HSC^HCR^HRI^HIP^HPT^HTI^HIO^HON^HN
       Bundler manages an a^Hap^Hpp^Hpl^Hli^Hic^Hca^Hat^Hti^Hio^Hon^Hn´^H´s^Hs d^Hde^Hep^Hpe^Hen^Hnd^Hde^Hen^Hnc^Hci^Hie^Hes^Hs through its entire life
       across many machines systematically and repeatably.

       See the bundler website _^Hh_^Ht_^Ht_^Hp_^Hs_^H:_^H/_^H/_^Hb_^Hu_^Hn_^Hd_^Hl_^He_^Hr_^H._^Hi_^Ho for information on getting
       started, and Gemfile(5) for more information on the G^HGe^Hem^Hmf^Hfi^Hil^Hle^He format.

here it is in vim:

enter image description here

and in vscode:

enter image description here

stevec
  • 41,291
  • 27
  • 223
  • 311
  • Found [this](https://superuser.com/questions/9192/save-me-from-gibberish-terminal) but seems unrelated. – stevec Feb 27 '23 at 09:28
  • 1
    Just to note, the "gibberish" is `roff`-style formatting, where boldfaced text is encoded as a letter, followed by a backspace, followed by the same letter, in a "simulation" of typewriter-style overstriking to make a character darker. – chepner Feb 27 '23 at 14:03
  • @chepner thanks for letting me know, I wasn't aware of that (although I had seen .roff files in GitHub repos in the past and wondered what they were). Is there a way to sensibly remove the 'roff' stuff, such that just the text can be preserved via `>`? I tried [this](https://stackoverflow.com/a/47918586/5783745) (i.e. `bundle --help | tr -cd '\11\12\15\40-\176'` but rather than removing the roff characters it appears to swap them for an ascii one (sample looks like this `DDEESSCCRRIIPPTTIIOONN Bundler manages an aapppplliiccaattiioonnss`. – stevec Feb 27 '23 at 22:27
  • Try `bundle -no-color ...`; that might include all kinds of formatting beyond plain text, not just coloring. – chepner Feb 27 '23 at 22:29
  • @chepner I tried a bunch of things and one of them worked: `bundle --help | col -b > test.txt`. I found it in some old notes and unfortunately don't keep any other information on it. I'll put it as an answer in case it helps someone else. I'll credit your observation that the formatting is roff. Out of interest, how did you know the formatting was roff? Did you recognise it from having seen it before? Is there a way a newbie can verify the formatting used in terminal output to help with 'unformatting' it if they need to? – stevec Feb 27 '23 at 22:42
  • @chepner Or you can make it an answer if you prefer. I just want to make sure it gets preserved in case others are affected (I'm surprised I didn't find more occurrences of this in my searches) – stevec Feb 27 '23 at 22:43

1 Answers1

0

What worked for me was

bundle --help | col -b > test.txt

or use this to store it and open it in one command:

bundle --help | col -b > test.txt && open test.txt

Replace bundle --help with whatever command's output you wish to store as a text file.

Also note: as mentioned by @chepner, the 'gibberish' is known as roff formatting.

stevec
  • 41,291
  • 27
  • 223
  • 311