Theme chooser + fox's theme #482

merged 5 commits into from Oct 10, 2011

4 participants


There are a lot of themes available with zsh but it's boring to set every theme to try it and see if it's cool for our needs. So I wrote this simple theme chooser (could be improved a lot! maybe even with an ncurses interface but it's only a prototype).

I added my zsh theme too ;)


This is really neat. Did you see my open issue #478 yet? Wondering if we can combine these ideas a bit. :-)


How do you go about playing with this?

I'm getting this:

 $ ./.oh-my-zsh/tools/

╺━┓┏━┓╻ ╻   ╺┳╸╻ ╻┏━╸┏┳┓┏━╸   ┏━╸╻ ╻┏━┓┏━┓┏━┓┏━╸┏━┓
┏━┛┗━┓┣━┫    ┃ ┣━┫┣╸ ┃┃┃┣╸    ┃  ┣━┫┃ ┃┃ ┃┗━┓┣╸ ┣┳┛
┗━╸┗━┛╹ ╹    ╹ ╹ ╹┗━╸╹ ╹┗━╸   ┗━╸╹ ╹┗━┛┗━┛┗━┛┗━╸╹┗╸

Now showing theme Soliah.zsh-theme
usage: mktemp [-d] [-q] [-t prefix] [-u] template ...
       mktemp [-d] [-q] [-u] -t prefix

uh, osx wants a template for mktemp! fixed ;)


Great addition! Some comments / suggestions :

  • I guess you forgot to push your mktemp template
  • I suggest using source $ZSH/ instead of source ~/.zshrc (sourcing .zshrc fails for me with rvm I think)
  • Could it be possible to just display a sample line for each theme?, instead of leaving an open session + (fav y/N)? > that would give a nice list... Trying to tweak this :)


  • yeah i forgot!
  • yeah it's better. i didn't do that becasue i didn't want to lose any custom setting
  • i tried but i can't do it! how could it be possible?

I'm definitely not a zsh scripter, but digging zsh man and other things, I came to this, which works not that bad, a few themes display are broken, but that still brings an interesting result:
omz themes

The quick&dirty piece of code :

source $ZSH/
for THEME in $(ls $THEMES_DIR); do
  THEME_NAME=`echo $THEME | sed 's/\.zsh-theme$//'`
  print "$fg[blue]${(l.((70-${#THEME_NAME}))..─.)}$reset_color $THEME_NAME $fg[blue]───$reset_color"
  source "$THEMES_DIR/$THEME"
  print -P $PROMPT

Ah! I forgot #478 prompt -p is a way much better that this dirty hack :)


your solution is cool! i didn't think about printing the prompt .-.
yeah prompt -p does everything but is shows only a few themes that are not in the OMZ folder. I don't know anything about that


That's the zsh built-in prompt theming, which I guess o-m-z doesn't use see man zshall > search for PROMPT THEMES
Sounds good to me :)


I think that now it's quite a good tool to choose a theme, what do you think?
I was thinking to write a plugin that uses the .zsh_favlist file and chooses a random theme from that. It would mess your shell up if you use totally different themes but if you use more or less the same theme but with different colors could be quite cool, what do you think?

@robbyrussell robbyrussell merged commit 84c20ce into robbyrussell:master Oct 10, 2011

Thanks for this! Going to tweet about it soon.

The RANDOM idea... maybe we should just check that if you already have favorite items, the existing random option uses that instead of some other config option.

It's either random amongst all or random from your favorites. Feel free to submit a new pull request for that.


Think the tool could benefit from q/quit option.


yeah! the random thing could be great!

i don't know if the q/quit stuff could be useful, you can just use ctrl+c. Maybe i'll add it anyway, it requires only to change one line of code


See patch at #651


Any ideas why doesn't work on my system? $ZSH seems to set to the correct value, but the script still doesn't seem to find the correct directories.


you have to export ZSH first I think... see #554 which is similar

should be a good idea to add an helper function to some lib/xxx.zsh like (untested) :

function choose_theme(){
   /usr/bin/env ZSH=$ZSH /bin/sh $ZSH/tools/

nope, didn't help either. here's my new error (i called the function choose_theme2):

``┌─[phil@toronto] - [~] - [2011-10-11 08:38:51]
└─[$] choose_theme2
/Users/phil/.zsh/oh-my-zsh/ line 14: syntax error near unexpected token
/Users/phil/.zsh/oh-my-zsh/ line 14: `for config_file ($ZSH/lib/*.zsh) source $config_file'
┌─[phil@toronto] - [~] - [2011-10-11 08:38:57]


do export ZSH or /usr/bin/env ZSH=$ZSH zsh $ZSH/tools/
(my bad, theme_chooser doesn't work with sh because it needs zsh globbing feature)


export ZSH; ./ actually worked. thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment