Browse code

added theme chooser

fox authored on 19/07/2011 at 19:47:26
Showing 1 changed files
1 1
new file mode 100755
... ...
@@ -0,0 +1,47 @@
0
+#!/bin/sh
1
+
2
+# Zsh Theme Chooser by fox (fox91 at anche dot no)
3
+# This program is free software. It comes without any warranty, to
4
+# the extent permitted by applicable law. You can redistribute it
5
+# and/or modify it under the terms of the Do What The Fuck You Want
6
+# To Public License, Version 2, as published by Sam Hocevar. See
7
+# http://sam.zoy.org/wtfpl/COPYING for more details.
8
+
9
+THEMES_DIR="$ZSH/themes"
10
+FAVLIST="~/.zsh_favlist"
11
+
12
+function noyes() {
13
+    read -p "$1 [y/N]" a
14
+    if [[ $a == "N" || $a == "n" || $a = "" ]]; then
15
+        return 0
16
+    fi
17
+    return 1
18
+}
19
+
20
+function theme_preview() {
21
+    THEME=$1
22
+    export ZDOTDIR="$(mktemp -d)"
23
+
24
+cat <<-EOF >"$ZDOTDIR/.zshrc"
25
+    source ~/.zshrc
26
+    source "$THEMES_DIR/$THEME"
27
+EOF
28
+    zsh
29
+    rm -rf "$ZDOTDIR"
30
+
31
+    echo
32
+    noyes "Do you want to add it to your favourite list?" && \
33
+          echo $THEME >> $FAVLIST
34
+    echo
35
+}
36
+
37
+echo
38
+echo "╺━┓┏━┓╻ ╻   ╺┳╸╻ ╻┏━╸┏┳┓┏━╸   ┏━╸╻ ╻┏━┓┏━┓┏━┓┏━╸┏━┓"
39
+echo "┏━┛┗━┓┣━┫    ┃ ┣━┫┣╸ ┃┃┃┣╸    ┃  ┣━┫┃ ┃┃ ┃┗━┓┣╸ ┣┳┛"
40
+echo "┗━╸┗━┛╹ ╹    ╹ ╹ ╹┗━╸╹ ╹┗━╸   ┗━╸╹ ╹┗━┛┗━┛┗━┛┗━╸╹┗╸"
41
+echo
42
+
43
+for i in $(ls $THEMES_DIR); do
44
+    echo "Now showing theme $i"
45
+    theme_preview $i
46
+done