unifi prompt
About 606 words
Show the current context in your shell prompt.
Usage
unifi prompt [flags]Print the prompt segment of the current context.
The segment is built from the configuration file alone: no network call, no keychain access. It is safe to run on every prompt. When no context is selected it prints nothing and exits 0, so a prompt simply stays empty.
The format is a template with the placeholders {context}, {site}, {controller} and {account}. Without --format the command uses preferences.prompt.format from the configuration, which defaults to {context}. Separators left dangling by an empty value are trimmed.
With --check nothing is printed: the exit code is 0 when a context is selected and 1 otherwise, which is what a prompt's when condition needs.
Set it up with unifi prompt init <starship|oh-my-posh|zsh|bash|fish|powershell>.
Examples
unifi prompt
unifi prompt --format '{context} · {site}'
unifi prompt --check && echo "a context is selected"
unifi prompt init starship >> ~/.config/starship.tomlFlags
| Flag | Description |
|---|---|
--check | print nothing; exit 0 when a context is selected, 1 otherwise |
--format <string> | segment template, such as '{context} · {site}' |
Commands
unifi prompt init: Print the snippet that adds the segment to a promptunifi prompt show: Print the prompt segment of the current context
unifi prompt init
Print the snippet that adds the segment to a prompt.
Usage
unifi prompt init <starship|oh-my-posh|zsh|bash|fish|powershell> [flags]Print the snippet that adds the unifi segment to a prompt manager or a shell's own prompt. The first lines of every snippet say where it goes.
The snippet is written to standard output unchanged, so it can be appended to the file it belongs in.
Examples
unifi prompt init starship >> ~/.config/starship.toml
unifi prompt init zsh >> ~/.zshrc
unifi prompt init bash >> ~/.bashrc
unifi prompt init fish >> ~/.config/fish/config.fish
unifi prompt init oh-my-posh
unifi prompt init powershell | Out-File -Append $PROFILEFlags
| Flag | Description |
|---|---|
-y, --yes | do not ask for confirmation; accepted by every command that changes something |
unifi prompt show
Print the prompt segment of the current context.
Usage
unifi prompt show [flags]Print the prompt segment of the current context.
The segment is built from the configuration file alone: no network call, no keychain access. It is safe to run on every prompt. When no context is selected it prints nothing and exits 0, so a prompt simply stays empty.
The format is a template with the placeholders {context}, {site}, {controller} and {account}. Without --format the command uses preferences.prompt.format from the configuration, which defaults to {context}. Separators left dangling by an empty value are trimmed.
With --check nothing is printed: the exit code is 0 when a context is selected and 1 otherwise, which is what a prompt's when condition needs.
Examples
unifi prompt show
unifi prompt show --format '{context} · {site}'
unifi prompt show --context lake
unifi prompt show --check
unifi prompt show --output jsonFlags
| Flag | Description |
|---|---|
--check | print nothing; exit 0 when a context is selected, 1 otherwise |
--format <string> | segment template, such as '{context} · {site}' |
Global flags
These flags are accepted by every command.
| Flag | Description |
|---|---|
--color-scheme <string> | color scheme: auto, dark or light |
--context <string> | context to use instead of the current one |
--no-cache | ask the controller for everything instead of using cached answers |
-o, --output <string> | output format: text, wide, json, yaml (table is another name for text) |
-s, --site <string> | site to act on instead of the context's default site |
--theme <string> | theme to render with instead of the configured one |
