add the functions needed for some keybindings
[zsh.git] / .zsh / functions / path
1 # -*- mode:sh -*-
2
3 # idea from
4 # http://zanshin.net/2013/02/02/zsh-configuration-from-the-ground-up/
5 # -------------------------------------------------------------------
6 # display a neatly formatted path
7 # -------------------------------------------------------------------
8
9 emulate -L zsh
10 local pcolor ppath arg
11
12 arg=${1:-"path"}
13
14 typeset -A pcolor
15 zstyle -a ':ganneff:config' pcolor pcolor || \
16 pcolor=(
17 /usr green
18 /bin blue
19 /opt cyan
20 /sbin magenta
21 /local yellow
22 /zsh white
23 )
24
25 ppath=${(P)arg}
26 for key value in ${(kv)pcolor}; do
27 ppath=${(%)${(@)ppath//${key}/${(P)${(U)value}}${key}${reset_color}}}
28 done
29
30 print -l ${=ppath}