Starship Prompt Builder

Hostname module

Show the machine hostname, optionally only for SSH sessions, with aliases and domain trimming.

When it appears

It appears over SSH by default. Set ssh_only to false to show it in local shells as well.

Preview

Rendered from the starting configuration in a representative simulated environment.

starship — preview
🌐 laptop 

Starting configuration

[hostname]
ssh_only = false
trim_at = "."
format = "[$ssh_symbol$hostname]($style) "
style = "bold green"
Open in the builder

The configuration is compressed into the URL fragment and stays in your browser.

Key options

formatstring
The format for the module.
ssh_onlyboolean
Only show hostname when connected to an SSH session.
ssh_symbolstring
A format string representing the symbol when connected to SSH session.
trim_atstring
String that the hostname is cut off at, after the first match. '.' will stop after the first dot. '' will disable any truncation.
stylestring
The style for the module.
aliasesobject
Translate system hostnames to something else. If trim_at is specified, only the first part will be matched and replaced.

Format variables

$ssh_symbol
The symbol to represent when connected to SSH session
$hostname
The hostname of the computer
$style
Mirrors the value of option style

Common adjustments

  • Keep ssh_only enabled if the hostname is mainly protection against editing the wrong remote.
  • Use trim_at to remove a repeated corporate or home DNS suffix.
  • Pair it with username in one optional styled group for compact user@host output.