fea4e54b1053764df10f507c233286281133fe90

Author
fox <fox91@anche.no>
Committer
fox <fox91@anche.no>
Date

Message

added theme chooser

Diff

This diff is truncated to protect this page.

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