1. bcat(1)
  2. Bcat 0.5.0
  3. bcat(1)

NAME

bcat - browser cat

SYNOPSIS

bcat [-htad] [file...]
btee [-htad] [file...]

DESCRIPTION

The bcat utility reads from standard input, or one or more files, and pipes output into a web browser. file may be '-', in which case standard input is concatenated at that position.

When invoked as btee, all input is written immediately to standard output in addition to being piped into the browser.

OPTIONS

bcat opens a simple, undecorated page with the system default web browser and immediately begins streaming input. The following options control the browser display:

-b, --browser=default|firefox|safari|chrome|opera|other

The name of the browser application. Defaults to the value of the BCAT_BROWSER environment variable, or the system default browser when no BCAT_BROWSER is defined.

-T, --title=text

Use text as the page <title>. By default, the path to the current working directory is used as the title.

-a, --ansi

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 -a option to turn it on when the input is HTML.

By default, bcat 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:

-t, --text

The input is non-HTML encoded text. All bare < and & characters are entity encoded, end-of-line characters are converted to <br>, and the entire output is wrapped in a <pre>.

-h, --html

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. bcat outputs <html>, <head>, and <body> elements even if they are not included in the input.

Miscellaneous options:

-d, --debug
Turn on verbose debug logging to standard error. Include this output when reporting defects if applicable.

ENVIRONMENT

BCAT_BROWSER=default|firefox|safari|chrome|opera|other

The name of the browser to use by default. bcat maps this to an actual browser command based on the current platform. The special value "default" maps to the system default browser.

BCAT_COMMAND=command

The entire browser command line (to be executed by /bin/sh). This overrides the BCAT_BROWSER environment variable and makes the --browser (-b) option a no-op. This should only be necessary when running a browser unknown to bcat or in order to pass special arguments.

EXAMPLES

Basic Shell Examples

With build tools:

make test |bcat
rake test |bcat

As a clipboard viewer:

pbpaste  |bcat  # mac
xclip -o |bcat  # X11

For previewing HTML:

markdown README.md |bcat
redcloth README.textile |bcat
erb -T - template.erb |bcat
mustache < template.mustache |bcat
pygmentize -Ofull,style=colorful -f html main.c |bcat

As a simple man pager:

export MANPAGER='col -b |bcat'
man grep

With git, selectively:

git log -p --color |bcat
git diff --color HEAD@{5d} HEAD |bcat

With git, as the default PAGER:

export GIT_PAGER=bcat

git log -p
git diff HEAD@{5d} HEAD

As a log viewer:

tail -n 1000 -f /var/log/messages |bcat
tail -f $RAILS_ROOT/log/development.log |bcat

Or, a remote log viewer:

ssh example.org 'tail -n 1000 -f /var/log/syslog' |bcat

Vim and vi Examples

Preview current buffer as HTML:

:!markdown % |bcat
:!ronn -5 --pipe % |bcat

Create keymappings:

map ,pm :!markdown % \|bcat
map ,pp :!pygmentize -Ofull,style=colorful -f html % \|bcat

Use with makeprg:

set makeprg=make\ \\\|bcat
set makeprg=markdown\ %\ \\\|bcat
set makeprg=testrb\ %\ \\\|bcat

SEE ALSO

cat(1), tee(1), open(1)

  1. Ryan Tomayko
  2. July 2010
  3. bcat(1)