-
-
Notifications
You must be signed in to change notification settings - Fork 899
Title
Print the title, including your username and hostname
| Module type | title |
| Default order | 1 — only used by --gen-config
|
| Module source | src/modules/title/title.c |
| Detection source | — (reads FFPlatform, no per-module detection code) |
Prints a single line, user@host, on top of the module list:
user@my-pc
It has no key by default: the initial key is a single space, which hides both the key and its
separator (see Pitfalls). With display.key.type left at its default (string) and a
key such as "Title" the line becomes Title: user@my-pc.
| Platform | Implementation | Notes |
|---|---|---|
| Linux | src/common/impl/FFPlatform_unix.c |
Common code, nothing Linux-specific |
| Android | src/common/impl/FFPlatform_unix.c |
userShell is usually empty |
| FreeBSD / NetBSD / OpenBSD / DragonFly / MidnightBSD | src/common/impl/FFPlatform_unix.c |
|
| Solaris | src/common/impl/FFPlatform_unix.c |
|
| Haiku | src/common/impl/FFPlatform_unix.c |
|
| macOS | src/common/impl/FFPlatform_unix.c |
fullUserName comes from the account database |
| Windows | src/common/impl/FFPlatform_windows.c |
userShell is resolved from SHELL, then a few fallbacks |
The module itself is platform independent — it only reads the already-populated
instance.state.platform (see Implementation).
| Option | Type | Default | Description |
|---|---|---|---|
key |
string | " " |
Key text. Default is a single space, i.e. the key is hidden. |
keyColor |
color | – | Overrides display.color.keys. |
keyIcon |
string | built-in glyph | The icon printed when display.key.type includes the icon bit. Set it to any glyph you like, or to "" to print none. |
keyWidth |
integer | – | Overrides display.key.width. |
outputColor |
color | – | Overrides display.color.output. Only affects format; the default user@host uses color below. |
format |
string | – | Output format string. See Format string. |
fqdn |
boolean | false |
Print the fully qualified domain name instead of truncating at the first .. |
color.user |
color | – | Color of the user name. Falls back to display.color.title. |
color.at |
color | – | Color of the @. |
color.host |
color | – | Color of the host name. |
condition |
object | – | See Configuration. |
Notes:
-
color.*only apply to the defaultuser@hostlayout. If you setformat, use the{user-name-colored},{at-symbol-colored}and{host-name-colored}variables to get the same effect — they are the only pre-colored variables in fastfetch. - With
fqdn: falsethe host name is cut at the first., somy-pc.localprints asmy-pc.hostNamein the JSON output is not truncated. - The icon is purely cosmetic and exists only to look good in a Nerd Font; replace it or set
"keyIcon": ""to drop it. - Module options are JSON-config only. Since 2.52.0 there are no
--title-*command line flags (see Global).
Run fastfetch -h title-format for the authoritative list.
| Variable | Description |
|---|---|
{user-name} |
User name |
{host-name} |
Host name (respects fqdn) |
{home-dir} |
Home directory, as reported by the OS (usually with a trailing slash) |
{exe-path} |
Absolute path of the running fastfetch binary |
{user-shell} |
The user's login shell |
{user-name-colored} |
User name, wrapped in color.user
|
{at-symbol-colored} |
@, wrapped in color.at
|
{host-name-colored} |
Host name (respects fqdn), wrapped in color.host
|
{full-user-name} |
Full / display name from the account database |
{user-id} |
UID on Unix, SID on Windows (see Pitfalls) |
{pid} |
PID of the running fastfetch process |
{cwd} |
Current working directory with the home directory replaced by ~
|
{
"type": "Title",
"result": {
"userId": 1000,
"userName": "user",
"fullUserName": "Jane Doe",
"hostName": "my-pc.local",
"homeDir": "/home/user/",
"exePath": "/usr/local/bin/fastfetch",
"userShell": "/bin/bash",
"pid": 1234,
"cwd": "/home/user/projects/"
}
}userId is a number on Unix and a string on Windows, where it carries the SID.
Hide the key completely and print a fully qualified host name:
{ "modules": [ { "type": "title", "key": " ", "fqdn": true } ] }Colored user and host names without touching color.*:
{
"modules": [
{ "type": "title", "format": "{user-name-colored} at {host-name-colored}" }
]
}Print the title with a user-provided format string:
{ "modules": [ { "type": "title", "format": "{user-name} in {cwd} on {host-name}" } ] }user in /home/user/projects on my-pc
-
The default key is a single space, not empty.
key: " "hides the key and the separator. Settingkey: ""does the opposite of hiding: it falls back to the localized module name (Title: …). This is the same convention as every other module — see Global. -
{user-id}changes type across platforms. On Unix it is a UID (number); on Windows it is a SID string. Anything that parses the JSON output must accept both. -
A missing
fqdndoes not affect{host-name}'s JSON counterpart.result.hostNameis always the full name. -
{cwd}collapsing is prefix-based and case-sensitive. It comparescwdagainsthomeDir, which the OS reports with a trailing slash. Acwdthat equals the home directory without that slash is printed in full instead of~. On Windows the comparison is case-insensitive and the result uses a forward slash (~/sub). -
{cwd}is trimmed of trailing slashes (except for the root/), so it does not always read back asresult.cwdfrom the JSON output. -
The Title module has a side effect. It stores
fqdnintoinstance.state.titleFqdn, which the Separator module reads to size its automatic rule. If you print a separator without a title, the separator sizes itself from a non-FQDN host name. -
fqdn: trueon Windows prints the full computer name (e.g.PC.domain.local), which is usually not what users expect from a "hostname".
ffPrintTitle() (src/modules/title/title.c) has two branches:
-
Default layout. Builds three string buffers (
userNameColored,atColored,hostNameColored) with the privateappendText()helper, thenffPrintLogoAndKey()+ffStrbufWriteTo()for each part.appendText()emitsFASTFETCH_TEXT_MODIFIER_BOLTwhendisplay.brightColoris on, then\e[<color>m, then the text, then a reset. Everything ANSI-related is skipped whendisplay.pipeis set (--pipe), so the pipe output is plain text.The
@gets special treatment: it is only colored whencolor.atis non-empty, and unlike the other two parts it does not fall back todisplay.color.title. -
formatbranch. Computes a tilde-collapsedcwdfirst, then callsFF_PRINT_FORMAT_CHECKEDwith the 12 format arguments. The tilde collapse is affStrbufStartsWith(case-insensitive on Windows) againstplatform.homeDir; the leading part is replaced with~/and trailing slashes are trimmed whilelength > 1.
ffGenerateTitleJsonResult() writes nine fields straight out of instance.state.platform and
hardcodes the sid/uid split with #ifdef _WIN32.
instance.state.titleFqdn is assigned on every call, before any output, so the Separator module
sees the current value even in --structure title:separator.
{ "modules": [ { "type": "title", "key": "Title", "fqdn": true, "color": { "user": "blue", "at": "white", "host": "green" } } ] }