Skip to main content

Prompt Customization

Customize your shell prompt to display the active DVS application.

Overview​

When you set the DVS_ACTIVE_APP environment variable, DVS automatically adds an indicator to your shell prompt showing the active app name: (dvs:app-name).

This indicator is compatible with most shell configurations and custom prompts (OhMyZsh, Starship, etc.).

Automatic Prompt Integration​

The prompt indicator is automatically added by the DVS wrapper script (~/.config/devspaces/helpers/wrapper.sh) when:

  1. The DVS_ACTIVE_APP environment variable is set to a valid app name
  2. The DVS_PROMPT_DISABLE environment variable is not set to 1

The integration uses shell hooks to avoid breaking custom prompts:

  • Bash: Uses PROMPT_COMMAND hook
  • Zsh: Uses precmd hook via add-zsh-hook
  • Fish: Wraps the fish_prompt function

Disabling the Prompt Indicator​

To disable the automatic prompt indicator, set the DVS_PROMPT_DISABLE environment variable:

export DVS_PROMPT_DISABLE=1

To re-enable it:

unset DVS_PROMPT_DISABLE

You can also add this to your shell configuration file to make it permanent:

# In ~/.bashrc, ~/.zshrc, or ~/.config/fish/config.fish
export DVS_PROMPT_DISABLE=1

Custom Prompt Integration​

Starship​

For a more integrated experience with Starship, you can add a custom module to your ~/.config/starship.toml:

[custom.dvs]
command = "echo $DVS_ACTIVE_APP"
when = "test -n \"$DVS_ACTIVE_APP\""
format = "[$symbol($output )]($style)"
symbol = "πŸ… "
style = "bold green"

This will display the active app name with a custom symbol and styling that matches your Starship theme.

OhMyZsh​

For OhMyZsh themes, you can customize the prompt by adding to your ~/.zshrc:

# DVS app indicator for OhMyZsh
_dvs_prompt_app() {
if [ -n "$DVS_ACTIVE_APP" ]; then
echo "%F{green}(dvs:$DVS_ACTIVE_APP)%f "
fi
}

# Add to your theme's prompt (example for robbyrussell theme)
# PROMPT='$(_dvs_prompt_app)'$PROMPT

Or integrate it into a custom theme function that's called by your theme.

Other Custom Prompts​

For other custom prompt systems, you need to read the active app dynamically each time the prompt is displayed. Here are examples for different shells:

Bash:

# Function to get active app (called before each prompt)
_dvs_get_active_app() {
if [ -n "$DVS_ACTIVE_APP" ]; then
echo "(dvs:$DVS_ACTIVE_APP) "
fi
}

# Add to PROMPT_COMMAND to update prompt dynamically
PROMPT_COMMAND='DVS_APP_INDICATOR=$(_dvs_get_active_app); '"$PROMPT_COMMAND"

# Use in your prompt
PS1='$DVS_APP_INDICATOR'"$PS1"

Zsh:

# Function to get active app (called before each prompt)
_dvs_get_active_app() {
if [ -n "$DVS_ACTIVE_APP" ]; then
echo "%F{green}(dvs:$DVS_ACTIVE_APP)%f "
fi
}

# Add to precmd hook
autoload -Uz add-zsh-hook
add-zsh-hook precmd _dvs_update_prompt
_dvs_update_prompt() {
DVS_APP_INDICATOR=$(_dvs_get_active_app)
}

# Use in your prompt
PROMPT='$DVS_APP_INDICATOR'"$PROMPT"

Fish:

# Function to get active app
function _dvs_get_active_app
if test -n "$DVS_ACTIVE_APP"
echo -n "(dvs:$DVS_ACTIVE_APP) "
end
end

# Use in fish_prompt
function fish_prompt
echo -n (_dvs_get_active_app)
# ... rest of your prompt
end

Important: The DVS_ACTIVE_APP environment variable is read directly from your shell environment. The indicator updates immediately when you set or unset the variable.

Environment Variable​

DVS_PROMPT_DISABLE​

Controls whether the automatic prompt indicator is displayed.

  • Default: 0 (prompt indicator enabled)
  • Values:
    • 0 or unset: Prompt indicator is shown when an app is active
    • 1: Prompt indicator is disabled

Example:

# Disable prompt indicator
export DVS_PROMPT_DISABLE=1

# Re-enable prompt indicator
unset DVS_PROMPT_DISABLE
# or
export DVS_PROMPT_DISABLE=0

Updating the Prompt​

After setting or unsetting DVS_ACTIVE_APP, the prompt indicator updates automatically. However, if you don't see the change:

  1. Restart your shell (open a new terminal)
  2. Or reload the wrapper script:
    source ~/.config/devspaces/helpers/wrapper.sh

See Also​