Post

Starship: My attempt at quitting Oh-My-ZSH for good

Starship: My attempt at quitting Oh-My-ZSH for good

For years, Oh-My-ZSH has been my loyal companion on this journey through the intricate web of coding. With its fancy prompts and endless customization, it’s been like having a stylish, albeit slightly high-maintenance, friend by my side in the terminal.

But as our relationship evolved, I began to notice the signs of complexity creeping in. My once-sleek terminal was now drowning in configurations and plugins. It was time for a change.

In this post, I invite you to join me on my journey as I bid farewell to Oh-My-ZSH and say hello to the minimalist yet efficient Starship. It’s not just a switch of tools but a shift in my approach towards simplicity and productivity. Oh, and it’s written in Rust! Nice.

I’ll take you through the steps, challenges, and the ‘aha’ moments I encountered during my transition. Let’s make your terminal experience smoother, more functional, and, dare I say, a tad more stylish. Say goodbye to the clutter and hello to the streamlined beauty of Starship – because sometimes, less truly is more.

Prerequisites

Before we embark on this tutorial, let’s ensure that you have everything you need to get started:

  1. An Apple computer.
  2. An internet connection.
  3. A general understanding of the command-line.
  4. Homebrew installed on your computer.
  5. Power fonts installed.
  6. A beverage of some sort, i.e. coffee.

TL;DR

My Dot Files are available here: https://gitlab.com/pycvalade/dot-files

Removing Oh-My-ZSH

My journey to streamline my setup took an unexpected turn when I decided it was time to part ways with Oh-My-ZSH. Oh-My-ZSH had been my trusted companion, offering a multitude of customization options, themes, and plugins that had made my terminal environment as flashy as a Hollywood premiere. However, as time went on, I found myself entangled in a web of configurations and options, each one more enticing and complex than the last.

It became apparent that my once-sleek and efficient terminal was slowly becoming cluttered and unwieldy. What had started as a quest for personalization had turned into an overwhelming cacophony of settings and plugins. It was time to regain control of my workspace and return to a simpler, leaner coding environment.

So, I made the decision to bid adieu to Oh-My-ZSH, knowing that a more minimalist and functional approach was in order. While it wasn’t a decision I took lightly, I was excited about the prospect of simplifying my terminal setup and improving my workflow. The funny thing about it is it only took 1 command to get rid of it!

1
uninstall_oh_my_zsh

Once that was done, I cleaned up my .zshrc file and kept the strict minimum:

1
2
3
4
5
6
if type brew &>/dev/null; then
  FPATH=$(brew --prefix)/share/zsh-completions:$FPATH

  autoload -Uz compinit
  compinit
fi

Installing Starship

With Oh-My-ZSH out of the way, it was time to introduce a new star player into my terminal setup. Enter Starship, a minimalist yet highly functional prompt for your terminal. To install Starship, I turned to Homebrew, the popular package manager for macOS. If you haven’t already installed Homebrew, you can do so by following the installation instructions on their website.

Once Homebrew is up and running, installing Starship was a breeze. I opened my terminal and entered the following command:

1
brew install starship

In a matter of seconds, Starship was downloaded and ready to go. The simplicity of the installation process was a refreshing change, and I was eager to see what Starship had to offer.

Configuring the Starship Prompt

So we’ve installed Starship but our prompt still looks like 1993. Starship is relies heavily on a config file to make it work and puts you back in control.

First things first, let’s actually enable the Starship prompt by adding this line at the end of our .zshrc file:

1
eval "$(starship init zsh)"

Now save the file, close and re-open your terminal. Hello beautiful!

The Starship Config File

Starship is installed so now what? Yup, we need to configure it to our liking!

Let’s start by creating our config file:

1
touch ~/.config/starship.toml

Then, I opened this configuration file using my preferred text editor and began customizing my prompt. Starship uses a TOML configuration file, which is easy to read and modify. I tweaked the prompt’s appearance, added information such as the current directory and Git status, and adjusted the colors to match my preferred theme.

After saving the changes, I restarted my terminal, and the new Starship prompt was in action. It was clean, functional, and, most importantly, tailored to my needs.

One of the aspects I appreciate most about Starship is its consistent and intuitive documentation. It made configuring the prompt a straightforward process. With the extensive customization options at my disposal, I could fine-tune the prompt to display the information that mattered most to me.

For example, I added the Git status to my prompt, allowing me to see at a glance which branch I was on and whether there were any uncommitted changes. This streamlined my workflow and saved me the hassle of running Git commands manually. Starship also offers a variety of icons and glyphs that can be incorporated into the prompt, giving it a unique and visually appealing look.

The prompt’s color scheme was another aspect I customized to match my preferred aesthetic. Whether you’re a fan of dark themes, light themes, or something in between, Starship provides ample options to make your prompt visually appealing and easy to read. In the end, my terminal prompt became an extension of my personal style, and it was a pleasure to work with.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# history setup
export HISTFILE="$HOME/.zsh_history"
export HISTSIZE=100000
export SAVEHIST=100000
setopt INC_APPEND_HISTORY
setopt SHARE_HISTORY
setopt HIST_EXPIRE_DUPS_FIRST
setopt HIST_IGNORE_DUPS
setopt HIST_IGNORE_ALL_DUPS
setopt HIST_FIND_NO_DUPS
setopt HIST_SAVE_NO_DUPS
setopt HIST_REDUCE_BLANKS
setopt HIST_VERIFY

# partial history search bindings
bindkey '\e[A' history-search-backward
bindkey '\e[B' history-search-forward

Adding a Transient Prompt

One of the features that excited me the most about Starship was its ability to include transient prompts. Transient prompts are extra information that appears temporarily when you need it and disappear when you don’t. It’s a fantastic feature for keeping your prompt clean and uncluttered.

I configured Starship to show Git information only when I was in a directory that contained a Git repository. This way, I had the information I needed right at my fingertips when working on Git projects, but it didn’t clutter my prompt when I wasn’t in a Git directory.

To set up transient prompts, I made a few adjustments to my ZSH configuration file and defined the custom bit to enable it. It was a game-changer for maintaining a sleek and organized prompt while still having access to essential data when I needed it the most.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# transient prompt
zle-line-init() {
  emulate -L zsh

  [[ $CONTEXT == start ]] || return 0

  while true; do
    zle .recursive-edit
    local -i ret=$?
    [[ $ret == 0 && $KEYS == $'\4' ]] || break
    [[ -o ignore_eof ]] || exit 0
  done

  local saved_prompt="$PROMPT"
  local saved_rprompt=$RPROMPT
  PROMPT="%K{white}%F{black} ❯ %f%k "
  RPROMPT=''
  zle .reset-prompt
  PROMPT=$saved_prompt
  RPROMPT=$saved_rprompt

  if (( ret )); then
    zle .send-break
  else
    zle .accept-line
  fi

  return ret
}
zle -N zle-line-init

Adding Fish-like Auto-Suggestions

1
2
# zsh-autosuggestions
source $(brew --prefix)/share/zsh-autosuggestions/zsh-autosuggestions.zsh

Final Thoughts

In conclusion, if you’re a Mac user looking to enhance your web development experience, consider the journey from Oh-My-ZSH to Starship. It’s a transition that can significantly simplify your workspace, improve your efficiency, and make your terminal setup more visually appealing.

The process involves saying goodbye to the complex world of Oh-My-ZSH and welcoming the minimalist elegance of Starship. Installing Starship with Homebrew is a breeze, and customizing it to your liking using the TOML configuration file offers endless possibilities.

Don’t forget to explore the world of transient prompts to keep your prompt clean and focused while still having easy access to crucial information when you need it.

In the end, the decision to switch from Oh-My-ZSH to Starship proved to be a pivotal moment in my web development journey. It made my workflow more efficient, my workspace less cluttered, and my coding experience more enjoyable. So, why not give it a try and experience the benefits of a cleaner, more focused development environment? Happy coding!