Skip to main content

Terminal Customizations

If you use Busly CLI often, you may want to customize your terminal to always display the currently configured transport and/or service control instance. This is especially helpful to quickly know whether you're pointing to your local or a non-production environment.

Busly Oh My Posh Custom Segment

Oh My Posh

Assuming Oh My Posh is installed and configured for your shell, you can extend your theme to display the current transport and service control instance in your prompt.

Shell Profile

Add the following to your shell profile so that Oh My Posh can populate the environment variables used by the theme segments below:

Add to the bottom of your PowerShell profile ($PROFILE):

function Set-EnvVar([bool]$originalStatus) {
$env:POSH_BUSLY_TRANSPORT_CURRENT=$(busly transport current)
$env:POSH_BUSLY_SERVICECONTROL_INSTANCE_CURRENT=$(busly servicecontrol instance current)
}
New-Alias -Name 'Set-PoshContext' -Value 'Set-EnvVar' -Scope Global -Force

Theme Configuration

Add the following segments to your Oh My Posh theme JSON:

{
"$schema": "https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/main/themes/schema.json",
"blocks": [
{
"type": "prompt",
"alignment": "left",
"segments": [
// ... your existing segments ...
{
"type": "text",
"style": "powerline",
"powerline_symbol": "\ue0b0",
"background": "#4e9a06",
"foreground": "#000000",
"template": "🚌 {{ .Env.POSH_BUSLY_TRANSPORT_CURRENT }}"
},
{
"type": "text",
"style": "powerline",
"powerline_symbol": "\ue0b0",
"background": "#3465a4",
"foreground": "#ffffff",
"template": "\uf233 {{ .Env.POSH_BUSLY_SERVICECONTROL_INSTANCE_CURRENT }}"
},
]
}
],
"final_space": true
}