# 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 - `bb`: used for modifying `bb`'s internal state (see BB Commands). - `ask`: get user input in a standardized and customizable way. The first argument is a variable where the value is stored. The second argument is a prompt. A third optional argument can provide a default value (may be ignored). - `ask1`: get a single character of user input. The first argument is a variable where the input will be stored and the second argument is a prompt. - `pause`: Display a "press any key to continue" message and wait for a keypress. - `confirm`: Display a "Is this okay? [y/N]" prompt and exit with failure if the user does not press 'y'. - `spin`: Display a spinning icon while a slow command executes in the background. (e.g. `spin sleep 5`). ## 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::