summaryrefslogtreecommitdiff
path: root/etc/unicode
blob: a846499cdb930c6d85e9c7eddcded799ccac7359 (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
## vim:ft=zsh
## This snippet serves two purposes:
##  - it offers a central place to manage 'special' characters
##  - it's used to enable / disable unicode
##
## The parameter unicode decides whether unicode is used or not,
## the default is to use unicode.
##
## In the associative array chars, the 'special' characters are stored.
## Each entry contains two characters, the first is ASCII,
## the second may be unicode.
##
## To get a ascii-/unicode-char, the function zchar is used, which outputs a
## character based on the setting of the unicode parameter
##
## disable unicode: unicode=0; reload
## disable ALL unicode, even in PS4 and such: unicode=0 zsh
##
## Note: This only affects zsh, for other programs set $LANG or similar

typeset -A chars
typeset unicode=${unicode-1}
chars=(
	compdelim '-·'
	prompt-user-ok '>>' # ▶?
	prompt-user-nz '>>' # ▷?
	prompt-root-ok '##'
	prompt-root-nz '##'
)

function zchar () {
	typeset char=$1
	if (( unicode == 1 )) {
		echo -n - ${chars[$char][2]}
	} else {
		echo -n - ${chars[$char][1]}
	}
}