Terminal"> Terminal"> Skip to content
Breaking
Latest technical intelligence from Northeast India • Infrastructure, AI, Cloud & Security Analysis • Precision Analysis | Raw Intelligence | Your North Star of Tech Latest technical intelligence from Northeast India • Infrastructure, AI, Cloud & Security Analysis • Precision Analysis | Raw Intelligence | Your North Star of Tech
WEBDEV

Analysis: Customizing MacOS Terminal with Starship Like a Pro

Streamlining Your Terminal: A Guide to Starship Prompt Customization

Why This Matters

In the rapidly evolving world of terminal applications, managing multiple Command Line Interfaces (CLIs) and their various versions can be a daunting task. Customizing your terminal environment can significantly improve productivity by simplifying the handling of multiple tools. This article will guide you through the process of building a custom Starship prompt, offering dynamic context for AWS profiles, Java, Node.js, and more.

Getting Started

To begin, you'll need to install Starship, a powerful terminal prompt tool that provides a declarative approach to customization. Follow these steps to get started:

  1. Install Starship via Homebrew

    Open your terminal and run:

    brew install starship

Integrate Starship with Zsh

Edit your .zshrc file (e.g., using nano):

nano ~/.zshrc

Add the following line to load Starship on every zsh session:

eval"$(starship init zsh)"

Optional: Enhance Your Terminal Experience with Zsh Plugins

While not mandatory, these plugins can provide real-time command highlighting and suggestions based on your command history and current input:

  1. Install zsh-syntax-highlighting

    brew install zsh-syntax-highlighting
  2. Install zsh-autosuggestions

    brew install zsh-autosuggestions

Edit your .zshrc file again to load the plugins:

nano ~/.zshrc
source $(brew --prefix)/share/zsh-autosuggestions/zsh-autosuggestions.zsh
source $(brew --prefix)/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh

Install Nerd Fonts

To ensure your terminal can correctly render icons and custom glyphs, you need to install a Nerd Font:

  1. Install Fira Code Nerd Font via Homebrew

    brew search font-fira-code-nerd-font
    brew install --cask font-fira-code-nerd-font

Set Terminal Font to Nerd Font

Update your terminal settings to use a Nerd Font:

  • Iterm2

    Navigate to: Settings > Profiles > Default > General > Terminal Font and select FiraCode Nerd Font.

  • VS Code Integrated Terminal

    Navigate to: Settings > User > terminal.integrated.fontFamily and select FiraCode Nerd Font.

  • MacOS Native Terminal

    Navigate to: Settings > Profiles > Text > Font and select FiraCode Nerd Font.

Customize Starship Theme

Create and open the starship.toml configuration file to customize the Starship prompt:

mkdir -p ~/.config && nano ~/.config/starship.toml

Add the following lines to customize the prompt:

# Get editor completions based on the config schema "$schema"='https://starship.rs/config-schema.json' # ~/.config/starship.toml format = """ $directory $git_branch $git_status $fill $aws $nodejs $java $gradle $os $character """ [fill] symbol = ' ' truncate_to_repo = true truncation_length = 1 [git_branch] format = '[$symbol $branch ]($style)' style = 'bg:green' [git_status] format = '[$all_status$ahead_behind](bg:green)' conflicted = '=[=](bg:yellow bold)' ahead = '=[ ](bg:yellow bold)' behind = '=[ ](bg:yellow bold)' diverged = '=[ ](bg:yellow bold)' up_to_date = '' untracked = '=[ ? ](bg:yellow bold)' stashed = '=[ \$ ](bg:yellow bold)' modified = '=[ ! ](bg:yellow bold)' staged = '=[ + ](bg:yellow bold)' renamed = '=[ ](bg:yellow bold)' deleted = '=[ ](bg:yellow bold)' typechanged = '' [aws] format = '[$symbol $profile $region ]($style)' symbol = ' ' [nodejs] format = '[$symbol $version ]($style)' version_format = '${raw}' [java] format = '[$symbol:$version ]($style)' version_format = '${raw}' style = 'bg:red bold' symbol = 'jdk' [gradle] format = '[$symbol $version ]($style)' version_format = '${raw}' symbol = ' ' [os] format = '[$symbol ]($style)' disabled = false [os.symbols] MacOS = ' ' [character] success_symbol = "[ ](bold default)" error_symbol = "[ ](bold red)" 

Play With Your New Prompt

Open a new terminal and observe how Starship dynamically updates your prompt based on your current environment, including AWS profiles, Node.js versions, and Git repository information.

Note: The North East region of India, like other parts of the country, benefits from the increased productivity and streamlined workflow offered by tools like Starship. By adopting such tools, developers can work more efficiently and focus on creating innovative solutions.