Changing Terminal Text Color¶
Example code¶
Use this when you want the color change only in the current tab:
Two separate things control what you see in the terminal: the prompt and the terminal text itself. They are configured differently. This page follows the provided Material for MkDocs style guidance. :contentReference[oaicite:0]{index=0}
What this changes
- Prompt color changes the shell prompt, such as
franz@Franzs-MacBook-Pro modernized-igloo % - Terminal text color changes regular text output and the cursor
- These are configured in different places
Cyberpunk color ideas¶
If you want a cyberpunk-style terminal, these color choices work well for prompt and terminal text:
| Color name | Hex |
|---|---|
| Neon Orange | #FF5F00 |
| Electric Pink | #FF2E88 |
| Hot Magenta | #FF00FF |
| Laser Purple | #A100FF |
| Neon Violet | #8A2BE2 |
| Acid Green | #A6FF00 |
| Toxic Lime | #7FFF00 |
| Neon Cyan | #00F5FF |
| Electric Blue | #00B7FF |
| Plasma Teal | #00FFC6 |
Tip
Pick one hex value and replace #FF5F00 in the examples below with that color.
Prompt color¶
The prompt is controlled by the shell. In zsh, set the PROMPT variable for the current session:
This produces output similar to:
Note
%F{208} sets the prompt color, and %f resets it at the end.
Terminal text color¶
Regular text and command output are controlled by the terminal emulator, not the shell. Send ANSI escape sequences to change them:
echo -ne '\e]10;#FF5F00\a' # default text color
echo -ne '\e]12;#FF5F00\a' # cursor color
What these escape codes do
\e]10;...sets the default foreground text color\e]12;...sets the cursor color- Support depends on the terminal emulator
Temporary changes for a single session¶
These changes apply only to the current terminal tab or session. They do not survive closing the terminal.
export PROMPT='%F{208}%n@%m %1~ %% %f'
echo -ne '\e]10;#FF5F00\a'
echo -ne '\e]12;#FF5F00\a'
To restore defaults in the same session:
Persistent configuration with ~/.zshrc¶
To apply the colors automatically for every new terminal session, add the following to your ~/.zshrc file:
# Prompt color
export PROMPT='%F{208}%n@%m %1~ %% %f'
# Terminal text and cursor color
echo -ne '\e]10;#FF5F00\a'
echo -ne '\e]12;#FF5F00\a'
Apply the changes to the current session without reopening the terminal:
To revert the persistent changes, remove or comment out those lines and reload the file again:
# export PROMPT='%F{208}%n@%m %1~ %% %f'
# echo -ne '\e]10;#FF5F00\a'
# echo -ne '\e]12;#FF5F00\a'
Then run:
Comparison¶
| Setting | Controlled by | Scope | Persistent |
|---|---|---|---|
| Prompt color | Shell (zsh) |
Current shell session | Yes, if added to ~/.zshrc |
| Terminal text color | Terminal emulator via ANSI escapes | Current terminal tab/session | Sometimes, if added to ~/.zshrc and supported |
| Cursor color | Terminal emulator via ANSI escapes | Current terminal tab/session | Sometimes, if added to ~/.zshrc and supported |
Notes¶
Terminal support
The ANSI escape sequences \e]10 and \e]12 depend on terminal emulator support. They work in macOS Terminal and iTerm2.
Alternative approach
For more control over permanent colors, use your terminal profile settings instead of shell startup files. In macOS Terminal, this is available under Preferences → Profiles.