How do you determine which theme you are on when ZSH_THEME="random"

13,160

Solution 1

According to oh-my-zsh.sh L81-87:

if [ "$ZSH_THEME" = "random" ]; then
  themes=($ZSH/themes/*zsh-theme)
  N=${#themes[@]}
  ((N=(RANDOM%N)+1))
  RANDOM_THEME=${themes[$N]}
  source "$RANDOM_THEME"
  echo "[oh-my-zsh] Random theme '$RANDOM_THEME' loaded..."

Therefore you should be able to print the path to the random theme with

print $RANDOM_THEME

Solution 2

As it was requested to its developers team, a new command is added to support this functionality:

just use:

echo $ZSH_THEME

the response will be the current theme which is using by user.

Solution 3

To update the answer of @4a1e1.

The current version of oh-my-zsh has implemented a second option ZSH_THEME_RANDOM_CANDIDATES that works together ZSH_THEME

When

    ZSH_THEME="random"
    ZSH_THEME_RANDOM_CANDIDATES=("robbyrussell" "rkj-repos")

To each new terminal opening, only robbyrussell or rkj-repos themes will be applied.

Share:
13,160
Naruto Sempai
Author by

Naruto Sempai

Software Developer ~~} Kotlin | Spring | Java | Javascript | Node | ReactJs | Tapestry | Docker | A little about a lot of other things....

Updated on June 13, 2022

Comments

  • Naruto Sempai
    Naruto Sempai almost 2 years

    I found a theme I like but only after executing a program on the command line with a lot of output, so I don't know the name of the current theme!

    Here is the relevant part of my .zshrc:

    # Set name of the theme to load.
    ...
    ZSH_THEME="random"
    

    Is there a way to determine which theme I am on?