40

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?

Naruto Sempai
  • 6,233
  • 8
  • 35
  • 51
  • 7
    According to [`oh-my-zsh.sh` line 85](https://github.com/robbyrussell/oh-my-zsh/blob/980528f9fa33780499d625bbbb8ea2cada78530d/oh-my-zsh.sh#L85), just `print $RANDOM_THEME`. – 4ae1e1 Jul 26 '15 at 23:21
  • You are correct! .oh-my-zsh/themes/nanotech.zsh-theme ftw! Add it as an answer so I can accept it. – Naruto Sempai Jul 26 '15 at 23:25
  • 1
    In the default omz `zshrc` you can find info on `random`: `# Set name of the theme to load --- if set to "random", it will # load a random theme each time oh-my-zsh is loaded, in which case, # to know which specific one was loaded, run: echo $RANDOM_THEME # See https://github.com/ohmyzsh/ohmyzsh/wiki/Themes` – Timo May 08 '20 at 05:23

5 Answers5

62

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
4ae1e1
  • 7,228
  • 8
  • 44
  • 77
14

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.

Majid Roustaei
  • 1,556
  • 1
  • 20
  • 39
  • 1
    This does not help here. The question is which theme is used when `random` as `zsh_theme` is used. I doubt that `zsh_theme` was introduced in 2021. I think it was already available when this question was asked with `echo $ZSH_THEME`. – Timo Oct 16 '22 at 08:32
7

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.

Abraxas
  • 101
  • 2
  • 6
3

In updated versions you can list the current theme using omz theme list. It will list the current theme as well as the available themes for oh-my-zsh.

io :: ~ % omz theme list                                                                                                                                                                  
Current theme: flazz

Custom themes:
example

Built-in themes:
3den                    Soliah                  adben                   af-magic                afowler                 agnoster                alanpeabody
amuse                   apple                   arrow                   aussiegeek              avit                    awesomepanda            bira
0

You can use prompt -c which will print the current theme.

note: I am not sure from which version this is available, mine is zsh 5.8

Bechir
  • 987
  • 10
  • 26