NAME

webrowse - browse the given input in a local web browser, with markup

SYNOPSIS

webrowse [ -C | -Z | -N | -M ] [ -O ] [ -s | -x | -mq | -u | -c ] [ -k minutes ] [ -p | -a ] [ -i id ] [ -w | -t ] [ -rnvo ] [ -h ] [ file ]

DESCRIPTION

Webrowse can be used for convenient file or URL loading remote control of Chrome, Mozilla (eg Firefox), Netscape or Mosaic browsers (though the latter two are essentially obsolete), for textual reference HTML markup, and, for example, for interfacing a browser to news and mail readers as a hypertextual external viewer for mail messages or news articles containing HTML or containing text with embedded URLs, mail addresses and other references. See the EXAMPLES section below. Statements below about Mozilla generally apply to Netscape as well.

Simply given a file argument, webrowse will direct a browser already running on the user's display to load the given file. With Chrome and newer Mozilla, a new browser will be started if one is not already running. With Mozilla, the browser may be automatically deiconified and raised as well. The browser must be running on the same host/filesystem. If the -m option is supplied, webrowse will interpret the file as text and create and load a temporary copy of the file containing HTML markup to hyperlink the URLs, shortened URLs, FTP locations, mail addresses, header newsgroups, news article IDs, and filesystem pathnames in the text to their references. A temporary file is used to hold and load the standard input if no file argument is given. By default, the temporary files are deleted 10 minutes after they've been first loaded by the browser. This delay can be set or disabled with the -k option or WB_KEEP environment variable. If a -u or -c option is supplied, webrowse will interpret the command line argument, or the standard input if there isn't one, as a URL to browse or as an (older) Mozilla remote control command to run, respectively.

OPTIONS

-C
Use a Chrome browser. This is the default only if the WB_BROWSER environment variable contains chrom. The WB_CHROME environment variable can be set to select which browser command to use.
-Z or -N
Use a Mozilla or Netscape browser. This is the default unless the WB_BROWSER environment variable contains chrom or mosaic. The WB_MOZILLA or WB_NETSCAPE environment variable can be set to select which browser command to use.
-M
Use a Mosaic browser. This is the default only if the WB_BROWSER environment variable contains mosaic.
-O
Use the old interface of Mozilla, eg applicable for Firefox versions before 36.0. This is the default only if the WB_MOZOLD environment variable is non-empty.
-s
Tag and treat the standard input as HTML instead of text.
-x
Tag and treat the standard input as XML instead of text.
-m
Markup and load a text copy of the input (whether a file or the standard input) with heuristically identified hyperlinks to Web, FTP, mail, news and file references.
-q
Markup and load a text copy of the input (whether a file or the standard input) with quoted mail/news message lines in italic or bold, alternating by depth of nesting.
-u
Take the command line argument, or the standard input if there isn't one, as a URL to browse, instead of as a file.
-c
Take the command line argument, or the standard input if there isn't one, as a remote control command to run, instead of as a file. This works with the old interface of Mozilla only.
-k minutes
Keep (ie, don't delete) any temporary files for the given integer number of minutes. If the minutes is the string forever, then the temporary files aren't ever deleted by webrowse, under the assumption they will be cleaned up later by some other means. Once temporary files are deleted, the browser will not be able to reload or re-enter them. The default is the value of the WB_KEEP environment variable, or 10 minutes if it isn't set.
-p
Use a sleeping background shell process to delete any kept temporary files. This will fail to complete should the process be killed while sleeping, and is only recommended for short temporary file lifetimes. This method is the default unless the WB_SLEEP environment variable is set to at.
-a
Use an at(1) job to delete any kept temporary files. This method is the default only if the WB_SLEEP environment variable is set to at.
-i id
The window ID (with older Mozilla) or process ID (with Mosaic) of an existing browser to use for loading. The default is any value of the WB_ID environment variable (see for more details).
-w
Open a new browser window, off of an already running browser, for loading the input. This is the default with Chrome and newer Mozilla, and for other browsers, by default, any running browser window may be used.
-t
Open a new browser tab, inside an already running browser window, for loading the input. This doesn't work with Mosaic or very old versions of Mozilla.
-r
Don't deiconify/raise the browser window. The default for older Mozilla is to raise the window, while newer Mozilla will always raise the window and Chrome and Mosaic will never raise the window.
-n
Don't actually use the browser at all. This is useful if only what is printed is of interest.
-v
Prints the shell command to run for remote control of the browser. This doesn't work with Mosaic.
-o
Prints the input (whether a file or the standard input, or whether marked up or not), perhaps in addition to loading it into the browser. This can be used to capture the marked up version of the input for other uses.
-h
Prints a helpful usage message.

ENVIRONMENT VARIABLES

WB_BROWSER
The default browser to use, Mozilla by default, unless containing chrom or mosaic. This may be overridden by the -C, -Z, -N or -M options.
WB_CHROME
The Chrome browser command name to use, chromium-browser by default.
WB_MOZILLA or WB_NETSCAPE
The Mozilla or Netscape browser command name to use, firefox by default.
WB_MOZOLD
If non-empty, the default is to use the older interface of Mozilla or Netscape, eg applicable for Firefox versions before 36.0.
WB_TMP
The directory in which to create any temporary files for use with any browser. The default depends on the browser in use. This may be overridden by the WB_CHTMP, WB_MZTMP, WB_NSTMP or WB_MSTMP environment variables.
WB_CHTMP
The directory in which to create any temporary files for use with Chrome, $HOME/.cache/chromium, $HOME/tmp or /tmp (the first which exists) by default. This overrides WB_TMP.
WB_MZTMP or WB_NSTMP
The directory in which to create any temporary files for use with Mozilla, $HOME/.mozilla, $HOME/.netscape, $HOME/tmp or /tmp (the first which exists) by default. This overrides WB_TMP.
WB_MSTMP
The directory in which to create any temporary files for use with Mosaic, $HOME/tmp or /tmp (the first which exists) by default. This overrides WB_TMP.
WB_UMASK
webrowse uses a umask of 077 when creating temporary files, unless overriden with this.
WB_KEEP
The number of minutes to wait before deleting any temporary files, or the string forever if they're not ever to be deleted. 10 minutes is the default. This may be overridden by the -k option.
WB_SLEEP
The default method to use to delete kept temporary files, sleep by default, unless set to at. This may be overridden by the -p or -a options.
WB_ID
With older Mozilla, this can be set to the window ID of an existing browser window to specify the use of that window for loading, instead of just the first one found on the display. For example, under X Windows, xwininfo(1) or xlswins(1) can identify window IDs. xwinid(1) is a supplementary script to webrowse to conveniently interface these programs, so one can simply use the output of, eg, xwinid -i $WB_MOZILLA to set this value. With Mosaic, this can be set to the process ID of a running browser to specify the use of that browser for loading, instead of the one associated with the process ID listed in the file $HOME/.mosaicpid. This variable may be overridden by the -i option. Chrome and newer Mozilla cannot make use of this.
WB_RUNURL
If present, a Bourne-shell command to run in the background just before webrowsing a URL.
WB_PWD
The command to run to determine the current working directory, instead of the configured default command (usually pwd(1)).

EXAMPLES

Besides its usage directly from the command line, webrowse can be useful as a tool within other scripts and, creatively, as an interface between a web browser and other applications. Most usages fall into two categories. One, based on webrowse -s, is useful for sending HTML that is found outside a web context into a browser so it may be viewed properly. The other, based on webrowse -m, is useful for sending text that contains URLs, mail addresses, filesystem pathnames, etc into a browser with these items conveniently hyperlinked.

The following vi(1) macros, for your .exrc file, may be used to view the currently editted text in a browser with markup (and perhaps in a new window), or to (re)load the currently editted file into a browser from vi. The latter can facilitate HTML development with vi using a browser for WYSIWYG-like viewing of the developing HTML source. (Control characters are shown in carat-notation.)

     map _wb :w !webrowse -m
     map _wm :w !webrowse -mw^M^M
     map _ws :w !webrowse -sw^M^M
     map _wn :!webrowse -w %^M^M
     map _wl :!webrowse %^M^M
     map _ww :!webrowse -c reload^M^M

The following vim(1) one-line macro, for your .vimrc file, may be used to (re)set the editor's WB_ID environment variable to a selected Mozilla browsing window. It requires xwinid(1) to be installed and WB_MOZILLA to be defined.

     noremap _wi mp:r!xwinid -i $WB_MOZILLA<CR>0"iy$u`p
     :let $WB_ID=@i<Bar>ec $WB_ID<CR>

If you receive a mail message in HTML with mailx(1), the following configuration in your .mailrc file will allow you to view the message in your browser via mailx's pipe command.

     set cmd='webrowse -sw'

If you receive a news article containing URLs with nn(1), the following configuration in your .nn/init file will allow you to view the article with markup in your browser via nn's I command.

     map both I (
             save-full "|webrowse -mqw"
     )

FILES

$HOME/{.cache/chromium,tmp}/webrowse*, /tmp/webrowse*
Possible temporary files for markup and loading. The defaults with Chrome unless the directory is changed via WB_CHTMP, or WB_TMP.
$HOME/{.mozilla,.netscape,tmp}/webrowse*, /tmp/webrowse*
Possible temporary files for markup and loading. The defaults with Mozilla unless the directory is changed via WB_MZTMP, WB_NSTMP or WB_TMP.
$HOME/tmp/webrowse*, /tmp/webrowse*
Possible temporary files for markup and loading. The defaults with Mosaic unless the directory is changed via WB_MSTMP or WB_TMP.
$HOME/.mosaicpid
Used to determine the process ID of a Mosaic browser. Created by Mosaic.
/tmp/Mosaic.*
Created, used and kept to communicate loading information to Mosaic.

CAVEATS

The textual pattern matching used to identify URLs, shortened URLs, FTP locations, mail addresses, header newsgroups, news article IDs, and filesystem pathnames is completely heuristic and can easily misidentify items. In practice, it's quite accurate, but occasionally text is identified as an FTP location (eg, hostname:path) or a filesystem pathname when it really isn't. Webrowse is designed to err on the side of overidentifying such references, to make it most useful when browsing temporary markup. Also, if the input text is exceptionally large, the pattern matching can become prohibitively expensive to compute. In such cases as these, a different program may be used to perform the markup, with its output piped into webrowse.

Not all Netscape remote control features may work with Mozilla, too, since Mozilla's support for Netscape-style remote control wasn't fully implemented. Support ended entirely with Firefox version 36.0. See the URLs in the SEE ALSO section below for current details.

VERSION

2.0.1

AUTHOR

Steve Kinzler, steve@kinzler.com, May 96/Jan 98/Feb 15

URL

http://kinzler.com/me/webrowse/
http://www.cs.duke.edu/~des/webrowse.html

SEE ALSO

chromium-browser(1), firefox(1), mozilla(1), netscape(1), Mosaic(1), umask(1), sleep(1), at(1), xwinid(1), xwininfo(1), xlswins(1), pwd(1), kill(1), vi(1), mailx(1), nn(1), http://peter.sh/experiments/chromium-command-line-switches/, http://www.mozilla.org/unix/remote.html, http://home.netscape.com/newsref/std/x-remote.html, xdg-open(1)