Published on

Showing the full path in Oh My Zsh.

Authors

Why?

I love how Oh My Zsh enhances the experience in the default terminal. However, after installing it, the default theme only shows the current folder we're in.

I prefer to see the full path, and fortunately, this can be changed.

After installation, the default theme is set to only display the current folder, but we can modify it to show the full path. Here's how:

Default Default theme
Modified Default theme modified

How do we achieve this?

Thanks to this answer on stack overflow, the solution is quite simple.

Identify your current theme:

echo $ZSH_THEME

In my case, the theme was robbyrussell

Create a copy the original theme file in the $ZSH_CUSTOM/themes directory.

It’s recommended to override themes in the custom themes directory to preserve the original ones. This is useful if an update is applied to the original theme later.

Let's do this.

cp $ZSH/themes/robbyrussell.zsh-theme $ZSH_CUSTOM/themes/ 

Edit the newly created custom copy of the theme:

nano $ZSH_CUSTOM/themes/robbyrussell.zsh-theme
Theme configuration

I replaced the c in this part of the theme setup

%{$fg[cyan]%}%c%{$reset_color%}"

with ~

%{$fg[cyan]%}%~%{$reset_color%}"

It should now look like this

Theme configuration final

Here’s a list of configurations we can use to fit our needs:

  • %~% -> shows: ~/example_dir/temp/hello_world
  • %d% -> shows: /User/ydave/Desktop/example_dir/temp/hello_world
  • %2d -> shows: temp/hello_world
  • %3d -> shows: example_dir/temp/hello_world
  • %c% -> shows: hello_world