# BB's API In `bb`, all interaction (more or less) occurs through binding keypresses (and mouse events) to shell scripts. These shell scripts can perform external actions (like moving files around) or internal actions (like changing the directory `bb` is displaying). When a shell script runs, `bb` creates a temporary file, and scripts may write commands to this file to modify `bb`'s internal state. ## Helper Functions - `bbask [-1] [prompt [initial]]`: get user input in a standardized and customizable way and output it to `STDOUT`. - `bbcmd *`: used for modifying `bb`'s internal state (see BB Commands). - `bbconfirm [prompt]`: Display a "Is this okay? [y/N]" prompt and exit with failure if the user does not press 'y'. - `bbpause`: Display a "press any key to continue" message and wait for a keypress. - `bbpick [prompt]`: Select one of `NULL`-delimited multiple inputs and print it. - `bbtargets "$BBCMD" "$@"`: If `$BBCURSOR` is not currently among `$@` (the selected files), this script prompts the user to ask whether they want to perform an action on the selected files, or on the cursor. The result is printed as `cursor` or `selected`. - `bbunscroll`: Print text to the screen *above* the cursor instead of below it. ## Environment Variables For startup commands and key bindings, the following values are provided as environment variables: - `$@` (the list of arguments): the full paths of the selected files - `$BBCURSOR`: the full path of the file under the cursor - `$BBDEPTH`: the number of `bb` instances deep (in case you want to run a shell and have that shell print something special in the prompt) - `$BBCMD`: a file to which `bb` commands can be written (used internally) - `$BBGLOB`: the glob pattern `bb` is using to determine which files to show ## BB Internal State Commands In order to modify bb's internal state, you can call `bbcmd `, where "cmd" is one of the following commands (or a unique prefix of one): - `bind::