Skip to main content

Command Palette

Search for a command to run...

Adding an Octopus to the Zsh Prompt

Updated
3 min read
Adding an Octopus to the Zsh Prompt

Transition from bash to zsh with custom settings, conditional emojis, and git prompt

Photo by Serena Repice Lentini on Unsplash

For my last Mac, I had a friendly hamster face emoji in my terminal bash prompt. After I recently upgraded to a new Mac, I discovered Apple has replaced bash with zsh as the default shell, beginning with macOS Catalina.

Starting with macOS Catalina, your Mac uses zsh as the default login shell and interactive shell.

You can still switch back to bash, for now, but the trend is moving to zsh as the command-line interpreter for the login shell and interactive shell.

Here’s how you can add an Octopus emoji and other custom items to your zsh prompt to make life in your terminal more hospitable.

Change your default shell

If you aren’t already using zsh in your terminal, change the shell by updating the shell path to /bin/zsh, with the following terminal command.

$ chsh -s /bin/zsh

Switch to a zsh prompt

Zsh recognizes a different set of prompt specifiers than bash, so you may need to modify some settings previously used in your bash profile.

If you’re starting from scratch, here’s 3 steps to add a custom prompt with an emoji as well as other information about the current git repository.

Step 1: install oh-my-zsh

Install Oh My Zsh, an open source framework for managing your zsh configuration, by running this curl command in your terminal.

$ sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"

Step 2: update your theme and plugins

Use your favorite text editor to open your ~/.zshrc config file located in your $HOME directory.

$ code ~/.zshrc

This config file is where you can update your theme for a different look and feel by selecting one of the many available themes, or leave it the default theme.

# in ~/.zshrc
# pick theme
ZSH_THEME="robbyrussell"

You can also add a plugin to this config file by selecting a few of the many available plugins, like [git-prompt](https://github.com/ohmyzsh/ohmyzsh/tree/master/plugins/git-prompt) to display information about the current directory.

# in ~/.zshrc
# add plugin
plugins=(
git-prompt
)

Step 3: customize the prompt

Use your favorite text editor to open your oh my zhs theme to further customize your terminal prompt.

$ code ~/.oh-my-zsh/themes/robbyrussell.zsh-theme

Tweak the theme by updating various parts of the PROMPT string. You can use a zsh prompt generator to easily configure, bold, or colorize more elements. Paste in your own emoji, or use Ctrl + Cmd + Space on Mac to open up the emoji keyboard.

customize prompt with emoji and git status

Another option is to add a conditional emoji based on the success of the previous command. In this example, an Octopus will display in the prompt if the preceding command succeeds, otherwise a Dinosaur.

customize with conditional emojis

Save your changes, and open a new terminal tab to inspect your newest Octopus friend 🐙!

More from this blog

J

JoyceJetson

18 posts

Adding an Octopus to the Zsh Prompt