Padre::Plugin::Shell::Command - The Shell Command plug-in functions
This plug-in takes shell commands from the active document and inserts the output of the command into the document.
If text is selected then the plug-in will attempt to execute the selected text. If no text is selected the the plug-in will attempt to execute the current line as a command.
"Commands" can either be valid shell commands, entire scripts (with shebang), or environment variables to be evaluated.
There are three associated menu items:
To provide additional information for the filters, various environment variables are set prior to running the filter. These environment variables are covered in the Padre::Plugin::Shell::Base documentation.
Typing `$USER` on an otherwise blank line and invoking 'Run Command' without selecting anything would insert your user-name on the next line down.
Combinations of Environment variables and commands are also possible:
$USER was last seen on `date` gsiems was last seen on Fri Oct 9 16:12:11 CDT 2009
By typing, on an otherwise blank line, `The date is:` then selecting the word `date` and invoking 'Run Command' results in the date being inserted on the next line down.
The date is: Fri Oct 9 16:12:11 CDT 2009
Typing a multi-line script, selecting the entire script and invoking 'Run Command' will run the entire selection as a shell script:
for I in 1 2 3 ; do echo " and a $I" done
and a 1 and a 2 and a 3
after the script block.
Shebangs are supported so the scripts aren't limited to shell commands/scripts.
For example, typing (and selecting) the following
#!/usr/bin/env perl print " and a $_\n" for (qw(one two three));
and invoking 'Run Command' inserts:
and a one and a two and a three
after the script block.
Running the following:
#!/bin/sh set | grep "^PE_"
Inserts something like:
PE_BASENAME=padre_test.pl PE_CONFIG_DIR=/home/gsiems/.padre PE_DEF_PROJ_DIR=/home/gsiems/projects PE_DIRECTORY=/home/gsiems PE_FILEPATH=/home/gsiems/padre_test.pl PE_INDENT_TAB=NO PE_INDENT_TAB_WIDTH=4 PE_INDENT_WIDTH=4 PE_MIMETYPE=application/x-perl
So, for instance, a user created script `mkheader` could use PE_BASENAME and PE_MIMETYPE to create an appropriate header for different file types.
Determines and returns the command is that is to be run.
Returns a menu items for the plugin.
Runs the command and performs the appropriate $action with the result.
This plug-in will not work on operating systems that do not have an appropriate shell environment (such as MS Windows).
Gregory Siems <firstname.lastname@example.org>
Copyright (C) 2009 by Gregory Siems
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.8 or, at your option, any later version of Perl 5 you may have available.