# General utilities Below you can find a list of general purpose utilities. ## `spaceship::exists` ``` title="Signature" spaceship::exists ``` This command validates that given program is available for execution. It checks for PATH binaries, functions, and builtins. It returns zero exit code if a `command` exists and non-zero code otherwise. You can use this utility to check if some program is installed and perform actions conditionally. For example, you can either return an error and exit or continue script's execution. For example: ```zsh # Check multiple commands for existing if spaceship::exists nvm; then # extract nvm version elif spaceship::exists node; then # extract node version else return fi # Do nothing if docker is not installed spaceship::exists docker || return ``` ## `spaceship::defined` ``` title="Signature" spaceship::defined ``` The same as [`spaceship::exists`](#spaceshipexists), but for functions. It returns zero exit code if a `function` has been defined previously and non-zero if `function` hasn't. You can use this utility to check if a user has previously defined a function or not. For example: ```zsh # Check if section has been defined if spaceship::defined spaceship_section; then spaceship_section else # section is not found fi ``` ## `spaceship::is_git` This utility returns zero exit code if a current working directory is a Git repository and non-zero if it's not. For example: ```zsh # Return if current directory is not a git repository spaceship::is_git || return ``` ## `spaceship::is_hg` The same as [`spaceship::is_git`](#spaceshipisgit), but for Mercurial repositories. This utility returns zero exit code if a current working directory is a Mercurial repository and non-zero if it's not. ```zsh # Return if current directory is not a Mercurial repository spaceship::is_hg || return ``` ## `spaceship::is_section_async` Checks if a section is asynchronous or not by checking `SPACESHIP_
_ASYNC` option. This utility returns zero exit code if a section is asynchronous and non-zero if it's not. If `SPACESHIP_PROMPT_ASYNC` is set to `false`, then all sections are considered to be synchronous. ``` title="Signature" spaceship::is_section_async
``` 1. `section` _Required_ — a section to be checked. Some sections are always synchronous, not matter what, to ensure correct work of the prompt. Those are: `user`, `dir`, `host`, `exec_time`, `async`, `line_sep`, `jobs`, `exit_code` and `char`. ## `spaceship::is_prompt_async` Checks if the prompt works in asynchronous mode or not. This utility returns zero exit code if the prompt works in asynchronous mode and non-zero if it's not. Check if `SPACESHIP_PROMPT_ASYNC` is set to `true` and [`zsh-async` is loaded](/api/environment/#asynchronous-runtime). ## `spaceship::deprecated` This utility checks if `option` variable is set and if it is, prints the `message`. The `message` supports escapes to set foreground color, background color and other visual effects. ``` title="Signature" spaceship::deprecated