summary refs log tree commit diff
path: root/Functions/Prompts/prompt_elite2_setup
blob: 7e7748ec7fac59a72ee0bc63f004b266306a3b02 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# Created by icetrey <trey@imagin.net>
# Added by Spidey 08/06
# Converted to zsh prompt theme by <adam@spiers.net>

prompt_elite2_help () {
  cat <<EOH
This prompt is color-scheme-able.  You can invoke it thus:

  prompt elite2 [<text-color> [<parentheses-color>]]

The default colors are both cyan.  This theme works best with a dark
background.

Recommended fonts for this theme: nexus or vga or similar.  If you
don't have any of these, the 8-bit characters will probably look stupid.
EOH
}

prompt_elite2_setup () {
  local text_col=${1:-'cyan'}
  local parens_col=${2:-$text_col}

  for code in 332 304 304 371 371 371 372 300 304 304 371 372; do
    local varname=char_$code
    : ${(P)varname=$(echo -n "\\0$code")}
  done

  local text="%{$fg_no_bold[$text_col]%}"
  local parens="%{$fg_bold[$parens_col]%}"
  local punctuation_color="%{$fg_bold[grey]%}"
  local reset="%{$reset_color%}"

  PS1="$punctuation_colorÚ$textÄ$parens($text%n$punctuation_color@$text%m$parens)$textÄ$parens($text%!$punctuation_color/$text%y$parens)$textÄ$parens($text%D{%I:%M%P}$punctuation_color:$text%D{%m/%d/%y}$parens)$textÄ$punctuation_color-$reset$prompt_newline$punctuation_colorÀ$textÄ$parens($text%#$punctuation_color:$text%~$parens)$textÄ$punctuation_color-$reset " 

  PS2="$parensÄ$textÄ$punctuation_color-$reset "

  precmd () { setopt promptsubst }
  preexec () { }
}

prompt_elite2_preview () {
  local color colors
  colors=(red yellow green blue magenta)

  if (( ! $#* )); then
    for (( i = 1; i <= $#colors; i++ )); do
      color=$colors[$i]
      prompt_preview_theme elite2 $color
      (( i < $#colors )) && print
    done
  else
    prompt_preview_theme elite2 "$@"
  fi
}

prompt_elite2_setup "$@"