Customize Warp Terminal With Starship And Custom Theme

Customize Warp Terminal With Starship And Custom Theme

The following guide demonstrates how to customize warp terminal with custom starship prompt and custom theme. Let’s get started.

Prerequisite

Organizing zsh

The default .zshrc is a mess. We need to make it simpler and make configs modular with separate files and folders. In order to do that please go through this article first ~ Organize Your Zsh Configurations and Plugins.

Installing warp

The terminal for the 21st century. WARP is a blazingly fast, Rust based terminal reimagined from the ground up to work like modern app. More about warp. To install ~

command line
brew install --cask warp

Installing starship

The minimal, blazing-fast, and infinitely customizable prompt for any shell! Starship is cross platform regardless of shell. More about starship. To install ~

command line
brew install starship

Nerd font

Nerd Fonts patches developer targeted fonts with a high number of glyphs (icons). These glyps we make our prompt beautiful 😊. There are a lot of nerd fonts availabe. You can download the font you like most. For me it is Meslo. Check Nerd Fonts to download your favorite font. In this guide I am going to use MesloLG Nerd Font. Download MesloLG Nerd Font and install the font.

Warp

Let’s get started with warp first.

Change font

Open your warp terminal. Go to settings by pressing command/ctrl + ,(comma). Select Appearance and scorll down to find terminal font. From the dropdown select Mono version of your installed nerd font. For my case it is MesloLGS Nerd Font Mono. warp-font-config

Features

Now select the feature tab and you can enable the features you like. But it is recomended to enable Honor user's custom prompt(PS1) and Open completions menu as you type. warp-feature-config

Note: if Honor user’s custom prompt(PS1) is not enabled our starship prompt will not be visible in warp.

Theming

In warp we can create our own themes and workspaces. In this guide we are only going to create a theme. To get started create a file ~/.warp/themes/sayeed.yml ~

command line
mkdir -p ~/.warp/themes && touch ~/.warp/themes/sayeed.yml

Note: The name of the file will be the name of the theme.

Now paste these lines in the yml file we created ~

default_file ~/.warp/themes/sayeed.yml
accent: "#2196f3" # Accent color for UI elements
background: "#1a1d21" # Terminal background color
details: darker # Whether the theme is lighter or darker.
foreground: "#f1f1f1" # The foreground color.
terminal_colors: # Ansi escape colors.
  bright:
    black: "#212121"
    blue: "#2196f3"
    cyan: "#00bcd4"
    green: "#4caf50"
    magenta: "#D80073"
    red: "#f44336"
    white: "#ffffff"
    yellow: "#ffeb3b"
  normal:
    black: "#212121"
    blue: "#2196f3"
    cyan: "#00bcd4"
    green: "#4caf50"
    magenta: "#D80073"
    red: "#f44336"
    white: "#f1f1f1"
    yellow: "#ffeb3b"

It is time to activate the theme in the Appearance setting of warp.

warp-theme-config

Starship

Let’s customize our prompt.

Config

We need a config file, that will contain all configuration related to starship. To get started configuring starship, create the following file: ~/.config/starship.toml.

command line
mkdir -p ~/.config && touch ~/.config/starship.toml

This will create the .config directory if it is not available and create the starship.toml file as well. All configuration for starship is done in this TOML file. Copy below configurations and paste in the starship.toml file:

default_file ~/.config/starship.toml

# Inserts a blank line between shell prompts
add_newline = true

# Change command timeout from 500 to 1000 ms
command_timeout = 1000

# Change the default prompt format
format = """$env_var $all"""

# Change the default prompt characters
[character]
success_symbol = ""
error_symbol = ""

# Shows an icon that should be included by zshrc script based on the distribution or os
[env_var.STARSHIP_DISTRO]
format = '[$env_value](white)'
variable = "STARSHIP_DISTRO"
disabled = false

# Shows the username
[username]
style_user = "green"
style_root = "red"
format = "[$user]($style) "
disabled = false
show_always = true

[hostname]
ssh_only = false
format = "on [$hostname](blue) "
disabled = false

[directory]
truncation_length = 1
truncation_symbol = "../"
home_symbol = "īŸ ~"
read_only_style = "197"
read_only = " ī€Ŗ "
format = "at [$path]($style)[$read_only]($read_only_style) "

[git_branch]
symbol = "īžĄ "
format = "[$symbol$branch]($style) "
# truncation_length = 4
truncation_symbol = "â€Ļ/"
style = "bold green"

[git_status]
format = '[\($all_status$ahead_behind\)]($style) '
style = "bold green"
conflicted = "đŸŗ"
up_to_date = "ī† "
untracked = "ī”Š "
ahead = "⇡${count}"
diverged = "⇕⇡${ahead_count}â‡Ŗ${behind_count}"
behind = "â‡Ŗ${count}"
stashed = "īŖ– "
modified = "ī„ "
staged = '[++\($count\)](green)'
renamed = "īĒļ "
deleted = "ī€” "

[kubernetes]
format = 'via [ī´ą $context\($namespace\)](bold purple) '
disabled = false

# (deactivated because of no space left)
[terraform]
format = "via [ī„ĩ terraform $version]($style) īĨ‚ [$workspace]($style) "
disabled = true

[vagrant]
format = "via [ī„ĩ vagrant $version]($style) "
disabled = true

[docker_context]
format = "via [īŒˆ $context](bold blue) "
disabled = true

[helm]
format = "via [īˆš $version](bold purple) "
disabled = true

[python]
symbol = "ī Ÿ "
python_binary = "python3"
disabled = true

[nodejs]
format = "via [īĸ˜ $version](bold green) "
disabled = true

[ruby]
format = "via [ $version]($style) "
disabled = true

You can always check the official configuration doc and make changes in the file as your liking.

OS icon

We are using a variable STARSHIP_DISTRO in our configuration which will show the os distribution icon at the begining of our prompt. But the variable is not initialized yet. Create a new file ~/.config/zsh/starship.zsh ~

command line
mkdir -p ~/.config/zsh && touch ~/.config/zsh/starship.zsh

Paste these lines in the file ~

default_file ~/.config/zsh/starship.zsh
# find out which distribution we are running on
LFILE="/etc/*-release"
MFILE="/System/Library/CoreServices/SystemVersion.plist"
if [[ -f $LFILE ]]; then
  _distro=$(awk '/^ID=/' /etc/*-release | awk -F'=' '{ print tolower($2) }')
elif [[ -f $MFILE ]]; then
  _distro="macos"
fi

# set an icon based on the distro
# make sure your font is compatible with https://github.com/lukas-w/font-logos
case $_distro in
    *kali*)                  ICON="ī´Ŗ";;
    *arch*)                  ICON="īŒƒ";;
    *debian*)                ICON="îŊ";;
    *raspbian*)              ICON="īŒ•";;
    *ubuntu*)                ICON="īŒ›";;
    *elementary*)            ICON="īŒ‰";;
    *fedora*)                ICON="īŒŠ";;
    *coreos*)                ICON="īŒ…";;
    *gentoo*)                ICON="īŒ";;
    *mageia*)                ICON="īŒ";;
    *centos*)                ICON="īŒ„";;
    *opensuse*|*tumbleweed*) ICON="īŒ”";;
    *sabayon*)               ICON="īŒ—";;
    *slackware*)             ICON="īŒ˜";;
    *linuxmint*)             ICON="īŒŽ";;
    *alpine*)                ICON="īŒ€";;
    *aosc*)                  ICON="īŒ";;
    *nixos*)                 ICON="īŒ“";;
    *devuan*)                ICON="īŒ‡";;
    *manjaro*)               ICON="īŒ’";;
    *rhel*)                  ICON="īŒ–";;
    *macos*)                 ICON="ī”´";;
    *)                       ICON="ī…ŧ";;
esac

export STARSHIP_DISTRO="$ICON"

Finally source the file and init starship in the ~/.zshrc ~

default_file .zshrc
[[ -f ~/.config/zsh/starship.zsh ]] && source ~/.config/zsh/starship.zsh

# Load Starship
eval "$(starship init zsh)"

Note: Paste these lines at the bottom of the file


We are done for now đŸĨŗ. Close all your terminal session and reopen warp to see the difference. Here’s my final warp + starship ~

my-warp

Happy Hacking 😉