My Configs for a Fancy-Looking Terminal (starship, exa, fonts)

My starship and exa configs for a fancy command prompt in bash and pwsh (PowerShell). How to beautify the terminal with nerd fonts and a nice background. Making it work in Windows Terminal. Within an SSH session, under both root and non-root users.

My Configs for a Fancy-Looking Terminal (starship, exa, fonts)
Safe Skies
Join Timothy Snyderโ€™s fundraiser! ๐Ÿ‘‡ Safe SkiesJoin Timothy Snyderโ€™s fundraiser! The history professor is raising funds towards a situational alert system for Ukraineโ€™s Air Defence Forces. Protect Ukrainian towns from terrorist attacks.
Safe Skies is an innovative sensor system for detecting air targets

My terminal environment is usually customized as follows:

  1. starship for a nice command-line prompt,
  2. exa for a nice directory listing instead of original ls,
  3. nerdfonts for beautiful glyphs in the terminal application,
  4. Windows Terminal, as a terminal application for setting up all the beauty.

bash is the main shell I usually work in.

๐Ÿ‘‰ All instructions below work in a Linux environment including SSH sessions.

Terminal emulator allows rendering custom fonts and backgrounds (like those little cartoonish bulbs ๐Ÿ’ก). I use Windows Terminal as a terminal application (terminal emulator) in Windows for simultaneous access to different terminal environments and shells in different tabs, I mainly use two environments:

  1. Ubuntu in Windows Subsystem for Linux (WSL2) with bash shell.
  2. Windows environment enabled with pwsh (PowerShell).

There are plenty of terminal emulators in different Linux distros, e.g. GNOME Terminal on Ubuntu, they can be configured to render different fonts and backgrounds.

๐Ÿ’ก Just remember:

  1. backgrounds and the fancy fonts ๐ŸŽจ are in the terminal settings (GNOME, Windows Terminal)
  2. while the command prompt (๐Ÿš€ starship) is in the shell configuration (bash, fish, pwsh).

๐Ÿš€ Starship

Starship is used for a nice-looking command prompt.

How to Install

The following steps work in any Linux, you can even quickly beautify your SSH session on the remote host!

sudo apt install gcc cmake

curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
source "$HOME/.cargo/env"

cargo install starship
eval "$(starship init bash)"

Add the next line into ~/.bashrc:

 eval "$(starship init bash)"

Don't forget to apply.

source ~/.bashrc

How the command prompt finally looks:

Starship shows information about git repository instead of a long local path (you have to cd into the Git repo directory): cocoon Git repo, main branch, rust v1.67.0, Ubuntu ๎ฏ‰, bash ๎ฏŠ

Root User

๐Ÿ‘ฎโ€โ™‚๏ธ Additionally, set up starship for the root user.

Change a shell user to be a root user.

sudo su

vi ~/.bashrc

Add the following line into /root/.bashrc (it's literally ~/.bashrc for the root user... and don't forget to change the "<user>" part of the command line below - this is the non-root user you came from).

eval "$(/home/<user>/.cargo/bin/starship init bash)"

Run the command above in the command line or apply the config:

source .bashrc

How it finally looks for the root:

SSH

๐ŸŒŽ You can install starship on the remote node within an SSH session.

Just open an SSH session (like ssh alex@dsn-play-alex-01 in my case), and then follow the instructions above (rustup install , cargo install starship, etc.) and you will able to see something as follows after ssh login (command prompt shows you have a remote connection to some host):

Setting up starship on different hosts helps to distinguish a remote and a local hosts

๐Ÿ”ง Starship bash config

It's about how exactly Starship is going to render the command prompt.

cat ~/.config/starship.toml
[shlvl]
disabled = false
threshold = 1
symbol = "โ†•๏ธ "

[shell]
disabled = false
bash_indicator = "๎ฏŠ"

[os]
disabled = false
format = "$symbol "
symbols.Ubuntu = "๎ฏ‰"
  • shlvl config makes it show the number of a shell level, e.g. it shows "โ†•๏ธ 1" when running under mc (Midnight Commander).
  • shell module helps identify a shell that is currently in use (bash, fish, pwsh).
  • os module shows the operating system.

The last 2 options are needed because I can open a tab with PowerShell, and, with properly configured Starship, it allows me to recognize shells between each other quickly.

PowerShell Installation Notes

You can find instructions here: https://starship.rs/guide/#๐Ÿš€-installation

The biggest challenge is to find where is the PowerShell config. Mine was here: C:\Users\user\OneDrive\Documents\PowerShell\Microsoft.PowerShell_profile.ps1.

Here is its content:

# Starship
Invoke-Expression (&starship init powershell)

Meanwhile, the Starship config is here: $HOME/.config/starship.toml.

๐Ÿ”ง Starship PowerShell pwsh config

cat ~\.config\starship.toml
[shell]
disabled = false
powershell_indicator = "๎ฏ‡"
cmd_indicator = "๎ฏ„"

[os]
disabled = false
format = "$symbol "
symbols.Windows = "๎œ"

How It Looks in Tabs

In the following example, I can quickly distinguish OS and shells via nice glyphs: ๎ฏ‰ ๎ฏŠ ๎œ ๎ฏ‡.

๎ฏ‰ ๎ฏŠ Tab #1 can be a WSL2 Ubuntu/Linux bash terminal:

Ubuntu ๎ฏ‰, bash ๎ฏŠ, shell level 1 under mc, path ~/.config

๎œ ๎ฏ‡ Tab #2 can be a PowerShell pwsh terminal:

Windows ๎œ, PowerShell ๎ฏ‡, path ~\.config

๐Ÿฆ€ =exa=

exa is a modern replacement for ls written in Rust.

How to install:

sudo apt install exa

Modify ~/.bashrc config. If the ls alias is already defined there, then substitute it with the following line:

alias ls='exa --icons -F -H --group-directories-first --git -1'
  • --icons shows the icons (I want a fancy look!)
  • -F type indicators
  • -H hard links
  • --group-directories-first list directories before other files
  • --git list each file's Git status
  • -1 show a table listing, 1 entry by line

And ll is usually already defined like this:

alias ll='ls -alF'

๐Ÿ“บ Windows Terminal

Finally, a proper setup of the Windows Terminal is needed to fully enable starship and exa showing fancy fonts (e.g. "nerd" glyphs ๎ฏ‰, ๎ฏŠ) on a custom background (๐Ÿ’ก) with support of different terminal environments (e.g. bash, pwsh).

  1. Install the Windows Terminal from the Microsoft Store: https://apps.microsoft.com/store/detail/windows-terminal/9N0DX20HK701

  2. Install Nerd Fonts. Download a "FiraCode Nerd Font": https://github.com/ryanoasis/nerd-fonts/releases/download/v2.3.3/FiraCode.zip

    Find the Fira Code Retina Nerd Font Complete Mono Windows Compatible.ttf inside of the archive and install it (double click).

    ๐Ÿ’ก You can find more nerd fonts at nerdfonts.com.

    firacode_nerd_font_donwload

  3. Set the Campbell color theme and FiraCode NFR Retina font, installed in the previous step:
    windows_terminal_config

  4. Download my bulbs background (Right Click -> Save Image As...):
    light-bulb-minimalism-wallpaper-c26162b00db69e6bba0822c520f849d2
    And set it in the Windows Terminal:
    windows_terminal_config_background


Voila!

My final setup is shown in the initial screenshot at the beginning of the article: