summaryrefslogtreecommitdiff
path: root/11_Colors.zsh
blob: 0e4d2933df3b3d32e93767f864eee510960dc247 (plain)
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
##
## Part of configuration files for Zsh 4
## by Hugues Hiegel <hugues@hiegel.fr>
## 
## NO WARRANTY PROVIDED, USE AT YOUR OWN RISKS
##
## You are encouraged to use, modify, and redistribute
## these files with or without this notice.
## 

typeset -A _prompt_colors _gcl_colors _mail_colors _correct_colors _battery_colors _date_colors _agent_colors _guilt_colors

_correct_colors[error]="$color[red];$color[bold]"
_correct_colors[suggest]="$color[blue];$color[bold]"

# This func is intended to give a quick way to reset the colors
# from a running zsh-session
#
sc ()
{
    C=""
    for c in $( echo $@ | tr ';' ' ' )
    do
        c=${$(echo "$c" | sed 's/^[0-9]$/0\0/;/^[0-9]\{2\}$/!d'):-$color[$c]}
        C+=${C:+;}${c:-00}
    done
    __set_prompt_colors $C
}

__set_prompt_colors ()
{
	# Forces HBAR re-generation with new colors..
	_COLUMNS_OLD=0

	local my_generic
	# Get the generic color from cmdline, else from envvar...
	my_generic=${1:-$_prompt_colors[generic]}
	# ...then stores it to envvar. :)
	_prompt_colors[generic]=$my_generic

	# Get soft and bold values of generic color, whichever it is bold or not
	_prompt_colors[bold_generic]="$(echo "$_prompt_colors[generic]" | tr ';' '\n' | grep -v "^$color[bold]$" | tr '\n' ';' | sed 's/\;$//');$color[bold]"
	_prompt_colors[soft_generic]="$(echo "$_prompt_colors[generic]" | tr ';' '\n' | grep -v "^$color[bold]$" | tr '\n' ';' | sed 's/\;$//')"

	_prompt_colors[path]="$_prompt_colors[generic];$color[bold]"			# pwd - bold generic
	#_prompt_colors[term]="$_prompt_colors[generic]"							# tty - unused, see term title
	_prompt_colors[user]="$_prompt_colors[generic]"							# login - generic
	_prompt_colors[host]="$_prompt_colors[generic]"							# hostname - generic
	_prompt_colors[display]="$_prompt_colors[generic]"							# hostname - generic
	#_prompt_colors[hist]="$color[none]"									# history number - unused
	_prompt_colors[arob]="$color[bold];$_prompt_colors[generic]"	# <login>@<hostname> - bold generic
	_prompt_colors[dies]="$_prompt_colors[generic]"							# the bottom-end of the prompt - generic
	_prompt_colors[doubledot]="$color[none]"							# separates pwd from git-branch - none
	#_prompt_colors[paren]="$color[cyan]"					# parenthesis (around tty) - unused, see term title
	_prompt_colors[bar]="$_prompt_colors[generic];$color[bold]"				# horizontal bar - bold generic
	_prompt_colors[braces]="$_prompt_colors[bar]"							# braces (around date) - bar color
	_prompt_colors[error]="$color[bold];$color[yellow]"					# error code - bold yellow

	_prompt_colors[warning]="$color[bold];$color[yellow]"

	_date_colors[normal]=$_prompt_colors[soft_generic]
	_date_colors[exec]=$_prompt_colors[bold_generic]

	_prompt_colors[cmd]="$color[none]"									# command prompt
	_prompt_colors[exec]="$color[none]"									# command output

	_battery_colors[full]="$_prompt_colors[soft_generic]"
	_battery_colors[charging]="$_prompt_colors[bold_generic]"
	_battery_colors[uncharging]="$_prompt_colors[soft_generic]"
	_battery_colors[critical]="$color[bg-red];$_prompt_colors[bold_generic]"

	_mail_colors[unread]="$color[yellow];$color[bold]"		# mail received
	_mail_colors[listes]="$_prompt_colors[generic];$color[bold]"		# less important mail received

	_agent_colors[empty]="$_prompt_colors[soft_generic]"
	_agent_colors[remote_empty]="$color[bold];$color[black]"
	_agent_colors[has_keys]="$_prompt_colors[bold_generic]"
	_agent_colors[has_remote_keys]="$_prompt_colors[bold_generic]"
	_agent_colors[id_dsa]="$color[bold];$color[yellow]"

	_gcl_colors[init]="$color[black];$color[bold]"
	_gcl_colors[gitdir]="$color[red];$color[bold]"
	_gcl_colors[uptodate]="$_prompt_colors[generic]"
	_gcl_colors[merging]="$color[bg-black]"
	_gcl_colors[changed]="$color[green]"
	_gcl_colors[cached]="$color[yellow];$color[bold]"
	_gcl_colors[mixed]="$color[green];$color[bold]"
	_gcl_colors[stashes]="$color[white]"
	_gcl_colors[ffwd]="$color[red];$color[bold]"
	_gcl_colors[untracked]="$color[black];$color[bold]"
	_gcl_colors[bisect-good]="$color[blue]"
	_gcl_colors[bisect-bad]="$color[red];$color[bold]"

	_guilt_colors[applied]=$_gcl_colors[cached]
	_guilt_colors[unapplied]=$color[black]
}