theme_chooser.sh 2.37 KB
Newer Older
fox's avatar
fox committed
1
2
3
4
5
6
7
8
9
10
#!/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"
fox's avatar
fox committed
11
FAVLIST="${HOME}/.zsh_favlist"
fox's avatar
fox committed
12
13

function noyes() {
fox's avatar
fox committed
14
    read -p "$1 [y/N] " a
fox's avatar
fox committed
15
16
17
18
19
20
21
22
    if [[ $a == "N" || $a == "n" || $a = "" ]]; then
        return 0
    fi
    return 1
}

function theme_preview() {
    THEME=$1
fox's avatar
fox committed
23
    THEME_NAME=`echo $THEME | sed s/\.zsh-theme//`
fox's avatar
fox committed
24
    export ZDOTDIR="$(mktemp -d tmp.zshXXXX)"
fox's avatar
fox committed
25
26

cat <<-EOF >"$ZDOTDIR/.zshrc"
fox's avatar
fox committed
27
28
    ZSH_THEME="$THEME_NAME"
    source $ZSH/oh-my-zsh.sh
fox's avatar
fox committed
29
30
31
32
33
EOF
    zsh
    rm -rf "$ZDOTDIR"

    echo
fox's avatar
fox committed
34
    noyes "Do you want to add it to your favourite list ($FAVLIST)?" || \
fox's avatar
fox committed
35
          echo $THEME_NAME >> $FAVLIST
fox's avatar
fox committed
36
37
38
39
40
41
42
43
44
45
46
47
48
    echo
}

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

for i in $(ls $THEMES_DIR); do
    echo "Now showing theme $i"
    theme_preview $i
done