bcat 0.4.0 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- data/INSTALLING +6 -1
- data/README +28 -19
- data/Rakefile +24 -1
- data/bcat.gemspec +10 -6
- data/bin/bcat +5 -2
- data/lib/bcat.rb +15 -9
- data/lib/bcat/ansi.rb +2 -1
- data/lib/bcat/server.rb +113 -0
- data/man/a2h.1 +55 -0
- data/man/bcat.1 +225 -0
- data/man/bcat.1.ronn +67 -1
- data/man/btee.1 +225 -0
- data/man/btee.1.ronn +67 -1
- data/man/index.html +195 -0
- data/test/test_bcat_ansi.rb +6 -0
- metadata +12 -8
- data/lib/bcat/kidgloves.rb +0 -149
data/INSTALLING
CHANGED
@@ -1,4 +1,9 @@
|
|
1
|
-
bcat is
|
1
|
+
bcat is known to work under MacOS X, Linux, and FreeBSD (other UNIX-like
|
2
|
+
environments with freedesktop.org integration should work fine too). Progressive
|
3
|
+
output has been tested under Safari, Firefox, Chrome, and GNOME Epiphany.
|
4
|
+
|
5
|
+
bcat is written in Ruby and requires a basic Ruby installation. Install bcat
|
6
|
+
using the gem command:
|
2
7
|
|
3
8
|
$ gem install bcat
|
4
9
|
|
data/README
CHANGED
@@ -3,37 +3,46 @@ bcat
|
|
3
3
|
git clone git://github.com/rtomayko/bcat.git
|
4
4
|
gem install bcat
|
5
5
|
|
6
|
-
bcat is a pipe to browser utility
|
7
|
-
|
6
|
+
bcat is a pipe to browser utility for use at the shell and within editors like
|
7
|
+
Vim or Emacs. It reads from standard input, or one or more files, and streams
|
8
|
+
output to a browser window:
|
8
9
|
|
9
10
|
$ echo "hi mom" |bcat
|
10
11
|
$ echo "hi mom" |bcat -t 'Important Message'
|
12
|
+
$ echo "hi mom" |bcat -b chrome
|
11
13
|
|
12
|
-
|
14
|
+
Plain text is converted to simple preformatted HTML with rudimentary support for
|
15
|
+
ANSI/VT100 escape sequences (color, background, bold, underline, etc.)
|
13
16
|
|
14
|
-
|
15
|
-
|
17
|
+
You can also pipe HTML into bcat, in which case input is written through to the
|
18
|
+
browser unmodified:
|
16
19
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
+
$ echo "<h1>hi mom</h1>" |bcat
|
21
|
+
$ echo "*hi mom*" |markdown |bcat
|
22
|
+
|
23
|
+
Output is displayed progressively as it's being read, making bcat especially
|
24
|
+
useful with build tools or even commands like tail(1) that generate output over
|
25
|
+
longer periods of time:
|
20
26
|
|
21
27
|
$ make all |bcat
|
22
28
|
$ rake test |bcat
|
23
29
|
$ tail -f /var/log/syslog |bcat
|
24
30
|
$ (while printf .; do sleep 1; done) |bcat
|
25
31
|
|
26
|
-
See the bcat(1)
|
27
|
-
|
28
|
-
bcat
|
29
|
-
environments with freedesktop.org integration should work fine too). Progressive
|
30
|
-
output has been tested under Safari, Firefox, Chrome, and GNOME Epiphany.
|
31
|
-
|
32
|
-
See the INSTALLING, COPYING, and CONTRIBUTING files for information on those
|
33
|
-
things.
|
32
|
+
See the bcat(1) EXAMPLES section for more on using bcat from the shell or within
|
33
|
+
editors like Vim:
|
34
|
+
<http://rtomayko.github.com/bcat/bcat.1.html#EXAMPLES>
|
34
35
|
|
35
|
-
bcat was inspired by
|
36
|
-
|
37
|
-
like Vim.
|
36
|
+
bcat was inspired by TextMate's HTML output capabilities and a desire to have
|
37
|
+
them at the shell and also within editors like Vim or Emacs. See:
|
38
38
|
<http://manual.macromates.com/en/commands#html_output>
|
39
39
|
<http://blog.macromates.com/2005/html-output-for-commands/>
|
40
|
+
|
41
|
+
Only a small portion of TextMate's HTML output features are currently supported,
|
42
|
+
although more will be added in the future (like hyperlinking file:line
|
43
|
+
references and injecting CSS/JavaScript).
|
44
|
+
|
45
|
+
See the INSTALLING, COPYING, and CONTRIBUTING files for more information on
|
46
|
+
those things.
|
47
|
+
|
48
|
+
Copyright (c) 2010 by Ryan Tomayko <http://tomayko.com/about>
|
data/Rakefile
CHANGED
@@ -34,7 +34,30 @@ desc 'Build the manual'
|
|
34
34
|
task :man do
|
35
35
|
ENV['RONN_MANUAL'] = "Bcat #{source_version}"
|
36
36
|
ENV['RONN_ORGANIZATION'] = "Ryan Tomayko"
|
37
|
-
sh "ronn -w -r5 man/*.ronn"
|
37
|
+
sh "ronn -stoc -w -r5 man/*.ronn"
|
38
|
+
end
|
39
|
+
|
40
|
+
desc 'Publish to github pages'
|
41
|
+
task :pages => :man do
|
42
|
+
puts '----------------------------------------------'
|
43
|
+
puts 'Rebuilding pages ...'
|
44
|
+
verbose(false) {
|
45
|
+
rm_rf 'pages'
|
46
|
+
push_url = `git remote show origin`.grep(/Push.*URL/).first[/git@.*/]
|
47
|
+
sh "
|
48
|
+
set -e
|
49
|
+
git fetch -q origin
|
50
|
+
rev=$(git rev-parse origin/gh-pages)
|
51
|
+
git clone -q -b gh-pages . pages
|
52
|
+
cd pages
|
53
|
+
git reset --hard $rev
|
54
|
+
rm -f *.html
|
55
|
+
cp -rp ../man/*.html ../man/index.* ./
|
56
|
+
git add -u *.html index.*
|
57
|
+
git commit -m 'rebuild manual'
|
58
|
+
git push #{push_url} gh-pages
|
59
|
+
", :verbose => false
|
60
|
+
}
|
38
61
|
end
|
39
62
|
|
40
63
|
file 'bcat.gemspec' => FileList['{lib,test,bin}/**','Rakefile'] do |f|
|
data/bcat.gemspec
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'bcat'
|
3
|
-
s.version = '0.
|
4
|
-
s.date = '2010-06-
|
3
|
+
s.version = '0.5.0'
|
4
|
+
s.date = '2010-06-28'
|
5
5
|
|
6
|
-
s.
|
7
|
-
s.
|
6
|
+
s.description = "pipe to browser utility"
|
7
|
+
s.summary =
|
8
8
|
"Concatenate input from standard input, or one or more files, " +
|
9
9
|
"and write progressive output to a browser."
|
10
10
|
|
@@ -26,11 +26,15 @@ Gem::Specification.new do |s|
|
|
26
26
|
lib/bcat/ansi.rb
|
27
27
|
lib/bcat/browser.rb
|
28
28
|
lib/bcat/html.rb
|
29
|
-
lib/bcat/kidgloves.rb
|
30
29
|
lib/bcat/reader.rb
|
30
|
+
lib/bcat/server.rb
|
31
|
+
man/a2h.1
|
31
32
|
man/a2h.1.ronn
|
33
|
+
man/bcat.1
|
32
34
|
man/bcat.1.ronn
|
35
|
+
man/btee.1
|
33
36
|
man/btee.1.ronn
|
37
|
+
man/index.html
|
34
38
|
test/test_bcat_a2h.rb
|
35
39
|
test/test_bcat_ansi.rb
|
36
40
|
test/test_bcat_browser.rb
|
@@ -47,7 +51,7 @@ Gem::Specification.new do |s|
|
|
47
51
|
s.extra_rdoc_files = %w[COPYING]
|
48
52
|
|
49
53
|
s.has_rdoc = true
|
50
|
-
s.homepage = "http://github.com/
|
54
|
+
s.homepage = "http://rtomayko.github.com/bcat/"
|
51
55
|
s.rdoc_options = ["--line-numbers", "--inline-source"]
|
52
56
|
s.require_paths = %w[lib]
|
53
57
|
end
|
data/bin/bcat
CHANGED
@@ -20,7 +20,7 @@ require 'optparse'
|
|
20
20
|
|
21
21
|
options = {
|
22
22
|
:Host => '127.0.0.1',
|
23
|
-
:Port =>
|
23
|
+
:Port => 0,
|
24
24
|
:format => nil,
|
25
25
|
:title => Dir.pwd,
|
26
26
|
:browser => (ENV['BCAT_BROWSER'].to_s.size > 0 ? ENV['BCAT_BROWSER'] : 'default'),
|
@@ -39,6 +39,8 @@ ARGV.options do |argv|
|
|
39
39
|
argv.on('-T', '--title=v') { |text| options[:title] = text }
|
40
40
|
argv.on('-a', '--ansi') { options[:ansi] = true }
|
41
41
|
argv.on('-d', '--debug') { options[:debug] = true }
|
42
|
+
argv.on('--host=v') { |addr| options[:Host] = addr }
|
43
|
+
argv.on('--port=v') { |port| options[:Port] = port.to_i }
|
42
44
|
argv.on_tail('--help') { exec "grep ^#/ <#{__FILE__} | cut -c4-" }
|
43
45
|
argv.parse!
|
44
46
|
end
|
@@ -56,7 +58,8 @@ pid = nil
|
|
56
58
|
begin
|
57
59
|
bcat = Bcat.new(ARGV, options)
|
58
60
|
bcat.serve! do |sock|
|
59
|
-
|
61
|
+
port = sock.addr[1]
|
62
|
+
url = "http://#{bcat[:Host]}:#{port}/#{File.basename(Dir.pwd)}"
|
60
63
|
pid = browser.open(url)
|
61
64
|
end
|
62
65
|
rescue Interrupt
|
data/lib/bcat.rb
CHANGED
@@ -2,11 +2,11 @@ require 'rack'
|
|
2
2
|
require 'bcat/reader'
|
3
3
|
require 'bcat/ansi'
|
4
4
|
require 'bcat/html'
|
5
|
-
require 'bcat/
|
5
|
+
require 'bcat/server'
|
6
6
|
require 'bcat/browser'
|
7
7
|
|
8
8
|
class Bcat
|
9
|
-
VERSION = '0.
|
9
|
+
VERSION = '0.5.0'
|
10
10
|
include Rack::Utils
|
11
11
|
|
12
12
|
attr_reader :format
|
@@ -14,12 +14,7 @@ class Bcat
|
|
14
14
|
def initialize(files=[], config={})
|
15
15
|
@config = {:Host => '127.0.0.1', :Port => 8091}.merge(config)
|
16
16
|
@reader = Bcat::Reader.new(files)
|
17
|
-
@format = @config[:format]
|
18
|
-
|
19
|
-
@filter = @reader
|
20
|
-
@filter = TeeFilter.new(@filter) if @config[:tee]
|
21
|
-
@filter = TextFilter.new(@filter) if @format == 'text'
|
22
|
-
@filter = ANSI.new(@filter) if @format == 'text' || @config[:ansi]
|
17
|
+
@format = @config[:format]
|
23
18
|
end
|
24
19
|
|
25
20
|
def [](key)
|
@@ -35,7 +30,7 @@ class Bcat
|
|
35
30
|
end
|
36
31
|
|
37
32
|
def serve!(&bk)
|
38
|
-
|
33
|
+
Bcat::Server.run to_app, @config, &bk
|
39
34
|
end
|
40
35
|
|
41
36
|
def call(env)
|
@@ -43,7 +38,18 @@ class Bcat
|
|
43
38
|
[200, {"Content-Type" => "text/html;charset=utf-8"}, self]
|
44
39
|
end
|
45
40
|
|
41
|
+
def assemble
|
42
|
+
@format = @reader.sniff if @format.nil?
|
43
|
+
|
44
|
+
@filter = @reader
|
45
|
+
@filter = TeeFilter.new(@filter) if @config[:tee]
|
46
|
+
@filter = TextFilter.new(@filter) if @format == 'text'
|
47
|
+
@filter = ANSI.new(@filter) if @format == 'text' || @config[:ansi]
|
48
|
+
end
|
49
|
+
|
46
50
|
def each
|
51
|
+
assemble
|
52
|
+
|
47
53
|
head_parser = Bcat::HeadParser.new
|
48
54
|
|
49
55
|
@filter.each do |buf|
|
data/lib/bcat/ansi.rb
CHANGED
@@ -144,7 +144,8 @@ class Bcat
|
|
144
144
|
[/\A\x08+/, lambda { |m| '' }],
|
145
145
|
|
146
146
|
# ansi escape sequences that mess with the display
|
147
|
-
[/\A\x1b\[((?:\d{1,3};?)
|
147
|
+
[/\A\x1b\[((?:\d{1,3};?)+|)m/, lambda { |m|
|
148
|
+
m = '0' if m.strip.empty?
|
148
149
|
m.chomp(';').split(';').
|
149
150
|
each { |code| yield :display, code.to_i };
|
150
151
|
'' }],
|
data/lib/bcat/server.rb
ADDED
@@ -0,0 +1,113 @@
|
|
1
|
+
require 'socket'
|
2
|
+
require 'stringio'
|
3
|
+
require 'rack/utils'
|
4
|
+
|
5
|
+
class Bcat
|
6
|
+
# Simple Rack handler based largely on Scott Chacon's kidgloves library:
|
7
|
+
# http://github.com/schacon/kidgloves
|
8
|
+
class Server
|
9
|
+
attr_accessor :app
|
10
|
+
|
11
|
+
def self.run(app, options={}, &block)
|
12
|
+
new(app, options).listen(&block)
|
13
|
+
end
|
14
|
+
|
15
|
+
def initialize(app, options={})
|
16
|
+
@app = app
|
17
|
+
@host = options[:Host] || '0.0.0.0'
|
18
|
+
@port = options[:Port] || 8089
|
19
|
+
end
|
20
|
+
|
21
|
+
def bind(host, port)
|
22
|
+
TCPServer.new(host, port)
|
23
|
+
rescue Errno::EADDRINUSE
|
24
|
+
port += 1
|
25
|
+
retry
|
26
|
+
end
|
27
|
+
|
28
|
+
def listen
|
29
|
+
server = TCPServer.new(@host, @port)
|
30
|
+
|
31
|
+
yield server if block_given?
|
32
|
+
|
33
|
+
loop do
|
34
|
+
socket = server.accept
|
35
|
+
socket.sync = true
|
36
|
+
log "#{socket.peeraddr[2]} (#{socket.peeraddr[3]})"
|
37
|
+
begin
|
38
|
+
req = {}
|
39
|
+
|
40
|
+
# parse the request line
|
41
|
+
request = socket.gets
|
42
|
+
method, path, version = request.split(" ", 3)
|
43
|
+
req["REQUEST_METHOD"] = method
|
44
|
+
info, query = path.split("?")
|
45
|
+
req["PATH_INFO"] = info
|
46
|
+
req["QUERY_STRING"] = query
|
47
|
+
|
48
|
+
# parse the headers
|
49
|
+
while (line = socket.gets)
|
50
|
+
line.strip!
|
51
|
+
break if line.size == 0
|
52
|
+
key, val = line.split(": ")
|
53
|
+
key = key.upcase.gsub('-', '_')
|
54
|
+
key = "HTTP_#{key}" if !%w[CONTENT_TYPE CONTENT_LENGTH].include?(key)
|
55
|
+
req[key] = val
|
56
|
+
end
|
57
|
+
|
58
|
+
# parse the body
|
59
|
+
body =
|
60
|
+
if len = req['CONTENT_LENGTH']
|
61
|
+
socket.read(len.to_i)
|
62
|
+
else
|
63
|
+
''
|
64
|
+
end
|
65
|
+
|
66
|
+
# process the request
|
67
|
+
process_request(req, body, socket)
|
68
|
+
ensure
|
69
|
+
socket.close if not socket.closed?
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
def log(message)
|
75
|
+
# $stderr.puts message
|
76
|
+
end
|
77
|
+
|
78
|
+
def status_message(code)
|
79
|
+
Rack::Utils::HTTP_STATUS_CODES[code]
|
80
|
+
end
|
81
|
+
|
82
|
+
def process_request(request, input_body, socket)
|
83
|
+
env = {}.replace(request)
|
84
|
+
env["HTTP_VERSION"] ||= env["SERVER_PROTOCOL"]
|
85
|
+
env["QUERY_STRING"] ||= ""
|
86
|
+
env["SCRIPT_NAME"] = ""
|
87
|
+
|
88
|
+
rack_input = StringIO.new(input_body)
|
89
|
+
rack_input.set_encoding(Encoding::BINARY) if rack_input.respond_to?(:set_encoding)
|
90
|
+
|
91
|
+
env.update(
|
92
|
+
"rack.version" => [1,0],
|
93
|
+
"rack.input" => rack_input,
|
94
|
+
"rack.errors" => $stderr,
|
95
|
+
"rack.multithread" => true,
|
96
|
+
"rack.multiprocess" => true,
|
97
|
+
"rack.run_once" => false,
|
98
|
+
"rack.url_scheme" => ["yes", "on", "1"].include?(env["HTTPS"]) ? "https" : "http"
|
99
|
+
)
|
100
|
+
status, headers, body = app.call(env)
|
101
|
+
begin
|
102
|
+
socket.write("HTTP/1.1 #{status} #{status_message(status)}\r\n")
|
103
|
+
headers.each do |k, vs|
|
104
|
+
vs.split("\n").each { |v| socket.write("#{k}: #{v}\r\n")}
|
105
|
+
end
|
106
|
+
socket.write("\r\n")
|
107
|
+
body.each { |s| socket.write(s) }
|
108
|
+
ensure
|
109
|
+
body.close if body.respond_to? :close
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|
data/man/a2h.1
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
.\" generated with Ronn/v0.6.42
|
2
|
+
.\" http://github.com/rtomayko/ronn/tree/0.6.6-36-gb67d494
|
3
|
+
.
|
4
|
+
.TH "A2H" "1" "June 2010" "Ryan Tomayko" "Bcat 0.4.0"
|
5
|
+
.
|
6
|
+
.SH "NAME"
|
7
|
+
\fBa2h\fR \- convert ANSI/VT100 escape sequences to HTML
|
8
|
+
.
|
9
|
+
.SH "SYNOPSIS"
|
10
|
+
\fBa2h\fR [\-] [\fIfile\fR\.\.\.]
|
11
|
+
.
|
12
|
+
.SH "DESCRIPTION"
|
13
|
+
The \fBa2h\fR utility reads from standard input, or one or more \fIfile\fRs, and converts ANSI/VT100 escape sequences to inline HTML\.
|
14
|
+
.
|
15
|
+
.SH "ESCAPE SEQUENCES"
|
16
|
+
The following escape sequences are supported:
|
17
|
+
.
|
18
|
+
.TP
|
19
|
+
\fB<ESC>[0m\fR
|
20
|
+
Resets all attributes / closes all HTML tags\.
|
21
|
+
.
|
22
|
+
.TP
|
23
|
+
\fB<ESC>[1m\fR=\fB<b>\fR
|
24
|
+
Bold\.
|
25
|
+
.
|
26
|
+
.TP
|
27
|
+
\fB<ESC>[4m\fR=\fB<u>\fR
|
28
|
+
Underscore\.
|
29
|
+
.
|
30
|
+
.TP
|
31
|
+
\fB<ESC>[5m\fR=\fB<blink>\fR
|
32
|
+
Blink\. Really\.
|
33
|
+
.
|
34
|
+
.TP
|
35
|
+
\fB<ESC>[8m\fR=\fB<span style=\'display:none\'>\fR
|
36
|
+
Hidden\.
|
37
|
+
.
|
38
|
+
.TP
|
39
|
+
\fB<ESC>[30\-37m\fR=\fB<span style=\'color:\fR\fIcolor\fR\fB>\fR
|
40
|
+
Foreground color\.
|
41
|
+
.
|
42
|
+
.TP
|
43
|
+
\fB<ESC>[40\-47m\fR=\fB<span style=\'background\-color:\fR\fIcolor\fR\fB>\fR
|
44
|
+
Background color\.
|
45
|
+
.
|
46
|
+
.TP
|
47
|
+
\fB<ESC>[90\-97m\fR=\fB<span style=\'color:\fR\fIcolor\fR\fB>\fR
|
48
|
+
Light foreground colors\.
|
49
|
+
.
|
50
|
+
.TP
|
51
|
+
\fB<ESC>[100\-107m\fR=\fB<span style=\'background\-color:\fR\fIcolor\fR\fB>\fR
|
52
|
+
Light background color\.
|
53
|
+
.
|
54
|
+
.SH "SEE ALSO"
|
55
|
+
ansi2html\.sh \fIhttp://code\.google\.com/p/wrdese/source/browse/trunk/b/ansi2html\.sh?r=5\fR, HTML::FromANSI \fIhttp://cpansearch\.perl\.org/src/NUFFIN/HTML\-FromANSI\-2\.03/lib/HTML/FromANSI\.pm\fR
|
data/man/bcat.1
ADDED
@@ -0,0 +1,225 @@
|
|
1
|
+
.\" generated with Ronn/v0.6.42
|
2
|
+
.\" http://github.com/rtomayko/ronn/tree/0.6.6-36-gb67d494
|
3
|
+
.
|
4
|
+
.TH "BCAT" "1" "June 2010" "Ryan Tomayko" "Bcat 0.4.0"
|
5
|
+
.
|
6
|
+
.SH "NAME"
|
7
|
+
\fBbcat\fR \- browser cat
|
8
|
+
.
|
9
|
+
.SH "SYNOPSIS"
|
10
|
+
\fBbcat\fR [\-htad] [\fIfile\fR\.\.\.]
|
11
|
+
.
|
12
|
+
.br
|
13
|
+
\fBbtee\fR [\-htad] [\fIfile\fR\.\.\.]
|
14
|
+
.
|
15
|
+
.SH "DESCRIPTION"
|
16
|
+
The \fBbcat\fR utility reads from standard input, or one or more \fIfile\fRs, and pipes output into a web browser\. \fIfile\fR may be \'\-\', in which case standard input is concatenated at that position\.
|
17
|
+
.
|
18
|
+
.P
|
19
|
+
When invoked as \fBbtee\fR, all input is written immediately to standard output in addition to being piped into the browser\.
|
20
|
+
.
|
21
|
+
.SH "OPTIONS"
|
22
|
+
\fBbcat\fR opens a simple, undecorated page with the system default web browser and immediately begins streaming input\. The following options control the browser display:
|
23
|
+
.
|
24
|
+
.TP
|
25
|
+
\fB\-b\fR, \fB\-\-browser\fR=default|firefox|safari|chrome|opera|\fIother\fR
|
26
|
+
The name of the browser application\. Defaults to the value of the \fBBCAT_BROWSER\fR environment variable, or the system default browser when no \fBBCAT_BROWSER\fR is defined\.
|
27
|
+
.
|
28
|
+
.TP
|
29
|
+
\fB\-T\fR, \fB\-\-title\fR=\fItext\fR
|
30
|
+
Use \fItext\fR as the page \fB<title>\fR\. By default, the path to the current working directory is used as the title\.
|
31
|
+
.
|
32
|
+
.TP
|
33
|
+
\fB\-a\fR, \fB\-\-ansi\fR
|
34
|
+
Turns on VT100/ANSI escape sequence conversion\. This causes all input to be piped through a2h(1), replacing ANSI escape sequences with HTML for things like bold, underline, and colors\. On by default when the input is text; use the \fB\-a\fR option to turn it on when the input is HTML\.
|
35
|
+
.
|
36
|
+
.P
|
37
|
+
By default, \fBbcat\fR attempts to detect whether input is HTML or plain text using a simple heuristic, but you can force input to be treated as one or the other with these options:
|
38
|
+
.
|
39
|
+
.TP
|
40
|
+
\fB\-t\fR, \fB\-\-text\fR
|
41
|
+
The input is non\-HTML encoded text\. All bare \fB<\fR and \fB&\fR characters are entity encoded, end\-of\-line characters are converted to \fB<br>\fR, and the entire output is wrapped in a \fB<pre>\fR\.
|
42
|
+
.
|
43
|
+
.TP
|
44
|
+
\fB\-h\fR, \fB\-\-html\fR
|
45
|
+
The input is already HTML encoded\. Under this mode, bcat passes input through to the browser mostly unmodified\. The input may be a full HTML document, or it may be an HTML fragment\. \fBbcat\fR outputs \fB<html>\fR, \fB<head>\fR, and \fB<body>\fR elements even if they are not included in the input\.
|
46
|
+
.
|
47
|
+
.P
|
48
|
+
Miscellaneous options:
|
49
|
+
.
|
50
|
+
.TP
|
51
|
+
\fB\-d\fR, \fB\-\-debug\fR
|
52
|
+
Turn on verbose debug logging to standard error\. Include this output when reporting defects if applicable\.
|
53
|
+
.
|
54
|
+
.SH "ENVIRONMENT"
|
55
|
+
.
|
56
|
+
.TP
|
57
|
+
\fBBCAT_BROWSER\fR=default|firefox|safari|chrome|opera|\fIother\fR
|
58
|
+
The name of the browser to use by default\. \fBbcat\fR maps this to an actual browser command based on the current platform\. The special value \"default\" maps to the system default browser\.
|
59
|
+
.
|
60
|
+
.TP
|
61
|
+
\fBBCAT_COMMAND\fR=\fIcommand\fR
|
62
|
+
The entire browser command line (to be executed by \fB/bin/sh\fR)\. This overrides the \fBBCAT_BROWSER\fR environment variable and makes the \fB\-\-browser\fR (\fB\-b\fR) option a no\-op\. This should only be necessary when running a browser unknown to bcat or in order to pass special arguments\.
|
63
|
+
.
|
64
|
+
.SH "EXAMPLES"
|
65
|
+
.
|
66
|
+
.SS "Basic Shell Examples"
|
67
|
+
With build tools:
|
68
|
+
.
|
69
|
+
.IP "" 4
|
70
|
+
.
|
71
|
+
.nf
|
72
|
+
|
73
|
+
make test |bcat
|
74
|
+
rake test |bcat
|
75
|
+
.
|
76
|
+
.fi
|
77
|
+
.
|
78
|
+
.IP "" 0
|
79
|
+
.
|
80
|
+
.P
|
81
|
+
As a clipboard viewer:
|
82
|
+
.
|
83
|
+
.IP "" 4
|
84
|
+
.
|
85
|
+
.nf
|
86
|
+
|
87
|
+
pbpaste |bcat
|
88
|
+
.
|
89
|
+
.fi
|
90
|
+
.
|
91
|
+
.IP "" 0
|
92
|
+
.
|
93
|
+
.P
|
94
|
+
For previewing HTML:
|
95
|
+
.
|
96
|
+
.IP "" 4
|
97
|
+
.
|
98
|
+
.nf
|
99
|
+
|
100
|
+
markdown README\.md |bcat
|
101
|
+
redcloth README\.textile |bcat
|
102
|
+
erb \-T \- template\.erb |bcat
|
103
|
+
mustache < template\.mustache |bcat
|
104
|
+
pygmentize \-Ofull,style=colorful \-f html main\.c |bcat
|
105
|
+
.
|
106
|
+
.fi
|
107
|
+
.
|
108
|
+
.IP "" 0
|
109
|
+
.
|
110
|
+
.P
|
111
|
+
As a simple man pager:
|
112
|
+
.
|
113
|
+
.IP "" 4
|
114
|
+
.
|
115
|
+
.nf
|
116
|
+
|
117
|
+
export MANPAGER=\'col \-b |bcat\'
|
118
|
+
man grep
|
119
|
+
.
|
120
|
+
.fi
|
121
|
+
.
|
122
|
+
.IP "" 0
|
123
|
+
.
|
124
|
+
.P
|
125
|
+
With git, selectively:
|
126
|
+
.
|
127
|
+
.IP "" 4
|
128
|
+
.
|
129
|
+
.nf
|
130
|
+
|
131
|
+
git log \-p \-\-color |bcat
|
132
|
+
git diff \-\-color HEAD@{5d} HEAD |bcat
|
133
|
+
.
|
134
|
+
.fi
|
135
|
+
.
|
136
|
+
.IP "" 0
|
137
|
+
.
|
138
|
+
.P
|
139
|
+
With git, as the default PAGER:
|
140
|
+
.
|
141
|
+
.IP "" 4
|
142
|
+
.
|
143
|
+
.nf
|
144
|
+
|
145
|
+
export GIT_PAGER=bcat
|
146
|
+
|
147
|
+
git log \-p
|
148
|
+
git diff HEAD@{5d} HEAD
|
149
|
+
.
|
150
|
+
.fi
|
151
|
+
.
|
152
|
+
.IP "" 0
|
153
|
+
.
|
154
|
+
.P
|
155
|
+
As a log viewer:
|
156
|
+
.
|
157
|
+
.IP "" 4
|
158
|
+
.
|
159
|
+
.nf
|
160
|
+
|
161
|
+
tail \-n 1000 \-f log/development\.log |bcat
|
162
|
+
tail \-f $RAILS_ROOT/log/development\.log
|
163
|
+
.
|
164
|
+
.fi
|
165
|
+
.
|
166
|
+
.IP "" 0
|
167
|
+
.
|
168
|
+
.P
|
169
|
+
Or, a remote log viewer:
|
170
|
+
.
|
171
|
+
.IP "" 4
|
172
|
+
.
|
173
|
+
.nf
|
174
|
+
|
175
|
+
ssh example\.org \'tail \-n 1000 \-f /var/log/syslog\' |bcat
|
176
|
+
.
|
177
|
+
.fi
|
178
|
+
.
|
179
|
+
.IP "" 0
|
180
|
+
.
|
181
|
+
.SS "Vim and vi Examples"
|
182
|
+
Preview current buffer as HTML:
|
183
|
+
.
|
184
|
+
.IP "" 4
|
185
|
+
.
|
186
|
+
.nf
|
187
|
+
|
188
|
+
:!markdown % |bcat
|
189
|
+
:!ronn \-5 \-\-pipe % |bcat
|
190
|
+
.
|
191
|
+
.fi
|
192
|
+
.
|
193
|
+
.IP "" 0
|
194
|
+
.
|
195
|
+
.P
|
196
|
+
Create keymappings:
|
197
|
+
.
|
198
|
+
.IP "" 4
|
199
|
+
.
|
200
|
+
.nf
|
201
|
+
|
202
|
+
map ,pm :!markdown % |bcat
|
203
|
+
map ,pp :!pygmentize \-Ofull,style=colorful \-f html % |bcat
|
204
|
+
.
|
205
|
+
.fi
|
206
|
+
.
|
207
|
+
.IP "" 0
|
208
|
+
.
|
209
|
+
.P
|
210
|
+
Use with \fBmakeprg\fR:
|
211
|
+
.
|
212
|
+
.IP "" 4
|
213
|
+
.
|
214
|
+
.nf
|
215
|
+
|
216
|
+
set makeprg=make\e \e\e\e|bcat
|
217
|
+
set makeprg=markdown\e %\e \e\e\e|bcat
|
218
|
+
set makeprg=testrb\e %\e \e\e\e|bcat
|
219
|
+
.
|
220
|
+
.fi
|
221
|
+
.
|
222
|
+
.IP "" 0
|
223
|
+
.
|
224
|
+
.SH "SEE ALSO"
|
225
|
+
cat(1), tee(1), open(1)
|