1
0
Fork 0
mirror of https://github.com/ohmyzsh/ohmyzsh.git synced 2024-11-16 02:40:08 +00:00
ohmyzsh/tools/theme_chooser.sh

49 lines
2.4 KiB
Bash
Raw Normal View History

2011-07-19 19:47:26 +00:00
#!/bin/sh
# Zsh Theme Chooser by fox (fox91 at anche dot no)
# This program is free software. It comes without any warranty, to
# the extent permitted by applicable law. You can redistribute it
# and/or modify it under the terms of the Do What The Fuck You Want
# To Public License, Version 2, as published by Sam Hocevar. See
# http://sam.zoy.org/wtfpl/COPYING for more details.
THEMES_DIR="$ZSH/themes"
2011-07-19 20:02:34 +00:00
FAVLIST="${HOME}/.zsh_favlist"
2011-07-19 19:47:26 +00:00
function noyes() {
2011-07-19 20:02:34 +00:00
read -p "$1 [y/N] " a
2011-07-19 19:47:26 +00:00
if [[ $a == "N" || $a == "n" || $a = "" ]]; then
return 0
fi
return 1
}
function theme_preview() {
THEME=$1
2011-07-24 18:51:27 +00:00
THEME_NAME=`echo $THEME | sed s/\.zsh-theme//`
2011-07-24 09:58:41 +00:00
export ZDOTDIR="$(mktemp -d tmp.zshXXXX)"
2011-07-19 19:47:26 +00:00
cat <<-EOF >"$ZDOTDIR/.zshrc"
2011-07-24 18:51:27 +00:00
ZSH_THEME="$THEME_NAME"
source $ZSH/oh-my-zsh.sh
2011-07-19 19:47:26 +00:00
EOF
zsh
rm -rf "$ZDOTDIR"
echo
2011-07-19 20:02:34 +00:00
noyes "Do you want to add it to your favourite list ($FAVLIST)?" || \
2011-07-24 18:51:27 +00:00
echo $THEME_NAME >> $FAVLIST
2011-07-19 19:47:26 +00:00
echo
}
echo
echo "╺━┓┏━┓╻ ╻ ╺┳╸╻ ╻┏━╸┏┳┓┏━╸ ┏━╸╻ ╻┏━┓┏━┓┏━┓┏━╸┏━┓"
echo "┏━┛┗━┓┣━┫ ┃ ┣━┫┣╸ ┃┃┃┣╸ ┃ ┣━┫┃ ┃┃ ┃┗━┓┣╸ ┣┳┛"
echo "┗━╸┗━┛╹ ╹ ╹ ╹ ╹┗━╸╹ ╹┗━╸ ┗━╸╹ ╹┗━┛┗━┛┗━┛┗━╸╹┗╸"
echo
for i in $(ls $THEMES_DIR); do
echo "Now showing theme $i"
theme_preview $i
done