bosh(1) | General Commands Manual | bosh(1) |
bosh - Browsable Output SHell
bosh [OPTIONS] [CONFIGURATION] [CONFIGURATION OPTIONS]
bosh takes the output of a program or script and provides a curses interface to browse that output. A particular line of that output can be selected and actions can be defined and executed and make use of the that selected line.
CONFIGURATION is the name of a bosh configuration file (see below), in which case that is loaded.
If CONFIGURATION is absent, and bosh is invoked on the end of a pipe, it will read from stdin.
Bosh now supports passing arguments to the CONFIGURATION. The arguments will be available in the standard way ($1...$9,$*,$@,etc).
Bosh can be invoked as above, or as "interpreter", meaning it can invoked from a shebang (#!) line at the top of a script. This script would just be a bosh configuration file. See bops as an example, which should have come with bosh.
Bosh configs are fairly simple. Firstly you need a line which tells bosh the actual program to execute to show it it's buffer -
It could also be a chain of commands (bash) -
Or it can spread it over multiple lines for readability with a \ (must be at the end of line!) -
do \
echo $i \
done
Or now even better, bosh supports blocks delimited by {{ and }} -
for i in *
do
echo $i
done
}}
These can be used with all options and actions.
Command line arguments given to bosh after the COMMAND parameter are available and can be used as follows -
This would allow the user to specify the format of ps when invoking bosh.
Commands can also set BOSHERR. When execution of the command finishes, bosh will exit and display the value of BOSHERR if it has been set.
then \
BOSHERR="usage: $BOSHCONF [SECTION] NAME" \
return 1 \
fi \
man $*
This will mean bosh exits immediately if no arguments are passed on the command line. Note the use of return rather than exit.
After the command option, you can specify any of the options specified above in the OPTIONS section, but without the -- prefix -
refresh=1
Basic actions are defined as -
eg:
9=kill -9 $(echo $BOSH | cut -f1 -d' ')
Or, using the preaction setting (see above) -
k=kill $PID
9=kill -9 $PID
The keys available are a-z,0-9 and enter. Bosh keys are not case sensitive, so A= is the same as a=.
$BOSH is an environment variable containing the currently selected line(s) in bosh. It is set when the action key is invoked. This is how information is passed to the actions. In the example above, the PID is extracted from the currently selected line of the ps output using cut, which can then be passed to the kill command.
For basic actions such as kill, which has no output to stdout, the above definition is sufficient. However, bosh can now intercept the output of actions and place that in the bosh window. These are defined as follows -
eg:
Assuming the preaction is used above, this action will use lsof to show in bosh a list of files that process $PID has open. In this situation, the output of the original command is lost, and replaced with the output of the action.
Alternatively an action can be defined -
In this situation, bosh is like a web browser, in that this output (lsof) will not override the current buffer, but create a new buffer - You can get then move back and forward through these buffers with the left and right arrow keys. At this stage, actions are only available in the original buffer.
The other possibility is that an action may be required that has output that isn't to be shown in the bosh window, such as other curses-based applications. So the following syntax will make bosh end curses mode when this action is invoked.
eg: If the bosh window contained a list of files, an action like this could be used to load that file in pico.
Actions can now have a prompt for user input before performing the action. The value is available to the action using the $BOSHPARAM variable.
eg: Using the ps example above, with PID preaction -
When this action is called, bosh will ask for user input with the prompt signal: . Once this has been entered, the action will run.
In addition to $BOSH , $BOSHPARAM and $BOSHERR (all explained above), the following variables available to actions -
User variables are variables to be set and used by commands and actions. They are of the form $BOSHVARx. When the command or action is run and sets a user variable, bosh will store the contents when that command or action has finished. This allows the values to be used by subsequent actions. To make use of these, you must first set the uservars to the number you need (eg: uservars=1 will give you BOSHVAR1, uservars=10 will give you BOSHVAR1 thru BOSHVAR10).
Currently bosh only supports bash as the shell that it spawns for executing the commands and actions. Support for other shells and languages will hopefully be included in the future.
Included with bosh should be a simple configuration named bops. It uses ps as the main command, and allows you to kill the selected process or view its open files (using lsof). This is where the above examples are taken from. The original inspiration for bosh was being able to kill processes easily in this manner.
To run bops, type -
This invokes bosh through the shebang at the top (assuming the path is set correctly).
Or to run it the traditional way -
The status bar contains some further information about the current configuration. It shows with exit=num the last exit value of a command run in bosh. Furthermore a R indicates that bosh is running with refresh option activated. In the status bar there will be a countdown shown if the autorefresh option is set.
Alex Sisson (alexsisson@gmail.com)
Check for updates at http://bosh.sourceforge.net
18-MAR-2008 | bosh-0.6 |