✩‿✩ Filter Through Command

A Redcar Editor plugin for manipulating and displaying text using shell commands

Filter Through Command supports running the current line of a document as a shell script, as well as manipulating and displaying text using several options for input and output.

Installation

Version 1.0 supports Redcar 0.8 and above, versions 1.1 and beyond support Redcar 0.12 and above only.

Redcar v0.12 and above:

gem install redcar-filter-through-command

alternately, you can install from source:

Redcar v0.8 to v0.11:

Download a build from the Downloads section and copy to ~/.redcar/plugins, or build from source:

cd ~/.redcar/plugins
git clone git://github.com/kattrali/redcar-filter-through-command.git filter_through_command
git fetch origin --tags
git checkout 1.0  # or 1.1, etc

Usage

Running the current line or selection as a shell script

Select Plugins > Filter Through Command > Evaluate Text to run the cursor line or selection as a shell script.

Evaluating a text as shell command

Filtering text through a shell script

Select Plugins > Filter Through Command > Open Speedbar... to view command filtering options. Press the Execute button or press Return in the Command field to run a shell command with the selected options. To rerun the last used filter options, select Plugins > Filter Through Command > Re-run Last Filter, or use the keyboard shortcuts.

Autocompletion is available for recently run commands, and the 10 most recent commands are available from the Command menu.

Input Options

NoneRun a command without input
Cursor LineRun a command using the text of the cursor line as input
Cursor WordRun a command with the word containing the cursor as input
DocumentRun a command with all of the text of the current document given as input
SelectionRun a command with the selected text or the cursor line text given as input

Output Options

Create new DocumentInsert output into a new document
DiscardIgnore output
Insert as TextInsert output into the current document at the cursor
Open as URLOpen the output in a web browser as a URL
Replace DocumentReplace the entire document with output
Replace SelectionReplace the selected text with output
Show as HTMLOpen the output in a new HtmlTab or in the default browser
Show as PopupOpen the output in a popup dialog under the selected text or cursor line
Show as HTML PopupOpen the output in a popup dialog formatted as HTML

Variable Substitution

Filter through Command also provides substitution variables for commonly needed text in commands. Substitutions can be further shortened to # + lower case first letter. (Scope being the exception, instead using #c.)

DOCUMENT (#d)All of the text of the current document
LINE (#l)Text of the cursor line
FILE_PATH (#f)The file path to the current document
SELECTION (#s)Text of the current selection
TEMP (#t)A new empty file, which is afterwards opened by Redcar
WORD (#w)Text of the word containing the cursor
SCOPE (#c)The current scope of the cursor

Extending this Plugin

Additional output types can be added by subclassing FilterCommand::OutputFormat and implementing the supported_types and format(text,type) methods, then including the new class in a Redcar plugin. Examples can be found in lib/filter_command/formats.

Screenshots

HTML Text before conversion to HAML

HTML Text after conversion to HAML

Converting HTML to Haml

Example of HTML output

HTML Output

Example of Popup output

Popup Output

Example of HTML Popup Output

HTML Popup

Example of Autocompletion

Autocompletion

Example of Substitution

Using Variable Substitution