Terminal

A command line tool and Go library for converting arbitrary shell output (with ANSI) into beautifully rendered HTML.

$ curl -o /tmp/file.txt https://example.com/file.txt
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed

  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
  0     0    0     0    0     0      0      0 --:--:--  0:00:01 --:--:--     0
  0     0    0     0    0     0      0      0 --:--:--  0:00:01 --:--:--     0
100 36982  100 36982    0     0  15968      0  0:00:02  0:00:02 --:--:-- 15974
$ curl -o /tmp/file.txt https://example.com/file.txt
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 36982  100 36982    0     0  15968      0  0:00:02  0:00:02 --:--:-- 15974
$ rspec -c specs.rb

Randomized with seed 58515
..F...

Failures:

  1) this test should fail
     Failure/Error: expect(false).to eql(true)
       
       expected: true
            got: false
       
       (compared using eql?)
     # ./specs.rb:18:in `block (2 levels) in '

Finished in 0.00138 seconds (files took 0.11502 seconds to load)
6 examples, 1 failure

Failed examples:

rspec ./specs.rb:17 # this test should fail

Randomized with seed 58515
$ rspec -c specs.rb
 
Randomized with seed 58515
..F...
 
Failures:
 
  1) this test should fail
     Failure/Error: expect(false).to eql(true)
       
       expected: true
            got: false
       
       (compared using eql?)
     # ./specs.rb:18:in `block (2 levels) in <top (required)>'
 
Finished in 0.00138 seconds (files took 0.11502 seconds to load)
6 examples, 1 failure
 
Failed examples:
 
rspec ./specs.rb:17 # this test should fail
 
Randomized with seed 58515
$ ./print_image.sh
]1338;url=http://media.giphy.com/media/wzCVIrkDwNAuk/giphy.gif;alt=OMG
$ ./print_image.sh
OMG
$ cat pikachu.ansi
                                 .:.                   
..   .ii;,                     f.:;,                   
.,::,,i1; ti:.                :;1i;,                   
  ,:;;LCLfti:t;,              ,tCL1:                   
    ,:tCCCCLfti i,.,,,,.      iLCCC1                   
      :tfLCCCCLfi. .,,  f1i;, tCCCLi                   
      ,,;1tfLLCCLffffffftt1;L fCCCf,                   
      .:;1 :;ifCCCCCCCCCCCLLtiLCCLi                    
          ,::fCLCCCCCCCCCCCCCLLCL1,                    
         .::fCfiLLCCCCCCCCCCCCCCt:,                    
          :1LCf1tfCCCCCCCCCCLCCCi:                     
         :tLfLCCCLLLLfCCCCtf1fCL;                      
         ,fLLCCCCftftttfLCfttLCtC1tfft:                
       ,; 1LCCCCCLCCCLffCCCCCLL;i1ttf1:.               
     :t.;iifCCCCCLCCCLLCCCCLLLffLCCCCLi ;;::,.         
     :1fLLLLLLLLCCLLLCCCCCCLffLCCCCCLtiii;;, ft11i;:.  
     1CCCCCCCCCCCLLCCCCCCCCLLLCCCCLLLLLLLLLffftt1ii:Ct;
     1CCCCCCCCCCCLLLLCCCCCCCCCCCLtfCCCCCCCCCCCCCCLLffti
     :1tfLLLLLLLLLCCCCCCCCCCCLLti:LCLLLLCCCCCCCCCCCCCfi
     :t,iLLLLCCCCCCCCCCCCCCLf1i,i1CLLLfLLLLCCCCCCCCf1:i
      ,:fCCCCCCCCCCCCCCCCCCL;:ii;fCLLti1ttffLLCCCf1:1: 
      .tCCCCCCCCCCCCCCCCCCCL;;fLLCLf1:i1t,:;i1tf1;t;   
     fiLCCCCCCCCCCCCCCCCCCCLi,tffff1,:  .,:;;it t;.    
     ;LCCCCCCCCCCCCCCCCCCCCCti1t;.: ,          ..      
     tCCCCCCCCCCCCCCCCCCCCCCLiii:,:,                   
   . tCLCCCCCCCCCCCCCCCCCCCCCtt                        
  .;,ifLLLLLLLffffffLLLLLLLLL1i:,                      
  .;1fLftttii;;;::;i11ttfffLfti;:,                     
  .:iii;:: i;;;::::;itt ;i1tfffti,                     

$ cat pikachu.ansi
                                 .:.                   
..   .ii;,                     f.:;,                   
.,::,,i1; ti:.                :;1i;,                   
  ,:;;LCLfti:t;,              ,tCL1:                   
    ,:tCCCCLfti i,.,,,,.      iLCCC1                   
      :tfLCCCCLfi. .,,  f1i;, tCCCLi                   
      ,,;1tfLLCCLffffffftt1;L fCCCf,                   
      .:;1 :;ifCCCCCCCCCCCLLtiLCCLi                    
          ,::fCLCCCCCCCCCCCCCLLCL1,                    
         .::fCfiLLCCCCCCCCCCCCCCt:,                    
          :1LCf1tfCCCCCCCCCCLCCCi:                     
         :tLfLCCCLLLLfCCCCtf1fCL;                      
         ,fLLCCCCftftttfLCfttLCtC1tfft:                
       ,; 1LCCCCCLCCCLffCCCCCLL;i1ttf1:.               
     :t.;iifCCCCCLCCCLLCCCCLLLffLCCCCLi ;;::,.         
     :1fLLLLLLLLCCLLLCCCCCCLffLCCCCCLtiii;;, ft11i;:.  
     1CCCCCCCCCCCLLCCCCCCCCLLLCCCCLLLLLLLLLffftt1ii:Ct;
     1CCCCCCCCCCCLLLLCCCCCCCCCCCLtfCCCCCCCCCCCCCCLLffti
     :1tfLLLLLLLLLCCCCCCCCCCCLLti:LCLLLLCCCCCCCCCCCCCfi
     :t,iLLLLCCCCCCCCCCCCCCLf1i,i1CLLLfLLLLCCCCCCCCf1:i
      ,:fCCCCCCCCCCCCCCCCCCL;:ii;fCLLti1ttffLLCCCf1:1: 
      .tCCCCCCCCCCCCCCCCCCCL;;fLLCLf1:i1t,:;i1tf1;t;   
     fiLCCCCCCCCCCCCCCCCCCCLi,tffff1,:  .,:;;it t;.    
     ;LCCCCCCCCCCCCCCCCCCCCCti1t;.: ,          ..      
     tCCCCCCCCCCCCCCCCCCCCCCLiii:,:,                   
   . tCLCCCCCCCCCCCCCCCCCCCCCtt                        
  .;,ifLLLLLLLffffffLLLLLLLLL1i:,                      
  .;1fLftttii;;;::;i11ttfffLfti;:,                     
  .:iii;:: i;;;::::;itt ;i1tfffti,                     
# Usage
cat input.raw | terminal-to-html > out.html
# Install via Go
go get github.com/buildkite/terminal-to-html/cmd/terminal-to-html
# Download a binary
open "https://github.com/buildkite/terminal-to-html/releases"

Head to the GitHub repo to grab the code, read the docs, and contribute. Or learn more about the supported inline image formats.