Browse code

Merge pull request #482 from volpino/master

Theme chooser + fox's theme

Robby Russell authored on 10/10/2011 at 12:17:21
Showing 2 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,8 @@
0
+#fox theme
1
+PROMPT='%{$fg[cyan]%}┌[%{$fg_bold[white]%}%n%{$reset_color%}%{$fg[cyan]%}☮%{$fg_bold[white]%}%M%{$reset_color%}%{$fg[cyan]%}]%{$fg[white]%}-%{$fg[cyan]%}(%{$fg_bold[white]%}%~%{$reset_color%}%{$fg[cyan]%})$(git_prompt_info)
2
+└> % %{$reset_color%}'
3
+
4
+ZSH_THEME_GIT_PROMPT_PREFIX="-[%{$reset_color%}%{$fg[white]%}git://%{$fg_bold[white]%}"
5
+ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}%{$fg[cyan]%}]-"
6
+ZSH_THEME_GIT_PROMPT_DIRTY=" %{$fg[red]%}✗%{$reset_color%}"
7
+ZSH_THEME_GIT_PROMPT_CLEAN=" %{$fg[green]%}✔%{$reset_color%}"
0 8
new file mode 100755
... ...
@@ -0,0 +1,96 @@
0
+#!/bin/zsh
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="${HOME}/.zsh_favlist"
11
+source $ZSH/oh-my-zsh.sh
12
+
13
+function noyes() {
14
+    read "a?$1 [y/N] "
15
+    if [[ $a == "N" || $a == "n" || $a = "" ]]; then
16
+        return 0
17
+    fi
18
+    return 1
19
+}
20
+
21
+function theme_preview() {
22
+    THEME=$1
23
+    THEME_NAME=`echo $THEME | sed s/\.zsh-theme$//`
24
+    print "$fg[blue]${(l.((${COLUMNS}-${#THEME_NAME}-5))..─.)}$reset_color $THEME_NAME $fg[blue]───$reset_color"
25
+    source "$THEMES_DIR/$THEME"
26
+    print -P $PROMPT
27
+}
28
+
29
+function banner() {
30
+    echo
31
+    echo "╺━┓┏━┓╻ ╻   ╺┳╸╻ ╻┏━╸┏┳┓┏━╸   ┏━╸╻ ╻┏━┓┏━┓┏━┓┏━╸┏━┓"
32
+    echo "┏━┛┗━┓┣━┫    ┃ ┣━┫┣╸ ┃┃┃┣╸    ┃  ┣━┫┃ ┃┃ ┃┗━┓┣╸ ┣┳┛"
33
+    echo "┗━╸┗━┛╹ ╹    ╹ ╹ ╹┗━╸╹ ╹┗━╸   ┗━╸╹ ╹┗━┛┗━┛┗━┛┗━╸╹┗╸"
34
+    echo
35
+}
36
+
37
+function usage() {
38
+    echo "Usage: $0 [options] [theme]"
39
+    echo
40
+    echo "Options"
41
+    echo "  -l   List available themes"
42
+    echo "  -s   Show all themes"
43
+    echo "  -h   Get this help message"
44
+    exit 1
45
+}
46
+
47
+function list_themes() {
48
+    for THEME in $(ls $THEMES_DIR); do
49
+        THEME_NAME=`echo $THEME | sed s/\.zsh-theme$//`
50
+        echo $THEME_NAME
51
+    done
52
+}
53
+
54
+function insert_favlist() {
55
+    if grep -q "$THEME_NAME" $FAVLIST 2> /dev/null ; then
56
+        echo "Already in favlist"
57
+    else
58
+        echo $THEME_NAME >> $FAVLIST
59
+        echo "Saved to favlist"
60
+    fi
61
+
62
+}
63
+
64
+function theme_chooser() {
65
+    for THEME in $(ls $THEMES_DIR); do
66
+        echo
67
+        theme_preview $THEME
68
+        echo
69
+        if [[ -z $1 ]]; then
70
+            noyes "Do you want to add it to your favourite list ($FAVLIST)?" || \
71
+                  insert_favlist $THEME_NAME
72
+            echo
73
+        fi
74
+    done
75
+}
76
+
77
+while getopts ":lhs" Option
78
+do
79
+  case $Option in
80
+    l ) list_themes ;;
81
+    s ) theme_chooser 0 ;;
82
+    h ) usage ;;
83
+    * ) usage ;; # Default.
84
+  esac
85
+done
86
+
87
+if [[ -z $Option ]]; then
88
+    if [[ -z $1 ]]; then
89
+        banner
90
+        echo
91
+        theme_chooser
92
+    else
93
+        theme_preview $1".zsh-theme"
94
+    fi
95
+fi