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

6

45

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?

Stowers answered 26/7, 2015 at 23:17 Comment(3)
According to oh-my-zsh.sh line 85, just print $RANDOM_THEME.Campo
You are correct! .oh-my-zsh/themes/nanotech.zsh-theme ftw! Add it as an answer so I can accept it.Stowers
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/ThemesAnarchist
C
67

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
Campo answered 26/7, 2015 at 23:29 Comment(2)
Is it possible to autocomplete Random_Theme as it is with zsh_theme?Anarchist
With Mac autocomplete works for echo $Random_ThemeAnarchist
C
15

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.

Cowpuncher answered 31/5, 2021 at 10:46 Comment(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.Anarchist
A
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.

Appleton answered 25/3, 2021 at 11:25 Comment(0)
K
6

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
Kinakinabalu answered 4/11, 2022 at 19:38 Comment(0)
R
1

You could use echo $RANDOM_THEME if you are on mac terminalenter image description here

Rees answered 8/5 at 22:20 Comment(0)
D
-1

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

Distaff answered 21/1, 2022 at 17:4 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.